diff --git a/client/src/main/java/agolf/GameApplet.java b/client/src/main/java/agolf/GameApplet.java index 99a77f00..e7581307 100644 --- a/client/src/main/java/agolf/GameApplet.java +++ b/client/src/main/java/agolf/GameApplet.java @@ -41,6 +41,10 @@ public class GameApplet extends AApplet { private Image anImage3774; private boolean verbose = false; + public GameApplet(Parameters parameters) { + super(parameters); + } + public void initApplet(Parameters parameters) { this.syncIsValidSite = new SynchronizedBool(this.isValidSite()); this.setBackground(colourGameBackground); @@ -166,8 +170,6 @@ protected void setGameState(int activePanel, int lobbyId, int lobbyExtra) { } else if (!this.gameContainer.synchronizedTrackTestMode.get()) { this.gameContainer.connection.writeData("login"); this.activePanel = 0; - } else { - } } @@ -302,18 +304,4 @@ public void quit(String from) { private boolean isValidSite() { return true; } - - private boolean containsDomain(String host, String domain, String[] tld) { - for (String text : tld) { - if (host.equals(domain + "." + text)) { - return true; - } - - if (host.endsWith("." + domain + "." + text)) { - return true; - } - } - - return false; - } } diff --git a/client/src/main/java/agolf/GolfConnection.java b/client/src/main/java/agolf/GolfConnection.java index 3f22ba7d..f31696c6 100644 --- a/client/src/main/java/agolf/GolfConnection.java +++ b/client/src/main/java/agolf/GolfConnection.java @@ -150,109 +150,109 @@ protected void disconnect() { private void handlePacket(String cmd) { String[] args = Tools.separateString(cmd, "\t"); - if (args[0].equals("error")) { - if (args[1].equals("vernotok")) { - this.gameContainer.gameApplet.setEndState(AApplet.END_ERROR_VERSION); - } else if (args[1].equals("serverfull")) { - this.gameContainer.gameApplet.setEndState(AApplet.END_ERROR_SERVERFULL); - } - - this.socketConnection.closeConnection(); - } else if (args[0].equals("versok")) { - this.writeData("language\t" + this.gameContainer.params.getLocale()); - this.writeData("logintype\t" - + (this.gameContainer.synchronizedTrackTestMode.get() - ? "ttm" - : (this.gameContainer.gameApplet.hasSession() ? "reg" : "nr"))); - } else if (args[0].equals("basicinfo")) { - this.gameContainer.gameApplet.setGameSettings( - args[1].equals("t"), Integer.parseInt(args[2]), args[3].equals("t"), args[4].equals("t")); - } else if (args[0].equals("broadcast")) { - if (this.gameContainer.lobbyPanel != null) { - this.gameContainer.lobbyPanel.broadcastMessage(args[1]); - } - - if (this.gameContainer.gamePanel != null) { - this.gameContainer.gamePanel.broadcastMessage(args[1]); - } - - } else if (args[0].equals("status")) { - if (args[1].equals("login")) { - if (args.length == 2) { - this.gameContainer.gameApplet.setGameState(1); - return; - } - - byte var3 = 0; - if (args[2].equals("nickinuse")) { - var3 = 4; - } - - if (args[2].equals("rlf")) { - var3 = 5; - } - - if (args[2].equals("invalidnick")) { - var3 = 6; + switch (args[0]) { + case "error" -> { + if (args[1].equals("vernotok")) { + this.gameContainer.gameApplet.setEndState(AApplet.END_ERROR_VERSION); + } else if (args[1].equals("serverfull")) { + this.gameContainer.gameApplet.setEndState(AApplet.END_ERROR_SERVERFULL); } - if (args[2].equals("forbiddennick")) { - var3 = 7; - } - - this.gameContainer.gameApplet.setGameState(1, var3); - return; + this.socketConnection.closeConnection(); } - - if (args[1].equals("lobbyselect")) { - this.gameContainer.gameApplet.setGameState(2, args.length > 2 ? Integer.parseInt(args[2]) : 0); - return; + case "versok" -> { + this.writeData("language\t" + this.gameContainer.params.getLocale()); + this.writeData("logintype\t" + + (this.gameContainer.synchronizedTrackTestMode.get() + ? "ttm" + : (this.gameContainer.gameApplet.hasSession() ? "reg" : "nr"))); } - - if (args[1].equals("lobby")) { - if (args.length == 2) { - this.gameContainer.gameApplet.setGameState(3, Integer.MIN_VALUE); - return; + case "basicinfo" -> this.gameContainer.gameApplet.setGameSettings( + args[1].equals("t"), Integer.parseInt(args[2]), args[3].equals("t"), args[4].equals("t")); + case "broadcast" -> { + if (this.gameContainer.lobbyPanel != null) { + this.gameContainer.lobbyPanel.broadcastMessage(args[1]); } - if (args[2].equals("tt")) { - this.gameContainer.gameApplet.setGameState(3, -1, args[3].equals("t") ? 1 : 0); - return; + if (this.gameContainer.gamePanel != null) { + this.gameContainer.gamePanel.broadcastMessage(args[1]); } - - if (!args[2].equals("1") && !args[2].equals("1h")) { - if (args[2].equals("2")) { - this.gameContainer.gameApplet.setGameState(3, 2); + } + case "status" -> { + switch (args[1]) { + case "login" -> { + if (args.length == 2) { + this.gameContainer.gameApplet.setGameState(1); + return; + } + + byte var3 = 0; + if (args[2].equals("nickinuse")) { + var3 = 4; + } + + if (args[2].equals("rlf")) { + var3 = 5; + } + + if (args[2].equals("invalidnick")) { + var3 = 6; + } + + if (args[2].equals("forbiddennick")) { + var3 = 7; + } + + this.gameContainer.gameApplet.setGameState(1, var3); return; } - - if (args.length == 3) { - this.gameContainer.gameApplet.setGameState(3, 3); + case "lobbyselect" -> { + this.gameContainer.gameApplet.setGameState(2, args.length > 2 ? Integer.parseInt(args[2]) : 0); + return; + } + case "lobby" -> { + if (args.length == 2) { + this.gameContainer.gameApplet.setGameState(3, Integer.MIN_VALUE); + return; + } + + if (args[2].equals("tt")) { + this.gameContainer.gameApplet.setGameState(3, -1, args[3].equals("t") ? 1 : 0); + return; + } + + if (!args[2].equals("1") && !args[2].equals("1h")) { + if (args[2].equals("2")) { + this.gameContainer.gameApplet.setGameState(3, 2); + return; + } + + if (args.length == 3) { + this.gameContainer.gameApplet.setGameState(3, 3); + return; + } + + this.gameContainer.gameApplet.setGameState(3, 3, Integer.parseInt(args[3])); + return; + } + + this.gameContainer.gameApplet.setGameState(3, 1, args[2].equals("1") ? 1 : -1); + // enables tracklistadmin this.aGameContainer_2370.gameApplet.setGameState(3, -1, + // 1); + return; + } + case "game" -> { + this.gameContainer.gameApplet.setGameState(4); return; } - - this.gameContainer.gameApplet.setGameState(3, 3, Integer.parseInt(args[3])); - return; } - - this.gameContainer.gameApplet.setGameState(3, 1, args[2].equals("1") ? 1 : -1); - // enables tracklistadmin this.aGameContainer_2370.gameApplet.setGameState(3, -1, - // 1); - return; - } - - if (args[1].equals("game")) { - this.gameContainer.gameApplet.setGameState(4); - return; } } - if (args[0].equals("lobbyselect")) { - this.gameContainer.lobbySelectionPanel.handlePacket(args); - } else if (args[0].equals("lobby")) { - this.gameContainer.lobbyPanel.handlePacket(args); - } else if (args[0].equals("game")) { - this.gameContainer.gamePanel.handlePacket(args); + switch (args[0]) { + case "lobbyselect" -> this.gameContainer.lobbySelectionPanel.handlePacket(args); + case "lobby" -> this.gameContainer.lobbyPanel.handlePacket(args); + case "game" -> this.gameContainer.gamePanel.handlePacket(args); } } } diff --git a/client/src/main/java/agolf/SpriteManager.java b/client/src/main/java/agolf/SpriteManager.java index c57dc3c8..7c92595a 100644 --- a/client/src/main/java/agolf/SpriteManager.java +++ b/client/src/main/java/agolf/SpriteManager.java @@ -39,20 +39,17 @@ protected void loadSprites() { GameBackgroundCanvas.anIntArray78[var1] * 15, GameBackgroundCanvas.anIntArray79[var1] * 15); } - } catch (Exception var4) { - this.anIntArrayArray968[var1] = null; - } catch (OutOfMemoryError var5) { + } catch (Exception | OutOfMemoryError e) { this.anIntArrayArray968[var1] = null; } } } /** - * MOTHER FUCKING IMPORTANT. Converts the tile code into an array of pixels (presumably 15*15 as - * a 1-d array) + * Converts the tile code into an array of pixels (presumably 15*15 as a 1-d array) * * @param tileCode The Map Tile code to get pixels of. - * @return An linear array of the tiles pixels init br0 + * @return A linear array of the tiles pixels */ public int[] getPixelsFromTileCode(int tileCode) { if (tileCode == 0) { @@ -107,7 +104,6 @@ private Image[] parseSpriteSheet( int sheetHeight = this.imageManager.getHeight(spriteSheet); int[] var9 = this.imageManager.getPixels(spriteSheet, sheetWidth, sheetHeight); - spriteSheet = null; Image[] var10 = new Image[spriteCount]; for (int var11 = 0; var11 < spriteCount; ++var11) { diff --git a/client/src/main/java/agolf/game/ChatPanel.java b/client/src/main/java/agolf/game/ChatPanel.java index 182cc124..f73d0b92 100644 --- a/client/src/main/java/agolf/game/ChatPanel.java +++ b/client/src/main/java/agolf/game/ChatPanel.java @@ -86,7 +86,7 @@ protected void addMessage(String var1) { } } - protected void addSay(int unused, String name, String message, boolean isLocalPlayer) { // /me action + protected void addSay(String name, String message, boolean isLocalPlayer) { // /me action if (this.gameExtra >= 2) { if (isLocalPlayer) { this.textAreaChat.addOwnSay(name, message); diff --git a/client/src/main/java/agolf/game/GameBackgroundCanvas.java b/client/src/main/java/agolf/game/GameBackgroundCanvas.java index 4b12538a..389fde49 100644 --- a/client/src/main/java/agolf/game/GameBackgroundCanvas.java +++ b/client/src/main/java/agolf/game/GameBackgroundCanvas.java @@ -34,7 +34,6 @@ public class GameBackgroundCanvas extends Canvas { private boolean[] trackSpecialSettings; private int[][] anIntArrayArray97; private boolean[] aBooleanArray98; - public static int anInt99; protected GameBackgroundCanvas(GameContainer gameContainer, Image backgroundImage) { this.gameContainer = gameContainer; @@ -214,7 +213,7 @@ protected boolean[] method120() { return this.aBooleanArray98; } - private boolean parseMapInstruction(String map) throws Exception { + private boolean parseMapInstruction(String map) { this.trackSettings = defaultTrackSettings; this.trackFirstBest = null; this.trackLastBest = null; diff --git a/client/src/main/java/agolf/game/GameCanvas.java b/client/src/main/java/agolf/game/GameCanvas.java index e08bea07..0899b087 100644 --- a/client/src/main/java/agolf/game/GameCanvas.java +++ b/client/src/main/java/agolf/game/GameCanvas.java @@ -1096,8 +1096,6 @@ private void doHackedStroke(int playerId, boolean isLocalPlayer, int mouseX, int double[] coords = hs.getHackedCoordintes(); hackedX = coords[0]; hackedY = coords[1]; - hs = null; - hack = null; } private void resetPosition(int playerId, boolean gameStart) { @@ -1548,7 +1546,6 @@ private double getSpeedEffect( } private void handleTeleport(int teleportId, int playerId, int x, int y) { - boolean var5 = true; int exitLen = this.teleportExists[teleportId].size(); int startLen; int random; diff --git a/client/src/main/java/agolf/game/GamePanel.java b/client/src/main/java/agolf/game/GamePanel.java index 69f5a470..12bde585 100644 --- a/client/src/main/java/agolf/game/GamePanel.java +++ b/client/src/main/java/agolf/game/GamePanel.java @@ -54,375 +54,387 @@ public void update(Graphics var1) { } public void handlePacket(String[] args) { - if (args[1].equals("gameinfo")) { - String gameName = args[2]; - boolean passworded = args[3].equals("t"); - int permission = Integer.parseInt(args[4]); - this.playerCount = Integer.parseInt(args[5]); - int trackCount = Integer.parseInt(args[6]); - int trackTypes = Integer.parseInt(args[7]); - int maxStrokes = Integer.parseInt(args[8]); - int strokeTimeout = Integer.parseInt(args[9]); - int waterEvent = Integer.parseInt(args[10]); - int collision = Integer.parseInt(args[11]); - int trackScoring = Integer.parseInt(args[12]); - int trackScoringEnd = Integer.parseInt(args[13]); - this.isSinglePlayerGame = args[14].equals("t"); // todo unsure - // int trackCategory = Launcher.isUsingCustomServer() ? Integer.parseInt(args[15]) : -1; - byte mode = 0; - if (this.gameContainer.synchronizedTrackTestMode.get()) { - mode = 1; - } - - if (this.playerCount > 1) { - mode = 2; - } - - this.addMultiPlayerPanels(mode); - this.playerInfoPanel.init(this.playerCount, trackCount, maxStrokes, strokeTimeout, trackScoring); - this.trackInfoPanel.setNumTracks(trackCount); - this.gameControlPanel.setPlayerCount(this.playerCount); - this.gameCanvas.init(this.playerCount, waterEvent, collision); - if (mode == 2) { - String settings = ""; - if (passworded) { - settings = this.gameContainer.textManager.getGame("GameChat_GS_Password") + ", "; - } else if (permission > 0) { - settings = this.gameContainer.textManager.getGame( - "GameChat_GS_" + (permission == 1 ? "Reg" : "Vip") + "Only") - + ", "; + switch (args[1]) { + case "gameinfo" -> { + String gameName = args[2]; + boolean passworded = args[3].equals("t"); + int permission = Integer.parseInt(args[4]); + this.playerCount = Integer.parseInt(args[5]); + int trackCount = Integer.parseInt(args[6]); + int trackTypes = Integer.parseInt(args[7]); + int maxStrokes = Integer.parseInt(args[8]); + int strokeTimeout = Integer.parseInt(args[9]); + int waterEvent = Integer.parseInt(args[10]); + int collision = Integer.parseInt(args[11]); + int trackScoring = Integer.parseInt(args[12]); + int trackScoringEnd = Integer.parseInt(args[13]); + this.isSinglePlayerGame = args[14].equals("t"); // todo unsure + + // int trackCategory = Launcher.isUsingCustomServer() ? Integer.parseInt(args[15]) : -1; + byte mode = 0; + if (this.gameContainer.synchronizedTrackTestMode.get()) { + mode = 1; } - settings = settings + this.gameContainer.textManager.getGame("GameChat_GS_Players", this.playerCount); - settings = settings + ", " + this.gameContainer.textManager.getGame("GameChat_GS_Tracks", trackCount); - if (trackTypes > 0) { - settings = settings - + " (" - + this.gameContainer.textManager.getIfAvailable( - "LobbyReal_TrackTypes" + trackTypes, - this.gameContainer.textManager.getGame("LobbyReal_TrackTypesTest")) - + ")"; + if (this.playerCount > 1) { + mode = 2; } - if (maxStrokes != 20) { - if (maxStrokes > 0) { + this.addMultiPlayerPanels(mode); + this.playerInfoPanel.init(this.playerCount, trackCount, maxStrokes, strokeTimeout, trackScoring); + this.trackInfoPanel.setNumTracks(trackCount); + this.gameControlPanel.setPlayerCount(this.playerCount); + this.gameCanvas.init(this.playerCount, waterEvent, collision); + if (mode == 2) { + String settings = ""; + if (passworded) { + settings = this.gameContainer.textManager.getGame("GameChat_GS_Password") + ", "; + } else if (permission > 0) { + settings = this.gameContainer.textManager.getGame( + "GameChat_GS_" + (permission == 1 ? "Reg" : "Vip") + "Only") + + ", "; + } + + settings = + settings + this.gameContainer.textManager.getGame("GameChat_GS_Players", this.playerCount); + settings = + settings + ", " + this.gameContainer.textManager.getGame("GameChat_GS_Tracks", trackCount); + if (trackTypes > 0) { settings = settings - + ", " - + this.gameContainer.textManager.getGame("GameChat_GS_MaxStrokes", maxStrokes); - } else { + + " (" + + this.gameContainer.textManager.getIfAvailable( + "LobbyReal_TrackTypes" + trackTypes, + this.gameContainer.textManager.getGame("LobbyReal_TrackTypesTest")) + + ")"; + } + + if (maxStrokes != 20) { + if (maxStrokes > 0) { + settings = settings + + ", " + + this.gameContainer.textManager.getGame("GameChat_GS_MaxStrokes", maxStrokes); + } else { + settings = settings + + ", " + + this.gameContainer.textManager.getGame( + "GameChat_GS_MaxStrokesUnlimited", maxStrokes); + } + } + + if (strokeTimeout > 0) { settings = settings + ", " - + this.gameContainer.textManager.getGame("GameChat_GS_MaxStrokesUnlimited", maxStrokes); + + this.gameContainer.textManager.getGame( + "GameChat_GS_TimeLimit" + (strokeTimeout < 60 ? "Sec" : "Min"), + strokeTimeout < 60 ? strokeTimeout : strokeTimeout / 60); } - } - if (strokeTimeout > 0) { - settings = settings - + ", " - + this.gameContainer.textManager.getGame( - "GameChat_GS_TimeLimit" + (strokeTimeout < 60 ? "Sec" : "Min"), - strokeTimeout < 60 ? strokeTimeout : strokeTimeout / 60); - } - - if (waterEvent == 1) { - settings = settings + ", " + this.gameContainer.textManager.getGame("GameChat_GS_WaterShore"); - } + if (waterEvent == 1) { + settings = settings + ", " + this.gameContainer.textManager.getGame("GameChat_GS_WaterShore"); + } - if (collision == 0) { - settings = settings + ", " + this.gameContainer.textManager.getGame("GameChat_GS_NoCollision"); - } + if (collision == 0) { + settings = settings + ", " + this.gameContainer.textManager.getGame("GameChat_GS_NoCollision"); + } - if (trackScoring == 1) { - settings = settings + ", " + this.gameContainer.textManager.getGame("GameChat_GS_TrackScoring"); - } + if (trackScoring == 1) { + settings = settings + ", " + this.gameContainer.textManager.getGame("GameChat_GS_TrackScoring"); + } - if (trackScoringEnd > 0) { - settings = settings - + ", " - + this.gameContainer.textManager.getGame("GameChat_GS_TrackScoringEnd" + trackScoringEnd); - } + if (trackScoringEnd > 0) { + settings = settings + + ", " + + this.gameContainer.textManager.getGame( + "GameChat_GS_TrackScoringEnd" + trackScoringEnd); + } - /*if(trackCategory > -1) { - settings = settings + ", " + (trackCategory == 0 ? "official" : (trackCategory == 1 ? "custom" : "unknown")) + " maps"; - }*/ + /*if(trackCategory > -1) { + settings = settings + ", " + (trackCategory == 0 ? "official" : (trackCategory == 1 ? "custom" : "unknown")) + " maps"; + }*/ - this.chatPanel.addMessage(this.gameContainer.textManager.getGame("GameChat_GameName", gameName)); - this.chatPanel.addMessage(this.gameContainer.textManager.getGame("GameChat_GameSettings", settings)); + this.chatPanel.addMessage(this.gameContainer.textManager.getGame("GameChat_GameName", gameName)); + this.chatPanel.addMessage( + this.gameContainer.textManager.getGame("GameChat_GameSettings", settings)); + } } + case "scoringmulti" -> { + int len = args.length - 2; + int[] trackScoresMultipliers = new int[len]; - } else if (args[1].equals("scoringmulti")) { - int len = args.length - 2; - int[] trackScoresMultipliers = new int[len]; + for (int track = 0; track < len; ++track) { + trackScoresMultipliers[track] = Integer.parseInt(args[2 + track]); + } - for (int track = 0; track < len; ++track) { - trackScoresMultipliers[track] = Integer.parseInt(args[2 + track]); + this.playerInfoPanel.setTrackScoresMultipliers(trackScoresMultipliers); } - - this.playerInfoPanel.setTrackScoresMultipliers(trackScoresMultipliers); - } else if (args[1].equals("players")) { - int len = (args.length - 2) / 3; - int playerCountIndex = 2; - - for (int trackTypes = 0; trackTypes < len; ++trackTypes) { - int playerCount = Integer.parseInt(args[playerCountIndex]); // todo lol why u inside the loop tho - String clan = args[playerCountIndex + 2].equals("-") ? null : args[playerCountIndex + 2]; - this.playerInfoPanel.addPlayer(playerCount, args[playerCountIndex + 1], clan, false); - this.chatPanel.setUserColour(args[playerCountIndex + 1], playerCount); - playerCountIndex += 3; + case "players" -> { + int len = (args.length - 2) / 3; + int playerCountIndex = 2; + + for (int trackTypes = 0; trackTypes < len; ++trackTypes) { + int playerCount = Integer.parseInt(args[playerCountIndex]); // todo lol why u inside the loop tho + String clan = args[playerCountIndex + 2].equals("-") ? null : args[playerCountIndex + 2]; + this.playerInfoPanel.addPlayer(playerCount, args[playerCountIndex + 1], clan, false); + this.chatPanel.setUserColour(args[playerCountIndex + 1], playerCount); + playerCountIndex += 3; + } } - - } else if (args[1].equals("owninfo")) { - int currentPlayerID = Integer.parseInt(args[2]); - String currentPlayerClan = args[4].equals("-") ? null : args[4]; - this.playerInfoPanel.addPlayer(currentPlayerID, args[3], currentPlayerClan, true); - this.chatPanel.setUserColour(args[3], currentPlayerID); - this.aLong364 = System.currentTimeMillis(); - } else if (args[1].equals("join")) { - int playerId = Integer.parseInt(args[2]); - String playerClan = args[4].equals("-") ? null : args[4]; - this.playerInfoPanel.addPlayer(playerId, args[3], playerClan, false); - this.chatPanel.setUserColour(args[3], playerId); - if (this.playerCount != 2 || playerId != 1) { - this.chatPanel.addMessage( - playerClan != null - ? this.gameContainer.textManager.getGame("GameChat_JoinClan", args[3], playerClan) - : this.gameContainer.textManager.getGame("GameChat_Join", args[3])); + case "owninfo" -> { + int currentPlayerID = Integer.parseInt(args[2]); + String currentPlayerClan = args[4].equals("-") ? null : args[4]; + this.playerInfoPanel.addPlayer(currentPlayerID, args[3], currentPlayerClan, true); + this.chatPanel.setUserColour(args[3], currentPlayerID); + this.aLong364 = System.currentTimeMillis(); + } + case "join" -> { + int playerId = Integer.parseInt(args[2]); + String playerClan = args[4].equals("-") ? null : args[4]; + this.playerInfoPanel.addPlayer(playerId, args[3], playerClan, false); + this.chatPanel.setUserColour(args[3], playerId); + if (this.playerCount != 2 || playerId != 1) { + this.chatPanel.addMessage( + playerClan != null + ? this.gameContainer.textManager.getGame("GameChat_JoinClan", args[3], playerClan) + : this.gameContainer.textManager.getGame("GameChat_Join", args[3])); + } } + case "part" -> { // player left game + int playerId = Integer.parseInt(args[2]); + boolean changed = this.playerInfoPanel.setPlayerPartStatus(playerId, Integer.parseInt(args[3])); + if (changed) { + this.gameControlPanel.method329(); + } - } else if (args[1].equals("part")) { // player left game - int playerId = Integer.parseInt(args[2]); - boolean changed = this.playerInfoPanel.setPlayerPartStatus(playerId, Integer.parseInt(args[3])); - if (changed) { - this.gameControlPanel.method329(); + String playerName = this.playerInfoPanel.playerNames[playerId]; + this.chatPanel.addMessage(this.gameContainer.textManager.getGame("GameChat_Part", playerName)); + this.chatPanel.removeUserColour(playerName); + this.gameControlPanel.refreshBackButton(); } + case "say" -> { + int playerId = Integer.parseInt(args[2]); + this.chatPanel.addSay(this.playerInfoPanel.playerNames[playerId], args[3], false); + } + case "cr" -> { + StringTokenizer tokenizer = new StringTokenizer(args[2], ","); + int tracks = tokenizer.countTokens(); + int[][] comparisonScores = new int[5][tracks]; + + for (int comparisonType = 0; comparisonType < 5; ++comparisonType) { + for (int track = 0; track < tracks; ++track) { + comparisonScores[comparisonType][track] = Integer.parseInt(tokenizer.nextToken()); + } - String playerName = this.playerInfoPanel.playerNames[playerId]; - this.chatPanel.addMessage(this.gameContainer.textManager.getGame("GameChat_Part", playerName)); - this.chatPanel.removeUserColour(playerName); - this.gameControlPanel.refreshBackButton(); - } else if (args[1].equals("say")) { - int playerId = Integer.parseInt(args[2]); - this.chatPanel.addSay(playerId, this.playerInfoPanel.playerNames[playerId], args[3], false); - } else if (args[1].equals("cr")) { // get results to compare track score against - StringTokenizer tokenizer = new StringTokenizer(args[2], ","); - int tracks = tokenizer.countTokens(); - int[][] comparisonScores = new int[5][tracks]; - - for (int comparisonType = 0; comparisonType < 5; ++comparisonType) { - for (int track = 0; track < tracks; ++track) { - comparisonScores[comparisonType][track] = Integer.parseInt(tokenizer.nextToken()); + if (comparisonType < 4) { + tokenizer = new StringTokenizer(args[3 + comparisonType], ","); + } } - if (comparisonType < 4) { - tokenizer = new StringTokenizer(args[3 + comparisonType], ","); + this.playerInfoPanel.initResultsComparison(comparisonScores); + } + case "start" -> { + if (this.playerCount > 1) { + if (this.aBoolean363) { + if (System.currentTimeMillis() > this.aLong364 + 1000L) { + this.gameContainer.soundManager.playNotify(); + // this.requestFocus();//todo this is annoying as fuck + } + + this.gameContainer.gameApplet.showPlayerList(this.playerInfoPanel.getPlayerNames()); + } else { + this.gameContainer.gameApplet.removePlayerListWinnders(); + } } + + this.aBoolean363 = false; + this.gameCanvas.createMap(16777216); + this.playerInfoPanel.reset(); + this.trackInfoPanel.resetCurrentTrack(); + this.setState(1); } + case "starttrack" -> { + // [1] = "startrack", (optional [2] == track test mode), [2 or 3] == player statuses, [3 + // or 4] == game id, [4 or 5] == track data + /* + * game + * starttrack + * t 1908821 + * V 1 + * A Tiikoni + * N Three Passages III + * T B3A12DBQARG20DBQARG12DE11DBTARBERQBAQQ20DBFRQBRARE11DE12DBAQQG20DFG12DE12DEE20DEE12DE12DEE20DEE12DE7DBQARE3DEE20DEE3DBQARE7DE6DBTARBERQBAQQ3DBGRQBRARE18DBTARBHRQF3DBFRQBRARE6DE7DBAQQG3DBSARG20DBSARG3DFG7DE7DEE6DBQARE14DBQARE6DEE7DE7DEE5DBTARBERQBAQQ14DBFRQBRARE5DEE7DE7DEE6DBAQQG14DFG6DEE7DE7DEE6DEE14DEE6DEE7DE7DEE6DEEDDBQARE10DEE6DEE7DE7DEE6DEEDBTARBERQBAQQ10DBGRQBRARE5DEE7DE7DEE6DEEDDBAQQG10DBSARG6DEE7DE7DEE6DEEDDEE13DBQARE3DEE7DE7DEE6DEEDDEE12DBTARBERQBAQQ3DBGRQBRARE6DE7DEE6DEEDDEEDDCBAE9DBAQQG3DBSARG7DE7DEE6DEEDDEE13DEE12DE7DEEDDCAAEDDEEDDEE13DEE12DE7DEE6DEEDDEE13DEE12DE7DEE6DEEDBTARBHRQF13DBGRQBRARE11DE7DEE6DEEDDBSARG13DBSARG12DE6DBTARBHRQF6DBGRQBRARE30DE7DBSARG6DBSARG31D,Ads:A3703B0101C4019 I 456956,1954871,2,17833 B Jerry,1087842155000 L abscission,1369657760469 R 1047,334,392,574,911,2281,1888,1543,1209,871,6559 + + + + V 1 + A {AUTHOR OF TRACK} + N {NAME OF TRACK} + T B3A11DBEAQBAQQ11DBAMMDDBGQMBAQQ11DBAMMDDBGQMBAQQ3DEDDBIALBHLEBGFEBJAFE3DBEAQBGAQB3A10DEEDBGQMBGAQB3A10DEEDBGQMBGAQB3ADCAAEEDDBHKLBALABAFABGGFEDDBEAQBGAQI11DEEBGQMBGAQB3A11DEEBGQMBGAQB3A3DEEDDBGJKBAJABAHABHHGEDBEAQBGAQI12DEBGQMBGAQB3A12DEBGQMBGAQB3A4DEEDDBLAJBGIJBHIHBKAHEBEAQBGAQI5DBEAQBGAQE5DEBGAQB3A5DBEAQBGAQE5DEBGAQB3A5DEE6DBEAQBGAQI5DBEAQBGAQH5DBEAQBGAQI5DBEAQBGAQH5DBEAQBGAQI5DBEAQBGAQBJAME4DBEAQBGAQB3A5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQIBAMMBLMAEDDBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQIDEDDBJAMBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQIDDEDDBGQMBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI3DEDBGQMBGAQB3A5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI4DEBGQMBGAQB3A5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQIDBIALBHLEBGFEBJAFBTMQBTQAB3A5DBTAQBTQAI5DBTAQBTQAI5DBTAQBTQAI5DBTAQBTQAI5DBTAQBTQAIDDBHKLBALABAFABGGFBKAMBHAQBFAQE5DBHAQBFAQE5DBHAQBFAQE5DBHAQBFAQE5DBHAQBFAQE5DBHAQBFAQEDBGJKBAJABAHABHHGB3ADFFE5DFFE5DFFE5DFFE5DFFE5DFFEBLAJBGIJBHIHBKAHEDDFFE5DFFE5DFFE5DFFE5DFFE5D3F3DE3DFFE5DFFE5DFFE5DFFE5DFFE5DFFEDBKMAE4DFFE5DFFE5DFFE5DFFE5DFFE5DFFBIAMBAMME5DFFE5DFFE5DFFE5DFFE5DFFE5DFBHQMEE6DFFE5DFFE5DFFE5DFFE5DFFE5DFFEDBIALBHLEBGFEBJAFEDFFEDCBAEDBEAQBAQQFE5DFE5DBEAQBAQQFE5DFE6DBRQAEDBHKLBALABAFABGGFEDDFFEDDBEAQBEQMBAMMBHMQFE10DBEAQBEQMBAMMBHMQFE11DBEAQBEQMEDBGJKBAJABAHABHHGE3DFFEBEAQBEQMBAMMDDFFE8DBEAQBEQMBAMMDDFFE9DBEAQBEQMBAMMEDBLAJBGIJBHIHBKAHE3DBIAMBHMQBSQABEQMBAMM4DFFE6DBEAQBEQMBAMM4DFFE7DBEAQBEQMBAMMDE8DBKMABAMMDBSMQG6DFBAQQ6DBEQMBAMM6DFBAQQ7DBEQMBAMMDD + I {NUMBER OF PLAYERS TO COMLETE?},{NUMBER OF PEOPLE TO ATTEMPT?},{BEST NUMBER OF STROKES},{NUMBER OF PEOPLE THAT GOT BEST STROKE} + B {FIRST BEST PAR PLAYER},{UNIX TIMESTAMP OF FIRST BEST PAR}000 + L {LAST BEST PAR PLAYER},{UNIX TIMESTAMP OF LAST BEST PAR}000 + R {RATING: 0},{RATING: 1},{RATING: 2},{RATING: 3},{RATING: 4},{RATING: 5},{RATING: 6},{RATING: 7},{RATING: 8},{RATING: 9},{RATING: 10} + */ + this.gameCanvas.restartGame(); + boolean trackTestMode1 = args[2].equals("ttm1"); + boolean trackTestMode2 = args[2].equals("ttm2"); + boolean trackTestMode = trackTestMode1 || trackTestMode2; + boolean hasPlayed = false; + int startIndex = trackTestMode ? 5 : 4; + int argsLen = args.length; + String author = null; + String name = null; + String data = null; + String fullInstruction = ""; + + for (int commandIndex = startIndex; commandIndex < argsLen; ++commandIndex) { + char command = args[commandIndex].charAt(0); + if (command == 'A') { + author = args[commandIndex].substring(2); + } - this.playerInfoPanel.initResultsComparison(comparisonScores); - } else if (args[1].equals("start")) { - if (this.playerCount > 1) { - if (this.aBoolean363) { - if (System.currentTimeMillis() > this.aLong364 + 1000L) { - this.gameContainer.soundManager.playNotify(); - // this.requestFocus();//todo this is annoying as fuck + if (command == 'N') { + name = args[commandIndex].substring(2); } - this.gameContainer.gameApplet.showPlayerList(this.playerInfoPanel.getPlayerNames()); - } else { - this.gameContainer.gameApplet.removePlayerListWinnders(); - } - } + if (command == 'T') { + data = args[commandIndex].substring(2); + } - this.aBoolean363 = false; - this.gameCanvas.createMap(16777216); - this.playerInfoPanel.reset(); - this.trackInfoPanel.resetCurrentTrack(); - this.setState(1); - } else if (args[1].equals("starttrack")) { - // [1] = "startrack", (optional [2] == track test mode), [2 or 3] == player statuses, [3 - // or 4] == game id, [4 or 5] == track data - /* - * game - * starttrack - * t 1908821 - * V 1 - * A Tiikoni - * N Three Passages III - * T B3A12DBQARG20DBQARG12DE11DBTARBERQBAQQ20DBFRQBRARE11DE12DBAQQG20DFG12DE12DEE20DEE12DE12DEE20DEE12DE7DBQARE3DEE20DEE3DBQARE7DE6DBTARBERQBAQQ3DBGRQBRARE18DBTARBHRQF3DBFRQBRARE6DE7DBAQQG3DBSARG20DBSARG3DFG7DE7DEE6DBQARE14DBQARE6DEE7DE7DEE5DBTARBERQBAQQ14DBFRQBRARE5DEE7DE7DEE6DBAQQG14DFG6DEE7DE7DEE6DEE14DEE6DEE7DE7DEE6DEEDDBQARE10DEE6DEE7DE7DEE6DEEDBTARBERQBAQQ10DBGRQBRARE5DEE7DE7DEE6DEEDDBAQQG10DBSARG6DEE7DE7DEE6DEEDDEE13DBQARE3DEE7DE7DEE6DEEDDEE12DBTARBERQBAQQ3DBGRQBRARE6DE7DEE6DEEDDEEDDCBAE9DBAQQG3DBSARG7DE7DEE6DEEDDEE13DEE12DE7DEEDDCAAEDDEEDDEE13DEE12DE7DEE6DEEDDEE13DEE12DE7DEE6DEEDBTARBHRQF13DBGRQBRARE11DE7DEE6DEEDDBSARG13DBSARG12DE6DBTARBHRQF6DBGRQBRARE30DE7DBSARG6DBSARG31D,Ads:A3703B0101C4019 I 456956,1954871,2,17833 B Jerry,1087842155000 L abscission,1369657760469 R 1047,334,392,574,911,2281,1888,1543,1209,871,6559 - - - - V 1 - A {AUTHOR OF TRACK} - N {NAME OF TRACK} - T B3A11DBEAQBAQQ11DBAMMDDBGQMBAQQ11DBAMMDDBGQMBAQQ3DEDDBIALBHLEBGFEBJAFE3DBEAQBGAQB3A10DEEDBGQMBGAQB3A10DEEDBGQMBGAQB3ADCAAEEDDBHKLBALABAFABGGFEDDBEAQBGAQI11DEEBGQMBGAQB3A11DEEBGQMBGAQB3A3DEEDDBGJKBAJABAHABHHGEDBEAQBGAQI12DEBGQMBGAQB3A12DEBGQMBGAQB3A4DEEDDBLAJBGIJBHIHBKAHEBEAQBGAQI5DBEAQBGAQE5DEBGAQB3A5DBEAQBGAQE5DEBGAQB3A5DEE6DBEAQBGAQI5DBEAQBGAQH5DBEAQBGAQI5DBEAQBGAQH5DBEAQBGAQI5DBEAQBGAQBJAME4DBEAQBGAQB3A5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQIBAMMBLMAEDDBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQIDEDDBJAMBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQIDDEDDBGQMBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI3DEDBGQMBGAQB3A5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI4DEBGQMBGAQB3A5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQIDBIALBHLEBGFEBJAFBTMQBTQAB3A5DBTAQBTQAI5DBTAQBTQAI5DBTAQBTQAI5DBTAQBTQAI5DBTAQBTQAIDDBHKLBALABAFABGGFBKAMBHAQBFAQE5DBHAQBFAQE5DBHAQBFAQE5DBHAQBFAQE5DBHAQBFAQE5DBHAQBFAQEDBGJKBAJABAHABHHGB3ADFFE5DFFE5DFFE5DFFE5DFFE5DFFEBLAJBGIJBHIHBKAHEDDFFE5DFFE5DFFE5DFFE5DFFE5D3F3DE3DFFE5DFFE5DFFE5DFFE5DFFE5DFFEDBKMAE4DFFE5DFFE5DFFE5DFFE5DFFE5DFFBIAMBAMME5DFFE5DFFE5DFFE5DFFE5DFFE5DFBHQMEE6DFFE5DFFE5DFFE5DFFE5DFFE5DFFEDBIALBHLEBGFEBJAFEDFFEDCBAEDBEAQBAQQFE5DFE5DBEAQBAQQFE5DFE6DBRQAEDBHKLBALABAFABGGFEDDFFEDDBEAQBEQMBAMMBHMQFE10DBEAQBEQMBAMMBHMQFE11DBEAQBEQMEDBGJKBAJABAHABHHGE3DFFEBEAQBEQMBAMMDDFFE8DBEAQBEQMBAMMDDFFE9DBEAQBEQMBAMMEDBLAJBGIJBHIHBKAHE3DBIAMBHMQBSQABEQMBAMM4DFFE6DBEAQBEQMBAMM4DFFE7DBEAQBEQMBAMMDE8DBKMABAMMDBSMQG6DFBAQQ6DBEQMBAMM6DFBAQQ7DBEQMBAMMDD - I {NUMBER OF PLAYERS TO COMLETE?},{NUMBER OF PEOPLE TO ATTEMPT?},{BEST NUMBER OF STROKES},{NUMBER OF PEOPLE THAT GOT BEST STROKE} - B {FIRST BEST PAR PLAYER},{UNIX TIMESTAMP OF FIRST BEST PAR}000 - L {LAST BEST PAR PLAYER},{UNIX TIMESTAMP OF LAST BEST PAR}000 - R {RATING: 0},{RATING: 1},{RATING: 2},{RATING: 3},{RATING: 4},{RATING: 5},{RATING: 6},{RATING: 7},{RATING: 8},{RATING: 9},{RATING: 10} - */ - this.gameCanvas.restartGame(); - boolean trackTestMode1 = args[2].equals("ttm1"); - boolean trackTestMode2 = args[2].equals("ttm2"); - boolean trackTestMode = trackTestMode1 || trackTestMode2; - boolean hasPlayed = false; - int startIndex = trackTestMode ? 5 : 4; - int argsLen = args.length; - String author = null; - String name = null; - String data = null; - String fullInstruction = ""; - - for (int commandIndex = startIndex; commandIndex < argsLen; ++commandIndex) { - char command = args[commandIndex].charAt(0); - if (command == 'A') { - author = args[commandIndex].substring(2); - } + if (command == 'T' && args[commandIndex].charAt(2) == '!') { // a track we already played? + args[commandIndex] = "T " + this.gameContainer.trackCollection.getTrack(author, name); + hasPlayed = true; + } - if (command == 'N') { - name = args[commandIndex].substring(2); + fullInstruction = fullInstruction + args[commandIndex]; + if (commandIndex < argsLen - 1) { + fullInstruction = fullInstruction + '\n'; + } } - if (command == 'T') { - data = args[commandIndex].substring(2); - } + if (Launcher.debug()) System.out.println("FULL: " + fullInstruction); - if (command == 'T' && args[commandIndex].charAt(2) == '!') { // a track we already played? - args[commandIndex] = "T " + this.gameContainer.trackCollection.getTrack(author, name); - hasPlayed = true; + if (!hasPlayed) { + this.gameContainer.trackCollection.addTrack(author, name, data); } - fullInstruction = fullInstruction + args[commandIndex]; - if (commandIndex < argsLen - 1) { - fullInstruction = fullInstruction + '\n'; + this.gameCanvas.init( + fullInstruction, args[trackTestMode ? 3 : 2], Integer.parseInt(args[trackTestMode ? 4 : 3])); + + /* trackinformation + [0]=author, [1]=trackname, [2]=firstbest, [3]=lastbest + + statistics: + var15[0][0]= number completeed + var15[0][1]= total attempts + var15[0][2]= best par (stroke count) + var15[0][3]= number of best par strokes + var15[1][0]= number of ratings: 0 + var15[1][1]= number of ratings: 1 + var15[1][2]= number of ratings: 2 + var15[1][3]= number of ratings: 3 + */ + String[] trackInformation = this.gameCanvas.generateTrackInformation(); + int[][] trackStats = this.gameCanvas.generateTrackStatistics(); + + this.trackInfoPanel.parseTrackInfoStats( + trackInformation[0], + trackInformation[1], + trackStats[0], + trackStats[1], + trackInformation[2], + trackInformation[3], + trackTestMode1, + trackTestMode2, + this.gameCanvas.method134()); + + int trackScoreMultiplier = this.playerInfoPanel.startNextTrack(); + if (trackScoreMultiplier > 1) { + this.chatPanel.addMessage( + gameContainer.textManager.getGame("GameChat_ScoreMultiNotify", trackScoreMultiplier)); } - } - if (Launcher.debug()) System.out.println("FULL: " + fullInstruction); + this.gameControlPanel.displaySkipButton(); // checks if you can skip on first shot - if (!hasPlayed) { - this.gameContainer.trackCollection.addTrack(author, name, data); + if (this.gameContainer.synchronizedTrackTestMode.get()) { + this.chatPanel.printSpecialSettingstoTextArea( + this.gameCanvas.getTrackComment(), + this.gameCanvas.getTrackSettings(), + this.gameCanvas.method120()); + } } - - this.gameCanvas.init( - fullInstruction, args[trackTestMode ? 3 : 2], Integer.parseInt(args[trackTestMode ? 4 : 3])); - - /* trackinformation - [0]=author, [1]=trackname, [2]=firstbest, [3]=lastbest - - statistics: - var15[0][0]= number completeed - var15[0][1]= total attempts - var15[0][2]= best par (stroke count) - var15[0][3]= number of best par strokes - var15[1][0]= number of ratings: 0 - var15[1][1]= number of ratings: 1 - var15[1][2]= number of ratings: 2 - var15[1][3]= number of ratings: 3 - */ - String[] trackInformation = this.gameCanvas.generateTrackInformation(); - int[][] trackStats = this.gameCanvas.generateTrackStatistics(); - - this.trackInfoPanel.parseTrackInfoStats( - trackInformation[0], - trackInformation[1], - trackStats[0], - trackStats[1], - trackInformation[2], - trackInformation[3], - trackTestMode1, - trackTestMode2, - this.gameCanvas.method134()); - - int trackScoreMultiplier = this.playerInfoPanel.startNextTrack(); - if (trackScoreMultiplier > 1) { - this.chatPanel.addMessage( - gameContainer.textManager.getGame("GameChat_ScoreMultiNotify", trackScoreMultiplier)); + case "startturn" -> { + this.isWaitingForTurnStart = false; + int playerId = Integer.parseInt(args[2]); + + boolean canPlay = this.playerInfoPanel.startTurn(playerId); + // canPlay = true; + this.gameCanvas.startTurn(playerId, canPlay, !this.chatPanel.haveFocus()); + + if (!this.isSinglePlayerGame) { + int trackCount = this.playerInfoPanel.method377(); + if (trackCount >= 10 || trackCount >= this.trackInfoPanel.method385()) { + this.gameControlPanel.showSkipButton(); + } + } } - - this.gameControlPanel.displaySkipButton(); // checks if you can skip on first shot - if (this.gameContainer.synchronizedTrackTestMode.get()) { - this.chatPanel.printSpecialSettingstoTextArea( - this.gameCanvas.getTrackComment(), - this.gameCanvas.getTrackSettings(), - this.gameCanvas.method120()); + case "beginstroke" -> { + int playerId = Integer.parseInt(args[2]); + this.playerInfoPanel.strokeStartedOrEnded(playerId, false); + this.gameContainer.soundManager.playGameMove(); + this.playerInfoPanel.stopTimer(); + this.gameCanvas.decodeCoords(playerId, false, args[3]); } + case "changescore" -> { + int numScores = args.length - 3; + int[] trackScores = new int[numScores]; - } else if (args[1].equals("startturn")) { - this.isWaitingForTurnStart = false; - int playerId = Integer.parseInt(args[2]); - - boolean canPlay = this.playerInfoPanel.startTurn(playerId); - // canPlay = true; - this.gameCanvas.startTurn(playerId, canPlay, !this.chatPanel.haveFocus()); + for (int trackCount = 0; trackCount < numScores; ++trackCount) { + trackScores[trackCount] = Integer.parseInt(args[3 + trackCount]); + } - if (!this.isSinglePlayerGame) { - int trackCount = this.playerInfoPanel.method377(); - if (trackCount >= 10 || trackCount >= this.trackInfoPanel.method385()) { + this.playerInfoPanel.setScores(Integer.parseInt(args[2]), trackScores); + } + case "voteskip" -> this.playerInfoPanel.voteSkip(Integer.parseInt(args[2])); + case "resetvoteskip" -> { + this.playerInfoPanel.voteSkipReset(); + if (!this.gameCanvas.getSynchronizedBool(this.playerInfoPanel.playerId)) { this.gameControlPanel.showSkipButton(); } } - } else if (args[1].equals("beginstroke")) { - int playerId = Integer.parseInt(args[2]); - this.playerInfoPanel.strokeStartedOrEnded(playerId, false); - this.gameContainer.soundManager.playGameMove(); - this.playerInfoPanel.stopTimer(); - this.gameCanvas.decodeCoords(playerId, false, args[3]); - - } else if (args[1].equals("changescore")) { - int numScores = args.length - 3; - int[] trackScores = new int[numScores]; + case "rfng" -> this.playerInfoPanel.readyForNewGame(Integer.parseInt(args[2])); + case "end" -> { + this.gameCanvas.endGame(); + int len = args.length - 2; + if (len > 0) { + int[] gameOutcome = new int[len]; + boolean[] isWinner = new boolean[len]; + + for (int i = 0; i < len; ++i) { + gameOutcome[i] = Integer.parseInt(args[2 + i]); + isWinner[i] = gameOutcome[i] == 1; + } - for (int trackCount = 0; trackCount < numScores; ++trackCount) { - trackScores[trackCount] = Integer.parseInt(args[3 + trackCount]); - } + this.playerInfoPanel.setGameOutcome(gameOutcome); + this.gameContainer.gameApplet.showPlayerListWinners(isWinner); + } else { + this.playerInfoPanel.setGameOutcome(null); + } - this.playerInfoPanel.setScores(Integer.parseInt(args[2]), trackScores); - } else if (args[1].equals("voteskip")) { - this.playerInfoPanel.voteSkip(Integer.parseInt(args[2])); - } else if (args[1].equals("resetvoteskip")) { - this.playerInfoPanel.voteSkipReset(); - if (!this.gameCanvas.getSynchronizedBool(this.playerInfoPanel.playerId)) { - this.gameControlPanel.showSkipButton(); - } + this.setState(2); // game state? - } else if (args[1].equals("rfng")) { - this.playerInfoPanel.readyForNewGame(Integer.parseInt(args[2])); - } else if (args[1].equals("end")) { - this.gameCanvas.endGame(); - int len = args.length - 2; - if (len > 0) { - int[] gameOutcome = new int[len]; - boolean[] isWinner = new boolean[len]; - - for (int i = 0; i < len; ++i) { - gameOutcome[i] = Integer.parseInt(args[2 + i]); - isWinner[i] = gameOutcome[i] == 1; + if (this.isSinglePlayerGame) { + this.gameContainer.lobbyPanel.requestTrackSetList(); } - this.playerInfoPanel.setGameOutcome(gameOutcome); - this.gameContainer.gameApplet.showPlayerListWinners(isWinner); - } else { - this.playerInfoPanel.setGameOutcome(null); - } - - this.setState(2); // game state? - if (this.isSinglePlayerGame) { - this.gameContainer.lobbyPanel.requestTrackSetList(); + this.gameContainer.gameApplet.gameFinished(this.playerCount > 1); } - - this.gameContainer.gameApplet.gameFinished(this.playerCount > 1); } } protected void sendChatMessage(String message) { String var2 = "say\t" + message; this.gameContainer.connection.writeData("game\t" + var2); - this.chatPanel.addSay( - this.playerInfoPanel.playerId, - this.playerInfoPanel.playerNames[this.playerInfoPanel.playerId], - message, - true); + this.chatPanel.addSay(this.playerInfoPanel.playerNames[this.playerInfoPanel.playerId], message, true); } protected void setBeginStroke(int playerId, int x, int y, int shootingMode) { diff --git a/client/src/main/java/agolf/game/HackedShot.java b/client/src/main/java/agolf/game/HackedShot.java index 5e2bbaac..5ef8cffd 100644 --- a/client/src/main/java/agolf/game/HackedShot.java +++ b/client/src/main/java/agolf/game/HackedShot.java @@ -11,7 +11,6 @@ public class HackedShot implements Runnable { private static final double aDouble2798 = Math.sqrt(2.0D) / 2.0D; private static final int anInt2799 = (int) (6.0D * aDouble2798 + 0.5D); private static int[] anIntArray2837 = new int[] {Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE}; - private static int anInt2838 = 2; private int anInt2809; private int anInt2810; @@ -1135,6 +1134,5 @@ private void method164(int var1) { } anIntArray2837[2] = var1; - anInt2838 = this.anInt2839; } } diff --git a/client/src/main/java/agolf/lobby/LobbyChatPanel.java b/client/src/main/java/agolf/lobby/LobbyChatPanel.java index 5ae784ab..694e3281 100644 --- a/client/src/main/java/agolf/lobby/LobbyChatPanel.java +++ b/client/src/main/java/agolf/lobby/LobbyChatPanel.java @@ -59,249 +59,265 @@ public void localUserAdminCommand(String var1, String var2, String var3) { } protected boolean handlePacket(String[] args) { - if (args[1].equals("numberofusers")) { - if ((this.lobbyId != 1 || aBoolean3712) - && (this.lobbyId != 2 || aBoolean3713) - && (this.lobbyId != 3 || aBoolean3714)) { + switch (args[1]) { + case "numberofusers" -> { + if ((this.lobbyId != 1 || aBoolean3712) + && (this.lobbyId != 2 || aBoolean3713) + && (this.lobbyId != 3 || aBoolean3714)) { + if (this.lobbyId == 1) { + aBoolean3712 = false; // ?? + } + + if (this.lobbyId == 2) { + aBoolean3713 = false; // ?? + } + + if (this.lobbyId == 3) { + aBoolean3714 = false; // ?? + } + } else { + super.chatTextArea.clear(); + super.userList.removeAllUsers(); + } + + int numSingleLobby = Integer.parseInt(args[2]); + int numSingleGames = Integer.parseInt(args[3]); + int numDualLobby = Integer.parseInt(args[4]); + int numDualGames = Integer.parseInt(args[5]); + int numMultiLobby = Integer.parseInt(args[6]); + int numMultiGames = Integer.parseInt(args[7]); + int singleLobbyUsers = numSingleLobby + numSingleGames; + int dualLobbyUsers = numDualLobby + numDualGames; + int multiLobbyUsers = numMultiLobby + numMultiGames; + int lobbyUsers = -1; + int ingameUsers = -1; if (this.lobbyId == 1) { - aBoolean3712 = false; // ?? + lobbyUsers = numSingleLobby + numSingleGames; + ingameUsers = numSingleGames; } if (this.lobbyId == 2) { - aBoolean3713 = false; // ?? + lobbyUsers = numDualLobby + numDualGames; + ingameUsers = numDualGames; } if (this.lobbyId == 3) { - aBoolean3714 = false; // ?? + lobbyUsers = numMultiLobby + numMultiGames; + ingameUsers = numMultiGames; } - } else { - super.chatTextArea.clear(); - super.userList.removeAllUsers(); - } - int numSingleLobby = Integer.parseInt(args[2]); - int numSingleGames = Integer.parseInt(args[3]); - int numDualLobby = Integer.parseInt(args[4]); - int numDualGames = Integer.parseInt(args[5]); - int numMultiLobby = Integer.parseInt(args[6]); - int numMultiGames = Integer.parseInt(args[7]); - int singleLobbyUsers = numSingleLobby + numSingleGames; - int dualLobbyUsers = numDualLobby + numDualGames; - int multiLobbyUsers = numMultiLobby + numMultiGames; - int lobbyUsers = -1; - int ingameUsers = -1; - if (this.lobbyId == 1) { - lobbyUsers = numSingleLobby + numSingleGames; - ingameUsers = numSingleGames; - } - - if (this.lobbyId == 2) { - lobbyUsers = numDualLobby + numDualGames; - ingameUsers = numDualGames; - } + String message = null; + if (lobbyUsers == 0 && ingameUsers == 0) { + message = this.gameContainer.textManager.getGame("LobbyChat_UsersInThisLobby00"); + } - if (this.lobbyId == 3) { - lobbyUsers = numMultiLobby + numMultiGames; - ingameUsers = numMultiGames; - } + if (lobbyUsers == 1 && ingameUsers == 0) { + message = this.gameContainer.textManager.getGame("LobbyChat_UsersInThisLobby10"); + } - String message = null; - if (lobbyUsers == 0 && ingameUsers == 0) { - message = this.gameContainer.textManager.getGame("LobbyChat_UsersInThisLobby00"); - } + if (lobbyUsers == 1 && ingameUsers == 1) { + message = this.gameContainer.textManager.getGame("LobbyChat_UsersInThisLobby11"); + } - if (lobbyUsers == 1 && ingameUsers == 0) { - message = this.gameContainer.textManager.getGame("LobbyChat_UsersInThisLobby10"); - } + if (lobbyUsers >= 2 && ingameUsers == 0) { + message = this.gameContainer.textManager.getGame("LobbyChat_UsersInThisLobbyX0", lobbyUsers); + } - if (lobbyUsers == 1 && ingameUsers == 1) { - message = this.gameContainer.textManager.getGame("LobbyChat_UsersInThisLobby11"); - } + if (lobbyUsers >= 2 && ingameUsers == 1) { + message = this.gameContainer.textManager.getGame("LobbyChat_UsersInThisLobbyX1", lobbyUsers); + } - if (lobbyUsers >= 2 && ingameUsers == 0) { - message = this.gameContainer.textManager.getGame("LobbyChat_UsersInThisLobbyX0", lobbyUsers); - } + if (lobbyUsers >= 2 && ingameUsers >= 2) { + message = this.gameContainer.textManager.getGame( + "LobbyChat_UsersInThisLobbyXX", lobbyUsers, ingameUsers); + } - if (lobbyUsers >= 2 && ingameUsers == 1) { - message = this.gameContainer.textManager.getGame("LobbyChat_UsersInThisLobbyX1", lobbyUsers); - } + super.chatTextArea.addPlainMessage(message); + message = null; + if (this.lobbyId == 1 && (dualLobbyUsers >= 1 || multiLobbyUsers >= 1)) { + message = "("; + if (dualLobbyUsers == 1) { + message = message + this.gameContainer.textManager.getGame("LobbyChat_UsersInDualPlayerLobby1"); + } - if (lobbyUsers >= 2 && ingameUsers >= 2) { - message = - this.gameContainer.textManager.getGame("LobbyChat_UsersInThisLobbyXX", lobbyUsers, ingameUsers); - } + if (dualLobbyUsers >= 2) { + message = message + + this.gameContainer.textManager.getGame( + "LobbyChat_UsersInDualPlayerLobbyX", dualLobbyUsers); + } - super.chatTextArea.addPlainMessage(message); - message = null; - if (this.lobbyId == 1 && (dualLobbyUsers >= 1 || multiLobbyUsers >= 1)) { - message = "("; - if (dualLobbyUsers == 1) { - message = message + this.gameContainer.textManager.getGame("LobbyChat_UsersInDualPlayerLobby1"); - } + if (dualLobbyUsers >= 1 && multiLobbyUsers >= 1) { + message = message + ", "; + } - if (dualLobbyUsers >= 2) { - message = message - + this.gameContainer.textManager.getGame( - "LobbyChat_UsersInDualPlayerLobbyX", dualLobbyUsers); - } + if (multiLobbyUsers == 1) { + message = + message + this.gameContainer.textManager.getGame("LobbyChat_UsersInMultiPlayerLobby1"); + } - if (dualLobbyUsers >= 1 && multiLobbyUsers >= 1) { - message = message + ", "; - } + if (multiLobbyUsers >= 2) { + message = message + + this.gameContainer.textManager.getGame( + "LobbyChat_UsersInMultiPlayerLobbyX", multiLobbyUsers); + } - if (multiLobbyUsers == 1) { - message = message + this.gameContainer.textManager.getGame("LobbyChat_UsersInMultiPlayerLobby1"); + message = message + ")"; } - if (multiLobbyUsers >= 2) { - message = message - + this.gameContainer.textManager.getGame( - "LobbyChat_UsersInMultiPlayerLobbyX", multiLobbyUsers); - } + if (this.lobbyId == 2 && (singleLobbyUsers >= 1 || multiLobbyUsers >= 1)) { + message = "("; + if (singleLobbyUsers == 1) { + message = + message + this.gameContainer.textManager.getGame("LobbyChat_UsersInSinglePlayerLobby1"); + } - message = message + ")"; - } + if (singleLobbyUsers >= 2) { + message = message + + this.gameContainer.textManager.getGame( + "LobbyChat_UsersInSinglePlayerLobbyX", singleLobbyUsers); + } - if (this.lobbyId == 2 && (singleLobbyUsers >= 1 || multiLobbyUsers >= 1)) { - message = "("; - if (singleLobbyUsers == 1) { - message = message + this.gameContainer.textManager.getGame("LobbyChat_UsersInSinglePlayerLobby1"); - } + if (singleLobbyUsers >= 1 && multiLobbyUsers >= 1) { + message = message + ", "; + } - if (singleLobbyUsers >= 2) { - message = message - + this.gameContainer.textManager.getGame( - "LobbyChat_UsersInSinglePlayerLobbyX", singleLobbyUsers); - } + if (multiLobbyUsers == 1) { + message = + message + this.gameContainer.textManager.getGame("LobbyChat_UsersInMultiPlayerLobby1"); + } - if (singleLobbyUsers >= 1 && multiLobbyUsers >= 1) { - message = message + ", "; - } + if (multiLobbyUsers >= 2) { + message = message + + this.gameContainer.textManager.getGame( + "LobbyChat_UsersInMultiPlayerLobbyX", multiLobbyUsers); + } - if (multiLobbyUsers == 1) { - message = message + this.gameContainer.textManager.getGame("LobbyChat_UsersInMultiPlayerLobby1"); + message = message + ")"; } - if (multiLobbyUsers >= 2) { - message = message - + this.gameContainer.textManager.getGame( - "LobbyChat_UsersInMultiPlayerLobbyX", multiLobbyUsers); - } + if (this.lobbyId == 3 && (singleLobbyUsers >= 1 || dualLobbyUsers >= 1)) { + message = "("; + if (singleLobbyUsers == 1) { + message = + message + this.gameContainer.textManager.getGame("LobbyChat_UsersInSinglePlayerLobby1"); + } - message = message + ")"; - } + if (singleLobbyUsers >= 2) { + message = message + + this.gameContainer.textManager.getGame( + "LobbyChat_UsersInSinglePlayerLobbyX", singleLobbyUsers); + } - if (this.lobbyId == 3 && (singleLobbyUsers >= 1 || dualLobbyUsers >= 1)) { - message = "("; - if (singleLobbyUsers == 1) { - message = message + this.gameContainer.textManager.getGame("LobbyChat_UsersInSinglePlayerLobby1"); - } + if (singleLobbyUsers >= 1 && dualLobbyUsers >= 1) { + message = message + ", "; + } - if (singleLobbyUsers >= 2) { - message = message - + this.gameContainer.textManager.getGame( - "LobbyChat_UsersInSinglePlayerLobbyX", singleLobbyUsers); - } + if (dualLobbyUsers == 1) { + message = message + this.gameContainer.textManager.getGame("LobbyChat_UsersInDualPlayerLobby1"); + } - if (singleLobbyUsers >= 1 && dualLobbyUsers >= 1) { - message = message + ", "; - } + if (dualLobbyUsers >= 2) { + message = message + + this.gameContainer.textManager.getGame( + "LobbyChat_UsersInDualPlayerLobbyX", dualLobbyUsers); + } - if (dualLobbyUsers == 1) { - message = message + this.gameContainer.textManager.getGame("LobbyChat_UsersInDualPlayerLobby1"); + message = message + ")"; } - if (dualLobbyUsers >= 2) { - message = message - + this.gameContainer.textManager.getGame( - "LobbyChat_UsersInDualPlayerLobbyX", dualLobbyUsers); + if (message != null) { + super.chatTextArea.addPlainMessage(message); } - message = message + ")"; + super.chatTextArea.addText(); + return true; } + case "users" -> { + int i = args.length - 2; + String[] users = new String[i]; - if (message != null) { - super.chatTextArea.addPlainMessage(message); - } + System.arraycopy(args, 2, users, 0, i); - super.chatTextArea.addText(); - return true; - } else if (args[1].equals("users")) { - int i = args.length - 2; - String[] users = new String[i]; - - System.arraycopy(args, 2, users, 0, i); - - this.setUserList(users); - return true; - } else if (args[1].equals("ownjoin")) { - this.localUserJoin(args[2]); - return true; - } else if (args[1].equals("join") || args[1].equals("joinfromgame")) { - String userData = this.userJoin(args[2]); - if (!this.isNoJoinPartMessages()) { - super.chatTextArea.addJoinMessage(this.gameContainer.textManager.getGame( - "LobbyChat_User" + (args[1].equals("join") ? "Joined" : "ReturnedFromGame"), userData)); + this.setUserList(users); + return true; } - - return true; - } else if (args[1].equals("part")) { - this.userLeft(args[2]); - int reason = Integer.parseInt(args[3]); - if (reason == 1 && this.lobbyId == 1) { - if (!this.isNoGameMessages()) { - super.chatTextArea.addMessage( - this.gameContainer.textManager.getGame("LobbyChat_UserStartedSp", args[2])); + case "ownjoin" -> { + this.localUserJoin(args[2]); + return true; + } + case "join", "joinfromgame" -> { + String userData = this.userJoin(args[2]); + if (!this.isNoJoinPartMessages()) { + super.chatTextArea.addJoinMessage(this.gameContainer.textManager.getGame( + "LobbyChat_User" + (args[1].equals("join") ? "Joined" : "ReturnedFromGame"), userData)); } return true; - } else if (reason == 2 || reason == 3) { - if (!this.isNoGameMessages()) { - String[] reasons = new String[] {null, null, "CreatedMp", "JoinedMp"}; - String var5; - if (args.length == 4) { - var5 = this.gameContainer.textManager.getGame("LobbyChat_User" + reasons[reason], args[2]); - } else { - var5 = this.gameContainer.textManager.getGame( - "LobbyChat_User" + reasons[reason], args[2], args[4]); + } + case "part" -> { + this.userLeft(args[2]); + int reason = Integer.parseInt(args[3]); + if (reason == 1 && this.lobbyId == 1) { + if (!this.isNoGameMessages()) { + super.chatTextArea.addMessage( + this.gameContainer.textManager.getGame("LobbyChat_UserStartedSp", args[2])); } - super.chatTextArea.addMessage(var5); - } + return true; + } else if (reason == 2 || reason == 3) { + if (!this.isNoGameMessages()) { + String[] reasons = new String[] {null, null, "CreatedMp", "JoinedMp"}; + String var5; + if (args.length == 4) { + var5 = this.gameContainer.textManager.getGame("LobbyChat_User" + reasons[reason], args[2]); + } else { + var5 = this.gameContainer.textManager.getGame( + "LobbyChat_User" + reasons[reason], args[2], args[4]); + } + + super.chatTextArea.addMessage(var5); + } - return true; - } else if (reason >= 4) { - if (!this.isNoJoinPartMessages()) { - super.chatTextArea.addPartMessage(this.gameContainer.textManager.getGame( - "LobbyChat_UserLeft" + (reason == 5 ? "ConnectionProblem" : ""), args[2])); + return true; + } else if (reason >= 4) { + if (!this.isNoJoinPartMessages()) { + super.chatTextArea.addPartMessage(this.gameContainer.textManager.getGame( + "LobbyChat_UserLeft" + (reason == 5 ? "ConnectionProblem" : ""), args[2])); + } + + return true; + } else { + return true; + } + } + case "gsn" -> { + if (!this.isNoGameMessages()) { + super.chatTextArea.addMessage( + this.gameContainer.textManager.getGame("LobbyChat_UsersStartedDp", args[2], args[3])); } return true; - } else { + } + case "say" -> { + this.userSay(Integer.parseInt(args[2]), args[3], args[4]); return true; } - } else if (args[1].equals("gsn")) { - if (!this.isNoGameMessages()) { - super.chatTextArea.addMessage( - this.gameContainer.textManager.getGame("LobbyChat_UsersStartedDp", args[2], args[3])); + case "sayp" -> { + this.userSayPrivately(args[2], args[3]); + return true; + } + case "sheriffsay" -> { + this.sheriffSay(args[2]); + return true; + } + case "serversay" -> { + this.serverSay(args[2]); + return true; + } + case "nc" -> { + this.getUser(args[2], args[3].equals("t")); + return true; } - - return true; - } else if (args[1].equals("say")) { - this.userSay(Integer.parseInt(args[2]), args[3], args[4]); - return true; - } else if (args[1].equals("sayp")) { - this.userSayPrivately(args[2], args[3]); - return true; - } else if (args[1].equals("sheriffsay")) { - this.sheriffSay(args[2]); - return true; - } else if (args[1].equals("serversay")) { - this.serverSay(args[2]); - return true; - } else if (args[1].equals("nc")) { - this.getUser(args[2], args[3].equals("t")); - return true; } return false; } diff --git a/client/src/main/java/agolf/lobby/LobbyDualPlayerPanel.java b/client/src/main/java/agolf/lobby/LobbyDualPlayerPanel.java index 6d321ec3..670bf46f 100644 --- a/client/src/main/java/agolf/lobby/LobbyDualPlayerPanel.java +++ b/client/src/main/java/agolf/lobby/LobbyDualPlayerPanel.java @@ -416,94 +416,100 @@ public void actionPerformed(ActionEvent evt) { } protected boolean handlePacket(String[] args) { - if (args[1].equals("challenge")) { - synchronized (synchronizedObject) { - if (this.currentState == 1) { - this.gameContainer.lobbyPanel.writeData("cfail\t" + args[2] + "\tcother"); - return true; - } - if (currentState == 2) { - this.gameContainer.lobbyPanel.writeData("cfail\t" + args[2] + "\tnochall"); - return true; + switch (args[1]) { + case "challenge" -> { + synchronized (synchronizedObject) { + if (this.currentState == 1) { + this.gameContainer.lobbyPanel.writeData("cfail\t" + args[2] + "\tcother"); + return true; + } + if (currentState == 2) { + this.gameContainer.lobbyPanel.writeData("cfail\t" + args[2] + "\tnochall"); + return true; + } + if (checkboxNoChallenges.getState() || gameContainer.lobbyPanel.isUserIgnored(args[2])) { + this.gameContainer.lobbyPanel.writeData("cfail\t" + args[2] + "\tcbyother"); + return true; + } + this.opponentName = args[2]; + this.tracksNum = Integer.parseInt(args[3]); + this.trackType = Integer.parseInt(args[4]); + this.maxStrokes = Integer.parseInt(args[5]); + this.timeLimit = Integer.parseInt(args[6]); + this.waterEvent = Integer.parseInt(args[7]); + this.collision = Integer.parseInt(args[8]); + this.scoring = Integer.parseInt(args[9]); + this.scoringEnd = Integer.parseInt(args[10]); + /*if(isUsingCustomServer) { + this.trackCategory = Integer.parseInt(args[11]); + }*/ + this.setState(2); } - if (checkboxNoChallenges.getState() || gameContainer.lobbyPanel.isUserIgnored(args[2])) { - this.gameContainer.lobbyPanel.writeData("cfail\t" + args[2] + "\tcbyother"); - return true; + + if (this.checkboxBeep.getState()) { + this.gameContainer.soundManager.playChallenge(); } - this.opponentName = args[2]; - this.tracksNum = Integer.parseInt(args[3]); - this.trackType = Integer.parseInt(args[4]); - this.maxStrokes = Integer.parseInt(args[5]); - this.timeLimit = Integer.parseInt(args[6]); - this.waterEvent = Integer.parseInt(args[7]); - this.collision = Integer.parseInt(args[8]); - this.scoring = Integer.parseInt(args[9]); - this.scoringEnd = Integer.parseInt(args[10]); - /*if(isUsingCustomServer) { - this.trackCategory = Integer.parseInt(args[11]); - }*/ - this.setState(2); - } - if (this.checkboxBeep.getState()) { - this.gameContainer.soundManager.playChallenge(); + return true; } + case "cancel" -> { + synchronized (synchronizedObject) { + if (this.currentState == 2) { + this.setState(0); + return true; + } - return true; - } else if (args[1].equals("cancel")) { - synchronized (synchronizedObject) { - if (this.currentState == 2) { - this.setState(0); return true; } - - return true; } - } else if (args[1].equals("cfail")) { - synchronized (synchronizedObject) { - if (this.currentState != 1) { - return true; + case "cfail" -> { + synchronized (synchronizedObject) { + if (this.currentState != 1) { + return true; + } + + this.setState(0); } - this.setState(0); - } + if (args[2].equals("nouser")) { + this.extraText = this.gameContainer.textManager.getGame("LobbyReal_NoChallengedUser"); + } - if (args[2].equals("nouser")) { - this.extraText = this.gameContainer.textManager.getGame("LobbyReal_NoChallengedUser"); - } + if (args[2].equals("nochall")) { + this.extraText = this.gameContainer.textManager.getGame("LobbyReal_NoChallenges"); + } - if (args[2].equals("nochall")) { - this.extraText = this.gameContainer.textManager.getGame("LobbyReal_NoChallenges"); - } + if (args[2].equals("cother")) { + this.extraText = this.gameContainer.textManager.getGame("LobbyReal_ChallengingOther"); + } - if (args[2].equals("cother")) { - this.extraText = this.gameContainer.textManager.getGame("LobbyReal_ChallengingOther"); - } + if (args[2].equals("cbyother")) { + this.extraText = this.gameContainer.textManager.getGame("LobbyReal_ChallengedByOther"); + } - if (args[2].equals("cbyother")) { - this.extraText = this.gameContainer.textManager.getGame("LobbyReal_ChallengedByOther"); - } + if (args[2].equals("refuse")) { + this.extraText = this.gameContainer.textManager.getGame("LobbyReal_ChallengeRefused"); + } - if (args[2].equals("refuse")) { - this.extraText = this.gameContainer.textManager.getGame("LobbyReal_ChallengeRefused"); + this.repaint(); + return true; } + case "afail" -> { + synchronized (synchronizedObject) { + if (this.currentState != -1) { + return true; + } - this.repaint(); - return true; - } else if (args[1].equals("afail")) { - synchronized (synchronizedObject) { - if (this.currentState != -1) { - return true; + this.setState(0); } - this.setState(0); + this.extraText = this.gameContainer.textManager.getGame("LobbyReal_ChallengedLeft"); + this.repaint(); + return true; + } + default -> { + return false; } - - this.extraText = this.gameContainer.textManager.getGame("LobbyReal_ChallengedLeft"); - this.repaint(); - return true; - } else { - return false; } } diff --git a/client/src/main/java/agolf/lobby/LobbyMultiPlayerPanel.java b/client/src/main/java/agolf/lobby/LobbyMultiPlayerPanel.java index 905840ed..fba757f0 100644 --- a/client/src/main/java/agolf/lobby/LobbyMultiPlayerPanel.java +++ b/client/src/main/java/agolf/lobby/LobbyMultiPlayerPanel.java @@ -403,27 +403,26 @@ protected void joinMultiPlayerGame(int gameId, String password) { protected boolean handlePacket(String[] args) { if (args[1].equals("gamelist")) { - if (args[2].equals("full")) { - this.gameListFull(args); - this.repaint(); - return true; - } - - if (args[2].equals("add")) { - this.gameListAdd(args, 3, this.trackList.getItemCount() == 0 ? Integer.parseInt(args[3]) : -1); - this.repaint(); - return true; - } - - if (args[2].equals("change")) { - this.gameListChange(args); - return true; - } - - if (args[2].equals("remove")) { - this.gameListRemove(args); - this.repaint(); - return true; + switch (args[2]) { + case "full" -> { + this.gameListFull(args); + this.repaint(); + return true; + } + case "add" -> { + this.gameListAdd(args, 3, this.trackList.getItemCount() == 0 ? Integer.parseInt(args[3]) : -1); + this.repaint(); + return true; + } + case "change" -> { + this.gameListChange(args); + return true; + } + case "remove" -> { + this.gameListRemove(args); + this.repaint(); + return true; + } } } diff --git a/client/src/main/java/agolf/lobby/LobbyPanel.java b/client/src/main/java/agolf/lobby/LobbyPanel.java index 36bbcc2c..2c602c95 100644 --- a/client/src/main/java/agolf/lobby/LobbyPanel.java +++ b/client/src/main/java/agolf/lobby/LobbyPanel.java @@ -24,7 +24,6 @@ public class LobbyPanel extends Panel { private LobbyChatPanel lobbyChatPanelMulti; private LobbyControlPanel lobbyControlPanel; private LobbyTrackListAdminPanel lobbyTrackListAdminPanel; - public static boolean aBoolean465; public LobbyPanel(GameContainer gameContainer, int width, int height) { this.gameContainer = gameContainer; @@ -150,44 +149,29 @@ public void requestTrackSetList() { } public void handlePacket(String[] args) { - boolean dummy = false; if (this.activeLobby > 0) { if (this.activeLobby == 1) { - if (this.lobbySinglePlayerPanel.handlePacket(args)) { - dummy = true; - } + this.lobbySinglePlayerPanel.handlePacket(args); - if (this.lobbyChatPanelSingle != null && this.lobbyChatPanelSingle.handlePacket(args)) { - dummy = true; + if (this.lobbyChatPanelSingle != null) { + this.lobbyChatPanelSingle.handlePacket(args); } } if (this.activeLobby == 2) { - if (this.lobbyDualPlayerPanel.handlePacket(args)) { - dummy = true; - } - - if (this.lobbyChatPanelDual.handlePacket(args)) { - dummy = true; - } + this.lobbyDualPlayerPanel.handlePacket(args); + this.lobbyChatPanelDual.handlePacket(args); } if (this.activeLobby == 3) { - if (this.lobbyMultiPlayerPanel.handlePacket(args)) { - dummy = true; - } - - if (this.lobbyChatPanelMulti.handlePacket(args)) { - dummy = true; - } + this.lobbyMultiPlayerPanel.handlePacket(args); + this.lobbyChatPanelMulti.handlePacket(args); } } - if (this.activeLobby == -1 && this.lobbyTrackListAdminPanel.handlePacket(args)) { - dummy = true; + if (this.activeLobby == -1) { + this.lobbyTrackListAdminPanel.handlePacket(args); } - - if (dummy) {} } public void broadcastMessage(String message) { diff --git a/client/src/main/java/com/aapeli/applet/AApplet.java b/client/src/main/java/com/aapeli/applet/AApplet.java index 5bf32571..f51156cc 100644 --- a/client/src/main/java/com/aapeli/applet/AApplet.java +++ b/client/src/main/java/com/aapeli/applet/AApplet.java @@ -18,6 +18,7 @@ import java.awt.Image; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.net.URI; import java.net.URL; public abstract class AApplet extends Applet implements Runnable, ActionListener, QuickTimerListener { @@ -63,14 +64,18 @@ public abstract class AApplet extends Applet implements Runnable, ActionListener private boolean destroyed; private boolean ready; private RetryCanvas retryCanvas; - private Image splashImage; - private long splashTimestamp; private QuickTimer popupTimer; private SocketConnection socketConnection; private Image appletImage; private Graphics appletGraphics; private boolean verbose; + public AApplet(Parameters parameters) { + super(); + this.param = parameters; + parameters.setRootComponent(this); + } + public void init() { System.out.println("\n" + this.getAppletInfo() + "\n"); this.appletWidth = 735; @@ -118,22 +123,13 @@ public void destroy() { this.soundManager.destroy(); } - if (this.imageManager != null) { - this.imageManager.destroy(); - } - if (this.textManager != null) { this.textManager.destroy(); } - if (this.param != null) { - this.param.destroy(); - } - this.soundManager = null; this.imageManager = null; this.textManager = null; - this.param = null; if (this.appletGraphics != null) { this.appletGraphics.dispose(); this.appletGraphics = null; @@ -162,277 +158,273 @@ public void update(Graphics graphics) { this.appletGraphics = this.appletImage.getGraphics(); } - if (this.splashImage != null) { - this.appletGraphics.drawImage(this.splashImage, 0, 0, this); - } else { - Color backgroundColor = this.getBackground(); - this.appletGraphics.setColor(backgroundColor); - this.appletGraphics.fillRect(0, 0, this.appletWidth, this.appletHeight); - if (this.imageManager != null && this.backgroundImageKey != null) { - Image image = this.imageManager.getGameImage(this.backgroundImageKey); - if (image != null) { - this.appletGraphics.drawImage(image, this.backgroundXOffset, this.backgroundYOffset, this); - } + Color backgroundColor = this.getBackground(); + this.appletGraphics.setColor(backgroundColor); + this.appletGraphics.fillRect(0, 0, this.appletWidth, this.appletHeight); + if (this.imageManager != null && this.backgroundImageKey != null) { + Image image = this.imageManager.getGameImage(this.backgroundImageKey); + if (image != null) { + this.appletGraphics.drawImage(image, this.backgroundXOffset, this.backgroundYOffset, this); } + } - if (this.textManager != null) { - this.appletGraphics.setColor(this.getForeground()); - Color outlineColor = this.drawTextOutline ? backgroundColor : null; - if (this.endState == END_ERROR_CONNECTION) { - byte textYOffset = -20; - this.appletGraphics.setFont(fontDialog15); + if (this.textManager != null) { + this.appletGraphics.setColor(this.getForeground()); + Color outlineColor = this.drawTextOutline ? backgroundColor : null; + if (this.endState == END_ERROR_CONNECTION) { + byte textYOffset = -20; + this.appletGraphics.setFont(fontDialog15); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_CE_ConnectionError"), + 40, + 80 + textYOffset, + -1); + this.appletGraphics.setFont(fontDialog12); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_CE_PossibleReasons"), + 40, + 125 + textYOffset, + -1); + if (!this.ready) { + this.appletGraphics.setFont(fontDialog12); StringDraw.drawOutlinedString( this.appletGraphics, outlineColor, - this.textManager.getShared("Message_CE_ConnectionError"), + "- " + this.textManager.getShared("Message_CE0_1_Short"), 40, - 80 + textYOffset, + 160 + textYOffset, -1); + this.appletGraphics.setFont(fontDialog11); + StringDraw.drawOutlinedStringWithMaxWidth( + this.appletGraphics, + outlineColor, + this.textManager.getShared( + "Message_CE0_1_Long", + this.param.getServerIp(), + "" + this.param.getServerPort()), + 50, + 180 + textYOffset, + -1, + this.appletWidth - 50 - 50); this.appletGraphics.setFont(fontDialog12); StringDraw.drawOutlinedString( this.appletGraphics, outlineColor, - this.textManager.getShared("Message_CE_PossibleReasons"), + "- " + this.textManager.getShared("Message_CE0_2_Short"), 40, - 125 + textYOffset, + 245 + textYOffset, -1); - if (!this.ready) { - this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString( - this.appletGraphics, - outlineColor, - "- " + this.textManager.getShared("Message_CE0_1_Short"), - 40, - 160 + textYOffset, - -1); - this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth( - this.appletGraphics, - outlineColor, - this.textManager.getShared( - "Message_CE0_1_Long", - this.param.getServerIp(), - "" + this.param.getServerPort()), - 50, - 180 + textYOffset, - -1, - this.appletWidth - 50 - 50); - this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString( - this.appletGraphics, - outlineColor, - "- " + this.textManager.getShared("Message_CE0_2_Short"), - 40, - 245 + textYOffset, - -1); - this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth( - this.appletGraphics, - outlineColor, - this.textManager.getShared("Message_CE0_2_Long"), - 50, - 265 + textYOffset, - -1, - this.appletWidth - 50 - 50); - this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString( - this.appletGraphics, - outlineColor, - "- " + this.textManager.getShared("Message_CE0_3_Short"), - 40, - 305 + textYOffset, - -1); - this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth( - this.appletGraphics, - outlineColor, - this.textManager.getShared("Message_CE0_3_Long"), - 50, - 325 + textYOffset, - -1, - this.appletWidth - 50 - 50); - } else { - this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString( - this.appletGraphics, - outlineColor, - "- " + this.textManager.getShared("Message_CE1_1_Short"), - 40, - 160 + textYOffset, - -1); - this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth( - this.appletGraphics, - outlineColor, - this.textManager.getShared("Message_CE1_1_Long"), - 50, - 180 + textYOffset, - -1, - this.appletWidth - 50 - 50); - this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString( - this.appletGraphics, - outlineColor, - "- " + this.textManager.getShared("Message_CE1_2_Short"), - 40, - 235 + textYOffset, - -1); - this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth( - this.appletGraphics, - outlineColor, - this.textManager.getShared("Message_CE1_2_Long"), - 50, - 255 + textYOffset, - -1, - this.appletWidth - 50 - 50); - this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString( - this.appletGraphics, - outlineColor, - "- " + this.textManager.getShared("Message_CE1_3_Short"), - 40, - 305 + textYOffset, - -1); - this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth( - this.appletGraphics, - outlineColor, - this.textManager.getShared("Message_CE1_3_Long"), - 50, - 325 + textYOffset, - -1, - this.appletWidth - 50 - 50); - } - } else if (this.endState == END_THROWABLE) { - this.appletGraphics.setFont(fontDialog15); + this.appletGraphics.setFont(fontDialog11); + StringDraw.drawOutlinedStringWithMaxWidth( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_CE0_2_Long"), + 50, + 265 + textYOffset, + -1, + this.appletWidth - 50 - 50); + this.appletGraphics.setFont(fontDialog12); StringDraw.drawOutlinedString( this.appletGraphics, outlineColor, - this.textManager.getShared("Message_PE_ProgramError"), + "- " + this.textManager.getShared("Message_CE0_3_Short"), + 40, + 305 + textYOffset, + -1); + this.appletGraphics.setFont(fontDialog11); + StringDraw.drawOutlinedStringWithMaxWidth( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_CE0_3_Long"), 50, - 100, + 325 + textYOffset, + -1, + this.appletWidth - 50 - 50); + } else { + this.appletGraphics.setFont(fontDialog12); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + "- " + this.textManager.getShared("Message_CE1_1_Short"), + 40, + 160 + textYOffset, -1); + this.appletGraphics.setFont(fontDialog11); + StringDraw.drawOutlinedStringWithMaxWidth( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_CE1_1_Long"), + 50, + 180 + textYOffset, + -1, + this.appletWidth - 50 - 50); this.appletGraphics.setFont(fontDialog12); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + "- " + this.textManager.getShared("Message_CE1_2_Short"), + 40, + 235 + textYOffset, + -1); + this.appletGraphics.setFont(fontDialog11); StringDraw.drawOutlinedStringWithMaxWidth( this.appletGraphics, outlineColor, - this.textManager.getShared("Message_PE_GameClosed"), + this.textManager.getShared("Message_CE1_2_Long"), 50, - 150, + 255 + textYOffset, -1, - this.appletWidth - 70 - 50); - this.appletGraphics.setFont(fontDialog12b); + this.appletWidth - 50 - 50); + this.appletGraphics.setFont(fontDialog12); StringDraw.drawOutlinedString( this.appletGraphics, outlineColor, - this.textManager.getShared("Message_PE_ErrorDesc", this.aThrowable2553.toString()), + "- " + this.textManager.getShared("Message_CE1_3_Short"), + 40, + 305 + textYOffset, + -1); + this.appletGraphics.setFont(fontDialog11); + StringDraw.drawOutlinedStringWithMaxWidth( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_CE1_3_Long"), 50, - 235, + 325 + textYOffset, + -1, + this.appletWidth - 50 - 50); + } + } else if (this.endState == END_THROWABLE) { + this.appletGraphics.setFont(fontDialog15); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_PE_ProgramError"), + 50, + 100, + -1); + this.appletGraphics.setFont(fontDialog12); + StringDraw.drawOutlinedStringWithMaxWidth( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_PE_GameClosed"), + 50, + 150, + -1, + this.appletWidth - 70 - 50); + this.appletGraphics.setFont(fontDialog12b); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_PE_ErrorDesc", this.aThrowable2553.toString()), + 50, + 235, + -1); + } else { + String endText = this.textManager.getShared("Message_WaitWhile"); + String endTextHelp = null; + if (this.endState == END_ERROR_MATCH) { + endText = this.textManager.getShared("Match_MessageError"); + endTextHelp = this.textManager.getShared("Match_MessageErrorHelp"); + } else if (this.endState == END_ERROR_VERSION) { + endText = this.textManager.getShared("Message_VersionError"); + endTextHelp = this.textManager.getShared("Message_VersionErrorHelp"); + } else if (this.endState == END_ERROR_SERVERFULL) { + endText = this.textManager.getShared("Message_ServerFullError"); + endTextHelp = this.textManager.getShared("Message_ServerFullErrorHelp"); + } else if (this.endState == END_QUIT) { + endText = this.textManager.getShared("Message_QuitGame"); + } else if (this.endState == END_QUIT_REGISTER) { + endText = this.textManager.getShared("Message_QuitGame_ToRegister"); + } else if (this.endState == END_QUIT_BUYCOINS) { + endText = this.textManager.getShared("Message_QuitGame_ToBuyCoins"); + } else if (this.endState == END_OTHER) { + endText = this.endTextCustom; + } else if (this.endState == END_ERROR_KICK_NOW) { + endText = this.textManager.getShared("Message_KickedNow"); + endTextHelp = this.textManager.getShared("Message_KickedNowHelp"); + } else if (this.endState == END_ERROR_KICKBAN_NOW) { + endText = this.textManager.getShared("Message_BannedNow"); + endTextHelp = this.textManager.getShared("Message_BannedNowHelp"); + } else if (this.endState == END_ERROR_BAN_INIT) { + endText = this.textManager.getShared("Message_BannedInitially"); + endTextHelp = this.textManager.getShared("Message_BannedInitiallyHelp"); + } else if (this.endState == END_ERROR_REGLOGIN_FAILED) { + endText = this.textManager.getShared("Message_LoginFailedReg"); + endTextHelp = this.textManager.getShared("Message_LoginFailedRegHelp"); + } else if (this.endState == END_ERROR_TOOMANYIP_INIT) { + endText = this.textManager.getShared("Message_TooManySameIP"); + endTextHelp = this.textManager.getShared("Message_TooManySameIPHelp"); + } + + this.appletGraphics.setFont(fontDialog15); + if (this.endTextLocation == TEXT_CENTER) { + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + endText, + this.appletWidth / 2, + this.appletHeight / 2 - 10, + 0); + } else if (this.endTextLocation == TEXT_LOWERLEFT) { + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + endText, + this.appletWidth / 12, + this.appletHeight - 120, -1); - } else { - String endText = this.textManager.getShared("Message_WaitWhile"); - String endTextHelp = null; - if (this.endState == END_ERROR_MATCH) { - endText = this.textManager.getShared("Match_MessageError"); - endTextHelp = this.textManager.getShared("Match_MessageErrorHelp"); - } else if (this.endState == END_ERROR_VERSION) { - endText = this.textManager.getShared("Message_VersionError"); - endTextHelp = this.textManager.getShared("Message_VersionErrorHelp"); - } else if (this.endState == END_ERROR_SERVERFULL) { - endText = this.textManager.getShared("Message_ServerFullError"); - endTextHelp = this.textManager.getShared("Message_ServerFullErrorHelp"); - } else if (this.endState == END_QUIT) { - endText = this.textManager.getShared("Message_QuitGame"); - } else if (this.endState == END_QUIT_REGISTER) { - endText = this.textManager.getShared("Message_QuitGame_ToRegister"); - } else if (this.endState == END_QUIT_BUYCOINS) { - endText = this.textManager.getShared("Message_QuitGame_ToBuyCoins"); - } else if (this.endState == END_OTHER) { - endText = this.endTextCustom; - } else if (this.endState == END_ERROR_KICK_NOW) { - endText = this.textManager.getShared("Message_KickedNow"); - endTextHelp = this.textManager.getShared("Message_KickedNowHelp"); - } else if (this.endState == END_ERROR_KICKBAN_NOW) { - endText = this.textManager.getShared("Message_BannedNow"); - endTextHelp = this.textManager.getShared("Message_BannedNowHelp"); - } else if (this.endState == END_ERROR_BAN_INIT) { - endText = this.textManager.getShared("Message_BannedInitially"); - endTextHelp = this.textManager.getShared("Message_BannedInitiallyHelp"); - } else if (this.endState == END_ERROR_REGLOGIN_FAILED) { - endText = this.textManager.getShared("Message_LoginFailedReg"); - endTextHelp = this.textManager.getShared("Message_LoginFailedRegHelp"); - } else if (this.endState == END_ERROR_TOOMANYIP_INIT) { - endText = this.textManager.getShared("Message_TooManySameIP"); - endTextHelp = this.textManager.getShared("Message_TooManySameIPHelp"); - } + } else if (this.endTextLocation == TEXT_LOWERMIDDLE) { + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + endText, + this.appletWidth / 2, + this.appletHeight - 120, + 0); + } - this.appletGraphics.setFont(fontDialog15); + if (endTextHelp != null) { + this.appletGraphics.setFont(fontDialog12); if (this.endTextLocation == TEXT_CENTER) { - StringDraw.drawOutlinedString( + StringDraw.drawOutlinedStringWithMaxWidth( this.appletGraphics, outlineColor, - endText, + endTextHelp, this.appletWidth / 2, - this.appletHeight / 2 - 10, - 0); + this.appletHeight / 2 + 30, + 0, + (int) ((double) this.appletWidth * 0.8D)); } else if (this.endTextLocation == TEXT_LOWERLEFT) { - StringDraw.drawOutlinedString( + StringDraw.drawOutlinedStringWithMaxWidth( this.appletGraphics, outlineColor, - endText, + endTextHelp, this.appletWidth / 12, - this.appletHeight - 120, - -1); + this.appletHeight - 80, + -1, + (int) ((double) this.appletWidth * 0.6D)); } else if (this.endTextLocation == TEXT_LOWERMIDDLE) { - StringDraw.drawOutlinedString( + StringDraw.drawOutlinedStringWithMaxWidth( this.appletGraphics, outlineColor, - endText, + endTextHelp, this.appletWidth / 2, - this.appletHeight - 120, - 0); - } - - if (endTextHelp != null) { - this.appletGraphics.setFont(fontDialog12); - if (this.endTextLocation == TEXT_CENTER) { - StringDraw.drawOutlinedStringWithMaxWidth( - this.appletGraphics, - outlineColor, - endTextHelp, - this.appletWidth / 2, - this.appletHeight / 2 + 30, - 0, - (int) ((double) this.appletWidth * 0.8D)); - } else if (this.endTextLocation == TEXT_LOWERLEFT) { - StringDraw.drawOutlinedStringWithMaxWidth( - this.appletGraphics, - outlineColor, - endTextHelp, - this.appletWidth / 12, - this.appletHeight - 80, - -1, - (int) ((double) this.appletWidth * 0.6D)); - } else if (this.endTextLocation == TEXT_LOWERMIDDLE) { - StringDraw.drawOutlinedStringWithMaxWidth( - this.appletGraphics, - outlineColor, - endTextHelp, - this.appletWidth / 2, - this.appletHeight - 80, - 0, - (int) ((double) this.appletWidth * 0.5D)); - } + this.appletHeight - 80, + 0, + (int) ((double) this.appletWidth * 0.5D)); } } } } - - int x = (this.getWidth() - appletImage.getWidth(null)) / 2; - int y = (this.getHeight() - appletImage.getHeight(null)) / 2; - graphics.drawImage(this.appletImage, x, y, this); } + + int x = (this.getWidth() - appletImage.getWidth(null)) / 2; + int y = (this.getHeight() - appletImage.getHeight(null)) / 2; + graphics.drawImage(this.appletImage, x, y, this); } public void run() { @@ -442,7 +434,6 @@ public void run() { this.add(this.loadingPanel); this.revalidate(); this.loadingPanel.start(); - this.param = new Parameters(this, this.isDebug()); String initMessage = this.param.getParameter("initmessage"); this.verbose = Boolean.parseBoolean(this.param.getParameter("verbose")); if (initMessage != null && initMessage.indexOf('|') == -1) { @@ -523,9 +514,6 @@ public void run() { this.loadingPanel.setLoadingMessage( this.textManager.getShared("Loader_LoadingGfxSfx") + (adInfo != null ? adInfo : "")); this.soundManager = new SoundManager(true, this.isDebug()); - if (startupDebug) { - this.soundManager.enableSUD(); - } this.loadingPanel.addProgress(0.15D); if (startupDebug) { @@ -573,7 +561,6 @@ public void run() { this.printSUD("Defining secondary images"); } - this.defineSecImages(this.imageManager, this.param.getSiteName()); if (!this.destroyed) { this.soundManager.startLoading(); if (System.currentTimeMillis() < startTime + 7000L) { @@ -728,7 +715,6 @@ public void setEndState(int state) { this.add(this.retryCanvas); } - this.splashImage = null; this.repaint(); } } @@ -778,8 +764,6 @@ public void textsLoadedNotify(TextManager var1) {} public abstract void createImages(); - public void defineSecImages(ImageManager imageManager, String var2) {} - public abstract void connectToServer(); public abstract void appletReady(); @@ -788,26 +772,6 @@ public void defineSecImages(ImageManager imageManager, String var2) {} public abstract boolean isDebug(); - public void showSplash(Image img) { - this.splashImage = img; - this.splashTimestamp = System.currentTimeMillis(); - } - - public void waitAndRemoveSplash(int millis, boolean noRepaint) { - if (this.splashImage != null) { - long var3 = this.splashTimestamp + (long) millis; - - while (System.currentTimeMillis() < var3) { - Tools.sleep(100L); - } - - this.splashImage = null; - if (!noRepaint) { - this.repaint(); - } - } - } - public boolean callJavaScriptJSON(String json) { return this.param.callJavaScriptJSON(json); } @@ -848,7 +812,6 @@ private void removeLoadingPanel() { if (var1 != null) { this.remove(var1); var1.destroy(); - var1 = null; this.loadingPanel = null; } } @@ -885,7 +848,7 @@ private void sendLoadTimes( queryUrl = Tools.replaceFirst(queryUrl, "%4", "" + time4); queryUrl = Tools.replaceFirst(queryUrl, "%5", "" + time5); queryUrl = Tools.replaceFirst(queryUrl, "%6", "" + time6); - URL url = new URL(queryUrl); + URL url = new URI(queryUrl).toURL(); if (this.isDebug()) { System.out.println("AApplet.sendLoadTimes(...): Displaying page \"" + url + "\""); } @@ -901,8 +864,7 @@ private String getSystemProperty(String key) { if (result != null) { return result; } - } catch (Exception e) { - } catch (Error e) { + } catch (Exception | Error e) { } return ""; diff --git a/client/src/main/java/com/aapeli/applet/AdCanvas.java b/client/src/main/java/com/aapeli/applet/AdCanvas.java index 7923966e..163d2e6b 100644 --- a/client/src/main/java/com/aapeli/applet/AdCanvas.java +++ b/client/src/main/java/com/aapeli/applet/AdCanvas.java @@ -4,12 +4,15 @@ import java.awt.Canvas; import java.awt.Color; import java.awt.Cursor; +import java.awt.Desktop; import java.awt.Graphics; import java.awt.Image; import java.awt.Point; import java.awt.Toolkit; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.io.IOException; +import java.net.URI; import java.net.URL; import java.util.ArrayList; import java.util.List; @@ -21,7 +24,7 @@ class AdCanvas extends Canvas implements MouseListener { private LoadingPanel loadingPanel; private URL anURL117; private List texts; - private URL anURL119; + private URI uri; private String aString120; private int anInt121; private Image anImage122; @@ -30,11 +33,11 @@ class AdCanvas extends Canvas implements MouseListener { private boolean aBoolean125; private long aLong126; - private AdCanvas(AApplet var1, URL var2, List var3, URL var4, String var5, int var6) { + private AdCanvas(AApplet var1, URL var2, List var3, URI var4, String var5, int var6) { this.gameApplet = var1; this.anURL117 = var2; this.texts = var3; - this.anURL119 = var4; + this.uri = var4; this.aString120 = var5; this.anInt121 = var6; this.aLong124 = 0L; @@ -59,10 +62,8 @@ public void update(Graphics var1) { } var1.drawImage(this.anImage122, 0, 0, null); - int var5 = this.texts.size(); - for (int var6 = 0; var6 < var5; ++var6) { - AdCanvasText var4 = this.texts.get(var6); + for (AdCanvasText var4 : this.texts) { var4.method1548(var1); } } else { @@ -81,7 +82,10 @@ public void mouseEntered(MouseEvent var1) {} public void mouseExited(MouseEvent var1) {} public void mousePressed(MouseEvent var1) { - this.gameApplet.getAppletContext().showDocument(this.anURL119, this.aString120); + try { + Desktop.getDesktop().browse(this.uri); + } catch (IOException e) { + } } public void mouseReleased(MouseEvent var1) {} @@ -91,7 +95,7 @@ public void mouseClicked(MouseEvent var1) {} protected static AdCanvas create(AApplet applet, Parameters parameters) { try { String var2 = parameters.getParameter("ad_image"); - URL var3 = new URL(applet.getCodeBase(), var2); + URL var3 = new URL(new URL(parameters.getServerIp()), var2); List var4 = new ArrayList<>(); String var6; @@ -103,7 +107,7 @@ protected static AdCanvas create(AApplet applet, Parameters parameters) { } String var14 = parameters.getParameter("ad_page"); - URL var8 = var14 != null ? new URL(var14) : null; + URI uri = var14 != null ? new URI(var14) : null; String var9 = parameters.getParameter("ad_target"); if (var9 == null) { var9 = linkTarget; @@ -115,8 +119,7 @@ protected static AdCanvas create(AApplet applet, Parameters parameters) { var10 = Integer.parseInt(var11); } - AdCanvas var12 = new AdCanvas(applet, var3, var4, var8, var9, var10); - return var12; + return new AdCanvas(applet, var3, var4, uri, var9, var10); } catch (Exception var13) { return null; } @@ -144,7 +147,7 @@ protected boolean method213() { this.setSize(20, 20); } - if (this.anURL119 != null) { + if (this.uri != null) { this.addMouseListener(this); this.setCursor(new Cursor(Cursor.HAND_CURSOR)); } @@ -171,7 +174,7 @@ protected int method215() { } protected boolean method216() { - if (this.anURL119 == null) { + if (this.uri == null) { return false; } else { String var1 = this.aString120.toLowerCase(); @@ -187,7 +190,8 @@ protected void method217() { this.anImage122 = null; } - this.anURL117 = this.anURL119 = null; + this.anURL117 = null; + this.uri = null; this.aString120 = null; this.loadingPanel = null; this.gameApplet = null; diff --git a/client/src/main/java/com/aapeli/applet/AdCanvasText.java b/client/src/main/java/com/aapeli/applet/AdCanvasText.java index 0c14cb61..bb207838 100644 --- a/client/src/main/java/com/aapeli/applet/AdCanvasText.java +++ b/client/src/main/java/com/aapeli/applet/AdCanvasText.java @@ -47,8 +47,7 @@ protected static AdCanvasText method1547(String var0) { Color var9 = hex2Color(var3.nextToken(), true); int var10 = Integer.parseInt(var3.nextToken()); boolean var11 = var3.nextToken().equalsIgnoreCase("bold"); - AdCanvasText var12 = new AdCanvasText(var4, var5, var6, var7, var8, var9, var10, var11, var2); - return var12; + return new AdCanvasText(var4, var5, var6, var7, var8, var9, var10, var11, var2); } catch (Exception var13) { return null; } @@ -80,12 +79,11 @@ private static Color hex2Color(String hex, boolean noThrow) throws Exception { hex = hex.substring(2); } - int var2 = Integer.parseInt(hex, 16); - if (var2 < 0) { + int rgb = Integer.parseInt(hex, 16); + if (rgb < 0) { throw new Exception(); } else { - Color var3 = new Color(var2); - return var3; + return new Color(rgb); } } catch (Exception var4) { if (!noThrow) { diff --git a/client/src/main/java/com/aapeli/applet/LoadingPanel.java b/client/src/main/java/com/aapeli/applet/LoadingPanel.java index bbf2029f..f3f48f3c 100644 --- a/client/src/main/java/com/aapeli/applet/LoadingPanel.java +++ b/client/src/main/java/com/aapeli/applet/LoadingPanel.java @@ -319,7 +319,7 @@ private void drawGradient( int var10, int var11) { for (int var17 = var2; var17 < var3; ++var17) { - double var12 = 1.0D * (double) (var17 - var2) / (double) (var3 - var2); + double var12 = (double) (var17 - var2) / (double) (var3 - var2); int var14 = (int) ((double) var6 + (double) (var7 - var6) * var12); int var15 = (int) ((double) var8 + (double) (var9 - var8) * var12); int var16 = (int) ((double) var10 + (double) (var11 - var10) * var12); @@ -343,7 +343,7 @@ private void drawGradient2( int var20 = -1; for (int var21 = var2; var21 < var3; ++var21) { - double var12 = 1.0D * (double) (var21 - var2) / (double) (var3 - var2); + double var12 = (double) (var21 - var2) / (double) (var3 - var2); for (int var22 = var4; var22 < var5; ++var22) { double var14; diff --git a/client/src/main/java/com/aapeli/client/AutoPopups.java b/client/src/main/java/com/aapeli/client/AutoPopups.java index 42b7fc03..1e5b3550 100644 --- a/client/src/main/java/com/aapeli/client/AutoPopups.java +++ b/client/src/main/java/com/aapeli/client/AutoPopups.java @@ -8,7 +8,6 @@ public class AutoPopups { private SignUpHandler signUpHandler; private TellFriendHandler tellFriendHandler; private long aLong1330; - private static final String aString1331 = "facebook"; public AutoPopups(AApplet var1) { if (!var1.param.getSiteName().equalsIgnoreCase("facebook")) { diff --git a/client/src/main/java/com/aapeli/client/FileUtil.java b/client/src/main/java/com/aapeli/client/FileUtil.java deleted file mode 100644 index 417df4cf..00000000 --- a/client/src/main/java/com/aapeli/client/FileUtil.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.aapeli.client; - -import java.net.URL; - -class FileUtil { - - protected static final String RESOURCE_DIR = "/Shared/Client/src/"; - protected static final String LANGUAGE_DIR = "/L10N/"; - - protected static final boolean isFileUrl(URL url) { - return url.getProtocol().equalsIgnoreCase("file") ? url.toString().indexOf("fs01") <= 0 : false; - } -} diff --git a/client/src/main/java/com/aapeli/client/HtmlLine.java b/client/src/main/java/com/aapeli/client/HtmlLine.java index 967eff0e..42b9555a 100644 --- a/client/src/main/java/com/aapeli/client/HtmlLine.java +++ b/client/src/main/java/com/aapeli/client/HtmlLine.java @@ -12,10 +12,8 @@ class HtmlLine { private List words; private int nextWordStart; private int height; - private final HtmlText aHtmlText1371; - protected HtmlLine(HtmlText htmlText, Graphics graphics, int var3, boolean var4) { - this.aHtmlText1371 = htmlText; + protected HtmlLine(Graphics graphics, int var3, boolean var4) { this.anInt1366 = var3; this.aBoolean1367 = var4; this.words = new ArrayList<>(); @@ -41,7 +39,7 @@ protected boolean method1604(int var1) { protected void addWord(String text, Font font, int length) { if (!this.isEmpty() || text.trim().length() != 0) { - HtmlWord word = new HtmlWord(this, text, font, this.nextWordStart, length); + HtmlWord word = new HtmlWord(text, font, this.nextWordStart, length); this.words.add(word); this.nextWordStart += length; int fontSize = font.getSize(); diff --git a/client/src/main/java/com/aapeli/client/HtmlParser.java b/client/src/main/java/com/aapeli/client/HtmlParser.java index 2cc7dd3f..cd78e31e 100644 --- a/client/src/main/java/com/aapeli/client/HtmlParser.java +++ b/client/src/main/java/com/aapeli/client/HtmlParser.java @@ -7,10 +7,8 @@ class HtmlParser { private String rawText; private Graphics graphics; - private final HtmlText htmlText; - protected HtmlParser(HtmlText htmlText, String rawText, Graphics graphics) { - this.htmlText = htmlText; + protected HtmlParser(String rawText, Graphics graphics) { this.rawText = rawText.trim(); this.graphics = graphics; } diff --git a/client/src/main/java/com/aapeli/client/HtmlText.java b/client/src/main/java/com/aapeli/client/HtmlText.java index 99a251eb..7fcfb41c 100644 --- a/client/src/main/java/com/aapeli/client/HtmlText.java +++ b/client/src/main/java/com/aapeli/client/HtmlText.java @@ -42,30 +42,35 @@ public int print(Graphics var1, int var2, int var3) { } private List createLines(Graphics g, int var2, String text) { - HtmlParser parser = new HtmlParser(this, text, g); + HtmlParser parser = new HtmlParser(text, g); List lines = new ArrayList<>(); boolean var6 = false; - HtmlLine line = new HtmlLine(this, g, var2, var6); + HtmlLine line = new HtmlLine(g, var2, var6); String word; while ((word = parser.getNextWord()) != null) { - if (word.equals("
")) { - lines.add(line); - line = new HtmlLine(this, g, var2, var6); - } else if (word.equals("
")) { - var6 = true; - line = this.method1590(line, lines, g, var2, var6); - } else if (word.equals("
")) { - var6 = false; - line = this.method1590(line, lines, g, var2, var6); - } else { - int var9 = g.getFontMetrics().stringWidth(word); - if (!line.method1604(var9)) { + switch (word) { + case "
" -> { lines.add(line); - line = new HtmlLine(this, g, var2, var6); + line = new HtmlLine(g, var2, var6); + } + case "
" -> { + var6 = true; + line = this.method1590(line, lines, g, var2, var6); + } + case "
" -> { + var6 = false; + line = this.method1590(line, lines, g, var2, var6); + } + default -> { + int var9 = g.getFontMetrics().stringWidth(word); + if (!line.method1604(var9)) { + lines.add(line); + line = new HtmlLine(g, var2, var6); + } + + line.addWord(word, g.getFont(), var9); } - - line.addWord(word, g.getFont(), var9); } } @@ -75,7 +80,7 @@ private List createLines(Graphics g, int var2, String text) { private HtmlLine method1590(HtmlLine var1, List var2, Graphics var3, int var4, boolean var5) { this.method1591(var1, var2); - return new HtmlLine(this, var3, var4, var5); + return new HtmlLine(var3, var4, var5); } private void method1591(HtmlLine var1, List var2) { diff --git a/client/src/main/java/com/aapeli/client/HtmlWord.java b/client/src/main/java/com/aapeli/client/HtmlWord.java index baf62956..bc702e1e 100644 --- a/client/src/main/java/com/aapeli/client/HtmlWord.java +++ b/client/src/main/java/com/aapeli/client/HtmlWord.java @@ -9,10 +9,8 @@ class HtmlWord { private Font font; private int start; private int length; - private final HtmlLine htmlLine; - protected HtmlWord(HtmlLine htmlLine, String word, Font font, int start, int length) { - this.htmlLine = htmlLine; + protected HtmlWord(String word, Font font, int start, int length) { this.word = word; this.font = font; this.start = start; diff --git a/client/src/main/java/com/aapeli/client/ImageManager.java b/client/src/main/java/com/aapeli/client/ImageManager.java index 1f519f54..8d6611d0 100644 --- a/client/src/main/java/com/aapeli/client/ImageManager.java +++ b/client/src/main/java/com/aapeli/client/ImageManager.java @@ -152,8 +152,6 @@ public Image[][] separateImages(Image image, int length, int rows) { return images; } - public void destroy() {} - private String removeExtension(String fileName) { return fileName.substring(0, fileName.lastIndexOf('.')); } diff --git a/client/src/main/java/com/aapeli/client/Parameters.java b/client/src/main/java/com/aapeli/client/Parameters.java index e02feb82..835d940c 100644 --- a/client/src/main/java/com/aapeli/client/Parameters.java +++ b/client/src/main/java/com/aapeli/client/Parameters.java @@ -1,11 +1,12 @@ package com.aapeli.client; -import com.aapeli.applet.AApplet; import com.aapeli.tools.Tools; -import java.applet.Applet; -import java.applet.AppletContext; -import java.net.MalformedURLException; -import java.net.URL; +import java.awt.Component; +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Map; import org.moparforia.shared.Locale; public final class Parameters { @@ -14,10 +15,7 @@ public final class Parameters { private static final String PLAYFORIA_SITE_NAME = "playforia"; private static final String PLAYFORIA_QUIT_PAGE = "http://www.playforia.com/"; private static final String QUIT_TARGET = "_top"; - private Applet applet; - private AApplet aApplet; - private String codeBaseHost; - private String documentBaseHost; + private Component rootComponent; private String serverIp; private Locale locale; private String siteName; @@ -33,25 +31,23 @@ public final class Parameters { private String json; private boolean tellFriend; private int serverPort; - private URL urlCreditPage; + private URI uriCreditPage; private int anInt1455; private String[] aStringArray1456; private String aString1457; private boolean debug; + private Map params; - public Parameters(Applet applet, boolean debug) { - this.applet = applet; - if (applet instanceof AApplet) { - this.aApplet = (AApplet) applet; - } - - this.codeBaseHost = applet.getCodeBase().getHost().toLowerCase(); - this.documentBaseHost = applet.getDocumentBase().getHost().toLowerCase(); + public Parameters(Map params) { + this.params = params; this.anInt1455 = 0; - this.debug = debug; this.init(); } + public void setRootComponent(Component rootComponent) { + this.rootComponent = rootComponent; + } + public static boolean getBooleanValue(String key) { if (key == null) { return false; @@ -66,13 +62,13 @@ public static boolean getBooleanValue(String key) { } public String getParameter(String key) { - String value = this.applet.getParameter(key); + String value = this.params.get(key); if (value == null) { - value = this.applet.getParameter(key.toLowerCase()); + value = this.params.get(key.toLowerCase()); } if (value == null) { - value = this.applet.getParameter(key.toUpperCase()); + value = this.params.get(key.toUpperCase()); } if (value == null) { @@ -135,17 +131,17 @@ public boolean showPlayerCard(String var1) { return false; } - this.showUrl(this.toURL(this.urlUserInfoPage + var1), this.urlTargetUserInfo); + this.showUri(this.toURI(this.urlUserInfoPage + var1), this.urlTargetUserInfo); return true; } if (var2.startsWith("javascript:")) { - URL var3 = this.toURL(Tools.replaceFirst(this.urlUserInfoPage, "%n", var1)); - if (var3 == null) { + URI uri = this.toURI(Tools.replaceFirst(this.urlUserInfoPage, "%n", var1)); + if (uri == null) { return false; } - this.showUrl(var3, this.urlTargetUserInfo); + this.showUri(uri, this.urlTargetUserInfo); return true; } } catch (Exception e) { @@ -240,15 +236,15 @@ public void removePlayerList() { } public boolean showRegisterPage() { - return this.showUrl(this.toURL(this.urlRegisterPage), null); + return this.showUri(this.toURI(this.urlRegisterPage), null); } public void showCreditPurchasePage(boolean openInNewTab) { - this.showUrl(this.urlCreditPage, openInNewTab ? "_blank" : null); + this.showUri(this.uriCreditPage, openInNewTab ? "_blank" : null); } public boolean isCreditPurchasePageAvailable() { - return this.urlCreditPage != null; + return this.uriCreditPage != null; } public boolean callJavaScriptJSON(String json) { @@ -262,11 +258,11 @@ public boolean callJavaScriptJSON(String json) { try { json = Tools.replaceAll(json, "'", "\\'"); String var2 = Tools.replaceFirst(this.json, "%o", "'" + json + "'"); - URL var3 = this.toURL(var2); - if (var3 == null) { + URI uri = this.toURI(var2); + if (uri == null) { return false; } else { - this.showUrl(var3, null); + this.showUri(uri, null); return true; } } catch (Exception e) { @@ -275,12 +271,8 @@ public boolean callJavaScriptJSON(String json) { } } - public Applet getApplet() { - return this.applet; - } - - public AApplet getAApplet() { - return this.aApplet; + public Component getRootComponent() { + return this.rootComponent; } public void destroy() { @@ -296,15 +288,9 @@ public void destroy() { this.urlTellFriendPage = null; this.urlTargetTellFriend = null; this.json = null; - this.urlCreditPage = null; + this.uriCreditPage = null; this.aStringArray1456 = null; this.aString1457 = null; - this.documentBaseHost = null; - this.codeBaseHost = null; - } - - protected AppletContext getAppletContext() { - return this.applet.getAppletContext(); } protected boolean getTellFriend() { @@ -326,7 +312,7 @@ private void init() { this.siteName = this.getParamSiteName(); this.session = this.getParameter("session"); this.urlRegisterPage = this.getParameter("registerpage"); - this.urlCreditPage = this.toURL(this.getParameter("creditpage")); + this.uriCreditPage = this.toURI(this.getParameter("creditpage")); this.urlUserInfoPage = this.getParameter("userinfopage"); this.urlTargetUserInfo = this.getParameter("userinfotarget"); this.urlUserListPage = this.getParameter("userlistpage"); @@ -336,6 +322,7 @@ private void init() { this.urlTargetTellFriend = this.getParameter("tellfriendtarget"); this.json = this.getParameter("json"); this.username = this.getParameter("username"); + this.debug = Tools.getBoolean(this.getParameter("verbose")); if (this.json != null) { this.json = Tools.replaceFirst(this.json, "'%o'", "%o"); if (!this.json.toLowerCase().startsWith("javascript:")) { @@ -350,7 +337,7 @@ private String getParamServer() { int portIndex = server.lastIndexOf(':'); return server.substring(0, portIndex); } catch (Exception e) { - return this.codeBaseHost.length() > 0 ? this.codeBaseHost : LOCALHOST; + return LOCALHOST; } } @@ -382,28 +369,17 @@ private Locale getParamLocale() { } private String getParamSiteName() { - try { - String siteName = this.getParameter("sitename"); - if (siteName != null) { - return siteName; - } - } catch (Exception e) { - } - - if (this.documentBaseHost.contains("aapeli.")) { - return "aapeli"; - } else if (this.documentBaseHost.contains("playforia.")) { - return PLAYFORIA_SITE_NAME; - } else if (this.documentBaseHost.contains("playray.")) { - return "playray"; + String siteName = this.getParameter("sitename"); + if (siteName != null) { + return siteName; } return PLAYFORIA_SITE_NAME; } - private URL toURL(String s) { + private URI toURI(String s) { try { - return new URL(s); - } catch (MalformedURLException e) { + return new URI(s); + } catch (URISyntaxException e) { return null; } } @@ -448,19 +424,19 @@ private void showPlayerList(String[] nicks, boolean[] winners, String subgame) { } } - this.showUrl(this.toURL(var8), this.urlTargetUserList); + this.showUri(this.toURI(var8), this.urlTargetUserList); } } else { if (var4.startsWith("javascript:")) { var8 = this.urlUserListPage; var8 = Tools.replaceFirst(var8, "%n", result != null ? result : ""); var8 = Tools.replaceFirst(var8, "%s", subgame != null ? subgame : ""); - URL var9 = this.toURL(var8); - if (var9 == null) { + URI uri = this.toURI(var8); + if (uri == null) { return; } - this.showUrl(var9, this.urlTargetUserList); + this.showUri(uri, this.urlTargetUserList); } } } @@ -513,17 +489,15 @@ private boolean method1675(String[] var1, String var2) { } } - private boolean showUrl(URL url, String target) { - if (url == null) { + private boolean showUri(URI uri, String target) { + if (uri == null) { return false; } else { - AppletContext appletContext = this.applet.getAppletContext(); - if (target != null) { - appletContext.showDocument(url, target); - } else { - appletContext.showDocument(url); + try { + Desktop.getDesktop().browse(uri); + } catch (IOException e) { + return false; } - return true; } } diff --git a/client/src/main/java/com/aapeli/client/SoundManager.java b/client/src/main/java/com/aapeli/client/SoundManager.java index cffe1dff..f971fa63 100644 --- a/client/src/main/java/com/aapeli/client/SoundManager.java +++ b/client/src/main/java/com/aapeli/client/SoundManager.java @@ -6,20 +6,11 @@ public final class SoundManager implements Runnable { private static final String[] methodLookup = {"stop", "play", "loop"}; private final boolean debug; - private boolean startupDebug; private Hashtable clientSounds; private Hashtable sharedSounds; private boolean clipLoaderThreadRunning; public int audioChoicerIndex; - public SoundManager() { - this(true, false); - } - - public SoundManager(boolean debug) { - this(true, debug); - } - public SoundManager(boolean shouldLoadClips, boolean debug) { this.debug = debug; this.audioChoicerIndex = 0; @@ -151,10 +142,6 @@ public void destroy() { this.clientSounds = null; } - public void enableSUD() { - this.startupDebug = true; - } - protected boolean isDebug() { return this.debug; } diff --git a/client/src/main/java/com/aapeli/client/TellFriendHandler.java b/client/src/main/java/com/aapeli/client/TellFriendHandler.java index 2df7f035..5846eade 100644 --- a/client/src/main/java/com/aapeli/client/TellFriendHandler.java +++ b/client/src/main/java/com/aapeli/client/TellFriendHandler.java @@ -2,9 +2,10 @@ import com.aapeli.colorgui.ColorButton; import java.awt.Color; +import java.awt.Desktop; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.net.URL; +import java.net.URI; import java.security.MessageDigest; class TellFriendHandler implements ActionListener { @@ -29,9 +30,7 @@ protected TellFriendHandler(Parameters var1, TextManager var2, ImageManager var3 try { this.aMessageDigest1503 = MessageDigest.getInstance("MD5"); - } catch (Exception var5) { - this.anInt1506 = 0; - } catch (Error var6) { + } catch (Exception | Error e) { this.anInt1506 = 0; } @@ -121,11 +120,10 @@ protected boolean method1702(String[] var1, String var2, int var3, int var4, int } var10 = var10 + "hash=" + var9; - URL var14 = new URL(this.aString1504 + "?" + var10); - this.aParameters1500.getAppletContext().showDocument(var14, this.aString1505); + URI uri = new URI(this.aString1504 + "?" + var10); + Desktop.getDesktop().browse(uri); return true; - } catch (Exception var12) { - } catch (Error var13) { + } catch (Exception | Error e) { } return false; @@ -137,7 +135,7 @@ protected void method1703() { private void method1704() { this.tellFriendWindow = new TellFriendWindow(this.aTextManager1501, this.anImageManager1502, this); - this.tellFriendWindow.method241(this.aParameters1500.getApplet()); + this.tellFriendWindow.method241(this.aParameters1500.getRootComponent()); this.anInt1506 = 2; } diff --git a/client/src/main/java/com/aapeli/client/TellFriendWindow.java b/client/src/main/java/com/aapeli/client/TellFriendWindow.java index 3063adc2..ed315795 100644 --- a/client/src/main/java/com/aapeli/client/TellFriendWindow.java +++ b/client/src/main/java/com/aapeli/client/TellFriendWindow.java @@ -6,7 +6,6 @@ class TellFriendWindow extends PopupWindow { private TellFriendHandler tellFriendHandler; private TellFriendPanel tellFriendPanel; - private static final String aString2892 = "TellFriend_Title"; protected TellFriendWindow(TextManager var1, ImageManager var2, TellFriendHandler var3) { super(var1); diff --git a/client/src/main/java/com/aapeli/client/TextManager.java b/client/src/main/java/com/aapeli/client/TextManager.java index 2c8026c7..16c82cac 100644 --- a/client/src/main/java/com/aapeli/client/TextManager.java +++ b/client/src/main/java/com/aapeli/client/TextManager.java @@ -232,8 +232,7 @@ public String getClock(long var1, boolean var3) { public String getCurrentDateAndClock(boolean var1) { long var2 = System.currentTimeMillis(); - String var4 = this.getDate(var2, var1) + " " + this.getClock(var2, var1); - return var4; + return this.getDate(var2, var1) + " " + this.getClock(var2, var1); } public String getDateWithTodayYesterday(long timestamp) { diff --git a/client/src/main/java/com/aapeli/client/UrlLabel.java b/client/src/main/java/com/aapeli/client/UrlLabel.java index a477b9c0..631d0acf 100644 --- a/client/src/main/java/com/aapeli/client/UrlLabel.java +++ b/client/src/main/java/com/aapeli/client/UrlLabel.java @@ -1,8 +1,8 @@ package com.aapeli.client; -import java.applet.Applet; import java.awt.Color; import java.awt.Cursor; +import java.awt.Desktop; import java.awt.Dimension; import java.awt.Font; import java.awt.FontMetrics; @@ -10,8 +10,9 @@ import java.awt.Image; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import java.net.MalformedURLException; -import java.net.URL; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; public class UrlLabel extends IPanel implements MouseListener { @@ -24,9 +25,8 @@ public class UrlLabel extends IPanel implements MouseListener { private static final Cursor defaultCursor = new Cursor(Cursor.DEFAULT_CURSOR); private static final Cursor handCursor = new Cursor(Cursor.HAND_CURSOR); private static final Font fontDialog11 = new Font("Dialog", Font.PLAIN, 11); - private Applet applet; private Font currentFont; - private URL url; + private URI uri; private String text; private String linkPlaceholderText; private String suffix; @@ -41,31 +41,20 @@ public class UrlLabel extends IPanel implements MouseListener { private int backgroundImageOffsetX; private int backgroundImageOffsetY; private String urlTarget; - private static final String aString3247 = "Dialog"; - public UrlLabel(Applet applet) { - this(applet, fontDialog11, null, null); + public UrlLabel() { + this(fontDialog11, null, null); } - public UrlLabel(Applet applet, String var2, String var3) { - this(applet, fontDialog11, var2, var3); - } - - public UrlLabel(Applet applet, Font font, String var3, String var4) { - this.applet = applet; + public UrlLabel(Font font, String text, String url) { this.backgroundColor = null; this.foregroundMainColor = Color.black; this.foregroundSecondaryColor = Color.blue; this.backgroundImage = null; - this.alignment = -1; + this.alignment = ALIGN_LEFT; this.urlTarget = "_blank"; this.currentFont = font; - this.setText(var3, var4); - } - - public UrlLabel(Applet applet, String var2, String var3, int width, int height) { - this(applet, fontDialog11, var2, var3); - this.setSize(width, height); + this.setText(text, url); } public void update(Graphics graphics) { @@ -92,64 +81,67 @@ public void update(Graphics graphics) { 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; + int textHeight = height / 2 + fontSize * 3 / 8; + int y = height / 2 + fontSize / 2; if (this.alignment == 0) { x = width / 2 - this.textWidth / 2; } - if (this.alignment == 1) { + if (this.alignment == ALIGN_RIGHT) { x = width - 2 - this.textWidth; } if (this.linkPlaceholderText != null && this.suffix != null) { graphics.setColor(this.foregroundSecondaryColor); - graphics.drawLine(x + this.prefixWidth, var8, x + this.prefixWidth + this.linkTextWidth, var8); + graphics.drawLine(x + this.prefixWidth, y, x + this.prefixWidth + this.linkTextWidth, y); } graphics.setFont(this.currentFont); graphics.setColor(this.foregroundMainColor); - graphics.drawString(this.text, x, y); + graphics.drawString(this.text, x, textHeight); if (this.linkPlaceholderText != null && this.suffix != null) { graphics.setColor(this.foregroundSecondaryColor); - graphics.drawString(this.linkPlaceholderText, x + this.prefixWidth, y); + graphics.drawString(this.linkPlaceholderText, x + this.prefixWidth, textHeight); graphics.setColor(this.foregroundMainColor); - graphics.drawString(this.suffix, x + this.prefixWidth + this.linkTextWidth, y); + graphics.drawString(this.suffix, x + this.prefixWidth + this.linkTextWidth, textHeight); } } } - public void mouseEntered(MouseEvent var1) {} + public void mouseEntered(MouseEvent e) {} - public void mouseExited(MouseEvent var1) {} + public void mouseExited(MouseEvent e) {} - public void mousePressed(MouseEvent var1) {} + public void mousePressed(MouseEvent e) {} - public void mouseReleased(MouseEvent var1) { - this.applet.getAppletContext().showDocument(this.url, this.urlTarget); + public void mouseReleased(MouseEvent e) { + try { + Desktop.getDesktop().browse(this.uri); + } catch (IOException ex) { + } } - public void mouseClicked(MouseEvent var1) {} + public void mouseClicked(MouseEvent e) {} public void setText(String text, String url) { if (text == null) { this.text = this.linkPlaceholderText = this.suffix = null; - this.url = null; + this.uri = null; this.setCursor(defaultCursor); this.repaint(); } else { - this.url = null; + this.uri = null; if (url != null) { try { - this.url = new URL(url); - } catch (MalformedURLException e) { + this.uri = new URI(url); + } catch (URISyntaxException e) { } } - FontMetrics fontMetrics = this.applet.getFontMetrics(this.currentFont); + FontMetrics fontMetrics = this.getFontMetrics(this.currentFont); int linkTextStart = text.indexOf('<'); int linkTextEnd = text.indexOf('>'); - if (this.url != null && linkTextStart != -1 && linkTextEnd >= linkTextStart) { + if (this.uri != null && linkTextStart != -1 && linkTextEnd >= linkTextStart) { this.text = text.substring(0, linkTextStart); this.linkPlaceholderText = text.substring(linkTextStart + 1, linkTextEnd); this.suffix = text.substring(linkTextEnd + 1); @@ -185,9 +177,9 @@ public void setForeground(Color color) { } } - public void setForeground(Color var1, Color var2) { - this.foregroundMainColor = var1; - this.foregroundSecondaryColor = var2; + public void setForeground(Color mainColor, Color secondaryColor) { + this.foregroundMainColor = mainColor; + this.foregroundSecondaryColor = secondaryColor; this.repaint(); } @@ -210,82 +202,4 @@ public void setTarget(int i) { public void setTarget(String target) { this.urlTarget = target; } - - private static char[] method822(String var0) { - char[] var10000 = var0.toCharArray(); - char[] var10001 = var10000; - - while (true) { - int var10002 = var10001.length; - var10001 = var10000; - int var4 = var10002; - if (var10002 >= 2) { - break; - } - - char[] var1 = var10001; - int var2 = var4; - var10000 = var1; - char[] var10003 = var1; - var10002 = var2; - var10001 = var10003; - if (var10002 != 0) { - var10001 = var10000; - boolean var3 = false; - var10003[0] = (char) (var10003[0] ^ 54); - break; - } - } - - return var10001; - } - - private static String method823(char[] var0) { - int var10000 = var0.length; - int var1 = 0; - char[] var10001 = var0; - if (var10000 > 1) { - var10001 = var0; - if (var10000 <= var1) { - return (new String(var0)).intern(); - } - } - - do { - char[] var10002 = var10001; - int var10003 = var1; - - while (true) { - char var10004 = var10002[var10003]; - byte var10005; - switch (var1 % 5) { - case 0: - var10005 = 41; - break; - case 1: - var10005 = 61; - break; - case 2: - var10005 = 79; - break; - case 3: - var10005 = 79; - break; - default: - var10005 = 54; - } - - var10002[var10003] = (char) (var10004 ^ var10005); - ++var1; - if (var10000 != 0) { - break; - } - - var10003 = var10000; - var10002 = var10001; - } - } while (var10000 > var1); - - return (new String(var10001)).intern(); - } } diff --git a/client/src/main/java/com/aapeli/colorgui/BlinkingButtonThread.java b/client/src/main/java/com/aapeli/colorgui/BlinkingButtonThread.java index 781b2925..5b46a594 100644 --- a/client/src/main/java/com/aapeli/colorgui/BlinkingButtonThread.java +++ b/client/src/main/java/com/aapeli/colorgui/BlinkingButtonThread.java @@ -6,10 +6,8 @@ class BlinkingButtonThread implements Runnable { private ColorButton button; private boolean enabled; - private final ColorButton _button; - protected BlinkingButtonThread(ColorButton _button, ColorButton button) { - this._button = _button; + protected BlinkingButtonThread(ColorButton button) { this.button = button; this.enabled = true; } diff --git a/client/src/main/java/com/aapeli/colorgui/Choicer.java b/client/src/main/java/com/aapeli/colorgui/Choicer.java index 30fc9575..5c1333ed 100644 --- a/client/src/main/java/com/aapeli/colorgui/Choicer.java +++ b/client/src/main/java/com/aapeli/colorgui/Choicer.java @@ -18,7 +18,7 @@ public class Choicer extends IPanel implements ComponentListener, ItemListener, private ColorSpinner colorSpinner; private boolean choiceMode = true; private List listeners; - private Object synchronizationObject = new Object(); + private Object lock = new Object(); public Choicer() { this.choice.setBackground(Color.white); @@ -38,8 +38,7 @@ public void componentShown(ComponentEvent e) {} public void componentMoved(ComponentEvent e) {} public void componentResized(ComponentEvent e) { - Object synchronizationObject = this.synchronizationObject; - synchronized (this.synchronizationObject) { + synchronized (this.lock) { Dimension size = this.getSize(); if (this.choiceMode) { this.choice.setSize(size); @@ -61,15 +60,13 @@ public void itemStateChanged(ItemEvent e) { } public Object[] getSelectedObjects() { - Object synchronizationObject = this.synchronizationObject; - synchronized (this.synchronizationObject) { + synchronized (this.lock) { return this.choiceMode ? this.choice.getSelectedObjects() : this.colorSpinner.getSelectedObjects(); } } public void setBackground(Color color) { - Object synchronizationObject = this.synchronizationObject; - synchronized (this.synchronizationObject) { + synchronized (this.lock) { super.setBackground(color); if (this.choiceMode) { this.choice.setBackground(color); @@ -80,8 +77,7 @@ public void setBackground(Color color) { } public void setForeground(Color color) { - Object synchronizationObject = this.synchronizationObject; - synchronized (this.synchronizationObject) { + synchronized (this.lock) { super.setForeground(color); if (this.choiceMode) { this.choice.setForeground(color); @@ -92,8 +88,7 @@ public void setForeground(Color color) { } public void addItem(String text) { - Object synchronizationObject = this.synchronizationObject; - synchronized (this.synchronizationObject) { + synchronized (this.lock) { if (this.choiceMode) { this.moveToSpinnerIfNecessary(text); } @@ -107,8 +102,7 @@ public void addItem(String text) { } public void removeItem(int i) { - Object synchronizationObject = this.synchronizationObject; - synchronized (this.synchronizationObject) { + synchronized (this.lock) { if (this.choiceMode) { this.choice.remove(i); } else { @@ -118,15 +112,13 @@ public void removeItem(int i) { } public int getItemCount() { - Object synchronizationObject = this.synchronizationObject; - synchronized (this.synchronizationObject) { + synchronized (this.lock) { return this.choiceMode ? this.choice.getItemCount() : this.colorSpinner.getItemCount(); } } public int getSelectedIndex() { - Object synchronizationObject = this.synchronizationObject; - synchronized (this.synchronizationObject) { + synchronized (this.lock) { return this.choiceMode ? this.choice.getSelectedIndex() : this.colorSpinner.getSelectedIndex(); } } @@ -136,8 +128,7 @@ public void select(int i) { } public void setSelectedIndex(int i) { - Object synchronizationObject = this.synchronizationObject; - synchronized (this.synchronizationObject) { + synchronized (this.lock) { if (this.choiceMode) { this.choice.select(i); } else { @@ -159,8 +150,7 @@ public void removeItemListener(ItemListener var1) { } public void moveToSpinner() { - Object synchronizationObject = this.synchronizationObject; - synchronized (this.synchronizationObject) { + synchronized (this.lock) { if (this.choiceMode) { this.colorSpinner = new ColorSpinner(); this.colorSpinner.setLocation(0, 0); diff --git a/client/src/main/java/com/aapeli/colorgui/ColorButton.java b/client/src/main/java/com/aapeli/colorgui/ColorButton.java index 2d8fd08d..62de71bb 100644 --- a/client/src/main/java/com/aapeli/colorgui/ColorButton.java +++ b/client/src/main/java/com/aapeli/colorgui/ColorButton.java @@ -53,7 +53,6 @@ public class ColorButton extends IPanel implements MouseMotionListener, MouseLis private int height; private BlinkingButtonThread blinkingThread; private boolean blinkState; - public static boolean aBoolean3287; public ColorButton() { this(null); @@ -91,13 +90,11 @@ public void update(Graphics g) { if (this.image == null || width != this.width || height != this.height) { this.image = this.createBuffer(width, height); this.graphics = this.image.getGraphics(); - this.graphicsCreated(this.graphics); this.width = width; this.height = height; } this.drawBackground(this.graphics); - this.baseBackgroundDrawn(this.graphics); boolean highlighted = this.isHighlighted(); if (this.backgroundImage != null && this.highlightedBackgroundImage != null) { Image backgroundImage = highlighted ? this.highlightedBackgroundImage : this.backgroundImage; @@ -384,7 +381,7 @@ public void setBlinking(boolean blinking) { return; } - this.blinkingThread = new BlinkingButtonThread(this, this); + this.blinkingThread = new BlinkingButtonThread(this); Thread thread = new Thread(this.blinkingThread); thread.setDaemon(true); thread.start(); @@ -404,10 +401,6 @@ public Image createBuffer(int width, int height) { return this.createImage(width, height); } - public void graphicsCreated(Graphics e) {} - - public void baseBackgroundDrawn(Graphics e) {} - public boolean isNormalState() { return !this.mousePressed; } diff --git a/client/src/main/java/com/aapeli/colorgui/ColorCheckbox.java b/client/src/main/java/com/aapeli/colorgui/ColorCheckbox.java index c8a79a06..62ebe014 100644 --- a/client/src/main/java/com/aapeli/colorgui/ColorCheckbox.java +++ b/client/src/main/java/com/aapeli/colorgui/ColorCheckbox.java @@ -19,167 +19,189 @@ public class ColorCheckbox extends IPanel implements ItemSelectable, MouseListen public static final int ALIGN_LEFT = -1; public static final int ALIGN_CENTER = 0; public static final int ALIGN_RIGHT = 1; - private static final Color aColor3289 = new Color(248, 248, 248); - private static final Color aColor3290 = Color.black; - private Font aFont3291; - private Color aColor3292; - private Color aColor3293; - private Color aColor3294; - private Color aColor3295; - private Color aColor3296; - private Image anImage3297; - private int anInt3298; - private int anInt3299; - private String aString3300; - private int anInt3301; - private boolean aBoolean3302; - private boolean aBoolean3303; - private ColorCheckboxGroup aColorCheckboxGroup3304; + private static final Color DEFAULT_BORDER_COLOR = new Color(248, 248, 248); + private static final Color CHECKMARK_COLOR = Color.black; + private Font font; + private Color foregroundColor; + private Color borderColor; + private Color checkmarkColor; + private Color borderColorLight; + private Color borderColorDark; + private Image backgroundImage; + private int backgroundImageOffsetX; + private int backgroundImageOffsetY; + private String text; + private int alignment; + private boolean checked; + private boolean pixelRoundedCorners; + private ColorCheckboxGroup checkboxGroup; private List listeners; - private Image anImage3306; - private Graphics aGraphics3307; - private int anInt3308; - private int anInt3309; + private Image image; + private Graphics graphics; + private int width; + private int height; - public ColorCheckbox() { - this(null, false); + public ColorCheckbox(String text) { + this(text, false); } - public ColorCheckbox(boolean var1) { - this(null, var1); - } - - public ColorCheckbox(String var1) { - this(var1, false); - } - - public ColorCheckbox(String var1, boolean var2) { - this.aString3300 = var1; - this.aBoolean3302 = var2; + public ColorCheckbox(String text, boolean checked) { + this.text = text; + this.checked = checked; this.listeners = new ArrayList<>(); - this.anInt3301 = -1; - this.aBoolean3303 = false; + this.alignment = -1; + this.pixelRoundedCorners = false; this.setFont(FontConstants.font); this.setForeground(FontConstants.black); - this.setBoxBackground(aColor3289); - this.setBoxForeground(aColor3290); + this.setBorderColor(DEFAULT_BORDER_COLOR); + this.setCheckmarkColor(CHECKMARK_COLOR); this.addMouseListener(this); - this.aColorCheckboxGroup3304 = null; - } - - public void update(Graphics var1) { - Dimension var2 = this.getSize(); - int var3 = var2.width; - int var4 = var2.height; - if (this.anImage3306 == null || var3 != this.anInt3308 || var4 != this.anInt3309) { - this.anImage3306 = this.createBuffer(var3, var4); - this.aGraphics3307 = this.getGraphics(this.anImage3306); - this.anInt3308 = var3; - this.anInt3309 = var4; + this.checkboxGroup = null; + } + + public void update(Graphics g) { + Dimension size = this.getSize(); + int totalWidth = size.width; + int totalHeight = size.height; + if (this.image == null || totalWidth != this.width || totalHeight != this.height) { + this.image = this.createBuffer(totalWidth, totalHeight); + this.graphics = this.getGraphics(this.image); + this.width = totalWidth; + this.height = totalHeight; } - if (this.anImage3297 != null) { - this.aGraphics3307.drawImage( - this.anImage3297, + if (this.backgroundImage != null) { + this.graphics.drawImage( + this.backgroundImage, 0, 0, - var3, - var4, - this.anInt3298, - this.anInt3299, - this.anInt3298 + var3, - this.anInt3299 + var4, + totalWidth, + totalHeight, + this.backgroundImageOffsetX, + this.backgroundImageOffsetY, + this.backgroundImageOffsetX + totalWidth, + this.backgroundImageOffsetY + totalHeight, this); } else { - this.drawBackground(this.aGraphics3307); + this.drawBackground(this.graphics); } - Font var5 = - this.aString3300 != null ? this.method837(this.aFont3291, this.aString3300, var3 - (var4 + 4)) : null; - int var6 = 0; - int var7; - if (this.anInt3301 == 0 || this.anInt3301 == 1) { - var7 = var4 + 4 + (var5 != null ? this.getFontMetrics(var5).stringWidth(this.aString3300) : 0); - if (this.anInt3301 == 0) { - var6 = var3 / 2 - var7 / 2; + Font sizeAdjustedFont = this.text != null + ? this.getSizeAdjustedFont(this.font, this.text, totalWidth - (totalHeight + 4)) + : null; + int x = 0; + int width; + if (this.alignment == ALIGN_CENTER || this.alignment == ALIGN_RIGHT) { + width = totalHeight + + 4 + + (sizeAdjustedFont != null + ? this.getFontMetrics(sizeAdjustedFont).stringWidth(this.text) + : 0); + if (this.alignment == 0) { + x = totalWidth / 2 - width / 2; } else { - var6 = var3 - 2 - var7; + x = totalWidth - 2 - width; } } - var7 = var4 - 4; - if (this.aColorCheckboxGroup3304 == null) { - this.method840( - this.aGraphics3307, - var6 + 2, + width = totalHeight - 4; + if (this.checkboxGroup == null) { + this.drawBorders( + this.graphics, + x + 2, 2, - var7, - var7, - this.method839(this.aColor3293), - this.method839(this.aColor3295), - this.method839(this.aColor3296)); + width, + width, + this.adjustColorForDisabled(this.borderColor), + this.adjustColorForDisabled(this.borderColorLight), + this.adjustColorForDisabled(this.borderColorDark)); } else { - this.aGraphics3307.setColor(this.method839(this.aColor3293)); - this.aGraphics3307.fillRect(var6 + 3, 3, var7 - 2, var7 - 2); - this.aGraphics3307.setColor(this.method839(this.aColor3295)); - this.aGraphics3307.drawLine(var6 + 3, var7 + 1, var6 + var7, var7 + 1); - this.aGraphics3307.drawLine(var6 + var7 + 1, 3, var6 + var7 + 1, var7); - this.aGraphics3307.fillRect(var6 + var7, 3, 1, 1); - this.aGraphics3307.fillRect(var6 + var7, var7, 1, 1); - this.aGraphics3307.setColor(this.method839(this.aColor3296)); - this.aGraphics3307.drawLine(var6 + 3, 2, var6 + var7, 2); - this.aGraphics3307.drawLine(var6 + 2, 3, var6 + 2, var7); - this.aGraphics3307.fillRect(var6 + 3, 3, 1, 1); - this.aGraphics3307.fillRect(var6 + 3, var7, 1, 1); + this.graphics.setColor(this.adjustColorForDisabled(this.borderColor)); + this.graphics.fillRect(x + 3, 3, width - 2, width - 2); + this.graphics.setColor(this.adjustColorForDisabled(this.borderColorLight)); + this.graphics.drawLine(x + 3, width + 1, x + width, width + 1); + this.graphics.drawLine(x + width + 1, 3, x + width + 1, width); + this.graphics.fillRect(x + width, 3, 1, 1); + this.graphics.fillRect(x + width, width, 1, 1); + this.graphics.setColor(this.adjustColorForDisabled(this.borderColorDark)); + this.graphics.drawLine(x + 3, 2, x + width, 2); + this.graphics.drawLine(x + 2, 3, x + 2, width); + this.graphics.fillRect(x + 3, 3, 1, 1); + this.graphics.fillRect(x + 3, width, 1, 1); } - if (this.aBoolean3302) { - this.aGraphics3307.setColor(this.method839(this.aColor3294)); - if (this.aColorCheckboxGroup3304 == null) { - var7 -= 4; - int var8 = var7 / 3; - int var9 = var8 - 1; - int var10 = var7 - var8 - 2; - this.aGraphics3307.drawLine(var6 + 4 + var8, 4 + var7 - 2, var6 + 4 + var8 - var9, 4 + var7 - 2 - var9); - this.aGraphics3307.drawLine( - var6 + 4 + var8, 4 + var7 - 2 - 1, var6 + 4 + var8 - var9, 4 + var7 - 2 - var9 - 1); - this.aGraphics3307.drawLine( - var6 + 4 + var8, 4 + var7 - 2 - 2, var6 + 4 + var8 - var9, 4 + var7 - 2 - var9 - 2); - this.aGraphics3307.drawLine( - var6 + 4 + var8, 4 + var7 - 2, var6 + 4 + var8 + var10, 4 + var7 - 2 - var10); - this.aGraphics3307.drawLine( - var6 + 4 + var8, 4 + var7 - 2 - 1, var6 + 4 + var8 + var10, 4 + var7 - 2 - var10 - 1); - this.aGraphics3307.drawLine( - var6 + 4 + var8, 4 + var7 - 2 - 2, var6 + 4 + var8 + var10, 4 + var7 - 2 - var10 - 2); + if (this.checked) { + this.graphics.setColor(this.adjustColorForDisabled(this.checkmarkColor)); + if (this.checkboxGroup == null) { + width -= 4; + int checkmarkStartX = width / 3; + int checkmarkHeight = checkmarkStartX - 1; + int checkmarkEndX = width - checkmarkStartX - 2; + this.graphics.drawLine( + x + 4 + checkmarkStartX, + 4 + width - 2, + x + 4 + checkmarkStartX - checkmarkHeight, + 4 + width - 2 - checkmarkHeight); + + this.graphics.drawLine( + x + 4 + checkmarkStartX, + 4 + width - 2 - 1, + x + 4 + checkmarkStartX - checkmarkHeight, + 4 + width - 2 - checkmarkHeight - 1); + + this.graphics.drawLine( + x + 4 + checkmarkStartX, + 4 + width - 2 - 2, + x + 4 + checkmarkStartX - checkmarkHeight, + 4 + width - 2 - checkmarkHeight - 2); + this.graphics.drawLine( + x + 4 + checkmarkStartX, + 4 + width - 2, + x + 4 + checkmarkStartX + checkmarkEndX, + 4 + width - 2 - checkmarkEndX); + this.graphics.drawLine( + x + 4 + checkmarkStartX, + 4 + width - 2 - 1, + x + 4 + checkmarkStartX + checkmarkEndX, + 4 + width - 2 - checkmarkEndX - 1); + this.graphics.drawLine( + x + 4 + checkmarkStartX, + 4 + width - 2 - 2, + x + 4 + checkmarkStartX + checkmarkEndX, + 4 + width - 2 - checkmarkEndX - 2); } else { - var7 -= 6; - this.aGraphics3307.fillRect(var6 + 6, 5, var7 - 2, var7); - this.aGraphics3307.fillRect(var6 + 5, 6, var7, var7 - 2); + width -= 6; + this.graphics.fillRect(x + 6, 5, width - 2, width); + this.graphics.fillRect(x + 5, 6, width, width - 2); } } - if (var5 != null) { - this.aGraphics3307.setFont(var5); - this.aGraphics3307.setColor(this.method839(this.aColor3292)); - this.drawText(this.aGraphics3307, this.aString3300, var6 + var4 + 4, var4 / 2 + var5.getSize() * 3 / 8 + 1); + if (sizeAdjustedFont != null) { + this.graphics.setFont(sizeAdjustedFont); + this.graphics.setColor(this.adjustColorForDisabled(this.foregroundColor)); + this.drawText( + this.graphics, + this.text, + x + totalHeight + 4, + totalHeight / 2 + sizeAdjustedFont.getSize() * 3 / 8 + 1); } - var1.drawImage(this.anImage3306, 0, 0, this); + g.drawImage(this.image, 0, 0, this); } - public void mouseEntered(MouseEvent var1) {} + public void mouseEntered(MouseEvent e) {} - public void mouseExited(MouseEvent var1) {} + public void mouseExited(MouseEvent e) {} - public void mousePressed(MouseEvent var1) {} + public void mousePressed(MouseEvent e) {} - public void mouseClicked(MouseEvent var1) {} + public void mouseClicked(MouseEvent e) {} - public void mouseReleased(MouseEvent var1) { - boolean var2 = !this.aBoolean3302; - if (this.aColorCheckboxGroup3304 == null || this.aColorCheckboxGroup3304.method1748(var2)) { - this.realSetState(var2); - this.method838(); + public void mouseReleased(MouseEvent e) { + boolean newState = !this.checked; + if (this.checkboxGroup == null || this.checkboxGroup.checkboxClicked(newState)) { + this.realSetState(newState); + this.notifyListeners(); } } @@ -196,72 +218,71 @@ public void removeItemListener(ItemListener listener) { } public Object[] getSelectedObjects() { - if (!this.aBoolean3302) { + if (!this.checked) { return null; } else { - Object[] var1 = new Object[] {this}; - return var1; + return new Object[] {this}; } } - public void setLabel(String var1) { - this.aString3300 = var1; + public void setLabel(String label) { + this.text = label; this.repaint(); } public String getLabel() { - return this.aString3300; + return this.text; } - public void setFont(Font var1) { - this.aFont3291 = var1; + public void setFont(Font font) { + this.font = font; this.repaint(); } - public void setAlign(int var1) { - this.anInt3301 = var1; + public void setAlign(int alignment) { + this.alignment = alignment; this.repaint(); } - public void setBackgroundImage(Image var1, int var2, int var3) { - this.anImage3297 = var1; - this.anInt3298 = var2; - this.anInt3299 = var3; + public void setBackgroundImage(Image image, int offsetX, int offsetY) { + this.backgroundImage = image; + this.backgroundImageOffsetX = offsetX; + this.backgroundImageOffsetY = offsetY; this.repaint(); } - public void setForeground(Color var1) { - this.aColor3292 = var1; + public void setForeground(Color foreground) { + this.foregroundColor = foreground; this.repaint(); } - public void setBoxBackground(Color var1) { - this.aColor3293 = var1; - this.aColor3295 = this.method835(var1, 32); - this.aColor3296 = this.method835(var1, -48); + public void setBorderColor(Color color) { + this.borderColor = color; + this.borderColorLight = this.translateColor(color, 32); + this.borderColorDark = this.translateColor(color, -48); this.repaint(); } - public void setBoxForeground(Color var1) { - this.aColor3294 = var1; + public void setCheckmarkColor(Color color) { + this.checkmarkColor = color; this.repaint(); } - public void setEnabled(boolean var1) { - super.setEnabled(var1); + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); this.repaint(); } - public void setState(boolean var1) { - if (this.aBoolean3302 != var1) { - if (this.aColorCheckboxGroup3304 == null || this.aColorCheckboxGroup3304.method1748(var1)) { - this.realSetState(var1); + public void setState(boolean state) { + if (this.checked != state) { + if (this.checkboxGroup == null || this.checkboxGroup.checkboxClicked(state)) { + this.realSetState(state); } } } public boolean getState() { - return this.aBoolean3302; + return this.checked; } public void click() { @@ -269,121 +290,128 @@ public void click() { } public Dimension getPreferredSize() { - int var1 = 3 + this.aFont3291.getSize() + 3; - return new Dimension(var1 + 4 + this.getFontMetrics(this.aFont3291).stringWidth(this.aString3300) + 4, var1); + int preferredHeight = 3 + this.font.getSize() + 3; + return new Dimension( + preferredHeight + 4 + this.getFontMetrics(this.font).stringWidth(this.text) + 4, preferredHeight); } - public void setGroup(ColorCheckboxGroup var1) { - this.aColorCheckboxGroup3304 = var1; - var1.addCheckbox(this); + public void setGroup(ColorCheckboxGroup group) { + this.checkboxGroup = group; + group.addCheckbox(this); this.repaint(); } - public void setBoxPixelRoundedCorners(boolean var1) { - this.aBoolean3303 = var1; + public void setBoxPixelRoundedCorners(boolean pixelRoundedCorners) { + this.pixelRoundedCorners = pixelRoundedCorners; this.repaint(); } - public Image createBuffer(int var1, int var2) { - return this.createImage(var1, var2); + public Image createBuffer(int width, int height) { + return this.createImage(width, height); } - public Graphics getGraphics(Image var1) { - return var1.getGraphics(); + public Graphics getGraphics(Image image) { + return image.getGraphics(); } - public void drawText(Graphics var1, String var2, int var3, int var4) { - var1.drawString(var2, var3, var4); + public void drawText(Graphics graphics, String text, int x, int y) { + graphics.drawString(text, x, y); } - public void realSetState(boolean var1) { - this.aBoolean3302 = var1; + public void realSetState(boolean checked) { + this.checked = checked; this.repaint(); } - private Color method835(Color var1, int var2) { + private Color translateColor(Color color, int offset) { return new Color( - this.method836(var1.getRed(), var2), - this.method836(var1.getGreen(), var2), - this.method836(var1.getBlue(), var2)); + this.translateColor(color.getRed(), offset), + this.translateColor(color.getGreen(), offset), + this.translateColor(color.getBlue(), offset)); } - private int method836(int var1, int var2) { - var1 += var2; - if (var1 < 0) { - var1 = 0; - } - - if (var1 > 255) { - var1 = 255; + private int translateColor(int base, int offset) { + base += offset; + if (base < 0) { + base = 0; + } else if (base > 255) { + base = 255; } - return var1; + return base; } - private Font method837(Font var1, String var2, int var3) { - int var4 = this.getFontMetrics(var1).stringWidth(var2); - if (var4 <= var3) { - return var1; + private Font getSizeAdjustedFont(Font font, String text, int width) { + int stringWidth = this.getFontMetrics(font).stringWidth(text); + if (stringWidth <= width) { + return font; } else { - int var7 = var1.getSize(); + int fontSize = font.getSize(); do { - Font var5 = var1; - int var6 = var4; - --var7; - var1 = new Font(var1.getName(), var1.getStyle(), var7); - var4 = this.getFontMetrics(var1).stringWidth(var2); - if (var4 >= var6) { - return var5; + Font newFont = font; + int newWidth = stringWidth; + --fontSize; + font = new Font(font.getName(), font.getStyle(), fontSize); + stringWidth = this.getFontMetrics(font).stringWidth(text); + if (stringWidth >= newWidth) { + return newFont; } - } while (var4 > var3 && var7 > 9); + } while (stringWidth > width && fontSize > 9); - return var1; + return font; } } - private void method838() { + private void notifyListeners() { synchronized (this.listeners) { if (this.listeners.size() != 0) { - ItemEvent var2 = new ItemEvent(this, 0, this, 701); + ItemEvent event = new ItemEvent(this, 0, this, 701); for (ItemListener listener : listeners) { - listener.itemStateChanged(var2); + listener.itemStateChanged(event); } } } } - private Color method839(Color var1) { + private Color adjustColorForDisabled(Color color) { if (this.isEnabled()) { - return var1; + return color; } else { - Color var2 = this.getBackground(); - int var3 = (var1.getRed() + var2.getRed() * 2) / 3; - int var4 = (var1.getGreen() + var2.getGreen() * 2) / 3; - int var5 = (var1.getBlue() + var2.getBlue() * 2) / 3; - return new Color(var3, var4, var5); + Color background = this.getBackground(); + int r = (color.getRed() + background.getRed() * 2) / 3; + int g = (color.getGreen() + background.getGreen() * 2) / 3; + int b = (color.getBlue() + background.getBlue() * 2) / 3; + return new Color(r, g, b); } } - private void method840(Graphics var1, int var2, int var3, int var4, int var5, Color var6, Color var7, Color var8) { - if (this.aBoolean3303) { - var1.setColor(var6); - var1.fillRect(var2 + 1, var3 + 1, var4 - 2, var5 - 2); - var1.setColor(var8); - var1.drawLine(var2 + 1, var3, var2 + var4 - 2, var3); - var1.drawLine(var2, var3 + 1, var2, var3 + var5 - 2); - var1.setColor(var7); - var1.drawLine(var2 + 1, var3 + var5 - 1, var2 + var4 - 2, var3 + var5 - 1); - var1.drawLine(var2 + var4 - 1, var3 + 1, var2 + var4 - 1, var3 + var5 - 2); + private void drawBorders( + Graphics graphics, + int x, + int y, + int width, + int height, + Color borderColor, + Color borderColorLight, + Color borderColorDark) { + if (this.pixelRoundedCorners) { + graphics.setColor(borderColor); + graphics.fillRect(x + 1, y + 1, width - 2, height - 2); + graphics.setColor(borderColorDark); + graphics.drawLine(x + 1, y, x + width - 2, y); + graphics.drawLine(x, y + 1, x, y + height - 2); + graphics.setColor(borderColorLight); + graphics.drawLine(x + 1, y + height - 1, x + width - 2, y + height - 1); + graphics.drawLine(x + width - 1, y + 1, x + width - 1, y + height - 2); } else { - var1.setColor(var6); - var1.fillRect(var2, var3, var4, var5); - var1.setColor(var7); - var1.drawRect(var2, var3, var4 - 1, var5 - 1); - var1.setColor(var8); - var1.drawLine(var2, var3, var2 + var4 - 2, var3); - var1.drawLine(var2, var3, var2, var3 + var5 - 1); + graphics.setColor(borderColor); + graphics.fillRect(x, y, width, height); + graphics.setColor(borderColorLight); + graphics.drawRect(x, y, width - 1, height - 1); + graphics.setColor(borderColorDark); + graphics.drawLine(x, y, x + width - 2, y); + graphics.drawLine(x, y, x, y + height - 1); } } } diff --git a/client/src/main/java/com/aapeli/colorgui/ColorCheckboxGroup.java b/client/src/main/java/com/aapeli/colorgui/ColorCheckboxGroup.java index 12e49420..e0ae6cff 100644 --- a/client/src/main/java/com/aapeli/colorgui/ColorCheckboxGroup.java +++ b/client/src/main/java/com/aapeli/colorgui/ColorCheckboxGroup.java @@ -13,16 +13,16 @@ protected void addCheckbox(ColorCheckbox checkbox) { } } - protected boolean method1748(boolean var1) { - if (var1) { - this.method1749(); + protected boolean checkboxClicked(boolean checked) { + if (checked) { + this.updateCheckboxes(); return true; } else { return false; } } - private void method1749() { + private void updateCheckboxes() { for (ColorCheckbox colorCheckbox : checkboxes) { colorCheckbox.realSetState(false); } diff --git a/client/src/main/java/com/aapeli/colorgui/ColorList.java b/client/src/main/java/com/aapeli/colorgui/ColorList.java index d35cc7b7..7f09a5db 100644 --- a/client/src/main/java/com/aapeli/colorgui/ColorList.java +++ b/client/src/main/java/com/aapeli/colorgui/ColorList.java @@ -546,8 +546,7 @@ private ColorListItem getItemAt(int y) { if (nodesCount == 0) { return null; } else { - for (int i = 0; i < nodesCount; ++i) { - ColorListNode node = this.nodes.get(i); + for (ColorListNode node : this.nodes) { if (node.containsYCoordinate(y)) { return node.getItem(); } diff --git a/client/src/main/java/com/aapeli/colorgui/ColorListItem.java b/client/src/main/java/com/aapeli/colorgui/ColorListItem.java index 493978f6..37e22f12 100644 --- a/client/src/main/java/com/aapeli/colorgui/ColorListItem.java +++ b/client/src/main/java/com/aapeli/colorgui/ColorListItem.java @@ -41,14 +41,6 @@ public ColorListItem(String text) { this(null, 0, false, text, null, false); } - public ColorListItem(int color, boolean bold, String text) { - this(null, color, bold, text, null, false); - } - - public ColorListItem(int color, boolean bold, String text, Object data, boolean selected) { - this(null, colors[color], bold, text, data, selected); - } - public ColorListItem(Image icon, int color, boolean bold, String text, Object data, boolean selected) { this(icon, colors[color], bold, text, data, selected); } diff --git a/client/src/main/java/com/aapeli/colorgui/ColorTextArea.java b/client/src/main/java/com/aapeli/colorgui/ColorTextArea.java index f26ac1a5..ca6b5013 100644 --- a/client/src/main/java/com/aapeli/colorgui/ColorTextArea.java +++ b/client/src/main/java/com/aapeli/colorgui/ColorTextArea.java @@ -68,10 +68,6 @@ public class ColorTextArea extends IPanel implements ComponentListener, Adjustme private int borderStyle; private Object synchronizationObject; - public ColorTextArea(int width, int height) { - this(width, height, null); - } - public ColorTextArea(int width, int height, Font font) { this.synchronizationObject = new Object(); this.width = width; diff --git a/client/src/main/java/com/aapeli/colorgui/MultiColorList.java b/client/src/main/java/com/aapeli/colorgui/MultiColorList.java index a01b9900..10477e31 100644 --- a/client/src/main/java/com/aapeli/colorgui/MultiColorList.java +++ b/client/src/main/java/com/aapeli/colorgui/MultiColorList.java @@ -384,10 +384,6 @@ public synchronized int getSelectedItemCount() { return var2; } - public void addItem(String[] var1) { - this.addItem(new MultiColorListItem(var1)); - } - public synchronized void addItem(MultiColorListItem var1) { int var2 = var1.getColumnCount(); if (this.anInt698 == 0) { @@ -683,7 +679,7 @@ private int[] method959(String[][] var1) { var6 += var5[var7]; } - double var11 = 1.0D * (double) this.anInt702 / (double) var6; + double var11 = (double) this.anInt702 / (double) var6; var6 = 0; int[] var9 = new int[var3]; diff --git a/client/src/main/java/com/aapeli/colorgui/MultiColorListItem.java b/client/src/main/java/com/aapeli/colorgui/MultiColorListItem.java index 3290ff00..4acb36be 100644 --- a/client/src/main/java/com/aapeli/colorgui/MultiColorListItem.java +++ b/client/src/main/java/com/aapeli/colorgui/MultiColorListItem.java @@ -28,22 +28,10 @@ public class MultiColorListItem { private Object data; private boolean selected; - public MultiColorListItem(String[] strings) { - this(colours[0], false, strings, null, false); - } - - public MultiColorListItem(int colourIndex, boolean bold, String[] strings) { - this(colours[colourIndex], bold, strings, null, false); - } - public MultiColorListItem(int colourIndex, String[] strings, Object data) { this(colours[colourIndex], false, strings, data, false); } - public MultiColorListItem(int colourIndex, boolean bold, String[] strings, Object data) { - this(colours[colourIndex], bold, strings, data, false); - } - public MultiColorListItem(int colourIndex, boolean bold, String[] strings, Object data, boolean selected) { this(colours[colourIndex], bold, strings, data, selected); } diff --git a/client/src/main/java/com/aapeli/colorgui/RadioButton.java b/client/src/main/java/com/aapeli/colorgui/RadioButton.java index e9f0ba50..ec498003 100644 --- a/client/src/main/java/com/aapeli/colorgui/RadioButton.java +++ b/client/src/main/java/com/aapeli/colorgui/RadioButton.java @@ -11,10 +11,6 @@ public class RadioButton extends ColorButton { private boolean aBoolean4724; private boolean aBoolean4725; - public RadioButton() { - this(null, null); - } - public RadioButton(RadioButtonGroup var1) { this(null, var1); } diff --git a/client/src/main/java/com/aapeli/connection/SocketConnection.java b/client/src/main/java/com/aapeli/connection/SocketConnection.java index 23fc6235..321107d5 100644 --- a/client/src/main/java/com/aapeli/connection/SocketConnection.java +++ b/client/src/main/java/com/aapeli/connection/SocketConnection.java @@ -61,11 +61,6 @@ public SocketConnection( this(gameApplet, gameApplet.param, socketConnectionListener, gameCipherCmds); } - public SocketConnection( - Parameters params, SocketConnectionListener socketConnectionListener, String[] gameCipherCmds) { - this(null, params, socketConnectionListener, gameCipherCmds); - } - private SocketConnection( AApplet gameApplet, Parameters params, @@ -182,10 +177,6 @@ public void closeConnection() { } } - public String getLocalIP() { - return null; - } - protected void handleCrash() { // TODO this.failed = true; this.state = STATE_DISCONNECTED; @@ -341,8 +332,7 @@ private void readInput() { this.writeLineC("old " + this.clientId); } } else if (cmd.startsWith("id ")) { // connected - long id = Long.parseLong(cmd.substring(3)); - this.clientId = id; + this.clientId = Long.parseLong(cmd.substring(3)); this.state = STATE_CONNECTED; } else if (cmd.equals("rcok")) { // reconnect ok this.state = STATE_CONNECTED; diff --git a/client/src/main/java/com/aapeli/multiuser/ChatBase.java b/client/src/main/java/com/aapeli/multiuser/ChatBase.java index a0724b73..977b3f47 100644 --- a/client/src/main/java/com/aapeli/multiuser/ChatBase.java +++ b/client/src/main/java/com/aapeli/multiuser/ChatBase.java @@ -539,7 +539,7 @@ private static UrlLabel getSignupMessage( return signupMessage; } else { if (signupMessage == null) { - signupMessage = new UrlLabel(parameters.getApplet()); + signupMessage = new UrlLabel(); Point inputFieldLocation = inputTextField.getLocation(); Point sayButtonLocation = sayButton.getLocation(); Dimension sayButtonSize = sayButton.getSize(); @@ -602,7 +602,6 @@ private void init( this.add(sayButton); this.sayButton = sayButton; this.userList = new UserList( - this.parameters.getApplet(), this, this.textManager, this.imageManager, @@ -611,7 +610,7 @@ private void init( addIgnoreUserCheckbox); this.userList.setChatReference(this); this.add(this.userList); - this.signupMessage = new UrlLabel(this.parameters.getApplet()); + this.signupMessage = new UrlLabel(); this.add(this.signupMessage); this.paintSignupMessage(); } diff --git a/client/src/main/java/com/aapeli/multiuser/ColorButton_Sub1.java b/client/src/main/java/com/aapeli/multiuser/ColorButton_Sub1.java deleted file mode 100644 index 134f5f92..00000000 --- a/client/src/main/java/com/aapeli/multiuser/ColorButton_Sub1.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.aapeli.multiuser; - -import com.aapeli.colorgui.ColorButton; -import java.awt.Color; -import java.awt.Graphics; - -class ColorButton_Sub1 extends ColorButton { - - private boolean aBoolean4726 = false; - - protected ColorButton_Sub1(String var1) { - super(var1); - } - - public void clearBackground(Graphics var1, int var2, int var3) { - var1.fillRect(1, 1, var2 - 1, var3 - 1); - } - - public void drawBorder(Graphics var1, int var2, int var3) { - boolean var4 = this.isNormalState(); - Color[] var5 = this.getLightAndDarkBorderColors(); - if (!this.aBoolean4726) { - var1.setColor(var4 ? var5[0] : var5[1]); - var1.drawLine(0, 0, var2 - 2, 0); - var1.drawLine(0, 0, 0, var3 - 1); - var1.setColor(var4 ? var5[1] : var5[0]); - var1.drawLine(var2 - 1, var3 - 1, 1, var3 - 1); - var1.drawLine(var2 - 1, var3 - 1, var2 - 1, 0); - } else { - var1.setColor(var4 ? var5[0] : var5[1]); - var1.drawLine(1, 0, var2 - 2, 0); - var1.drawLine(0, 1, 0, var3 - 1); - var1.setColor(var4 ? var5[1] : var5[0]); - var1.drawLine(var2 - 1, var3 - 1, 1, var3 - 1); - var1.drawLine(var2 - 1, var3 - 1, var2 - 1, 1); - } - } - - public void setPixelRoundedUpperCorners() { - this.aBoolean4726 = true; - this.repaint(); - } -} diff --git a/client/src/main/java/com/aapeli/multiuser/MultiLanguageChatContainer.java b/client/src/main/java/com/aapeli/multiuser/MultiLanguageChatContainer.java index b23bf431..488b34c9 100644 --- a/client/src/main/java/com/aapeli/multiuser/MultiLanguageChatContainer.java +++ b/client/src/main/java/com/aapeli/multiuser/MultiLanguageChatContainer.java @@ -9,7 +9,7 @@ import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; -final class MultiLanguageChatContainer extends IPanel implements ComponentListener, TabBarListener { +public final class MultiLanguageChatContainer extends IPanel implements ComponentListener, TabBarListener { private ChatBase chatBase; private Languages languages; diff --git a/client/src/main/java/com/aapeli/multiuser/RoundedUpperCornersButton.java b/client/src/main/java/com/aapeli/multiuser/RoundedUpperCornersButton.java new file mode 100644 index 00000000..fbde23d9 --- /dev/null +++ b/client/src/main/java/com/aapeli/multiuser/RoundedUpperCornersButton.java @@ -0,0 +1,47 @@ +package com.aapeli.multiuser; + +import com.aapeli.colorgui.ColorButton; +import java.awt.Color; +import java.awt.Graphics; + +public class RoundedUpperCornersButton extends ColorButton { + + private boolean roundedUpperCorners = false; + + public RoundedUpperCornersButton(String label) { + super(label); + } + + public void clearBackground(Graphics g, int var2, int var3) { + g.fillRect(1, 1, var2 - 1, var3 - 1); + } + + public void drawBorder(Graphics g, int width, int height) { + boolean normalState = this.isNormalState(); + Color[] borderColors = this.getLightAndDarkBorderColors(); + if (!this.roundedUpperCorners) { + g.setColor(normalState ? borderColors[0] : borderColors[1]); + g.setColor(Color.red); + g.drawLine(0, 0, width - 2, 0); + g.drawLine(0, 0, 0, height - 1); + g.setColor(normalState ? borderColors[1] : borderColors[0]); + g.setColor(Color.red); + g.drawLine(width - 1, height - 1, 1, height - 1); + g.drawLine(width - 1, height - 1, width - 1, 0); + } else { + g.setColor(normalState ? borderColors[0] : borderColors[1]); + g.setColor(Color.red); + g.drawLine(1, 0, width - 2, 0); + g.drawLine(0, 1, 0, height - 1); + g.setColor(normalState ? borderColors[1] : borderColors[0]); + g.setColor(Color.red); + g.drawLine(width - 1, height - 1, 1, height - 1); + g.drawLine(width - 1, height - 1, width - 1, 1); + } + } + + public void setRoundedUpperCorners() { + this.roundedUpperCorners = true; + this.repaint(); + } +} diff --git a/client/src/main/java/com/aapeli/multiuser/User.java b/client/src/main/java/com/aapeli/multiuser/User.java index 67e8afc9..9f0927b6 100644 --- a/client/src/main/java/com/aapeli/multiuser/User.java +++ b/client/src/main/java/com/aapeli/multiuser/User.java @@ -21,7 +21,6 @@ public final class User { private boolean isNotAcceptingChallenges; private ColorListItem colorListItem; private String profilePage; - public static boolean aBoolean1684; public User(String nick, boolean isLocal, boolean isRegistered, boolean isVip, boolean isSheriff) { this(nick, isLocal, isRegistered, isVip, isSheriff, -1); diff --git a/client/src/main/java/com/aapeli/multiuser/UserList.java b/client/src/main/java/com/aapeli/multiuser/UserList.java index bdedcd5a..960bb8f1 100644 --- a/client/src/main/java/com/aapeli/multiuser/UserList.java +++ b/client/src/main/java/com/aapeli/multiuser/UserList.java @@ -9,9 +9,9 @@ import com.aapeli.colorgui.ColorListItemGroup; import com.aapeli.colorgui.ColorTextArea; import com.aapeli.tools.Tools; -import java.applet.Applet; import java.awt.CheckboxMenuItem; import java.awt.Color; +import java.awt.Desktop; import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics; @@ -26,7 +26,7 @@ import java.awt.event.ComponentListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -import java.net.URL; +import java.net.URI; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; @@ -48,7 +48,6 @@ public class UserList extends IPanel implements ComponentListener, ItemListener, private UserListHandler userListHandler; private TextManager textManager; private ImageManager imageManager; - private Applet applet; private int width; private int height; private Image[] rankingIcons; @@ -56,8 +55,8 @@ public class UserList extends IPanel implements ComponentListener, ItemListener, private ColorList playersList; private ColorCheckbox sendPrivatelyCheckbox; private ColorCheckbox ignoreUserCheckbox; - private ColorButton_Sub1 sortByRankingButton; - private ColorButton_Sub1 sortByNicknameButton; + private RoundedUpperCornersButton sortByRankingButton; + private RoundedUpperCornersButton sortByNicknameButton; private Image backgroundImage; private Image playersListBackgroundImage; private int backgroundImageOffsetX; @@ -95,33 +94,18 @@ public class UserList extends IPanel implements ComponentListener, ItemListener, private Hashtable languageGroups; public UserList( - Applet applet, UserListHandler handler, TextManager textManager, ImageManager imageManager, boolean showRankingIcons, boolean addSendPrivately, boolean addIgnoreUser) { - this(applet, handler, textManager, imageManager, showRankingIcons, addSendPrivately, addIgnoreUser, 100, 200); - } - - public UserList( - Applet applet, - UserListHandler handler, - TextManager textManager, - ImageManager imageManager, - boolean showRankingIcons, - boolean addSendPrivately, - boolean addIgnoreUser, - int width, - int height) { - this.applet = applet; this.userListHandler = handler; this.textManager = textManager; this.imageManager = imageManager; - this.width = width; - this.height = height; - this.setSize(width, height); + this.width = 100; + this.height = 200; + this.setSize(100, 200); this.rankingsShown = showRankingIcons; this.init(addSendPrivately, addIgnoreUser); this.setBackground(backgroundColor); @@ -682,11 +666,11 @@ public void setChatReference(ChatBase chat) { public void usePixelRoundedButtonsAndCheckBoxes() { if (this.sortByRankingButton != null) { - this.sortByRankingButton.setPixelRoundedUpperCorners(); + this.sortByRankingButton.setRoundedUpperCorners(); } if (this.sortByNicknameButton != null) { - this.sortByNicknameButton.setPixelRoundedUpperCorners(); + this.sortByNicknameButton.setRoundedUpperCorners(); } if (this.sendPrivatelyCheckbox != null) { @@ -801,13 +785,15 @@ private Color getUserColor(User user) { private void init(boolean addSendPrivately, boolean addIgnoreUser) { this.setLayout(null); if (this.rankingsShown) { - this.sortByRankingButton = new ColorButton_Sub1(this.textManager.getShared("UserList_SortByRanking")); + this.sortByRankingButton = + new RoundedUpperCornersButton(this.textManager.getShared("UserList_SortByRanking")); this.sortByRankingButton.setBounds(0, 0, 17, 11); this.sortByRankingButton.setFont(sortingButtonsFont); this.sortByRankingButton.setBackground(columnHeaderDefaultColor); this.sortByRankingButton.addActionListener(this); this.add(this.sortByRankingButton); - this.sortByNicknameButton = new ColorButton_Sub1(this.textManager.getShared("UserList_SortByNick")); + this.sortByNicknameButton = + new RoundedUpperCornersButton(this.textManager.getShared("UserList_SortByNick")); this.sortByNicknameButton.setBounds(17, 0, this.width - 17, 11); this.sortByNicknameButton.setFont(sortingButtonsFont); this.sortByNicknameButton.setBackground(columnHeaderSortedColor); @@ -903,12 +889,7 @@ private boolean openProfilePage(User user) { return false; } else { try { - String target = this.textManager.getParameters().getParameter("guestinfotarget"); - if (target == null) { - target = "_blank"; - } - - this.applet.getAppletContext().showDocument(new URL(profilePage), target); + Desktop.getDesktop().browse(new URI(profilePage)); } catch (Exception e) { } diff --git a/client/src/main/java/com/aapeli/tools/EncodedXmlReader.java b/client/src/main/java/com/aapeli/tools/EncodedXmlReader.java index 5cb2db04..d9f8ca2c 100644 --- a/client/src/main/java/com/aapeli/tools/EncodedXmlReader.java +++ b/client/src/main/java/com/aapeli/tools/EncodedXmlReader.java @@ -19,7 +19,7 @@ public EncodedXmlReader(String resourcePath, boolean debug) { public XmlUnit readXmlUnit() { try { String xmlData = this.readFile(); - return XmlUnit.parseString(xmlData, true, true); + return XmlUnit.parseString(xmlData, true); } catch (Exception ex) { if (this.isDebug) { System.out.println("EncodedXmlReader.readXmlUnit(): Failed to read or parse xml-file \"" diff --git a/client/src/main/java/com/aapeli/tools/QuickTimer.java b/client/src/main/java/com/aapeli/tools/QuickTimer.java index d4a77642..07b09e9d 100644 --- a/client/src/main/java/com/aapeli/tools/QuickTimer.java +++ b/client/src/main/java/com/aapeli/tools/QuickTimer.java @@ -8,7 +8,6 @@ public class QuickTimer implements Runnable { private int anInt1727; private List listeners; private boolean stopped; - private static final String aString1730 = "QuickTimer.start() called after QuickTimer.stopAll() was called"; public QuickTimer(int var1) { this(var1, null, false); diff --git a/client/src/main/java/com/aapeli/tools/Tools.java b/client/src/main/java/com/aapeli/tools/Tools.java index 49cfbd83..8b844b79 100644 --- a/client/src/main/java/com/aapeli/tools/Tools.java +++ b/client/src/main/java/com/aapeli/tools/Tools.java @@ -1,8 +1,5 @@ package com.aapeli.tools; -import java.awt.Color; -import java.awt.Component; -import java.awt.Graphics; import java.util.Calendar; import java.util.StringTokenizer; @@ -24,21 +21,6 @@ public static boolean sleep(long var0) { } } - public static boolean forcedRepaint(Component target) { - try { - Graphics graphics = target.getGraphics(); - if (graphics != null) { - target.update(graphics); - return true; - } - - target.repaint(); - } catch (Exception var2) { - } - - return false; - } - public static String changeToSaveable(String var0) { int var1 = var0.length(); StringBuffer var2 = new StringBuffer(var1 * 2); @@ -89,49 +71,6 @@ public static String changeFromSaveable(String s) { return sb.toString(); } - public static int getRandomByPossibility(double[] var0) { - int var1 = var0.length; - double[] var2 = new double[var1]; - - for (int var3 = 0; var3 < var1; ++var3) { - if (var0[var3] < 0.0D) { - throw new IllegalArgumentException("Negative possibility"); - } - - var2[var3] = var3 == 0 ? var0[0] : var2[var3 - 1] + var0[var3]; - } - - if (var2[var1 - 1] == 0.0D) { - throw new IllegalArgumentException("Total zero possibility"); - } else { - double var6 = Math.random() * var2[var1 - 1]; - - for (int var5 = 0; var5 < var1; ++var5) { - if (var6 < var2[var5]) { - return var5; - } - } - - return -1; - } - } - - public static int[] stringToIntArray(String var0) { - try { - StringTokenizer var1 = new StringTokenizer(var0, ","); - int var2 = var1.countTokens(); - int[] var3 = new int[var2]; - - for (int var4 = 0; var4 < var2; ++var4) { - var3[var4] = Integer.parseInt(var1.nextToken()); - } - - return var3; - } catch (Exception var5) { - return null; - } - } - public static String[] separateString(String var0, String var1) { StringTokenizer var2 = new StringTokenizer(var0, var1); int var3 = var2.countTokens(); @@ -144,12 +83,6 @@ public static String[] separateString(String var0, String var1) { return var4; } - public static double getDistance(double var0, double var2, double var4, double var6) { - double var8 = var4 - var0; - double var10 = var6 - var2; - return Math.sqrt(var8 * var8 + var10 * var10); - } - public static String replaceFirst(String var0, String var1, String var2) { int var3 = var0.indexOf(var1); if (var3 == -1) { @@ -184,29 +117,6 @@ public static boolean getBoolean(String var0) { return false; } - public static Color getColor(String var0, Color var1) { - if (var0 == null) { - return var1; - } else { - var0 = var0.trim(); - if (var0.startsWith("#")) { - var0 = var0.substring(1).trim(); - } else if (var0.startsWith("0x")) { - var0 = var0.substring(2).trim(); - } - - if (var0.length() == 0) { - return var1; - } else { - try { - return new Color(Integer.parseInt(var0, 16)); - } catch (Exception var3) { - return var1; - } - } - } - } - public static String reverse(String var0) { if (var0 == null) { return null; @@ -275,20 +185,6 @@ public static void printTimeElapsed(String message) { System.out.println(sb); } - public static String arrayToString(Object[] var0, char var1) { - StringBuffer var2 = new StringBuffer(); - int var3 = var0.length; - - for (int var4 = 0; var4 < var3; ++var4) { - var2.append(var0[var4].toString()); - if (var4 < var3 - 1) { - var2.append(var1); - } - } - - return var2.toString(); - } - private static void method1875(StringBuffer var0, int var1) { int var2 = var1 / 60000; var1 -= var2 * 60000; diff --git a/client/src/main/java/com/aapeli/tools/XmlUnit.java b/client/src/main/java/com/aapeli/tools/XmlUnit.java index 2f35065b..fca631b3 100644 --- a/client/src/main/java/com/aapeli/tools/XmlUnit.java +++ b/client/src/main/java/com/aapeli/tools/XmlUnit.java @@ -21,7 +21,7 @@ private XmlUnit(String var1) { this.attributes = new Hashtable<>(); } - public static XmlUnit parseString(String declarationTag, boolean var1, boolean var2) throws Exception { + public static XmlUnit parseString(String declarationTag, boolean var2) throws Exception { declarationTag = declarationTag.trim(); if (declarationTag.startsWith(" params; - private String server; - - public Stub(String server, Locale locale, String username, int port, boolean verbose, boolean norandom) { - if (server.indexOf(':') == -1) { // is ipv4 - this.server = server; - } else { // is ipv6 - this.server = "[" + server + "]"; - } - params = new HashMap<>(); - params.put("initmessage", "Loading game..."); - params.put( - "ld_page", - "javascript:Playray.Notify.delegate({ jvm: { version: '%v', vendor: '%w', t1: '%r', t2: '%f' } })"); - params.put("server", server + ":" + port); - params.put("locale", locale.toString()); - params.put("sitename", "playray"); - params.put("registerpage", "http://www.playforia.com/account/create/"); - params.put("creditpage", "http://www.playforia.com/shop/buy/"); - params.put("userinfopage", "http://www.playforia.com/community/user/"); - params.put("userinfotarget", "_blank"); - params.put("userlistpage", "javascript:Playray.GameFaceGallery('%n','#99FF99','agolf','%s')"); - params.put("json", "Playray.Notify.delegate(%o)"); - params.put("verbose", Boolean.toString(verbose)); - params.put("norandom", Boolean.toString(norandom)); - params.put("username", username); - } - - public boolean isActive() { - return true; - } - - public URL getDocumentBase() { - try { - return new URL("http://" + this.server + "/AGolf/"); - } catch (Exception ex) { - System.err.println("getdocumentbase exc eption"); - return null; - } - } - - public URL getCodeBase() { - return getDocumentBase(); - } - - public String getParameter(String name) { - if (!params.containsKey(name)) return ""; - return params.get(name); + private Parameters getParameters( + String server, Locale locale, String username, int port, boolean verbose, boolean norandom) { + Map params = new HashMap<>(); + if (server.indexOf(':') == -1) { // is ipv4 + params.put("server", server); + } else { // is ipv6 + params.put("server", "[" + server + "]"); } - - public AppletContext getAppletContext() { - return null; - } - - public void appletResize(int width, int height) {} + params = new HashMap<>(); + params.put("initmessage", "Loading game..."); + params.put( + "ld_page", + "javascript:Playray.Notify.delegate({ jvm: { version: '%v', vendor: '%w', t1: '%r', t2: '%f' } })"); + params.put("server", server + ":" + port); + params.put("locale", locale.toString()); + params.put("sitename", "playray"); + params.put("registerpage", "http://www.playforia.com/account/create/"); + params.put("creditpage", "http://www.playforia.com/shop/buy/"); + params.put("userinfopage", "http://www.playforia.com/community/user/"); + params.put("userinfotarget", "_blank"); + params.put("userlistpage", "javascript:Playray.GameFaceGallery('%n','#99FF99','agolf','%s')"); + params.put("json", "Playray.Notify.delegate(%o)"); + params.put("verbose", Boolean.toString(verbose)); + params.put("norandom", Boolean.toString(norandom)); + params.put("username", username); + return new Parameters(params); } }