Fixed tribe selection gui not scrolling to the correct position when opening

This commit is contained in:
Sollace 2024-02-12 17:45:03 +00:00
parent cdcbfea8dc
commit db53f4906e
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB

View file

@ -71,10 +71,7 @@ public class TribeSelectionScreen extends GameGui implements HidesHud {
addOption(race, top); addOption(race, top);
} }
if (SELECTION == -1) { scroll(SELECTION == -1 ? options.size() / 2 : SELECTION, false);
SELECTION = options.size() / 2;
}
scroll(SELECTION, false);
} }
private void addOption(Race race, int y) { private void addOption(Race race, int y) {
@ -167,11 +164,12 @@ public class TribeSelectionScreen extends GameGui implements HidesHud {
} }
private void scroll(int target, boolean animate) { private void scroll(int target, boolean animate) {
if (target == SELECTION) { SELECTION = target;
target *= 4;
if (targetScroll == target) {
return; return;
} }
SELECTION = target; targetScroll = target;
targetScroll = SELECTION * 4;
if (!animate) { if (!animate) {
scrollPosition = targetScroll; scrollPosition = targetScroll;
prevScrollPosition = scrollPosition; prevScrollPosition = scrollPosition;