Skip to content

Commit

Permalink
Merge pull request #110 from StenAL/features
Browse files Browse the repository at this point in the history
Paint everything in the middle of the applet
  • Loading branch information
PhilippvK authored May 31, 2024
2 parents ee9374e + 3a6fe29 commit db5983e
Show file tree
Hide file tree
Showing 11 changed files with 291 additions and 265 deletions.
31 changes: 16 additions & 15 deletions client/src/main/java/agolf/GameApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import com.aapeli.client.*;
import org.moparforia.client.Launcher;

import java.applet.Applet;
import java.applet.AudioClip;
import java.awt.*;
import java.net.URL;

public class GameApplet extends AApplet {

Expand All @@ -29,7 +26,7 @@ public class GameApplet extends AApplet {
public static final Font fontDialog12 = new Font("Dialog", 0, 12);
public static final Font fontDialog11 = new Font("Dialog", 0, 11);
private GameContainer gameContainer;
private int anInt3769;
private int activePanel;
private SynchronizedBool syncUnknownBool;
private SynchronizedInteger syncPlayerAccessLevel;
private boolean disableGuestChat;
Expand Down Expand Up @@ -112,7 +109,7 @@ public boolean isDebug() {
}

protected int method32() {
return this.anInt3769;
return this.activePanel;
}

public void setGameState(int state) {
Expand All @@ -123,15 +120,19 @@ protected void setGameState(int state, int lobbyId) {
this.setGameState(state, lobbyId, 0);
}

protected void setGameState(int panelActive, int lobbyId, int lobbyExtra) {
if (panelActive != this.anInt3769 && this.syncIsValidSite.get()) {
this.anInt3769 = panelActive;
/**
* @param activePanel 0 == ?, 1 == login, 2 == lobby selection panel, 3 == in lobby, 4 == in game
* @param lobbyId game type, single player == 1, dual player == 2, multiplayer == 3
*/
protected void setGameState(int activePanel, int lobbyId, int lobbyExtra) {
if (activePanel != this.activePanel && this.syncIsValidSite.get()) {
this.activePanel = activePanel;
if (this.gameContainer.lobbySelectionPanel != null) {
this.gameContainer.lobbySelectionPanel.destroyRNOP();
}

this.clearContent();
if (panelActive == 1) {
if (activePanel == 1) {
if (this.aBoolean3773) {
super.param.removeSession();
} else {
Expand All @@ -151,16 +152,16 @@ protected void setGameState(int panelActive, int lobbyId, int lobbyExtra) {
} else if (this.hasSession()) {
super.param.noGuestAutoLogin();
this.gameContainer.connection.writeData("login\t" + super.param.getSession());
this.anInt3769 = 0;
this.activePanel = 0;
} else if (!this.gameContainer.synchronizedTrackTestMode.get()) {
this.gameContainer.connection.writeData("login");
this.anInt3769 = 0;
this.activePanel = 0;
} else {

}
}

if (panelActive == 2) {
if (activePanel == 2) {
if (this.gameContainer.lobbySelectionPanel == null) {
this.gameContainer.lobbySelectionPanel = new LobbySelectPanel(this.gameContainer, super.appletWidth, super.appletHeight);
this.gameContainer.lobbySelectionPanel.setLocation(0, 0);
Expand All @@ -187,7 +188,7 @@ protected void setGameState(int panelActive, int lobbyId, int lobbyExtra) {
}
}

if (panelActive == 3) {
if (activePanel == 3) {
this.gameContainer.gamePanel = null;
if (this.gameContainer.lobbyPanel == null) {
this.gameContainer.lobbyPanel = new LobbyPanel(this.gameContainer, super.appletWidth, super.appletHeight);
Expand All @@ -205,13 +206,13 @@ protected void setGameState(int panelActive, int lobbyId, int lobbyExtra) {
this.addToContent(this.gameContainer.lobbyPanel);
}

if (panelActive == 4) {
if (activePanel == 4) {
this.gameContainer.gamePanel = new GamePanel(this.gameContainer, super.appletWidth, super.appletHeight, this.anImage3774);
this.gameContainer.gamePanel.setLocation(0, 0);
this.addToContent(this.gameContainer.gamePanel);
}

if (panelActive == 5) {
if (activePanel == 5) {
//super.param.showQuitPage();
System.exit(0);
} else {
Expand Down
38 changes: 26 additions & 12 deletions client/src/main/java/agolf/LobbySelectPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import java.awt.Color;
import java.awt.Graphics;
import java.awt.LayoutManager;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
Expand All @@ -34,6 +33,7 @@ public class LobbySelectPanel extends Panel implements ActionListener, MouseList
private ColorButton buttonQuit;
private ColorCheckbox checkboxPlayHidden;
private Choicer choicerGraphics;
private Choicer audioChoicer;
private int[] lobbyNumPlayers;
private LobbySelectRNOPspammer lobbySelectRNOP;
private static final String[] aStringArray544 = new String[22];
Expand Down Expand Up @@ -139,7 +139,12 @@ else if (evtSource == this.buttonDual) {
}

public void itemStateChanged(ItemEvent evt) {
this.gameContainer.graphicsQualityIndex = this.choicerGraphics.getSelectedIndex();
Object source = evt.getSource();
if (source == this.choicerGraphics) {
this.gameContainer.graphicsQualityIndex = this.choicerGraphics.getSelectedIndex();
} else if (source == this.audioChoicer) {
this.gameContainer.soundManager.audioChoicerIndex = this.audioChoicer.getSelectedIndex();
}
}

public static String getLobbySelectMessage(int lobbyId) {
Expand Down Expand Up @@ -209,7 +214,7 @@ protected void writeData(String var1) {
}

private void create() {
this.setLayout((LayoutManager) null);
this.setLayout(null);
this.checkboxPlayHidden = new ColorCheckbox(this.gameContainer.textManager.getGame("LobbySelect_PlayHidden"));
this.checkboxPlayHidden.setBounds(this.width / 6 - 75 - 10, this.height - 124, 220, 18);
this.checkboxPlayHidden.setBackground(GameApplet.colourGameBackground);
Expand All @@ -226,34 +231,43 @@ private void create() {
this.add(this.buttonSingleQuick);
}



//this.buttonDual = new ColorButton(this.gameContainer.textManager.getGame("LobbySelect_DualPlayer"));
this.buttonDual = new ColorButton("Coming soon...");
this.buttonDual.setBounds(this.width * 3 / 6 - 75, this.height - 150, 150, 25);
//this.buttonDual.addActionListener(this);
this.add(this.buttonDual);


this.buttonMulti = new ColorButton(this.gameContainer.textManager.getGame("LobbySelect_MultiPlayer"));
this.buttonMulti.setBounds(this.width * 5 / 6 - 75, this.height - 150, 150, 25);
this.buttonMulti.addActionListener(this);
this.add(this.buttonMulti);

this.buttonMultiQuick = new ColorButton(this.gameContainer.textManager.getGame("LobbySelect_QuickStart"));
this.buttonMultiQuick.setBackground(GameApplet.colourButtonBlue);
this.buttonMultiQuick.setBounds(this.width * 5 / 6 - 50, this.height - 95, 100, 20);
this.buttonMultiQuick.addActionListener(this);
this.add(this.buttonMultiQuick);
String text = this.gameContainer.textManager.getGame("LobbySelect_Gfx");

String graphicsOptionText = this.gameContainer.textManager.getGame("LobbySelect_Gfx");
this.choicerGraphics = new Choicer();
this.choicerGraphics.addItem(text + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx0"));
this.choicerGraphics.addItem(text + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx1"));
this.choicerGraphics.addItem(text + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx2"));
this.choicerGraphics.addItem(text + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx3"));
this.choicerGraphics.addItem(graphicsOptionText + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx0"));
this.choicerGraphics.addItem(graphicsOptionText + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx1"));
this.choicerGraphics.addItem(graphicsOptionText + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx2"));
this.choicerGraphics.addItem(graphicsOptionText + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx3"));
this.choicerGraphics.select(this.gameContainer.graphicsQualityIndex);
this.choicerGraphics.setBounds(this.width / 3 - 100, this.height - 10 - 20, 200, 20);
this.choicerGraphics.setBounds(this.width / 3 - 100, this.height - 10 - 50, 200, 20);
this.choicerGraphics.addItemListener(this);
this.add(this.choicerGraphics);

String audioOptionsText = "Audio:";
this.audioChoicer = new Choicer();
this.audioChoicer.addItem(audioOptionsText + " On");
this.audioChoicer.addItem(audioOptionsText + " Off");
this.audioChoicer.select(this.gameContainer.soundManager.audioChoicerIndex);
this.audioChoicer.setBounds(this.width / 3 - 100, this.height - 10 - 20, 200, 20);
this.audioChoicer.addItemListener(this);
this.add(this.audioChoicer);

this.buttonQuit = new ColorButton(this.gameContainer.textManager.getGame("LobbySelect_Quit"));
this.buttonQuit.setBackground(GameApplet.colourButtonRed);
this.buttonQuit.setBounds(this.width * 2 / 3 - 50, this.height - 10 - 20, 100, 20);
Expand Down
Loading

0 comments on commit db5983e

Please sign in to comment.