[Jrisk-cvs] SF.net SVN: domination-code:[2641] Domination
Brought to you by:
yuranet
|
From: <yu...@us...> - 2025-02-10 20:44:21
|
Revision: 2641
http://sourceforge.net/p/domination/code/2641
Author: yuranet
Date: 2025-02-10 20:44:18 +0000 (Mon, 10 Feb 2025)
Log Message:
-----------
show correct images in battle/move dialog
Modified Paths:
--------------
Domination/src/net/yura/domination/engine/Risk.java
Domination/swingUI/src/net/yura/domination/guishared/PicturePanel.java
Domination/swingUI/src/net/yura/domination/ui/flashgui/BattleDialog.java
Domination/swingUI/src/net/yura/domination/ui/flashgui/GameFrame.java
Domination/swingUI/src/net/yura/domination/ui/flashgui/MoveDialog.java
Modified: Domination/src/net/yura/domination/engine/Risk.java
===================================================================
--- Domination/src/net/yura/domination/engine/Risk.java 2025-02-10 09:30:43 UTC (rev 2640)
+++ Domination/src/net/yura/domination/engine/Risk.java 2025-02-10 20:44:18 UTC (rev 2641)
@@ -2593,11 +2593,11 @@
/**
* Get the name of the country from the game
- * @param c The (unique) country identifier
+ * @param color The (unique) country identifier
* @return String Return Country name if it is there, else return empty speech-marks otherwise
*/
- public String getCountryName(int c) {
- Country t = game.getCountryInt(c);
+ public String getCountryName(int color) {
+ Country t = game.getCountryInt(color);
if (t==null) {
return "";
} else {
@@ -2605,8 +2605,8 @@
}
}
- public Player getCountryCapital(int c) {
- Country t = game.getCountryInt(c);
+ public Player getCountryCapital(int color) {
+ Country t = game.getCountryInt(color);
List<Player> players = game.getPlayers();
for (Player player: players) {
if (player.getCapital() == t) {
Modified: Domination/swingUI/src/net/yura/domination/guishared/PicturePanel.java
===================================================================
--- Domination/swingUI/src/net/yura/domination/guishared/PicturePanel.java 2025-02-10 09:30:43 UTC (rev 2640)
+++ Domination/swingUI/src/net/yura/domination/guishared/PicturePanel.java 2025-02-10 20:44:18 UTC (rev 2641)
@@ -444,17 +444,17 @@
y = (int)ballWorld.balls[c].y;
}
- drawArmy(this, g2, t.getOwner().getColor(), t.getArmies(), x, y, BALL_SIZE, capitals.get(t));
+ drawArmy(g2, t.getOwner().getColor(), t.getArmies(), x, y, BALL_SIZE, capitals.get(t));
}
}
}
- public static void drawArmy(PicturePanel pp, Graphics2D g2, int countryOwnerColor, int armies, int x, int y, int ballSize, Player capital) {
+ public void drawArmy(Graphics2D g2, int countryOwnerColor, int armies, int x, int y, int ballSize, Player capital) {
int r = ballSize / 2;
- Image icon = pp.getIconForColor(countryOwnerColor);
+ Image icon = getIconForColor(countryOwnerColor);
if (icon == null) {
- g2.setColor( new Color( countryOwnerColor ) );
+ g2.setColor(new Color(countryOwnerColor));
Ellipse2D ellipse = new Ellipse2D.Double();
ellipse.setFrame( x-r , y-r , ballSize, ballSize);
g2.fill(ellipse);
@@ -462,11 +462,11 @@
}
else {
int w = (int)(ballSize * 1.1);
- int h = (int)(icon.getHeight(pp) * (w / (double)icon.getWidth(pp)));
- g2.drawImage(icon, x-(w/2), y-(w/2), w, h, pp);
+ int h = (int)(icon.getHeight(this) * (w / (double)icon.getWidth(this)));
+ g2.drawImage(icon, x-(w/2), y-(w/2), w, h, this);
}
- g2.setColor( new Color( ColorUtil.getTextColorFor( countryOwnerColor ) ) );
+ g2.setColor(new Color(ColorUtil.getTextColorFor(countryOwnerColor)));
String noa = String.valueOf( armies );
int w2 = g2.getFontMetrics().stringWidth(noa) / 2;
int h2 = g2.getFontMetrics().getAscent()*2/5 ;
Modified: Domination/swingUI/src/net/yura/domination/ui/flashgui/BattleDialog.java
===================================================================
--- Domination/swingUI/src/net/yura/domination/ui/flashgui/BattleDialog.java 2025-02-10 09:30:43 UTC (rev 2640)
+++ Domination/swingUI/src/net/yura/domination/ui/flashgui/BattleDialog.java 2025-02-10 20:44:18 UTC (rev 2641)
@@ -357,9 +357,11 @@
MoveDialog.paintMove(g,
c1img, c2img,
- color1, color2,
+ color1, color2,
+ gui.getCountryCapital(country1), gui.getCountryCapital(country2),
country1.getName(), country2.getName(),
- myrisk.hasArmiesInt(c1num),myrisk.hasArmiesInt(c2num) );
+ myrisk.hasArmiesInt(c1num), myrisk.hasArmiesInt(c2num),
+ gui);
g.setColor( Color.BLACK );
GraphicsUtil.drawStringCenteredAt(g, resb.getString("battle.select.dice"), 240, 320);
Modified: Domination/swingUI/src/net/yura/domination/ui/flashgui/GameFrame.java
===================================================================
--- Domination/swingUI/src/net/yura/domination/ui/flashgui/GameFrame.java 2025-02-10 09:30:43 UTC (rev 2640)
+++ Domination/swingUI/src/net/yura/domination/ui/flashgui/GameFrame.java 2025-02-10 20:44:18 UTC (rev 2641)
@@ -908,7 +908,15 @@
public BufferedImage getCountryImage(int a) {
return pp.getCountryImage(a, true);
}
+
+ public Player getCountryCapital(Country c) {
+ return myrisk.getCountryCapital(c.getColor());
+ }
+ public void drawArmy(Graphics2D g2, Color countryOwnerColor, int armies, int x, int y, int ballSize, Player capital) {
+ pp.drawArmy(g2, countryOwnerColor.getRGB(), armies, GraphicsUtil.scale(x), GraphicsUtil.scale(y), GraphicsUtil.scale(ballSize), capital);
+ }
+
public void openMove(int min, int c1num, int c2num, boolean tacmove) {
int src = myrisk.hasArmiesInt( c1num );
Modified: Domination/swingUI/src/net/yura/domination/ui/flashgui/MoveDialog.java
===================================================================
--- Domination/swingUI/src/net/yura/domination/ui/flashgui/MoveDialog.java 2025-02-10 09:30:43 UTC (rev 2640)
+++ Domination/swingUI/src/net/yura/domination/ui/flashgui/MoveDialog.java 2025-02-10 20:44:18 UTC (rev 2641)
@@ -22,6 +22,7 @@
import net.yura.domination.audio.GameSound;
import net.yura.domination.guishared.RiskUIUtil;
import net.yura.domination.engine.core.Country;
+import net.yura.domination.engine.core.Player;
import net.yura.swing.GraphicsUtil;
import net.yura.domination.engine.translation.TranslationBundle;
@@ -300,8 +301,9 @@
paintMove(g,
c1img, c2img,
color, color,
+ gui.getCountryCapital(country1), gui.getCountryCapital(country2),
country1.getName(), country2.getName(),
- csrc-move,cdes+move );
+ csrc - move, cdes + move, gui);
g.setColor( RiskUIUtil.getTextColorFor(color) );
GraphicsUtil.drawStringCenteredAt(g, java.lang.Integer.toString(move), 240, 104);
@@ -309,36 +311,36 @@
}
static void paintMove(Graphics g,
- BufferedImage c1img,BufferedImage c2img,
- Color color1, Color color2,
- String name1,String name2,
- int noa1i, int noa2i
- ) {
- Graphics2D g2 = (Graphics2D)g;
- g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ BufferedImage c1img,BufferedImage c2img,
+ Color playerColor1, Color playerColor2,
+ Player capital1,Player capital2,
+ String name1, String name2,
+ int noa1i, int noa2i, GameFrame gf) {
- GraphicsUtil.drawImageInRect(g2, c1img, 30, 30, 200, 140, null);
- GraphicsUtil.drawImageInRect(g2, c2img, 250, 30, 200, 140, null);
+ Graphics2D g2 = (Graphics2D)g;
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- g2.setColor( Color.black );
+ GraphicsUtil.drawImageInRect(g2, c1img, 30, 30, 200, 140, null);
+ GraphicsUtil.drawImageInRect(g2, c2img, 250, 30, 200, 140, null);
- GraphicsUtil.drawStringCenteredAt(g, name1, 130, 40);
- GraphicsUtil.drawStringCenteredAt(g, name2, 350, 40);
+ g2.setColor( Color.black );
- g2.setColor( color1 );
- GraphicsUtil.fillOval(g, 120 , 90 , 20, 20);
+ GraphicsUtil.drawStringCenteredAt(g, name1, 130, 40);
+ GraphicsUtil.drawStringCenteredAt(g, name2, 350, 40);
- g2.setColor( color2 );
- GraphicsUtil.fillOval(g, 340 , 90 , 20, 20);
+ gf.drawArmy(g2, playerColor1, noa1i, 130, 100, 20, capital1);
+ //g2.setColor(color1);
+ //GraphicsUtil.fillOval(g, 120 , 90 , 20, 20);
+ //g2.setColor(RiskUIUtil.getTextColorFor(color1));
+ //GraphicsUtil.drawStringCenteredAt(g, String.valueOf(noa1i), 130, 105);
- g2.setColor( new Color(color1.getRed(), color1.getGreen(), color1.getBlue(), 150) );
+ gf.drawArmy(g2, playerColor2, noa2i, 350, 100, 20, capital2);
+ //g2.setColor(color2);
+ //GraphicsUtil.fillOval(g, 340 , 90 , 20, 20);
+ //g2.setColor(RiskUIUtil.getTextColorFor(color2));
+ //GraphicsUtil.drawStringCenteredAt(g, String.valueOf(noa2i), 350, 105);
- g2.fillPolygon( arrow );
-
- g2.setColor( RiskUIUtil.getTextColorFor(color1) );
- GraphicsUtil.drawStringCenteredAt(g, String.valueOf(noa1i), 130, 105);
-
- g2.setColor( RiskUIUtil.getTextColorFor(color2) );
- GraphicsUtil.drawStringCenteredAt(g, String.valueOf(noa2i), 350, 105);
+ g2.setColor(new Color(playerColor1.getRed(), playerColor1.getGreen(), playerColor1.getBlue(), 150) );
+ g2.fillPolygon( arrow );
}
}
|