[Picross-commit] SF.net SVN: picross: [70] trunk/src/picross
Status: Pre-Alpha
Brought to you by:
yvan_norsa
|
From: <yva...@us...> - 2008-04-28 13:33:02
|
Revision: 70
http://picross.svn.sourceforge.net/picross/?rev=70&view=rev
Author: yvan_norsa
Date: 2008-04-28 06:30:53 -0700 (Mon, 28 Apr 2008)
Log Message:
-----------
game modes separation
Modified Paths:
--------------
trunk/src/picross/Picross.java
trunk/src/picross/PicrossController.java
trunk/src/picross/PicrossMediator.java
trunk/src/picross/game/random/RandomGameController.java
trunk/src/picross/game/random/RandomGameMediator.java
trunk/src/picross/game/random/RandomGameMode.java
trunk/src/picross/game/simple/LevelMenuController.java
trunk/src/picross/game/simple/LevelMenuMediator.java
trunk/src/picross/game/simple/LevelMenuModel.java
trunk/src/picross/game/simple/LevelMenuUI.java
Modified: trunk/src/picross/Picross.java
===================================================================
--- trunk/src/picross/Picross.java 2008-04-28 13:12:16 UTC (rev 69)
+++ trunk/src/picross/Picross.java 2008-04-28 13:30:53 UTC (rev 70)
@@ -33,11 +33,9 @@
package picross;
-import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.net.URL;
@@ -49,8 +47,8 @@
//import org.apache.log4j.Logger;
-import picross.game.simple.FileInfos;
-import picross.game.simple.LevelInfos;
+//import picross.game.simple.FileInfos;
+//import picross.game.simple.LevelInfos;
/**
* Helper class.
@@ -66,9 +64,6 @@
/** Data directory. */
private static final String DATA_DIR = "/picross/data/";
- /** File containing the data files list. */
- private static final String DATA_LIST = "contents.txt";
-
/** Images directory corresponding to the default locale. */
private static final String LOCAL_IMAGES_PATH = Picross.IMAGES_DIR
+ Locale.getDefault().getLanguage() + "/";
@@ -168,37 +163,5 @@
return Picross.getFile(Picross.DATA_DIR + name).openStream();
}
-
- /**
- * Reads the data files list and returns informations about the levels.
- *
- * @return informations about the available levels
- * @throws IOException if a problem occurs during the operation
- */
- public static List<LevelInfos> listDataFiles() throws IOException {
- List<LevelInfos> list = new ArrayList<LevelInfos>();
-
- BufferedReader in = null;
-
- try {
- in = new
- BufferedReader(new
- InputStreamReader(Picross
- .loadDataFile(Picross
- .DATA_LIST)));
-
- String line = null;
-
- while ((line = in.readLine()) != null) {
- list.add(FileInfos.readFileInfos(line));
- }
- } catch (IOException ioEx) {
- throw ioEx;
- } finally {
- in.close();
- }
-
- return list;
- }
}
Modified: trunk/src/picross/PicrossController.java
===================================================================
--- trunk/src/picross/PicrossController.java 2008-04-28 13:12:16 UTC (rev 69)
+++ trunk/src/picross/PicrossController.java 2008-04-28 13:30:53 UTC (rev 70)
@@ -50,14 +50,14 @@
public static final String PLAY_CMD = "PLAY_CMD";
/** Random game command. */
- public static final String RANDOM_GAME_CMD = "RANDOM_GAME_CMD";
+ //public static final String RANDOM_GAME_CMD = "RANDOM_GAME_CMD";
- public static final String NEXT_RANDOM_GAME_CMD = "NEXT_RANDOM_GAME_CMD";
+ //public static final String NEXT_RANDOM_GAME_CMD = "NEXT_RANDOM_GAME_CMD";
/** Select level command. */
- public static final String SELECT_LEVEL_CMD = "SELECT_LEVEL_CMD";
+ //public static final String SELECT_LEVEL_CMD = "SELECT_LEVEL_CMD";
- public static final String LEVEL_CMD = "LEVEL_CMD";
+ //public static final String LEVEL_CMD = "LEVEL_CMD";
/** Exit command. */
public static final String EXIT_CMD = "EXIT_CMD";
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2008-04-28 13:12:16 UTC (rev 69)
+++ trunk/src/picross/PicrossMediator.java 2008-04-28 13:30:53 UTC (rev 70)
@@ -47,7 +47,7 @@
import picross.game.GameCommand;
import picross.game.GameMediator;
-import picross.game.random.RandomGameMediator;
+//import picross.game.random.RandomGameMediator;
//import picross.game.simple.SimpleGameMediator;
@@ -76,6 +76,8 @@
/** Main view. */
private PicrossUI view;
+ private boolean firstTime = true;
+
/*** Constructor ***/
/** Constructor. */
@@ -116,11 +118,12 @@
}
*/
- // FIXME doesn't belong here
+ /*
if (cmd.equals(PicrossController.NEXT_RANDOM_GAME_CMD)) {
this.startRandomGame();
return;
}
+ */
/*
if (cmd.equals(PicrossController.SELECT_LEVEL_CMD)) {
@@ -145,7 +148,10 @@
}
if (cmd.equals(GameCommand.GAME_CMD)) {
- this.displayWaitScreen();
+ if (this.firstTime) {
+ this.displayWaitScreen();
+ this.firstTime = false;
+ }
GameCommand command = (GameCommand) e.getCommand();
this.startGame(command.getGame());
@@ -244,7 +250,8 @@
worker.start();
}
- /** Starts a random game. */
+ /** Starts a random game. *
+ /*
private void startRandomGame() {
Thread worker = new Thread() {
public void run() {
@@ -264,7 +271,7 @@
worker.start();
}
-
+ */
/** Starts a new game. */
/*
private void startGame(final String level) {
Modified: trunk/src/picross/game/random/RandomGameController.java
===================================================================
--- trunk/src/picross/game/random/RandomGameController.java 2008-04-28 13:12:16 UTC (rev 69)
+++ trunk/src/picross/game/random/RandomGameController.java 2008-04-28 13:30:53 UTC (rev 70)
@@ -52,6 +52,11 @@
/** Command asking to create another grid. */
static final String NEXT_CMD = "NEXT_CMD";
+ /** Random game command. */
+ /*public */static final String RANDOM_GAME_CMD = "RANDOM_GAME_CMD";
+
+ //public static final String NEXT_RANDOM_GAME_CMD = "NEXT_RANDOM_GAME_CMD";
+
/*** Static field ***/
/** The class' logger. */
Modified: trunk/src/picross/game/random/RandomGameMediator.java
===================================================================
--- trunk/src/picross/game/random/RandomGameMediator.java 2008-04-28 13:12:16 UTC (rev 69)
+++ trunk/src/picross/game/random/RandomGameMediator.java 2008-04-28 13:30:53 UTC (rev 70)
@@ -65,11 +65,12 @@
* @throws PicrossException if there is a problem loading the grid model
* or building the view
*/
+ /*
public RandomGameMediator() {//throws PicrossException {
//super();
//this.init();
}
-
+ */
/*** Methods overloaded from the class GameMediator ***/
/** {@inheritDoc} */
@@ -93,7 +94,9 @@
String cmd = e.getCommandName();
if (cmd.equals(RandomGameController.NEXT_CMD)) {
- this.fireEventPerformed(PicrossController.NEXT_RANDOM_GAME_CMD);
+ //this.fireEventPerformed(RandomGameController.NEXT_RANDOM_GAME_CMD);
+ this.fireEventPerformed(RandomGameMode.getRandomGameCommand());
+
return;
}
Modified: trunk/src/picross/game/random/RandomGameMode.java
===================================================================
--- trunk/src/picross/game/random/RandomGameMode.java 2008-04-28 13:12:16 UTC (rev 69)
+++ trunk/src/picross/game/random/RandomGameMode.java 2008-04-28 13:30:53 UTC (rev 70)
@@ -42,6 +42,7 @@
import picross.Picross;
+import picross.game.GameCommand;
import picross.game.GameMode;
import picross.menus.PicrossButton;
@@ -76,9 +77,13 @@
*/
/*** M\xE9thode ***/
+ public static GameCommand getRandomGameCommand() {
+ return new GameCommand(new RandomGameMediator());
+ }
+
public SimpleButton<JButton> getButton() {
ImageIcon icon = Picross.getLocalizedImage(RandomGameMode.RANDOM_BUTTON_IMAGE);
- SimpleEvent event = new SimpleEvent(new picross.game.GameCommand(new RandomGameMediator()));
+ SimpleEvent event = new SimpleEvent(RandomGameMode.getRandomGameCommand());
/*PicrossButton button = */return new PicrossButton(icon, event);
//button.getButton().setIcon(icon);
Modified: trunk/src/picross/game/simple/LevelMenuController.java
===================================================================
--- trunk/src/picross/game/simple/LevelMenuController.java 2008-04-28 13:12:16 UTC (rev 69)
+++ trunk/src/picross/game/simple/LevelMenuController.java 2008-04-28 13:30:53 UTC (rev 70)
@@ -49,6 +49,11 @@
static final String LEVELS_LIST_CMD = "LEVELS_LIST_CMD";
+ /** Select level command. */
+ //static final String SELECT_LEVEL_CMD = "SELECT_LEVEL_CMD";
+
+ static final String LEVEL_CMD = "LEVEL_CMD";
+
/*** Champ statique ***/
private static Logger log = Logger.getLogger(LevelMenuController.class);
Modified: trunk/src/picross/game/simple/LevelMenuMediator.java
===================================================================
--- trunk/src/picross/game/simple/LevelMenuMediator.java 2008-04-28 13:12:16 UTC (rev 69)
+++ trunk/src/picross/game/simple/LevelMenuMediator.java 2008-04-28 13:30:53 UTC (rev 70)
@@ -109,7 +109,7 @@
return;
}
- if (cmd.equals(picross.PicrossController.LEVEL_CMD)) {
+ if (cmd.equals(LevelMenuController.LEVEL_CMD)) {
this.fireEventPerformed(new picross.game.GameCommand(new picross.game.simple.SimpleGameMediator(e.getComment())));
return;
}
Modified: trunk/src/picross/game/simple/LevelMenuModel.java
===================================================================
--- trunk/src/picross/game/simple/LevelMenuModel.java 2008-04-28 13:12:16 UTC (rev 69)
+++ trunk/src/picross/game/simple/LevelMenuModel.java 2008-04-28 13:30:53 UTC (rev 70)
@@ -35,7 +35,9 @@
import java.awt.Dimension;
+import java.io.BufferedReader;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
@@ -53,6 +55,11 @@
* @author Y. Norsa
*/
class LevelMenuModel {
+ /*** Constant ***/
+
+ /** File containing the data files list. */
+ private static final String DATA_LIST = "contents.txt";
+
/*** Field ***/
/** Level list. */
@@ -74,7 +81,8 @@
try {
//this.levels = Picross.listDataFiles();
- infos = Picross.listDataFiles();
+ //infos = Picross.listDataFiles();
+ infos = LevelMenuModel.listDataFiles();
} catch (IOException ioEx) {
throw new PicrossException(ioEx);
}
@@ -92,6 +100,40 @@
}
}
+ /*** Static method ***/
+
+ /**
+ * Reads the data files list and returns informations about the levels.
+ *
+ * @return informations about the available levels
+ * @throws IOException if a problem occurs during the operation
+ */
+ public static List<LevelInfos> listDataFiles() throws IOException {
+ List<LevelInfos> list = new ArrayList<LevelInfos>();
+
+ BufferedReader in = null;
+
+ try {
+ in = new
+ BufferedReader(new
+ InputStreamReader(Picross
+ .loadDataFile(LevelMenuModel
+ .DATA_LIST)));
+
+ String line = null;
+
+ while ((line = in.readLine()) != null) {
+ list.add(FileInfos.readFileInfos(line));
+ }
+ } catch (IOException ioEx) {
+ throw ioEx;
+ } finally {
+ in.close();
+ }
+
+ return list;
+ }
+
/*** Method ***/
/**
Modified: trunk/src/picross/game/simple/LevelMenuUI.java
===================================================================
--- trunk/src/picross/game/simple/LevelMenuUI.java 2008-04-28 13:12:16 UTC (rev 69)
+++ trunk/src/picross/game/simple/LevelMenuUI.java 2008-04-28 13:30:53 UTC (rev 70)
@@ -97,7 +97,7 @@
int y = 150;
for (String level : levels) {
- SimpleEvent event = new SimpleEvent(PicrossController.LEVEL_CMD, level);
+ SimpleEvent event = new SimpleEvent(LevelMenuController.LEVEL_CMD, level);
this.addSimpleButton(level, event, listener, x, y);
y += 75;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|