|
From: Frederick W. <fre...@us...> - 2012-02-11 18:42:22
|
LocalisedText.properties | 2
data/GamesList.xml | 63 +++++++-------
data/Properties.xml | 4
rails/ui/images/Train.png |binary
rails/ui/images/accept.png |binary
rails/ui/images/arrow_redo.png |binary
rails/ui/images/arrow_undo.png |binary
rails/ui/images/auction_hammer_gavel.png |binary
rails/ui/images/bricks.png |binary
rails/ui/images/button.png |binary
rails/ui/images/cash_stack.png |binary
rails/ui/images/clock_add.png |binary
rails/ui/images/clock_delete.png |binary
rails/ui/images/coins_in_hand.png |binary
rails/ui/images/control_fastforward_blue.png |binary
rails/ui/images/control_play_blue.png |binary
rails/ui/images/globe_model.png |binary
rails/ui/images/hand_property.png |binary
rails/ui/images/information.png |binary
rails/ui/images/money_add.png |binary
rails/ui/images/money_bag.png |binary
rails/ui/images/participation_rate.png |binary
rails/ui/images/rails32.png |binary
rails/ui/images/script.png |binary
rails/ui/images/traffic_lights_green.png |binary
rails/ui/images/traffic_lights_red.png |binary
rails/ui/images/traffic_lights_yellow.png |binary
rails/ui/swing/ConfigWindow.java | 2
rails/ui/swing/GameSetupWindow.java | 2
rails/ui/swing/ORPanel.java | 28 +++---
rails/ui/swing/ORWindow.java | 12 +-
rails/ui/swing/ReportWindowDynamic.java | 5 -
rails/ui/swing/StartRoundWindow.java | 12 +-
rails/ui/swing/StatusWindow.java | 14 +--
rails/ui/swing/elements/ActionButton.java | 100 ++++++++++++++++++++++
rails/ui/swing/elements/DockingFrame.java | 5 -
rails/ui/swing/elements/RailsIcon.java | 119 +++++++++++++++++++++++++--
37 files changed, 290 insertions(+), 78 deletions(-)
New commits:
commit b7e95f18296f06fcce810682b89a542608ce5b71
Author: Frederick Weld <fre...@gm...>
Date: Sat Feb 11 19:39:51 2012 +0100
Included and pre-configured icon set for action buttons and dockables
Attribution now part of the credits.
diff --git a/data/GamesList.xml b/data/GamesList.xml
index 10d120d..3b6b2c5 100644
--- a/data/GamesList.xml
+++ b/data/GamesList.xml
@@ -315,33 +315,38 @@ Known Issues:
</Game>
- <Credits>Rails is a computer implementation of a number of board games.
- These games all have a railroad theme. They are collectively known as "18xx"
- games due to the naming scheme used by many games in the genre.
-
-Contributors:
- Erik Vos
- Stefan Frey
- Freek Dijkstra
- Scott Peterson
- Adam Badura
- Phil Davies
- Bill Rosgen
- Martin Brumm
- Chris Shaffer
- Brett Lentz
-
-All rights reserved by the respective owners of the original games
-(see the Game Notes per game for specific acknowledgements).
-
-No challenge to the original author's or publisher's rights, licensing, or status is intended.
-
-Rails is intended as a play aid for owners of each respective boardgame.
-
-The Rails application and source code are distributed under
-version 2 of the GNU Public License (GPL).
-
-A copy of the GPL should have been shipped with the game files and is also available here:
- http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
- </Credits>
+ <Credits><html>Rails is a computer implementation of a number of board games.<br>
+ These games all have a railroad theme. They are collectively known as "18xx" <br>
+ games due to the naming scheme used by many games in the genre. <br>
+ <br>
+Contributors: <br>
+ Erik Vos<br>
+ Stefan Frey<br>
+ Freek Dijkstra<br>
+ Scott Peterson<br>
+ Adam Badura<br>
+ Phil Davies<br>
+ Bill Rosgen<br>
+ Martin Brumm<br>
+ Chris Shaffer <br>
+ Brett Lentz<br>
+<br>
+All rights reserved by the respective owners of the original games<br>
+(see the Game Notes per game for specific acknowledgements).<br>
+<br>
+No challenge to the original author's or publisher's rights, licensing, or status is intended.<br>
+<br>
+Rails is intended as a play aid for owners of each respective boardgame.<br>
+<br>
+The Rails application and source code are distributed under<br>
+version 2 of the GNU Public License (GPL).<br>
+<br>
+A copy of the GPL should have been shipped with the game files and is also available here:<br>
+ <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">http://www.gnu.org/licenses/old-licenses/gpl-2.0.html</a><br>
+<br>
+Icon sets are taken from the following sites:<ul>
+ <li><a href="http://www.fatcow.com/">http://www.fatcow.com/</a><br>
+ under a Creative Commons Attribution 3.0 License (<a href="http://creativecommons.org/licenses/by/3.0/us/">http://creativecommons.org/licenses/by/3.0/us/</a>)
+ </ul>
+ </html></Credits>
</GamesList>
diff --git a/rails/ui/images/Train.png b/rails/ui/images/Train.png
new file mode 100644
index 0000000..0957b13
Binary files /dev/null and b/rails/ui/images/Train.png differ
diff --git a/rails/ui/images/accept.png b/rails/ui/images/accept.png
new file mode 100644
index 0000000..7786ac7
Binary files /dev/null and b/rails/ui/images/accept.png differ
diff --git a/rails/ui/images/arrow_redo.png b/rails/ui/images/arrow_redo.png
new file mode 100644
index 0000000..c80608a
Binary files /dev/null and b/rails/ui/images/arrow_redo.png differ
diff --git a/rails/ui/images/arrow_undo.png b/rails/ui/images/arrow_undo.png
new file mode 100644
index 0000000..be4f8e9
Binary files /dev/null and b/rails/ui/images/arrow_undo.png differ
diff --git a/rails/ui/images/auction_hammer_gavel.png b/rails/ui/images/auction_hammer_gavel.png
new file mode 100644
index 0000000..c27c3f5
Binary files /dev/null and b/rails/ui/images/auction_hammer_gavel.png differ
diff --git a/rails/ui/images/bricks.png b/rails/ui/images/bricks.png
new file mode 100644
index 0000000..a453ca0
Binary files /dev/null and b/rails/ui/images/bricks.png differ
diff --git a/rails/ui/images/button.png b/rails/ui/images/button.png
new file mode 100644
index 0000000..4b1eb80
Binary files /dev/null and b/rails/ui/images/button.png differ
diff --git a/rails/ui/images/cash_stack.png b/rails/ui/images/cash_stack.png
new file mode 100644
index 0000000..ee8e307
Binary files /dev/null and b/rails/ui/images/cash_stack.png differ
diff --git a/rails/ui/images/clock_add.png b/rails/ui/images/clock_add.png
new file mode 100644
index 0000000..c61c062
Binary files /dev/null and b/rails/ui/images/clock_add.png differ
diff --git a/rails/ui/images/clock_delete.png b/rails/ui/images/clock_delete.png
new file mode 100644
index 0000000..2f8ffb8
Binary files /dev/null and b/rails/ui/images/clock_delete.png differ
diff --git a/rails/ui/images/coins_in_hand.png b/rails/ui/images/coins_in_hand.png
new file mode 100644
index 0000000..aaceea1
Binary files /dev/null and b/rails/ui/images/coins_in_hand.png differ
diff --git a/rails/ui/images/control_fastforward_blue.png b/rails/ui/images/control_fastforward_blue.png
new file mode 100644
index 0000000..e348959
Binary files /dev/null and b/rails/ui/images/control_fastforward_blue.png differ
diff --git a/rails/ui/images/control_play_blue.png b/rails/ui/images/control_play_blue.png
new file mode 100644
index 0000000..a1f7345
Binary files /dev/null and b/rails/ui/images/control_play_blue.png differ
diff --git a/rails/ui/images/globe_model.png b/rails/ui/images/globe_model.png
new file mode 100644
index 0000000..66a5c0b
Binary files /dev/null and b/rails/ui/images/globe_model.png differ
diff --git a/rails/ui/images/hand_property.png b/rails/ui/images/hand_property.png
new file mode 100644
index 0000000..fe4725e
Binary files /dev/null and b/rails/ui/images/hand_property.png differ
diff --git a/rails/ui/images/information.png b/rails/ui/images/information.png
new file mode 100644
index 0000000..93c67f2
Binary files /dev/null and b/rails/ui/images/information.png differ
diff --git a/rails/ui/images/money_add.png b/rails/ui/images/money_add.png
new file mode 100644
index 0000000..62154f3
Binary files /dev/null and b/rails/ui/images/money_add.png differ
diff --git a/rails/ui/images/money_bag.png b/rails/ui/images/money_bag.png
new file mode 100644
index 0000000..24a1a06
Binary files /dev/null and b/rails/ui/images/money_bag.png differ
diff --git a/rails/ui/images/participation_rate.png b/rails/ui/images/participation_rate.png
new file mode 100644
index 0000000..1c30d07
Binary files /dev/null and b/rails/ui/images/participation_rate.png differ
diff --git a/rails/ui/images/rails32.png b/rails/ui/images/rails32.png
new file mode 100644
index 0000000..c62e18c
Binary files /dev/null and b/rails/ui/images/rails32.png differ
diff --git a/rails/ui/images/script.png b/rails/ui/images/script.png
new file mode 100644
index 0000000..8755c17
Binary files /dev/null and b/rails/ui/images/script.png differ
diff --git a/rails/ui/images/traffic_lights_green.png b/rails/ui/images/traffic_lights_green.png
new file mode 100644
index 0000000..bd53d89
Binary files /dev/null and b/rails/ui/images/traffic_lights_green.png differ
diff --git a/rails/ui/images/traffic_lights_red.png b/rails/ui/images/traffic_lights_red.png
new file mode 100644
index 0000000..fd00be2
Binary files /dev/null and b/rails/ui/images/traffic_lights_red.png differ
diff --git a/rails/ui/images/traffic_lights_yellow.png b/rails/ui/images/traffic_lights_yellow.png
new file mode 100644
index 0000000..54034fc
Binary files /dev/null and b/rails/ui/images/traffic_lights_yellow.png differ
diff --git a/rails/ui/swing/StartRoundWindow.java b/rails/ui/swing/StartRoundWindow.java
index 4011121..a6ea8d6 100644
--- a/rails/ui/swing/StartRoundWindow.java
+++ b/rails/ui/swing/StartRoundWindow.java
@@ -134,7 +134,7 @@ implements ActionListener, KeyListener, ActionPerformer, DialogOwner {
buttonPanel = new JPanel();
- buyButton = new ActionButton(RailsIcon.BUY);
+ buyButton = new ActionButton(RailsIcon.AUCTION_BUY);
buyButton.setMnemonic(KeyEvent.VK_B);
buyButton.addActionListener(this);
buyButton.setEnabled(false);
diff --git a/rails/ui/swing/elements/RailsIcon.java b/rails/ui/swing/elements/RailsIcon.java
index eed61ff..bc420b0 100644
--- a/rails/ui/swing/elements/RailsIcon.java
+++ b/rails/ui/swing/elements/RailsIcon.java
@@ -15,27 +15,35 @@ import rails.common.LocalText;
public enum RailsIcon {
// in parentheses the image file
- AUTOPASS ("","Autopass"),
- BID ("","BID"),
- BUY ("","BUY"),
- BUY_PRIVATE ("","BUY_PRIVATE"),
- BUY_TRAIN ("","BUY_TRAIN"),
- DONE ("","Done"),
+ AUCTION_BUY ("auction_hammer_gavel.png","BUY"),
+ AUTOPASS ("control_fastforward_blue.png","Autopass"),
+ BID ("money_add.png","BID"),
+ BUY_PRIVATE ("money_bag.png","BUY_PRIVATE"),
+ BUY_TRAIN ("train.png","BUY_TRAIN"),
+ DONE ("accept.png","Done"),
+ INFO ("information.png","Info"),
+ LAY_TILE ("rails32.png","LayTile"),
+ PANEL_OR ("participation_rate.png","Dockable.orWindow.orPanel"),
+ PANEL_OR_BUTTONS ("button.png","Dockable.orWindow.buttonPanel"),
+ PANEL_MAP ("globe_model.png","Dockable.orWindow.mapPanel"),
+ PANEL_MESSAGE ("script.png","Dockable.orWindow.messagePanel"),
+ PANEL_REMAINING_TILES ("rails32.png","Dockable.orWindow.remainingTilesPanel"),
+ PANEL_UPGRADE ("bricks.png","Dockable.orWindow.upgradePanel"),
+ PASS ("control_play_blue.png","PASS"),
+ PAYOUT ("traffic_lights_green.png","PAYOUT"),
+ REDO ("arrow_redo.png","REDO"),
+ REPAY_LOANS ("cash_stack.png","RepayLoans"),
+ REPORT_MOVE_BACKWARD ("clock_delete.png","REPORT_MOVE_BACKWARD"),
+ REPORT_MOVE_FORWARD ("clock_add.png","REPORT_MOVE_FORWARD"),
+ SELECT_NO_BID ("hand_property.png","SelectNoBid"),
+ SET_REVENUE ("coins_in_hand.png","SET_REVENUE"),
+ SPLIT ("traffic_lights_yellow.png","SPLIT"),
+ UNDO ("arrow_undo.png","UNDO"),
+ WITHHOLD ("traffic_lights_red.png","WITHHOLD"),
+
+ //no icons by purpose
END_OF_GAME_CLOSE_ALL_WINDOWS ("","END_OF_GAME_CLOSE_ALL_WINDOWS"),
- INFO ("Inform.gif","Info"),
- LAY_TILE ("","LayTile"),
OPERATING_COST ("","OCButtonLabel"),
- PASS ("","PASS"),
- PAYOUT ("","PAYOUT"),
- REDO ("","REDO"),
- REPAY_LOANS ("","RepayLoans"),
- REPORT_MOVE_BACKWARD ("","REPORT_MOVE_BACKWARD"),
- REPORT_MOVE_FORWARD ("","REPORT_MOVE_FORWARD"),
- SELECT_NO_BID ("","SelectNoBid"),
- SET_REVENUE ("","SET_REVENUE"),
- SPLIT ("","SPLIT"),
- UNDO ("","UNDO"),
- WITHOLD ("","WITHHOLD"),
//null meaning all public fields are null
NULL ();
commit d0d630d07e4b5b7edd5764ee1b6b125fc806df49
Author: Frederick Weld <fre...@gm...>
Date: Sat Feb 11 17:30:59 2012 +0100
Added support for icons in dockable panels / further refactoring
As a result, add dockable now also gets the config key in order
to be able to map the dockable to the respective icon.
diff --git a/rails/ui/swing/ConfigWindow.java b/rails/ui/swing/ConfigWindow.java
index 4d25293..db03e10 100644
--- a/rails/ui/swing/ConfigWindow.java
+++ b/rails/ui/swing/ConfigWindow.java
@@ -419,7 +419,7 @@ class ConfigWindow extends JFrame {
}
// add info icon for infoText
if (infoText != null) {
- JLabel infoIcon = new JLabel(RailsIcon.INFO.largeIcon);
+ JLabel infoIcon = new JLabel(RailsIcon.INFO.smallIcon);
infoIcon.addMouseListener(new MouseListener() {
public void mousePressed(MouseEvent e) {
final JDialog dialog = new JDialog(ConfigWindow.this, false);
diff --git a/rails/ui/swing/GameSetupWindow.java b/rails/ui/swing/GameSetupWindow.java
index e91880d..4e69739 100644
--- a/rails/ui/swing/GameSetupWindow.java
+++ b/rails/ui/swing/GameSetupWindow.java
@@ -324,7 +324,7 @@ public class GameSetupWindow extends JDialog implements ActionListener {
System.exit(0);
} else if (arg0.getSource().equals(creditsButton)) {
JOptionPane.showMessageDialog(this,
- credits,
+ new JLabel(credits), //enable html rendering
LocalText.getText("CREDITS"),
JOptionPane.INFORMATION_MESSAGE);
} else if (arg0.getSource().equals(gameNameBox)) {
diff --git a/rails/ui/swing/ORPanel.java b/rails/ui/swing/ORPanel.java
index ec8c7ec..0dd18ce 100644
--- a/rails/ui/swing/ORPanel.java
+++ b/rails/ui/swing/ORPanel.java
@@ -1183,7 +1183,7 @@ implements ActionListener, KeyListener, RevenueListener {
setSelect(revenue[orCompIndex], revenueSelect[orCompIndex], false);
if (withhold) {
- button1.setRailsIcon(RailsIcon.WITHOLD);
+ button1.setRailsIcon(RailsIcon.WITHHOLD);
button1.setActionCommand(WITHHOLD_CMD);
clonedAction = (SetDividend) action.clone();
clonedAction.setRevenueAllocation(SetDividend.WITHHOLD);
diff --git a/rails/ui/swing/ORWindow.java b/rails/ui/swing/ORWindow.java
index acee3e9..9b049a5 100644
--- a/rails/ui/swing/ORWindow.java
+++ b/rails/ui/swing/ORWindow.java
@@ -82,22 +82,22 @@ public class ORWindow extends DockingFrame implements ActionPerformer {
//generate layout
addDockable ( messagePanelSlider,
- LocalText.getText("Dockable.orWindow.messagePanel"),
+ "Dockable.orWindow.messagePanel",
0, 0, 100, 10, DockableProperty.closeable);
addDockable ( upgradePanel,
- LocalText.getText("Dockable.orWindow.upgradePanel"),
+ "Dockable.orWindow.upgradePanel",
0, 10, 20, 70, DockableProperty.standard);
addDockable ( mapPanel,
- LocalText.getText("Dockable.orWindow.mapPanel"),
+ "Dockable.orWindow.mapPanel",
20, 10, 80, 70, DockableProperty.standard);
addDockable ( remainingTilesPanelSlider,
- LocalText.getText("Dockable.orWindow.remainingTilesPanel"),
+ "Dockable.orWindow.remainingTilesPanel",
100, 0, 120, 100, DockableProperty.initially_hidden);
addDockable ( orPanel,
- LocalText.getText("Dockable.orWindow.orPanel"),
+ "Dockable.orWindow.orPanel",
0, 80, 100, 15, DockableProperty.standard);
addDockable ( orPanel.getButtonPanel(),
- LocalText.getText("Dockable.orWindow.buttonPanel"),
+ "Dockable.orWindow.buttonPanel",
0, 95, 100, 5, DockableProperty.standard);
deployDockables();
diff --git a/rails/ui/swing/StartRoundWindow.java b/rails/ui/swing/StartRoundWindow.java
index a2c83eb..4011121 100644
--- a/rails/ui/swing/StartRoundWindow.java
+++ b/rails/ui/swing/StartRoundWindow.java
@@ -797,7 +797,7 @@ implements ActionListener, KeyListener, ActionPerformer, DialogOwner {
}
private ImageIcon createInfoIcon() {
- return RailsIcon.INFO.largeIcon;
+ return RailsIcon.INFO.smallIcon;
}
public void keyPressed(KeyEvent e) {
diff --git a/rails/ui/swing/elements/ActionButton.java b/rails/ui/swing/elements/ActionButton.java
index 2594741..d07bbba 100644
--- a/rails/ui/swing/elements/ActionButton.java
+++ b/rails/ui/swing/elements/ActionButton.java
@@ -113,7 +113,8 @@ public class ActionButton extends JButton implements ActionTaker {
}
private boolean isIconSizeSmall() {
- return "small".equals(Config.get("actionButton.iconSize"));
+ //small is default
+ return !"large".equals(Config.get("actionButton.iconSize"));
}
/**
diff --git a/rails/ui/swing/elements/DockingFrame.java b/rails/ui/swing/elements/DockingFrame.java
index 78edec1..82c0ea6 100644
--- a/rails/ui/swing/elements/DockingFrame.java
+++ b/rails/ui/swing/elements/DockingFrame.java
@@ -114,13 +114,14 @@ public abstract class DockingFrame extends JFrame {
* The dockable is only deployed to the frame if deployDockables is called.
*/
protected void addDockable(JComponent c,
- String dockableTitle,
+ String dockableConfigKey,
int x, int y, int width, int height,
DockableProperty dockableProperty) {
+ String dockableTitle = LocalText.getText(dockableConfigKey);
DefaultSingleCDockable d = new DefaultSingleCDockable(
dockableTitle, dockableTitle );
d.add( c, BorderLayout.CENTER );
- d.setTitleIcon(null);
+ d.setTitleIcon(RailsIcon.getByConfigKey(dockableConfigKey).smallIcon);
d.setCloseable(
( dockableProperty == DockableProperty.closeable
|| dockableProperty == DockableProperty.initially_hidden )
commit 9ee0450b4dfce30542923740000d050bbe7b8cd1
Author: Frederick Weld <fre...@gm...>
Date: Sat Feb 11 15:28:21 2012 +0100
Added framework for managing/displaying icons on ActionButtons
RailsIcon and ActionButton have undergone rework / extensions.
ActionButton's construction and setText is not based on label text
any more. Instead RailsIcon enum instances are used for this purpose.
Added two options (display text/icon/both and small/large icons).
diff --git a/LocalisedText.properties b/LocalisedText.properties
index a0f256f..a6f24f6 100644
--- a/LocalisedText.properties
+++ b/LocalisedText.properties
@@ -183,6 +183,8 @@ Config.infoText.sound.sfx.gen.newCurrentPlayer=<html>Enter assignment of sound e
Config.infoText.sound.sfx.or.buyTrain=<html>Enter assignment of sound effect files to train types.<ul><li>Separate the assignments by commas.<li>Each assignment has the syntax trainName=complete file path<li>Default sound effect is defined by omitting "trainName=" in the assignment.</ul><strong>Examples:</strong><ul><li>Set default sound effect: <br><code>c:\BuyTrain-default.mp3</code><li>Set train-dependent sound effect and a default (for trains above 6): <br><code>2=c:\BuyTrain-2.mp3,3=c:\BuyTrain-3.mp3,4=c:\BuyTrain-4.mp3,5=c:\BuyTrain-5.mp3,6=c:\BuyTrain-6.mp3,c:\BuyTrain-D.mp3</code></ul> </html>
Config.infoText.sound.sfx.or.setRevenue=<html><ul><li>Only the latter portion of this file is played.<ul><li>For an average revenue, the last third is played.</ul><li>The higher the company's revenue the longer this file is played.<ul><li>But the file is at most played once as a whole.</li></ul></html>
Config.infoText.sound.sfx.sr.newPresident=This also includes becoming the president when buying the president share.
+Config.label.actionButton.iconText=Button display type
+Config.label.actionButton.iconSize=Icon size
Config.label.default_game=Default game
Config.label.default_players=Default players
Config.label.font.ui.name=Font selection
diff --git a/data/Properties.xml b/data/Properties.xml
index da62099..b78d097 100644
--- a/data/Properties.xml
+++ b/data/Properties.xml
@@ -48,6 +48,10 @@
</Section>
<Section name="Appearance">
<Property name="gridPanel.tableBorders" type="LIST" values="disabled,enabled"/>
+ <Property name="actionButton.iconText" type="LIST" values="text and icon,only text,only icon"
+ initClass="rails.ui.swing.elements.ActionButton" initMethod="resetRailsIcons" initParameter="no" />
+ <Property name="actionButton.iconSize" type="LIST" values="small,large"
+ initClass="rails.ui.swing.elements.ActionButton" initMethod="resetRailsIcons" initParameter="no" />
<Property name="route.colour.1" type="COLOR"
initClass="rails.ui.swing.hexmap.HexMap" initMethod="setRouteColours" />
<Property name="route.colour.2" type="COLOR"
diff --git a/rails/ui/swing/ConfigWindow.java b/rails/ui/swing/ConfigWindow.java
index 8c9e7e8..4d25293 100644
--- a/rails/ui/swing/ConfigWindow.java
+++ b/rails/ui/swing/ConfigWindow.java
@@ -419,7 +419,7 @@ class ConfigWindow extends JFrame {
}
// add info icon for infoText
if (infoText != null) {
- JLabel infoIcon = new JLabel(RailsIcon.INFO.icon);
+ JLabel infoIcon = new JLabel(RailsIcon.INFO.largeIcon);
infoIcon.addMouseListener(new MouseListener() {
public void mousePressed(MouseEvent e) {
final JDialog dialog = new JDialog(ConfigWindow.this, false);
diff --git a/rails/ui/swing/ORPanel.java b/rails/ui/swing/ORPanel.java
index 280ef18..ec8c7ec 100644
--- a/rails/ui/swing/ORPanel.java
+++ b/rails/ui/swing/ORPanel.java
@@ -285,39 +285,39 @@ implements ActionListener, KeyListener, RevenueListener {
private void initButtonPanel() {
// sfy: operatingcosts button
- buttonOC = new ActionButton(LocalText.getText("OCButtonLabel"));
+ buttonOC = new ActionButton(RailsIcon.OPERATING_COST);
buttonOC.setActionCommand(OPERATING_COST_CMD);
buttonOC.setMnemonic(KeyEvent.VK_O);
buttonOC.addActionListener(this);
buttonOC.setEnabled(false);
buttonOC.setVisible(false);
- button1 = new ActionButton(LocalText.getText("LayTile"));
+ button1 = new ActionButton(RailsIcon.LAY_TILE);
button1.setActionCommand(LAY_TILE_CMD);
button1.setMnemonic(KeyEvent.VK_T);
button1.addActionListener(this);
button1.setEnabled(false);
- button2 = new ActionButton(LocalText.getText("BUY_PRIVATE"));
+ button2 = new ActionButton(RailsIcon.BUY_PRIVATE);
button2.setActionCommand(BUY_PRIVATE_CMD);
button2.setMnemonic(KeyEvent.VK_V);
button2.addActionListener(this);
button2.setEnabled(false);
button2.setVisible(false);
- button3 = new ActionButton(LocalText.getText("Done"));
+ button3 = new ActionButton(RailsIcon.DONE);
button3.setActionCommand(DONE_CMD);
button3.setMnemonic(KeyEvent.VK_D);
button3.addActionListener(this);
button3.setEnabled(false);
- undoButton = new ActionButton(LocalText.getText("UNDO"));
+ undoButton = new ActionButton(RailsIcon.UNDO);
undoButton.setActionCommand(UNDO_CMD);
undoButton.setMnemonic(KeyEvent.VK_U);
undoButton.addActionListener(this);
undoButton.setEnabled(false);
- redoButton = new ActionButton(LocalText.getText("REDO"));
+ redoButton = new ActionButton(RailsIcon.REDO);
redoButton.setActionCommand(REDO_CMD);
redoButton.setMnemonic(KeyEvent.VK_R);
redoButton.addActionListener(this);
@@ -1134,7 +1134,7 @@ implements ActionListener, KeyListener, RevenueListener {
setSelect(revenue[orCompIndex], revenueSelect[orCompIndex], true);
- button1.setText(LocalText.getText("SET_REVENUE"));
+ button1.setRailsIcon(RailsIcon.SET_REVENUE);
button1.setActionCommand(SET_REVENUE_CMD);
button1.setPossibleAction(action);
button1.setMnemonic(KeyEvent.VK_R);
@@ -1183,7 +1183,7 @@ implements ActionListener, KeyListener, RevenueListener {
setSelect(revenue[orCompIndex], revenueSelect[orCompIndex], false);
if (withhold) {
- button1.setText(LocalText.getText("WITHHOLD"));
+ button1.setRailsIcon(RailsIcon.WITHOLD);
button1.setActionCommand(WITHHOLD_CMD);
clonedAction = (SetDividend) action.clone();
clonedAction.setRevenueAllocation(SetDividend.WITHHOLD);
@@ -1196,7 +1196,7 @@ implements ActionListener, KeyListener, RevenueListener {
}
if (split) {
- button2.setText(LocalText.getText("SPLIT"));
+ button2.setRailsIcon(RailsIcon.SPLIT);
button2.setActionCommand(SPLIT_CMD);
clonedAction = (SetDividend) action.clone();
clonedAction.setRevenueAllocation(SetDividend.SPLIT);
@@ -1209,7 +1209,7 @@ implements ActionListener, KeyListener, RevenueListener {
}
if (payout) {
- button3.setText(LocalText.getText("PAYOUT"));
+ button3.setRailsIcon(RailsIcon.PAYOUT);
button3.setActionCommand(PAYOUT_CMD);
clonedAction = (SetDividend) action.clone();
clonedAction.setRevenueAllocation(SetDividend.PAYOUT);
@@ -1227,7 +1227,7 @@ implements ActionListener, KeyListener, RevenueListener {
setHighlight(trains[orCompIndex],true);
setHighlight(newTrainCost[orCompIndex],true);
- button1.setText(LocalText.getText("BUY_TRAIN"));
+ button1.setRailsIcon(RailsIcon.BUY_TRAIN);
button1.setActionCommand(BUY_TRAIN_CMD);
button1.setMnemonic(KeyEvent.VK_T);
button1.setEnabled(enabled);
@@ -1248,7 +1248,7 @@ implements ActionListener, KeyListener, RevenueListener {
if (privatesCanBeBought) {
if (enabled) {
- button2.setText(LocalText.getText("BUY_PRIVATE"));
+ button2.setRailsIcon(RailsIcon.BUY_PRIVATE);
button2.setActionCommand(BUY_PRIVATE_CMD);
button2.setMnemonic(KeyEvent.VK_V);
}
@@ -1280,7 +1280,7 @@ implements ActionListener, KeyListener, RevenueListener {
public void enableDone(NullAction action) {
- button3.setText(LocalText.getText("Done"));
+ button3.setRailsIcon(RailsIcon.DONE);
button3.setActionCommand(DONE_CMD);
button3.setMnemonic(KeyEvent.VK_D);
button3.setPossibleAction(action);
@@ -1310,7 +1310,7 @@ implements ActionListener, KeyListener, RevenueListener {
loansCaption.setHighlight(true);
setHighlight(compLoans[orCompIndex],true);
- button1.setText(LocalText.getText("RepayLoans"));
+ button1.setRailsIcon(RailsIcon.REPAY_LOANS);
button1.setActionCommand(REPAY_LOANS_CMD);
button1.setPossibleAction(action);
button1.setMnemonic(KeyEvent.VK_R);
diff --git a/rails/ui/swing/ReportWindowDynamic.java b/rails/ui/swing/ReportWindowDynamic.java
index a5c6128..00daad2 100644
--- a/rails/ui/swing/ReportWindowDynamic.java
+++ b/rails/ui/swing/ReportWindowDynamic.java
@@ -22,6 +22,7 @@ import rails.game.action.PossibleActions;
import rails.game.move.MoveStack;
import rails.sound.SoundManager;
import rails.ui.swing.elements.ActionButton;
+import rails.ui.swing.elements.RailsIcon;
/**
* Dynamic Report window that acts as linked game history
@@ -109,11 +110,11 @@ public class ReportWindowDynamic extends AbstractReportWindow implements Action
buttonPanel = new JPanel();
add(buttonPanel, "South");
- backwardButton = new ActionButton(LocalText.getText("REPORT_MOVE_BACKWARD"));
+ backwardButton = new ActionButton(RailsIcon.REPORT_MOVE_BACKWARD);
backwardButton.addActionListener(this);
buttonPanel.add(backwardButton);
- forwardButton = new ActionButton(LocalText.getText("REPORT_MOVE_FORWARD"));
+ forwardButton = new ActionButton(RailsIcon.REPORT_MOVE_FORWARD);
forwardButton.addActionListener(this);
buttonPanel.add(forwardButton);
diff --git a/rails/ui/swing/StartRoundWindow.java b/rails/ui/swing/StartRoundWindow.java
index 1ff36cd..a2c83eb 100644
--- a/rails/ui/swing/StartRoundWindow.java
+++ b/rails/ui/swing/StartRoundWindow.java
@@ -134,14 +134,14 @@ implements ActionListener, KeyListener, ActionPerformer, DialogOwner {
buttonPanel = new JPanel();
- buyButton = new ActionButton(LocalText.getText("BUY"));
+ buyButton = new ActionButton(RailsIcon.BUY);
buyButton.setMnemonic(KeyEvent.VK_B);
buyButton.addActionListener(this);
buyButton.setEnabled(false);
buttonPanel.add(buyButton);
if (includeBidding) {
- bidButton = new ActionButton(LocalText.getText("BID") + ":");
+ bidButton = new ActionButton(RailsIcon.BID);
bidButton.setMnemonic(KeyEvent.VK_D);
bidButton.addActionListener(this);
bidButton.setEnabled(false);
@@ -156,7 +156,7 @@ implements ActionListener, KeyListener, ActionPerformer, DialogOwner {
buttonPanel.add(bidAmount);
}
- passButton = new ActionButton(LocalText.getText("PASS"));
+ passButton = new ActionButton(RailsIcon.PASS);
passButton.setMnemonic(KeyEvent.VK_P);
passButton.addActionListener(this);
passButton.setEnabled(false);
@@ -518,7 +518,7 @@ implements ActionListener, KeyListener, ActionPerformer, DialogOwner {
// only one NullAction is allowed
NullAction na = inactiveItems.get(0);
// nullActions differ in text to display
- passButton.setText(LocalText.getText(na.toString()));
+ passButton.setRailsIcon(RailsIcon.getByConfigKey(na.toString()));
passAllowed = true;
passButton.setPossibleAction(na);
passButton.setMnemonic(KeyEvent.VK_P);
@@ -586,7 +586,7 @@ implements ActionListener, KeyListener, ActionPerformer, DialogOwner {
// In this case, "Pass" becomes "Select, don't buy"
passButton.setPossibleAction(currentActiveItem);
passButton.setEnabled(true);
- passButton.setText(LocalText.getText("SelectNoBid"));
+ passButton.setRailsIcon(RailsIcon.SELECT_NO_BID);
passButton.setVisible(true);
// if (!repacked) {
pack();
@@ -797,7 +797,7 @@ implements ActionListener, KeyListener, ActionPerformer, DialogOwner {
}
private ImageIcon createInfoIcon() {
- return RailsIcon.INFO.icon;
+ return RailsIcon.INFO.largeIcon;
}
public void keyPressed(KeyEvent e) {
diff --git a/rails/ui/swing/StatusWindow.java b/rails/ui/swing/StatusWindow.java
index 77db336..6271180 100644
--- a/rails/ui/swing/StatusWindow.java
+++ b/rails/ui/swing/StatusWindow.java
@@ -285,13 +285,13 @@ KeyListener, ActionPerformer {
buttonPanel = new JPanel();
- passButton = new ActionButton(LocalText.getText("PASS"));
+ passButton = new ActionButton(RailsIcon.PASS);
passButton.setMnemonic(KeyEvent.VK_P);
buttonPanel.add(passButton);
passButton.setActionCommand(DONE_CMD);
passButton.addActionListener(this);
- autopassButton = new ActionButton(LocalText.getText("Autopass"));
+ autopassButton = new ActionButton(RailsIcon.AUTOPASS);
autopassButton.setMnemonic(KeyEvent.VK_A);
buttonPanel.add(autopassButton);
autopassButton.setActionCommand(AUTOPASS_CMD);
@@ -547,14 +547,14 @@ KeyListener, ActionPerformer {
for (NullAction na : inactiveItems) {
switch (na.getMode()) {
case NullAction.PASS:
- passButton.setText(LocalText.getText("PASS"));
+ passButton.setRailsIcon(RailsIcon.PASS);
passButton.setEnabled(true);
passButton.setActionCommand(PASS_CMD);
passButton.setMnemonic(KeyEvent.VK_P);
passButton.setPossibleAction(na);
break;
case NullAction.DONE:
- passButton.setText(LocalText.getText("Done"));
+ passButton.setRailsIcon(RailsIcon.DONE);
passButton.setEnabled(true);
passButton.setActionCommand(DONE_CMD);
passButton.setMnemonic(KeyEvent.VK_D);
@@ -698,9 +698,9 @@ KeyListener, ActionPerformer {
if (action != null) {
int mode = action.getMode();
if (mode == NullAction.PASS) {
- passButton.setText(LocalText.getText("PASS"));
+ passButton.setRailsIcon(RailsIcon.PASS);
} else if (mode == NullAction.DONE) {
- passButton.setText(LocalText.getText("Done"));
+ passButton.setRailsIcon(RailsIcon.DONE);
}
passButton.setEnabled(true);
passButton.setVisible(true);
@@ -750,7 +750,7 @@ KeyListener, ActionPerformer {
// Enable Passbutton
passButton.setEnabled(true);
- passButton.setText(LocalText.getText("END_OF_GAME_CLOSE_ALL_WINDOWS"));
+ passButton.setRailsIcon(RailsIcon.END_OF_GAME_CLOSE_ALL_WINDOWS);
gameUIManager.orWindow.finish();
}
diff --git a/rails/ui/swing/elements/ActionButton.java b/rails/ui/swing/elements/ActionButton.java
index b2c06aa..2594741 100644
--- a/rails/ui/swing/elements/ActionButton.java
+++ b/rails/ui/swing/elements/ActionButton.java
@@ -1,11 +1,16 @@
/* $Header: /Users/blentz/rails_rcs/cvs/18xx/rails/ui/swing/elements/ActionButton.java,v 1.5 2008/06/04 19:00:38 evos Exp $*/
package rails.ui.swing.elements;
+import java.awt.Insets;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import javax.swing.JButton;
+import rails.common.parser.Config;
import rails.game.action.ActionTaker;
import rails.game.action.PossibleAction;
@@ -18,10 +23,34 @@ public class ActionButton extends JButton implements ActionTaker {
private static final long serialVersionUID = 1L;
+ private static final Set<String> KEYS_TEXT_DISPLAY = new HashSet<String>
+ (Arrays.asList( new String[] {
+ "text and icon",
+ "only text",
+ "",
+ null
+ }));
+ private static final Set<String> KEYS_ICON_DISPLAY = new HashSet<String>
+ (Arrays.asList( new String[] {
+ "text and icon",
+ "only icon"
+ }));
+
+ private static Set<ActionButton> actionButtons = new HashSet<ActionButton>();
+
private List<PossibleAction> actions = new ArrayList<PossibleAction>(1);
- public ActionButton(String text) {
- super(text);
+ /**
+ * null value means that the action button is not set up by an appropriate
+ * RailsIcon (eg., by calling setText directly).
+ */
+ private RailsIcon railsIcon = null;
+
+ public ActionButton(RailsIcon railsIcon) {
+ super();
+ setRailsIcon(railsIcon);
+ this.setMargin(new Insets(2,2,2,2));
+ actionButtons.add(this);
}
public void addPossibleAction(PossibleAction o) {
@@ -41,4 +70,70 @@ public class ActionButton extends JButton implements ActionTaker {
addPossibleAction(action);
}
+ public void setRailsIcon(RailsIcon railsIcon) {
+ if (railsIcon == null) railsIcon = RailsIcon.NULL;
+ this.railsIcon = railsIcon;
+ showRailsIcon();
+ }
+
+ /**
+ * Display according to configuration.
+ * If no text/icon is attached, then icon/text is displayed as fallback
+ * (irrespective of configuration).
+ * Text becomes the tool tip text in case of icon-only display.
+ */
+ private void showRailsIcon() {
+ if (railsIcon != null) {
+ if (isTextEnabled() || railsIcon.largeIcon == null) {
+ super.setText(railsIcon.description);
+ } else {
+ super.setText(null);
+ }
+ if (isIconEnabled() || railsIcon.description == null) {
+ if (isIconSizeSmall()) {
+ super.setIcon(railsIcon.smallIcon);
+ } else {
+ super.setIcon(railsIcon.largeIcon);
+ }
+ if (!isTextEnabled()) {
+ super.setToolTipText(railsIcon.description);
+ }
+ } else {
+ super.setIcon(null);
+ }
+ }
+ }
+
+ private boolean isTextEnabled() {
+ return KEYS_TEXT_DISPLAY.contains(Config.get("actionButton.iconText",""));
+ }
+
+ private boolean isIconEnabled() {
+ return KEYS_ICON_DISPLAY.contains(Config.get("actionButton.iconText",""));
+ }
+
+ private boolean isIconSizeSmall() {
+ return "small".equals(Config.get("actionButton.iconSize"));
+ }
+
+ /**
+ * Should only be used if an arbitrary text is to displayed without icon.
+ * In any other case, setRailsIcon should be used.
+ */
+ @Override
+ public void setText(String text) {
+ super.setText(text);
+ setIcon(null);
+ railsIcon = null;
+ }
+
+ /**
+ * To be called upon change of button display type
+ */
+ public static void resetRailsIcons() {
+ for (ActionButton ab : actionButtons) {
+ ab.showRailsIcon();
+ }
+ }
+
}
diff --git a/rails/ui/swing/elements/RailsIcon.java b/rails/ui/swing/elements/RailsIcon.java
index 0eaba36..eed61ff 100644
--- a/rails/ui/swing/elements/RailsIcon.java
+++ b/rails/ui/swing/elements/RailsIcon.java
@@ -1,30 +1,125 @@
package rails.ui.swing.elements;
+import java.awt.Image;
+
import javax.swing.ImageIcon;
+import rails.common.LocalText;
+
/**
* Enumeration that provides a specific ImageIcon
- * Simply use RailsIcon.{IconName}.create
+ * Simply use RailsIcon.{IconName}.icon/description
* @author freystef
*/
public enum RailsIcon {
// in parentheses the image file
- INFO ("Inform.gif");
-
- private final static String IMAGE_PATH = "/rails/ui/images/";
- public final ImageIcon icon;
+ AUTOPASS ("","Autopass"),
+ BID ("","BID"),
+ BUY ("","BUY"),
+ BUY_PRIVATE ("","BUY_PRIVATE"),
+ BUY_TRAIN ("","BUY_TRAIN"),
+ DONE ("","Done"),
+ END_OF_GAME_CLOSE_ALL_WINDOWS ("","END_OF_GAME_CLOSE_ALL_WINDOWS"),
+ INFO ("Inform.gif","Info"),
+ LAY_TILE ("","LayTile"),
+ OPERATING_COST ("","OCButtonLabel"),
+ PASS ("","PASS"),
+ PAYOUT ("","PAYOUT"),
+ REDO ("","REDO"),
+ REPAY_LOANS ("","RepayLoans"),
+ REPORT_MOVE_BACKWARD ("","REPORT_MOVE_BACKWARD"),
+ REPORT_MOVE_FORWARD ("","REPORT_MOVE_FORWARD"),
+ SELECT_NO_BID ("","SelectNoBid"),
+ SET_REVENUE ("","SET_REVENUE"),
+ SPLIT ("","SPLIT"),
+ UNDO ("","UNDO"),
+ WITHOLD ("","WITHHOLD"),
+
+ //null meaning all public fields are null
+ NULL ();
+
+ private final static String IMAGE_PATH = "/rails/ui/images/";
+ private final static int SMALL_IMAGE_WIDTH = 16;
+ private final static int SMALL_IMAGE_HEIGHT = 16;
+ private final String configKey;
+ /**
+ * icon in original resolution
+ */
+ public final ImageIcon largeIcon;
+ /**
+ * icon in restricted / small resolution
+ */
+ public final ImageIcon smallIcon;
+ public final String description;
+
+ private RailsIcon() {
+ configKey = null;
+ largeIcon = null;
+ smallIcon = null;
+ description = null;
+ }
+
+ private RailsIcon(String fileName,String configKey) {
+ this.configKey = configKey;
+ this.description = LocalText.getText(configKey);
+ largeIcon = createIcon(fileName,description);
+ smallIcon = createSmallIcon(largeIcon);
+ }
- private RailsIcon(String fileName) {
+ private ImageIcon createIcon(String fileName, String description) {
+ //check whether icon is expected to be found
+ //don't write error messages if icon not expected to be found
+ if (fileName == null || fileName.equals("")) {
+ return null;
+ }
+
+ //get icon
String path = IMAGE_PATH + fileName;
java.net.URL imgURL = getClass().getResource(path);
if (imgURL != null) {
- icon = new ImageIcon(imgURL, "Info");
+ return new ImageIcon(imgURL, description);
} else {
System.err.println("Couldn't find file: " + path);
- icon = null;
+ return null;
+ }
+ }
+
+ private ImageIcon createSmallIcon(ImageIcon originalIcon) {
+ ImageIcon smallIcon = null;
+ if (originalIcon != null) {
+ Image img = originalIcon.getImage();
+ if (img != null) {
+ smallIcon = new ImageIcon(
+ img.getScaledInstance(
+ SMALL_IMAGE_WIDTH,
+ SMALL_IMAGE_HEIGHT,
+ Image.SCALE_SMOOTH
+ ),
+ originalIcon.getDescription()
+ );
+ }
+ }
+ return smallIcon;
+ }
+
+ /**
+ * @return The Rails icon associated with the key or, if nothing is found,
+ * RailsConfig.NULL
+ */
+ public static RailsIcon getByConfigKey(String configKey) {
+ if (configKey == null) return RailsIcon.NULL;
+
+ RailsIcon ri = null;
+ for (RailsIcon r : RailsIcon.values()) {
+ //ignore case necessary as both Pass and PASS are used by consumers
+ if (configKey.equalsIgnoreCase(r.configKey)) ri = r;
+ }
+ if (ri == null) {
+ ri = RailsIcon.NULL;
}
+ return ri;
}
}
|