Skip to content

Commit

Permalink
Deobfuscate lobby selection and chat code
Browse files Browse the repository at this point in the history
These were helpful in tracking down the layout shift bug fixed in
LobbyPanel in the next commit.
  • Loading branch information
StenAL committed May 27, 2024
1 parent 4cc50ed commit b530afa
Show file tree
Hide file tree
Showing 8 changed files with 443 additions and 448 deletions.
2 changes: 1 addition & 1 deletion client/src/main/java/agolf/game/ChatPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected void addBroadcastMessage(String message) {
}

private void create() {
this.setLayout((LayoutManager) null);
this.setLayout(null);
this.textAreaChat = new ChatTextArea(this.gameContainer.textManager, this.gameContainer.badWordFilter, this.width, this.height - 22, new Font("Dialog", 0, 11));
this.textAreaChat.setLocation(0, 0);
this.textFieldMessage = new InputTextField(this.gameContainer.textManager.getGame("GameChat_TypeHere"), 200, true);
Expand Down
26 changes: 13 additions & 13 deletions client/src/main/java/agolf/lobby/LobbyChatPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ protected boolean handlePacket(String[] args) {
aBoolean3714 = false;// ??
}
} else {
super.gui_output.clear();
super.gui_userlist.removeAllUsers();
super.chatTextArea.clear();
super.userList.removeAllUsers();
}

int numSingleLobby = Integer.parseInt(args[2]);
Expand Down Expand Up @@ -124,7 +124,7 @@ protected boolean handlePacket(String[] args) {
message = this.gameContainer.textManager.getGame("LobbyChat_UsersInThisLobbyXX", lobbyUsers, ingameUsers);
}

super.gui_output.addPlainMessage(message);
super.chatTextArea.addPlainMessage(message);
message = null;
if (this.lobbyId == 1 && (dualLobbyUsers >= 1 || multiLobbyUsers >= 1)) {
message = "(";
Expand Down Expand Up @@ -202,10 +202,10 @@ protected boolean handlePacket(String[] args) {
}

if (message != null) {
super.gui_output.addPlainMessage(message);
super.chatTextArea.addPlainMessage(message);
}

super.gui_output.addLine();
super.chatTextArea.addLine();
return true;
}
else if(args[1].equals("users")) {
Expand All @@ -226,7 +226,7 @@ else if(args[1].equals("ownjoin")) {
else if(args[1].equals("join") || args[1].equals("joinfromgame")) {
String userData = this.userJoin(args[2]);
if (!this.isNoJoinPartMessages()) {
super.gui_output.addJoinMessage(this.gameContainer.textManager.getGame("LobbyChat_User" + (args[1].equals("join") ? "Joined" : "ReturnedFromGame"), userData));
super.chatTextArea.addJoinMessage(this.gameContainer.textManager.getGame("LobbyChat_User" + (args[1].equals("join") ? "Joined" : "ReturnedFromGame"), userData));
}

return true;
Expand All @@ -236,7 +236,7 @@ else if(args[1].equals("part")) {
int reason = Integer.parseInt(args[3]);
if(reason == 1 && this.lobbyId == 1) {
if (!this.isNoGameMessages()) {
super.gui_output.addMessage(this.gameContainer.textManager.getGame("LobbyChat_UserStartedSp", args[2]));
super.chatTextArea.addMessage(this.gameContainer.textManager.getGame("LobbyChat_UserStartedSp", args[2]));
}

return true;
Expand All @@ -250,13 +250,13 @@ else if(args[1].equals("part")) {
var5 = this.gameContainer.textManager.getGame("LobbyChat_User" + reasons[reason], args[2], args[4]);
}

super.gui_output.addMessage(var5);
super.chatTextArea.addMessage(var5);
}

return true;
} else if(reason >= 4) {
if (!this.isNoJoinPartMessages()) {
super.gui_output.addPartMessage(this.gameContainer.textManager.getGame("LobbyChat_UserLeft" + (reason == 5 ? "ConnectionProblem" : ""), args[2]));
super.chatTextArea.addPartMessage(this.gameContainer.textManager.getGame("LobbyChat_UserLeft" + (reason == 5 ? "ConnectionProblem" : ""), args[2]));
}

return true;
Expand All @@ -266,7 +266,7 @@ else if(args[1].equals("part")) {
}
else if(args[1].equals("gsn")) {
if (!this.isNoGameMessages()) {
super.gui_output.addMessage(this.gameContainer.textManager.getGame("LobbyChat_UsersStartedDp", args[2], args[3]));
super.chatTextArea.addMessage(this.gameContainer.textManager.getGame("LobbyChat_UsersStartedDp", args[2], args[3]));
}

return true;
Expand Down Expand Up @@ -297,14 +297,14 @@ else if (args[1].equals("nc")) {
protected void getUser(String name, boolean var2) {
UserListItem var3;
if (name != null) {
var3 = super.gui_userlist.getUser(name);
var3 = super.userList.getUser(name);
if (var3 == null) {
return;
}
} else {
var3 = super.gui_userlist.getLocalUser();
var3 = super.userList.getLocalUser();
}

super.gui_userlist.setNotAcceptingChallenges(var3, var2);
super.userList.setNotAcceptingChallenges(var3, var2);
}
}
27 changes: 13 additions & 14 deletions client/src/main/java/agolf/lobby/LobbyControlPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
import com.aapeli.colorgui.ColorButton;

import java.awt.Graphics;
import java.awt.LayoutManager;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

class LobbyControlPanel extends Panel implements ActionListener {

private GameContainer gameContainer;
private int height;
private int width;
private int height;
private ColorButton buttonBack;
private ColorButton buttonSingle;
//private ColorButton buttonDual;
Expand All @@ -25,8 +24,8 @@ class LobbyControlPanel extends Panel implements ActionListener {

protected LobbyControlPanel(GameContainer gameContainer, int width, int height) {
this.gameContainer = gameContainer;
this.height = width;
this.width = height;
this.width = width;
this.height = height;
this.setSize(width, height);
this.create();
}
Expand All @@ -36,13 +35,13 @@ public void addNotify() {
this.repaint();
}

public void paint(Graphics var1) {
this.update(var1);
public void paint(Graphics graphics) {
this.update(graphics);
}

public void update(Graphics var1) {
var1.setColor(GameApplet.colourGameBackground);
var1.fillRect(0, 0, this.height, this.width);
public void update(Graphics graphics) {
graphics.setColor(GameApplet.colourGameBackground);
graphics.fillRect(0, 0, this.width, this.height);
}

public void actionPerformed(ActionEvent evt) {
Expand Down Expand Up @@ -98,15 +97,15 @@ protected void setState(int state) {
}

private void create() {
this.setLayout((LayoutManager) null);
this.setLayout(null);
this.buttonBack = new ColorButton(this.gameContainer.textManager.getGame("LobbyControl_Main"));
this.buttonBack.setBackground(GameApplet.colourButtonYellow);
this.buttonBack.setBounds(0, 0, this.height, 20);
this.buttonBack.setBounds(0, 0, this.width, 20);
this.buttonBack.addActionListener(this);
this.add(this.buttonBack);
if (!this.gameContainer.disableSinglePlayer) {
this.buttonSingle = new ColorButton(this.gameContainer.textManager.getGame("LobbyControl_Single"));
this.buttonSingle.setBounds(0, 27, this.height, 20);
this.buttonSingle.setBounds(0, 27, this.width, 20);
this.buttonSingle.addActionListener(this);
}

Expand All @@ -117,11 +116,11 @@ private void create() {
*/

this.buttonMulti = new ColorButton(this.gameContainer.textManager.getGame("LobbyControl_Multi"));
this.buttonMulti.setBounds(0, 77, this.height, 20);
this.buttonMulti.setBounds(0, 77, this.width, 20);
this.buttonMulti.addActionListener(this);
this.buttonQuit = new ColorButton(this.gameContainer.textManager.getGame("LobbyControl_Quit"));
this.buttonQuit.setBackground(GameApplet.colourButtonRed);
this.buttonQuit.setBounds(0, this.width - 20, this.height, 20);
this.buttonQuit.setBounds(0, this.height - 20, this.width, 20);
this.buttonQuit.addActionListener(this);
this.add(this.buttonQuit);
}
Expand Down
27 changes: 13 additions & 14 deletions client/src/main/java/agolf/lobby/LobbyPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import com.aapeli.multiuser.UserListItem;
import org.moparforia.client.Launcher;

import java.awt.Graphics;
import java.awt.Panel;
import java.awt.*;

public class LobbyPanel extends Panel {

Expand Down Expand Up @@ -40,13 +39,13 @@ public void addNotify() {
this.repaint();
}

public void paint(Graphics var1) {
this.update(var1);
public void paint(Graphics graphics) {
this.update(graphics);
}

public void update(Graphics var1) {
var1.setColor(GameApplet.colourGameBackground);
var1.fillRect(0, 0, this.width, this.height);
public void update(Graphics graphics) {
graphics.setColor(GameApplet.colourGameBackground);
graphics.fillRect(0, 0, this.width, this.height);
}

public void selectLobby(int lobbyId, int lobbyExtra) {
Expand Down Expand Up @@ -193,17 +192,17 @@ public void handlePacket(String[] args) {

}

public void broadcastMessage(String var1) {
public void broadcastMessage(String message) {
if (this.lobbyChatPanelSingle != null) {
this.lobbyChatPanelSingle.broadcastMessage(var1);
this.lobbyChatPanelSingle.broadcastMessage(message);
}

if (this.lobbyChatPanelDual != null) {
this.lobbyChatPanelDual.broadcastMessage(var1);
this.lobbyChatPanelDual.broadcastMessage(message);
}

if (this.lobbyChatPanelMulti != null) {
this.lobbyChatPanelMulti.broadcastMessage(var1);
this.lobbyChatPanelMulti.broadcastMessage(message);
}

}
Expand All @@ -224,9 +223,9 @@ protected void getUser(String name, boolean var2) {
this.lobbyChatPanelDual.getUser(name, var2);
}

protected boolean isNotAcceptingChallenges(String var1) {
UserListItem var2 = this.lobbyChatPanelDual.gui_userlist.getUser(var1);
return var2 != null ? var2.isNotAcceptingChallenges() : true;
protected boolean isNotAcceptingChallenges(String user) {
UserListItem userItem = this.lobbyChatPanelDual.userList.getUser(user);
return userItem != null ? userItem.isNotAcceptingChallenges() : true;
}

protected Choicer addChoicerNumTracks(Panel container, int x, int y, int width, int height) {
Expand Down
Loading

0 comments on commit b530afa

Please sign in to comment.