From 4cc50eddfc48bda51c3ac970f37a04746fb83775 Mon Sep 17 00:00:00 2001 From: Sten Laane <21343173+StenAL@users.noreply.github.com> Date: Mon, 27 May 2024 09:05:43 +0300 Subject: [PATCH 1/6] Deobfuscate start-up code in AApplet Mostly code in AdCanvas, IPanel and LoadingPanel to understand what AApplet is doing. --- .../main/java/com/aapeli/applet/AApplet.java | 227 +++++++++--------- .../main/java/com/aapeli/applet/AdCanvas.java | 28 +-- .../java/com/aapeli/applet/ContentPanel.java | 12 +- .../java/com/aapeli/applet/LoadingPanel.java | 194 +++++++-------- .../main/java/com/aapeli/client/IPanel.java | 82 +++---- .../java/com/aapeli/client/ImageTracker.java | 12 +- 6 files changed, 275 insertions(+), 280 deletions(-) diff --git a/client/src/main/java/com/aapeli/applet/AApplet.java b/client/src/main/java/com/aapeli/applet/AApplet.java index 8b14a123..167d5d7d 100644 --- a/client/src/main/java/com/aapeli/applet/AApplet.java +++ b/client/src/main/java/com/aapeli/applet/AApplet.java @@ -52,9 +52,9 @@ public abstract class AApplet extends Applet implements Runnable, ActionListener public SoundManager soundManager; private ContentPanel contentPanel; private LoadingPanel loadingPanel; - private String aString2547; - private int anInt2548; - private int anInt2549; + private String backgroundImageKey; + private int backgroundXOffset; + private int backgroundYOffset; private int endTextLocation; private int endState; private String endTextCustom; @@ -77,8 +77,9 @@ public void init() { Dimension dim = this.getSize(); this.appletWidth = dim.width; this.appletHeight = dim.height; - this.aString2547 = null; - this.anInt2548 = this.anInt2549 = 0; + this.backgroundImageKey = null; + this.backgroundXOffset = 0; + this.backgroundYOffset = 0; this.endTextLocation = 0; this.endState = 0; this.endTextCustom = null; @@ -114,7 +115,7 @@ public void destroy() { } if (this.contentPanel != null) { - this.contentPanel.dispose(); + this.contentPanel.destroy(); this.contentPanel = null; } @@ -148,18 +149,18 @@ public void destroy() { this.appletImage = null; } - this.aString2547 = null; + this.backgroundImageKey = null; } public String getAppletInfo() { return "-= Playforia Applet =-\nCopyright (c) Playforia (www.playforia.info)\nProgramming: Pasi Laaksonen"; } - public void paint(Graphics var1) { - this.update(var1); + public void paint(Graphics graphics) { + this.update(graphics); } - public void update(Graphics var1) { + public void update(Graphics graphics) { if (!this.destroyed) { if (this.appletImage == null) { this.appletImage = this.createImage(this.appletWidth, this.appletHeight); @@ -172,10 +173,10 @@ public void update(Graphics var1) { Color backgroundColor = this.getBackground(); this.appletGraphics.setColor(backgroundColor); this.appletGraphics.fillRect(0, 0, this.appletWidth, this.appletHeight); - if (this.imageManager != null && this.aString2547 != null) { - Image var3 = this.imageManager.getIfAvailable(this.aString2547); - if (var3 != null) { - this.appletGraphics.drawImage(var3, this.anInt2548, this.anInt2549, this); + if (this.imageManager != null && this.backgroundImageKey != null) { + Image image = this.imageManager.getIfAvailable(this.backgroundImageKey); + if (image != null) { + this.appletGraphics.drawImage(image, this.backgroundXOffset, this.backgroundYOffset, this); } } @@ -183,37 +184,37 @@ public void update(Graphics var1) { this.appletGraphics.setColor(this.getForeground()); Color color = this.aBoolean2554 ? backgroundColor : null; if (this.endState == END_ERROR_CONNECTION) { - byte var4 = -20; + byte yOffset = -20; this.appletGraphics.setFont(fontDialog15); - StringDraw.drawOutlinedString(this.appletGraphics, color, this.textManager.getShared("Message_CE_ConnectionError"), 40, 80 + var4, -1); + StringDraw.drawOutlinedString(this.appletGraphics, color, this.textManager.getShared("Message_CE_ConnectionError"), 40, 80 + yOffset, -1); this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString(this.appletGraphics, color, this.textManager.getShared("Message_CE_PossibleReasons"), 40, 125 + var4, -1); + StringDraw.drawOutlinedString(this.appletGraphics, color, this.textManager.getShared("Message_CE_PossibleReasons"), 40, 125 + yOffset, -1); if (!this.aBoolean2557) { this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString(this.appletGraphics, color, "- " + this.textManager.getShared("Message_CE0_1_Short"), 40, 160 + var4, -1); + StringDraw.drawOutlinedString(this.appletGraphics, color, "- " + this.textManager.getShared("Message_CE0_1_Short"), 40, 160 + yOffset, -1); this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, color, this.textManager.getShared("Message_CE0_1_Long", this.param.getServerIp(), "" + this.param.getServerPort()), 50, 180 + var4, -1, this.appletWidth - 50 - 50); + StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, color, this.textManager.getShared("Message_CE0_1_Long", this.param.getServerIp(), "" + this.param.getServerPort()), 50, 180 + yOffset, -1, this.appletWidth - 50 - 50); this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString(this.appletGraphics, color, "- " + this.textManager.getShared("Message_CE0_2_Short"), 40, 245 + var4, -1); + StringDraw.drawOutlinedString(this.appletGraphics, color, "- " + this.textManager.getShared("Message_CE0_2_Short"), 40, 245 + yOffset, -1); this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, color, this.textManager.getShared("Message_CE0_2_Long"), 50, 265 + var4, -1, this.appletWidth - 50 - 50); + StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, color, this.textManager.getShared("Message_CE0_2_Long"), 50, 265 + yOffset, -1, this.appletWidth - 50 - 50); this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString(this.appletGraphics, color, "- " + this.textManager.getShared("Message_CE0_3_Short"), 40, 305 + var4, -1); + StringDraw.drawOutlinedString(this.appletGraphics, color, "- " + this.textManager.getShared("Message_CE0_3_Short"), 40, 305 + yOffset, -1); this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, color, this.textManager.getShared("Message_CE0_3_Long"), 50, 325 + var4, -1, this.appletWidth - 50 - 50); + StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, color, this.textManager.getShared("Message_CE0_3_Long"), 50, 325 + yOffset, -1, this.appletWidth - 50 - 50); } else { this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString(this.appletGraphics, color, "- " + this.textManager.getShared("Message_CE1_1_Short"), 40, 160 + var4, -1); + StringDraw.drawOutlinedString(this.appletGraphics, color, "- " + this.textManager.getShared("Message_CE1_1_Short"), 40, 160 + yOffset, -1); this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, color, this.textManager.getShared("Message_CE1_1_Long"), 50, 180 + var4, -1, this.appletWidth - 50 - 50); + StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, color, this.textManager.getShared("Message_CE1_1_Long"), 50, 180 + yOffset, -1, this.appletWidth - 50 - 50); this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString(this.appletGraphics, color, "- " + this.textManager.getShared("Message_CE1_2_Short"), 40, 235 + var4, -1); + StringDraw.drawOutlinedString(this.appletGraphics, color, "- " + this.textManager.getShared("Message_CE1_2_Short"), 40, 235 + yOffset, -1); this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, color, this.textManager.getShared("Message_CE1_2_Long"), 50, 255 + var4, -1, this.appletWidth - 50 - 50); + StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, color, this.textManager.getShared("Message_CE1_2_Long"), 50, 255 + yOffset, -1, this.appletWidth - 50 - 50); this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString(this.appletGraphics, color, "- " + this.textManager.getShared("Message_CE1_3_Short"), 40, 305 + var4, -1); + StringDraw.drawOutlinedString(this.appletGraphics, color, "- " + this.textManager.getShared("Message_CE1_3_Short"), 40, 305 + yOffset, -1); this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, color, this.textManager.getShared("Message_CE1_3_Long"), 50, 325 + var4, -1, this.appletWidth - 50 - 50); + StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, color, this.textManager.getShared("Message_CE1_3_Long"), 50, 325 + yOffset, -1, this.appletWidth - 50 - 50); } } else if (this.endState == END_THROWABLE) { this.appletGraphics.setFont(fontDialog15); @@ -282,7 +283,7 @@ public void update(Graphics var1) { } } - var1.drawImage(this.appletImage, 0, 0, this); + graphics.drawImage(this.appletImage, 0, 0, this); } } @@ -292,19 +293,19 @@ public void run() { this.loadingPanel = new LoadingPanel(this); this.loadingPanel.setBounds(0, 0, this.appletWidth, this.appletHeight); this.add(this.loadingPanel); - this.loadingPanel.method463(); + this.loadingPanel.start(); this.param = new Parameters(this, this.isDebug()); - String var3 = this.param.getParameter("initmessage"); + String initMessage = this.param.getParameter("initmessage"); this.verbose = Boolean.parseBoolean(this.param.getParameter("verbose")); - if (var3 != null && var3.indexOf(124) == -1) { - this.loadingPanel.setLoadingMessage(var3); + if (initMessage != null && initMessage.indexOf('|') == -1) { + this.loadingPanel.setLoadingMessage(initMessage); } this.initApplet(this.param); this.loadingPanel.setBackground(this.getBackground()); this.callJavaScriptJSON("{\"loading\":\"started\"}"); if (this.endState == 0 && !this.destroyed) { - int var4 = (int) (System.currentTimeMillis() - startTime); + int time1 = (int) (System.currentTimeMillis() - startTime); boolean startupDebug = false; String startupDebugParameter = this.param.getParameter("startupdebug"); if (startupDebugParameter != null && Tools.getBoolean(startupDebugParameter)) { @@ -312,24 +313,24 @@ public void run() { this.printSUD("StartUp Debug enabled!"); } - AdCanvas var16 = AdCanvas.method211(this, this.param); - if (var16 != null) { + AdCanvas adCanvas = AdCanvas.create(this, this.param); + if (adCanvas != null) { if (startupDebug) { this.printSUD("Loading ad-image..."); } - this.loadingPanel.method467(0.25D); - var16.method212(); + this.loadingPanel.setActualProgress(0.25D); + adCanvas.method212(); - while (!var16.method213()) { + while (!adCanvas.method213()) { Tools.sleep(50L); if (this.destroyed) { - var16.method217(); + adCanvas.method217(); return; } } - this.loadingPanel.method466(var16, Tools.getBoolean(this.param.getParameter("ad_clicktocontinue"))); + this.loadingPanel.method466(adCanvas, Tools.getBoolean(this.param.getParameter("ad_clicktocontinue"))); if (startupDebug) { this.printSUD("...done"); } @@ -337,12 +338,12 @@ public void run() { this.printSUD("No ad-image"); } - int var7 = (int) (System.currentTimeMillis() - startTime); + int time2 = (int) (System.currentTimeMillis() - startTime); if (startupDebug) { this.printSUD("Creating text manager"); } - this.loadingPanel.method467(0.5D); + this.loadingPanel.setActualProgress(0.5D); this.textManager = new TextManager(this.param, true, this.isDebug()); this.loadingPanel.method462(this.param, this.textManager); if (startupDebug) { @@ -356,12 +357,12 @@ public void run() { this.printSUD("...done"); } - String var8 = null; - if (var16 != null && var16.method216()) { - var8 = " " + this.textManager.getShared("Loader_AdClickNote"); + String adInfo = null; + if (adCanvas != null && adCanvas.method216()) { + adInfo = " " + this.textManager.getShared("Loader_AdClickNote"); } - int var9 = (int) (System.currentTimeMillis() - startTime); + int time3 = (int) (System.currentTimeMillis() - startTime); if (System.currentTimeMillis() < startTime + 3000L) { this.loadingPanel.method468(2.0D); } @@ -371,20 +372,20 @@ public void run() { this.printSUD("Creating sound manager"); } - this.loadingPanel.setLoadingMessage(this.textManager.getShared("Loader_LoadingGfxSfx") + (var8 != null ? var8 : "")); + this.loadingPanel.setLoadingMessage(this.textManager.getShared("Loader_LoadingGfxSfx") + (adInfo != null ? adInfo : "")); this.soundManager = new SoundManager(this, true, this.isDebug()); if (startupDebug) { this.soundManager.enableSUD(); } - this.loadingPanel.method465(0.15D); + this.loadingPanel.addProgress(0.15D); if (startupDebug) { this.printSUD("Defining sounds..."); } this.defineSounds(this.soundManager); if (!this.destroyed) { - int var10 = (int) (System.currentTimeMillis() - startTime); + int time4 = (int) (System.currentTimeMillis() - startTime); if (startupDebug) { this.printSUD("...done"); } @@ -399,7 +400,7 @@ public void run() { } this.imageManager.setImageAliases(this.param.getImageAliases()); - this.loadingPanel.method465(0.05D); + this.loadingPanel.addProgress(0.05D); this.defineImages(this.imageManager, this.param.getSiteName()); if (!this.destroyed) { this.imageManager.startLoadingImages(); @@ -413,10 +414,10 @@ public void run() { return; } - this.loadingPanel.method467(0.7D + this.imageManager.getImageLoadProgress() * 0.15D); + this.loadingPanel.setActualProgress(0.7D + this.imageManager.getImageLoadProgress() * 0.15D); } - int var11 = (int) (System.currentTimeMillis() - startTime); + int time5 = (int) (System.currentTimeMillis() - startTime); if (startupDebug) { this.printSUD("...done"); } @@ -425,7 +426,7 @@ public void run() { this.printSUD("Creating images..."); } - this.loadingPanel.method465(0.05D); + this.loadingPanel.addProgress(0.05D); this.createImages(); if (startupDebug) { this.printSUD("...done"); @@ -444,20 +445,20 @@ public void run() { } if (!this.destroyed) { - int var12 = (int) (System.currentTimeMillis() - startTime); + int time6 = (int) (System.currentTimeMillis() - startTime); if (startupDebug) { this.printSUD("Connecting to server..."); } - this.loadingPanel.setLoadingMessage(this.textManager.getShared("Message_Connecting") + (var8 != null ? var8 : "")); - this.loadingPanel.method467(1.0D); + this.loadingPanel.setLoadingMessage(this.textManager.getShared("Message_Connecting") + (adInfo != null ? adInfo : "")); + this.loadingPanel.setActualProgress(1.0D); this.connectToServer(); if (startupDebug) { this.printSUD("...done"); } if (this.endState == 0) { - int var13 = (int) (System.currentTimeMillis() - startTime); + int readyTime = (int) (System.currentTimeMillis() - startTime); this.aBoolean2557 = true; if (startupDebug) { this.printSUD("Waiting loader screen to finish..."); @@ -467,24 +468,24 @@ public void run() { this.loadingPanel.method468(5.0D); this.loadingPanel.method470(); - LoadingPanel var14; + LoadingPanel loadingPanel; do { - var14 = this.loadingPanel; - if (this.destroyed || var14 == null) { + loadingPanel = this.loadingPanel; + if (this.destroyed || loadingPanel == null) { return; } Tools.sleep(50L); - } while (!var14.method471()); + } while (!loadingPanel.isLoaded()); - int var15 = (int) (System.currentTimeMillis() - startTime); + int finishedTime = (int) (System.currentTimeMillis() - startTime); if (startupDebug) { this.printSUD("...done"); } - this.sendLoadTimes(var13, var15, var4, var7, var9, var10, var11, var12); - this.writeThriftDebug("clientconnect", "loadtime:i:" + var13 + "^loadertime:i:" + var15); - this.loadingPanel.method472(); + this.sendLoadTimes(readyTime, finishedTime, time1, time2, time3, time4, time5, time6); + this.writeThriftDebug("clientconnect", "loadtime:i:" + readyTime + "^loadertime:i:" + finishedTime); + this.loadingPanel.displayButtons(); if (this.endState == 0 && !this.destroyed) { this.remove(this.loadingPanel); this.loadingPanel.destroy(); @@ -496,8 +497,8 @@ public void run() { this.contentPanel = new ContentPanel(this); this.contentPanel.setBounds(0, 0, this.appletWidth, this.appletHeight); - if (this.aString2547 != null) { - this.contentPanel.setBackground(this.imageManager, this.aString2547, this.anInt2548, this.anInt2549); + if (this.backgroundImageKey != null) { + this.contentPanel.setBackground(this.imageManager, this.backgroundImageKey, this.backgroundXOffset, this.backgroundYOffset); } this.contentPanel.setVisible(false); @@ -544,16 +545,16 @@ public void qtFinished() { this.allowExternalPopups(); } - public void setBackground(String var1) { - this.setBackground(var1, 0, 0); + public void setBackground(String imageKey) { + this.setBackground(imageKey, 0, 0); } - public void setBackground(String var1, int var2, int var3) { - this.aString2547 = var1; - this.anInt2548 = var2; - this.anInt2549 = var3; + public void setBackground(String imageKey, int xOffset, int yOffset) { + this.backgroundImageKey = imageKey; + this.backgroundXOffset = xOffset; + this.backgroundYOffset = yOffset; if (this.contentPanel != null) { - this.contentPanel.setBackground(this.imageManager, var1, var2, var3); + this.contentPanel.setBackground(this.imageManager, imageKey, xOffset, yOffset); } this.repaint(); @@ -574,7 +575,7 @@ public void setEndState(int state) { this.endState = state; this.removeLoadingPanel(); if (this.contentPanel != null) { - this.contentPanel.dispose(); + this.contentPanel.destroy(); } if (state == END_ERROR_CONNECTION) { @@ -592,8 +593,8 @@ public void setEndState(int state) { } } - public void setEndState(String var1) { - this.endTextCustom = var1; + public void setEndState(String endMessage) { + this.endTextCustom = endMessage; this.setEndState(END_OTHER); } @@ -605,7 +606,7 @@ public void setEndState(Throwable var1) { public void clearContent() { if (this.endState == 0) { - this.contentPanel.dispose(); + this.contentPanel.destroy(); } } @@ -631,7 +632,7 @@ public void printSUD(String var1) { System.out.println("SUD(" + System.currentTimeMillis() + "): " + var1); } - public abstract void initApplet(Parameters var1); + public abstract void initApplet(Parameters parameters); public void textsLoadedNotify(TextManager var1) { } @@ -642,7 +643,7 @@ public void textsLoadedNotify(TextManager var1) { public abstract void createImages(); - public void defineSecImages(ImageManager var1, String var2) { + public void defineSecImages(ImageManager imageManager, String var2) { } public abstract void connectToServer(); @@ -674,8 +675,8 @@ public void waitAndRemoveSplash(int millis, boolean noRepaint) { } } - public boolean callJavaScriptJSON(String var1) { - return this.param.callJavaScriptJSON(var1); + public boolean callJavaScriptJSON(String json) { + return this.param.callJavaScriptJSON(json); } public void blockExternalPopups() { @@ -722,58 +723,58 @@ private void removeLoadingPanel() { } - private void sendLoadTimes(int var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8) { + private void sendLoadTimes(int readyTime, int finishedTime, int time1, int time2, int time3, int time4, int time5, int time6) { if (this.isDebug()) { - System.out.println("AApplet.sendLoadTimes(" + var1 + "," + var2 + ")"); + System.out.println("AApplet.sendLoadTimes(" + readyTime + "," + finishedTime + ")"); } try { - String var9 = this.param.getParameter("ld_page"); - if (var9 == null) { + String loadTimesPage = this.param.getParameter("ld_page"); + if (loadTimesPage == null) { return; } - if (!var9.toLowerCase().startsWith("javascript:")) { + if (!loadTimesPage.toLowerCase().startsWith("javascript:")) { return; } - String var10 = this.getSystemProperty("java.version"); - String var11 = this.getSystemProperty("java.vendor"); - if (var11.length() > 128) { - var11 = var11.substring(0, 128); + String javaVersion = this.getSystemProperty("java.version"); + String javaVendor = this.getSystemProperty("java.vendor"); + if (javaVendor.length() > 128) { + javaVendor = javaVendor.substring(0, 128); } - String var12 = Tools.replaceFirst(var9, "%v", var10); - var12 = Tools.replaceFirst(var12, "%w", var11); - var12 = Tools.replaceFirst(var12, "%r", "" + var1); - var12 = Tools.replaceFirst(var12, "%f", "" + var2); - var12 = Tools.replaceFirst(var12, "%1", "" + var3); - var12 = Tools.replaceFirst(var12, "%2", "" + var4); - var12 = Tools.replaceFirst(var12, "%3", "" + var5); - var12 = Tools.replaceFirst(var12, "%4", "" + var6); - var12 = Tools.replaceFirst(var12, "%5", "" + var7); - var12 = Tools.replaceFirst(var12, "%6", "" + var8); - URL var13 = new URL(var12); + String queryUrl = Tools.replaceFirst(loadTimesPage, "%v", javaVersion); + queryUrl = Tools.replaceFirst(queryUrl, "%w", javaVendor); + queryUrl = Tools.replaceFirst(queryUrl, "%r", "" + readyTime); + queryUrl = Tools.replaceFirst(queryUrl, "%f", "" + finishedTime); + queryUrl = Tools.replaceFirst(queryUrl, "%1", "" + time1); + queryUrl = Tools.replaceFirst(queryUrl, "%2", "" + time2); + queryUrl = Tools.replaceFirst(queryUrl, "%3", "" + time3); + queryUrl = Tools.replaceFirst(queryUrl, "%4", "" + time4); + queryUrl = Tools.replaceFirst(queryUrl, "%5", "" + time5); + queryUrl = Tools.replaceFirst(queryUrl, "%6", "" + time6); + URL url = new URL(queryUrl); if (this.isDebug()) { - System.out.println("AApplet.sendLoadTimes(...): Displaying page \"" + var13.toString() + "\""); + System.out.println("AApplet.sendLoadTimes(...): Displaying page \"" + url.toString() + "\""); } - this.getAppletContext().showDocument(var13); - } catch (Exception var14) { + this.getAppletContext().showDocument(url); + } catch (Exception e) { ; } } - private String getSystemProperty(String var1) { + private String getSystemProperty(String key) { try { - String var2 = System.getProperty(var1); - if (var2 != null) { - return var2; + String result = System.getProperty(key); + if (result != null) { + return result; } - } catch (Exception var3) { + } catch (Exception e) { ; - } catch (Error var4) { + } catch (Error e) { ; } diff --git a/client/src/main/java/com/aapeli/applet/AdCanvas.java b/client/src/main/java/com/aapeli/applet/AdCanvas.java index 5bc07fac..1bd4c647 100644 --- a/client/src/main/java/com/aapeli/applet/AdCanvas.java +++ b/client/src/main/java/com/aapeli/applet/AdCanvas.java @@ -13,7 +13,7 @@ class AdCanvas extends Canvas implements MouseListener { private static final String linkTarget = "_blank"; private AApplet gameApplet; - private LoadingPanel aLoadingPanel__116; + private LoadingPanel loadingPanel; private URL anURL117; private Vector aVector118; private URL anURL119; @@ -46,8 +46,8 @@ public void paint(Graphics var1) { public void update(Graphics var1) { if (this.aBoolean123) { if (!this.aBoolean125) { - if (this.aLoadingPanel__116 != null) { - Image var2 = this.aLoadingPanel__116.method469(); + if (this.loadingPanel != null) { + Image var2 = this.loadingPanel.method469(); if (var2 != null) { Point var3 = this.getLocation(); var1.drawImage(var2, -var3.x, -var3.y, this); @@ -89,34 +89,34 @@ public void mouseReleased(MouseEvent var1) { public void mouseClicked(MouseEvent var1) { } - protected static AdCanvas method211(AApplet var0, Parameters var1) { + protected static AdCanvas create(AApplet applet, Parameters parameters) { try { - String var2 = var1.getParameter("ad_image"); - URL var3 = new URL(var0.getCodeBase(), var2); + String var2 = parameters.getParameter("ad_image"); + URL var3 = new URL(applet.getCodeBase(), var2); Vector var4 = new Vector(); String var6; - for (int var5 = 1; (var6 = var1.getParameter("ad_text-" + var5)) != null; ++var5) { + for (int var5 = 1; (var6 = parameters.getParameter("ad_text-" + var5)) != null; ++var5) { AdCanvasText var7 = AdCanvasText.method1547(var6); if (var7 != null) { var4.addElement(var7); } } - String var14 = var1.getParameter("ad_page"); + String var14 = parameters.getParameter("ad_page"); URL var8 = var14 != null ? new URL(var14) : null; - String var9 = var1.getParameter("ad_target"); + String var9 = parameters.getParameter("ad_target"); if (var9 == null) { var9 = linkTarget; } int var10 = 10; - String var11 = var1.getParameter("ad_mintime"); + String var11 = parameters.getParameter("ad_mintime"); if (var11 != null) { var10 = Integer.parseInt(var11); } - AdCanvas var12 = new AdCanvas(var0, var3, var4, var8, var9, var10); + AdCanvas var12 = new AdCanvas(applet, var3, var4, var8, var9, var10); return var12; } catch (Exception var13) { return null; @@ -155,8 +155,8 @@ protected boolean method213() { } } - protected void method214(LoadingPanel var1) { - this.aLoadingPanel__116 = var1; + protected void method214(LoadingPanel loadingPanel) { + this.loadingPanel = loadingPanel; this.aLong126 = System.currentTimeMillis(); this.repaint(); } @@ -190,7 +190,7 @@ protected void method217() { this.anURL117 = this.anURL119 = null; this.aString120 = null; - this.aLoadingPanel__116 = null; + this.loadingPanel = null; this.gameApplet = null; } } diff --git a/client/src/main/java/com/aapeli/applet/ContentPanel.java b/client/src/main/java/com/aapeli/applet/ContentPanel.java index 5c316bfc..1a500310 100644 --- a/client/src/main/java/com/aapeli/applet/ContentPanel.java +++ b/client/src/main/java/com/aapeli/applet/ContentPanel.java @@ -1,19 +1,17 @@ package com.aapeli.applet; -import com.aapeli.applet.AApplet; import com.aapeli.client.IPanel; -import java.awt.LayoutManager; class ContentPanel extends IPanel { - protected ContentPanel(AApplet var1) { - this.setBackground(var1.getBackground()); - this.setForeground(var1.getForeground()); - this.setLayout((LayoutManager) null); + protected ContentPanel(AApplet applet) { + this.setBackground(applet.getBackground()); + this.setForeground(applet.getForeground()); + this.setLayout(null); } - protected void dispose() { + protected void destroy() { this.setVisible(false); this.removeAll(); } diff --git a/client/src/main/java/com/aapeli/applet/LoadingPanel.java b/client/src/main/java/com/aapeli/applet/LoadingPanel.java index 7405129d..276b6c62 100644 --- a/client/src/main/java/com/aapeli/applet/LoadingPanel.java +++ b/client/src/main/java/com/aapeli/applet/LoadingPanel.java @@ -10,7 +10,6 @@ import java.awt.Font; import java.awt.Graphics; import java.awt.Image; -import java.awt.LayoutManager; import java.awt.Panel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -20,66 +19,67 @@ class LoadingPanel extends Panel implements Runnable, ActionListener { private static final Font fontDialog14 = new Font("Dialog", 0, 14); private static final Font fontDialog20b = new Font("Dialog", 1, 20); private AApplet gameApplet; - private Parameters aParameters581; - private TextManager aTextManager582; + private Parameters parameters; + private TextManager textManager; private String loadingMessage; - private double aDouble584; - private double aDouble585; + private double actualProgress; + private double renderedProgress; private double aDouble586; - private int anInt587; + private int updateInterval; private boolean aBoolean588; private boolean aBoolean589; - private boolean aBoolean590; + private boolean loaded; private boolean destroyed; private Image panelImage; private Graphics panelGraphics; private AdCanvas adCanvas; private boolean aBoolean595; - private RoundButton aRoundButton596; - private RoundButton aRoundButton597; - private int anInt598; + private RoundButton startGameButton; + private RoundButton paymentOptionsButton; + private int startGameClicked; - protected LoadingPanel(AApplet var1) { - this.gameApplet = var1; + protected LoadingPanel(AApplet applet) { + this.gameApplet = applet; this.loadingMessage = null; - this.aDouble584 = this.aDouble585 = 0.0D; + this.actualProgress = 0.0D; + this.renderedProgress = 0.0D; this.aDouble586 = 0.0018D; - this.anInt587 = 50; - this.aBoolean590 = false; + this.updateInterval = 50; + this.loaded = false; this.destroyed = false; this.aBoolean588 = true; this.aBoolean589 = true; - this.anInt598 = -1; + this.startGameClicked = -1; } - public void paint(Graphics var1) { - this.update(var1); + public void paint(Graphics graphics) { + this.update(graphics); } - public synchronized void update(Graphics var1) { + public synchronized void update(Graphics graphics) { if (!this.destroyed) { - AApplet var2 = this.gameApplet; - if (var2 != null) { - int var3 = var2.appletWidth; - int var4 = var2.appletHeight; + AApplet applet = this.gameApplet; + if (applet != null) { + int width = applet.appletWidth; + int height = applet.appletHeight; if (this.panelImage == null) { - this.panelImage = this.createImage(var3, var4); + this.panelImage = this.createImage(width, height); this.panelGraphics = this.panelImage.getGraphics(); this.aBoolean588 = true; } - Color var5 = this.getBackground(); - if (var5.equals(Color.black)) { - var5 = new Color(24, 24, 24); + Color background = this.getBackground(); + if (background.equals(Color.black)) { + background = new Color(24, 24, 24); } boolean var6 = this.aBoolean588; this.aBoolean588 = false; if (var6) { - this.drawGradient(this.panelGraphics, var5, 0, 32, 0, var4, 0, var3, this.aBoolean589); + this.drawGradient(this.panelGraphics, background, 0, 32, 0, height, 0, width, this.aBoolean589); this.aBoolean589 = false; - if (this.loadingMessage != null && this.anInt598 == -1) { + if (this.loadingMessage != null && this.startGameClicked == -1) { this.panelGraphics.setColor(this.getForeground()); this.drawLoadingMessage(this.panelGraphics, fontDialog14, this.loadingMessage); } @@ -89,18 +89,18 @@ public synchronized void update(Graphics var1) { } } - if (this.anInt598 == -1) { - this.drawGradient(this.panelGraphics, Color.white, 0, 48, 25, 40, 5, var3 - 5, true); - int var7 = (int) ((double) (var3 - 10) * this.aDouble585); + if (this.startGameClicked == -1) { + this.drawGradient(this.panelGraphics, Color.white, 0, 48, 25, 40, 5, width - 5, true); + int var7 = (int) ((double) (width - 10) * this.renderedProgress); if (var7 > 0) { this.drawGradient(this.panelGraphics, Color.green, 144, 144, 25, 40, 5, 5 + var7, true); } this.panelGraphics.setColor(Color.black); - this.panelGraphics.drawRect(5, 25, var3 - 10 - 1, 14); + this.panelGraphics.drawRect(5, 25, width - 10 - 1, 14); } - var1.drawImage(this.panelImage, 0, 0, this); + graphics.drawImage(this.panelImage, 0, 0, this); } } } @@ -114,8 +114,8 @@ public void setBackground(Color var1) { public void run() { do { try { - Thread.sleep((long) this.anInt587); - } catch (InterruptedException var3) { + Thread.sleep(this.updateInterval); + } catch (InterruptedException e) { ; } @@ -123,73 +123,73 @@ public void run() { return; } - boolean var1 = false; - if (this.aDouble585 < this.aDouble584) { - this.aDouble585 += this.method478(); - if (this.aDouble585 > 1.0D) { - this.aDouble585 = 1.0D; + boolean done = false; + if (this.renderedProgress < this.actualProgress) { + this.renderedProgress += this.getNextProgressIncrementToRender(); + if (this.renderedProgress > 1.0D) { + this.renderedProgress = 1.0D; } - var1 = true; + done = true; } - if (this.aDouble584 >= 1.0D && this.gameApplet.isDebug()) { - this.aDouble585 = 1.0D; - var1 = true; + if (this.actualProgress >= 1.0D && this.gameApplet.isDebug()) { + this.renderedProgress = 1.0D; + done = true; } - if (var1) { + if (done) { this.repaint(); } - } while (this.aDouble585 < 1.0D); + } while (this.renderedProgress < 1.0D); - this.aBoolean590 = true; + this.loaded = true; } - public void actionPerformed(ActionEvent var1) { - if (var1.getSource() == this.aRoundButton596) { - this.anInt598 = 1; + public void actionPerformed(ActionEvent action) { + if (action.getSource() == this.startGameButton) { + this.startGameClicked = 1; } else { this.gameApplet.setEndState(AApplet.END_QUIT_BUYCOINS); - this.aParameters581.showCreditPurchasePage(false); + this.parameters.showCreditPurchasePage(false); } } - protected void method462(Parameters var1, TextManager var2) { - this.aParameters581 = var1; - this.aTextManager582 = var2; + protected void method462(Parameters parameters, TextManager textManager) { + this.parameters = parameters; + this.textManager = textManager; } - protected void method463() { - Thread var1 = new Thread(this); - var1.start(); + protected void start() { + Thread thread = new Thread(this); + thread.start(); } - protected void setLoadingMessage(String var1) { - this.loadingMessage = var1; + protected void setLoadingMessage(String message) { + this.loadingMessage = message; this.aBoolean588 = true; this.repaint(); } - protected void method465(double var1) { - this.aDouble584 += var1; + protected void addProgress(double progress) { + this.actualProgress += progress; } - protected void method466(AdCanvas var1, boolean var2) { - this.setLayout((LayoutManager) null); + protected void method466(AdCanvas adCanvas, boolean var2) { + this.setLayout(null); int var3 = this.gameApplet.appletWidth - 5 - 5; int var4 = this.gameApplet.appletHeight - 5 - 5 - 40; - Dimension var5 = var1.getSize(); - var1.setLocation(5 + var3 / 2 - var5.width / 2, 45 + var4 / 2 - var5.height / 2); - this.add(var1); - var1.method214(this); - this.adCanvas = var1; + Dimension adCanvasSize = adCanvas.getSize(); + adCanvas.setLocation(5 + var3 / 2 - adCanvasSize.width / 2, 45 + var4 / 2 - adCanvasSize.height / 2); + this.add(adCanvas); + adCanvas.method214(this); + this.adCanvas = adCanvas; this.aBoolean595 = var2; } - protected void method467(double var1) { - this.aDouble584 = var1; + protected void setActualProgress(double actualProgress) { + this.actualProgress = actualProgress; } protected void method468(double var1) { @@ -201,44 +201,44 @@ protected Image method469() { } protected void method470() { - this.anInt587 = 25; + this.updateInterval = 25; } - protected boolean method471() { - return this.aBoolean590; + protected boolean isLoaded() { + return this.loaded; } - protected void method472() { + protected void displayButtons() { if (this.adCanvas != null) { if (this.aBoolean595) { - this.anInt598 = 0; + this.startGameClicked = 0; this.aBoolean588 = true; this.repaint(); short var1 = 300; int var2 = (this.gameApplet.appletWidth - 25 - 15 - 15 - 25) / 2; - int var3 = Math.min(var1, var2); - this.aRoundButton596 = new RoundButton(this.aTextManager582.getShared("Loader_Button_StartGame")); - this.aRoundButton596.setBounds(this.gameApplet.appletWidth / 2 + 15, 10, var3, 35); - this.aRoundButton596.setBackground(new Color(96, 224, 96)); - this.aRoundButton596.setForeground(Color.black); - this.aRoundButton596.setFont(fontDialog20b); - this.aRoundButton596.addActionListener(this); - this.add(this.aRoundButton596); - if (this.aParameters581.isCreditPurchasePageAvailable()) { - this.aRoundButton597 = new RoundButton(this.aTextManager582.getShared("Loader_Button_MorePaymentOptions")); - this.aRoundButton597.setBounds(this.gameApplet.appletWidth / 2 - 15 - var3, 10, var3, 35); - this.aRoundButton597.setBackground(new Color(96, 96, 255)); - this.aRoundButton597.setForeground(Color.black); - this.aRoundButton597.setFont(fontDialog20b); - this.aRoundButton597.addActionListener(this); - this.add(this.aRoundButton597); + int width = Math.min(var1, var2); + this.startGameButton = new RoundButton(this.textManager.getShared("Loader_Button_StartGame")); + this.startGameButton.setBounds(this.gameApplet.appletWidth / 2 + 15, 10, width, 35); + this.startGameButton.setBackground(new Color(96, 224, 96)); + this.startGameButton.setForeground(Color.black); + this.startGameButton.setFont(fontDialog20b); + this.startGameButton.addActionListener(this); + this.add(this.startGameButton); + if (this.parameters.isCreditPurchasePageAvailable()) { + this.paymentOptionsButton = new RoundButton(this.textManager.getShared("Loader_Button_MorePaymentOptions")); + this.paymentOptionsButton.setBounds(this.gameApplet.appletWidth / 2 - 15 - width, 10, width, 35); + this.paymentOptionsButton.setBackground(new Color(96, 96, 255)); + this.paymentOptionsButton.setForeground(Color.black); + this.paymentOptionsButton.setFont(fontDialog20b); + this.paymentOptionsButton.addActionListener(this); + this.add(this.paymentOptionsButton); } do { Tools.sleep(25L); - } while (this.anInt598 == 0 && !this.destroyed); + } while (this.startGameClicked == 0 && !this.destroyed); - this.remove(this.aRoundButton596); + this.remove(this.startGameButton); } } } @@ -359,7 +359,7 @@ private void drawLoadingMessage(Graphics g, Font font, String s) { g.drawString(this.loadingMessage, 6, 19); } - private double method478() { + private double getNextProgressIncrementToRender() { if (this.adCanvas == null) { return this.aDouble586; } else { @@ -367,8 +367,8 @@ private double method478() { if (var1 <= 0) { return this.aDouble586; } else { - double var2 = 1.0D - this.aDouble585; - double var4 = var2 * (double) this.anInt587 / (double) var1; + double remainingProgress = 1.0D - this.renderedProgress; + double var4 = remainingProgress * (double) this.updateInterval / (double) var1; return var4 > this.aDouble586 ? this.aDouble586 : var4; } } diff --git a/client/src/main/java/com/aapeli/client/IPanel.java b/client/src/main/java/com/aapeli/client/IPanel.java index 155b3e8c..aba26f7d 100644 --- a/client/src/main/java/com/aapeli/client/IPanel.java +++ b/client/src/main/java/com/aapeli/client/IPanel.java @@ -1,8 +1,5 @@ package com.aapeli.client; -import com.aapeli.client.Class84; -import com.aapeli.client.ImageManager; - import java.awt.Component; import java.awt.Container; import java.awt.Dimension; @@ -10,45 +7,44 @@ import java.awt.Image; import java.awt.Panel; import java.awt.Point; -import java.awt.image.ImageObserver; public class IPanel extends Panel { - private Image anImage644; - private int anInt645; - private int anInt646; + private Image backgroundImage; + private int backgroundImageXOffset; + private int backgroundImageYOffset; private Class84 aClass84_647; private Object anObject648 = new Object(); public static int anInt649; - public void paint(Graphics var1) { - this.update(var1); + public void paint(Graphics graphics) { + this.update(graphics); } - public void update(Graphics var1) { - this.drawBackground(var1); + public void update(Graphics graphics) { + this.drawBackground(graphics); } - public void setBackground(Image var1) { - this.setBackground(var1, 0, 0); + public void setBackground(Image image) { + this.setBackground(image, 0, 0); } - public void setBackground(Image var1, int var2, int var3) { - this.anImage644 = var1; - this.anInt645 = var2; - this.anInt646 = var3; + public void setBackground(Image image, int xOffset, int yOffset) { + this.backgroundImage = image; + this.backgroundImageXOffset = xOffset; + this.backgroundImageYOffset = yOffset; this.recursiveRepaint(); } - public void setBackground(ImageManager var1, String var2) { - this.setBackground(var1, var2, 0, 0); + public void setBackground(ImageManager imageManager, String imageKey) { + this.setBackground(imageManager, imageKey, 0, 0); } - public void setBackground(ImageManager var1, String var2, int var3, int var4) { - Image var5 = var1.getIfAvailable(var2); - if (var5 != null) { - this.setBackground(var5, var3, var4); + public void setBackground(ImageManager imageManager, String imageKey, int xOffset, int yOffset) { + Image image = imageManager.getIfAvailable(imageKey); + if (image != null) { + this.setBackground(image, xOffset, yOffset); } else { Object var6 = this.anObject648; synchronized (this.anObject648) { @@ -56,7 +52,7 @@ public void setBackground(ImageManager var1, String var2, int var3, int var4) { this.aClass84_647.method1653(); } - this.aClass84_647 = new Class84(this, this, var1, var2, var3, var4, false); + this.aClass84_647 = new Class84(this, this, imageManager, imageKey, xOffset, yOffset, false); } } @@ -87,31 +83,31 @@ public void drawBackground(Graphics var1) { } - public boolean drawBackgroundImage(Graphics var1) { - Object[] var2 = this.getBackgroundAndLocation(0, 0); - if (var2 == null) { + public boolean drawBackgroundImage(Graphics graphics) { + Object[] backgroundData = this.getBackgroundAndLocation(0, 0); + if (backgroundData == null) { return false; } else { - Image var3 = (Image) ((Image) var2[0]); - int var4 = ((Integer) ((Integer) var2[1])).intValue(); - int var5 = ((Integer) ((Integer) var2[2])).intValue(); - Dimension var6 = this.getSize(); - var1.drawImage(var3, 0, 0, var6.width, var6.height, -var4, -var5, -var4 + var6.width, -var5 + var6.height, (ImageObserver) null); + Image backgroundImage = (Image) backgroundData[0]; + int backgroundImageXOffset = (Integer) backgroundData[1]; + int backgroundImageYOffset = (Integer) backgroundData[2]; + Dimension size = this.getSize(); + graphics.drawImage(backgroundImage, 0, 0, size.width, size.height, -backgroundImageXOffset, -backgroundImageYOffset, -backgroundImageXOffset + size.width, -backgroundImageYOffset + size.height, null); return true; } } public void recursiveRepaint() { this.repaint(); - Component[] var1 = this.getComponents(); - if (var1 != null) { - int var2 = var1.length; - if (var2 != 0) { - for (int var3 = 0; var3 < var2; ++var3) { - if (var1[var3] instanceof IPanel) { - ((IPanel) ((IPanel) var1[var3])).recursiveRepaint(); + Component[] components = this.getComponents(); + if (components != null) { + int componentsCount = components.length; + if (componentsCount != 0) { + for (Component component : components) { + if (component instanceof IPanel) { + ((IPanel) component).recursiveRepaint(); } else { - var1[var3].repaint(); + component.repaint(); } } @@ -120,8 +116,8 @@ public void recursiveRepaint() { } public Object[] getBackgroundAndLocation(int var1, int var2) { - if (this.anImage644 != null) { - return new Object[]{this.anImage644, new Integer(this.anInt645 + var1), new Integer(this.anInt646 + var2)}; + if (this.backgroundImage != null) { + return new Object[]{this.backgroundImage, new Integer(this.backgroundImageXOffset + var1), new Integer(this.backgroundImageYOffset + var2)}; } else { Container var3 = this.getParent(); if (var3 == null) { @@ -132,7 +128,7 @@ public Object[] getBackgroundAndLocation(int var1, int var2) { Point var4 = this.getLocation(); var1 -= var4.x; var2 -= var4.y; - IPanel var5 = (IPanel) ((IPanel) var3); + IPanel var5 = (IPanel) var3; return var5.getBackgroundAndLocation(var1, var2); } } diff --git a/client/src/main/java/com/aapeli/client/ImageTracker.java b/client/src/main/java/com/aapeli/client/ImageTracker.java index 930e66e2..051bcd06 100644 --- a/client/src/main/java/com/aapeli/client/ImageTracker.java +++ b/client/src/main/java/com/aapeli/client/ImageTracker.java @@ -84,8 +84,8 @@ protected Image getNImage(String var1) { return this.getImage("N\t" + var1, false); } - protected Image getNImageFromTable(String var1) { - return this.getImageFromTable("N\t" + var1); + protected Image getNImageFromTable(String key) { + return this.getImageFromTable("N\t" + key); } protected Image method1629(String var1) { @@ -205,10 +205,10 @@ private Image getImage(String var1, boolean var2) { } } - private Image getImageFromTable(String var1) { - Image var2 = (Image) ((Image) this.imageTable.get(var1)); - if (var2 != null) { - return var2; + private Image getImageFromTable(String key) { + Image image = (Image) this.imageTable.get(key); + if (image != null) { + return image; } else { this.method1626(); return null; From b530afad06cedce19e84780b062802910276850c Mon Sep 17 00:00:00 2001 From: Sten Laane <21343173+StenAL@users.noreply.github.com> Date: Mon, 27 May 2024 09:05:43 +0300 Subject: [PATCH 2/6] Deobfuscate lobby selection and chat code These were helpful in tracking down the layout shift bug fixed in LobbyPanel in the next commit. --- .../src/main/java/agolf/game/ChatPanel.java | 2 +- .../main/java/agolf/lobby/LobbyChatPanel.java | 26 +- .../java/agolf/lobby/LobbyControlPanel.java | 27 +- .../src/main/java/agolf/lobby/LobbyPanel.java | 27 +- .../main/java/com/aapeli/client/UrlLabel.java | 236 +++++++------ .../java/com/aapeli/multiuser/ChatBase.java | 323 +++++++++--------- .../java/com/aapeli/multiuser/ChatLobby.java | 164 ++++----- .../java/com/aapeli/multiuser/UserList.java | 86 ++--- 8 files changed, 443 insertions(+), 448 deletions(-) diff --git a/client/src/main/java/agolf/game/ChatPanel.java b/client/src/main/java/agolf/game/ChatPanel.java index 1ecfab02..761c7f0b 100644 --- a/client/src/main/java/agolf/game/ChatPanel.java +++ b/client/src/main/java/agolf/game/ChatPanel.java @@ -160,7 +160,7 @@ protected void addBroadcastMessage(String message) { } private void create() { - this.setLayout((LayoutManager) null); + this.setLayout(null); this.textAreaChat = new ChatTextArea(this.gameContainer.textManager, this.gameContainer.badWordFilter, this.width, this.height - 22, new Font("Dialog", 0, 11)); this.textAreaChat.setLocation(0, 0); this.textFieldMessage = new InputTextField(this.gameContainer.textManager.getGame("GameChat_TypeHere"), 200, true); diff --git a/client/src/main/java/agolf/lobby/LobbyChatPanel.java b/client/src/main/java/agolf/lobby/LobbyChatPanel.java index 0944b5ed..ec116849 100644 --- a/client/src/main/java/agolf/lobby/LobbyChatPanel.java +++ b/client/src/main/java/agolf/lobby/LobbyChatPanel.java @@ -69,8 +69,8 @@ protected boolean handlePacket(String[] args) { aBoolean3714 = false;// ?? } } else { - super.gui_output.clear(); - super.gui_userlist.removeAllUsers(); + super.chatTextArea.clear(); + super.userList.removeAllUsers(); } int numSingleLobby = Integer.parseInt(args[2]); @@ -124,7 +124,7 @@ protected boolean handlePacket(String[] args) { message = this.gameContainer.textManager.getGame("LobbyChat_UsersInThisLobbyXX", lobbyUsers, ingameUsers); } - super.gui_output.addPlainMessage(message); + super.chatTextArea.addPlainMessage(message); message = null; if (this.lobbyId == 1 && (dualLobbyUsers >= 1 || multiLobbyUsers >= 1)) { message = "("; @@ -202,10 +202,10 @@ protected boolean handlePacket(String[] args) { } if (message != null) { - super.gui_output.addPlainMessage(message); + super.chatTextArea.addPlainMessage(message); } - super.gui_output.addLine(); + super.chatTextArea.addLine(); return true; } else if(args[1].equals("users")) { @@ -226,7 +226,7 @@ else if(args[1].equals("ownjoin")) { else if(args[1].equals("join") || args[1].equals("joinfromgame")) { String userData = this.userJoin(args[2]); if (!this.isNoJoinPartMessages()) { - super.gui_output.addJoinMessage(this.gameContainer.textManager.getGame("LobbyChat_User" + (args[1].equals("join") ? "Joined" : "ReturnedFromGame"), userData)); + super.chatTextArea.addJoinMessage(this.gameContainer.textManager.getGame("LobbyChat_User" + (args[1].equals("join") ? "Joined" : "ReturnedFromGame"), userData)); } return true; @@ -236,7 +236,7 @@ else if(args[1].equals("part")) { int reason = Integer.parseInt(args[3]); if(reason == 1 && this.lobbyId == 1) { if (!this.isNoGameMessages()) { - super.gui_output.addMessage(this.gameContainer.textManager.getGame("LobbyChat_UserStartedSp", args[2])); + super.chatTextArea.addMessage(this.gameContainer.textManager.getGame("LobbyChat_UserStartedSp", args[2])); } return true; @@ -250,13 +250,13 @@ else if(args[1].equals("part")) { var5 = this.gameContainer.textManager.getGame("LobbyChat_User" + reasons[reason], args[2], args[4]); } - super.gui_output.addMessage(var5); + super.chatTextArea.addMessage(var5); } return true; } else if(reason >= 4) { if (!this.isNoJoinPartMessages()) { - super.gui_output.addPartMessage(this.gameContainer.textManager.getGame("LobbyChat_UserLeft" + (reason == 5 ? "ConnectionProblem" : ""), args[2])); + super.chatTextArea.addPartMessage(this.gameContainer.textManager.getGame("LobbyChat_UserLeft" + (reason == 5 ? "ConnectionProblem" : ""), args[2])); } return true; @@ -266,7 +266,7 @@ else if(args[1].equals("part")) { } else if(args[1].equals("gsn")) { if (!this.isNoGameMessages()) { - super.gui_output.addMessage(this.gameContainer.textManager.getGame("LobbyChat_UsersStartedDp", args[2], args[3])); + super.chatTextArea.addMessage(this.gameContainer.textManager.getGame("LobbyChat_UsersStartedDp", args[2], args[3])); } return true; @@ -297,14 +297,14 @@ else if (args[1].equals("nc")) { protected void getUser(String name, boolean var2) { UserListItem var3; if (name != null) { - var3 = super.gui_userlist.getUser(name); + var3 = super.userList.getUser(name); if (var3 == null) { return; } } else { - var3 = super.gui_userlist.getLocalUser(); + var3 = super.userList.getLocalUser(); } - super.gui_userlist.setNotAcceptingChallenges(var3, var2); + super.userList.setNotAcceptingChallenges(var3, var2); } } diff --git a/client/src/main/java/agolf/lobby/LobbyControlPanel.java b/client/src/main/java/agolf/lobby/LobbyControlPanel.java index 11cdb51b..45cbceb7 100644 --- a/client/src/main/java/agolf/lobby/LobbyControlPanel.java +++ b/client/src/main/java/agolf/lobby/LobbyControlPanel.java @@ -6,7 +6,6 @@ import com.aapeli.colorgui.ColorButton; import java.awt.Graphics; -import java.awt.LayoutManager; import java.awt.Panel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -14,8 +13,8 @@ class LobbyControlPanel extends Panel implements ActionListener { private GameContainer gameContainer; - private int height; private int width; + private int height; private ColorButton buttonBack; private ColorButton buttonSingle; //private ColorButton buttonDual; @@ -25,8 +24,8 @@ class LobbyControlPanel extends Panel implements ActionListener { protected LobbyControlPanel(GameContainer gameContainer, int width, int height) { this.gameContainer = gameContainer; - this.height = width; - this.width = height; + this.width = width; + this.height = height; this.setSize(width, height); this.create(); } @@ -36,13 +35,13 @@ public void addNotify() { this.repaint(); } - public void paint(Graphics var1) { - this.update(var1); + public void paint(Graphics graphics) { + this.update(graphics); } - public void update(Graphics var1) { - var1.setColor(GameApplet.colourGameBackground); - var1.fillRect(0, 0, this.height, this.width); + public void update(Graphics graphics) { + graphics.setColor(GameApplet.colourGameBackground); + graphics.fillRect(0, 0, this.width, this.height); } public void actionPerformed(ActionEvent evt) { @@ -98,15 +97,15 @@ protected void setState(int state) { } private void create() { - this.setLayout((LayoutManager) null); + this.setLayout(null); this.buttonBack = new ColorButton(this.gameContainer.textManager.getGame("LobbyControl_Main")); this.buttonBack.setBackground(GameApplet.colourButtonYellow); - this.buttonBack.setBounds(0, 0, this.height, 20); + this.buttonBack.setBounds(0, 0, this.width, 20); this.buttonBack.addActionListener(this); this.add(this.buttonBack); if (!this.gameContainer.disableSinglePlayer) { this.buttonSingle = new ColorButton(this.gameContainer.textManager.getGame("LobbyControl_Single")); - this.buttonSingle.setBounds(0, 27, this.height, 20); + this.buttonSingle.setBounds(0, 27, this.width, 20); this.buttonSingle.addActionListener(this); } @@ -117,11 +116,11 @@ private void create() { */ this.buttonMulti = new ColorButton(this.gameContainer.textManager.getGame("LobbyControl_Multi")); - this.buttonMulti.setBounds(0, 77, this.height, 20); + this.buttonMulti.setBounds(0, 77, this.width, 20); this.buttonMulti.addActionListener(this); this.buttonQuit = new ColorButton(this.gameContainer.textManager.getGame("LobbyControl_Quit")); this.buttonQuit.setBackground(GameApplet.colourButtonRed); - this.buttonQuit.setBounds(0, this.width - 20, this.height, 20); + this.buttonQuit.setBounds(0, this.height - 20, this.width, 20); this.buttonQuit.addActionListener(this); this.add(this.buttonQuit); } diff --git a/client/src/main/java/agolf/lobby/LobbyPanel.java b/client/src/main/java/agolf/lobby/LobbyPanel.java index 033b6c04..6358a5c5 100644 --- a/client/src/main/java/agolf/lobby/LobbyPanel.java +++ b/client/src/main/java/agolf/lobby/LobbyPanel.java @@ -6,8 +6,7 @@ import com.aapeli.multiuser.UserListItem; import org.moparforia.client.Launcher; -import java.awt.Graphics; -import java.awt.Panel; +import java.awt.*; public class LobbyPanel extends Panel { @@ -40,13 +39,13 @@ public void addNotify() { this.repaint(); } - public void paint(Graphics var1) { - this.update(var1); + public void paint(Graphics graphics) { + this.update(graphics); } - public void update(Graphics var1) { - var1.setColor(GameApplet.colourGameBackground); - var1.fillRect(0, 0, this.width, this.height); + public void update(Graphics graphics) { + graphics.setColor(GameApplet.colourGameBackground); + graphics.fillRect(0, 0, this.width, this.height); } public void selectLobby(int lobbyId, int lobbyExtra) { @@ -193,17 +192,17 @@ public void handlePacket(String[] args) { } - public void broadcastMessage(String var1) { + public void broadcastMessage(String message) { if (this.lobbyChatPanelSingle != null) { - this.lobbyChatPanelSingle.broadcastMessage(var1); + this.lobbyChatPanelSingle.broadcastMessage(message); } if (this.lobbyChatPanelDual != null) { - this.lobbyChatPanelDual.broadcastMessage(var1); + this.lobbyChatPanelDual.broadcastMessage(message); } if (this.lobbyChatPanelMulti != null) { - this.lobbyChatPanelMulti.broadcastMessage(var1); + this.lobbyChatPanelMulti.broadcastMessage(message); } } @@ -224,9 +223,9 @@ protected void getUser(String name, boolean var2) { this.lobbyChatPanelDual.getUser(name, var2); } - protected boolean isNotAcceptingChallenges(String var1) { - UserListItem var2 = this.lobbyChatPanelDual.gui_userlist.getUser(var1); - return var2 != null ? var2.isNotAcceptingChallenges() : true; + protected boolean isNotAcceptingChallenges(String user) { + UserListItem userItem = this.lobbyChatPanelDual.userList.getUser(user); + return userItem != null ? userItem.isNotAcceptingChallenges() : true; } protected Choicer addChoicerNumTracks(Panel container, int x, int y, int width, int height) { diff --git a/client/src/main/java/com/aapeli/client/UrlLabel.java b/client/src/main/java/com/aapeli/client/UrlLabel.java index 54f68fb6..18e698c3 100644 --- a/client/src/main/java/com/aapeli/client/UrlLabel.java +++ b/client/src/main/java/com/aapeli/client/UrlLabel.java @@ -1,7 +1,5 @@ package com.aapeli.client; -import com.aapeli.client.IPanel; - import java.applet.Applet; import java.awt.Color; import java.awt.Cursor; @@ -22,92 +20,92 @@ public class UrlLabel extends IPanel implements MouseListener { public static final int ALIGN_RIGHT = 1; public static final int TARGET_SAME = 0; public static final int TARGET_NEW = 1; - private static final String[] aStringArray3226 = new String[2]; - private static final Cursor aCursor3227; - private static final Cursor aCursor3228; - private static final Font aFont3229; - private Applet anApplet3230; - private Font aFont3231; - private URL anURL3232; - private String aString3233; - private String aString3234; - private String aString3235; - private int anInt3236; - private int anInt3237; - private int anInt3238; - private int anInt3239; - private Color aColor3240; - private Color aColor3241; - private Color aColor3242; - private Image anImage3243; - private int anInt3244; - private int anInt3245; - private String aString3246; + private static final String[] urlTargets = new String[2]; + private static final Cursor defaultCursor; + private static final Cursor handCursor; + private static final Font fontDialog11; + private Applet applet; + private Font currentFont; + private URL url; + private String text; + private String linkPlaceholderText; + private String suffix; + private int prefixWidth; + private int linkTextWidth; + private int textWidth; + private int alignment; + private Color backgroundColor; + private Color foregroundMainColor; + private Color foregroundSecondaryColor; + private Image backgroundImage; + private int backgroundImageOffsetX; + private int backgroundImageOffsetY; + private String urlTarget; private static final String aString3247 = "Dialog"; - public UrlLabel(Applet var1) { - this(var1, aFont3229, (String) null, (String) null); + public UrlLabel(Applet applet) { + this(applet, fontDialog11, null, null); } - public UrlLabel(Applet var1, String var2, String var3) { - this(var1, aFont3229, var2, var3); + public UrlLabel(Applet applet, String var2, String var3) { + this(applet, fontDialog11, var2, var3); } - public UrlLabel(Applet var1, Font var2, String var3, String var4) { - this.anApplet3230 = var1; - this.aColor3240 = null; - this.aColor3241 = Color.black; - this.aColor3242 = Color.blue; - this.anImage3243 = null; - this.anInt3239 = -1; - this.aString3246 = "_blank"; - this.aFont3231 = var2; + public UrlLabel(Applet applet, Font font, String var3, String var4) { + this.applet = applet; + this.backgroundColor = null; + this.foregroundMainColor = Color.black; + this.foregroundSecondaryColor = Color.blue; + this.backgroundImage = null; + this.alignment = -1; + this.urlTarget = "_blank"; + this.currentFont = font; this.setText(var3, var4); } - public UrlLabel(Applet var1, String var2, String var3, int var4, int var5) { - this(var1, aFont3229, var2, var3); - this.setSize(var4, var5); + public UrlLabel(Applet applet, String var2, String var3, int width, int height) { + this(applet, fontDialog11, var2, var3); + this.setSize(width, height); } - public void update(Graphics var1) { - Dimension var2 = this.getSize(); - int var3 = var2.width; - int var4 = var2.height; - if (this.anImage3243 != null) { - var1.drawImage(this.anImage3243, 0, 0, var3, var4, this.anInt3244, this.anInt3245, this.anInt3244 + var3, this.anInt3245 + var4, this); - } else if (!this.drawBackgroundImage(var1)) { - var1.setColor(this.aColor3240 != null ? this.aColor3240 : this.getBackground()); - var1.fillRect(0, 0, var3, var4); + public void update(Graphics graphics) { + Dimension size = this.getSize(); + int width = size.width; + int height = size.height; + if (this.backgroundImage != null) { + graphics.drawImage(this.backgroundImage, 0, 0, width, height, this.backgroundImageOffsetX, this.backgroundImageOffsetY, this.backgroundImageOffsetX + width, this.backgroundImageOffsetY + height, this); + } else if (!this.drawBackgroundImage(graphics)) { + graphics.setColor(this.backgroundColor != null ? this.backgroundColor : this.getBackground()); + graphics.fillRect(0, 0, width, height); } - if (this.aString3233 != null) { - int var5 = 2; - int var6 = this.aFont3231.getSize(); - int var7 = var4 / 2 + var6 * 3 / 8; - int var8 = var4 / 2 + var6 / 2; - if (this.anInt3239 == 0) { - var5 = var3 / 2 - this.anInt3238 / 2; + if (this.text != null) { + int x = 2; + int fontSize = this.currentFont.getSize(); + int y = height / 2 + fontSize * 3 / 8; + int var8 = height / 2 + fontSize / 2; + if (this.alignment == 0) { + x = width / 2 - this.textWidth / 2; } - if (this.anInt3239 == 1) { - var5 = var3 - 2 - this.anInt3238; + if (this.alignment == 1) { + x = width - 2 - this.textWidth; } - if (this.aString3234 != null && this.aString3235 != null) { - var1.setColor(this.aColor3242); - var1.drawLine(var5 + this.anInt3236, var8, var5 + this.anInt3236 + this.anInt3237, var8); + if (this.linkPlaceholderText != null && this.suffix != null) { + graphics.setColor(this.foregroundSecondaryColor); + graphics.drawLine(x + this.prefixWidth, var8, x + this.prefixWidth + this.linkTextWidth, var8); } - var1.setFont(this.aFont3231); - var1.setColor(this.aColor3241); - var1.drawString(this.aString3233, var5, var7); - if (this.aString3234 != null && this.aString3235 != null) { - var1.setColor(this.aColor3242); - var1.drawString(this.aString3234, var5 + this.anInt3236, var7); - var1.setColor(this.aColor3241); - var1.drawString(this.aString3235, var5 + this.anInt3236 + this.anInt3237, var7); + graphics.setFont(this.currentFont); + graphics.setColor(this.foregroundMainColor); + graphics.drawString(this.text, x, y); + if (this.linkPlaceholderText != null && this.suffix != null) { + graphics.setColor(this.foregroundSecondaryColor); + graphics.drawString(this.linkPlaceholderText, x + this.prefixWidth, y); + graphics.setColor(this.foregroundMainColor); + graphics.drawString(this.suffix, x + this.prefixWidth + this.linkTextWidth, y); } } @@ -123,99 +121,99 @@ public void mousePressed(MouseEvent var1) { } public void mouseReleased(MouseEvent var1) { - this.anApplet3230.getAppletContext().showDocument(this.anURL3232, this.aString3246); + this.applet.getAppletContext().showDocument(this.url, this.urlTarget); } public void mouseClicked(MouseEvent var1) { } - public void setText(String var1, String var2) { - if (var1 == null) { - this.aString3233 = this.aString3234 = this.aString3235 = null; - this.anURL3232 = null; - this.setCursor(aCursor3227); + public void setText(String text, String url) { + if (text == null) { + this.text = this.linkPlaceholderText = this.suffix = null; + this.url = null; + this.setCursor(defaultCursor); this.repaint(); } else { - this.anURL3232 = null; - if (var2 != null) { + this.url = null; + if (url != null) { try { - this.anURL3232 = new URL(var2); - } catch (MalformedURLException var6) { + this.url = new URL(url); + } catch (MalformedURLException e) { ; } } - FontMetrics var3 = this.anApplet3230.getFontMetrics(this.aFont3231); - int var4 = var1.indexOf(60); - int var5 = var1.indexOf(62); - if (this.anURL3232 != null && var4 != -1 && var5 >= var4) { - this.aString3233 = var1.substring(0, var4); - this.aString3234 = var1.substring(var4 + 1, var5); - this.aString3235 = var1.substring(var5 + 1); - this.anInt3236 = var3.stringWidth(this.aString3233); - this.anInt3237 = var3.stringWidth(this.aString3234); - this.anInt3238 = this.anInt3236 + this.anInt3237 + var3.stringWidth(this.aString3235); - this.setCursor(aCursor3228); + FontMetrics fontMetrics = this.applet.getFontMetrics(this.currentFont); + int linkTextStart = text.indexOf('<'); + int linkTextEnd = text.indexOf('>'); + if (this.url != null && linkTextStart != -1 && linkTextEnd >= linkTextStart) { + this.text = text.substring(0, linkTextStart); + this.linkPlaceholderText = text.substring(linkTextStart + 1, linkTextEnd); + this.suffix = text.substring(linkTextEnd + 1); + this.prefixWidth = fontMetrics.stringWidth(this.text); + this.linkTextWidth = fontMetrics.stringWidth(this.linkPlaceholderText); + this.textWidth = this.prefixWidth + this.linkTextWidth + fontMetrics.stringWidth(this.suffix); + this.setCursor(handCursor); this.removeMouseListener(this); this.addMouseListener(this); this.repaint(); } else { - this.aString3233 = var1; - this.anInt3238 = var3.stringWidth(this.aString3233); - this.aString3234 = this.aString3235 = null; - this.setCursor(aCursor3227); + this.text = text; + this.textWidth = fontMetrics.stringWidth(this.text); + this.linkPlaceholderText = this.suffix = null; + this.setCursor(defaultCursor); this.repaint(); } } } - public void setAlign(int var1) { - this.anInt3239 = var1; + public void setAlign(int alignment) { + this.alignment = alignment; this.repaint(); } - public void setForeground(Color var1) { - if (var1 != null) { - int var2 = var1.getRed(); - int var3 = var1.getGreen(); - int var4 = var1.getBlue(); - Color var5 = new Color((var2 * 3 + 0) / 4, (var3 * 3 + 0) / 4, (var4 * 3 + 255) / 4); - this.setForeground(var1, var5); + public void setForeground(Color color) { + if (color != null) { + int r = color.getRed(); + int g = color.getGreen(); + int b = color.getBlue(); + Color secondary = new Color((r * 3 + 0) / 4, (g * 3 + 0) / 4, (b * 3 + 255) / 4); + this.setForeground(color, secondary); } } public void setForeground(Color var1, Color var2) { - this.aColor3241 = var1; - this.aColor3242 = var2; + this.foregroundMainColor = var1; + this.foregroundSecondaryColor = var2; this.repaint(); } - public void setBackground(Color var1) { - this.aColor3240 = var1; + public void setBackground(Color color) { + this.backgroundColor = color; this.repaint(); } - public void setBackgroundImage(Image var1, int var2, int var3) { - this.anImage3243 = var1; - this.anInt3244 = var2; - this.anInt3245 = var3; + public void setBackgroundImage(Image image, int offsetX, int offsetY) { + this.backgroundImage = image; + this.backgroundImageOffsetX = offsetX; + this.backgroundImageOffsetY = offsetY; this.repaint(); } - public void setTarget(int var1) { - this.setTarget(aStringArray3226[var1]); + public void setTarget(int i) { + this.setTarget(urlTargets[i]); } - public void setTarget(String var1) { - this.aString3246 = var1; + public void setTarget(String target) { + this.urlTarget = target; } static { - aStringArray3226[0] = "_top"; - aStringArray3226[1] = "_blank"; - aCursor3227 = new Cursor(0); - aCursor3228 = new Cursor(12); - aFont3229 = new Font("Dialog", 0, 11); + urlTargets[0] = "_top"; + urlTargets[1] = "_blank"; + defaultCursor = new Cursor(Cursor.DEFAULT_CURSOR); + handCursor = new Cursor(Cursor.HAND_CURSOR); + fontDialog11 = new Font("Dialog", Font.PLAIN, 11); } private static char[] method822(String var0) { diff --git a/client/src/main/java/com/aapeli/multiuser/ChatBase.java b/client/src/main/java/com/aapeli/multiuser/ChatBase.java index 16c4e963..6b1544d6 100644 --- a/client/src/main/java/com/aapeli/multiuser/ChatBase.java +++ b/client/src/main/java/com/aapeli/multiuser/ChatBase.java @@ -17,7 +17,6 @@ import java.awt.Dimension; import java.awt.Graphics; import java.awt.Image; -import java.awt.LayoutManager; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -30,8 +29,8 @@ public abstract class ChatBase extends IPanel implements ComponentListener, User public static final int CIDR_NONE = 0; public static final int CIDR_UNREG = 1; public static final int CIDR_UNCONF = 2; - private static final Color aColor2342; - private static boolean aBoolean2343; + private static final Color sayButtonColor; + private static boolean shouldDisplayChatInputHelp; public Parameters param; public TextManager textManager; public ImageManager imageManager; @@ -45,26 +44,26 @@ public abstract class ChatBase extends IPanel implements ComponentListener, User private int anInt2353; private int anInt2354; private String aString2355; - private int anInt2356; - public UserList gui_userlist; - public ChatTextArea gui_output; + private int chatDisabledStatus; + public UserList userList; + public ChatTextArea chatTextArea; public GlobalTextArea gui_globaloutput; - public InputTextField gui_input; - public Component gui_say; - public UrlLabel gui_idnote; + public InputTextField inputTextField; + public Component sayButton; + public UrlLabel signupMessage; private String aString2357; - private Vector chatListeners; + private Vector chatListeners; private Object synchronizedObject; - public ChatBase(Parameters var1, TextManager var2, ImageManager var3, BadWordFilter var4, boolean var5, boolean var6, int var7, int var8) { - this(var1, var2, var3, var4, true, true, var5, var6, false, var7, var8); + public ChatBase(Parameters parameters, TextManager textManager, ImageManager imageManager, BadWordFilter badWordFilter, boolean useSmallFont, boolean var6, int width, int height) { + this(parameters, textManager, imageManager, badWordFilter, true, true, useSmallFont, var6, false, width, height); } - public ChatBase(Parameters var1, TextManager var2, ImageManager var3, BadWordFilter var4, boolean var5, boolean var6, boolean var7, boolean var8, int var9, int var10) { - this(var1, var2, var3, var4, var5, var6, var7, var8, false, var9, var10); + public ChatBase(Parameters parameters, TextManager textManager, ImageManager imageManager, BadWordFilter badWordFilter, boolean var5, boolean var6, boolean useSmallFont, boolean var8, int width, int height) { + this(parameters, textManager, imageManager, badWordFilter, var5, var6, useSmallFont, var8, false, width, height); } - public ChatBase(Parameters params, TextManager textManager, ImageManager imageManager, BadWordFilter badWordFilter, boolean var5, boolean var6, boolean var7, boolean var8, boolean var9, int width, int height) { + public ChatBase(Parameters params, TextManager textManager, ImageManager imageManager, BadWordFilter badWordFilter, boolean var5, boolean var6, boolean useSmallFont, boolean var8, boolean shouldNotWriteWelcomeMessage, int width, int height) { this.param = params; this.textManager = textManager; this.imageManager = imageManager; @@ -75,10 +74,10 @@ public ChatBase(Parameters params, TextManager textManager, ImageManager imageMa this.height = height; this.setSize(width, height); this.aString2355 = null; - this.anInt2356 = 0; - this.method892(var5, var6, var7, var8, var9); + this.chatDisabledStatus = 0; + this.init(var5, var6, useSmallFont, var8, shouldNotWriteWelcomeMessage); this.addComponentListener(this); - this.chatListeners = new Vector(); + this.chatListeners = new Vector<>(); } public void update(Graphics g) { @@ -106,10 +105,10 @@ public void componentMoved(ComponentEvent var1) { } - public void componentResized(ComponentEvent var1) { - Dimension var2 = this.getSize(); - this.width = var2.width; - this.height = var2.height; + public void componentResized(ComponentEvent event) { + Dimension size = this.getSize(); + this.width = size.width; + this.height = size.height; this.resizeLayout(); } @@ -118,7 +117,7 @@ public void openPlayerCard(String var1) { } public void adminCommand(String var1, String var2) { - ChatListener[] var3 = this.method895(); + ChatListener[] var3 = this.getChatListenersCopy(); for (int var4 = 0; var4 < var3.length; ++var4) { var3[var4].localUserAdminCommand(var1, var2); @@ -127,7 +126,7 @@ public void adminCommand(String var1, String var2) { } public void adminCommand(String var1, String var2, String var3) { - ChatListener[] var4 = this.method895(); + ChatListener[] var4 = this.getChatListenersCopy(); for (int var5 = 0; var5 < var4.length; ++var5) { var4[var5].localUserAdminCommand(var1, var2, var3); @@ -135,15 +134,15 @@ public void adminCommand(String var1, String var2, String var3) { } - public void actionPerformed(ActionEvent var1) { - if (var1.getSource() == this.gui_say) { - this.method893(); + public void actionPerformed(ActionEvent event) { + if (event.getSource() == this.sayButton) { + this.sendMessage(); } } public void startedTyping() { - this.aString2357 = this.method894(); + this.aString2357 = this.getMessageRecipient(); } public void clearedField() { @@ -151,32 +150,32 @@ public void clearedField() { } public void enterPressed() { - this.method893(); + this.sendMessage(); } public static UrlLabel setInputByCIDR(int var0, Container var1, InputTextField var2, Component var3, UrlLabel var4, TextManager var5, Parameters var6) { - return method891(var0, var1, var2, var3, var4, var5.getShared("Chat_NoGuestChatAndRegNote"), var5.getShared("Chat_NoUnconfirmedChatNote"), var6); + return getSignupMessage(var0, var1, var2, var3, var4, var5.getShared("Chat_NoGuestChatAndRegNote"), var5.getShared("Chat_NoUnconfirmedChatNote"), var6); } public void setBackground(Color var1) { - if (this.gui_userlist != null) { - this.gui_userlist.setBackground(var1); + if (this.userList != null) { + this.userList.setBackground(var1); } - if (this.gui_idnote != null) { - this.gui_idnote.setBackground(var1); + if (this.signupMessage != null) { + this.signupMessage.setBackground(var1); } this.repaint(); } public void setForeground(Color var1) { - if (this.gui_userlist != null) { - this.gui_userlist.setForeground(var1); + if (this.userList != null) { + this.userList.setForeground(var1); } - if (this.gui_idnote != null) { - this.gui_idnote.setForeground(var1); + if (this.signupMessage != null) { + this.signupMessage.setForeground(var1); } } @@ -188,8 +187,8 @@ public void setBackgroundImage(Image var1, int var2, int var3) { Point var4 = this.getLocation(); this.anInt2353 = var4.x; this.anInt2354 = var4.y; - Point var5 = this.gui_userlist.getLocation(); - this.gui_userlist.setBackgroundImage(var1, var2 + var5.x, var3 + var5.y); + Point var5 = this.userList.getLocation(); + this.userList.setBackgroundImage(var1, var2 + var5.x, var3 + var5.y); this.repaint(); } @@ -202,14 +201,14 @@ public void removeChatListener(ChatListener var1) { } public void setMessageMaximumLength(int var1) { - this.gui_input.setTextMaximumLength(var1); + this.inputTextField.setTextMaximumLength(var1); } public void clearOutput() { Object var1 = this.synchronizedObject; synchronized (this.synchronizedObject) { if (this.gui_globaloutput == null) { - this.gui_output.clear(); + this.chatTextArea.clear(); } else { this.gui_globaloutput.clear(); } @@ -218,27 +217,27 @@ public void clearOutput() { } public void enablePopUp(boolean isModerator, boolean isAdmin) { - this.gui_userlist.enablePopUp(isModerator, isAdmin); + this.userList.enablePopUp(isModerator, isAdmin); } public void addPlainMessage(String var1) { - this.gui_output.addPlainMessage(var1); + this.chatTextArea.addPlainMessage(var1); } public void addMessage(String var1) { - this.gui_output.addMessage(var1); + this.chatTextArea.addMessage(var1); } public void addHighlightMessage(String var1) { - this.gui_output.addHighlightMessage(var1); + this.chatTextArea.addHighlightMessage(var1); } public void addErrorMessage(String var1) { - this.gui_output.addErrorMessage(var1); + this.chatTextArea.addErrorMessage(var1); } public void addLine() { - this.gui_output.addLine(); + this.chatTextArea.addLine(); } public int setFullUserList(String[] list) { @@ -246,14 +245,14 @@ public int setFullUserList(String[] list) { } public int setFullUserList(String[] list, int var2) { - this.gui_userlist.removeAllUsers(); - int var3 = list.length; + this.userList.removeAllUsers(); + int l = list.length; - for (int var4 = 0; var4 < var3; ++var4) { - this.addToUserList(list[var4], var2 == var4); + for (int i = 0; i < l; ++i) { + this.addToUserList(list[i], var2 == i); } - return var3; + return l; } public String localUserJoin(String var1) { @@ -263,7 +262,7 @@ public String localUserJoin(String var1) { public void userSay(String var1, String var2) { if (!this.isUserIgnored(var1)) { - this.gui_output.addSay(var1, var2); + this.chatTextArea.addSay(var1, var2); } } @@ -277,7 +276,7 @@ public void userSay(int var1, String var2, String var3) { public void userSayPrivately(String var1, String var2) { if (!this.isUserIgnored(var1)) { - this.gui_output.addSayPrivately(var1, this.aString2355, var2); + this.chatTextArea.addSayPrivately(var1, this.aString2355, var2); } } @@ -286,7 +285,7 @@ public void sheriffSay(String var1) { Object var2 = this.synchronizedObject; synchronized (this.synchronizedObject) { if (this.gui_globaloutput == null) { - this.gui_output.addSheriffSay(var1); + this.chatTextArea.addSheriffSay(var1); } else { this.gui_globaloutput.method918(var1); } @@ -317,14 +316,14 @@ public void serverSay(String var1) { } if (var4.length() > 1) { - if ((var12.equals("ServerSay_SheriffGaveWarning") || var12.equals("ServerSay_SheriffMutedUser") || var12.equals("ServerSay_SheriffUnMutedUser")) && var3 != null && !this.gui_userlist.isUser(var3)) { + if ((var12.equals("ServerSay_SheriffGaveWarning") || var12.equals("ServerSay_SheriffMutedUser") || var12.equals("ServerSay_SheriffUnMutedUser")) && var3 != null && !this.userList.isUser(var3)) { return; } Object var13 = this.synchronizedObject; synchronized (this.synchronizedObject) { if (this.gui_globaloutput == null) { - this.gui_output.addLocalizedServerSay(var4); + this.chatTextArea.addLocalizedServerSay(var4); } else { this.gui_globaloutput.method920(var4); } @@ -335,7 +334,7 @@ public void serverSay(String var1) { Object var2 = this.synchronizedObject; synchronized (this.synchronizedObject) { if (this.gui_globaloutput == null) { - this.gui_output.addServerSay(var1); + this.chatTextArea.addServerSay(var1); } else { this.gui_globaloutput.method919(var1); } @@ -344,13 +343,13 @@ public void serverSay(String var1) { } } - public void broadcastMessage(String var1) { + public void broadcastMessage(String message) { Object var2 = this.synchronizedObject; synchronized (this.synchronizedObject) { if (this.gui_globaloutput == null) { - this.gui_output.addBroadcastMessage(var1); + this.chatTextArea.addBroadcastMessage(message); } else { - this.gui_globaloutput.method921(var1); + this.gui_globaloutput.method921(message); } } @@ -361,28 +360,28 @@ public boolean isUserInLobby(String var1) { } public boolean isUserInChat(String var1) { - return this.gui_userlist.getUser(var1) != null; + return this.userList.getUser(var1) != null; } - public boolean isUserIgnored(String var1) { - UserListItem var2 = this.gui_userlist.getUser(var1); - return var2 == null ? true : var2.isIgnore(); + public boolean isUserIgnored(String user) { + UserListItem userItem = this.userList.getUser(user); + return userItem == null ? true : userItem.isIgnore(); } public UserList getUserList() { - return this.gui_userlist; + return this.userList; } public boolean useRoundButtons() { Object var1 = this.synchronizedObject; synchronized (this.synchronizedObject) { - if (this.gui_say instanceof RoundButton) { + if (this.sayButton instanceof RoundButton) { return false; } else { - RoundButton var2 = this.copyColorButtonToRoundButton(this.gui_say); - var2.setVisible(this.gui_say.isVisible()); - this.gui_say = var2; - this.gui_userlist.usePixelRoundedButtonsAndCheckBoxes(); + RoundButton var2 = this.copyColorButtonToRoundButton(this.sayButton); + var2.setVisible(this.sayButton.isVisible()); + this.sayButton = var2; + this.userList.usePixelRoundedButtonsAndCheckBoxes(); return true; } } @@ -392,22 +391,22 @@ public void setOutputToGlobal(int var1) { Object var2 = this.synchronizedObject; synchronized (this.synchronizedObject) { if (this.gui_globaloutput == null) { - Point var3 = this.gui_output.getLocation(); - this.remove(this.gui_output); - this.gui_globaloutput = new GlobalTextArea(this, this.gui_output, var1); + Point var3 = this.chatTextArea.getLocation(); + this.remove(this.chatTextArea); + this.gui_globaloutput = new GlobalTextArea(this, this.chatTextArea, var1); this.gui_globaloutput.setLocation(var3.x, var3.y); this.add(this.gui_globaloutput); } } } - public void disableChatInput(int var1) { - this.anInt2356 = var1; - this.method896(); + public void disableChatInput(int status) { + this.chatDisabledStatus = status; + this.paintSignupMessage(); } public boolean isTyping() { - return this.gui_input.isTyping(); + return this.inputTextField.isTyping(); } public abstract void resizeLayout(); @@ -417,7 +416,7 @@ public String addToUserList(String var1, boolean var2) { } public UserListItem addToUserListNew(String var1, boolean var2) { - UserListItem var3 = this.gui_userlist.addUser(var1, var2); + UserListItem var3 = this.userList.addUser(var1, var2); if (var2) { this.aString2355 = var3.getNick(); } @@ -453,14 +452,14 @@ public String getConfirmationNeededText() { } public void setCurrentOutput(ChatTextArea var1) { - this.gui_output = var1; + this.chatTextArea = var1; } protected void method889(UserListItem var1, String var2) { Object var3 = this.synchronizedObject; synchronized (this.synchronizedObject) { if (this.gui_globaloutput == null) { - this.gui_output.addMessage(var2); + this.chatTextArea.addMessage(var2); } else { this.gui_globaloutput.method917(var1.getLanguage(), var2); } @@ -472,7 +471,7 @@ protected void method890(UserListItem var1, UserListItem var2, String var3) { Object var4 = this.synchronizedObject; synchronized (this.synchronizedObject) { if (this.gui_globaloutput == null) { - this.gui_output.addMessage(var3); + this.chatTextArea.addMessage(var3); } else { int var5 = var1.getLanguage(); int var6 = var2.getLanguage(); @@ -485,95 +484,95 @@ protected void method890(UserListItem var1, UserListItem var2, String var3) { } } - private static UrlLabel method891(int var0, Container var1, InputTextField var2, Component var3, UrlLabel var4, String var5, String var6, Parameters var7) { - if (var0 == 0) { - if (var4 != null) { - var4.setVisible(false); + private static UrlLabel getSignupMessage(int chatDisabledStatus, Container container, InputTextField inputTextField, Component sayButton, UrlLabel signupMessage, String registrationNeededText, String confirmationNeededText, Parameters parameters) { + if (chatDisabledStatus == 0) { + if (signupMessage != null) { + signupMessage.setVisible(false); } - var2.setVisible(true); - var3.setVisible(true); - return var4; + inputTextField.setVisible(true); + sayButton.setVisible(true); + return signupMessage; } else { - if (var4 == null) { - var4 = new UrlLabel(var7.getApplet()); - Point var8 = var2.getLocation(); - Point var9 = var3.getLocation(); - Dimension var10 = var3.getSize(); - var4.setBounds(var8.x, var8.y, var9.x + var10.width - var8.x, var9.y + var10.height - var8.y); - var4.setBackground(var1.getBackground()); - var4.setForeground(var1.getForeground()); - var1.add(var4); + if (signupMessage == null) { + signupMessage = new UrlLabel(parameters.getApplet()); + Point inputFieldLocation = inputTextField.getLocation(); + Point sayButtonLocation = sayButton.getLocation(); + Dimension sayButtonSize = sayButton.getSize(); + signupMessage.setBounds(inputFieldLocation.x, inputFieldLocation.y, sayButtonLocation.x + sayButtonSize.width - inputFieldLocation.x, sayButtonLocation.y + sayButtonSize.height - inputFieldLocation.y); + signupMessage.setBackground(container.getBackground()); + signupMessage.setForeground(container.getForeground()); + container.add(signupMessage); } - var2.setVisible(false); - var3.setVisible(false); - if (var0 == 1) { - var4.setText(var5, var7.getRegisterPage()); - var4.setTarget(0); - } else if (var0 == 2) { - var4.setText(var6, (String) null); + inputTextField.setVisible(false); + sayButton.setVisible(false); + if (chatDisabledStatus == 1) { + signupMessage.setText(registrationNeededText, parameters.getRegisterPage()); + signupMessage.setTarget(0); + } else if (chatDisabledStatus == 2) { + signupMessage.setText(confirmationNeededText, null); } else { - var4.setText((String) null, (String) null); + signupMessage.setText(null, null); } - var4.setVisible(true); - return var4; + signupMessage.setVisible(true); + return signupMessage; } } - private void method892(boolean var1, boolean var2, boolean var3, boolean var4, boolean var5) { - this.setLayout((LayoutManager) null); - this.gui_output = new ChatTextArea(this.textManager, this.badWordFilter, 200, 100, var3 ? ChatTextArea.SMALL_FONT : ChatTextArea.DEFAULT_FONT); - if (aBoolean2343 && !var5) { - this.gui_output.addWelcomeMessage(this.textManager.getShared("Chat_Welcome")); + private void init(boolean var1, boolean var2, boolean useSmallFont, boolean var4, boolean shouldNotWriteWelcomeMessage) { + this.setLayout(null); + this.chatTextArea = new ChatTextArea(this.textManager, this.badWordFilter, 200, 100, useSmallFont ? ChatTextArea.SMALL_FONT : ChatTextArea.DEFAULT_FONT); + if (shouldDisplayChatInputHelp && !shouldNotWriteWelcomeMessage) { + this.chatTextArea.addWelcomeMessage(this.textManager.getShared("Chat_Welcome")); } - this.add(this.gui_output); - if (aBoolean2343) { - this.gui_input = new InputTextField(this.textManager.getShared("Chat_InputHelp"), 200, true); - aBoolean2343 = false; + this.add(this.chatTextArea); + if (shouldDisplayChatInputHelp) { + this.inputTextField = new InputTextField(this.textManager.getShared("Chat_InputHelp"), 200, true); + shouldDisplayChatInputHelp = false; } else { - this.gui_input = new InputTextField(200, true); + this.inputTextField = new InputTextField(200, true); } - this.gui_input.addInputTextFieldListener(this); - this.add(this.gui_input); - ColorButton var6 = new ColorButton(this.textManager.getShared("Chat_SayButton")); - var6.setBackground(aColor2342); - var6.addActionListener(this); - this.add(var6); - this.gui_say = var6; - this.gui_userlist = new UserList(this, this.textManager, this.imageManager, !var4, var1, var2); - this.gui_userlist.setChatReference(this); - this.add(this.gui_userlist); - this.gui_idnote = new UrlLabel(this.param.getApplet()); - this.add(this.gui_idnote); - this.method896(); - } - - private void method893() { + this.inputTextField.addInputTextFieldListener(this); + this.add(this.inputTextField); + ColorButton sayButton = new ColorButton(this.textManager.getShared("Chat_SayButton")); + sayButton.setBackground(sayButtonColor); + sayButton.addActionListener(this); + this.add(sayButton); + this.sayButton = sayButton; + this.userList = new UserList(this, this.textManager, this.imageManager, !var4, var1, var2); + this.userList.setChatReference(this); + this.add(this.userList); + this.signupMessage = new UrlLabel(this.param.getApplet()); + this.add(this.signupMessage); + this.paintSignupMessage(); + } + + private void sendMessage() { if (this.aString2355 != null) { - String var1 = this.gui_input.getText().trim(); - if (var1.length() != 0) { - if (!this.floodProtection.isOkToSay(var1)) { - this.gui_output.addFloodMessage(); + String message = this.inputTextField.getText().trim(); + if (message.length() != 0) { + if (!this.floodProtection.isOkToSay(message)) { + this.chatTextArea.addFloodMessage(); } else { - String var2 = this.method894(); + String var2 = this.getMessageRecipient(); String var3 = this.aString2357; this.aString2357 = null; if (var2 == null && var3 != null && !this.isUserInChat(var3)) { - this.gui_output.addPrivateMessageUserLeftMessage(var3); + this.chatTextArea.addPrivateMessageUserLeftMessage(var3); } else { - var1 = this.gui_input.getInputText(); - if (var1.length() > 0) { - ChatListener[] var4 = this.method895(); + message = this.inputTextField.getInputText(); + if (message.length() > 0) { + ChatListener[] var4 = this.getChatListenersCopy(); if (var2 != null) { for (int var10 = 0; var10 < var4.length; ++var10) { - var4[var10].localUserSayPrivately(var2, var1); + var4[var10].localUserSayPrivately(var2, message); } - this.gui_output.addOwnSayPrivately(this.aString2355, var2, var1); + this.chatTextArea.addOwnSayPrivately(this.aString2355, var2, message); return; } @@ -582,18 +581,18 @@ private void method893() { int var6; if (this.gui_globaloutput == null) { for (var6 = 0; var6 < var4.length; ++var6) { - var4[var6].localUserSay(var1); + var4[var6].localUserSay(message); } } else { var6 = this.gui_globaloutput.method914(); for (int var7 = 0; var7 < var4.length; ++var7) { - ((GlobalChatListener) ((GlobalChatListener) var4[var7])).localUserSay(var6, var1); + ((GlobalChatListener) ((GlobalChatListener) var4[var7])).localUserSay(var6, message); } } } - this.gui_output.addOwnSay(this.aString2355, var1); + this.chatTextArea.addOwnSay(this.aString2355, message); } } @@ -602,28 +601,28 @@ private void method893() { } } - private String method894() { - UserListItem var1 = this.gui_userlist.getSelectedUser(); - return var1 != null && var1.isPrivately() ? var1.getNick() : null; + private String getMessageRecipient() { + UserListItem user = this.userList.getSelectedUser(); + return user != null && user.isPrivately() ? user.getNick() : null; } - private ChatListener[] method895() { - int var1 = this.chatListeners.size(); - ChatListener[] var2 = new ChatListener[var1]; + private ChatListener[] getChatListenersCopy() { + int chatListenersCount = this.chatListeners.size(); + ChatListener[] chatListeners = new ChatListener[chatListenersCount]; - for (int var3 = 0; var3 < var1; ++var3) { - var2[var3] = (ChatListener) ((ChatListener) this.chatListeners.elementAt(var3)); + for (int i = 0; i < chatListenersCount; ++i) { + chatListeners[i] = this.chatListeners.elementAt(i); } - return var2; + return chatListeners; } - private void method896() { - this.gui_idnote = method891(this.anInt2356, this, this.gui_input, this.gui_say, this.gui_idnote, this.getRegisterationNeededText(), this.getConfirmationNeededText(), this.param); + private void paintSignupMessage() { + this.signupMessage = getSignupMessage(this.chatDisabledStatus, this, this.inputTextField, this.sayButton, this.signupMessage, this.getRegisterationNeededText(), this.getConfirmationNeededText(), this.param); } static { - aColor2342 = new Color(144, 144, 224); - aBoolean2343 = true; + sayButtonColor = new Color(144, 144, 224); + shouldDisplayChatInputHelp = true; } } diff --git a/client/src/main/java/com/aapeli/multiuser/ChatLobby.java b/client/src/main/java/com/aapeli/multiuser/ChatLobby.java index 410cb169..5df9d9e1 100644 --- a/client/src/main/java/com/aapeli/multiuser/ChatLobby.java +++ b/client/src/main/java/com/aapeli/multiuser/ChatLobby.java @@ -12,71 +12,71 @@ public class ChatLobby extends ChatBase { - private ColorCheckbox aColorCheckbox3664; - private ColorCheckbox aColorCheckbox3665; - private boolean aBoolean3666; + private ColorCheckbox noJoinAndPartMessagesCheckbox; + private ColorCheckbox noGameMessagesChatbox; + private boolean shouldMuteMessagesIfUserListSet; - public ChatLobby(Parameters var1, TextManager var2, ImageManager var3, BadWordFilter var4, int var5, int var6) { - this(var1, var2, var3, var4, false, false, var5, var6); + public ChatLobby(Parameters parameters, TextManager textManager, ImageManager imageManager, BadWordFilter badWordFilter, int width, int height) { + this(parameters, textManager, imageManager, badWordFilter, false, false, width, height); } - public ChatLobby(Parameters var1, TextManager var2, ImageManager var3, BadWordFilter var4, boolean var5, int var6, int var7) { - this(var1, var2, var3, var4, var5, false, var6, var7); + public ChatLobby(Parameters parameters, TextManager textManager, ImageManager imageManager, BadWordFilter badWordFilter, boolean useSmallFont, int width, int height) { + this(parameters, textManager, imageManager, badWordFilter, useSmallFont, false, width, height); } - public ChatLobby(Parameters var1, TextManager var2, ImageManager var3, BadWordFilter var4, boolean var5, boolean var6, int var7, int var8) { - super(var1, var2, var3, var4, var5, var6, var7, var8); - this.method905(); + public ChatLobby(Parameters parameters, TextManager textManager, ImageManager imageManager, BadWordFilter badWordFilter, boolean useSmallFont, boolean var6, int width, int height) { + super(parameters, textManager, imageManager, badWordFilter, useSmallFont, var6, width, height); + this.createSettingsCheckBoxes(); this.resizeLayout(); - this.aBoolean3666 = true; + this.shouldMuteMessagesIfUserListSet = true; } public void setBackground(Color var1) { super.setBackground(var1); - if (this.aColorCheckbox3664 != null) { - this.aColorCheckbox3664.setBackground(var1); + if (this.noJoinAndPartMessagesCheckbox != null) { + this.noJoinAndPartMessagesCheckbox.setBackground(var1); } - if (this.aColorCheckbox3665 != null) { - this.aColorCheckbox3665.setBackground(var1); + if (this.noGameMessagesChatbox != null) { + this.noGameMessagesChatbox.setBackground(var1); } } public void setForeground(Color var1) { super.setForeground(var1); - if (this.aColorCheckbox3664 != null) { - this.aColorCheckbox3664.setForeground(var1); + if (this.noJoinAndPartMessagesCheckbox != null) { + this.noJoinAndPartMessagesCheckbox.setForeground(var1); } - if (this.aColorCheckbox3665 != null) { - this.aColorCheckbox3665.setForeground(var1); + if (this.noGameMessagesChatbox != null) { + this.noGameMessagesChatbox.setForeground(var1); } } public void setBackgroundImage(Image var1, int var2, int var3) { super.setBackgroundImage(var1, var2, var3); - Point var4 = this.aColorCheckbox3664.getLocation(); - Point var5 = this.aColorCheckbox3665.getLocation(); - this.aColorCheckbox3664.setBackgroundImage(var1, var2 + var4.x, var3 + var4.y); - this.aColorCheckbox3665.setBackgroundImage(var1, var2 + var5.x, var3 + var5.y); + Point var4 = this.noJoinAndPartMessagesCheckbox.getLocation(); + Point var5 = this.noGameMessagesChatbox.getLocation(); + this.noJoinAndPartMessagesCheckbox.setBackgroundImage(var1, var2 + var4.x, var3 + var4.y); + this.noGameMessagesChatbox.setBackgroundImage(var1, var2 + var5.x, var3 + var5.y); } public int setFullUserList(String[] list) { - int var2 = super.setFullUserList(list); - if (this.aBoolean3666) { - if (var2 >= 30) { - this.aColorCheckbox3664.setState(true); - if (var2 >= 40) { - this.aColorCheckbox3665.setState(true); + int users = super.setFullUserList(list); + if (this.shouldMuteMessagesIfUserListSet) { + if (users >= 30) { + this.noJoinAndPartMessagesCheckbox.setState(true); + if (users >= 40) { + this.noGameMessagesChatbox.setState(true); } } - this.aBoolean3666 = false; + this.shouldMuteMessagesIfUserListSet = false; } - return var2; + return users; } public String userJoin(String var1) { @@ -85,7 +85,7 @@ public String userJoin(String var1) { public String userJoin(String var1, boolean var2) { UserListItem var3 = this.addToUserListNew(var1, false); - if (!this.aColorCheckbox3664.getState()) { + if (!this.noJoinAndPartMessagesCheckbox.getState()) { this.method889(var3, super.textManager.getShared("Chat_Lobby_User" + (var2 ? "ReturnedFromGame" : "Joined"), var3.getNick())); } @@ -93,45 +93,45 @@ public String userJoin(String var1, boolean var2) { } public void userLeft(String var1) { - super.gui_userlist.removeUser(var1); + super.userList.removeUser(var1); } public void userLeft(String var1, boolean var2) { - UserListItem var3 = super.gui_userlist.removeUserNew(var1); - if (var3 != null && !this.aColorCheckbox3664.getState()) { + UserListItem var3 = super.userList.removeUserNew(var1); + if (var3 != null && !this.noJoinAndPartMessagesCheckbox.getState()) { this.method889(var3, super.textManager.getShared("Chat_Lobby_UserLeft" + (var2 ? "ConnectionProblem" : ""), var1)); } } public void userLeftCreatedGame(String var1, String var2) { - UserListItem var3 = super.gui_userlist.removeUserNew(var1); - if (var3 != null && !this.aColorCheckbox3665.getState()) { + UserListItem var3 = super.userList.removeUserNew(var1); + if (var3 != null && !this.noGameMessagesChatbox.getState()) { this.method889(var3, super.textManager.getShared("Chat_Lobby_UserCreatedGame", var1, var2)); } } public void userLeftJoinedGame(String var1, String var2) { - UserListItem var3 = super.gui_userlist.removeUserNew(var1); - if (var3 != null && !this.aColorCheckbox3665.getState()) { + UserListItem var3 = super.userList.removeUserNew(var1); + if (var3 != null && !this.noGameMessagesChatbox.getState()) { this.method889(var3, super.textManager.getShared("Chat_Lobby_UserJoinedGame", var1, var2)); } } public void userLeftWatchingGame(String var1, String var2) { - UserListItem var3 = super.gui_userlist.removeUserNew(var1); - if (var3 != null && !this.aColorCheckbox3665.getState()) { + UserListItem var3 = super.userList.removeUserNew(var1); + if (var3 != null && !this.noGameMessagesChatbox.getState()) { this.method889(var3, super.textManager.getShared("Chat_Lobby_UserWathicngGame", var1, var2)); } } public void usersLeftStartedGame(String var1, String var2, String var3) { - UserListItem var4 = super.gui_userlist.removeUserNew(var1); - UserListItem var5 = super.gui_userlist.removeUserNew(var2); - if (var4 != null && var5 != null && !this.aColorCheckbox3665.getState()) { + UserListItem var4 = super.userList.removeUserNew(var1); + UserListItem var5 = super.userList.removeUserNew(var2); + if (var4 != null && var5 != null && !this.noGameMessagesChatbox.getState()) { String var6; if (var3 != null) { var6 = super.textManager.getShared("Chat_Lobby_UsersStartedGame", var1, var2, var3); @@ -149,15 +149,15 @@ public void usersLeftStartedGame(String var1, String var2) { } public UserListItem getSelectedUserForChallenge() { - UserListItem var1 = super.gui_userlist.getSelectedUser(); + UserListItem var1 = super.userList.getSelectedUser(); if (var1 == null) { - super.gui_output.addMessage(super.textManager.getShared("Chat_Lobby_CantChallengeNone")); + super.chatTextArea.addMessage(super.textManager.getShared("Chat_Lobby_CantChallengeNone")); } else { if (!var1.isLocal()) { return var1; } - super.gui_output.addMessage(super.textManager.getShared("Chat_Lobby_CantChallengeSelf")); + super.chatTextArea.addMessage(super.textManager.getShared("Chat_Lobby_CantChallengeSelf")); } return null; @@ -169,52 +169,52 @@ public String getSelectedNickForChallenge() { } public boolean[] getCheckBoxStates() { - boolean[] var1 = new boolean[]{this.aColorCheckbox3664.getState(), this.aColorCheckbox3665.getState()}; + boolean[] var1 = new boolean[]{this.noJoinAndPartMessagesCheckbox.getState(), this.noGameMessagesChatbox.getState()}; return var1; } public void setCheckBoxStates(boolean var1, boolean var2) { - this.aColorCheckbox3664.setState(var1); - this.aColorCheckbox3665.setState(var2); + this.noJoinAndPartMessagesCheckbox.setState(var1); + this.noGameMessagesChatbox.setState(var2); } public boolean isNoJoinPartMessages() { - return this.aColorCheckbox3664.getState(); + return this.noJoinAndPartMessagesCheckbox.getState(); } public boolean isNoGameMessages() { - return this.aColorCheckbox3665.getState(); + return this.noGameMessagesChatbox.getState(); } public synchronized boolean useRoundButtons() { if (!super.useRoundButtons()) { return false; } else { - this.aColorCheckbox3664.setBoxPixelRoundedCorners(true); - this.aColorCheckbox3665.setBoxPixelRoundedCorners(true); + this.noJoinAndPartMessagesCheckbox.setBoxPixelRoundedCorners(true); + this.noGameMessagesChatbox.setBoxPixelRoundedCorners(true); return true; } } public void resizeLayout() { - int var1 = super.width / 5; - if (var1 < 100) { - var1 = 100; + int width = super.width / 5; + if (width < 100) { + width = 100; } - if (var1 > 150) { - var1 = 150; + if (width > 150) { + width = 150; } double var2 = ((double) super.height - 100.0D) / 100.0D; - int var4 = (int) (20.0D + var2 * 5.0D); + int height = (int) (20.0D + var2 * 5.0D); int var5 = (int) (15.0D + var2 * 5.0D); - if (var4 < 20) { - var4 = 20; + if (height < 20) { + height = 20; } - if (var4 > 25) { - var4 = 25; + if (height > 25) { + height = 25; } if (var5 < 15) { @@ -225,8 +225,8 @@ public void resizeLayout() { var5 = 20; } - int var6 = super.width - 0 - 3 - var1 - 0; - int var7 = super.height - 0 - var5 - 3 - var4 - 2 - 0; + int var6 = super.width - 0 - 3 - width - 0; + int var7 = super.height - 0 - var5 - 3 - height - 2 - 0; int var8 = (int) (50.0D + ((double) var6 - 200.0D) / 300.0D * 70.0D); if (var8 < 50) { var8 = 50; @@ -238,29 +238,29 @@ public void resizeLayout() { int var9 = var6 - 1 - var8; int var10 = (var6 - 2) / 2; - super.gui_userlist.setBounds(0, 0, var1, super.height - 0 - 0); + super.userList.setBounds(0, 0, width, super.height - 0 - 0); synchronized (this) { if (super.gui_globaloutput == null) { - super.gui_output.setBounds(0 + var1 + 3, 0, var6, var7); + super.chatTextArea.setBounds(0 + width + 3, 0, var6, var7); } else { - super.gui_globaloutput.setBounds(0 + var1 + 3, 0, var6, var7); + super.gui_globaloutput.setBounds(0 + width + 3, 0, var6, var7); } } - int var11 = 0 + var1 + 3; - int var12 = 0 + var7 + 2; - super.gui_input.setBounds(var11, var12, var9, var4); - int var13 = 0 + var1 + 3 + var9 + 1; - super.gui_say.setBounds(var13, 0 + var7 + 2, var8, var4); - this.aColorCheckbox3664.setBounds(0 + var1 + 3, super.height - 0 - var5, var10, var5); - this.aColorCheckbox3665.setBounds(0 + var1 + 3 + var10 + 2, super.height - 0 - var5, var10, var5); - super.gui_idnote.setBounds(var11, var12, var13 - var11 + var8, var4); + int x = 0 + width + 3; + int y = 0 + var7 + 2; + super.inputTextField.setBounds(x, y, var9, height); + int var13 = 0 + width + 3 + var9 + 1; + super.sayButton.setBounds(var13, 0 + var7 + 2, var8, height); + this.noJoinAndPartMessagesCheckbox.setBounds(0 + width + 3, super.height - 0 - var5, var10, var5); + this.noGameMessagesChatbox.setBounds(0 + width + 3 + var10 + 2, super.height - 0 - var5, var10, var5); + super.signupMessage.setBounds(x, y, var13 - x + var8, height); } - private void method905() { - this.aColorCheckbox3664 = new ColorCheckbox(super.textManager.getShared("Chat_Lobby_NoJoinPartMessages")); - this.add(this.aColorCheckbox3664); - this.aColorCheckbox3665 = new ColorCheckbox(super.textManager.getShared("Chat_Lobby_NoGameMessages")); - this.add(this.aColorCheckbox3665); + private void createSettingsCheckBoxes() { + this.noJoinAndPartMessagesCheckbox = new ColorCheckbox(super.textManager.getShared("Chat_Lobby_NoJoinPartMessages")); + this.add(this.noJoinAndPartMessagesCheckbox); + this.noGameMessagesChatbox = new ColorCheckbox(super.textManager.getShared("Chat_Lobby_NoGameMessages")); + this.add(this.noGameMessagesChatbox); } } diff --git a/client/src/main/java/com/aapeli/multiuser/UserList.java b/client/src/main/java/com/aapeli/multiuser/UserList.java index d290f135..c9ee6c7f 100644 --- a/client/src/main/java/com/aapeli/multiuser/UserList.java +++ b/client/src/main/java/com/aapeli/multiuser/UserList.java @@ -45,10 +45,10 @@ public class UserList extends IPanel implements ComponentListener, ItemListener, private static final Color aColor3456; private static final Color aColor3457; private UserListHandler anUserListHandler3458; - private TextManager aTextManager3459; - private ImageManager anImageManager3460; - private int anInt3461; - private int anInt3462; + private TextManager textManager; + private ImageManager imageManager; + private int width; + private int height; private Image[] anImageArray3463; private boolean aBoolean3464; private ColorList aColorList3465; @@ -93,24 +93,24 @@ public class UserList extends IPanel implements ComponentListener, ItemListener, private Hashtable aHashtable3504; - public UserList(UserListHandler var1, TextManager var2, ImageManager var3, boolean var4, boolean var5, boolean var6) { - this(var1, var2, var3, var4, var5, var6, 100, 200); + public UserList(UserListHandler handler, TextManager textManager, ImageManager imageManager, boolean var4, boolean var5, boolean var6) { + this(handler, textManager, imageManager, var4, var5, var6, 100, 200); } - public UserList(UserListHandler hndlr, TextManager var2, ImageManager var3, boolean var4, boolean var5, boolean var6, int var7, int var8) { - this.anUserListHandler3458 = hndlr; - this.aTextManager3459 = var2; - this.anImageManager3460 = var3; - this.anInt3461 = var7; - this.anInt3462 = var8; - this.setSize(var7, var8); + public UserList(UserListHandler handler, TextManager textManager, ImageManager imageManager, boolean var4, boolean var5, boolean var6, int width, int height) { + this.anUserListHandler3458 = handler; + this.textManager = textManager; + this.imageManager = imageManager; + this.width = width; + this.height = height; + this.setSize(width, height); this.aBoolean3464 = var4; this.method931(var5, var6); this.setBackground(aColor3453); this.setForeground(aColor3454); if (var4) { - Image var9 = var3.getShared("ranking-icons.gif"); - this.anImageArray3463 = var3.separateImages(var9, 14); + Image var9 = imageManager.getShared("ranking-icons.gif"); + this.anImageArray3463 = imageManager.separateImages(var9, 14); } this.isSheriff = false; @@ -118,7 +118,7 @@ public UserList(UserListHandler hndlr, TextManager var2, ImageManager var3, bool this.aVector3497 = new Vector(); this.aVector3498 = new Vector(); this.aBoolean3499 = this.aBoolean3500 = true; - this.aLanguages3503 = new Languages(var2, var3); + this.aLanguages3503 = new Languages(textManager, imageManager); this.aHashtable3504 = new Hashtable(); this.addComponentListener(this); } @@ -134,7 +134,7 @@ public void paint(Graphics var1) { public void update(Graphics var1) { if (this.anImage3470 != null) { - var1.drawImage(this.anImage3470, 0, 0, this.anInt3461, this.anInt3462, this.anInt3472, this.anInt3473, this.anInt3472 + this.anInt3461, this.anInt3473 + this.anInt3462, this); + var1.drawImage(this.anImage3470, 0, 0, this.width, this.height, this.anInt3472, this.anInt3473, this.anInt3472 + this.width, this.anInt3473 + this.height, this); } else { this.drawBackground(var1); } @@ -160,24 +160,24 @@ public void componentMoved(ComponentEvent var1) { public void componentResized(ComponentEvent var1) { Dimension var2 = this.getSize(); - this.anInt3461 = var2.width; - this.anInt3462 = var2.height; + this.width = var2.width; + this.height = var2.height; boolean var3 = this.aColorCheckbox3466 != null; boolean var4 = this.aColorCheckbox3467 != null; if (this.aBoolean3464) { this.aColorButton_Sub1_3468.setSize(17, 11); - this.aColorButton_Sub1_3469.setSize(this.anInt3461 - 17, 11); + this.aColorButton_Sub1_3469.setSize(this.width - 17, 11); } - int var5 = this.anInt3461; - int var6 = this.anInt3462 - (var4 ? 18 : 0) - (var3 ? 18 : 0) - (!var4 && !var3 ? 0 : 2) - (this.aBoolean3464 ? 11 : 0); + int var5 = this.width; + int var6 = this.height - (var4 ? 18 : 0) - (var3 ? 18 : 0) - (!var4 && !var3 ? 0 : 2) - (this.aBoolean3464 ? 11 : 0); this.aColorList3465.setBounds(0, this.aBoolean3464 ? 11 : 0, var5, var6); if (var3) { - this.aColorCheckbox3466.setBounds(0, this.anInt3462 - 18 - (var4 ? 18 : 0), this.anInt3461, 18); + this.aColorCheckbox3466.setBounds(0, this.height - 18 - (var4 ? 18 : 0), this.width, 18); } if (var4) { - this.aColorCheckbox3467.setBounds(0, this.anInt3462 - 18, this.anInt3461, 18); + this.aColorCheckbox3467.setBounds(0, this.height - 18, this.width, 18); } this.componentMoved(var1); @@ -272,7 +272,7 @@ public void actionPerformed(ActionEvent var1) { this.method929(4, (String) null); } else if (var2 == this.aMenuItem3491) { CopyChatFrame var4 = new CopyChatFrame(); - var4.create(this.anImageManager3460.getApplet(), (ColorTextArea) (this.aChatBase3502 != null ? this.aChatBase3502.gui_output : this.aColorTextArea3501)); + var4.create(this.imageManager.getApplet(), (ColorTextArea) (this.aChatBase3502 != null ? this.aChatBase3502.chatTextArea : this.aColorTextArea3501)); } else if (var2 == this.aMenuItem3492) { this.anUserListHandler3458.adminCommand("info", this.anUserListItem3495.getNick()); } else if (var2 == this.aMenuItem3493) { @@ -442,7 +442,7 @@ public UserListItem addUser(String userData, boolean userIsLocal, int var3) { } if (!avatarUrl.equals("-")) { - listItem.loadAvatar(avatarUrl, this.anImageManager3460, this.aColorList3465); + listItem.loadAvatar(avatarUrl, this.imageManager, this.aColorList3465); } return listItem; @@ -461,7 +461,7 @@ public void addUser(UserListItem var1) { String var3 = var1.getNick(); if (var1.isSheriff() && this.aBoolean3499) { - var3 = var3 + " " + this.aTextManager3459.getShared("UserList_Sheriff"); + var3 = var3 + " " + this.textManager.getShared("UserList_Sheriff"); } ColorListItem var4 = new ColorListItem(this.method933(var1), this.method930(var1), var1.isRegistered(), var3, var1, false); @@ -663,7 +663,7 @@ private void showSheriffMenu(UserListItem var1, int var2, int var3) { } this.aPopupMenu3479 = new PopupMenu(); - this.aMenuItem3480 = this.method927(this.aPopupMenu3479, this.aTextManager3459.getShared("UserList_OpenPlayerCard")); + this.aMenuItem3480 = this.method927(this.aPopupMenu3479, this.textManager.getShared("UserList_OpenPlayerCard")); this.aMenuItem3480.setEnabled(var1.isRegistered() || var1.method1826() != null); if (this.aColorCheckbox3466 != null || this.aColorCheckbox3467 != null) { this.aPopupMenu3479.addSeparator(); @@ -735,8 +735,8 @@ private void method929(int var1, String var2) { this.aStaffActionFrame__3496.windowClosing((WindowEvent) null); } - this.aStaffActionFrame__3496 = new StaffActionFrame(this.aTextManager3459, this.anUserListHandler3458, var1, var2); - this.aStaffActionFrame__3496.method251(this.anImageManager3460.getApplet(), this.adminStatus > 0); + this.aStaffActionFrame__3496 = new StaffActionFrame(this.textManager, this.anUserListHandler3458, var1, var2); + this.aStaffActionFrame__3496.method251(this.imageManager.getApplet(), this.adminStatus > 0); } private Color method930(UserListItem var1) { @@ -750,24 +750,24 @@ private Color method930(UserListItem var1) { } private void method931(boolean var1, boolean var2) { - this.setLayout((LayoutManager) null); + this.setLayout(null); if (this.aBoolean3464) { - this.aColorButton_Sub1_3468 = new ColorButton_Sub1(this.aTextManager3459.getShared("UserList_SortByRanking")); + this.aColorButton_Sub1_3468 = new ColorButton_Sub1(this.textManager.getShared("UserList_SortByRanking")); this.aColorButton_Sub1_3468.setBounds(0, 0, 17, 11); this.aColorButton_Sub1_3468.setFont(aFont3455); this.aColorButton_Sub1_3468.setBackground(aColor3456); this.aColorButton_Sub1_3468.addActionListener(this); this.add(this.aColorButton_Sub1_3468); - this.aColorButton_Sub1_3469 = new ColorButton_Sub1(this.aTextManager3459.getShared("UserList_SortByNick")); - this.aColorButton_Sub1_3469.setBounds(17, 0, this.anInt3461 - 17, 11); + this.aColorButton_Sub1_3469 = new ColorButton_Sub1(this.textManager.getShared("UserList_SortByNick")); + this.aColorButton_Sub1_3469.setBounds(17, 0, this.width - 17, 11); this.aColorButton_Sub1_3469.setFont(aFont3455); this.aColorButton_Sub1_3469.setBackground(aColor3457); this.aColorButton_Sub1_3469.addActionListener(this); this.add(this.aColorButton_Sub1_3469); } - int var3 = this.anInt3461; - int var4 = this.anInt3462 - (var2 ? 18 : 0) - (var1 ? 18 : 0) - (!var2 && !var1 ? 0 : 2) - (this.aBoolean3464 ? 11 : 0); + int var3 = this.width; + int var4 = this.height - (var2 ? 18 : 0) - (var1 ? 18 : 0) - (!var2 && !var1 ? 0 : 2) - (this.aBoolean3464 ? 11 : 0); if (this.aBoolean3464) { this.aColorList3465 = new ColorList(var3, var4, 11, 11); } else { @@ -780,15 +780,15 @@ private void method931(boolean var1, boolean var2) { this.add(this.aColorList3465); this.setSorting(1); if (var1) { - this.aColorCheckbox3466 = new ColorCheckbox(this.aTextManager3459.getShared("UserList_Privately")); - this.aColorCheckbox3466.setBounds(0, this.anInt3462 - 18 - (var2 ? 18 : 0), this.anInt3461, 18); + this.aColorCheckbox3466 = new ColorCheckbox(this.textManager.getShared("UserList_Privately")); + this.aColorCheckbox3466.setBounds(0, this.height - 18 - (var2 ? 18 : 0), this.width, 18); this.aColorCheckbox3466.addItemListener(this); this.add(this.aColorCheckbox3466); } if (var2) { - this.aColorCheckbox3467 = new ColorCheckbox(this.aTextManager3459.getShared("UserList_Ignore")); - this.aColorCheckbox3467.setBounds(0, this.anInt3462 - 18, this.anInt3461, 18); + this.aColorCheckbox3467 = new ColorCheckbox(this.textManager.getShared("UserList_Ignore")); + this.aColorCheckbox3467.setBounds(0, this.height - 18, this.width, 18); this.aColorCheckbox3467.addItemListener(this); this.add(this.aColorCheckbox3467); } @@ -853,12 +853,12 @@ private boolean openProfilePage(UserListItem var1) { return false; } else { try { - String var3 = this.aTextManager3459.getParameters().getParameter("guestinfotarget"); + String var3 = this.textManager.getParameters().getParameter("guestinfotarget"); if (var3 == null) { var3 = "_blank"; } - this.anImageManager3460.getApplet().getAppletContext().showDocument(new URL(var2), var3); + this.imageManager.getApplet().getAppletContext().showDocument(new URL(var2), var3); } catch (Exception var4) { ; } @@ -929,7 +929,7 @@ private UserListItem method937(String var1, boolean var2, int var3) { } if (!var16.equals("-")) { - var14.loadAvatar(Tools.changeFromSaveable(var16), this.anImageManager3460, this.aColorList3465); + var14.loadAvatar(Tools.changeFromSaveable(var16), this.imageManager, this.aColorList3465); } } From 36ae7731818606bea67071ff5498651a3e3079ce Mon Sep 17 00:00:00 2001 From: Sten Laane <21343173+StenAL@users.noreply.github.com> Date: Mon, 27 May 2024 09:05:43 +0300 Subject: [PATCH 3/6] Fix layout shift when resizing the game while in a lobby Resizing the applet caused the lobby screen to do a new layout and since it was using the default LayoutManager (FlowLayout), the panels were being placed in unintended places. Most other classes explicitly set the layout manager to null to avoid this, however, looks like this was overlooked in LobbyPanel. --- client/src/main/java/agolf/lobby/LobbyPanel.java | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/main/java/agolf/lobby/LobbyPanel.java b/client/src/main/java/agolf/lobby/LobbyPanel.java index 6358a5c5..c67ff597 100644 --- a/client/src/main/java/agolf/lobby/LobbyPanel.java +++ b/client/src/main/java/agolf/lobby/LobbyPanel.java @@ -31,6 +31,7 @@ public LobbyPanel(GameContainer gameContainer, int width, int height) { this.gameContainer = gameContainer; this.width = width; this.height = height; + this.setLayout(null); this.setSize(width, height); } From 8bd754de7d0b972dcebad8f648f803153dc6654b Mon Sep 17 00:00:00 2001 From: Sten Laane <21343173+StenAL@users.noreply.github.com> Date: Mon, 27 May 2024 09:05:43 +0300 Subject: [PATCH 4/6] Fix client connection retry behaviour Previously, this tried to open a new page in the browser, however, in our environment, appletContext was null and was throwing an exception. This was fixed by destroying the game applet and reinitializing it when the retry button is clicked. Reinitalizing the applet caused its size to get re-measured which was leading to layout bugs after retries, this was fixed by hardcoding the applet width and height in AApplet. Since the whole game is hardcoded for this size, this does not result in any problems elsewhere. --- .../main/java/com/aapeli/applet/AApplet.java | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/client/src/main/java/com/aapeli/applet/AApplet.java b/client/src/main/java/com/aapeli/applet/AApplet.java index 167d5d7d..70bb919d 100644 --- a/client/src/main/java/com/aapeli/applet/AApplet.java +++ b/client/src/main/java/com/aapeli/applet/AApplet.java @@ -60,7 +60,7 @@ public abstract class AApplet extends Applet implements Runnable, ActionListener private String endTextCustom; private Throwable aThrowable2553; private boolean aBoolean2554; - private boolean aBoolean2555; + private boolean notStarted; private boolean destroyed; private boolean aBoolean2557; private RetryCanvas retryCanvas; @@ -74,9 +74,8 @@ public abstract class AApplet extends Applet implements Runnable, ActionListener public void init() { System.out.println("\n" + this.getAppletInfo() + "\n"); - Dimension dim = this.getSize(); - this.appletWidth = dim.width; - this.appletHeight = dim.height; + this.appletWidth = 735; + this.appletHeight = 525; this.backgroundImageKey = null; this.backgroundXOffset = 0; this.backgroundYOffset = 0; @@ -86,14 +85,14 @@ public void init() { this.aThrowable2553 = null; this.aBoolean2554 = false; this.aBoolean2557 = false; - this.aBoolean2555 = true; + this.notStarted = true; this.destroyed = false; this.verbose = false; } public void start() { - if (this.aBoolean2555 && !this.destroyed) { - this.aBoolean2555 = false; + if (this.notStarted && !this.destroyed) { + this.notStarted = false; Thread t = new Thread(this); t.start(); } @@ -526,16 +525,12 @@ public void run() { public void actionPerformed(ActionEvent action) { if (action.getSource() == this.retryCanvas) { try { - String url = this.getDocumentBase().toString(); - if (url.indexOf('?') == -1) { - url = url + "?retry=1"; - } else if (!url.contains("retry=")) { - url = url + "&retry=1"; - } - - this.getAppletContext().showDocument(new URL(url)); - } catch (Exception e) { this.retryCanvas.setVisible(false); + this.destroy(); + this.init(); + this.start(); + } catch (Exception e) { + e.printStackTrace(); } } From b87ac4d1bbedb7cf5f5481df03ca2a0e66160050 Mon Sep 17 00:00:00 2001 From: Sten Laane <21343173+StenAL@users.noreply.github.com> Date: Mon, 27 May 2024 09:05:43 +0300 Subject: [PATCH 5/6] Deobfuscate lobby joining code This revealed artificial delays in joining lobbies, probably as a means of flood protection. This can be verified by going into a single player lobby and clicking "Multiplayer", then "Single player" again rapidly and seeing a blank screen stuck on the sleep timer. --- client/src/main/java/agolf/GameApplet.java | 8 +-- .../src/main/java/agolf/LobbySelectPanel.java | 53 +++++++++---------- .../java/agolf/lobby/LobbyControlPanel.java | 2 +- 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/client/src/main/java/agolf/GameApplet.java b/client/src/main/java/agolf/GameApplet.java index cf9f31d6..7164fea7 100644 --- a/client/src/main/java/agolf/GameApplet.java +++ b/client/src/main/java/agolf/GameApplet.java @@ -169,13 +169,13 @@ protected void setGameState(int panelActive, int lobbyId, int lobbyExtra) { boolean var5 = false; if (this.gameContainer.defaultLobby != null) { if (this.gameContainer.defaultLobby.equalsIgnoreCase("singlehidden")) { - var5 = this.gameContainer.lobbySelectionPanel.method443(1, true); + var5 = this.gameContainer.lobbySelectionPanel.selectLobby(1, true); } else if (this.gameContainer.defaultLobby.equalsIgnoreCase("single")) { - var5 = this.gameContainer.lobbySelectionPanel.method443(1, false); + var5 = this.gameContainer.lobbySelectionPanel.selectLobby(1, false); } else if (this.gameContainer.defaultLobby.equalsIgnoreCase("dual")) { - var5 = this.gameContainer.lobbySelectionPanel.method443(2, false); + var5 = this.gameContainer.lobbySelectionPanel.selectLobby(2, false); } else if (this.gameContainer.defaultLobby.equalsIgnoreCase("multi")) { - var5 = this.gameContainer.lobbySelectionPanel.method443(3, false); + var5 = this.gameContainer.lobbySelectionPanel.selectLobby(3, false); } this.gameContainer.defaultLobby = null; diff --git a/client/src/main/java/agolf/LobbySelectPanel.java b/client/src/main/java/agolf/LobbySelectPanel.java index fca1675f..098b0e60 100644 --- a/client/src/main/java/agolf/LobbySelectPanel.java +++ b/client/src/main/java/agolf/LobbySelectPanel.java @@ -19,9 +19,8 @@ public class LobbySelectPanel extends Panel implements ActionListener, MouseListener, ItemListener { - private static final int[] anIntArray526 = new int[]{3000, 7000, 15000}; - private static final int anInt527 = anIntArray526.length; - private static long[] aLongArray528; + private static final int[] lobbyJoinDelays = new int[]{3000, 7000, 15000}; + private static long[] lobbyJoinAvailableTimestamps; private static boolean playHidden; private GameContainer gameContainer; private int width; @@ -143,41 +142,41 @@ public void itemStateChanged(ItemEvent evt) { this.gameContainer.graphicsQualityIndex = this.choicerGraphics.getSelectedIndex(); } - public static String method442(int var0) { - if (aLongArray528 == null) { - aLongArray528 = new long[anInt527]; + public static String getLobbySelectMessage(int lobbyId) { + if (lobbyJoinAvailableTimestamps == null) { + lobbyJoinAvailableTimestamps = new long[lobbyJoinDelays.length]; - for (int var1 = 0; var1 < anInt527; ++var1) { - aLongArray528[var1] = 0L; + for (int i = 0; i < lobbyJoinDelays.length; ++i) { + lobbyJoinAvailableTimestamps[i] = 0L; } } - long var2 = System.currentTimeMillis(); - long var4 = 0L; + long now = System.currentTimeMillis(); + long sleepTime = 0L; - for (int var6 = 0; var6 < anInt527; ++var6) { - long var7 = aLongArray528[var6] + (long) anIntArray526[var6] - var2; - if (var7 > var4) { - var4 = var7; + for (int i = 0; i < lobbyJoinDelays.length; ++i) { + long delayNeededForTimestamp = lobbyJoinAvailableTimestamps[i] + (long) lobbyJoinDelays[i] - now; + if (delayNeededForTimestamp > sleepTime) { + sleepTime = delayNeededForTimestamp; } } - for (int var9 = anInt527 - 1; var9 >= 1; --var9) { - aLongArray528[var9] = aLongArray528[var9 - 1]; + for (int i = lobbyJoinDelays.length - 1; i >= 1; --i) { + lobbyJoinAvailableTimestamps[i] = lobbyJoinAvailableTimestamps[i - 1]; } - aLongArray528[0] = var2 + var4; - Tools.sleep(var4); - return "select\t" + (var0 <= 2 ? String.valueOf(var0) : "x") + (var0 == 1 && playHidden ? "h" : ""); + lobbyJoinAvailableTimestamps[0] = now + sleepTime; + Tools.sleep(sleepTime); + return "select\t" + (lobbyId <= 2 ? String.valueOf(lobbyId) : "x") + (lobbyId == 1 && playHidden ? "h" : ""); } - protected boolean method443(int var1, boolean var2) { - if (this.gameContainer.disableSinglePlayer && var1 == 1) { + protected boolean selectLobby(int lobbyId, boolean playHidden) { + if (this.gameContainer.disableSinglePlayer && lobbyId == 1) { return false; } else { - this.checkboxPlayHidden.setState(var2); - playHidden = var2; - return this.selectLobby(var1); + this.checkboxPlayHidden.setState(playHidden); + LobbySelectPanel.playHidden = playHidden; + return this.selectLobby(lobbyId); } } @@ -281,12 +280,12 @@ private void drawNumPlayers(Graphics g, int x, int numPlayers) { } } - private boolean selectLobby(int var1) { - if (this.lobbyNumPlayers[var1 - 1] >= this.lobbyMaxPlayers && this.gameContainer.gameApplet.getPlayerAccessLevel() == 0) { + private boolean selectLobby(int lobbyId) { + if (this.lobbyNumPlayers[lobbyId - 1] >= this.lobbyMaxPlayers && this.gameContainer.gameApplet.getPlayerAccessLevel() == 0) { return false; } else { this.gameContainer.gameApplet.setGameState(0); - this.writeData(method442(var1)); + this.writeData(getLobbySelectMessage(lobbyId)); return true; } } diff --git a/client/src/main/java/agolf/lobby/LobbyControlPanel.java b/client/src/main/java/agolf/lobby/LobbyControlPanel.java index 45cbceb7..b6de1eee 100644 --- a/client/src/main/java/agolf/lobby/LobbyControlPanel.java +++ b/client/src/main/java/agolf/lobby/LobbyControlPanel.java @@ -65,7 +65,7 @@ public void actionPerformed(ActionEvent evt) { if (lobbyId > 0) { this.gameContainer.gameApplet.setGameState(0); - this.gameContainer.lobbyPanel.writeData(LobbySelectPanel.method442(lobbyId)); + this.gameContainer.lobbyPanel.writeData(LobbySelectPanel.getLobbySelectMessage(lobbyId)); } } From 6759ad77a5117509f43b3f0ee8417310e4f34ff4 Mon Sep 17 00:00:00 2001 From: Sten Laane <21343173+StenAL@users.noreply.github.com> Date: Mon, 27 May 2024 09:05:44 +0300 Subject: [PATCH 6/6] Set lobby join delay to 1 second Previously the delay was a ladder of 3 -> 7 -> 15 seconds and switching between lobbies was annoying. Now it's faster and the change does not seem to cause any issues. I still opted to keep a one second delay in case removing the delay would break something. --- client/src/main/java/agolf/LobbySelectPanel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/main/java/agolf/LobbySelectPanel.java b/client/src/main/java/agolf/LobbySelectPanel.java index 098b0e60..79bb3711 100644 --- a/client/src/main/java/agolf/LobbySelectPanel.java +++ b/client/src/main/java/agolf/LobbySelectPanel.java @@ -19,7 +19,7 @@ public class LobbySelectPanel extends Panel implements ActionListener, MouseListener, ItemListener { - private static final int[] lobbyJoinDelays = new int[]{3000, 7000, 15000}; + private static final int[] lobbyJoinDelays = new int[]{1000}; private static long[] lobbyJoinAvailableTimestamps; private static boolean playHidden; private GameContainer gameContainer;