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);
}
if (SELECTION == -1) {
SELECTION = options.size() / 2;
}
scroll(SELECTION, false);
scroll(SELECTION == -1 ? options.size() / 2 : SELECTION, false);
}
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) {
if (target == SELECTION) {
SELECTION = target;
target *= 4;
if (targetScroll == target) {
return;
}
SELECTION = target;
targetScroll = SELECTION * 4;
targetScroll = target;
if (!animate) {
scrollPosition = targetScroll;
prevScrollPosition = scrollPosition;