a lot of progress on a relay manager gui

This commit is contained in:
LAX1DUDE 2022-08-12 00:16:49 -07:00
parent 01b1e31ce4
commit 6d06b5f7e9
23 changed files with 17958 additions and 17019 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

View file

@ -249,9 +249,22 @@ lanServer.title=LAN World
lanServer.scanning=Scanning for games on your local network
lanServer.start=Start LAN World
lanServer.otherPlayers=Settings for Other Players
mcoServer.title=Minecraft Online World
mcoServer.title=yeeeeeee
addServer.SSLWarn1=you are on an https: page!
addServer.SSLWarn2=html5 will only allow wss://
directConnect.prompt=What would you like to do?
directConnect.lanWorld=Join LAN World
directConnect.lanWorldCode=Enter Join Code:
directConnect.serverJoin=Connect to Server
directConnect.lanWorldJoin=Join World
directConnect.lanWorldRelay=Network Settings
networkSettings.title=LAN World Relay Servers
networkSettings.add=Add Relay
networkSettings.delete=Delete Relay
networkSettings.default=Set Primary
networkSettings.refresh=Refresh
networkSettings.loadDefaults=Load Defaults
multiplayer.title=Play Multiplayer
multiplayer.connect=Connect

View file

@ -73,6 +73,7 @@ import net.lax1dude.eaglercraft.AssetRepository;
import net.lax1dude.eaglercraft.EaglerImage;
import net.lax1dude.eaglercraft.EarlyLoadScreen;
import net.lax1dude.eaglercraft.PKT;
import net.lax1dude.eaglercraft.RelayQuery;
import net.lax1dude.eaglercraft.ServerQuery;
import net.lax1dude.eaglercraft.Voice;
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.ProgramGL;
@ -1701,4 +1702,55 @@ public class EaglerAdapterImpl2 {
return false;
}
private static final RelayQuery dummyRelayQuery = new RelayQuery() {
@Override
public boolean isQueryOpen() {
return false;
}
@Override
public boolean isQueryFailed() {
return false;
}
@Override
public void close() {
}
@Override
public int getVersion() {
return 1;
}
@Override
public String getComment() {
return "this is a dummy";
}
@Override
public String getBrand() {
return "lax1dude";
}
@Override
public long getPing() {
return 10l;
}
@Override
public VersionMismatch getCompatible() {
return VersionMismatch.COMPATIBLE;
}
};
public static final RelayQuery openRelayQuery(String addr) {
return dummyRelayQuery;
}
public static final boolean glNeedsAnisotropicFix() {
return false;
}
}

View file

@ -23,6 +23,8 @@ public class ConfigConstants {
public static List<String> splashTexts = null;
public static List<RelayEntry> relays = null;
public static boolean eaglercraftTitleLogo = false;
}

View file

@ -0,0 +1,41 @@
package net.lax1dude.eaglercraft;
import net.minecraft.client.Minecraft;
import net.minecraft.src.EnumChatFormatting;
import net.minecraft.src.Gui;
import net.minecraft.src.GuiScreen;
import net.minecraft.src.StringTranslate;
public class GuiNetworkSettingsButton extends Gui {
private final GuiScreen screen;
private final String text;
private final Minecraft mc;
public GuiNetworkSettingsButton(GuiScreen screen) {
this.screen = screen;
this.text = StringTranslate.getInstance().translateKey("directConnect.lanWorldRelay");
this.mc = Minecraft.getMinecraft();
}
public void drawScreen(int xx, int yy) {
EaglerAdapter.glPushMatrix();
EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f);
int w = mc.fontRenderer.getStringWidth(text);
boolean hover = xx > 1 && yy > 1 && xx < (w * 3 / 4) + 7 && yy < 12;
drawString(mc.fontRenderer, EnumChatFormatting.UNDERLINE + text, 5, 5, hover ? 0xFFEEEE22 : 0xFFCCCCCC);
EaglerAdapter.glPopMatrix();
}
public void mouseClicked(int xx, int yy, int btn) {
int w = mc.fontRenderer.getStringWidth(text);
if(xx > 2 && yy > 2 && xx < (w * 3 / 4) + 5 && yy < 12) {
mc.displayGuiScreen(new GuiScreenRelay(screen));
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
}
}
}

View file

@ -0,0 +1,13 @@
package net.lax1dude.eaglercraft;
import net.minecraft.src.GuiScreen;
public class GuiScreenAddRelay extends GuiScreen {
private final GuiScreenRelay screen;
public GuiScreenAddRelay(GuiScreenRelay screen) {
this.screen = screen;
}
}

View file

@ -0,0 +1,56 @@
package net.lax1dude.eaglercraft;
import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiMultiplayer;
import net.minecraft.src.GuiScreen;
import net.minecraft.src.GuiScreenDirectConnect;
import net.minecraft.src.StringTranslate;
public class GuiScreenConnectOption extends GuiScreen {
private final GuiMultiplayer guiScreen;
private String title;
private String prompt;
private final GuiNetworkSettingsButton relaysButton;
public GuiScreenConnectOption(GuiMultiplayer guiScreen) {
this.guiScreen = guiScreen;
this.relaysButton = new GuiNetworkSettingsButton(this);
}
public void initGui() {
StringTranslate var1 = StringTranslate.getInstance();
title = var1.translateKey("selectServer.direct");
prompt = var1.translateKey("directConnect.prompt");
buttonList.clear();
buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 - 60 + 90, var1.translateKey("directConnect.serverJoin")));
buttonList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 - 60 + 115, var1.translateKey("directConnect.lanWorld")));
buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 - 60 + 155, var1.translateKey("gui.cancel")));
}
protected void actionPerformed(GuiButton par1GuiButton) {
if(par1GuiButton.id == 0) {
mc.displayGuiScreen(guiScreen);
}else if(par1GuiButton.id == 1) {
mc.displayGuiScreen(new GuiScreenDirectConnect(guiScreen, guiScreen.getTheServerData()));
}else if(par1GuiButton.id == 2) {
mc.displayGuiScreen(new GuiScreenLANConnect(guiScreen));
}
}
public void drawScreen(int par1, int par2, float par3) {
StringTranslate var4 = StringTranslate.getInstance();
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, title, this.width / 2, this.height / 4 - 60 + 20, 16777215);
this.drawCenteredString(this.fontRenderer, prompt, this.width / 2, this.height / 4 - 60 + 55, 0x999999);
super.drawScreen(par1, par2, par3);
relaysButton.drawScreen(par1, par2);
}
protected void mouseClicked(int par1, int par2, int par3) {
relaysButton.mouseClicked(par1, par2, par3);
super.mouseClicked(par1, par2, par3);
}
}

View file

@ -0,0 +1,73 @@
package net.lax1dude.eaglercraft;
import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiScreen;
import net.minecraft.src.GuiTextField;
import net.minecraft.src.StringTranslate;
public class GuiScreenLANConnect extends GuiScreen {
private final GuiScreen parent;
private GuiTextField codeTextField;
private final GuiNetworkSettingsButton relaysButton;
private static String lastCode = "";
public GuiScreenLANConnect(GuiScreen parent) {
this.parent = parent;
this.relaysButton = new GuiNetworkSettingsButton(this);
}
public void initGui() {
StringTranslate var1 = StringTranslate.getInstance();
EaglerAdapter.enableRepeatEvents(true);
this.buttonList.clear();
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, var1.translateKey("directConnect.lanWorldJoin")));
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, var1.translateKey("gui.cancel")));
this.codeTextField = new GuiTextField(this.fontRenderer, this.width / 2 - 100, this.height / 4 + 27, 200, 20);
this.codeTextField.setMaxStringLength(48);
this.codeTextField.setFocused(true);
this.codeTextField.setText(lastCode);
((GuiButton) this.buttonList.get(0)).enabled = this.codeTextField.getText().length() > 0;
}
public void onGuiClosed() {
EaglerAdapter.enableRepeatEvents(false);
lastCode = this.codeTextField.getText();
}
protected void keyTyped(char par1, int par2) {
if (this.codeTextField.textboxKeyTyped(par1, par2)) {
((GuiButton) this.buttonList.get(0)).enabled = this.codeTextField.getText().length() > 0;
} else if (par2 == 28) {
this.actionPerformed((GuiButton) this.buttonList.get(0));
}
}
public void updateScreen() {
this.codeTextField.updateCursorCounter();
}
protected void mouseClicked(int par1, int par2, int par3) {
super.mouseClicked(par1, par2, par3);
this.codeTextField.mouseClicked(par1, par2, par3);
this.relaysButton.mouseClicked(par1, par2, par3);
}
public void drawScreen(int xx, int yy, float pt) {
StringTranslate var4 = StringTranslate.getInstance();
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, var4.translateKey("selectServer.direct"), this.width / 2, this.height / 4 - 60 + 20, 16777215);
this.drawString(this.fontRenderer, var4.translateKey("directConnect.lanWorldCode"), this.width / 2 - 100, this.height / 4 + 12, 10526880);
this.codeTextField.drawTextBox();
super.drawScreen(xx, yy, pt);
this.relaysButton.drawScreen(xx, yy);
}
protected void actionPerformed(GuiButton par1GuiButton) {
if(par1GuiButton.id == 1) {
mc.displayGuiScreen(parent);
}
}
}

View file

@ -0,0 +1,115 @@
package net.lax1dude.eaglercraft;
import net.minecraft.client.Minecraft;
import net.minecraft.src.Gui;
import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiScreen;
import net.minecraft.src.StringTranslate;
public class GuiScreenRelay extends GuiScreen {
private final GuiScreen screen;
private GuiSlotRelay slots;
private boolean hasPinged;
int selected;
private GuiButton addRelay;
private GuiButton deleteRelay;
private GuiButton setPrimary;
private GuiButton refresh;
private GuiButton loadDefault;
private String tooltipString = null;
public GuiScreenRelay(GuiScreen screen) {
this.screen = screen;
}
public void initGui() {
selected = -1;
StringTranslate var1 = StringTranslate.getInstance();
buttonList.clear();
buttonList.add(new GuiButton(0, this.width / 2 + 54, this.height - 28, 100, 20, var1.translateKey("gui.cancel")));
buttonList.add(addRelay = new GuiButton(1, this.width / 2 - 154, this.height - 52, 100, 20, var1.translateKey("networkSettings.add")));
buttonList.add(deleteRelay = new GuiButton(2, this.width / 2 - 50, this.height - 52, 100, 20, var1.translateKey("networkSettings.delete")));
buttonList.add(setPrimary = new GuiButton(3, this.width / 2 + 54, this.height - 52, 100, 20, var1.translateKey("networkSettings.default")));
buttonList.add(refresh = new GuiButton(4, this.width / 2 - 50, this.height - 28, 100, 20, var1.translateKey("networkSettings.refresh")));
buttonList.add(loadDefault = new GuiButton(5, this.width / 2 - 154, this.height - 28, 100, 20, var1.translateKey("networkSettings.loadDefaults")));
updateButtons();
this.slots = new GuiSlotRelay(this);
if(!hasPinged) {
hasPinged = true;
slots.relayManager.ping();
}
}
void updateButtons() {
if(selected < 0) {
addRelay.enabled = false;
deleteRelay.enabled = false;
setPrimary.enabled = false;
loadDefault.enabled = false;
}else {
addRelay.enabled = true;
deleteRelay.enabled = true;
setPrimary.enabled = true;
loadDefault.enabled = true;
}
}
public void actionPerformed(GuiButton btn) {
if(btn.id == 0) {
mc.displayGuiScreen(screen);
} else if(btn.id == 4) {
slots.relayManager.ping();
} else if(btn.id == 3) {
if(selected >= 0) {
slots.relayManager.setPrimary(selected);
selected = 0;
}
}
}
public void updateScreen() {
slots.relayManager.update();
}
private int mx = 0;
private int my = 0;
int getFrameMouseX() {
return mx;
}
int getFrameMouseY() {
return my;
}
public void drawScreen(int par1, int par2, float par3) {
drawDefaultBackground();
StringTranslate var4 = StringTranslate.getInstance();
mx = par1;
my = par2;
slots.drawScreen(par1, par2, par3);
if(tooltipString != null) {
int ww = mc.fontRenderer.getStringWidth(tooltipString);
Gui.drawRect(par1 + 1, par2 - 14, par1 + ww + 7, par2 - 2, 0xC0000000);
screen.drawString(mc.fontRenderer, tooltipString, par1 + 4, par2 - 12, 0xFF999999);
tooltipString = null;
}
this.drawCenteredString(this.fontRenderer, var4.translateKey("networkSettings.title"), this.width / 2, 16, 16777215);
super.drawScreen(par1, par2, par3);
}
void setToolTip(String str) {
tooltipString = str;
}
static Minecraft getMinecraft(GuiScreenRelay screen) {
return screen.mc;
}
}

View file

@ -0,0 +1,131 @@
package net.lax1dude.eaglercraft;
import net.lax1dude.eaglercraft.RelayQuery.VersionMismatch;
import net.lax1dude.eaglercraft.adapter.Tessellator;
import net.minecraft.client.Minecraft;
import net.minecraft.src.Gui;
import net.minecraft.src.GuiSlot;
class GuiSlotRelay extends GuiSlot {
final GuiScreenRelay screen;
final RelayManager relayManager;
public GuiSlotRelay(GuiScreenRelay screen) {
super(GuiScreenRelay.getMinecraft(screen), screen.width, screen.height, 32, screen.height - 64, 26);
this.screen = screen;
this.relayManager = IntegratedServer.relayManager;
}
@Override
protected int getSize() {
return relayManager.count();
}
@Override
protected void elementClicked(int var1, boolean var2) {
screen.selected = var1;
screen.updateButtons();
}
@Override
protected boolean isSelected(int var1) {
return screen.selected == var1;
}
@Override
protected void drawBackground() {
screen.drawDefaultBackground();
}
private static final TextureLocation icons = new TextureLocation("/gui/icons.png");
@Override
protected void drawSlot(int id, int xx, int yy, int height, Tessellator var5) {
if(id < relayManager.count()) {
icons.bindTexture();
RelayServer srv = relayManager.get(id);
String comment = srv.comment;
int var15 = 0;
int var16 = 0;
String str = null;
int h = 12;
long ping = srv.getPing();
if(ping == 0l) {
var16 = 5;
str = "No Connection";
}else if(ping < 0l) {
var15 = 1;
var16 = (int) (Minecraft.getSystemTime() / 100L + (long) (id * 2) & 7L);
if (var16 > 4) {
var16 = 8 - var16;
}
str = "Polling...";
}else {
VersionMismatch vm = srv.getPingCompatible();
if(!vm.isCompatible()) {
var16 = 5;
switch(vm) {
case CLIENT_OUTDATED:
str = "Outdated Client!";
break;
case RELAY_OUTDATED:
str = "Outdated Relay!";
break;
default:
case UNKNOWN:
str = "Incompatible Relay!";
break;
}
EaglerAdapter.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
EaglerAdapter.glPushMatrix();
EaglerAdapter.glTranslatef(xx + 205, yy + 11, 0.0f);
EaglerAdapter.glScalef(0.6f, 0.6f, 0.6f);
screen.drawTexturedModalRect(0, 0, 0, 144, 16, 16);
EaglerAdapter.glPopMatrix();
h += 10;
}else {
String pingComment = srv.getPingComment().trim();
if(pingComment.length() > 0) {
comment = pingComment;
}
str = "" + ping + "ms";
if (ping < 150L) {
var16 = 0;
} else if (ping < 300L) {
var16 = 1;
} else if (ping < 600L) {
var16 = 2;
} else if (ping < 1000L) {
var16 = 3;
} else {
var16 = 4;
}
}
}
EaglerAdapter.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
screen.drawTexturedModalRect(xx + 205, yy, 0 + var15 * 10, 176 + var16 * 8, 10, 8);
if(srv.isPrimary()) {
EaglerAdapter.glPushMatrix();
EaglerAdapter.glTranslatef(xx + 4, yy + 5, 0.0f);
EaglerAdapter.glScalef(0.8f, 0.8f, 0.8f);
screen.drawTexturedModalRect(0, 0, 0, 160, 16, 16);
EaglerAdapter.glPopMatrix();
}
screen.drawString(mc.fontRenderer, comment, xx + 22, yy + 2, 0xFFFFFFFF);
screen.drawString(mc.fontRenderer, srv.address, xx + 22, yy + 12, 0xFF999999);
if(str != null) {
int mx = screen.getFrameMouseX();
int my = screen.getFrameMouseY();
int rx = xx + 202;
if(mx > rx && mx < rx + 13 && my > yy - 1 && my < yy + h) {
screen.setToolTip(str);
}
}
}
}
}

View file

@ -29,6 +29,8 @@ public class IntegratedServer {
private static boolean isPaused = false;
private static List<String> integratedServerTPS = new LinkedList();
public static final RelayManager relayManager = new RelayManager();
public static List<String> getTPS() {
return integratedServerTPS;
}

View file

@ -0,0 +1,15 @@
package net.lax1dude.eaglercraft;
public class RelayEntry {
public final String address;
public final String comment;
public final boolean primary;
public RelayEntry(String address, String comment, boolean primary) {
this.address = address;
this.comment = comment;
this.primary = primary;
}
}

View file

@ -0,0 +1,201 @@
package net.lax1dude.eaglercraft;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import net.minecraft.src.NBTBase;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NBTTagList;
public class RelayManager {
private final List<RelayServer> relays = new ArrayList();
private long lastPingThrough = 0l;
public RelayManager() {
relays.add(new RelayServer("wss://addr1/", "relay #1", true));
relays.add(new RelayServer("wss://addr2/", "relay #2", false));
relays.add(new RelayServer("wss://addr3/", "relay #3", false));
}
public void load(NBTTagList relayConfig) {
relays.clear();
if(relayConfig.tagCount() > 0) {
boolean gotAPrimary = false;
for(int i = 0, l = relayConfig.tagCount(); i < l; ++i) {
NBTBase relay = relayConfig.tagAt(l);
if(relay instanceof NBTTagCompound) {
NBTTagCompound relayee = (NBTTagCompound) relay;
boolean p = relayee.getBoolean("primary");
if(p) {
if(gotAPrimary) {
p = false;
}else {
gotAPrimary = true;
}
}
relays.add(new RelayServer(relayee.getString("addr"), relayee.getString("comment"), p));
}
}
}
if(relays.size() == 0) {
for(int i = 0, l = ConfigConstants.relays.size(); i < l; ++i) {
relays.add(new RelayServer(ConfigConstants.relays.get(i)));
}
}
sort();
}
private void sort() {
if(relays.size() == 0) {
return;
}
int j = -1;
for(int i = 0, l = relays.size(); i < l; ++i) {
if(relays.get(i).isPrimary()) {
if(j == -1) {
j = i;
}else {
relays.get(i).setPrimary(false);
}
}
}
if(j == -1) {
boolean found = false;
for(int i = 0, l = relays.size(); i < l; ++i) {
RelayServer srv = relays.get(i);
if(srv.getPing() > 0l) {
found = true;
srv.setPrimary(true);
break;
}
}
if(!found) {
relays.get(0).setPrimary(true);
}
}else {
RelayServer srv = relays.remove(j);
relays.add(0, srv);
}
}
public void ping() {
lastPingThrough = System.currentTimeMillis();
for(int i = 0, l = relays.size(); i < l; ++i) {
relays.get(i).ping();
}
}
public void update() {
for(int i = 0, l = relays.size(); i < l; ++i) {
relays.get(i).update();
}
}
public void close() {
for(int i = 0, l = relays.size(); i < l; ++i) {
relays.get(i).close();
}
}
public int count() {
return relays.size();
}
public RelayServer get(int idx) {
return relays.get(idx);
}
public void add(String addr, String comment, boolean primary) {
lastPingThrough = 0l;
int i = relays.size();
relays.add(new RelayServer(addr, comment, false));
if(primary) {
setPrimary(i);
}
}
public void setPrimary(int idx) {
if(idx >= 0 && idx < relays.size()) {
for(int i = 0, l = relays.size(); i < l; ++i) {
RelayServer srv = relays.get(i);
if(srv.isPrimary()) {
srv.setPrimary(false);
}
}
RelayServer pr = relays.remove(idx);
pr.setPrimary(true);
relays.add(0, pr);
}
}
public void remove(int idx) {
RelayServer srv = relays.remove(idx);
srv.close();
sort();
}
public RelayServer getPrimary() {
if(relays.size() > 0) {
for(int i = 0, l = relays.size(); i < l; ++i) {
RelayServer srv = relays.get(i);
if(srv.isPrimary()) {
return srv;
}
}
sort();
return getPrimary();
}else {
return null;
}
}
public RelayServer getWorkingRelay(Consumer<String> progressCallback) {
if(relays.size() > 0) {
long millis = System.currentTimeMillis();
if(millis - lastPingThrough > 10000l) {
RelayServer relay = getPrimary();
if(relay.getPing() > 0l && relay.getPingCompatible().isCompatible()) {
return relay;
}
for(int i = 0, l = relays.size(); i < l; ++i) {
RelayServer relayEtr = relays.get(i);
if(relayEtr != relay) {
if(relayEtr.getPing() > 0l && relayEtr.getPingCompatible().isCompatible()) {
return relayEtr;
}
}
}
}
return getWorkingRelayActive(progressCallback);
}else {
return null;
}
}
private RelayServer getWorkingRelayActive(Consumer<String> progressCallback) {
if(relays.size() > 0) {
RelayServer relay = getPrimary();
progressCallback.accept(relay.address);
relay.pingBlocking();
if(relay.getPing() > 0l && relay.getPingCompatible().isCompatible()) {
return relay;
}
for(int i = 0, l = relays.size(); i < l; ++i) {
RelayServer relayEtr = relays.get(i);
if(relayEtr != relay) {
progressCallback.accept(relayEtr.address);
relayEtr.pingBlocking();
if(relayEtr.getPing() > 0l && relayEtr.getPingCompatible().isCompatible()) {
return relayEtr;
}
}
}
return null;
}else {
return null;
}
}
}

View file

@ -0,0 +1,23 @@
package net.lax1dude.eaglercraft;
public interface RelayQuery {
public static enum VersionMismatch {
COMPATIBLE, CLIENT_OUTDATED, RELAY_OUTDATED, UNKNOWN;
public boolean isCompatible() {
return this == COMPATIBLE;
}
}
public boolean isQueryOpen();
public boolean isQueryFailed();
public void close();
public int getVersion();
public String getComment();
public String getBrand();
public long getPing();
public VersionMismatch getCompatible();
}

View file

@ -0,0 +1,114 @@
package net.lax1dude.eaglercraft;
import net.lax1dude.eaglercraft.RelayQuery.VersionMismatch;
public class RelayServer {
public final String address;
public final String comment;
private boolean primary;
private RelayQuery query = null;
private int queriedVersion = -1;
private String queriedComment;
private String queriedVendor;
private VersionMismatch queriedCompatible;
private long ping = 0l;
private long workingPing = 0l;
public RelayServer(String address, String comment, boolean primary) {
this.address = address;
this.comment = comment;
this.primary = primary;
}
public RelayServer(RelayEntry etr) {
this(etr.address, etr.comment, etr.primary);
}
public boolean isPrimary() {
return primary;
}
public void setPrimary(boolean primaryee) {
primary = primaryee;
}
public long getPing() {
return ping;
}
public long getWorkingPing() {
return workingPing;
}
public int getPingVersion() {
return queriedVersion;
}
public String getPingComment() {
return queriedComment;
}
public String getPingVendor() {
return queriedVendor;
}
public VersionMismatch getPingCompatible() {
return queriedCompatible;
}
public void pingBlocking() {
ping();
while(getPing() < 0l) {
try {
Thread.sleep(250l);
}catch(InterruptedException ex) {
}
update();
}
}
public void ping() {
close();
query = EaglerAdapter.openRelayQuery(address);
queriedVersion = -1;
queriedComment = null;
queriedVendor = null;
queriedCompatible = VersionMismatch.UNKNOWN;
ping = -1l;
}
public void update() {
if(query != null && !query.isQueryOpen()) {
if(query.isQueryFailed()) {
queriedVersion = -1;
queriedComment = null;
queriedVendor = null;
queriedCompatible = VersionMismatch.UNKNOWN;
ping = 0l;
}else {
queriedVersion = query.getVersion();
queriedComment = query.getComment();
queriedVendor = query.getBrand();
ping = query.getPing();
queriedCompatible = query.getCompatible();
workingPing = ping;
}
query = null;
}
}
public void close() {
if(query != null && query.isQueryOpen()) {
query.close();
query = null;
queriedVersion = -1;
queriedComment = null;
queriedVendor = null;
queriedCompatible = VersionMismatch.UNKNOWN;
ping = 0l;
}
}
}

View file

@ -5,6 +5,8 @@ import java.util.List;
import net.lax1dude.eaglercraft.ConfigConstants;
import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.GuiNetworkSettingsButton;
import net.lax1dude.eaglercraft.GuiScreenConnectOption;
public class GuiMultiplayer extends GuiScreen {
/** Number of outstanding ThreadPollServers threads */
@ -62,8 +64,11 @@ public class GuiMultiplayer extends GuiScreen {
private static int cooldownTimer = 0;
private static boolean isLockedOut = false;
private final GuiNetworkSettingsButton relaysButton;
public GuiMultiplayer(GuiScreen par1GuiScreen) {
this.parentScreen = par1GuiScreen;
this.relaysButton = new GuiNetworkSettingsButton(this);
isLockedOut = false;
}
@ -123,14 +128,13 @@ public class GuiMultiplayer extends GuiScreen {
*/
public void initGuiControls() {
StringTranslate var1 = StringTranslate.getInstance();
this.buttonList.add(this.field_96289_p = new GuiButton(7, this.width / 2 - 154 + 36, this.height - 28, 60, 20, var1.translateKey("selectServer.edit")));
this.buttonList.add(this.buttonDelete = new GuiButton(2, this.width / 2 - 74 + 22, this.height - 28, 60, 20, var1.translateKey("selectServer.delete")));
this.buttonList.add(this.field_96289_p = new GuiButton(7, this.width / 2 - 154, this.height - 28, 70, 20, var1.translateKey("selectServer.edit")));
this.buttonList.add(this.buttonDelete = new GuiButton(2, this.width / 2 - 74, this.height - 28, 70, 20, var1.translateKey("selectServer.delete")));
this.buttonList.add(this.buttonSelect = new GuiButton(1, this.width / 2 - 154, this.height - 52, 100, 20, var1.translateKey("selectServer.select")));
this.buttonList.add(new GuiButton(4, this.width / 2 - 50, this.height - 52, 100, 20, var1.translateKey("selectServer.direct")));
this.buttonList.add(new GuiButton(3, this.width / 2 + 4 + 50, this.height - 52, 100, 20, var1.translateKey("selectServer.add")));
this.buttonList.add(new GuiButton(8, this.width / 2 + 4 + 10, this.height - 28, 60, 20, var1.translateKey("selectServer.refresh")));
this.buttonList.add(new GuiButton(8, this.width / 2 + 4, this.height - 28, 70, 20, var1.translateKey("selectServer.refresh")));
this.buttonList.add(new GuiButton(0, this.width / 2 + 4 + 76, this.height - 28, 75, 20, var1.translateKey("gui.cancel")));
this.buttonList.add(new GuiButton(10, this.width / 2 - 154, this.height - 28, 30, 20, var1.translateKey("selectServer.lan")));
boolean var2 = this.selectedServer >= 0 && this.selectedServer < this.serverSlotContainer.getSize();
this.buttonSelect.enabled = var2;
this.field_96289_p.enabled = var2;
@ -153,6 +157,10 @@ public class GuiMultiplayer extends GuiScreen {
EaglerAdapter.enableRepeatEvents(false);
}
public ServerData getTheServerData() {
return this.theServerData = new ServerData(StatCollector.translateToLocal("selectServer.defaultName"), "", false);
}
/**
* Fired when a control is clicked. This is the equivalent of
* ActionListener.actionPerformed(ActionEvent e).
@ -176,7 +184,7 @@ public class GuiMultiplayer extends GuiScreen {
this.joinServer(this.selectedServer);
} else if (par1GuiButton.id == 4) {
this.directClicked = true;
this.mc.displayGuiScreen(new GuiScreenDirectConnect(this, this.theServerData = new ServerData(StatCollector.translateToLocal("selectServer.defaultName"), "", false)));
this.mc.displayGuiScreen(new GuiScreenConnectOption(this));
} else if (par1GuiButton.id == 3) {
this.addClicked = true;
this.mc.displayGuiScreen(new GuiScreenAddServer(this, this.theServerData = new ServerData(StatCollector.translateToLocal("selectServer.defaultName"), "", false)));
@ -194,8 +202,6 @@ public class GuiMultiplayer extends GuiScreen {
--cooldownTimer;
this.mc.displayGuiScreen(new GuiMultiplayer(this.parentScreen));
}
} else if (par1GuiButton.id == 10) {
this.mc.displayGuiScreen(this.parentScreen);
} else {
this.serverSlotContainer.actionPerformed(par1GuiButton);
}
@ -323,6 +329,8 @@ public class GuiMultiplayer extends GuiScreen {
isLockedOut = false;
}
}
relaysButton.drawScreen(par1, par2);
}
@ -335,6 +343,7 @@ public class GuiMultiplayer extends GuiScreen {
return;
}
}
relaysButton.mouseClicked(par1, par2, par3);
super.mouseClicked(par1, par2, par3);
}

View file

@ -31,7 +31,7 @@ public class GuiScreenDirectConnect extends GuiScreen {
this.buttonList.clear();
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, var1.translateKey("selectServer.select")));
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, var1.translateKey("gui.cancel")));
this.serverTextField = new GuiTextField(this.fontRenderer, this.width / 2 - 100, 116, 200, 20);
this.serverTextField = new GuiTextField(this.fontRenderer, this.width / 2 - 100, this.height / 4 + 27, 200, 20);
this.serverTextField.setMaxStringLength(128);
this.serverTextField.setFocused(true);
this.serverTextField.setText(this.mc.gameSettings.lastServer);
@ -89,10 +89,10 @@ public class GuiScreenDirectConnect extends GuiScreen {
StringTranslate var4 = StringTranslate.getInstance();
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, var4.translateKey("selectServer.direct"), this.width / 2, this.height / 4 - 60 + 20, 16777215);
this.drawString(this.fontRenderer, var4.translateKey("addServer.enterIp"), this.width / 2 - 100, 100, 10526880);
this.drawString(this.fontRenderer, var4.translateKey("addServer.enterIp"), this.width / 2 - 100, this.height / 4 + 12, 10526880);
if(EaglerAdapter.isSSLPage()) {
this.drawCenteredString(this.fontRenderer, var4.translateKey("addServer.SSLWarn1"), this.width / 2, 116 + 28, 0xccccff);
this.drawCenteredString(this.fontRenderer, var4.translateKey("addServer.SSLWarn2"), this.width / 2, 116 + 40, 0xccccff);
this.drawCenteredString(this.fontRenderer, var4.translateKey("addServer.SSLWarn1"), this.width / 2, this.height / 4 + 30 + 28, 0xccccff);
this.drawCenteredString(this.fontRenderer, var4.translateKey("addServer.SSLWarn2"), this.width / 2, this.height / 4 + 30 + 40, 0xccccff);
}
this.serverTextField.drawTextBox();
super.drawScreen(par1, par2, par3);

View file

@ -68,9 +68,34 @@ class GuiSlotServer extends GuiSlot {
protected void drawSlot(int par1, int par2, int par3, int par4, Tessellator par5Tessellator) {
if (par1 < GuiMultiplayer.getInternetServerList(this.parentGui).countServers()) {
this.func_77247_d(par1, par2, par3, par4, par5Tessellator);
}else {
this.func_77249_c(par1, par2, par3, par4, par5Tessellator);
}
}
private void func_77249_c(int par1, int par2, int par3, int par4, Tessellator par5Tessellator) {
this.parentGui.drawCenteredString(this.parentGui.fontRenderer,
StatCollector.translateToLocal("lanServer.scanning"), this.parentGui.width / 2, par3 + 6, 16777215);
String var6;
switch (GuiMultiplayer.getTicksOpened(this.parentGui) / 3 % 4) {
case 0:
default:
var6 = "O o o";
break;
case 1:
case 3:
var6 = "o O o";
break;
case 2:
var6 = "o o O";
}
this.parentGui.drawCenteredString(this.parentGui.fontRenderer, var6, this.parentGui.width / 2, par3 + 18, 8421504);
}
private static final TextureLocation icons = new TextureLocation("/gui/icons.png");
private void func_77247_d(int par1, int par2, int par3, int par4, Tessellator par5Tessellator) {

View file

@ -14,6 +14,7 @@ import net.lax1dude.eaglercraft.Base64;
import net.lax1dude.eaglercraft.ConfigConstants;
import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.LocalStorageManager;
import net.lax1dude.eaglercraft.RelayEntry;
import net.lax1dude.eaglercraft.ServerQuery.QueryResponse;
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.RateLimit;
import net.minecraft.client.Minecraft;
@ -114,6 +115,29 @@ public class ServerList {
}
}
ConfigConstants.relays = new ArrayList();
JSONArray relays = json.optJSONArray("relays");
if(relays != null) {
for(int i = 0, l = relays.length(); i < l; ++i) {
JSONObject relay = relays.getJSONObject(i);
String addr = relay.optString("url", null);
if(addr == null) {
addr = relay.optString("address", null);
if(addr == null) {
addr = relay.getString("addr");
}
}
String comment = relay.optString("name", null);
if(comment == null) {
comment = relay.optString("comment", "Default Relay");
}
boolean primary = relay.optBoolean("default", false);
if(!primary) {
primary = relay.optBoolean("primary", false);
}
ConfigConstants.relays.add(new RelayEntry(addr, comment, primary));
}
}
}

View file

@ -91,6 +91,7 @@ import net.lax1dude.eaglercraft.ExpiringSet;
import net.lax1dude.eaglercraft.IntegratedServer;
import net.lax1dude.eaglercraft.LocalStorageManager;
import net.lax1dude.eaglercraft.PKT;
import net.lax1dude.eaglercraft.RelayQuery;
import net.lax1dude.eaglercraft.ServerQuery;
import net.lax1dude.eaglercraft.Voice;
import net.lax1dude.eaglercraft.adapter.teavm.EaglercraftLANClient;
@ -2932,6 +2933,10 @@ public class EaglerAdapterImpl2 {
return !isLittleEndian;
}
public static final RelayQuery openRelayQuery(String addr) {
throw new UnsupportedOperationException("TODO");
}
private static EaglercraftLANClient rtcLANClient = null;
@JSBody(params = { }, script = "return window.startLANClient();")