[Picross-commit] SF.net SVN: picross: [39] trunk
Status: Pre-Alpha
Brought to you by:
yvan_norsa
|
From: <yva...@us...> - 2007-06-14 13:51:02
|
Revision: 39
http://picross.svn.sourceforge.net/picross/?rev=39&view=rev
Author: yvan_norsa
Date: 2007-06-14 06:51:01 -0700 (Thu, 14 Jun 2007)
Log Message:
-----------
XBM support
Modified Paths:
--------------
trunk/build.xml
trunk/src/picross/Picross.java
trunk/src/picross/PicrossMediator.java
trunk/src/picross/game/GameMediator.java
trunk/src/picross/game/random/RandomGameMediator.java
Added Paths:
-----------
trunk/data/
trunk/data/anchor.xbm
trunk/data/bart.xbm
trunk/data/blarg.xbm
trunk/data/bunny.xbm
trunk/data/candle.xbm
trunk/data/crab.xbm
trunk/data/ghost_left.xbm
trunk/data/halloween.xbm
trunk/data/squares.xbm
trunk/src/picross/game/simple/
trunk/src/picross/game/simple/SimpleGameMediator.java
trunk/src/picross/game/simple/XBMModel.java
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2007-06-14 09:33:57 UTC (rev 38)
+++ trunk/build.xml 2007-06-14 13:51:01 UTC (rev 39)
@@ -80,6 +80,10 @@
<fileset dir="images" />
</copy>
+ <copy todir="${build.dir}/picross/data">
+ <fileset dir="data" />
+ </copy>
+
<jar destfile="${jar.name}"
basedir="${build.dir}" />
</target>
Added: trunk/data/anchor.xbm
===================================================================
--- trunk/data/anchor.xbm (rev 0)
+++ trunk/data/anchor.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,6 @@
+#define anchor.xbm_width 16
+#define anchor.xbm_height 16
+static char anchor.xbm_bits[] = {
+ 0x00, 0x00, 0xe0, 0x07, 0xe0, 0x07, 0x80, 0x05, 0x80, 0x05, 0x80, 0x05,
+ 0x80, 0x03, 0x80, 0x01, 0x9e, 0x79, 0x8e, 0x71, 0x8e, 0x71, 0x8a, 0x51,
+ 0x90, 0x09, 0xe0, 0x07, 0x80, 0x01, 0x00, 0x00};
Added: trunk/data/bart.xbm
===================================================================
--- trunk/data/bart.xbm (rev 0)
+++ trunk/data/bart.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,27 @@
+#define noname_width 43
+#define noname_height 58
+static char noname_bits[] = {
+ 0x00,0x00,0x00,0xc4,0x00,0x00,0x00,0x00,0xc0,0xca,0x00,0x00,0x00,0x00,0xc0,
+ 0xb2,0x00,0x00,0x00,0x00,0x4c,0xb3,0x00,0x00,0x00,0xc0,0x34,0x82,0x00,0x00,
+ 0x00,0x4c,0x35,0x80,0x00,0x00,0x80,0x54,0x26,0x80,0x00,0x00,0x80,0x67,0x04,
+ 0x80,0x00,0x00,0xb0,0x4c,0x00,0x80,0x00,0x00,0xd0,0x08,0x00,0x00,0x01,0x00,
+ 0x90,0x01,0x00,0x00,0x01,0x00,0x17,0x00,0x00,0x00,0x01,0x00,0x39,0x00,0x00,
+ 0x00,0x01,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0x00,0x02,0x00,
+ 0x04,0x00,0x00,0x00,0x02,0x00,0x08,0x00,0x00,0x00,0x02,0x00,0x08,0x00,0x00,
+ 0x00,0x0c,0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x1f,0x00,
+ 0x20,0x00,0x00,0x80,0x20,0x00,0x20,0x00,0x80,0x43,0x40,0x00,0x40,0x00,0x60,
+ 0x2c,0x80,0x00,0x40,0x00,0x18,0x10,0x80,0x00,0x40,0x00,0x04,0x20,0x8c,0x00,
+ 0x80,0x00,0x04,0x40,0x8c,0x00,0x80,0x00,0x02,0x40,0x40,0x00,0x00,0x01,0x01,
+ 0x40,0x70,0x00,0x00,0x01,0xc1,0xc0,0x8f,0x00,0x00,0x02,0xc1,0x40,0x00,0x01,
+ 0x00,0x02,0x02,0x20,0x00,0x01,0x00,0x02,0x02,0x10,0x00,0x01,0x00,0x04,0x04,
+ 0x10,0x00,0x01,0x00,0x04,0x08,0x0c,0x80,0x00,0x00,0x04,0xf0,0x03,0x40,0x00,
+ 0x00,0x08,0x00,0x00,0xbe,0x00,0x00,0x08,0x00,0x00,0x80,0x00,0x00,0x30,0x00,
+ 0x00,0x80,0x00,0x00,0x48,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0x00,0x01,
+ 0x00,0x74,0x00,0x00,0x00,0x02,0x00,0x2a,0x00,0x00,0x00,0x04,0x00,0x6a,0x40,
+ 0x00,0x00,0x03,0x00,0x04,0x20,0x00,0xc0,0x00,0x00,0x88,0x70,0x00,0x3e,0x00,
+ 0x00,0x70,0x90,0xff,0x01,0x00,0x00,0x20,0x10,0x80,0x00,0x00,0x00,0x20,0x00,
+ 0x80,0x00,0x00,0x00,0x20,0x00,0x60,0x00,0x00,0x00,0x20,0x00,0x10,0x00,0x00,
+ 0x00,0x20,0x00,0x08,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x10,0x00,
+ 0x08,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x60,0x00,0x08,0x00,0x00,
+ 0x00,0x80,0x01,0x08,0x00,0x00,0x00,0x00,0x06,0x04,0x00,0x00,0x00,0x00,0xf8,
+ 0x03,0x00,0x00};
Added: trunk/data/blarg.xbm
===================================================================
--- trunk/data/blarg.xbm (rev 0)
+++ trunk/data/blarg.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,5 @@
+#define test_width 16
+#define test_height 7
+static char test_bits[] = {
+0x13, 0x00, 0x15, 0x00, 0x93, 0xcd, 0x55, 0xa5, 0x93, 0xc5, 0x00, 0x80,
+0x00, 0x60, };
Added: trunk/data/bunny.xbm
===================================================================
--- trunk/data/bunny.xbm (rev 0)
+++ trunk/data/bunny.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,6 @@
+#define bunny_width 16
+#define bunny_height 16
+static char bunny_bits[] = {
+ 0x00,0x00,0x00,0x44,0x00,0xee,0x00,0xee,0x00,0xee,0x00,0xee,0x00,0x6c,0x00,
+ 0x38,0xe0,0x7c,0xf0,0xbd,0xf8,0xff,0xfa,0xff,0xff,0x7f,0xff,0x3f,0xff,0xff,
+ 0xfa,0xff};
Added: trunk/data/candle.xbm
===================================================================
--- trunk/data/candle.xbm (rev 0)
+++ trunk/data/candle.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,8 @@
+#define noname_width 16
+#define noname_height 33
+static char noname_bits[] = {
+ 0x00,0x01,0x00,0x03,0x00,0x03,0x00,0x03,0x80,0x06,0x40,0x06,0x40,0x06,0x40,
+ 0x06,0x40,0x03,0x80,0x01,0xf0,0x0f,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,
+ 0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,0x0c,0x10,
+ 0x0c,0x10,0x0c,0xfe,0x7f,0x01,0xc0,0x02,0x60,0x0c,0x38,0x10,0x0c,0x10,0x0c,
+ 0x20,0x06,0x20,0x06,0x10,0x0c};
Added: trunk/data/crab.xbm
===================================================================
--- trunk/data/crab.xbm (rev 0)
+++ trunk/data/crab.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,7 @@
+#define crab_width 16
+#define crab_height 16
+
+static char crab_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x70, 0x0e, 0x78, 0x1e, 0x18, 0x18, 0x44, 0x22,
+ 0xc4, 0x23, 0xf8, 0x1f, 0xe0, 0x07, 0xf8, 0x1f, 0xe4, 0x27, 0xd0, 0x0b,
+ 0x08, 0x10, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00 };
Added: trunk/data/ghost_left.xbm
===================================================================
--- trunk/data/ghost_left.xbm (rev 0)
+++ trunk/data/ghost_left.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,6 @@
+#define pacman_left_width 16
+#define pacman_left_height 16
+static char pacman_left_bits[] = {
+ 0xf0,0x07,0x0c,0x18,0x02,0x20,0x3a,0x2e,0x45,0x51,0x5d,0x57,0x5d,0x57,0x5d,
+ 0x57,0x45,0x51,0x39,0x4e,0x01,0x40,0x01,0x40,0x11,0x44,0x29,0x4a,0x45,0x51,
+ 0x82,0x20};
Added: trunk/data/halloween.xbm
===================================================================
--- trunk/data/halloween.xbm (rev 0)
+++ trunk/data/halloween.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,6 @@
+#define noname_width 16
+#define noname_height 16
+static char noname_bits[] = {
+ 0x00,0x03,0x80,0x01,0x80,0x01,0xb8,0x0d,0xf8,0x3f,0xfe,0x7f,0xce,0xf3,0xdf,
+ 0xf7,0x7f,0xfe,0xff,0xfe,0xff,0xff,0xce,0x67,0x1e,0x70,0x7c,0x3d,0xf0,0x0f,
+ 0x00,0x00};
Added: trunk/data/squares.xbm
===================================================================
--- trunk/data/squares.xbm (rev 0)
+++ trunk/data/squares.xbm 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,6 @@
+ #define test_width 16
+ #define test_height 16
+ static unsigned char test_bits[] = {
+ 0xff, 0xff, 0x01, 0x80, 0xfd, 0xbf, 0x05, 0xa0, 0xf5, 0xaf, 0x15, 0xa8,
+ 0xd5, 0xab, 0x55, 0xaa, 0x55, 0xaa, 0xd5, 0xab, 0x15, 0xa8, 0xf5, 0xaf,
+ 0x05, 0xa0, 0xfd, 0xbf, 0x01, 0x80, 0xff, 0xff};
Modified: trunk/src/picross/Picross.java
===================================================================
--- trunk/src/picross/Picross.java 2007-06-14 09:33:57 UTC (rev 38)
+++ trunk/src/picross/Picross.java 2007-06-14 13:51:01 UTC (rev 39)
@@ -33,6 +33,9 @@
package picross;
+import java.io.IOException;
+import java.io.InputStream;
+
import java.util.Locale;
import javax.swing.ImageIcon;
@@ -50,6 +53,8 @@
/** Images directory. */
private static final String IMAGES_DIR = "/picross/images/";
+ private static final String DATA_DIR = "/picross/data/";
+
/** Images directory corresponding to the default locale. */
private static final String LOCAL_IMAGES_PATH = Picross.IMAGES_DIR
+ Locale.getDefault().getLanguage() + "/";
@@ -95,5 +100,11 @@
public static ImageIcon getLocalizedImage(String name) {
return Picross.loadImage(Picross.LOCAL_IMAGES_PATH + name);
}
+
+ public static InputStream loadDataFile(String name)
+ throws IOException {
+
+ return Picross.class.getResource(Picross.DATA_DIR + name).openStream();
+ }
}
Modified: trunk/src/picross/PicrossMediator.java
===================================================================
--- trunk/src/picross/PicrossMediator.java 2007-06-14 09:33:57 UTC (rev 38)
+++ trunk/src/picross/PicrossMediator.java 2007-06-14 13:51:01 UTC (rev 39)
@@ -105,7 +105,16 @@
if (cmd.equals(PicrossController.PLAY_CMD)) {
//this.view.setContent(grid.getView());
- GameMediator game = new picross.game.random.RandomGameMediator();
+ //GameMediator game = new picross.game.random.RandomGameMediator();
+ GameMediator game = null;
+
+ try {
+ game = new picross.game.simple.SimpleGameMediator();
+ } catch (PicrossException picrossEx) {
+ this.view.displayError(picrossEx.getMessage());
+ return;
+ }
+
game.addSimpleListener(this);
this.view.setContent(game.getView());
Modified: trunk/src/picross/game/GameMediator.java
===================================================================
--- trunk/src/picross/game/GameMediator.java 2007-06-14 09:33:57 UTC (rev 38)
+++ trunk/src/picross/game/GameMediator.java 2007-06-14 13:51:01 UTC (rev 39)
@@ -40,6 +40,7 @@
//import org.apache.log4j.Logger;
+import picross.PicrossException;
import picross.PicrossGrid;
import picross.grid.GridMediator;
@@ -63,7 +64,7 @@
/*** Constructor ***/
/** Constructor. */
- public GameMediator() {
+ public GameMediator() throws PicrossException {
PicrossGrid model = this.initModel();
int width = model.getWidth();
@@ -86,14 +87,16 @@
* @param gridView the grid itself
* @return view containing the grid
*/
- protected abstract GameUI initView(int width, int height, JPanel gridView);
+ protected GameUI initView(int width, int height, JPanel gridView) {
+ return new GameUI(width, height, gridView);
+ }
/**
* Creates the model.
*
* @return grid model
*/
- protected abstract PicrossGrid initModel();
+ protected abstract PicrossGrid initModel() throws PicrossException;
/*** Method overloaded from the class Mediator ***/
Modified: trunk/src/picross/game/random/RandomGameMediator.java
===================================================================
--- trunk/src/picross/game/random/RandomGameMediator.java 2007-06-14 09:33:57 UTC (rev 38)
+++ trunk/src/picross/game/random/RandomGameMediator.java 2007-06-14 13:51:01 UTC (rev 39)
@@ -40,6 +40,7 @@
//import org.apache.log4j.Logger;
import picross.PicrossController;
+import picross.PicrossException;
import picross.PicrossGrid;
import picross.game.GameMediator;
@@ -56,6 +57,10 @@
/** The class' logger. */
//private static Logger log = Logger.getLogger(RandomGameMediator.class);
+ RandomGameMediator() throws PicrossException {
+ super();
+ }
+
/*** Methods overloaded from the class GameMediator ***/
/** {@inheritDoc} */
Added: trunk/src/picross/game/simple/SimpleGameMediator.java
===================================================================
--- trunk/src/picross/game/simple/SimpleGameMediator.java (rev 0)
+++ trunk/src/picross/game/simple/SimpleGameMediator.java 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,75 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * 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.game.simple;
+
+import java.io.IOException;
+
+import javax.swing.JPanel;
+
+import picross.Picross;
+import picross.PicrossException;
+import picross.PicrossGrid;
+
+import picross.game.GameMediator;
+
+/**
+ * @author Y. Norsa
+ */
+public final class SimpleGameMediator extends GameMediator {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ public SimpleGameMediator() throws PicrossException {
+ super();
+ }
+
+ /*** M\xE9thode ***/
+
+ protected PicrossGrid initModel() throws PicrossException {
+ try {
+ return new XBMModel(Picross.loadDataFile("halloween.xbm"));
+ } catch (IOException ioEx) {
+ throw new PicrossException(ioEx);
+ }
+ }
+}
+
Property changes on: trunk/src/picross/game/simple/SimpleGameMediator.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/picross/game/simple/XBMModel.java
===================================================================
--- trunk/src/picross/game/simple/XBMModel.java (rev 0)
+++ trunk/src/picross/game/simple/XBMModel.java 2007-06-14 13:51:01 UTC (rev 39)
@@ -0,0 +1,157 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2007
+ *
+ * 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.game.simple;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import picross.AbstractPicrossModel;
+
+/**
+ * @author Y. Norsa
+ */
+final class XBMModel extends AbstractPicrossModel {
+ /*** Constante ***/
+
+ /*** Champ statique ***/
+
+ private static Logger log = Logger.getLogger(XBMModel.class);
+
+ /*** Champ ***/
+
+ /*** Constructeur ***/
+
+ /**
+ * Constructeur.
+ */
+ XBMModel(InputStream input) throws IOException {
+ super();
+
+ List<String> byteValues = new ArrayList<String>();
+
+ BufferedReader in = new BufferedReader(new InputStreamReader(input));
+
+ String line = null;
+
+ try {
+ while ((line = in.readLine()) != null) {
+ if (line.contains("width")) {
+ this.width =
+ Integer.parseInt(line.substring(line
+ .lastIndexOf(' '))
+ .trim());
+ XBMModel.log.debug("width = " + this.width);
+ continue;
+ }
+
+ if (line.contains("height")) {
+ this.height =
+ Integer.parseInt(line.substring(line
+ .lastIndexOf(' '))
+ .trim());
+ XBMModel.log.debug("height = " + this.height);
+ continue;
+ }
+
+ if (line.contains("bits")) {
+ this.data = new boolean[this.width][this.height];
+
+ while ((line = in.readLine()) != null) {
+ String[] values = line.split(",");
+
+ for (int i = 0; i < values.length; i++) {
+ //XBMModel.log.debug("values[" + i + "] = "
+ //+ values[i]);
+
+ if (values[i].contains("0x")) {
+ String byteStr =
+ values[i].trim().substring(2, 4);
+ byteValues.add(byteStr);
+ }
+ }
+ }
+ }
+ }
+ } catch (IOException ioEx) {
+ throw ioEx;
+ } finally {
+ try {
+ in.close();
+ } catch (IOException ioEx) {
+ XBMModel.log.error(ioEx.getMessage());
+ }
+ }
+
+ int xIndex = 0;
+ int yIndex = 0;
+
+ for (String byteStr : byteValues) {
+ int byteVal = Integer.parseInt(byteStr, 16);
+ String binaryStr = Integer.toBinaryString(byteVal);
+
+ while (binaryStr.length() < 8) {
+ binaryStr = "0" + binaryStr;
+ }
+
+ //XBMModel.log.debug(binaryStr);
+
+ for (int j = 8 - 1; j >= 0; j--) {
+ //XBMModel.log.debug("this.data[" + yIndex
+ //+ "][" + xIndex + "] = "
+ //+ (binaryStr.charAt(j) == '1' ? true
+ //: false));
+
+ this.data[yIndex++][xIndex] =
+ (binaryStr.charAt(j) == '1' ? true : false);
+
+ if (yIndex == this.width) {
+ xIndex++;
+ yIndex = 0;
+ }
+
+ if (xIndex == this.height) {
+ xIndex = 0;
+ }
+ }
+ }
+ }
+}
+
Property changes on: trunk/src/picross/game/simple/XBMModel.java
___________________________________________________________________
Name: svn:keywords
+ Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|