|
From: Stefan F. <ste...@us...> - 2012-01-02 18:42:02
|
LocalisedText.properties | 2 ++
rails/ui/swing/ORPanel.java | 39 ++++++++++++++++++++++++++++++++++++---
2 files changed, 38 insertions(+), 3 deletions(-)
New commits:
commit 39ac84492244350708aa503a7c23c81997e2955f
Author: Frederick Weld <fre...@gm...>
Date: Fri Dec 30 21:19:13 2011 +0100
Added user-friendly network info including keyboard shortcut
Provided for a non-developer version of the network info menu.
Differences to the developer-only version (available before):
- omitting the menu item for the complete network graph
- providing a localized dialog text for the dialog
- omitting train run information and train simulation
Applied further extensions to network info menu (also valid for
the developer-only version):
- Keyboard shortcut (Ctrl+N) dynamically assigned to the network info
menu item of the currently operating company
- Network info run visualization takes care of potential conflicts
with the visualization of the set revenue step
- Network info run visualization is turned off after the dialog
Provided functionality covers the use case described in feature
request 3064835.
Signed-off-by: Stefan Frey <ste...@we...>
diff --git a/LocalisedText.properties b/LocalisedText.properties
index 26b182e..a3fdd12 100644
--- a/LocalisedText.properties
+++ b/LocalisedText.properties
@@ -400,6 +400,8 @@ MustWithholdUntilPermanent={0} must withhold revenue until it owns a permanent t
NamesTrain={0} names {1}-train as {2}
NegativeAmountNotAllowed=Negative amount {0} not allowed
NetworkInfo=Network Info
+NetworkInfoDialogTitle=Network Info for Company {0}
+NetworkInfoDialogMessage={0} could run for a revenue of {1}
NEW=New
NewGame=New Game
NextPlayerMessage=Message(s) from previous player''s ({0}) turn:
diff --git a/rails/ui/swing/ORPanel.java b/rails/ui/swing/ORPanel.java
index ffcb997..e88b788 100644
--- a/rails/ui/swing/ORPanel.java
+++ b/rails/ui/swing/ORPanel.java
@@ -611,7 +611,7 @@ implements ActionListener, KeyListener, RevenueListener {
if (networkInfoMenu != null) infoMenu.remove(networkInfoMenu);
networkInfoMenu = createNetworkInfo();
if (networkInfoMenu == null) return;
- networkInfoMenu.setEnabled(Game.getDevelop());
+ networkInfoMenu.setEnabled(true);
infoMenu.add(networkInfoMenu);
}
@@ -624,7 +624,8 @@ implements ActionListener, KeyListener, RevenueListener {
JMenu networkMenu = new JMenu(LocalText.getText("NetworkInfo"));
- if (route_highlight) {
+ //network graphs only for developers
+ if (route_highlight && Game.getDevelop()) {
JMenuItem item = new JMenuItem("Network");
item.addActionListener(this);
item.setActionCommand(NETWORK_INFO_CMD);
@@ -683,6 +684,17 @@ implements ActionListener, KeyListener, RevenueListener {
log.debug("Revenue Run:" + ra.getOptimalRunPrettyPrint(true));
ra.drawOptimalRunAsPath(orUIManager.getMap());
orUIManager.getMap().repaint();
+
+ if (!Game.getDevelop()) {
+ //parent component is ORPanel so that dialog won't hide the routes painted on the map
+ JOptionPane.showMessageDialog(this,
+ LocalText.getText("NetworkInfoDialogMessage",company.getName(),Bank.format(revenueValue)) ,
+ LocalText.getText("NetworkInfoDialogTitle",company.getName()),
+ JOptionPane.INFORMATION_MESSAGE);
+ //train simulation only for developers
+ break;
+ }
+
JOptionPane.showMessageDialog(orWindow, "RevenueValue = " + revenueValue +
"\nRevenueRun = \n" + ra.getOptimalRunPrettyPrint(true));
@@ -697,7 +709,11 @@ implements ActionListener, KeyListener, RevenueListener {
}
}
- revenueAdapter = ra;
+ //clean up the paths on the map
+ orUIManager.getMap().setTrainPaths(null);
+ //but retain paths already existing before
+ if (revenueAdapter != null) revenueAdapter.drawOptimalRunAsPath(orUIManager.getMap());
+ orUIManager.getMap().repaint();
}
}
@@ -842,6 +858,21 @@ implements ActionListener, KeyListener, RevenueListener {
setSelect(revenue[orCompIndex], revenueSelect[orCompIndex], false);
}
+ /**
+ * Sets the keyboard shortcut (CTRL+N) for displaying routes of the given company
+ */
+ private void setKeyboardShortcutForNetwork(PublicCompanyI orComp) {
+ if (networkInfoMenu == null) return;
+ for (int i=0 ; i<networkInfoMenu.getItemCount(); i++) {
+ JMenuItem item = networkInfoMenu.getItem(i);
+ if (item.getAccelerator() != null) item.setAccelerator(null);
+ if (item.getText().equals(orComp.getName())) {
+ item.setAccelerator(KeyStroke.getKeyStroke(
+ KeyEvent.VK_N , ActionEvent.CTRL_MASK ));
+ }
+ }
+
+ }
public void initORCompanyTurn(PublicCompanyI orComp, int orCompIndex) {
@@ -858,6 +889,8 @@ implements ActionListener, KeyListener, RevenueListener {
button1.setEnabled(false);
button2.setEnabled(false);
button3.setEnabled(false);
+
+ setKeyboardShortcutForNetwork(orComp);
}
public void initTileLayingStep() {
|