fix maxscrolloffset

This commit is contained in:
yugecin 2017-01-29 14:19:54 +01:00
parent e476ed5c62
commit 04405b7289

View File

@ -271,10 +271,8 @@ public class OptionsOverlay extends OverlayOpsuState {
int y = -scrollOffset + optionStartY; int y = -scrollOffset + optionStartY;
maxScrollOffset = optionStartY; maxScrollOffset = optionStartY;
boolean render = true; boolean render = true;
int lastNonSkippedSectionIndex = 0;
int sectionIndex = 0; int sectionIndex = 0;
for (; sectionIndex < sections.length; sectionIndex++) { for (; sectionIndex < sections.length && render; sectionIndex++) {
lastNonSkippedSectionIndex = sectionIndex;
OptionTab section = sections[sectionIndex]; OptionTab section = sections[sectionIndex];
if (section.filtered) { if (section.filtered) {
continue; continue;
@ -298,7 +296,7 @@ public class OptionsOverlay extends OverlayOpsuState {
if (!option.showCondition() || option.isFiltered()) { if (!option.showCondition() || option.isFiltered()) {
continue; continue;
} }
if ((y > -optionHeight && render) || (isListOptionOpen && hoverOption == option)) { if (y > -optionHeight || (isListOptionOpen && hoverOption == option)) {
renderOption(g, option, y); renderOption(g, option, y);
} }
y += optionHeight; y += optionHeight;
@ -306,15 +304,15 @@ public class OptionsOverlay extends OverlayOpsuState {
lineHeight += optionHeight; lineHeight += optionHeight;
if (y > height) { if (y > height) {
render = false; render = false;
sectionIndex = sections.length;
maxScrollOffset += (section.options.length - optionIndex - 1) * optionHeight; maxScrollOffset += (section.options.length - optionIndex - 1) * optionHeight;
break;
} }
} }
g.setColor(COL_GREY); g.setColor(COL_GREY);
g.fillRect(paddingLeft, lineStartY, LINEWIDTH, lineHeight); g.fillRect(paddingLeft, lineStartY, LINEWIDTH, lineHeight);
} }
// iterate over skipped options to correctly calculate max scroll offset // iterate over skipped options to correctly calculate max scroll offset
for (sectionIndex = lastNonSkippedSectionIndex + 1; sectionIndex < sections.length; sectionIndex++) { for (; sectionIndex < sections.length; sectionIndex++) {
maxScrollOffset += Fonts.LARGE.getLineHeight() * 1.5f; maxScrollOffset += Fonts.LARGE.getLineHeight() * 1.5f;
if (sections[sectionIndex].options != null) { if (sections[sectionIndex].options != null) {
maxScrollOffset += sections[sectionIndex].options.length * optionHeight; maxScrollOffset += sections[sectionIndex].options.length * optionHeight;