mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 07:11:31 +01:00
commit
c7c7b12f07
@ -43,9 +43,6 @@ public class NewOutfitModal extends SilentScreen {
|
||||
this.buttonList.add(new IconButton(1, x + this.modalWidth - 14 - 3, y + 3, 14, 14, 8, 8, new ResourceLocation("silentclient/icons/exit.png")));
|
||||
this.buttonList.add(new Button(2, x + 3, y + this.modalHeight - 23, this.modalWidth - 6, 20, "Done"));
|
||||
this.silentInputs.add(new Input("Outfit Name"));
|
||||
if(mc.thePlayer == null) {
|
||||
Client.backgroundPanorama.updateWidthHeight(this.width, this.height);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,16 +1,12 @@
|
||||
package net.silentclient.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiMultiplayer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiScreenServerList;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.silentclient.client.mixin.ducks.GuiMultiplayerExt;
|
||||
import net.silentclient.client.gui.multiplayer.SilentMultiplayerGui;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GuiMultiplayerInGame extends GuiMultiplayer {
|
||||
public class GuiMultiplayerInGame extends SilentMultiplayerGui {
|
||||
|
||||
public GuiMultiplayerInGame(GuiScreen parentScreen) {
|
||||
super(parentScreen);
|
||||
@ -22,12 +18,6 @@ public class GuiMultiplayerInGame extends GuiMultiplayer {
|
||||
disconnect();
|
||||
}
|
||||
|
||||
if(button.id == 4) {
|
||||
((GuiMultiplayerExt) this).silent$setDirectConnect(true);
|
||||
((GuiMultiplayerExt) this).silent$setSelectedServer(new ServerData(I18n.format("selectServer.defaultName"), "", false));
|
||||
this.mc.displayGuiScreen(new GuiScreenServerList(this, new ServerData(I18n.format("selectServer.defaultName"), "", false)));
|
||||
}
|
||||
|
||||
super.actionPerformed(button);
|
||||
}
|
||||
|
||||
@ -42,7 +32,7 @@ public class GuiMultiplayerInGame extends GuiMultiplayer {
|
||||
this.mc.theWorld.sendQuittingDisconnectingPacket();
|
||||
this.mc.loadWorld(null);
|
||||
this.mc.displayGuiScreen(null);
|
||||
((GuiMultiplayerExt) this).silent$setParentScreen(null);
|
||||
this.setParentScreen(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
|
||||
import net.silentclient.client.gui.silentmainmenu.MainMenuConcept;
|
||||
import net.silentclient.client.gui.util.RenderUtil;
|
||||
import net.silentclient.client.utils.FileUtils;
|
||||
import net.silentclient.client.utils.MouseCursorHandler;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
@ -25,6 +26,7 @@ public class UserTutorial extends SilentScreen {
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
defaultCursor = false;
|
||||
this.configs.clear();
|
||||
this.buttonList.clear();
|
||||
Client.backgroundPanorama.updateWidthHeight(this.width, this.height);
|
||||
@ -42,6 +44,7 @@ public class UserTutorial extends SilentScreen {
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
MouseCursorHandler.CursorType cursorType = getCursor(silentInputs, buttonList);
|
||||
GlStateManager.disableAlpha();
|
||||
Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks);
|
||||
GlStateManager.enableAlpha();
|
||||
@ -54,6 +57,9 @@ public class UserTutorial extends SilentScreen {
|
||||
}
|
||||
RenderUtils.drawRect(blockX, blockY, 350, 180, new Color(20, 20, 20).getRGB());
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
if(MouseUtils.isInside(mouseX, mouseY, blockX + (350 / 2) - (Client.getInstance().getSilentFontRenderer().getStringWidth("Skip Tutorial", 10, SilentFontRenderer.FontType.TITLE) / 2), blockY + 180 - 12, Client.getInstance().getSilentFontRenderer().getStringWidth("Skip Tutorial", 10, SilentFontRenderer.FontType.TITLE), 10)) {
|
||||
cursorType = MouseCursorHandler.CursorType.POINTER;
|
||||
}
|
||||
Client.getInstance().getSilentFontRenderer().drawCenteredString("Skip Tutorial", blockX + (350 / 2), blockY + 180 - 12, 10, SilentFontRenderer.FontType.TITLE);
|
||||
switch (step) {
|
||||
case 1:
|
||||
@ -69,7 +75,9 @@ public class UserTutorial extends SilentScreen {
|
||||
this.buttonList.get(0).displayString = "Next";
|
||||
|
||||
Client.getInstance().getSilentFontRenderer().drawCenteredString("Choose a version of Silent Client", blockX + (350 / 2), blockY + 3, 16, SilentFontRenderer.FontType.TITLE);
|
||||
|
||||
if(MouseUtils.isInside(mouseX, mouseY, blockX + 9, blockY + 29, 161, 102) || MouseUtils.isInside(mouseX, mouseY, blockX + 180, blockY + 29, 161, 102)) {
|
||||
cursorType = MouseCursorHandler.CursorType.POINTER;
|
||||
}
|
||||
if(!Client.getInstance().getGlobalSettings().isLite()) {
|
||||
RenderUtils.drawRect(blockX + 9, blockY + 29, 161, 102, -1);
|
||||
}
|
||||
@ -85,7 +93,9 @@ public class UserTutorial extends SilentScreen {
|
||||
this.buttonList.get(0).displayString = "Next";
|
||||
|
||||
Client.getInstance().getSilentFontRenderer().drawCenteredString("Choose a config preset", blockX + (350 / 2), blockY + 3, 16, SilentFontRenderer.FontType.TITLE);
|
||||
|
||||
if(MouseUtils.isInside(mouseX, mouseY, blockX + 60, blockY + 35 + 50 - 10, 20, 20) || MouseUtils.isInside(mouseX, mouseY, blockX + 95 + 159 + 15, blockY + 35 + 50 - 10, 20, 20)) {
|
||||
cursorType = MouseCursorHandler.CursorType.POINTER;
|
||||
}
|
||||
RenderUtil.drawImage(new ResourceLocation("silentclient/icons/back.png"), blockX + 60, blockY + 35 + 50 - 10, 20, 20);
|
||||
RenderUtil.drawImage(new ResourceLocation("silentclient/icons/next.png"), blockX + 95 + 159 + 15, blockY + 35 + 50 - 10, 20, 20);
|
||||
|
||||
@ -94,6 +104,8 @@ public class UserTutorial extends SilentScreen {
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Client.getInstance().getMouseCursorHandler().enableCursor(cursorType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -139,10 +139,13 @@ public class Input {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
String test = "";
|
||||
if (GuiScreen.isKeyComboCtrlV(keyCode))
|
||||
{
|
||||
setValue(GuiScreen.getClipboardString());
|
||||
test += GuiScreen.getClipboardString();
|
||||
if(this.pattern.matcher(test).matches()) {
|
||||
value += ChatAllowedCharacters.filterAllowedCharacters(test);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -150,8 +153,6 @@ public class Input {
|
||||
NotificationUtils.showNotification("Error", "Maximum " + name + " size " + maxLength + " characters");
|
||||
return;
|
||||
}
|
||||
|
||||
String test = "";
|
||||
test += typedChar;
|
||||
|
||||
if(this.pattern.matcher(test).matches()) {
|
||||
|
@ -91,6 +91,7 @@ public class GuiConnecting extends SilentScreen
|
||||
}
|
||||
catch (UnknownHostException unknownhostexception)
|
||||
{
|
||||
Client.logger.catching(unknownhostexception);
|
||||
if (GuiConnecting.this.cancel)
|
||||
{
|
||||
return;
|
||||
@ -101,6 +102,7 @@ public class GuiConnecting extends SilentScreen
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Client.logger.catching(exception);
|
||||
if (GuiConnecting.this.cancel)
|
||||
{
|
||||
return;
|
||||
|
@ -0,0 +1,158 @@
|
||||
package net.silentclient.client.gui.multiplayer;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.gui.SilentScreen;
|
||||
import net.silentclient.client.gui.elements.Button;
|
||||
import net.silentclient.client.gui.elements.IconButton;
|
||||
import net.silentclient.client.gui.elements.Input;
|
||||
import net.silentclient.client.gui.font.SilentFontRenderer;
|
||||
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
|
||||
import net.silentclient.client.gui.theme.Theme;
|
||||
import net.silentclient.client.utils.MenuBlurUtils;
|
||||
import net.silentclient.client.utils.NotificationUtils;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
public class AddServerGui extends SilentScreen {
|
||||
private final SilentMultiplayerGui parentScreen;
|
||||
private int modalWidth;
|
||||
private int modalHeight;
|
||||
private Button serverResourcePacks;
|
||||
private final ServerData serverData;
|
||||
private final boolean edit;
|
||||
private final int index;
|
||||
|
||||
public AddServerGui(SilentMultiplayerGui p_i1033_1_, ServerData p_i1033_2_, boolean edit, int index)
|
||||
{
|
||||
this.parentScreen = p_i1033_1_;
|
||||
this.serverData = p_i1033_2_;
|
||||
this.modalWidth = 200;
|
||||
this.modalHeight = 120;
|
||||
this.edit = edit;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public AddServerGui(SilentMultiplayerGui p_i1033_1_, ServerData p_i1033_2_, boolean edit)
|
||||
{
|
||||
this(p_i1033_1_, p_i1033_2_, edit, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
if(mc.thePlayer == null) {
|
||||
Client.backgroundPanorama.updateWidthHeight(this.width, this.height);
|
||||
} else {
|
||||
MenuBlurUtils.loadBlur();
|
||||
}
|
||||
int x = width / 2 - (this.modalWidth / 2);
|
||||
int y = height / 2 - (this.modalHeight / 2);
|
||||
this.buttonList.add(new IconButton(1, x + this.modalWidth - 14 - 3, y + 3, 14, 14, 8, 8, new ResourceLocation("silentclient/icons/exit.png")));
|
||||
this.buttonList.add(this.serverResourcePacks = new Button(2, x + 3, y + 23 + 25 + 25, this.modalWidth - 6, 20, "Server Resource Packs: " + this.serverData.getResourceMode().getMotd().getFormattedText()));
|
||||
this.buttonList.add(new Button(3, x + 3, y + this.modalHeight - 23, this.modalWidth - 6, 20, "Done"));
|
||||
this.silentInputs.add(new Input("Server Name", this.serverData.serverName));
|
||||
this.silentInputs.add(new Input("Server IP", this.serverData.serverIP));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
switch (button.id) {
|
||||
case 1:
|
||||
mc.displayGuiScreen(parentScreen);
|
||||
break;
|
||||
case 2:
|
||||
this.serverData.setResourceMode(ServerData.ServerResourceMode.values()[(this.serverData.getResourceMode().ordinal() + 1) % ServerData.ServerResourceMode.values().length]);
|
||||
this.serverResourcePacks.displayString = "Server Resource Packs: " + this.serverData.getResourceMode().getMotd().getFormattedText();
|
||||
break;
|
||||
case 3:
|
||||
if(this.silentInputs.get(0).getValue().trim().length() == 0) {
|
||||
NotificationUtils.showNotification("Error", "Please enter a Server Name");
|
||||
break;
|
||||
}
|
||||
if(this.silentInputs.get(1).getValue().trim().length() == 0) {
|
||||
NotificationUtils.showNotification("Error", "Please enter a Server IP");
|
||||
break;
|
||||
}
|
||||
this.serverData.serverName = this.silentInputs.get(0).getValue().trim();
|
||||
this.serverData.serverIP = this.silentInputs.get(1).getValue().trim();
|
||||
if(edit) {
|
||||
parentScreen.editServer(serverData, index);
|
||||
} else {
|
||||
parentScreen.getServerList().addServerData(serverData);
|
||||
parentScreen.getServerList().saveServerList();
|
||||
}
|
||||
parentScreen.refreshServerList();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
if(mc.thePlayer == null) {
|
||||
Client.backgroundPanorama.tickPanorama();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
if(mc.thePlayer == null) {
|
||||
GlStateManager.disableAlpha();
|
||||
Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks);
|
||||
GlStateManager.enableAlpha();
|
||||
if(Client.getInstance().getGlobalSettings().isLite()) {
|
||||
this.drawGradientRect(0, 0, this.width, this.height, new Color(0, 0, 0, 127).getRGB(), new Color(0, 0, 0, 200).getRGB());
|
||||
} else {
|
||||
this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE);
|
||||
}
|
||||
} else {
|
||||
MenuBlurUtils.renderBackground(this);
|
||||
}
|
||||
GlStateManager.pushMatrix();
|
||||
int x = width / 2 - (this.modalWidth / 2);
|
||||
int y = height / 2 - (this.modalHeight / 2);
|
||||
|
||||
// Header
|
||||
RenderUtils.drawRect(x, y, this.modalWidth, this.modalHeight, Theme.backgroundColor().getRGB());
|
||||
Client.getInstance().getSilentFontRenderer().drawString("Add Server", x + 3, y + 3, 14, SilentFontRenderer.FontType.TITLE);
|
||||
|
||||
// Content
|
||||
this.silentInputs.get(0).render(mouseX, mouseY, x + 3, y + 23, this.modalWidth - 6);
|
||||
this.silentInputs.get(1).render(mouseX, mouseY, x + 3, y + 23 + 25, this.modalWidth - 6);
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
int x = width / 2 - (this.modalWidth / 2);
|
||||
int y = height / 2 - (this.modalHeight / 2);
|
||||
this.silentInputs.get(0).onClick(mouseX, mouseY, x + 3, y + 23, this.modalWidth - 6);
|
||||
this.silentInputs.get(1).onClick(mouseX, mouseY, x + 3, y + 23 + 25, this.modalWidth - 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
MenuBlurUtils.unloadBlur();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
if (keyCode == Keyboard.KEY_ESCAPE) {
|
||||
mc.displayGuiScreen(parentScreen);
|
||||
return;
|
||||
};
|
||||
|
||||
this.silentInputs.get(0).onKeyTyped(typedChar, keyCode);
|
||||
this.silentInputs.get(1).onKeyTyped(typedChar, keyCode);
|
||||
}
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
package net.silentclient.client.gui.multiplayer;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.gui.SilentScreen;
|
||||
import net.silentclient.client.gui.elements.Button;
|
||||
import net.silentclient.client.gui.elements.IconButton;
|
||||
import net.silentclient.client.gui.elements.Input;
|
||||
import net.silentclient.client.gui.font.SilentFontRenderer;
|
||||
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
|
||||
import net.silentclient.client.gui.minecraft.GuiConnecting;
|
||||
import net.silentclient.client.gui.theme.Theme;
|
||||
import net.silentclient.client.utils.MenuBlurUtils;
|
||||
import net.silentclient.client.utils.NotificationUtils;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
public class DirectConnectGui extends SilentScreen {
|
||||
private final SilentMultiplayerGui parentScreen;
|
||||
private int modalWidth;
|
||||
private int modalHeight;
|
||||
private ServerData serverData;
|
||||
|
||||
public DirectConnectGui(SilentMultiplayerGui p_i1033_1_)
|
||||
{
|
||||
this.parentScreen = p_i1033_1_;
|
||||
this.modalWidth = 200;
|
||||
this.modalHeight = 70;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
serverData = new ServerData("", "", false);
|
||||
if(mc.thePlayer == null) {
|
||||
Client.backgroundPanorama.updateWidthHeight(this.width, this.height);
|
||||
} else {
|
||||
MenuBlurUtils.loadBlur();
|
||||
}
|
||||
int x = width / 2 - (this.modalWidth / 2);
|
||||
int y = height / 2 - (this.modalHeight / 2);
|
||||
this.buttonList.add(new IconButton(1, x + this.modalWidth - 14 - 3, y + 3, 14, 14, 8, 8, new ResourceLocation("silentclient/icons/exit.png")));
|
||||
this.buttonList.add(new Button(3, x + 3, y + this.modalHeight - 23, this.modalWidth - 6, 20, "Done"));
|
||||
this.silentInputs.add(new Input("Server IP", this.mc.gameSettings.lastServer != null ? this.mc.gameSettings.lastServer : ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
switch (button.id) {
|
||||
case 1:
|
||||
mc.displayGuiScreen(parentScreen);
|
||||
break;
|
||||
case 3:
|
||||
if(this.silentInputs.get(0).getValue().trim().length() == 0) {
|
||||
NotificationUtils.showNotification("Error", "Please enter a Server IP");
|
||||
break;
|
||||
}
|
||||
this.serverData.serverIP = this.silentInputs.get(0).getValue().trim();
|
||||
this.mc.gameSettings.lastServer = this.silentInputs.get(0).getValue().trim();
|
||||
this.mc.gameSettings.saveOptions();
|
||||
this.mc.displayGuiScreen(new GuiConnecting(parentScreen, this.mc, new ServerData(serverData.serverName, serverData.serverIP, false)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
if(mc.thePlayer == null) {
|
||||
Client.backgroundPanorama.tickPanorama();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
if(mc.thePlayer == null) {
|
||||
GlStateManager.disableAlpha();
|
||||
Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks);
|
||||
GlStateManager.enableAlpha();
|
||||
if(Client.getInstance().getGlobalSettings().isLite()) {
|
||||
this.drawGradientRect(0, 0, this.width, this.height, new Color(0, 0, 0, 127).getRGB(), new Color(0, 0, 0, 200).getRGB());
|
||||
} else {
|
||||
this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE);
|
||||
}
|
||||
} else {
|
||||
MenuBlurUtils.renderBackground(this);
|
||||
}
|
||||
GlStateManager.pushMatrix();
|
||||
int x = width / 2 - (this.modalWidth / 2);
|
||||
int y = height / 2 - (this.modalHeight / 2);
|
||||
|
||||
// Header
|
||||
RenderUtils.drawRect(x, y, this.modalWidth, this.modalHeight, Theme.backgroundColor().getRGB());
|
||||
Client.getInstance().getSilentFontRenderer().drawString("Direct Connect", x + 3, y + 3, 14, SilentFontRenderer.FontType.TITLE);
|
||||
|
||||
// Content
|
||||
this.silentInputs.get(0).render(mouseX, mouseY, x + 3, y + 23, this.modalWidth - 6);
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
int x = width / 2 - (this.modalWidth / 2);
|
||||
int y = height / 2 - (this.modalHeight / 2);
|
||||
this.silentInputs.get(0).onClick(mouseX, mouseY, x + 3, y + 23, this.modalWidth - 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
MenuBlurUtils.unloadBlur();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
if (keyCode == Keyboard.KEY_ESCAPE) {
|
||||
mc.displayGuiScreen(parentScreen);
|
||||
return;
|
||||
};
|
||||
|
||||
this.silentInputs.get(0).onKeyTyped(typedChar, keyCode);
|
||||
}
|
||||
}
|
@ -0,0 +1,378 @@
|
||||
package net.silentclient.client.gui.multiplayer;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.multiplayer.ServerList;
|
||||
import net.minecraft.client.network.OldServerPinger;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.gui.SilentScreen;
|
||||
import net.silentclient.client.gui.animation.SimpleAnimation;
|
||||
import net.silentclient.client.gui.elements.Button;
|
||||
import net.silentclient.client.gui.elements.Input;
|
||||
import net.silentclient.client.gui.font.SilentFontRenderer;
|
||||
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
|
||||
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
|
||||
import net.silentclient.client.gui.minecraft.GuiConnecting;
|
||||
import net.silentclient.client.gui.multiplayer.components.ServerComponent;
|
||||
import net.silentclient.client.gui.theme.Theme;
|
||||
import net.silentclient.client.mixin.ducks.ServerListExt;
|
||||
import net.silentclient.client.utils.MouseCursorHandler;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SilentMultiplayerGui extends SilentScreen {
|
||||
private final OldServerPinger oldServerPinger = new OldServerPinger();
|
||||
private int blockX = 0;
|
||||
private int blockY = 0;
|
||||
private int blockWidth = 0;
|
||||
private int blockHeight = 0;
|
||||
private GuiScreen parentScreen;
|
||||
private ServerList savedServerList;
|
||||
private Button btnEditServer;
|
||||
private Button btnSelectServer;
|
||||
private Button btnDeleteServer;
|
||||
private boolean initialized;
|
||||
private ArrayList<ServerComponent> servers = new ArrayList<>();
|
||||
private SimpleAnimation scrollAnimation = new SimpleAnimation(0.0F);
|
||||
private float scrollY = 0;
|
||||
private int selectedServer = -1;
|
||||
|
||||
public SilentMultiplayerGui(GuiScreen parentScreen) {
|
||||
this.parentScreen = parentScreen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
defaultCursor = false;
|
||||
Client.backgroundPanorama.updateWidthHeight(this.width, this.height);
|
||||
blockWidth = 250;
|
||||
blockHeight = height - 20;
|
||||
blockX = (width / 2) - (blockWidth / 2);
|
||||
blockY = 10;
|
||||
|
||||
if (!this.initialized) {
|
||||
this.initialized = true;
|
||||
this.savedServerList = new ServerList(this.mc);
|
||||
this.savedServerList.loadServerList();
|
||||
|
||||
servers.clear();
|
||||
for (int i = 0; i < savedServerList.countServers(); ++i)
|
||||
{
|
||||
ServerData serverData = savedServerList.getServerData(i);
|
||||
|
||||
servers.add(new ServerComponent(this, serverData));
|
||||
}
|
||||
}
|
||||
|
||||
this.silentInputs.clear();
|
||||
this.buttonList.clear();
|
||||
|
||||
this.silentInputs.add(new Input("Search", ""));
|
||||
|
||||
this.createButtons();
|
||||
}
|
||||
|
||||
public void createButtons()
|
||||
{
|
||||
this.buttonList.add(this.btnSelectServer = new Button(1, blockX + 5, blockY + blockHeight - 39, 77, 14, "Join Server"));
|
||||
this.buttonList.add(new Button(4, blockX + 5 + 5 + 77, blockY + blockHeight - 39, 77, 14, "Direct Connect"));
|
||||
this.buttonList.add(new Button(3, blockX + 5 + 5 + 77 + 5 + 77, blockY + blockHeight - 39, 77, 14, "Add Server"));
|
||||
this.buttonList.add(this.btnEditServer = new Button(7, blockX + 5, blockY + blockHeight - 20, 56, 14, "Edit"));
|
||||
this.buttonList.add(this.btnDeleteServer = new Button(2, blockX + 5 + 56 + 6, blockY + blockHeight - 20, 56, 14, "Delete"));
|
||||
this.buttonList.add(new Button(8, blockX + 5 + 56 + 6 + 56 + 6, blockY + blockHeight - 20, 56, 14, "Refresh"));
|
||||
this.buttonList.add(new Button(0, blockX + 5 + 56 + 6 + 56 + 6 + 56 + 5, blockY + blockHeight - 20, 56, 14, "Cancel"));
|
||||
this.selectServer(-1);
|
||||
}
|
||||
|
||||
public void selectServer(int index)
|
||||
{
|
||||
this.selectedServer = index;
|
||||
this.btnSelectServer.enabled = false;
|
||||
this.btnEditServer.enabled = false;
|
||||
this.btnDeleteServer.enabled = false;
|
||||
|
||||
if(index != -1) {
|
||||
ServerComponent serverComponent = this.servers.get(index);
|
||||
|
||||
if(serverComponent != null) {
|
||||
this.btnSelectServer.enabled = true;
|
||||
this.btnEditServer.enabled = true;
|
||||
this.btnDeleteServer.enabled = true;
|
||||
} else {
|
||||
Client.logger.info("Server " + index + " not found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
MouseCursorHandler.CursorType cursorType = getCursor(silentInputs, buttonList);
|
||||
GlStateManager.disableAlpha();
|
||||
Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks);
|
||||
GlStateManager.enableAlpha();
|
||||
if(Client.getInstance().getGlobalSettings().isLite()) {
|
||||
this.drawGradientRect(0, 0, this.width, this.height, new Color(0, 0, 0, 127).getRGB(), new Color(0, 0, 0, 200).getRGB());
|
||||
} else {
|
||||
this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
RenderUtils.drawRect(blockX, blockY, blockWidth, blockHeight, Theme.backgroundColor().getRGB());
|
||||
|
||||
Client.getInstance().getSilentFontRenderer().drawCenteredString("Play Multiplayer", blockX + blockWidth / 2, blockY + 3, 16, SilentFontRenderer.FontType.TITLE);
|
||||
|
||||
this.silentInputs.get(0).render(mouseX, mouseY, blockX + 5, blockY + 3 + 16 + 5, blockWidth - 10, true);
|
||||
|
||||
float serverY = blockY + 43 - scrollAnimation.getValue();
|
||||
trimContentStart();
|
||||
int serverIndex = -1;
|
||||
for (ServerComponent serverComponent : servers)
|
||||
{
|
||||
serverIndex += 1;
|
||||
if((!this.silentInputs.get(0).getValue().trim().equals("") && !serverComponent.getServer().serverName.toLowerCase().contains(this.silentInputs.get(0).getValue().trim().toLowerCase()) && !serverComponent.getServer().serverIP.toLowerCase().contains(this.silentInputs.get(0).getValue().trim().toLowerCase()))) {
|
||||
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(serverIndex, mouseX, mouseY, blockX + 5, serverY, serverIndex == selectedServer);
|
||||
if(cursor != null) {
|
||||
cursorType = cursor;
|
||||
}
|
||||
}
|
||||
serverY += 38;
|
||||
}
|
||||
trimContentEnd();
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
|
||||
Client.getInstance().getMouseCursorHandler().enableCursor(cursorType);
|
||||
|
||||
scrollAnimation.setAnimation(scrollY, 12);
|
||||
}
|
||||
|
||||
public void connectToSelected() {
|
||||
ServerData server = savedServerList.getServerData(selectedServer);
|
||||
if(server != null) {
|
||||
this.mc.displayGuiScreen(new GuiConnecting(this, this.mc, new ServerData(server.serverName, server.serverIP, false)));
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
switch (button.id) {
|
||||
case 0:
|
||||
mc.displayGuiScreen(parentScreen);
|
||||
break;
|
||||
case 1:
|
||||
this.connectToSelected();
|
||||
break;
|
||||
case 2:
|
||||
if(this.selectedServer != -1) {
|
||||
this.savedServerList.removeServerData(this.selectedServer);
|
||||
this.savedServerList.saveServerList();
|
||||
this.selectServer(-1);
|
||||
this.refreshServerList();
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
mc.displayGuiScreen(new AddServerGui(this, new ServerData("Minecraft Server", "", false), false));
|
||||
break;
|
||||
case 4:
|
||||
mc.displayGuiScreen(new DirectConnectGui(this));
|
||||
break;
|
||||
case 7:
|
||||
ServerComponent serverComponent = this.servers.get(selectedServer);
|
||||
if(serverComponent != null && serverComponent.getServer() != null) {
|
||||
mc.displayGuiScreen(new AddServerGui(this, serverComponent.getServer(), true, selectedServer));
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
this.refreshServerList();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void editServer(ServerData serverData, int index) {
|
||||
ServerList newServerList = new ServerList(mc);
|
||||
((ServerListExt) newServerList).clearServerList();
|
||||
Client.logger.info("Updating server list...");
|
||||
for (int i = 0; i < savedServerList.countServers(); ++i)
|
||||
{
|
||||
if(i == index) {
|
||||
Client.logger.info("Editing server...");
|
||||
newServerList.addServerData(serverData);
|
||||
} else {
|
||||
Client.logger.info("Adding server...");
|
||||
newServerList.addServerData(savedServerList.getServerData(i));
|
||||
}
|
||||
}
|
||||
|
||||
Client.logger.info("Saving server list...");
|
||||
newServerList.saveServerList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
if (mouseButton == 0)
|
||||
{
|
||||
for (int i = 0; i < this.buttonList.size(); ++i)
|
||||
{
|
||||
GuiButton guibutton = (GuiButton)this.buttonList.get(i);
|
||||
|
||||
if (guibutton.mousePressed(this.mc, mouseX, mouseY))
|
||||
{
|
||||
guibutton.playPressSound(this.mc.getSoundHandler());
|
||||
this.actionPerformed(guibutton);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.silentInputs.get(0).onClick(mouseX, mouseY, blockX + 5, blockY + 3 + 16 + 5, blockWidth - 10, true);
|
||||
float serverY = blockY + 43 - scrollAnimation.getValue();
|
||||
int serverIndex = -1;
|
||||
boolean isReset = true;
|
||||
for (ServerComponent serverComponent : servers)
|
||||
{
|
||||
serverIndex += 1;
|
||||
if((!this.silentInputs.get(0).getValue().trim().equals("") && !serverComponent.getServer().serverName.toLowerCase().contains(this.silentInputs.get(0).getValue().trim().toLowerCase()) && !serverComponent.getServer().serverIP.toLowerCase().contains(this.silentInputs.get(0).getValue().trim().toLowerCase()))) {
|
||||
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)) && isReset) {
|
||||
isReset = !serverComponent.mouseClicked(serverIndex, mouseX, mouseY, blockX + 5, serverY, serverIndex == selectedServer);
|
||||
if(!isReset) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
serverY += 38;
|
||||
}
|
||||
|
||||
if(isReset) {
|
||||
this.selectServer(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
this.silentInputs.get(0).onKeyTyped(typedChar, keyCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
Client.backgroundPanorama.tickPanorama();
|
||||
}
|
||||
|
||||
public void trimContentStart() {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
ScaledResolution r = new ScaledResolution(Minecraft.getMinecraft());
|
||||
int s = r.getScaleFactor();
|
||||
int listHeight = blockHeight - 43 - 41;
|
||||
int translatedY = r.getScaledHeight() - blockY - 43 - listHeight;
|
||||
GL11.glScissor(0 * s, translatedY * s, width * s, listHeight * s);
|
||||
}
|
||||
|
||||
public static void trimContentEnd() {
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput() throws IOException {
|
||||
super.handleMouseInput();
|
||||
int dw = Mouse.getEventDWheel();
|
||||
double newScrollY = this.scrollY;
|
||||
if(dw != 0) {
|
||||
if (dw > 0) {
|
||||
dw = -1;
|
||||
} else {
|
||||
dw = 1;
|
||||
}
|
||||
float amountScrolled = (float) (dw * 10);
|
||||
if (newScrollY + amountScrolled > 0)
|
||||
newScrollY += amountScrolled;
|
||||
else
|
||||
newScrollY = 0;
|
||||
if((newScrollY < blockHeight && ((servers.size() + 1) * 38) > blockHeight - 39) || amountScrolled < 0) {
|
||||
this.scrollY = (float) newScrollY;
|
||||
if(this.scrollY < 0) {
|
||||
this.scrollY = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshServerList()
|
||||
{
|
||||
this.mc.displayGuiScreen(new SilentMultiplayerGui(this.parentScreen));
|
||||
}
|
||||
|
||||
public OldServerPinger getOldServerPinger() {
|
||||
return oldServerPinger;
|
||||
}
|
||||
|
||||
public ServerList getServerList() {
|
||||
return savedServerList;
|
||||
}
|
||||
|
||||
public void setParentScreen(GuiScreen parentScreen) {
|
||||
this.parentScreen = parentScreen;
|
||||
}
|
||||
}
|
@ -0,0 +1,274 @@
|
||||
package net.silentclient.client.gui.multiplayer.components;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufInputStream;
|
||||
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;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.gui.font.SilentFontRenderer;
|
||||
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
|
||||
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
|
||||
import net.silentclient.client.gui.multiplayer.SilentMultiplayerGui;
|
||||
import net.silentclient.client.gui.theme.Theme;
|
||||
import net.silentclient.client.gui.util.RenderUtil;
|
||||
import net.silentclient.client.utils.MouseCursorHandler;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
public class ServerComponent {
|
||||
private static final ThreadPoolExecutor field_148302_b = new ScheduledThreadPoolExecutor(5, (new ThreadFactoryBuilder()).setNameFormat("Server Pinger #%d").setDaemon(true).build());
|
||||
private static final ResourceLocation UNKNOWN_SERVER = new ResourceLocation("textures/misc/unknown_server.png");
|
||||
private static final ResourceLocation SERVER_SELECTION_BUTTONS = new ResourceLocation("textures/gui/server_selection.png");
|
||||
private final SilentMultiplayerGui owner;
|
||||
private final Minecraft mc;
|
||||
private final ServerData server;
|
||||
private final ResourceLocation serverIcon;
|
||||
private String field_148299_g;
|
||||
private DynamicTexture field_148305_h;
|
||||
private long field_148298_f;
|
||||
|
||||
public ServerComponent(SilentMultiplayerGui p_i45048_1_, ServerData serverIn)
|
||||
{
|
||||
this.owner = p_i45048_1_;
|
||||
this.server = serverIn;
|
||||
this.mc = Minecraft.getMinecraft();
|
||||
this.serverIcon = new ResourceLocation("servers/" + serverIn.serverIP + "/icon");
|
||||
this.field_148305_h = (DynamicTexture)this.mc.getTextureManager().getTexture(this.serverIcon);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
this.server.field_78841_f = true;
|
||||
this.server.pingToServer = -2L;
|
||||
this.server.serverMOTD = "";
|
||||
this.server.populationInfo = "";
|
||||
field_148302_b.submit(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
ServerComponent.this.owner.getOldServerPinger().ping(ServerComponent.this.server);
|
||||
}
|
||||
catch (UnknownHostException var2)
|
||||
{
|
||||
ServerComponent.this.server.pingToServer = -1L;
|
||||
ServerComponent.this.server.serverMOTD = EnumChatFormatting.DARK_RED + "Can\'t resolve hostname";
|
||||
}
|
||||
catch (Exception var3)
|
||||
{
|
||||
ServerComponent.this.server.pingToServer = -1L;
|
||||
ServerComponent.this.server.serverMOTD = EnumChatFormatting.DARK_RED + "Can\'t connect to server.";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
boolean isHovered = MouseUtils.isInside(mouseX, mouseY, x, y, 240, 35);
|
||||
RenderUtil.drawRoundedOutline(x, y, 240, 35, 3, isSelected ? 3 : 1, isSelected ? -1 : Theme.borderColor().getRGB());
|
||||
if(isHovered) {
|
||||
RenderUtil.drawRoundedRect(x, y, 240, 35, 3, new Color(255, 255, 255, 30).getRGB());
|
||||
cursorType = MouseCursorHandler.CursorType.POINTER;
|
||||
}
|
||||
|
||||
if (this.server.getBase64EncodedIconData() != null && !this.server.getBase64EncodedIconData().equals(this.field_148299_g))
|
||||
{
|
||||
this.field_148299_g = this.server.getBase64EncodedIconData();
|
||||
this.prepareServerIcon();
|
||||
this.owner.getServerList().saveServerList();
|
||||
}
|
||||
|
||||
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<String> list = this.mc.fontRendererObj.listFormattedStringToWidth(this.server.serverMOTD, 240 - 36);
|
||||
|
||||
for (int i = 0; i < Math.min(list.size(), 2); ++i)
|
||||
{
|
||||
this.mc.fontRendererObj.drawString((String)list.get(i), (int) x + 2 + 31 + 3, (int) y + 5 + this.mc.fontRendererObj.FONT_HEIGHT * (i + 1), -1);
|
||||
}
|
||||
|
||||
boolean flag = this.server.version > 47;
|
||||
boolean flag1 = this.server.version < 47;
|
||||
boolean flag2 = flag || flag1;
|
||||
String s2 = flag2 ? EnumChatFormatting.DARK_RED + this.server.gameVersion : this.server.populationInfo;
|
||||
int j = this.mc.fontRendererObj.getStringWidth(s2);
|
||||
this.mc.fontRendererObj.drawString(s2, (int) x + 240 - j - 15 - 2, (int) y + 3, -1);
|
||||
int k = 0;
|
||||
String s = null;
|
||||
int l;
|
||||
String s1;
|
||||
|
||||
if (flag2)
|
||||
{
|
||||
l = 5;
|
||||
s1 = flag ? "Client out of date!" : "Server out of date!";
|
||||
s = this.server.playerList;
|
||||
}
|
||||
else if (this.server.field_78841_f && this.server.pingToServer != -2L)
|
||||
{
|
||||
if (this.server.pingToServer < 0L)
|
||||
{
|
||||
l = 5;
|
||||
}
|
||||
else if (this.server.pingToServer < 150L)
|
||||
{
|
||||
l = 0;
|
||||
}
|
||||
else if (this.server.pingToServer < 300L)
|
||||
{
|
||||
l = 1;
|
||||
}
|
||||
else if (this.server.pingToServer < 600L)
|
||||
{
|
||||
l = 2;
|
||||
}
|
||||
else if (this.server.pingToServer < 1000L)
|
||||
{
|
||||
l = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
l = 4;
|
||||
}
|
||||
|
||||
if (this.server.pingToServer < 0L)
|
||||
{
|
||||
s1 = "(no connection)";
|
||||
}
|
||||
else
|
||||
{
|
||||
s1 = this.server.pingToServer + "ms";
|
||||
s = this.server.playerList;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
k = 1;
|
||||
l = (int)(Minecraft.getSystemTime() / 100L + (long)(1 * 2) & 7L);
|
||||
|
||||
if (l > 4)
|
||||
{
|
||||
l = 8 - l;
|
||||
}
|
||||
|
||||
s1 = "Pinging...";
|
||||
}
|
||||
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(Gui.icons);
|
||||
Gui.drawModalRectWithCustomSizedTexture((int) x + 240 - 15, (int) y + 2, (float)(k * 10), (float)(176 + l * 8), 10, 8, 256.0F, 256.0F);
|
||||
if(MouseUtils.isInside(mouseX, mouseY, x + 240 - 15, y + 2, 10, 8)) {
|
||||
float toastWidth = Client.getInstance().getSilentFontRenderer().getStringWidth(s1, 10, SilentFontRenderer.FontType.TITLE) + 4;
|
||||
float toastX = x + 240 - 15 + (10 / 2) - (toastWidth / 2);
|
||||
RenderUtils.drawRect(toastX, y + 2 + 10 + 1, toastWidth, 14, Theme.backgroundColor().getRGB());
|
||||
Client.getInstance().getSilentFontRenderer().drawString(s1, toastX + 2, y + 2 + 10 + 1 + 2, 10, SilentFontRenderer.FontType.TITLE);
|
||||
}
|
||||
|
||||
return cursorType;
|
||||
}
|
||||
|
||||
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 {
|
||||
this.owner.connectToSelected();
|
||||
}
|
||||
}
|
||||
|
||||
return isHovered;
|
||||
}
|
||||
|
||||
private void prepareServerIcon()
|
||||
{
|
||||
if (this.server.getBase64EncodedIconData() == null)
|
||||
{
|
||||
this.mc.getTextureManager().deleteTexture(this.serverIcon);
|
||||
this.field_148305_h = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
ByteBuf bytebuf = Unpooled.copiedBuffer((CharSequence)this.server.getBase64EncodedIconData(), Charsets.UTF_8);
|
||||
ByteBuf bytebuf1 = Base64.decode(bytebuf);
|
||||
BufferedImage bufferedimage;
|
||||
label101:
|
||||
{
|
||||
try
|
||||
{
|
||||
bufferedimage = TextureUtil.readBufferedImage(new ByteBufInputStream(bytebuf1));
|
||||
Validate.validState(bufferedimage.getWidth() == 64, "Must be 64 pixels wide", new Object[0]);
|
||||
Validate.validState(bufferedimage.getHeight() == 64, "Must be 64 pixels high", new Object[0]);
|
||||
break label101;
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
Client.logger.error("Invalid icon for server " + this.server.serverName + " (" + this.server.serverIP + ")", throwable);
|
||||
this.server.setBase64EncodedIconData((String)null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
bytebuf.release();
|
||||
bytebuf1.release();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.field_148305_h == null)
|
||||
{
|
||||
this.field_148305_h = new DynamicTexture(bufferedimage.getWidth(), bufferedimage.getHeight());
|
||||
this.mc.getTextureManager().loadTexture(this.serverIcon, this.field_148305_h);
|
||||
}
|
||||
|
||||
bufferedimage.getRGB(0, 0, bufferedimage.getWidth(), bufferedimage.getHeight(), this.field_148305_h.getTextureData(), 0, bufferedimage.getWidth());
|
||||
this.field_148305_h.updateDynamicTexture();
|
||||
}
|
||||
}
|
||||
|
||||
public ServerData getServer() {
|
||||
return server;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package net.silentclient.client.gui.resourcepacks;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.ResourcePackListEntry;
|
||||
import net.silentclient.client.gui.SilentScreen;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SilentResourcePacksGui extends SilentScreen {
|
||||
private final GuiScreen parentScreen;
|
||||
private List<ResourcePackListEntry> availableResourcePacks;
|
||||
private List<ResourcePackListEntry> selectedResourcePacks;
|
||||
private boolean changed = false;
|
||||
|
||||
public SilentResourcePacksGui(GuiScreen parentScreenIn)
|
||||
{
|
||||
this.parentScreen = parentScreenIn;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package net.silentclient.client.mixin.ducks;
|
||||
|
||||
public interface GuiMultiplayerExt {
|
||||
void silent$setParentScreen(Object a);
|
||||
Object silent$getParentScreen();
|
||||
void silent$setDirectConnect(boolean a);
|
||||
void silent$setSelectedServer(Object a);
|
||||
Object silent$getSelectedServer();
|
||||
|
@ -0,0 +1,5 @@
|
||||
package net.silentclient.client.mixin.ducks;
|
||||
|
||||
public interface ServerListExt {
|
||||
void clearServerList();
|
||||
}
|
@ -34,6 +34,11 @@ public abstract class GuiMultiplayerMixin extends GuiScreen implements GuiMultip
|
||||
this.parentScreen = (GuiScreen) a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object silent$getParentScreen() {
|
||||
return this.parentScreen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void silent$setDirectConnect(boolean a) {
|
||||
this.directConnect = a;
|
||||
|
@ -20,10 +20,13 @@ import net.minecraft.util.Timer;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.event.impl.*;
|
||||
import net.silentclient.client.gui.SilentScreen;
|
||||
import net.silentclient.client.gui.lite.LiteMainMenu;
|
||||
import net.silentclient.client.gui.multiplayer.SilentMultiplayerGui;
|
||||
import net.silentclient.client.gui.silentmainmenu.MainMenuConcept;
|
||||
import net.silentclient.client.gui.util.BackgroundPanorama;
|
||||
import net.silentclient.client.hooks.MinecraftHook;
|
||||
import net.silentclient.client.mixin.ducks.GuiMultiplayerExt;
|
||||
import net.silentclient.client.mixin.ducks.MinecraftExt;
|
||||
import net.silentclient.client.mods.player.ZoomMod;
|
||||
import net.silentclient.client.mods.render.AnimationsMod;
|
||||
@ -142,11 +145,14 @@ public abstract class MinecraftMixin implements MinecraftExt {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(guiScreenIn instanceof GuiMultiplayer) {
|
||||
displayGuiScreen(new SilentMultiplayerGui((GuiScreen) ((GuiMultiplayerExt) guiScreenIn).silent$getParentScreen()));
|
||||
}
|
||||
if(guiScreenIn instanceof GuiIngameMenu) {
|
||||
displayGuiScreen(new net.silentclient.client.gui.minecraft.GuiIngameMenu());
|
||||
return;
|
||||
}
|
||||
if(guiScreenIn != null) {
|
||||
if(guiScreenIn != null && guiScreenIn instanceof SilentScreen) {
|
||||
Client.logger.info("Opening menu: " + guiScreenIn.getClass().toString());
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.silentclient.client.mixin.mixins;
|
||||
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.multiplayer.ServerList;
|
||||
import net.silentclient.client.mixin.ducks.ServerListExt;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
@ -12,7 +13,7 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(ServerList.class)
|
||||
public abstract class ServerListMixin {
|
||||
public abstract class ServerListMixin implements ServerListExt {
|
||||
private static final Logger silent$logger = LogManager.getLogger("SC - ServerList");
|
||||
|
||||
@Shadow @Final
|
||||
@ -88,4 +89,9 @@ public abstract class ServerListMixin {
|
||||
silent$logger.error("Failed to set server data.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearServerList() {
|
||||
this.servers.clear();
|
||||
}
|
||||
}
|
||||
|
BIN
src/main/resources/assets/minecraft/silentclient/icons/hazard.png
Executable file
BIN
src/main/resources/assets/minecraft/silentclient/icons/hazard.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 5.0 KiB |
BIN
src/main/resources/assets/minecraft/silentclient/icons/page-down.png
Executable file
BIN
src/main/resources/assets/minecraft/silentclient/icons/page-down.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 439 B |
BIN
src/main/resources/assets/minecraft/silentclient/icons/page-left.png
Executable file
BIN
src/main/resources/assets/minecraft/silentclient/icons/page-left.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 495 B |
BIN
src/main/resources/assets/minecraft/silentclient/icons/page-right.png
Executable file
BIN
src/main/resources/assets/minecraft/silentclient/icons/page-right.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 484 B |
BIN
src/main/resources/assets/minecraft/silentclient/icons/page-up.png
Executable file
BIN
src/main/resources/assets/minecraft/silentclient/icons/page-up.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 440 B |
Loading…
Reference in New Issue
Block a user