[Picross-commit] SF.net SVN: picross:[113] branches/engine_split
Status: Pre-Alpha
Brought to you by:
yvan_norsa
From: <yva...@us...> - 2013-01-14 08:38:38
|
Revision: 113 http://sourceforge.net/p/picross/code/113 Author: yvan_norsa Date: 2013-01-14 08:38:33 +0000 (Mon, 14 Jan 2013) Log Message: ----------- android integration into build script Modified Paths: -------------- branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java branches/engine_split/android/src/picross/specific/game/simple/ui/SimpleGameModeUI.java branches/engine_split/android/src/picross/specific/ui/GameMenuUI.java branches/engine_split/android/src/picross/specific/ui/MenuUI.java branches/engine_split/android/src/picross/specific/ui/PicrossButton.java branches/engine_split/build.xml branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java branches/engine_split/common/src/picross/common/ui/MainMenuUI.java branches/engine_split/src/picross/app/MainMenuAppUI.java branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameModeUI.java branches/engine_split/swing/src/picross/specific/game/simple/ui/LevelMenuUI.java branches/engine_split/swing/src/picross/specific/game/simple/ui/SimpleGameModeUI.java branches/engine_split/swing/src/picross/specific/ui/MenuUI.java branches/engine_split/swing/src/picross/specific/ui/WaitMenuUI.java branches/engine_split/swing/test/picross/specific/ui/PicrossUIHelperTest.java Added Paths: ----------- branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java branches/engine_split/android/src/picross/specific/game/simple/ui/LevelMenuUI.java branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java branches/engine_split/images/empty_button.png branches/engine_split/images/en/button_back.png branches/engine_split/images/en/button_exit.png branches/engine_split/images/en/button_play.png branches/engine_split/images/en/button_random.png branches/engine_split/images/en/button_select.png branches/engine_split/images/en/label_wait.png branches/engine_split/images/fr/button_back.png branches/engine_split/images/fr/button_exit.png branches/engine_split/images/fr/button_play.png branches/engine_split/images/fr/button_random.png branches/engine_split/images/fr/button_select.png branches/engine_split/images/fr/label_wait.png Removed Paths: ------------- branches/engine_split/android/libs/bundleHelper.jar branches/engine_split/android/libs/mmvcs.jar branches/engine_split/android/libs/picross-common.jar branches/engine_split/android/libs/picross-engine.jar branches/engine_split/android/libs/simpleButton.jar branches/engine_split/android/res/drawable/background.png branches/engine_split/android/res/drawable/button_play.png branches/engine_split/android/res/drawable/button_random.png branches/engine_split/android/res/drawable/button_select.png branches/engine_split/android/servicesData/META-INF/services/ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java branches/engine_split/images/empty-button.png branches/engine_split/images/en/button-back.png branches/engine_split/images/en/button-exit.png branches/engine_split/images/en/button-play.png branches/engine_split/images/en/button-random.png branches/engine_split/images/en/button-select.png branches/engine_split/images/en/label-wait.png branches/engine_split/images/fr/button-back.png branches/engine_split/images/fr/button-exit.png branches/engine_split/images/fr/button-play.png branches/engine_split/images/fr/button-random.png branches/engine_split/images/fr/button-select.png branches/engine_split/images/fr/label-wait.png Deleted: branches/engine_split/android/libs/bundleHelper.jar =================================================================== (Binary files differ) Deleted: branches/engine_split/android/libs/mmvcs.jar =================================================================== (Binary files differ) Deleted: branches/engine_split/android/libs/picross-common.jar =================================================================== (Binary files differ) Deleted: branches/engine_split/android/libs/picross-engine.jar =================================================================== (Binary files differ) Deleted: branches/engine_split/android/libs/simpleButton.jar =================================================================== (Binary files differ) Deleted: branches/engine_split/android/res/drawable/background.png =================================================================== (Binary files differ) Deleted: branches/engine_split/android/res/drawable/button_play.png =================================================================== (Binary files differ) Deleted: branches/engine_split/android/res/drawable/button_random.png =================================================================== (Binary files differ) Deleted: branches/engine_split/android/res/drawable/button_select.png =================================================================== (Binary files differ) Modified: branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/android/src/picross/specific/activities/MainMenuActivityUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -49,10 +49,10 @@ private static final long serialVersionUID = -505088917693050187L; /** "Play" button X coordinate. */ - private static final int PLAY_BUTTON_X = 0;//50; + private static final int PLAY_BUTTON_X = 150; /** "Play" button Y coordinate. */ - private static final int PLAY_BUTTON_Y = 0;//225; + private static final int PLAY_BUTTON_Y = 225; public MainMenuActivityUI(Context androidContext) { super(androidContext); Added: branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java =================================================================== --- branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java (rev 0) +++ branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java 2013-01-14 08:38:33 UTC (rev 113) @@ -0,0 +1,69 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.specific.game.simple.ui; + +import android.content.Context; + +import picross.common.game.simple.ui.LevelMenuMediator; + +import picross.specific.ui.MenuUI; +import picross.specific.ui.MenuController; +import picross.common.ui.PicrossUI; +import picross.engine.PicrossException; +import picross.common.game.simple.ui.LevelMenuModel; + +public final class AndroidLevelMenuMediator extends LevelMenuMediator { + private Context context; + + public AndroidLevelMenuMediator(Context context) { + LevelMenuMediator.log.debug("AndroidLevelMenuMediator(" + context + ")"); + this.context = context; + } + + /** {@inheritDoc} */ + @Override + protected MenuUI initView(PicrossUI ui, MenuController controller) + throws PicrossException { + + LevelMenuMediator.log.debug("initView()"); + + this.model = new LevelMenuModel(); + + LevelMenuMediator.log.debug("this : " + this); + LevelMenuMediator.log.debug("this.model : " + this.model); + + return new LevelMenuUI(this.context, controller, this.model.getSizesList()); + } +} + Property changes on: branches/engine_split/android/src/picross/specific/game/simple/ui/AndroidLevelMenuMediator.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Added: branches/engine_split/android/src/picross/specific/game/simple/ui/LevelMenuUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/game/simple/ui/LevelMenuUI.java (rev 0) +++ branches/engine_split/android/src/picross/specific/game/simple/ui/LevelMenuUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -0,0 +1,192 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.specific.game.simple.ui; + +import fr.cle.mmvcs.SimpleEvent; + +import java.util.List; + +import picross.engine.game.simple.Dimensions; + +import picross.specific.ui.PicrossUIHelper; + +import picross.specific.ui.MenuController; +import picross.specific.ui.MenuUI; +import picross.common.ui.PicrossController; + +import picross.common.game.simple.ui.SelectSizeCommand; +import picross.common.game.simple.ui.LevelMenuController; + +import android.content.Context; + +import picross.specific.activities.R; + + +/** + * UI for the level selection menu. + * + * @author Y. Norsa + */ +public final class LevelMenuUI extends MenuUI { + /*** Constructor ***/ + + /** + * Constructor. + * + * @param listener listener for the buttons + * @param sizes available grid sizes + */ + public LevelMenuUI(Context context, MenuController listener, List<Dimensions> sizes) { + super(context); + + this.displaySizes(listener, sizes); + } + + /*** Method ***/ + + /** + * Displays the available level sizes. + * + * @param listener listener for the buttons + * @param sizes grid sizes + */ + void displaySizes(MenuController listener, List<Dimensions> sizes) { + // FIXME + //this.removeAll(); + + int x = 150; + int y = 150; + + for (Dimensions currentDim : sizes) { + String size = (int) currentDim.getWidth() + "x" + + (int) currentDim.getHeight(); + + SimpleEvent event = + new SimpleEvent(new SelectSizeCommand(currentDim)); + this.addSimpleButton(size, event, listener, x, y); + + y += 75; + + if (y == 375) { + x = 250; + y = 150; + } + } + + this.addBackButton(listener, PicrossController.PLAY_CMD); + + // FIXME + //this.repaint(); + } + + /** + * Displays the levels list. + * + * @param listener listener for the buttons + * @param levels levels to display + */ + public void displayLevels(MenuController listener, List<String> levels) { + // FIXME + /* + this.removeAll(); + + + JPanel panel = new JPanel(); + panel.setOpaque(false); + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + */ + int nbLevels = levels.size(); + + for (int i = 0; i < nbLevels; i++) { + String level = levels.get(i); + + SimpleEvent event = + new SimpleEvent(LevelMenuController.LEVEL_CMD, level); + // FIXME + /* + panel.add(this.createSimpleButton(level, event, listener) + .getButton()); + + if (i != (nbLevels - 1)) { + panel.add(Box.createRigidArea(new Dimension(0, 20))); + }*/ + } + // FIXME + /* + JScrollPane scrollPane = new JScrollPane(panel); + scrollPane.setOpaque(false); + scrollPane.setBorder(null); + scrollPane.setBounds(150, 120, 294, 200); + + scrollPane.getViewport().setOpaque(false); + + this.add(scrollPane); + */ + this.addBackButton(listener, MenuController.BACK_CMD); + + // FIXME + /* + this.revalidate(); + this.repaint(); + */ + } + + /** + * Adds a "back" button. + * + * @param listener listener for the button + * @param command command associated to the button + */ + private void addBackButton(/*ActionListener*/MenuController listener, String command) { + // FIXME + /* + ImageIcon backIcon = + PicrossUIHelper.getLocalizedImage("button-back.png"); + + JButton backButton = new JButton(backIcon); + backButton.setActionCommand(command); + backButton.addActionListener(listener); + + backButton.setBorder(null); + backButton.setBounds(7, 318, + backIcon.getIconWidth(), + backIcon.getIconHeight()); + + this.add(backButton); + */ + + this.addButton(R.drawable.button_back, command, listener, 7, 318); + } +} + Property changes on: branches/engine_split/android/src/picross/specific/game/simple/ui/LevelMenuUI.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Modified: branches/engine_split/android/src/picross/specific/game/simple/ui/SimpleGameModeUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/game/simple/ui/SimpleGameModeUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/android/src/picross/specific/game/simple/ui/SimpleGameModeUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -42,7 +42,7 @@ import picross.engine.game.simple.SimpleGameMode; import picross.specific.game.ui.UIGameMode; -import picross.common.game.simple.ui.LevelMenuMediator; +import picross.specific.game.simple.ui.AndroidLevelMenuMediator; import picross.common.ui.MenuCommand; import picross.specific.ui.PicrossButton; @@ -78,7 +78,7 @@ //ImageIcon icon = //PicrossUIHelper.getLocalizedImage(SimpleGameModeUI.SELECT_BUTTON_IMAGE); SimpleEvent event = - new SimpleEvent(new MenuCommand(LevelMenuMediator.class)); + new SimpleEvent(new MenuCommand(AndroidLevelMenuMediator.class)); return new PicrossButton(R.drawable.button_select, event); } Modified: branches/engine_split/android/src/picross/specific/ui/GameMenuUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/GameMenuUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/android/src/picross/specific/ui/GameMenuUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -71,8 +71,8 @@ public GameMenuUI(Context context, MenuController listener, ServiceLoader<GameMode> modes) { super(context); - int x = 0;//150; - int y = 0;//150; + int x = 150; + int y = 150; GameMenuUI.log.debug("listing des modes..."); Modified: branches/engine_split/android/src/picross/specific/ui/MenuUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/MenuUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/android/src/picross/specific/ui/MenuUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -338,6 +338,8 @@ button.setIcon(PicrossUIHelper.getImage(this.context.getResources(), button.getResID())); } + button.setListener(listener); + this.putButton(button, x, y, button.getIcon().getWidth(), button.getIcon().getHeight()); } @@ -409,7 +411,14 @@ && (y >= button.getY() && y <= (button.getY() + button.getHeight()))) { MenuUI.log.debug("found"); - button.getController().onPicrossEvent(new PicrossEvent(button.getCommand())); + + if (button.getController() != null) { + button.getController().onPicrossEvent(new PicrossEvent(button.getCommand())); + } + else { + button.getListener().eventPerformed(button.getEvent()); + } + return true; } } Modified: branches/engine_split/android/src/picross/specific/ui/PicrossButton.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/PicrossButton.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/android/src/picross/specific/ui/PicrossButton.java 2013-01-14 08:38:33 UTC (rev 113) @@ -34,6 +34,7 @@ package picross.specific.ui; import fr.cle.mmvcs.SimpleEvent; +import fr.cle.mmvcs.SimpleListener; import android.graphics.Bitmap; @@ -61,6 +62,10 @@ private int resID; private SimpleEvent event; + public SimpleEvent getEvent() { + return this.event; + } + public int getResID() { return this.resID; } @@ -77,6 +82,16 @@ return this.controller; } + private SimpleListener listener; + + public SimpleListener getListener() { + return this.listener; + } + + public void setListener(SimpleListener listener) { + this.listener = listener; + } + public String getCommand() { return this.command; } Modified: branches/engine_split/build.xml =================================================================== --- branches/engine_split/build.xml 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/build.xml 2013-01-14 08:38:33 UTC (rev 113) @@ -443,4 +443,39 @@ <sourcePath path="${game.src.dir}" /> </findbugs> </target> + + <!-- Android stuff --> + + <property name="android.dir" + value="android" /> + + <target name="android-dist" + depends="common-dist"> + <copy todir="${android.dir}/servicesData/META-INF/services"> + <fileset dir="services" /> + </copy> + + <copy todir="${android.dir}/libs" + file="${common.jar.name}" /> + <copy todir="${android.dir}/libs" + file="${engine.jar.name}" /> + <copy todir="${android.dir}/libs" + file="${bundleHelper.jar}" /> + <copy todir="${android.dir}/libs" + file="${mmvcs.jar}" /> + <copy todir="${android.dir}/libs" + file="${simpleButton.jar}" /> + + <copy todir="${android.dir}/res/drawable"> + <fileset dir="images" + includes="*.png" + excludes="*rollover*.png" /> + <fileset dir="images/en/" + includes="*.png" /> + </copy> + + <ant antfile="build.xml" + dir="${android.dir}" + target="debug" /> + </target> </project> Deleted: branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java 2013-01-14 08:38:33 UTC (rev 113) @@ -1,140 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2008-2011 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.common.game.simple.ui; - -import fr.cle.mmvcs.SimpleEvent; - -import java.util.List; - -import picross.engine.PicrossLogger; -import picross.engine.PicrossLogHelper; -import picross.engine.PicrossException; - -import picross.common.game.ui.GameCommand; - -import picross.specific.ui.MenuController; -import picross.common.ui.MenuMediator; -import picross.common.ui.PicrossUI; - -import picross.specific.ui.MenuUI; - -import picross.specific.game.simple.ui.LevelMenuUI; - -/** - * Level selection menu. - * - * @author Y. Norsa - */ -public final class LevelMenuMediator extends MenuMediator { - /*** Static field ***/ - - /** The class' logger. */ - private static PicrossLogger log = PicrossLogHelper.getLogger(); - - /*** Field ***/ - - /** Model containing the levels list. */ - private LevelMenuModel model = null; - - /*** Methods overloaded from the class MenuMediator ***/ - - /** {@inheritDoc} */ - @Override - protected MenuController initController() { - MenuController controller = new LevelMenuController(); - this.addSimpleListener(controller); - - return controller; - } - - /** {@inheritDoc} */ - @Override - protected MenuUI initView(PicrossUI ui, MenuController controller) - throws PicrossException { - - LevelMenuMediator.log.debug("initView()"); - - this.model = new LevelMenuModel(); - - LevelMenuMediator.log.debug("this : " + this); - LevelMenuMediator.log.debug("this.model : " + this.model); - - return new LevelMenuUI(controller, this.model.getSizesList()); - } - - /** {@inheritDoc} */ - @Override - public void eventPerformed(SimpleEvent e) { - LevelMenuMediator.log.debug("eventPerformed(" + e + ")"); - LevelMenuMediator.log.debug("this : " + this); - LevelMenuMediator.log.debug("this.model : " + this.model); - - String cmd = e.getCommandName(); - - if (cmd.equals(LevelMenuController.SIZE_CMD)) { - SelectSizeCommand command = (SelectSizeCommand) e.getCommand(); - this.displayLevels(this.model.getLevels(command.getSize())); - - return; - } - - if (cmd.equals(LevelMenuController.LEVEL_CMD)) { - String level = e.getComment(); - this.fireEventPerformed(new - GameCommand(new - SimpleGameMediator(level))); - return; - } - - if (cmd.equals(MenuController.BACK_CMD)) { - this.fireEventPerformed(new SizesListCommand(this.model - .getSizesList())); - return; - } - - super.eventPerformed(e); - } - - /*** Method ***/ - - /** - * Sends a message asking to display the levels list. - * - * @param levels the levels list - */ - private void displayLevels(List<String> levels) { - this.fireEventPerformed(new LevelsListCommand(levels)); - } -} - Added: branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java (rev 0) +++ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuMediator.java 2013-01-14 08:38:33 UTC (rev 113) @@ -0,0 +1,140 @@ +/* + * $Id$ + * + * Copyright (c) 2008-2011 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.common.game.simple.ui; + +import fr.cle.mmvcs.SimpleEvent; + +import java.util.List; + +import picross.engine.PicrossLogger; +import picross.engine.PicrossLogHelper; +import picross.engine.PicrossException; + +import picross.common.game.ui.GameCommand; + +import picross.specific.ui.MenuController; +import picross.common.ui.MenuMediator; +import picross.common.ui.PicrossUI; + +import picross.specific.ui.MenuUI; + +import picross.specific.game.simple.ui.LevelMenuUI; + +/** + * Level selection menu. + * + * @author Y. Norsa + */ +public class LevelMenuMediator extends MenuMediator { + /*** Static field ***/ + + /** The class' logger. */ + protected static PicrossLogger log = PicrossLogHelper.getLogger(); + + /*** Field ***/ + + /** Model containing the levels list. */ + protected LevelMenuModel model = null; + + /*** Methods overloaded from the class MenuMediator ***/ + + /** {@inheritDoc} */ + @Override + protected MenuController initController() { + MenuController controller = new LevelMenuController(); + this.addSimpleListener(controller); + + return controller; + } + + /** {@inheritDoc} */ + @Override + protected MenuUI initView(PicrossUI ui, MenuController controller) + throws PicrossException { + + LevelMenuMediator.log.debug("initView()"); + + this.model = new LevelMenuModel(); + + LevelMenuMediator.log.debug("this : " + this); + LevelMenuMediator.log.debug("this.model : " + this.model); + + return new LevelMenuUI(controller, this.model.getSizesList()); + } + + /** {@inheritDoc} */ + @Override + public void eventPerformed(SimpleEvent e) { + LevelMenuMediator.log.debug("eventPerformed(" + e + ")"); + LevelMenuMediator.log.debug("this : " + this); + LevelMenuMediator.log.debug("this.model : " + this.model); + + String cmd = e.getCommandName(); + + if (cmd.equals(LevelMenuController.SIZE_CMD)) { + SelectSizeCommand command = (SelectSizeCommand) e.getCommand(); + this.displayLevels(this.model.getLevels(command.getSize())); + + return; + } + + if (cmd.equals(LevelMenuController.LEVEL_CMD)) { + String level = e.getComment(); + this.fireEventPerformed(new + GameCommand(new + SimpleGameMediator(level))); + return; + } + + if (cmd.equals(MenuController.BACK_CMD)) { + this.fireEventPerformed(new SizesListCommand(this.model + .getSizesList())); + return; + } + + super.eventPerformed(e); + } + + /*** Method ***/ + + /** + * Sends a message asking to display the levels list. + * + * @param levels the levels list + */ + private void displayLevels(List<String> levels) { + this.fireEventPerformed(new LevelsListCommand(levels)); + } +} + Modified: branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java =================================================================== --- branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/common/src/picross/common/game/simple/ui/LevelMenuModel.java 2013-01-14 08:38:33 UTC (rev 113) @@ -54,7 +54,7 @@ * * @author Y. Norsa */ -final class LevelMenuModel { +public final class LevelMenuModel { /*** Constant ***/ /** File containing the data files list. */ @@ -72,7 +72,7 @@ * * @throws PicrossException if an error arises during the levels listing */ - LevelMenuModel() throws PicrossException { + public LevelMenuModel() throws PicrossException { this.levels = new HashMap<Dimensions, List<String>>(); List<LevelInfos> infos = null; @@ -137,7 +137,7 @@ * * @return list of all the grid sizes */ - List<Dimensions> getSizesList() { + public List<Dimensions> getSizesList() { return new ArrayList<Dimensions>(this.levels.keySet()); } Modified: branches/engine_split/common/src/picross/common/ui/MainMenuUI.java =================================================================== --- branches/engine_split/common/src/picross/common/ui/MainMenuUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/common/src/picross/common/ui/MainMenuUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -50,7 +50,7 @@ private static final long serialVersionUID = -505088917693050187L; /** Image for the "play" button. */ - private static final String PLAY_BUTTON_IMAGE = "button-play.png"; + private static final String PLAY_BUTTON_IMAGE = "button_play.png"; /*** Abstract methods ***/ Deleted: branches/engine_split/images/empty-button.png =================================================================== (Binary files differ) Copied: branches/engine_split/images/empty_button.png (from rev 109, branches/engine_split/images/empty-button.png) =================================================================== (Binary files differ) Deleted: branches/engine_split/images/en/button-back.png =================================================================== (Binary files differ) Deleted: branches/engine_split/images/en/button-exit.png =================================================================== (Binary files differ) Deleted: branches/engine_split/images/en/button-play.png =================================================================== (Binary files differ) Deleted: branches/engine_split/images/en/button-random.png =================================================================== (Binary files differ) Deleted: branches/engine_split/images/en/button-select.png =================================================================== (Binary files differ) Copied: branches/engine_split/images/en/button_back.png (from rev 109, branches/engine_split/images/en/button-back.png) =================================================================== (Binary files differ) Copied: branches/engine_split/images/en/button_exit.png (from rev 109, branches/engine_split/images/en/button-exit.png) =================================================================== (Binary files differ) Copied: branches/engine_split/images/en/button_play.png (from rev 109, branches/engine_split/images/en/button-play.png) =================================================================== (Binary files differ) Copied: branches/engine_split/images/en/button_random.png (from rev 109, branches/engine_split/images/en/button-random.png) =================================================================== (Binary files differ) Copied: branches/engine_split/images/en/button_select.png (from rev 109, branches/engine_split/images/en/button-select.png) =================================================================== (Binary files differ) Deleted: branches/engine_split/images/en/label-wait.png =================================================================== (Binary files differ) Copied: branches/engine_split/images/en/label_wait.png (from rev 109, branches/engine_split/images/en/label-wait.png) =================================================================== (Binary files differ) Deleted: branches/engine_split/images/fr/button-back.png =================================================================== (Binary files differ) Deleted: branches/engine_split/images/fr/button-exit.png =================================================================== (Binary files differ) Deleted: branches/engine_split/images/fr/button-play.png =================================================================== (Binary files differ) Deleted: branches/engine_split/images/fr/button-random.png =================================================================== (Binary files differ) Deleted: branches/engine_split/images/fr/button-select.png =================================================================== (Binary files differ) Copied: branches/engine_split/images/fr/button_back.png (from rev 109, branches/engine_split/images/fr/button-back.png) =================================================================== (Binary files differ) Copied: branches/engine_split/images/fr/button_exit.png (from rev 109, branches/engine_split/images/fr/button-exit.png) =================================================================== (Binary files differ) Copied: branches/engine_split/images/fr/button_play.png (from rev 109, branches/engine_split/images/fr/button-play.png) =================================================================== (Binary files differ) Copied: branches/engine_split/images/fr/button_random.png (from rev 109, branches/engine_split/images/fr/button-random.png) =================================================================== (Binary files differ) Copied: branches/engine_split/images/fr/button_select.png (from rev 109, branches/engine_split/images/fr/button-select.png) =================================================================== (Binary files differ) Deleted: branches/engine_split/images/fr/label-wait.png =================================================================== (Binary files differ) Copied: branches/engine_split/images/fr/label_wait.png (from rev 109, branches/engine_split/images/fr/label-wait.png) =================================================================== (Binary files differ) Modified: branches/engine_split/src/picross/app/MainMenuAppUI.java =================================================================== --- branches/engine_split/src/picross/app/MainMenuAppUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/src/picross/app/MainMenuAppUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -58,7 +58,7 @@ private static final int PLAY_BUTTON_Y = 225; /** Image for the "exit" button. */ - private static final String EXIT_BUTTON_IMAGE = "button-exit.png"; + private static final String EXIT_BUTTON_IMAGE = "button_exit.png"; /** "Exit" button X coordinate. */ private static final int EXIT_BUTTON_X = 250; Modified: branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameModeUI.java =================================================================== --- branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameModeUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/swing/src/picross/specific/game/random/ui/RandomGameModeUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -59,7 +59,7 @@ /*** Constants ***/ /** Image for the "random" button. */ - private static final String RANDOM_BUTTON_IMAGE = "button-random.png"; + private static final String RANDOM_BUTTON_IMAGE = "button_random.png"; /** "Random" button X coordinate. */ private static final int RANDOM_BUTTON_X = 150; Modified: branches/engine_split/swing/src/picross/specific/game/simple/ui/LevelMenuUI.java =================================================================== --- branches/engine_split/swing/src/picross/specific/game/simple/ui/LevelMenuUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/swing/src/picross/specific/game/simple/ui/LevelMenuUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -172,7 +172,7 @@ */ private void addBackButton(ActionListener listener, String command) { ImageIcon backIcon = - PicrossUIHelper.getLocalizedImage("button-back.png"); + PicrossUIHelper.getLocalizedImage("button_back.png"); JButton backButton = new JButton(backIcon); backButton.setActionCommand(command); Modified: branches/engine_split/swing/src/picross/specific/game/simple/ui/SimpleGameModeUI.java =================================================================== --- branches/engine_split/swing/src/picross/specific/game/simple/ui/SimpleGameModeUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/swing/src/picross/specific/game/simple/ui/SimpleGameModeUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -62,7 +62,7 @@ /*** Constant ***/ /** Image for the "select" button. */ - private static final String SELECT_BUTTON_IMAGE = "button-select.png"; + private static final String SELECT_BUTTON_IMAGE = "button_select.png"; /** "Select" button X coordinate. */ private static final int SELECT_BUTTON_X = 150; Modified: branches/engine_split/swing/src/picross/specific/ui/MenuUI.java =================================================================== --- branches/engine_split/swing/src/picross/specific/ui/MenuUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/swing/src/picross/specific/ui/MenuUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -170,7 +170,7 @@ SimpleListener listener) { PicrossButton button = new PicrossButton(label, - PicrossUIHelper.getImage("empty-button.png"), + PicrossUIHelper.getImage("empty_button.png"), event); button.addSimpleListener(listener); Modified: branches/engine_split/swing/src/picross/specific/ui/WaitMenuUI.java =================================================================== --- branches/engine_split/swing/src/picross/specific/ui/WaitMenuUI.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/swing/src/picross/specific/ui/WaitMenuUI.java 2013-01-14 08:38:33 UTC (rev 113) @@ -56,7 +56,7 @@ super(); ImageIcon labelIcon = - PicrossUIHelper.getLocalizedImage("label-wait.png"); + PicrossUIHelper.getLocalizedImage("label_wait.png"); JLabel label = new JLabel(labelIcon); label.setBorder(null); label.setBounds(75, 225, Modified: branches/engine_split/swing/test/picross/specific/ui/PicrossUIHelperTest.java =================================================================== --- branches/engine_split/swing/test/picross/specific/ui/PicrossUIHelperTest.java 2013-01-11 14:36:50 UTC (rev 112) +++ branches/engine_split/swing/test/picross/specific/ui/PicrossUIHelperTest.java 2013-01-14 08:38:33 UTC (rev 113) @@ -109,7 +109,7 @@ @Test public void getLocalizedImage() { - ImageIcon icon = PicrossUIHelper.getLocalizedImage("button-play.png"); + ImageIcon icon = PicrossUIHelper.getLocalizedImage("button_play.png"); PicrossUIHelperTest.testIcon(icon, 150, 50); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |