mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 11:36:43 +01:00
Add interaction indicators to the tribe selection gui
This commit is contained in:
parent
277753b81b
commit
cb94d3c841
2 changed files with 23 additions and 2 deletions
|
@ -14,6 +14,7 @@ import com.minelittlepony.unicopia.network.Channel;
|
|||
import com.minelittlepony.unicopia.network.MsgRequestSpeciesChange;
|
||||
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
@ -110,7 +111,7 @@ public class TribeSelectionScreen extends GameGui implements HidesHud {
|
|||
private void updateScolling() {
|
||||
final int itemWidth = 70 + 10;
|
||||
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++) {
|
||||
var option = options.get(i);
|
||||
|
@ -124,6 +125,21 @@ public class TribeSelectionScreen extends GameGui implements HidesHud {
|
|||
updateScolling();
|
||||
renderBackground(context);
|
||||
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
|
||||
|
@ -151,11 +167,16 @@ public class TribeSelectionScreen extends GameGui implements HidesHud {
|
|||
}
|
||||
|
||||
private void scroll(int target, boolean animate) {
|
||||
if (target == SELECTION) {
|
||||
return;
|
||||
}
|
||||
SELECTION = target;
|
||||
targetScroll = SELECTION * 8;
|
||||
targetScroll = SELECTION * 4;
|
||||
if (!animate) {
|
||||
scrollPosition = targetScroll;
|
||||
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 |
Loading…
Reference in a new issue