|
From: <ste...@us...> - 2010-08-22 19:53:40
|
Revision: 1403
http://rails.svn.sourceforge.net/rails/?rev=1403&view=rev
Author: stefanfrey
Date: 2010-08-22 19:53:34 +0000 (Sun, 22 Aug 2010)
Log Message:
-----------
Final improvements to Gamehistory report window for upcoming release
Modified Paths:
--------------
trunk/18xx/LocalisedText.properties
trunk/18xx/rails/game/move/MoveStack.java
trunk/18xx/rails/ui/swing/AbstractReportWindow.java
trunk/18xx/rails/ui/swing/ConfigWindow.java
trunk/18xx/rails/ui/swing/GameUIManager.java
trunk/18xx/rails/ui/swing/MessagePanel.java
trunk/18xx/rails/ui/swing/ReportWindowDynamic.java
Modified: trunk/18xx/LocalisedText.properties
===================================================================
--- trunk/18xx/LocalisedText.properties 2010-08-22 15:47:27 UTC (rev 1402)
+++ trunk/18xx/LocalisedText.properties 2010-08-22 19:53:34 UTC (rev 1403)
@@ -494,11 +494,14 @@
RepayLoans=Repay loan(s)
RepayLoan=Repay {0} loan(s) of {1} for {2}
REPORT=Report Window
-REPORT_MOVE_BACKWARD=<
-REPORT_MOVE_FORWARD=>
REPORT_COMMENT=Comment
REPORT_COMMENT_TITLE=Add Comment
REPORT_COMMENT_ASK=Add a comment to the previous action
+REPORT_MOVE_BACKWARD=<
+REPORT_MOVE_FORWARD=>
+REPORT_PLAY_FROM_HERE=Play from here
+REPORT_LEAVE_TIMEWARP=Leave history
+REPORT_TIMEWARP_ACTIVE=<html><center><font color="red"> Game history active <br> (Other windows disabled) </font></center></html>
REVENUE=Revenue
RevenueBonus=Bonus(es) = {0}
RevenueCalculation=support for revenue calculation
Modified: trunk/18xx/rails/game/move/MoveStack.java
===================================================================
--- trunk/18xx/rails/game/move/MoveStack.java 2010-08-22 15:47:27 UTC (rev 1402)
+++ trunk/18xx/rails/game/move/MoveStack.java 2010-08-22 19:53:34 UTC (rev 1403)
@@ -178,6 +178,10 @@
}
}
+ public int size() {
+ return moveStack.size();
+ }
+
/**
* undo/redo to a given moveStack index
*/
Modified: trunk/18xx/rails/ui/swing/AbstractReportWindow.java
===================================================================
--- trunk/18xx/rails/ui/swing/AbstractReportWindow.java 2010-08-22 15:47:27 UTC (rev 1402)
+++ trunk/18xx/rails/ui/swing/AbstractReportWindow.java 2010-08-22 19:53:34 UTC (rev 1403)
@@ -10,6 +10,9 @@
public abstract class AbstractReportWindow extends JFrame {
private static final long serialVersionUID = 1L;
+
+ // can be set to false, than it cannot be closed
+ protected boolean closeable = true;
public void init() {
setSize(400, 400);
@@ -17,13 +20,16 @@
setTitle(LocalText.getText("GameReportTitle"));
final JFrame frame = this;
+ this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
+ if (!closeable) return;
StatusWindow.uncheckMenuItemBox(StatusWindow.REPORT_CMD);
frame.dispose();
}
});
+
setVisible("yes".equalsIgnoreCase(Config.get("report.window.open")));
}
Modified: trunk/18xx/rails/ui/swing/ConfigWindow.java
===================================================================
--- trunk/18xx/rails/ui/swing/ConfigWindow.java 2010-08-22 15:47:27 UTC (rev 1402)
+++ trunk/18xx/rails/ui/swing/ConfigWindow.java 2010-08-22 19:53:34 UTC (rev 1403)
@@ -555,6 +555,12 @@
private boolean saveConfig() {
Config.updateProfile(fromStatusWindow); // transfer the configitem to the active profile
+
+ if (fromStatusWindow) {
+ JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_APPLY_MESSAGE"),
+ LocalText.getText("CONFIG_APPLY_TITLE"), JOptionPane.INFORMATION_MESSAGE);
+ }
+
if (Config.saveActiveProfile()) {
JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_SAVE_CONFIRM_MESSAGE", Config.getActiveProfileName()),
LocalText.getText("CONFIG_SAVE_TITLE"), JOptionPane.INFORMATION_MESSAGE);
Modified: trunk/18xx/rails/ui/swing/GameUIManager.java
===================================================================
--- trunk/18xx/rails/ui/swing/GameUIManager.java 2010-08-22 15:47:27 UTC (rev 1402)
+++ trunk/18xx/rails/ui/swing/GameUIManager.java 2010-08-22 19:53:34 UTC (rev 1403)
@@ -1,5 +1,7 @@
package rails.ui.swing;
+import java.awt.Component;
+import java.awt.Container;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.GraphicsConfiguration;
@@ -822,7 +824,26 @@
public boolean getGameParameterAsBoolean (GuiDef.Parm key) {
return (Boolean) getGameParameter(key);
}
+
+ private void setEnabledWindow(boolean enabled, JFrame window, JFrame exceptionWindow) {
+
+ if (window != null && window != exceptionWindow) {
+ window.setEnabled(enabled);
+ }
+ }
+ /**
+ * deactivate all game windows, except the argument one
+ */
+ public void setEnabledAllWindows(boolean enabled, JFrame exceptionWindow) {
+ setEnabledWindow(enabled, stockChart, exceptionWindow);
+ setEnabledWindow(enabled, reportWindow, exceptionWindow);
+ setEnabledWindow(enabled, configWindow, exceptionWindow);
+ setEnabledWindow(enabled, orWindow, exceptionWindow);
+ setEnabledWindow(enabled, startRoundWindow, exceptionWindow);
+ setEnabledWindow(enabled, statusWindow, exceptionWindow);
+ }
+
private void updateWindowsLookAndFeel() {
SwingUtilities.updateComponentTreeUI(statusWindow);
statusWindow.pack();
@@ -843,11 +864,5 @@
Scale.initFromConfiguration();
instance.initFontSettings();
instance.updateWindowsLookAndFeel();
-
-// EventQueue.invokeLater(new Runnable() {
-// public void run() {
-// instance.repaintWindows();
-// }
-// });
}
}
Modified: trunk/18xx/rails/ui/swing/MessagePanel.java
===================================================================
--- trunk/18xx/rails/ui/swing/MessagePanel.java 2010-08-22 15:47:27 UTC (rev 1402)
+++ trunk/18xx/rails/ui/swing/MessagePanel.java 2010-08-22 19:53:34 UTC (rev 1403)
@@ -75,7 +75,7 @@
// display
String text = messageText.toString();
int lines = text.split("<[Bb][Rr]>").length + 1;
- setLines(lines);
+// setLines(lines);
message.setText("<html><center>" + text + "</center></html>");
}
Modified: trunk/18xx/rails/ui/swing/ReportWindowDynamic.java
===================================================================
--- trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-08-22 15:47:27 UTC (rev 1402)
+++ trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-08-22 19:53:34 UTC (rev 1403)
@@ -1,7 +1,10 @@
package rails.ui.swing;
+import java.awt.BorderLayout;
+import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
+import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
@@ -9,6 +12,7 @@
import javax.swing.JButton;
import javax.swing.JEditorPane;
+import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
@@ -36,14 +40,20 @@
private GameUIManager gameUIManager;
+ private JLabel message;
+
private JScrollPane reportPane;
private JEditorPane editorPane;
private JPanel buttonPanel;
private ActionButton forwardButton;
private ActionButton backwardButton;
+ private JButton returnButton;
+ private JButton playFromHereButton;
private JButton commentButton;
+ private boolean timeWarpMode;
+
protected static Logger log =
Logger.getLogger(ReportWindowDynamic.class.getPackage().getName());
@@ -54,6 +64,41 @@
}
public void init() {
+ super.init();
+
+ setLayout(new BorderLayout());
+
+ JPanel messagePanel = new JPanel();
+ messagePanel.setLayout(new BorderLayout());
+
+ message = new JLabel();
+ message.setText( LocalText.getText("REPORT_TIMEWARP_ACTIVE"));
+ message.setHorizontalAlignment(JLabel.CENTER);
+ messagePanel.add(message, "North");
+
+ JPanel timeWarpButtons = new JPanel();
+ returnButton = new JButton(LocalText.getText("REPORT_LEAVE_TIMEWARP"));
+ returnButton.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent arg0) {
+ gotoLastIndex();
+ }
+ }
+ );
+ timeWarpButtons.add(returnButton);
+
+ playFromHereButton = new JButton(LocalText.getText("REPORT_PLAY_FROM_HERE"));
+ playFromHereButton.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent arg0) {
+ deactivateTimeWarp();
+ }
+ }
+ );
+ timeWarpButtons.add(playFromHereButton);
+ messagePanel.add(timeWarpButtons, "South");
+ add(messagePanel, "North");
+
editorPane = new JEditorPane();
editorPane.setEditable(false);
editorPane.setContentType("text/html");
@@ -74,7 +119,6 @@
buttonPanel = new JPanel();
add(buttonPanel, "South");
-
backwardButton = new ActionButton(LocalText.getText("REPORT_MOVE_BACKWARD"));
backwardButton.addActionListener(this);
buttonPanel.add(backwardButton);
@@ -83,6 +127,7 @@
forwardButton.addActionListener(this);
buttonPanel.add(forwardButton);
+
commentButton = new JButton(LocalText.getText("REPORT_COMMENT"));
commentButton.addActionListener(
new ActionListener() {
@@ -106,7 +151,6 @@
);
buttonPanel.add(commentButton);
- super.init();
}
@Override
@@ -116,7 +160,9 @@
scrollDown();
forwardButton.setEnabled(false);
- backwardButton.setEnabled(true);
+ backwardButton.setEnabled(false);
+
+ boolean haveRedo = false;
List<GameAction> gameActions = PossibleActions.getInstance().getType(GameAction.class);
for (GameAction action:gameActions) {
switch (action.getMode()) {
@@ -128,9 +174,12 @@
case GameAction.REDO:
forwardButton.setPossibleAction(action);
forwardButton.setEnabled(true);
+ haveRedo = true;
+ if (!timeWarpMode) activateTimeWarp();
break;
}
}
+ if (!haveRedo) deactivateTimeWarp();
}
@Override
@@ -168,6 +217,10 @@
}
}
+ private void gotoLastIndex() {
+ gotoIndex(gameUIManager.getGameManager().getMoveStack().size());
+ }
+
private void gotoIndex(int index) {
MoveStack stack = gameUIManager.getGameManager().getMoveStack();
int currentIndex = stack.getIndex();
@@ -182,4 +235,21 @@
}
}
+ private void activateTimeWarp() {
+ message.setVisible(true);
+ playFromHereButton.setVisible(true);
+ returnButton.setVisible(true);
+ gameUIManager.setEnabledAllWindows(false, this);
+ timeWarpMode = true;
+ closeable = false;
+ }
+
+ private void deactivateTimeWarp() {
+ gameUIManager.setEnabledAllWindows(true, this);
+ message.setVisible(false);
+ playFromHereButton.setVisible(false);
+ returnButton.setVisible(false);
+ timeWarpMode = false;
+ closeable = true;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|