Skip to content

Commit

Permalink
Add comments to GamePlayerInfoPanel UI drawing code
Browse files Browse the repository at this point in the history
  • Loading branch information
StenAL committed May 18, 2024
1 parent 36e3cb0 commit 8128b05
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions client/src/main/java/agolf/game/GamePlayerInfoPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,22 @@ public void update(Graphics g) {
this.graphics.fillRect(130 + this.currentTrackIndex * 20 - 5, offsetY - 13 + 1, 21, this.playerCount * 15 + 2 - 2);
}

// draw player status text
for (int player = 0; player < this.playerCount; ++player) {
Font font = this.playerId == player ? fontDialog12b : fontDialog12;
int playerLeft = this.playerLeaveReasons[player] == 0 ? 0 : 1;
Color color = playerColors[player][playerLeft];
this.graphics.setFont(font);
this.graphics.setColor(color);
if (this.playerCount > 1) {
if (this.playerCount > 1) { // draw 1., 2., etc in front of player name
this.graphics.drawString(player + 1 + ".", 2, offsetY);
}

if (this.playerNames[player] != null) {
if (this.playerNames[player] != null) { // draw player name
this.graphics.drawString(this.playerNames[player], 20, offsetY);
}

// draw track scores
for (int track = 0; track < this.trackCount; ++track) {
if (track <= this.currentTrackIndex) {
int strokes = this.trackStrokes[player][track].get();
Expand All @@ -158,11 +160,13 @@ public void update(Graphics g) {
}
}

// draw sum of player strokes
this.graphics.drawString("= " + this.playersId[player].get(), 130 + this.trackCount * 20 + 15, offsetY);
String playerInfo;

String playerInfo = null;
int[] scoreDifferences = this.getScoreDifferences();
// draw difference with leader's score
if (scoreDifferences != null && this.playerLeaveReasons[player] == 0) {
playerInfo = null;
if (scoreDifferences[player] == 0) {
if (this.gameOutcome == null) {
playerInfo = this.gameContainer.textManager.getGame("GamePlayerInfo_Leader");
Expand All @@ -178,6 +182,7 @@ public void update(Graphics g) {

playerInfo = null;
String timeRemaining = null;
// draw "waiting for player" text if lobby has empty slots
if (this.playerNames[player] == null) {
playerInfo = "GamePlayerInfo_WaitingPlayer";
}
Expand Down

0 comments on commit 8128b05

Please sign in to comment.