[Jrisk-cvs] SF.net SVN: domination-code:[2725] Domination
Brought to you by:
yuranet
|
From: <yu...@us...> - 2026-02-07 16:07:23
|
Revision: 2725
http://sourceforge.net/p/domination/code/2725
Author: yuranet
Date: 2026-02-07 16:07:20 +0000 (Sat, 07 Feb 2026)
Log Message:
-----------
dashbard added
Modified Paths:
--------------
Domination/ChangeLog.txt
Domination/sharedUI/src_mini_game_ui/net/yura/domination/mobile/flashgui/GameWindow.java
Domination/src/net/yura/domination/engine/RiskUtil.java
Domination/swingUI/src/net/yura/domination/guishared/PicturePanel.java
Domination/swingUI/src/net/yura/domination/guishared/RiskUIUtil.java
Modified: Domination/ChangeLog.txt
===================================================================
--- Domination/ChangeLog.txt 2026-02-07 13:54:39 UTC (rev 2724)
+++ Domination/ChangeLog.txt 2026-02-07 16:07:20 UTC (rev 2725)
@@ -13,11 +13,12 @@
Simple GUI: 2
Increment1GUI: 2
CommandLine: 2
-
-1.3.5
-
- Stats screen can be resized
+1.3.5
+
+ Dashboard added when game screen stretched wider
+ Stats screen can be resized
+
1.3.4 (13.03.2025) (svn rev 2664)
Accessibility GameGUI: Color Blind mode for the game
Modified: Domination/sharedUI/src_mini_game_ui/net/yura/domination/mobile/flashgui/GameWindow.java
===================================================================
--- Domination/sharedUI/src_mini_game_ui/net/yura/domination/mobile/flashgui/GameWindow.java 2026-02-07 13:54:39 UTC (rev 2724)
+++ Domination/sharedUI/src_mini_game_ui/net/yura/domination/mobile/flashgui/GameWindow.java 2026-02-07 16:07:20 UTC (rev 2725)
@@ -253,18 +253,35 @@
List<Player> players = myrisk.getGame().getPlayers();
Player current = myrisk.getGame().getCurrentPlayer();
g.setFont(font);
- final int x = font.getHeight();
- int y = font.getHeight();
- for (Player p : players) {
+ final int lineHeight = font.getHeight();
+ int y = lineHeight;
+
+ int xPadding = font.getWidth(" ");
+ String[][] data = RiskUtil.getDashboardText(myrisk.getGame());
+
+ // Compute max width for each column
+ int[] colWidths = new int[data[0].length];
+ for (String[] row : data) {
+ for (int j = 0; j < row.length; j++) {
+ colWidths[j] = Math.max(colWidths[j], font.getWidth(row[j]));
+ }
+ }
+
+ // Draw each row
+ for (int row = 0; row < data.length; row++) {
+ int x = font.getHeight();
+ Player p = players.get(row);
g.setColor(p.getColor());
- String emoji = p.isAlive() ? (p.getType() == Player.PLAYER_HUMAN ? "\ud83e\uddd1" : "\ud83e\udd16") : (p.getType() == Player.PLAYER_HUMAN ? "\ud83d\udc80" : "\ud83d\uddd1");
- String text = emoji + " " + p.getName() + " - " + p.getCards().size();
- g.drawString(text, x, y);
+ for (int col = 0; col < data[row].length; col++) {
+ g.drawString(data[row][col], x, y);
+ x += colWidths[col] + xPadding;
+ }
if (p == current) {
- int offset = x + font.getWidth(text) + x / 2;
- MoveDialog.drawArrow(g, offset + (int)(x * 1.5), offset, y, y + x, ARROW_COLOR);
+ g.setColor(0xFFFFFFFF);
+ String arrow = "\u25ba";
+ g.drawString(arrow, lineHeight - font.getWidth(arrow), y);
}
- y = y + x;
+ y += lineHeight;
}
}
}
Modified: Domination/src/net/yura/domination/engine/RiskUtil.java
===================================================================
--- Domination/src/net/yura/domination/engine/RiskUtil.java 2026-02-07 13:54:39 UTC (rev 2724)
+++ Domination/src/net/yura/domination/engine/RiskUtil.java 2026-02-07 16:07:20 UTC (rev 2725)
@@ -28,6 +28,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import net.yura.domination.engine.core.Continent;
+import net.yura.domination.engine.core.Player;
import net.yura.domination.engine.core.RiskGame;
import net.yura.domination.engine.translation.MapTranslator;
@@ -589,4 +590,25 @@
// if file starts with a dot, this is a hidden file, not an extension
return dotIndex > 0 ? filename.substring(0, dotIndex) : filename;
}
+
+ public static String[][] getDashboardText(RiskGame game) {
+ List<Player> players = game.getPlayers();
+ String[][] dashboard = new String[players.size()][];
+
+ for (int i = 0; i < players.size(); i++) {
+ Player p = players.get(i);
+
+ String card = "\ud83c\udcad";
+ String flag = "\u2691";
+ String army = "\uc6c3"; // happy face: \u263a
+ String extraArmies = "+";
+
+ String emoji = p.isAlive() ? (p.getType() == Player.PLAYER_HUMAN ? "\ud83e\uddd1" : "\ud83e\udd16") : (p.getType() == Player.PLAYER_HUMAN ? "\ud83d\udc80" : "\ud83d\uddd1");
+
+ int extra = game.getSetupDone() ? game.getExtraArmiesForPlayer(p) : p.getExtraArmies();
+
+ dashboard[i] = new String[] { emoji + " " + p.getName(), card + p.getCards().size(), flag + p.getNoTerritoriesOwned(), army + p.getNoArmies(), extraArmies + extra };
+ }
+ return dashboard;
+ }
}
Modified: Domination/swingUI/src/net/yura/domination/guishared/PicturePanel.java
===================================================================
--- Domination/swingUI/src/net/yura/domination/guishared/PicturePanel.java 2026-02-07 13:54:39 UTC (rev 2724)
+++ Domination/swingUI/src/net/yura/domination/guishared/PicturePanel.java 2026-02-07 16:07:20 UTC (rev 2725)
@@ -236,10 +236,11 @@
* @param g a Graphics object.
*/
public void paintComponent(Graphics g) {
-
super.paintComponent(g);
try {
+ g.setFont(getFont());
+ RiskUIUtil.drawDashboard(g, myrisk.getGame());
if (img != null) {
@@ -304,7 +305,10 @@
}
}
- catch(Exception e) { } // an excpetion here really does not matter
+ catch(Exception e) {
+ // an excpetion here really does not matter
+ Logger.getLogger(PicturePanel.class.getName()).info("error in paintComponent: " + e);
+ }
}
private int getDrawImageX(double ratio) {
Modified: Domination/swingUI/src/net/yura/domination/guishared/RiskUIUtil.java
===================================================================
--- Domination/swingUI/src/net/yura/domination/guishared/RiskUIUtil.java 2026-02-07 13:54:39 UTC (rev 2724)
+++ Domination/swingUI/src/net/yura/domination/guishared/RiskUIUtil.java 2026-02-07 16:07:20 UTC (rev 2725)
@@ -9,7 +9,9 @@
import java.awt.Dimension;
import java.awt.FileDialog;
import java.awt.Font;
+import java.awt.FontMetrics;
import java.awt.Frame;
+import java.awt.Graphics;
import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.Image;
@@ -78,6 +80,7 @@
import net.yura.domination.engine.RiskSettings;
import net.yura.domination.engine.RiskUtil;
import net.yura.domination.engine.ai.AIManager;
+import net.yura.domination.engine.core.Player;
import net.yura.domination.engine.core.RiskGame;
import net.yura.swing.BrowserLauncher;
import net.yura.swing.GraphicsUtil;
@@ -1623,4 +1626,51 @@
colorBlind = prefs.getBoolean(RiskSettings.COLOR_BLIND_KEY, false);
}
}
+
+ /**
+ * @see net.yura.domination.mobile.flashgui.GameWindow
+ */
+ public static void drawDashboard(Graphics g, RiskGame game) {
+
+ FontMetrics font = g.getFontMetrics();
+ List<Player> players = game.getPlayers();
+ Player current = game.getCurrentPlayer();
+
+ final int lineHeight = font.getHeight();
+ int y = lineHeight;
+
+ int xPadding = font.stringWidth(" ");
+ String[][] data = RiskUtil.getDashboardText(game);
+
+ // Compute max width for each column
+ int[] colWidths = new int[data[0].length];
+ for (String[] row : data) {
+ for (int j = 0; j < row.length; j++) {
+ colWidths[j] = Math.max(colWidths[j], font.stringWidth(row[j]));
+ }
+ }
+
+ // Draw each row
+ for (int row = 0; row < data.length; row++) {
+ int x = font.getHeight();
+ Player p = players.get(row);
+ if (p == current) {
+ g.setColor(Color.WHITE);
+ String arrow = "\u25ba";
+ g.drawString(arrow, lineHeight - font.stringWidth(arrow), y);
+ }
+ g.setColor(new Color(p.getColor()));
+ for (int col = 0; col < data[row].length; col++) {
+ g.drawString(data[row][col], x, y);
+ if (col == 0) {
+ x += lineHeight + font.stringWidth(" "); // player emoji width + space
+ y += lineHeight;
+ }
+ else {
+ x += colWidths[col] + xPadding;
+ }
+ }
+ y += lineHeight + xPadding;
+ }
+ }
}
|