Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify and clean up resource loading #132

Merged
merged 9 commits into from
Jan 22, 2025
32 changes: 16 additions & 16 deletions client/src/main/java/agolf/GolfGameFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,25 @@ public void defineSounds(SoundManager soundManager) {

public void defineImages(ImageManager imageManager) {
this.gameContainer.imageManager = imageManager;
imageManager.defineGameImage("bg-lobbyselect.gif");
imageManager.defineGameImage("bg-lobby-single.gif");
imageManager.defineGameImage("bg-lobby-single-fade.jpg");
imageManager.defineGameImage("bg-lobby-dual.gif");
imageManager.defineGameImage("bg-lobby-multi.gif");
imageManager.defineGameImage("bg-lobby-multi-fade.jpg");
imageManager.defineGameImage("bg-lobby-password.gif");
imageManager.defineGameImage("shapes.gif");
imageManager.defineGameImage("elements.gif");
imageManager.defineGameImage("special.gif");
imageManager.defineGameImage("balls.gif");
imageManager.defineSharedImage("ranking-icons.gif");
imageManager.defineSharedImage("language-flags.png");
imageManager.defineSharedImage("credit-background.jpg");
imageManager.defineSharedImage("tf-background.gif");
imageManager.defineImage("bg-lobbyselect.gif");
imageManager.defineImage("bg-lobby-single.gif");
imageManager.defineImage("bg-lobby-single-fade.jpg");
imageManager.defineImage("bg-lobby-dual.gif");
imageManager.defineImage("bg-lobby-multi.gif");
imageManager.defineImage("bg-lobby-multi-fade.jpg");
imageManager.defineImage("bg-lobby-password.gif");
imageManager.defineImage("shapes.gif");
imageManager.defineImage("elements.gif");
imageManager.defineImage("special.gif");
imageManager.defineImage("balls.gif");
imageManager.defineImage("ranking-icons.gif");
imageManager.defineImage("language-flags.png");
imageManager.defineImage("credit-background.jpg");
imageManager.defineImage("tf-background.gif");

for (int i = 0; i < GameBackgroundCanvas.trackAdvertSize; ++i) {
if (this.gameContainer.adverts[i] != null) {
imageManager.defineGameImage("ad" + i, this.gameContainer.adverts[i]);
imageManager.defineImage("ad" + i, this.gameContainer.adverts[i]);
}
}
}
Expand Down
38 changes: 19 additions & 19 deletions client/src/main/java/agolf/LobbySelectPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ public void paint(Graphics g) {
}

public void update(Graphics g) {
g.drawImage(this.gameContainer.imageManager.getGameImage("bg-lobbyselect"), 0, 0, this);
g.drawImage(this.gameContainer.imageManager.getImage("bg-lobbyselect"), 0, 0, this);
g.setColor(Color.black);
g.setFont(GolfGameFrame.fontSerif26b);
if (!this.gameContainer.disableSinglePlayer) {
StringDraw.drawString(
g, this.gameContainer.textManager.getGame("LobbySelect_SinglePlayer"), this.width / 6, 70, 0);
g, this.gameContainer.textManager.getText("LobbySelect_SinglePlayer"), this.width / 6, 70, 0);
}

StringDraw.drawString(
g, this.gameContainer.textManager.getGame("LobbySelect_DualPlayer"), this.width * 3 / 6, 70, 0);
g, this.gameContainer.textManager.getText("LobbySelect_DualPlayer"), this.width * 3 / 6, 70, 0);
StringDraw.drawString(
g, this.gameContainer.textManager.getGame("LobbySelect_MultiPlayer"), this.width * 5 / 6, 70, 0);
g, this.gameContainer.textManager.getText("LobbySelect_MultiPlayer"), this.width * 5 / 6, 70, 0);
g.setFont(GolfGameFrame.fontDialog12);
if (!this.gameContainer.disableSinglePlayer) {
this.drawNumPlayers(g, this.width / 6, this.lobbyNumPlayers[0]);
Expand Down Expand Up @@ -207,16 +207,16 @@ protected void writeData(String var1) {

private void create() {
this.setLayout(null);
this.checkboxPlayHidden = new ColorCheckbox(this.gameContainer.textManager.getGame("LobbySelect_PlayHidden"));
this.checkboxPlayHidden = new ColorCheckbox(this.gameContainer.textManager.getText("LobbySelect_PlayHidden"));
this.checkboxPlayHidden.setBounds(this.width / 6 - 75 - 10, this.height - 124, 220, 18);
this.checkboxPlayHidden.setBackground(GolfGameFrame.colourGameBackground);
if (!this.gameContainer.disableSinglePlayer) {
this.add(this.checkboxPlayHidden);
this.buttonSingle = new ColorButton(this.gameContainer.textManager.getGame("LobbySelect_SinglePlayer"));
this.buttonSingle = new ColorButton(this.gameContainer.textManager.getText("LobbySelect_SinglePlayer"));
this.buttonSingle.setBounds(this.width / 6 - 75, this.height - 150, 150, 25);
this.buttonSingle.addActionListener(this);
this.add(this.buttonSingle);
this.buttonSingleQuick = new ColorButton(this.gameContainer.textManager.getGame("LobbySelect_QuickStart"));
this.buttonSingleQuick = new ColorButton(this.gameContainer.textManager.getText("LobbySelect_QuickStart"));
this.buttonSingleQuick.setBackground(GolfGameFrame.colourButtonBlue);
this.buttonSingleQuick.setBounds(this.width / 6 - 50, this.height - 95, 100, 20);
this.buttonSingleQuick.addActionListener(this);
Expand All @@ -230,27 +230,27 @@ private void create() {
// this.buttonDual.addActionListener(this);
this.add(this.buttonDual);

this.buttonMulti = new ColorButton(this.gameContainer.textManager.getGame("LobbySelect_MultiPlayer"));
this.buttonMulti = new ColorButton(this.gameContainer.textManager.getText("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 = new ColorButton(this.gameContainer.textManager.getText("LobbySelect_QuickStart"));
this.buttonMultiQuick.setBackground(GolfGameFrame.colourButtonBlue);
this.buttonMultiQuick.setBounds(this.width * 5 / 6 - 50, this.height - 95, 100, 20);
this.buttonMultiQuick.addActionListener(this);
this.add(this.buttonMultiQuick);

String graphicsOptionText = this.gameContainer.textManager.getGame("LobbySelect_Gfx");
String graphicsOptionText = this.gameContainer.textManager.getText("LobbySelect_Gfx");
this.choicerGraphics = new Choicer();
this.choicerGraphics.addItem(
graphicsOptionText + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx0"));
graphicsOptionText + " " + this.gameContainer.textManager.getText("LobbySelect_Gfx0"));
this.choicerGraphics.addItem(
graphicsOptionText + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx1"));
graphicsOptionText + " " + this.gameContainer.textManager.getText("LobbySelect_Gfx1"));
this.choicerGraphics.addItem(
graphicsOptionText + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx2"));
graphicsOptionText + " " + this.gameContainer.textManager.getText("LobbySelect_Gfx2"));
this.choicerGraphics.addItem(
graphicsOptionText + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx3"));
graphicsOptionText + " " + this.gameContainer.textManager.getText("LobbySelect_Gfx3"));
this.choicerGraphics.select(this.gameContainer.graphicsQualityIndex);
this.choicerGraphics.setBounds(this.width / 3 - 100, this.height - 10 - 50, 200, 20);
this.choicerGraphics.addItemListener(this);
Expand All @@ -265,7 +265,7 @@ private void create() {
this.audioChoicer.addItemListener(this);
this.add(this.audioChoicer);

this.buttonQuit = new ColorButton(this.gameContainer.textManager.getGame("LobbySelect_Quit"));
this.buttonQuit = new ColorButton(this.gameContainer.textManager.getText("LobbySelect_Quit"));
this.buttonQuit.setBackground(GolfGameFrame.colourButtonRed);
this.buttonQuit.setBounds(this.width * 2 / 3 - 50, this.height - 10 - 20, 100, 20);
this.buttonQuit.addActionListener(this);
Expand All @@ -276,16 +276,16 @@ private void drawNumPlayers(Graphics g, int x, int numPlayers) {
if (numPlayers != -1) {
String text = null;
if (numPlayers == 0) {
text = this.gameContainer.textManager.getGame("LobbySelect_Players0");
text = this.gameContainer.textManager.getText("LobbySelect_Players0");
} else if (numPlayers == 1) {
text = this.gameContainer.textManager.getGame("LobbySelect_Players1");
text = this.gameContainer.textManager.getText("LobbySelect_Players1");
} else if (numPlayers >= 2) {
text = this.gameContainer.textManager.getGame("LobbySelect_PlayersX", numPlayers);
text = this.gameContainer.textManager.getText("LobbySelect_PlayersX", numPlayers);
}

StringDraw.drawString(g, text, x, 110, 0);
if (numPlayers >= this.lobbyMaxPlayers && this.gameContainer.golfGameFrame.getPlayerAccessLevel() == 0) {
StringDraw.drawString(g, this.gameContainer.textManager.getGame("LobbySelect_Full"), x, 130, 0);
StringDraw.drawString(g, this.gameContainer.textManager.getText("LobbySelect_Full"), x, 130, 0);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions client/src/main/java/agolf/SpriteManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ protected void loadSprites() {
for (int var1 = 0; var1 < GameBackgroundCanvas.trackAdvertSize; ++var1) {
try {
String var2 = "ad" + var1;
Image var3 = this.imageManager.getGameImage(var2);
Image var3 = this.imageManager.getImage(var2);
if (var3 != null) {
this.imageManager.unloadGameImage(var2);
this.imageManager.unloadImage(var2);
this.anIntArrayArray968[var1] = this.imageManager.getPixels(
var3,
GameBackgroundCanvas.anIntArray78[var1] * 15,
Expand Down Expand Up @@ -98,8 +98,8 @@ public int[][] method1138() {

private Image[] parseSpriteSheet(
String spriteSheetName, int spriteCount, int spritesPerRow, int spriteWidth, int spriteHeight) {
Image spriteSheet = this.imageManager.getGameImage(spriteSheetName);
this.imageManager.unloadGameImage(spriteSheetName);
Image spriteSheet = this.imageManager.getImage(spriteSheetName);
this.imageManager.unloadImage(spriteSheetName);
int sheetWidth = this.imageManager.getWidth(spriteSheet);
int sheetHeight = this.imageManager.getHeight(spriteSheet);

Expand Down
4 changes: 2 additions & 2 deletions client/src/main/java/agolf/game/ChatPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ private void create() {
new Font("Dialog", Font.PLAIN, 11));
this.textAreaChat.setLocation(0, 0);
this.textFieldMessage =
new InputTextField(this.gameContainer.textManager.getGame("GameChat_TypeHere"), 200, true);
new InputTextField(this.gameContainer.textManager.getText("GameChat_TypeHere"), 200, true);
this.textFieldMessage.setBounds(0, this.height - 20, this.width - 70, 20);
this.buttonSay = new ColorButton(this.gameContainer.textManager.getGame("GameChat_Say"));
this.buttonSay = new ColorButton(this.gameContainer.textManager.getText("GameChat_Say"));
this.buttonSay.setBounds(this.width - 69, this.height - 20, 69, 20);
this.buttonSay.setBackground(GolfGameFrame.colourButtonBlue);
if (this.gameExtra > 0) {
Expand Down
8 changes: 4 additions & 4 deletions client/src/main/java/agolf/game/GameControlPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ protected void setState(int state) {
this.removeAll();
this.skipButtonVisible = false;
if (state == 2) {
this.buttonNewGame = new ColorButton(this.gameContainer.textManager.getGame("GameControl_New"));
this.buttonNewGame = new ColorButton(this.gameContainer.textManager.getText("GameControl_New"));
this.buttonNewGame.setBounds(0, this.anInt343 - 55, this.anInt342, 25);
this.buttonNewGame.setBackground(GolfGameFrame.colourButtonGreen);
this.buttonNewGame.setForeground(GolfGameFrame.colourTextBlack);
this.buttonNewGame.addActionListener(this);
this.add(this.buttonNewGame);
} else {
this.buttonSkip = new ColorButton(this.gameContainer.textManager.getGame("GameControl_Skip"));
this.buttonSkip = new ColorButton(this.gameContainer.textManager.getText("GameControl_Skip"));
this.buttonSkip.setBounds(0, this.anInt343 - 55, this.anInt342, 25);
this.buttonSkip.setBackground(GolfGameFrame.colourButtonBlue);
this.buttonSkip.setForeground(GolfGameFrame.colourTextBlack);
Expand All @@ -129,7 +129,7 @@ protected void setState(int state) {

for (int option = 0; option < 4; ++option) {
this.playerNamesDisplayModeChoicer.addItem(
this.gameContainer.textManager.getGame("GameControl_Names" + option));
this.gameContainer.textManager.getText("GameControl_Names" + option));
}

this.playerNamesDisplayModeChoicer.select(this.playerCount <= 2 ? 0 : 3);
Expand All @@ -139,7 +139,7 @@ protected void setState(int state) {
}
}

this.buttonBack = new ColorButton(this.gameContainer.textManager.getGame("GameControl_Back"));
this.buttonBack = new ColorButton(this.gameContainer.textManager.getText("GameControl_Back"));
this.buttonBack.setBounds(0, this.anInt343 - 25, this.anInt342, 25);
this.buttonBack.setBackground(GolfGameFrame.colourButtonYellow);
this.buttonBack.setForeground(GolfGameFrame.colourTextBlack);
Expand Down
Loading
Loading