[Picross-commit] SF.net SVN: picross:[125] branches/engine_split
Status: Pre-Alpha
Brought to you by:
yvan_norsa
|
From: <yva...@us...> - 2013-01-16 11:56:07
|
Revision: 125
http://sourceforge.net/p/picross/code/125
Author: yvan_norsa
Date: 2013-01-16 11:56:03 +0000 (Wed, 16 Jan 2013)
Log Message:
-----------
alert dialog; options menu
Modified Paths:
--------------
branches/engine_split/android/src/picross/specific/activities/PicrossActivityUI.java
branches/engine_split/android/src/picross/specific/activities/PicrossMainActivity.java
branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameController.java
branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameUI.java
branches/engine_split/android/src/picross/specific/game/ui/GameUI.java
branches/engine_split/android/src/picross/specific/grid/ui/GridUI.java
branches/engine_split/android/src/picross/specific/ui/MenuController.java
branches/engine_split/android/src/picross/specific/ui/MenuUI.java
branches/engine_split/android/src/picross/specific/ui/PicrossMediator.java
Added Paths:
-----------
branches/engine_split/android/src/picross/specific/ui/PicrossEvent.java
branches/engine_split/common/src/picross/common/game/ui/GameMediator.java
Modified: branches/engine_split/android/src/picross/specific/activities/PicrossActivityUI.java
===================================================================
--- branches/engine_split/android/src/picross/specific/activities/PicrossActivityUI.java 2013-01-16 10:16:31 UTC (rev 124)
+++ branches/engine_split/android/src/picross/specific/activities/PicrossActivityUI.java 2013-01-16 11:56:03 UTC (rev 125)
@@ -74,16 +74,18 @@
/** {@inheritDoc} */
@Override
- public void displayMessage(String msg) {
+ public void displayMessage(final String msg) {
PicrossActivityUI.log.debug("displayMessage(" + msg + ")");
- // FIXME
- /*
- AlertDialog.Builder builder = new AlertDialog.Builder(this.activity);
+ this.activity.runOnUiThread(new Runnable() {
+ public void run() {
+ AlertDialog.Builder builder = new AlertDialog.Builder(PicrossActivityUI.this.activity);
builder.setMessage(msg)
.setTitle("Picross");
AlertDialog dialog = builder.create();
- */
+ dialog.show();
+ }
+ });
}
/** {@inheritDoc} */
Modified: branches/engine_split/android/src/picross/specific/activities/PicrossMainActivity.java
===================================================================
--- branches/engine_split/android/src/picross/specific/activities/PicrossMainActivity.java 2013-01-16 10:16:31 UTC (rev 124)
+++ branches/engine_split/android/src/picross/specific/activities/PicrossMainActivity.java 2013-01-16 11:56:03 UTC (rev 125)
@@ -37,11 +37,16 @@
import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+
import picross.specific.ui.PicrossMediator;
import picross.specific.ui.PicrossAndroidLogger;
import picross.engine.PicrossLogHelper;
public class PicrossMainActivity extends Activity {
+ private PicrossMediator mediator;
+
static {
PicrossLogHelper.setLoggerClass(PicrossAndroidLogger.class);
}
@@ -50,6 +55,16 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- new PicrossMediator(this, new PicrossActivityUI(this));
+ this.mediator = new PicrossMediator(this, new PicrossActivityUI(this));
}
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ return this.mediator.populateOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ return this.mediator.onOptionsItemSelected(item);
+ }
}
Modified: branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameController.java
===================================================================
--- branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameController.java 2013-01-16 10:16:31 UTC (rev 124)
+++ branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameController.java 2013-01-16 11:56:03 UTC (rev 125)
@@ -35,6 +35,8 @@
import picross.specific.game.ui.GameController;
+import picross.specific.ui.PicrossEvent;
+
/**
* Controller for the random game UI.
*
@@ -45,6 +47,7 @@
/** Command asking to create another grid. */
static final String NEXT_CMD = "NEXT_CMD";
+ static final int NEXT_CMD_ID = RandomGameController.NEXT_CMD.hashCode();
/** Random game command. */
static final String RANDOM_GAME_CMD = "RANDOM_GAME_CMD";
@@ -67,4 +70,16 @@
super.actionPerformed(e);
}
*/
+
+ @Override
+ public void onPicrossEvent(PicrossEvent e) {
+ int itemId = e.getItemId();
+
+ if (itemId == RandomGameController.NEXT_CMD_ID) {
+ this.fireEventPerformed(RandomGameController.NEXT_CMD);
+ return;
+ }
+
+ super.onPicrossEvent(e);
+ }
}
Modified: branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameUI.java
===================================================================
--- branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameUI.java 2013-01-16 10:16:31 UTC (rev 124)
+++ branches/engine_split/android/src/picross/specific/game/random/ui/RandomGameUI.java 2013-01-16 11:56:03 UTC (rev 125)
@@ -42,6 +42,7 @@
import picross.specific.ui.MenuController;
import android.content.Context;
+import android.view.Menu;
/**
* Custom UI for a random game.
@@ -78,4 +79,15 @@
this.addButton(nextButton);
*/
}
+
+ @Override
+ public void populateOptionsMenu(Menu menu) {
+ super.populateOptionsMenu(menu);
+
+ if (menu.findItem(RandomGameController.NEXT_CMD_ID) != null) {
+ return;
+ }
+
+ menu.add(Menu.NONE, RandomGameController.NEXT_CMD_ID, Menu.NONE, BundleHelper.getString(this, "anotherGrid"));
+ }
}
Modified: branches/engine_split/android/src/picross/specific/game/ui/GameUI.java
===================================================================
--- branches/engine_split/android/src/picross/specific/game/ui/GameUI.java 2013-01-16 10:16:31 UTC (rev 124)
+++ branches/engine_split/android/src/picross/specific/game/ui/GameUI.java 2013-01-16 11:56:03 UTC (rev 125)
@@ -55,7 +55,11 @@
import picross.specific.grid.ui.UIBox;
import android.view.MotionEvent;
+import android.view.Menu;
+import android.view.MenuItem;
+import picross.specific.ui.PicrossEvent;
+
/**
* The game UI.
*
@@ -75,6 +79,9 @@
private GridUI grid;
+ private MenuController controller;
+
+
/*** Constructor ***/
/**
@@ -95,6 +102,8 @@
// HACK should not be here
UIBox.staticInit(context.getResources());
+ this.controller = listener;
+
// FIXME
/*
this.setLayout(new BorderLayout());
@@ -167,4 +176,13 @@
// FIXME
//this.buttonsPanel.add(button);
}
+
+ public void populateOptionsMenu(Menu menu) {
+ GameUI.log.debug("TODO options menu");
+ }
+
+ public boolean onOptionsItemSelected(MenuItem item) {
+ this.controller.onPicrossEvent(new PicrossEvent(item.getItemId()));
+ return true;
+ }
}
Modified: branches/engine_split/android/src/picross/specific/grid/ui/GridUI.java
===================================================================
--- branches/engine_split/android/src/picross/specific/grid/ui/GridUI.java 2013-01-16 10:16:31 UTC (rev 124)
+++ branches/engine_split/android/src/picross/specific/grid/ui/GridUI.java 2013-01-16 11:56:03 UTC (rev 125)
@@ -264,6 +264,8 @@
Rect currentRect = this.boxes[i][j].getRect();
if (currentRect.intersect(clipRect)) {
+
+
c.drawBitmap(this.boxes[i][j].getIcon(),
currentRect.left,
currentRect.top, null);
Modified: branches/engine_split/android/src/picross/specific/ui/MenuController.java
===================================================================
--- branches/engine_split/android/src/picross/specific/ui/MenuController.java 2013-01-16 10:16:31 UTC (rev 124)
+++ branches/engine_split/android/src/picross/specific/ui/MenuController.java 2013-01-16 11:56:03 UTC (rev 125)
@@ -62,7 +62,7 @@
return false;
}*/
- public void onPicrossEvent(MenuUI.PicrossEvent e) {
+ public void onPicrossEvent(PicrossEvent e) {
this.fireEventPerformed(e.getActionCommand());
}
}
Modified: branches/engine_split/android/src/picross/specific/ui/MenuUI.java
===================================================================
--- branches/engine_split/android/src/picross/specific/ui/MenuUI.java 2013-01-16 10:16:31 UTC (rev 124)
+++ branches/engine_split/android/src/picross/specific/ui/MenuUI.java 2013-01-16 11:56:03 UTC (rev 125)
@@ -405,16 +405,4 @@
PicrossLabel label = new PicrossLabel(icon, x, y, icon.getWidth(), icon.getHeight());
this.add(label);
}
-
- public static class PicrossEvent {
- private String actionCommand;
-
- private PicrossEvent(String command) {
- this.actionCommand = command;
- }
-
- public String getActionCommand() {
- return this.actionCommand;
- }
- }
}
Added: branches/engine_split/android/src/picross/specific/ui/PicrossEvent.java
===================================================================
--- branches/engine_split/android/src/picross/specific/ui/PicrossEvent.java (rev 0)
+++ branches/engine_split/android/src/picross/specific/ui/PicrossEvent.java 2013-01-16 11:56:03 UTC (rev 125)
@@ -0,0 +1,56 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2008
+ *
+ * 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.ui;
+
+public final class PicrossEvent {
+ private String actionCommand;
+ private int itemId;
+
+ public PicrossEvent(String command) {
+ this.actionCommand = command;
+ }
+
+ public PicrossEvent(int id) {
+ this.itemId = id;
+ }
+
+ public String getActionCommand() {
+ return this.actionCommand;
+ }
+
+ public int getItemId() {
+ return this.itemId;
+ }
+}
+
Property changes on: branches/engine_split/android/src/picross/specific/ui/PicrossEvent.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Modified: branches/engine_split/android/src/picross/specific/ui/PicrossMediator.java
===================================================================
--- branches/engine_split/android/src/picross/specific/ui/PicrossMediator.java 2013-01-16 10:16:31 UTC (rev 124)
+++ branches/engine_split/android/src/picross/specific/ui/PicrossMediator.java 2013-01-16 11:56:03 UTC (rev 125)
@@ -49,6 +49,11 @@
import picross.engine.PicrossLogger;
import picross.engine.PicrossLogHelper;
+import android.view.Menu;
+import android.view.MenuItem;
+
+import picross.specific.game.ui.GameUI;
+
public final class PicrossMediator extends AbstractPicrossMediator {
private static PicrossLogger log = PicrossLogHelper.getLogger(PicrossMediator.class);
@@ -108,8 +113,12 @@
PicrossMediator.this.view.setContent(game.getView());
// }
//}.start();
+
+ this.gameView = (GameUI) game.getView();
}
+ private GameUI gameView;
+
/**
* Method launching a game.
*
@@ -132,4 +141,21 @@
// worker.start();
}
+
+ public boolean populateOptionsMenu(Menu menu) {
+ if (this.gameView == null) {
+ return false;
+ }
+
+ this.gameView.populateOptionsMenu(menu);
+ return true;
+ }
+
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (this.gameView == null) {
+ return false;
+ }
+
+ return this.gameView.onOptionsItemSelected(item);
+ }
}
Added: branches/engine_split/common/src/picross/common/game/ui/GameMediator.java
===================================================================
--- branches/engine_split/common/src/picross/common/game/ui/GameMediator.java (rev 0)
+++ branches/engine_split/common/src/picross/common/game/ui/GameMediator.java 2013-01-16 11:56:03 UTC (rev 125)
@@ -0,0 +1,45 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007-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.ui;
+
+import fr.cle.mmvcs.IMediateur;
+
+import picross.engine.PicrossException;
+import picross.engine.grid.PicrossGrid;
+
+public interface GameMediator extends IMediateur {
+ PicrossGrid initModel() throws PicrossException;
+ void init() throws PicrossException;
+}
+
Property changes on: branches/engine_split/common/src/picross/common/game/ui/GameMediator.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|