diff --git a/src/main/java/net/silentclient/client/gui/multiplayer/SilentMultiplayerGui.java b/src/main/java/net/silentclient/client/gui/multiplayer/SilentMultiplayerGui.java index a02baa6..fd2eb0c 100644 --- a/src/main/java/net/silentclient/client/gui/multiplayer/SilentMultiplayerGui.java +++ b/src/main/java/net/silentclient/client/gui/multiplayer/SilentMultiplayerGui.java @@ -141,7 +141,7 @@ public class SilentMultiplayerGui extends SilentScreen { continue; } if(MouseUtils.isInside(blockX + 5, (int) serverY, blockX + 5, blockY + 43, blockWidth - 10, blockHeight - 43 - 39) || MouseUtils.isInside(blockX + 5, (int) serverY + 38, blockX + 5, blockY + 43, blockWidth - 10, blockHeight - 43 - 39)) { - MouseCursorHandler.CursorType cursor = serverComponent.draw(mouseX, mouseY, blockX + 5, serverY, serverIndex == selectedServer); + MouseCursorHandler.CursorType cursor = serverComponent.draw(serverIndex, mouseX, mouseY, blockX + 5, serverY, serverIndex == selectedServer); if(cursor != null) { cursorType = cursor; } @@ -164,6 +164,54 @@ public class SilentMultiplayerGui extends SilentScreen { } } + public boolean canUpSwap(int index) + { + return index > 0; + } + + public boolean canDownSwap(int index) + { + return index < this.savedServerList.countServers() - 1; + } + + public void swapUp(int index, boolean fullSwap) + { + int i = fullSwap ? 0 : index - 1; + this.savedServerList.swapServers(index, i); + + if (this.selectedServer == index) + { + this.selectServer(i); + } + + servers.clear(); + for (int i1 = 0; i1 < savedServerList.countServers(); ++i1) + { + ServerData serverData = savedServerList.getServerData(i1); + + servers.add(new ServerComponent(this, serverData)); + } + } + + public void swapDown(int index, boolean fullSwap) + { + int i = fullSwap ? this.savedServerList.countServers() - 1 : index + 1; + this.savedServerList.swapServers(index, i); + + if (this.selectedServer == index) + { + this.selectServer(i); + } + + servers.clear(); + for (int i1 = 0; i1 < savedServerList.countServers(); ++i1) + { + ServerData serverData = savedServerList.getServerData(i1); + + servers.add(new ServerComponent(this, serverData)); + } + } + @Override protected void actionPerformed(GuiButton button) throws IOException { super.actionPerformed(button); @@ -247,6 +295,9 @@ public class SilentMultiplayerGui extends SilentScreen { } if((MouseUtils.isInside(blockX + 5, (int) serverY, blockX + 5, blockY + 43, blockWidth - 10, blockHeight - 43 - 39) || MouseUtils.isInside(blockX + 5, (int) serverY + 38, blockX + 5, blockY + 43, blockWidth - 10, blockHeight - 43 - 39)) && isReset) { isReset = !serverComponent.mouseClicked(serverIndex, mouseX, mouseY, blockX + 5, serverY, serverIndex == selectedServer); + if(!isReset) { + break; + } } serverY += 38; } diff --git a/src/main/java/net/silentclient/client/gui/multiplayer/components/ServerComponent.java b/src/main/java/net/silentclient/client/gui/multiplayer/components/ServerComponent.java index 45ac645..a6df2cd 100644 --- a/src/main/java/net/silentclient/client/gui/multiplayer/components/ServerComponent.java +++ b/src/main/java/net/silentclient/client/gui/multiplayer/components/ServerComponent.java @@ -8,6 +8,7 @@ import io.netty.buffer.Unpooled; import io.netty.handler.codec.base64.Base64; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.texture.DynamicTexture; @@ -52,7 +53,7 @@ public class ServerComponent { this.field_148305_h = (DynamicTexture)this.mc.getTextureManager().getTexture(this.serverIcon); } - public MouseCursorHandler.CursorType draw(int mouseX, int mouseY, float x, float y, boolean isSelected) { + public MouseCursorHandler.CursorType draw(int serverIndex, int mouseX, int mouseY, float x, float y, boolean isSelected) { MouseCursorHandler.CursorType cursorType = null; if (!this.server.field_78841_f) { @@ -96,6 +97,17 @@ public class ServerComponent { } RenderUtil.drawImage(this.field_148305_h != null ? serverIcon : UNKNOWN_SERVER, x + 2, y + 2, 31, 31, false); + + if(MouseUtils.isInside(mouseX, mouseY, x + 2, y + 2, 31, 31)) { + if(this.owner.canUpSwap(serverIndex)) { + RenderUtil.drawImage(new ResourceLocation("silentclient/icons/page-up.png"), x + 2 + (31 / 2) - (15 / 2), y + 2, 15, 15, true, MouseUtils.isInside(mouseX, mouseY, x + 2 + (31 / 2) - (15 / 2), y + 2, 15, 15) ? new Color(255, 255, 255).getRGB() : Theme.borderColor().getRGB()); + } + + if(this.owner.canDownSwap(serverIndex)) { + RenderUtil.drawImage(new ResourceLocation("silentclient/icons/page-down.png"), x + 2 + (31 / 2) - (15 / 2), y + 2 + 31 - 16, 15, 15, true, MouseUtils.isInside(mouseX, mouseY, x + 2 + (31 / 2) - (15 / 2), y + 2 + 31 - 16, 15, 15) ? new Color(255, 255, 255).getRGB() : Theme.borderColor().getRGB()); + } + } + mc.fontRendererObj.drawString(server.serverName, x + 2 + 31 + 3, (int) y + 3, -1, true); List list = this.mc.fontRendererObj.listFormattedStringToWidth(this.server.serverMOTD, 240 - 36); @@ -187,6 +199,19 @@ public class ServerComponent { public boolean mouseClicked(int serverIndex, int mouseX, int mouseY, float x, float y, boolean isSelected) { boolean isHovered = MouseUtils.isInside(mouseX, mouseY, x, y, 240, 35); if(isHovered) { + if(MouseUtils.isInside(mouseX, mouseY, x + 2, y + 2, 31, 31)) { + if(this.owner.canUpSwap(serverIndex) && MouseUtils.isInside(mouseX, mouseY, x + 2 + (31 / 2) - (15 / 2), y + 2, 15, 15)) { + Client.logger.info("Swapping server " + serverIndex + " to up"); + this.owner.swapUp(serverIndex, GuiScreen.isShiftKeyDown()); + return isHovered; + } + + if(this.owner.canDownSwap(serverIndex) && MouseUtils.isInside(mouseX, mouseY, x + 2 + (31 / 2) - (15 / 2), y + 2 + 31 - 16, 15, 15)) { + Client.logger.info("Swapping server " + serverIndex + " to down"); + this.owner.swapDown(serverIndex, GuiScreen.isShiftKeyDown()); + return isHovered; + } + } if(!isSelected) { this.owner.selectServer(serverIndex); } else { diff --git a/src/main/resources/assets/minecraft/silentclient/icons/hazard.png b/src/main/resources/assets/minecraft/silentclient/icons/hazard.png new file mode 100755 index 0000000..3c4f66b Binary files /dev/null and b/src/main/resources/assets/minecraft/silentclient/icons/hazard.png differ diff --git a/src/main/resources/assets/minecraft/silentclient/icons/page-down.png b/src/main/resources/assets/minecraft/silentclient/icons/page-down.png new file mode 100755 index 0000000..2b2d70a Binary files /dev/null and b/src/main/resources/assets/minecraft/silentclient/icons/page-down.png differ diff --git a/src/main/resources/assets/minecraft/silentclient/icons/page-left.png b/src/main/resources/assets/minecraft/silentclient/icons/page-left.png new file mode 100755 index 0000000..22df32f Binary files /dev/null and b/src/main/resources/assets/minecraft/silentclient/icons/page-left.png differ diff --git a/src/main/resources/assets/minecraft/silentclient/icons/page-right.png b/src/main/resources/assets/minecraft/silentclient/icons/page-right.png new file mode 100755 index 0000000..50f891c Binary files /dev/null and b/src/main/resources/assets/minecraft/silentclient/icons/page-right.png differ diff --git a/src/main/resources/assets/minecraft/silentclient/icons/page-up.png b/src/main/resources/assets/minecraft/silentclient/icons/page-up.png new file mode 100755 index 0000000..6ac7706 Binary files /dev/null and b/src/main/resources/assets/minecraft/silentclient/icons/page-up.png differ