Skip to content

Commit

Permalink
Update TeleportsPage.java
Browse files Browse the repository at this point in the history
adjustments related to #796 and #795
  • Loading branch information
Thutmose committed Oct 3, 2021
1 parent 3fdd012 commit b92443e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/pokecube/core/client/gui/watch/TeleportsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public boolean keyPressed(final int keyCode, final int p_keyPressed_2_, final in
{
PacketPokedex.sendRenameTelePacket(this.text.getValue(), this.dest.index);
this.dest.setName(this.text.getValue());
this.text.setFocused(false);
return true;
}
return false;
Expand All @@ -109,6 +110,7 @@ public boolean charTyped(final char typedChar, final int keyCode)
{
PacketPokedex.sendRenameTelePacket(this.text.getValue(), this.dest.index);
this.dest.setName(this.text.getValue());
this.text.setFocused(false);
return true;
}
return super.charTyped(typedChar, keyCode);
Expand All @@ -118,11 +120,11 @@ public boolean charTyped(final char typedChar, final int keyCode)
public boolean mouseClicked(final double mouseX, final double mouseY, final int mouseEvent)
{
boolean fits = true;
fits = this.text.y >= this.offsetY;
fits = fits && mouseX - this.text.x >= 0;
fits = fits && mouseX - this.text.x <= this.text.getWidth();
fits = fits && this.text.y + this.text.getHeight() <= this.offsetY + this.guiHeight;
this.text.setFocused(fits);
if (fits) for (final TeleOption o : this.parent.list.children())
if (o != this) o.text.setFocused(false);
if (this.delete.isMouseOver(mouseX, mouseY))
{
this.delete.playDownSound(this.mc.getSoundManager());
Expand Down Expand Up @@ -197,9 +199,12 @@ public TeleportsPage(final GuiPokeWatch watch)
TeleportsPage.TEX_NM);
}

protected double scroll = 0;

@Override
public void initList()
{
if (this.list != null) this.scroll = this.list.getScrollAmount();
super.initList();
this.locations = TeleportHandler.getTeleports(this.watch.player.getStringUUID());
final int offsetX = (this.watch.width - GuiPokeWatch.GUIW) / 2 + 55;
Expand All @@ -214,5 +219,6 @@ public void initList()
this.list.addEntry(new TeleOption(this.minecraft, offsetY, d, name, height, this));
}
this.children.add(this.list);
this.list.setScrollAmount(this.scroll);
}
}

0 comments on commit b92443e

Please sign in to comment.