From: <ste...@us...> - 2010-08-11 23:22:05
|
Revision: 1379 http://rails.svn.sourceforge.net/rails/?rev=1379&view=rev Author: stefanfrey Date: 2010-08-11 23:21:59 +0000 (Wed, 11 Aug 2010) Log Message: ----------- Newline copy&paste fix and moved execution of multiple undos to server part of Rails Modified Paths: -------------- trunk/18xx/rails/game/GameManager.java trunk/18xx/rails/game/ReportBuffer.java trunk/18xx/rails/game/action/GameAction.java trunk/18xx/rails/ui/swing/ReportWindowDynamic.java Modified: trunk/18xx/rails/game/GameManager.java =================================================================== --- trunk/18xx/rails/game/GameManager.java 2010-08-10 23:08:08 UTC (rev 1378) +++ trunk/18xx/rails/game/GameManager.java 2010-08-11 23:21:59 UTC (rev 1379) @@ -773,30 +773,9 @@ // Process undo/redo centrally if (action instanceof GameAction) { - GameAction gameAction = (GameAction) action; - switch (gameAction.getMode()) { - case GameAction.SAVE: - result = save(gameAction); - break; - case GameAction.UNDO: - moveStack.undoMoveSet(false); - result = true; - break; - case GameAction.FORCED_UNDO: - moveStack.undoMoveSet(true); - result = true; - break; - case GameAction.REDO: - moveStack.redoMoveSet(); - result = true; - break; - case GameAction.EXPORT: - result = export(gameAction); - break; - } + result = processGameActions(gameAction); if (result) break; - } // All other actions: process per round @@ -890,6 +869,43 @@ return result; } + private boolean processGameActions(GameAction gameAction) { + // Process undo/redo centrally + boolean result = false; + + int index = gameAction.getmoveStackIndex(); + switch (gameAction.getMode()) { + case GameAction.SAVE: + result = save(gameAction); + break; + case GameAction.UNDO: + moveStack.undoMoveSet(true); + result = true; + break; + case GameAction.FORCED_UNDO: + if (index != -1) { + moveStack.gotoIndex(index); + } else { + moveStack.undoMoveSet(false); + } + result = true; + break; + case GameAction.REDO: + if (index != -1) { + moveStack.gotoIndex(index); + } else { + moveStack.redoMoveSet(); + } + result = true; + break; + case GameAction.EXPORT: + result = export(gameAction); + break; + } + + return result; + } + /* (non-Javadoc) * @see rails.game.GameManagerI#processOnReload(java.util.List) */ Modified: trunk/18xx/rails/game/ReportBuffer.java =================================================================== --- trunk/18xx/rails/game/ReportBuffer.java 2010-08-10 23:08:08 UTC (rev 1378) +++ trunk/18xx/rails/game/ReportBuffer.java 2010-08-11 23:21:59 UTC (rev 1379) @@ -51,10 +51,10 @@ if (init) { s.append("<a href=http://rails:" + index + ">"); s.append(message); - s.append("</a><br>"); + s.append("</a><br> "); // is the linefeed character to induce line feed on copy & paste init = false; } else { - s.append(message + "<br>"); + s.append(message + "<br> "); // see above } } return s.toString(); Modified: trunk/18xx/rails/game/action/GameAction.java =================================================================== --- trunk/18xx/rails/game/action/GameAction.java 2010-08-10 23:08:08 UTC (rev 1378) +++ trunk/18xx/rails/game/action/GameAction.java 2010-08-11 23:21:59 UTC (rev 1379) @@ -20,6 +20,7 @@ // Client-side settings protected String filepath; // Only applies to SAVE and LOAD + protected int moveStackIndex = -1; // target moveStackIndex, only for FORCED_UNDO and REDO public static final long serialVersionUID = 1L; @@ -37,6 +38,14 @@ return filepath; } + public void setmoveStackIndex(int moveStackIndex) { + this.moveStackIndex = moveStackIndex; + } + + public int getmoveStackIndex() { + return moveStackIndex; + } + public int getMode() { return mode; } Modified: trunk/18xx/rails/ui/swing/ReportWindowDynamic.java =================================================================== --- trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-08-10 23:08:08 UTC (rev 1378) +++ trunk/18xx/rails/ui/swing/ReportWindowDynamic.java 2010-08-11 23:21:59 UTC (rev 1379) @@ -146,16 +146,12 @@ MoveStack stack = gameUIManager.getGameManager().getMoveStack(); int currentIndex = stack.getIndex(); if (index > currentIndex) { // move forward - if (index != currentIndex +1) { - stack.gotoIndex(index - 1); - } GameAction action = new GameAction(GameAction.REDO); + action.setmoveStackIndex(index); gameUIManager.processOnServer(action); } else if (index < currentIndex) { // move backward - if (index != currentIndex - 1) { - stack.gotoIndex(index + 1); - } GameAction action = new GameAction(GameAction.FORCED_UNDO); + action.setmoveStackIndex(index); gameUIManager.processOnServer(action); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |