|
From: <ev...@us...> - 2011-05-04 19:10:51
|
Revision: 1544
http://rails.svn.sourceforge.net/rails/?rev=1544&view=rev
Author: evos
Date: 2011-05-04 19:10:44 +0000 (Wed, 04 May 2011)
Log Message:
-----------
Autosave/load improvements and fixes.
Also fixed a few bugs introduced by the new capability for companies to have more than one home base.
Modified Paths:
--------------
trunk/18xx/rails/game/OperatingRound.java
trunk/18xx/rails/game/PublicCompany.java
trunk/18xx/rails/game/specific/_1856/CGRFormationRound.java
trunk/18xx/rails/ui/swing/ActionPerformer.java
trunk/18xx/rails/ui/swing/AutoSaveLoadDialog.java
trunk/18xx/rails/ui/swing/GameStatus.java
trunk/18xx/rails/ui/swing/GameUIManager.java
trunk/18xx/rails/ui/swing/ORUIManager.java
trunk/18xx/rails/ui/swing/StatusWindow.java
trunk/18xx/rails/ui/swing/elements/Caption.java
trunk/18xx/rails/ui/swing/elements/CheckBoxDialog.java
trunk/18xx/rails/ui/swing/elements/MessageDialog.java
trunk/18xx/rails/ui/swing/elements/RadioButtonDialog.java
trunk/18xx/rails/ui/swing/gamespecific/_1835/StatusWindow_1835.java
trunk/18xx/rails/ui/swing/gamespecific/_1856/StatusWindow_1856.java
trunk/18xx/rails/ui/swing/gamespecific/_18EU/GameStatus_18EU.java
trunk/18xx/rails/ui/swing/gamespecific/_18EU/GameUIManager_18EU.java
Modified: trunk/18xx/rails/game/OperatingRound.java
===================================================================
--- trunk/18xx/rails/game/OperatingRound.java 2011-05-04 19:10:09 UTC (rev 1543)
+++ trunk/18xx/rails/game/OperatingRound.java 2011-05-04 19:10:44 UTC (rev 1544)
@@ -1958,6 +1958,8 @@
// Check if any more companies must discard trains,
// otherwise continue train buying
if (!checkForExcessTrains()) {
+ // Trains may have been discarded by other players
+ setCurrentPlayer (operatingCompany.get().getPresident());
stepObject.set(GameDef.OrStep.BUY_TRAIN);
}
Modified: trunk/18xx/rails/game/PublicCompany.java
===================================================================
--- trunk/18xx/rails/game/PublicCompany.java 2011-05-04 19:10:09 UTC (rev 1543)
+++ trunk/18xx/rails/game/PublicCompany.java 2011-05-04 19:10:44 UTC (rev 1544)
@@ -812,8 +812,8 @@
* @param homeHex The homeHex to set.
*/
public void setHomeHex(MapHex homeHex) {
- if (homeHexes == null) homeHexes = new ArrayList<MapHex>(1);
- homeHexes.set(0, homeHex);
+ homeHexes = new ArrayList<MapHex>(1);
+ homeHexes.add(homeHex);
}
/**
Modified: trunk/18xx/rails/game/specific/_1856/CGRFormationRound.java
===================================================================
--- trunk/18xx/rails/game/specific/_1856/CGRFormationRound.java 2011-05-04 19:10:09 UTC (rev 1543)
+++ trunk/18xx/rails/game/specific/_1856/CGRFormationRound.java 2011-05-04 19:10:44 UTC (rev 1544)
@@ -526,13 +526,14 @@
for (PublicCompanyI comp : mergingCompanies) {
// Exchange home tokens and collect non-home tokens
+ List<MapHex> homeHexes = comp.getHomeHexes();
for (TokenI token :comp.getTokens()) {
if (token instanceof BaseToken) {
bt = (BaseToken) token;
if (!bt.isPlaced()) continue;
city = (City) bt.getHolder();
hex = city.getHolder();
- if (hex == comp.getHomeHexes()) {
+ if (homeHexes != null && homeHexes.contains(hex)) {
homeTokens.add(bt);
} else {
nonHomeTokens.add(bt);
Modified: trunk/18xx/rails/ui/swing/ActionPerformer.java
===================================================================
--- trunk/18xx/rails/ui/swing/ActionPerformer.java 2011-05-04 19:10:09 UTC (rev 1543)
+++ trunk/18xx/rails/ui/swing/ActionPerformer.java 2011-05-04 19:10:44 UTC (rev 1544)
@@ -10,4 +10,6 @@
public boolean process(PossibleAction action);
public boolean processImmediateAction();
+
+ //public void deactivate();
}
Modified: trunk/18xx/rails/ui/swing/AutoSaveLoadDialog.java
===================================================================
--- trunk/18xx/rails/ui/swing/AutoSaveLoadDialog.java 2011-05-04 19:10:09 UTC (rev 1543)
+++ trunk/18xx/rails/ui/swing/AutoSaveLoadDialog.java 2011-05-04 19:10:44 UTC (rev 1544)
@@ -129,7 +129,8 @@
}
interval = ((Integer) intervalSpinner.getValue()).intValue();
} else if (arg0.getSource().equals(cancelButton)) {
- status = -1;
+ //status = -1;
+ // Better change nothing?
}
this.setVisible(false);
this.dispose();
Modified: trunk/18xx/rails/ui/swing/GameStatus.java
===================================================================
--- trunk/18xx/rails/ui/swing/GameStatus.java 2011-05-04 19:10:09 UTC (rev 1543)
+++ trunk/18xx/rails/ui/swing/GameStatus.java 2011-05-04 19:10:44 UTC (rev 1544)
@@ -675,7 +675,9 @@
int index = 0;
if (options.size() > 1) {
if (startCompany) {
- RadioButtonDialog dialog = new RadioButtonDialog (gameUIManager,
+ RadioButtonDialog dialog = new RadioButtonDialog (
+ gameUIManager,
+ parent,
LocalText.getText("PleaseSelect"),
LocalText.getText("WHICH_START_PRICE",
playerName,
@@ -896,7 +898,21 @@
+ (j == index ? " PD" : ""));
}
}
+
+ public void highlightCurrentPlayer (int index) {
+ for (int j = 0; j < np; j++) {
+ upperPlayerCaption[j].setHighlight(j == index);
+ lowerPlayerCaption[j].setHighlight(j == index);
+ }
+ }
+ public void highlightLocalPlayer (int index) {
+ for (int j = 0; j < np; j++) {
+ upperPlayerCaption[j].setLocalPlayer(j == index);
+ lowerPlayerCaption[j].setLocalPlayer(j == index);
+ }
+ }
+
public String getSRPlayer() {
if (actorIndex >= 0)
return players[actorIndex].getName();
Modified: trunk/18xx/rails/ui/swing/GameUIManager.java
===================================================================
--- trunk/18xx/rails/ui/swing/GameUIManager.java 2011-05-04 19:10:09 UTC (rev 1543)
+++ trunk/18xx/rails/ui/swing/GameUIManager.java 2011-05-04 19:10:44 UTC (rev 1544)
@@ -262,6 +262,7 @@
} else if (!wasMyTurn && isMyTurn) {
autoLoadPoller.setActive(false);
setCurrentDialog(new MessageDialog(this,
+ (JFrame) activeWindow,
LocalText.getText("Message"),
LocalText.getText("YourTurn", localPlayerName)),
null);
@@ -280,6 +281,8 @@
// and make sure that the right window is active.
updateUI();
+ statusWindow.initGameActions();
+ if (!myTurn) return true;
statusWindow.setGameActions();
statusWindow.setCorrectionMenu();
@@ -328,6 +331,7 @@
String[] message = DisplayBuffer.get();
if (message != null) {
setCurrentDialog(new MessageDialog(this,
+ (JFrame) activeWindow,
LocalText.getText("Message"),
"<html>" + Util.joinWithDelimiter(message, "<br>")),
null);
@@ -606,6 +610,7 @@
orWindow.toFront();
CheckBoxDialog dialog = new CheckBoxDialog(this,
+ orWindow,
LocalText.getText("ExchangeTokens"),
prompt,
options.toArray(new String[0]));
@@ -697,7 +702,7 @@
}
}
- if (currentDialogAction != null) processAction(currentDialogAction);
+ /*if (currentDialogAction != null)*/ processAction(currentDialogAction);
}
Modified: trunk/18xx/rails/ui/swing/ORUIManager.java
===================================================================
--- trunk/18xx/rails/ui/swing/ORUIManager.java 2011-05-04 19:10:09 UTC (rev 1543)
+++ trunk/18xx/rails/ui/swing/ORUIManager.java 2011-05-04 19:10:44 UTC (rev 1544)
@@ -550,6 +550,7 @@
orWindow.toFront();
CheckBoxDialog dialog = new CheckBoxDialog(this,
+ orWindow,
LocalText.getText("DestinationsReached"),
LocalText.getText("DestinationsReachedPrompt"),
options.toArray(new String[0]));
@@ -1226,6 +1227,7 @@
// TODO This must be split off from here, as in the future
// different clients may handle the discards of each company.
+ /*
while (possibleActions.contains(DiscardTrain.class)) {
// Check if there are any forced discards;
// otherwise, nothing to do here
@@ -1235,6 +1237,7 @@
gameUIManager.discardTrains(dt);
}
+ */
}
int newOffBoardRevenueStep =
@@ -1433,6 +1436,7 @@
}
}
RadioButtonDialog currentDialog = new RadioButtonDialog (gameUIManager,
+ orWindow,
LocalText.getText("Select"),
LocalText.getText("SelectLoansToRepay", action.getCompanyName()),
options,
Modified: trunk/18xx/rails/ui/swing/StatusWindow.java
===================================================================
--- trunk/18xx/rails/ui/swing/StatusWindow.java 2011-05-04 19:10:09 UTC (rev 1543)
+++ trunk/18xx/rails/ui/swing/StatusWindow.java 2011-05-04 19:10:44 UTC (rev 1544)
@@ -349,7 +349,7 @@
ws.set(frame);
}
- public void setGameActions() {
+ public void initGameActions() {
// Check the local Undo/Redo menu items,
// which must always be up-to-date.
@@ -358,7 +358,9 @@
redoItem.setEnabled(false);
redoItem2.setEnabled(false);
// SAVE, RELOAD, AUTOSAVELOAD are always enabled
+ }
+ public void setGameActions() {
List<GameAction> gameActions =
possibleActions.getType(GameAction.class);
if (gameActions != null) {
Modified: trunk/18xx/rails/ui/swing/elements/Caption.java
===================================================================
--- trunk/18xx/rails/ui/swing/elements/Caption.java 2011-05-04 19:10:09 UTC (rev 1543)
+++ trunk/18xx/rails/ui/swing/elements/Caption.java 2011-05-04 19:10:44 UTC (rev 1544)
@@ -2,6 +2,7 @@
package rails.ui.swing.elements;
import java.awt.Color;
+import java.awt.Font;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
@@ -13,19 +14,28 @@
private Border labelBorder = BorderFactory.createEmptyBorder(1, 2, 1, 2);
- private static final Color NORMAL_BG_COLOR = new Color(240, 240, 240);
+ private static final Color NORMAL_BG_COLOUR = new Color(240, 240, 240);
private static final Color HIGHLIGHT_BG_COLOUR = new Color(255, 255, 80);
+
+ private static final Color NORMAL_FG_COLOUR = new Color (0, 0, 0);
+
+ private static final Color LOCAL_PLAYER_COLOUR = new Color (255, 0, 0);
public Caption(String text) {
super(text);
- this.setBackground(NORMAL_BG_COLOR);
+ this.setForeground(NORMAL_FG_COLOUR);
+ this.setBackground(NORMAL_BG_COLOUR);
this.setHorizontalAlignment(SwingConstants.CENTER);
this.setBorder(labelBorder);
this.setOpaque(true);
}
public void setHighlight(boolean highlight) {
- this.setBackground(highlight ? HIGHLIGHT_BG_COLOUR : NORMAL_BG_COLOR);
+ this.setBackground(highlight ? HIGHLIGHT_BG_COLOUR : NORMAL_BG_COLOUR);
}
+
+ public void setLocalPlayer (boolean highlight) {
+ this.setForeground(highlight ? LOCAL_PLAYER_COLOUR : NORMAL_FG_COLOUR);
+ }
}
Modified: trunk/18xx/rails/ui/swing/elements/CheckBoxDialog.java
===================================================================
--- trunk/18xx/rails/ui/swing/elements/CheckBoxDialog.java 2011-05-04 19:10:09 UTC (rev 1543)
+++ trunk/18xx/rails/ui/swing/elements/CheckBoxDialog.java 2011-05-04 19:10:44 UTC (rev 1544)
@@ -35,12 +35,12 @@
protected static Logger log =
Logger.getLogger(CheckBoxDialog.class.getPackage().getName());
- public CheckBoxDialog(DialogOwner owner, String title, String message,
+ public CheckBoxDialog(DialogOwner owner, JFrame window, String title, String message,
String[] options) {
- this (owner, title, message, options, null, false);
+ this (owner, window, title, message, options, null, false);
}
- public CheckBoxDialog(DialogOwner owner, String title, String message,
+ public CheckBoxDialog(DialogOwner owner, JFrame window, String title, String message,
String[] options, boolean[] selectedOptions, boolean addCancelButton) {
super((Frame) null, title, false); // Non-modal
this.owner = owner;
@@ -58,16 +58,10 @@
pack();
// Center on owner
- /*
- int x =
- (int) owner.getLocationOnScreen().getX()
- + (owner.getWidth() - getWidth()) / 2;
- int y =
- (int) owner.getLocationOnScreen().getY()
- + (owner.getHeight() - getHeight()) / 2;
- */
- int x = 400;
- int y = 400;
+ int x = (int) window.getLocationOnScreen().getX()
+ + (window.getWidth() - getWidth()) / 2;
+ int y = (int) window.getLocationOnScreen().getY()
+ + (window.getHeight() - getHeight()) / 2;
setLocation(x, y);
setVisible(true);
Modified: trunk/18xx/rails/ui/swing/elements/MessageDialog.java
===================================================================
--- trunk/18xx/rails/ui/swing/elements/MessageDialog.java 2011-05-04 19:10:09 UTC (rev 1543)
+++ trunk/18xx/rails/ui/swing/elements/MessageDialog.java 2011-05-04 19:10:44 UTC (rev 1544)
@@ -28,7 +28,7 @@
protected static Logger log =
Logger.getLogger(MessageDialog.class.getPackage().getName());
- public MessageDialog(DialogOwner owner, String title, String message) {
+ public MessageDialog(DialogOwner owner, JFrame window, String title, String message) {
super((Frame) null, title, false); // Non-modal
this.owner = owner;
@@ -37,12 +37,15 @@
initialize();
pack();
- int x = 400;
- int y = 400;
+ // Center on window
+ int x = (int) window.getLocationOnScreen().getX()
+ + (window.getWidth() - getWidth()) / 2;
+ int y = (int) window.getLocationOnScreen().getY()
+ + (window.getHeight() - getHeight()) / 2;
setLocation(x, y);
setVisible(true);
- setAlwaysOnTop(true);
+ toFront();
}
private void initialize() {
Modified: trunk/18xx/rails/ui/swing/elements/RadioButtonDialog.java
===================================================================
--- trunk/18xx/rails/ui/swing/elements/RadioButtonDialog.java 2011-05-04 19:10:09 UTC (rev 1543)
+++ trunk/18xx/rails/ui/swing/elements/RadioButtonDialog.java 2011-05-04 19:10:44 UTC (rev 1544)
@@ -33,7 +33,7 @@
protected static Logger log =
Logger.getLogger(RadioButtonDialog.class.getPackage().getName());
- public RadioButtonDialog(DialogOwner owner, String title, String message,
+ public RadioButtonDialog(DialogOwner owner, JFrame window, String title, String message,
String[] options, int selectedOption) {
super((Frame) null, title, false); // Non-modal
this.owner = owner;
@@ -45,17 +45,11 @@
initialize();
pack();
- // Center on owner
- /*
- int x =
- (int) owner.getLocationOnScreen().getX()
- + (owner.getWidth() - getWidth()) / 2;
- int y =
- (int) owner.getLocationOnScreen().getY()
- + (owner.getHeight() - getHeight()) / 2;
- */
- int x = 400;
- int y = 400;
+ // Center on window
+ int x = (int) window.getLocationOnScreen().getX()
+ + (window.getWidth() - getWidth()) / 2;
+ int y = (int) window.getLocationOnScreen().getY()
+ + (window.getHeight() - getHeight()) / 2;
setLocation(x, y);
setVisible(true);
Modified: trunk/18xx/rails/ui/swing/gamespecific/_1835/StatusWindow_1835.java
===================================================================
--- trunk/18xx/rails/ui/swing/gamespecific/_1835/StatusWindow_1835.java 2011-05-04 19:10:09 UTC (rev 1543)
+++ trunk/18xx/rails/ui/swing/gamespecific/_1835/StatusWindow_1835.java 2011-05-04 19:10:44 UTC (rev 1544)
@@ -89,6 +89,7 @@
);
}
currentDialog = new CheckBoxDialog (gameUIManager,
+ this,
LocalText.getText("Select"),
LocalText.getText("SelectCompaniesToFold",
getCurrentPlayer().getName(),
Modified: trunk/18xx/rails/ui/swing/gamespecific/_1856/StatusWindow_1856.java
===================================================================
--- trunk/18xx/rails/ui/swing/gamespecific/_1856/StatusWindow_1856.java 2011-05-04 19:10:09 UTC (rev 1543)
+++ trunk/18xx/rails/ui/swing/gamespecific/_1856/StatusWindow_1856.java 2011-05-04 19:10:44 UTC (rev 1544)
@@ -98,6 +98,7 @@
}
RadioButtonDialog currentDialog = new RadioButtonDialog (gameUIManager,
+ this,
LocalText.getText("1856MergerDialog", action.getCompanyName()),
message,
options,
Modified: trunk/18xx/rails/ui/swing/gamespecific/_18EU/GameStatus_18EU.java
===================================================================
--- trunk/18xx/rails/ui/swing/gamespecific/_18EU/GameStatus_18EU.java 2011-05-04 19:10:09 UTC (rev 1543)
+++ trunk/18xx/rails/ui/swing/gamespecific/_18EU/GameStatus_18EU.java 2011-05-04 19:10:44 UTC (rev 1544)
@@ -70,6 +70,7 @@
}
RadioButtonDialog dialog = new RadioButtonDialog (gameUIManager,
+ parent,
LocalText.getText("PleaseSelect"),
LocalText.getText("SelectCompanyToMergeMinorInto",
minor.getName()),
Modified: trunk/18xx/rails/ui/swing/gamespecific/_18EU/GameUIManager_18EU.java
===================================================================
--- trunk/18xx/rails/ui/swing/gamespecific/_18EU/GameUIManager_18EU.java 2011-05-04 19:10:09 UTC (rev 1543)
+++ trunk/18xx/rails/ui/swing/gamespecific/_18EU/GameUIManager_18EU.java 2011-05-04 19:10:44 UTC (rev 1544)
@@ -73,6 +73,7 @@
+ minor.getLongName();
}
dialog = new RadioButtonDialog (this,
+ statusWindow,
LocalText.getText("PleaseSelect"),
LocalText.getText(
"SelectMinorToMerge",
@@ -90,6 +91,7 @@
options[i] = cities.get(i).toString();
}
dialog = new RadioButtonDialog (this,
+ statusWindow,
LocalText.getText("PleaseSelect"),
LocalText.getText(
"SelectHomeStation",
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|