mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 08:21:32 +01:00
Custom Multiplayer Screen 90%
This commit is contained in:
parent
cc9608f99b
commit
43672c6ce9
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ 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;
|
||||
@ -94,7 +95,6 @@ public class SilentMultiplayerGui extends SilentScreen {
|
||||
|
||||
public void selectServer(int index)
|
||||
{
|
||||
Client.logger.info("Selecting server " + index);
|
||||
this.selectedServer = index;
|
||||
this.btnSelectServer.enabled = false;
|
||||
this.btnEditServer.enabled = false;
|
||||
@ -182,15 +182,59 @@ public class SilentMultiplayerGui extends SilentScreen {
|
||||
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 {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
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;
|
||||
@ -229,7 +273,7 @@ public class SilentMultiplayerGui extends SilentScreen {
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
ScaledResolution r = new ScaledResolution(Minecraft.getMinecraft());
|
||||
int s = r.getScaleFactor();
|
||||
int listHeight = blockHeight - 43 - 39;
|
||||
int listHeight = blockHeight - 43 - 41;
|
||||
int translatedY = r.getScaledHeight() - blockY - 43 - listHeight;
|
||||
GL11.glScissor(0 * s, translatedY * s, width * s, listHeight * s);
|
||||
}
|
||||
@ -255,7 +299,7 @@ public class SilentMultiplayerGui extends SilentScreen {
|
||||
newScrollY += amountScrolled;
|
||||
else
|
||||
newScrollY = 0;
|
||||
if((newScrollY < blockHeight && (servers.size() * 38) > blockHeight - 39) || amountScrolled < 0) {
|
||||
if((newScrollY < blockHeight && ((servers.size() + 1) * 38) > blockHeight - 39) || amountScrolled < 0) {
|
||||
this.scrollY = (float) newScrollY;
|
||||
if(this.scrollY < 0) {
|
||||
this.scrollY = 0;
|
||||
@ -264,7 +308,7 @@ public class SilentMultiplayerGui extends SilentScreen {
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshServerList()
|
||||
public void refreshServerList()
|
||||
{
|
||||
this.mc.displayGuiScreen(new SilentMultiplayerGui(this.parentScreen));
|
||||
}
|
||||
|
@ -189,7 +189,6 @@ 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) {
|
||||
Client.logger.info("Hey!");
|
||||
if(!isSelected) {
|
||||
this.owner.selectServer(serverIndex);
|
||||
} else {
|
||||
|
@ -0,0 +1,5 @@
|
||||
package net.silentclient.client.mixin.ducks;
|
||||
|
||||
public interface ServerListExt {
|
||||
void clearServerList();
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user