Add interaction indicators to the tribe selection gui

This commit is contained in:
Sollace 2023-11-25 20:12:54 +00:00
parent 277753b81b
commit cb94d3c841
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
2 changed files with 23 additions and 2 deletions

View file

@ -14,6 +14,7 @@ import com.minelittlepony.unicopia.network.Channel;
import com.minelittlepony.unicopia.network.MsgRequestSpeciesChange; import com.minelittlepony.unicopia.network.MsgRequestSpeciesChange;
import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.DrawContext;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Formatting; import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@ -110,7 +111,7 @@ public class TribeSelectionScreen extends GameGui implements HidesHud {
private void updateScolling() { private void updateScolling() {
final int itemWidth = 70 + 10; final int itemWidth = 70 + 10;
int x = (width - itemWidth) / 2; int x = (width - itemWidth) / 2;
float diff = MathHelper.lerp(client.getTickDelta(), prevScrollPosition, scrollPosition) / 8F; float diff = MathHelper.lerp(client.getTickDelta(), prevScrollPosition, scrollPosition) / 4F;
for (int i = 0; i < options.size(); i++) { for (int i = 0; i < options.size(); i++) {
var option = options.get(i); var option = options.get(i);
@ -124,6 +125,21 @@ public class TribeSelectionScreen extends GameGui implements HidesHud {
updateScolling(); updateScolling();
renderBackground(context); renderBackground(context);
super.render(context, mouseX, mouseY, delta); super.render(context, mouseX, mouseY, delta);
if (!options.isEmpty()) {
var element = options.get(0);
float diff = (targetScroll - MathHelper.lerp(client.getTickDelta(), prevScrollPosition, scrollPosition)) * 7;
context.drawTexture(TEXTURE, (width / 2) + 40 + (scrollPosition < targetScroll ? (int)diff : 0), element.getY() - 20, 10, 165, 153, 30, 85, 312, 312);
context.drawTexture(TEXTURE, (width / 2) - 80 + (scrollPosition > targetScroll ? (int)diff : 0), element.getY() - 20, 10, 195, 153, 30, 85, 312, 312);
if (element.getBounds().left < 0) {
context.drawTexture(TEXTURE, 20, element.getY() - 10, 10, 188, 235, 24, 60, 312, 312);
}
element = options.get(options.size() - 1);
if (element.getBounds().right() > width) {
context.drawTexture(TEXTURE, width - 50, element.getY() - 10, 10, 164, 235, 24, 60, 312, 312);
}
}
} }
@Override @Override
@ -151,11 +167,16 @@ public class TribeSelectionScreen extends GameGui implements HidesHud {
} }
private void scroll(int target, boolean animate) { private void scroll(int target, boolean animate) {
if (target == SELECTION) {
return;
}
SELECTION = target; SELECTION = target;
targetScroll = SELECTION * 8; targetScroll = SELECTION * 4;
if (!animate) { if (!animate) {
scrollPosition = targetScroll; scrollPosition = targetScroll;
prevScrollPosition = scrollPosition; prevScrollPosition = scrollPosition;
} else {
playSound(SoundEvents.UI_BUTTON_CLICK);
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB