[nullpomino] r894 committed - +nm8.GUI: Added Next and Hold display...

6 views
Skip to first unread message

nullp...@googlecode.com

unread,
Jan 31, 2012, 2:23:25 AM1/31/12
to nullpom...@googlegroups.com
Revision: 894
Author: pbomql...@gmail.com
Date: Mon Jan 30 23:22:36 2012
Log: +nm8.GUI: Added Next and Hold display
+nm8.Slick.JInput: Keyboard ID "-1" will autodetect the keyboard, and "-2"
will use all keyboards
*nm8.NEURO: Temporary disabled GUI-related stuff (Judging from the warning
message in the log, it seems NiftyGUI doesn't want to be inited more than
once...)

http://code.google.com/p/nullpomino/source/detail?r=894

Modified:
/branches/nm8/data/properties/log.cfg
/branches/nm8/data/xml/game_main.xml
/branches/nm8/src/cx/it/nullpo/nm8/gui/game/GameFieldController.java
/branches/nm8/src/cx/it/nullpo/nm8/gui/game/GameFieldRenderer.java
/branches/nm8/src/cx/it/nullpo/nm8/gui/game/NullpoMinoNiftyGUI.java

/branches/nm8/src/cx/it/nullpo/nm8/gui/slick/framework/SlickNFJInputKeyboard.java
/branches/nm8/src/cx/it/nullpo/nm8/neuro/core/NEUROCore.java
/branches/nm8/src/cx/it/nullpo/nm8/neuro/gui/ScreenSet.java
/branches/nm8/src/cx/it/nullpo/nm8/neuro/gui/ScreenStack.java
/branches/nm8/src/cx/it/nullpo/nm8/neuro/light/NEUROLight.java

=======================================
--- /branches/nm8/data/properties/log.cfg Thu Nov 10 01:23:35 2011
+++ /branches/nm8/data/properties/log.cfg Mon Jan 30 23:22:36 2012
@@ -22,6 +22,7 @@
log4j.logger.org.bushe.swing=INFO

# Suppress NiftyGUI logs
+log4j.logger.de.lessvoid.nifty.Nifty=WARN
log4j.logger.de.lessvoid.nifty.NiftyStopwatch=WARN
log4j.logger.de.lessvoid.nifty.effects.Effect=WARN
log4j.logger.de.lessvoid.nifty.effects.EffectProcessor=WARN
=======================================
--- /branches/nm8/data/xml/game_main.xml Fri Jan 6 07:28:02 2012
+++ /branches/nm8/data/xml/game_main.xml Mon Jan 30 23:22:36 2012
@@ -6,22 +6,75 @@

<controlDefinition name="gamefield"
controller="cx.it.nullpo.nm8.gui.game.GameFieldController">
<panel childLayout="center">
- <panel id="panel-field" backgroundColor="#000000"
childLayout="absolute">
+ <panel id="#panel-field" backgroundColor="#000000"
childLayout="absolute">
</panel>
</panel>
</controlDefinition>

<screen id="start"
controller="cx.it.nullpo.nm8.gui.game.MainScreenController">
- <layer childLayout="vertical" backgroundColor="#00000000">
- <panel childLayout="horizontal" width="100%" height="10%" />
-
- <panel backgroundColor="#FF0000" childLayout="center" width="162"
height="326" align="center" valign="center">
- <panel childLayout="center" width="160" height="324" align="center"
valign="center">
- <control id="field-0" name="gamefield" blocksize="16" />
+ <layer childLayout="horizontal">
+ <!-- Player 1 -->
+ <panel childLayout="center" width="*" height="*">
+ <panel childLayout="horizontal" width="294" align="center"
valign="center">
+ <!-- Hold -->
+ <panel backgroundColor="#FF0000" childLayout="center" width="66"
height="66">
+ <panel childLayout="center" width="64" height="64" align="center"
valign="center">
+ <control id="hold-0" name="gamefield" blocksize="16" />
+ </panel>
+ </panel>
+ <!-- Field -->
+ <panel backgroundColor="#FF0000" childLayout="center" width="162"
height="326">
+ <panel childLayout="center" width="160" height="324" align="center"
valign="center">
+ <control id="field-0" name="gamefield" blocksize="16" />
+ </panel>
+ </panel>
+ <!-- Next -->
+ <panel childLayout="vertical" width="66" height="326">
+ <!-- Next1 -->
+ <panel backgroundColor="#FF0000" childLayout="center" width="66"
height="66" align="center">
+ <panel childLayout="center" width="64" height="64" align="center"
valign="center">
+ <control id="next-0-0" name="gamefield" blocksize="16" />
+ </panel>
+ </panel>
+ <!-- Next2 -->
+ <panel backgroundColor="#FF0000" childLayout="center" width="59"
height="59" align="center">
+ <panel childLayout="center" width="57" height="57" align="center"
valign="center">
+ <control id="next-0-1" name="gamefield" blocksize="14" />
+ </panel>
+ </panel>
+ <!-- Next3 -->
+ <panel backgroundColor="#FF0000" childLayout="center" width="53"
height="53" align="center">
+ <panel childLayout="center" width="51" height="51" align="center"
valign="center">
+ <control id="next-0-2" name="gamefield" blocksize="12" />
+ </panel>
+ </panel>
+ <!-- Next4 -->
+ <panel backgroundColor="#FF0000" childLayout="center" width="46"
height="46" align="center">
+ <panel childLayout="center" width="44" height="44" align="center"
valign="center">
+ <control id="next-0-3" name="gamefield" blocksize="11" />
+ </panel>
+ </panel>
+ <!-- Next5 -->
+ <panel backgroundColor="#FF0000" childLayout="center" width="46"
height="46" align="center">
+ <panel childLayout="center" width="44" height="44" align="center"
valign="center">
+ <control id="next-0-4" name="gamefield" blocksize="11" />
+ </panel>
+ </panel>
+ <!-- Next6 -->
+ <panel backgroundColor="#FF0000" childLayout="center" width="46"
height="46" align="center">
+ <panel childLayout="center" width="44" height="44" align="center"
valign="center">
+ <control id="next-0-5" name="gamefield" blocksize="11" />
+ </panel>
+ </panel>
+ </panel>
</panel>
</panel>
-
- <panel childLayout="horizontal" width="100%" height="20%">
+ </layer>
+
+ <layer childLayout="vertical">
+ <panel width="100%" height="90%" />
+ <panel childLayout="horizontal">
+ <panel width="5%" />
<control id="buttonStart" name="button" label="Start"
focusable="false" />
<control id="buttonQuit" name="button" label="Quit" focusable="false"
/>
</panel>
=======================================
--- /branches/nm8/src/cx/it/nullpo/nm8/gui/game/GameFieldController.java
Thu Nov 10 01:23:35 2011
+++ /branches/nm8/src/cx/it/nullpo/nm8/gui/game/GameFieldController.java
Mon Jan 30 23:22:36 2012
@@ -26,12 +26,17 @@

elementMain = element;
if(elementMain == null) log.warn("elementMain == null!");
- elementPanelField = element.findElementByName("panel-field");
+ elementPanelField = element.findElementByName("#panel-field");
if(elementPanelField == null) log.warn("elementPanelField == null!");

CustomProperties params = new CustomProperties(parameter);
- blocksize = params.getProperty("blksize", 16);
- log.trace("blocksize:" + blocksize);
+ String strBlkSize = params.getProperty("blocksize");
+ if(strBlkSize == null) {
+ log.warn("No blksize is set for " + elementMain.getId() + ". Using 16
for default.");
+ blocksize = 16;
+ } else {
+ blocksize = params.getProperty("blocksize", 16);
+ }
}

public void onStartScreen() {
=======================================
--- /branches/nm8/src/cx/it/nullpo/nm8/gui/game/GameFieldRenderer.java Thu
Nov 10 01:23:35 2011
+++ /branches/nm8/src/cx/it/nullpo/nm8/gui/game/GameFieldRenderer.java Mon
Jan 30 23:22:36 2012
@@ -175,6 +175,22 @@
public static void drawPiece(Piece piece, NFGraphics g, int x, int y, int
blksize) {
drawPiece(piece, piece.direction, g, x, y, blksize);
}
+
+ public static void drawPieceCenter(Piece piece, int direction, NFGraphics
g, int x, int y, int blksize,
+ int boxWidth, int boxHeight)
+ {
+ int pWidth = piece.getWidth() + 1;
+ int pHeight = piece.getHeight() + 1;
+ int x2 = ((boxWidth - (pWidth * blksize)) / 2) -
(piece.getMinimumBlockX() * blksize);
+ int y2 = ((boxHeight - (pHeight * blksize)) / 2) -
(piece.getMinimumBlockY() * blksize);
+ drawPiece(piece, direction, g, x+x2, y+y2, blksize);
+ }
+
+ public static void drawPieceCenter(Piece piece, NFGraphics g, int x, int
y, int blksize,
+ int boxWidth, int boxHeight)
+ {
+ drawPieceCenter(piece, piece.direction, g, x, y, blksize, boxWidth,
boxHeight);
+ }

/**
* Draw a Block to somewhere on the screen
@@ -190,11 +206,12 @@

if(ResourceHolder.blockSkin != null) {
// TODO: Add support of multiple block skin
- NFImage img = ResourceHolder.blockSkin.mapImageNormal.get(16);
+ int obs = 16;
+ NFImage img = ResourceHolder.blockSkin.mapImageNormal.get(obs);

if(img != null) {
NFColor col = new NFColor(255,255,255,(int)(blk.alpha * 255));
- g.drawImage(img, x, y, x+blksize, y+blksize, blk.color * blksize, 0,
(blk.color * blksize) + blksize, blksize, col);
+ g.drawImage(img, x, y, x+blksize, y+blksize, blk.color * obs, 0,
(blk.color * obs) + obs, obs, col);
}
} else {
g.setColor(NFColor.green);
=======================================
--- /branches/nm8/src/cx/it/nullpo/nm8/gui/game/NullpoMinoNiftyGUI.java Fri
Jan 6 07:28:02 2012
+++ /branches/nm8/src/cx/it/nullpo/nm8/gui/game/NullpoMinoNiftyGUI.java Mon
Jan 30 23:22:36 2012
@@ -9,6 +9,7 @@
import org.jdom.input.SAXBuilder;

import cx.it.nullpo.nm8.game.component.Controller;
+import cx.it.nullpo.nm8.game.component.Piece;
import cx.it.nullpo.nm8.game.play.GameEngine;
import cx.it.nullpo.nm8.game.play.GameManager;
import cx.it.nullpo.nm8.game.play.GamePlay;
@@ -156,11 +157,41 @@
Screen curScreen = nifty.getCurrentScreen();
if(curScreen != null) {
for(int engineID = 0; engineID < gameManager.getNumberOfEngines();
engineID++) {
- GameFieldController fldctl = curScreen.findControl("field-" +
engineID, GameFieldController.class);
-
+ GameFieldController fldctl = null;
+ GameEngine engine = gameManager.getGameEngine(engineID);
+
+ // Draw Hold
+ fldctl = curScreen.findControl("hold-" + engineID,
GameFieldController.class);
if((fldctl != null) && (fldctl.getElementPanelField() != null)) {
Element e = fldctl.getElementPanelField();
- GameEngine engine = gameManager.getGameEngine(engineID);
+
+ if(engine.gameStarted) {
+ Piece piece = engine.getGamePlay(0).holdPieceObject;
+ if(piece != null) {
+ GameFieldRenderer.drawPieceCenter(piece, g, e.getX(), e.getY(),
+ fldctl.getBlockSize(), e.getWidth(), e.getHeight());
+ }
+ }
+ }
+ // Draw Next
+ for(int i = 0; i < engine.getGamePlay(0).ruleopt.nextDisplay; i++) {
+ fldctl = curScreen.findControl("next-" + engineID + "-" + i,
GameFieldController.class);
+ if((fldctl != null) && (fldctl.getElementPanelField() != null)) {
+ Element e = fldctl.getElementPanelField();
+
+ if(engine.gameStarted) {
+ Piece piece = engine.getGamePlay(0).nextPieceArray[i];
+ if(piece != null) {
+ GameFieldRenderer.drawPieceCenter(piece, g, e.getX(), e.getY(),
+ fldctl.getBlockSize(), e.getWidth(), e.getHeight());
+ }
+ }
+ }
+ }
+ // Draw Field
+ fldctl = curScreen.findControl("field-" + engineID,
GameFieldController.class);
+ if((fldctl != null) && (fldctl.getElementPanelField() != null)) {
+ Element e = fldctl.getElementPanelField();

if(engine.gameStarted) {
GameFieldRenderer.drawField(engine, g, e.getX(), e.getY(),
e.getWidth(), e.getHeight(), fldctl.getBlockSize());
=======================================
---
/branches/nm8/src/cx/it/nullpo/nm8/gui/slick/framework/SlickNFJInputKeyboard.java
Fri Oct 28 07:58:07 2011
+++
/branches/nm8/src/cx/it/nullpo/nm8/gui/slick/framework/SlickNFJInputKeyboard.java
Mon Jan 30 23:22:36 2012
@@ -31,6 +31,9 @@
/** true if JInput has inited */
public static boolean isInited;

+ /** true if keyboard will be autodetected */
+ public static boolean isAutoDetect;
+
/** ControllerEnvironment: Main object of JInput */
public static ControllerEnvironment controllerEnvironment;

@@ -43,8 +46,11 @@
/** Keysym map */
public static HashMap<Integer, Component.Identifier.Key> keyMap;

+ /** List of all keyboards */
+ protected static List<Keyboard> listKeyboard = new ArrayList<Keyboard>();
+
/** Key down array */
- protected boolean[] keyDownFlagArray = new boolean[KeyEvent.KEY_LAST];
+ protected static boolean[][] keyDownFlagArray;

/** Keyboard Listeners */
protected List<NFKeyListener> keyListeners =
Collections.synchronizedList(new ArrayList<NFKeyListener>());
@@ -58,8 +64,7 @@
protected static void initKeyboard(int keyboardID) {
controllerEnvironment = ControllerEnvironment.getDefaultEnvironment();
controllers = controllerEnvironment.getControllers();
-
- List<Keyboard> listKeyboard = new ArrayList<Keyboard>();
+ isAutoDetect = false;

log.trace("Start finding the controllers...");
for(int i = 0; i < controllers.length; i++) {
@@ -69,8 +74,9 @@
listKeyboard.add((Keyboard)c);
}

- log.trace("Controller " + i + " : " + c.getType().toString());
- }
+ log.trace("Controller #" + i + " : " + c.getType().toString() + " (" +
c.toString() + ")");
+ }
+ keyDownFlagArray = new boolean[listKeyboard.size()][KeyEvent.KEY_LAST];

if(listKeyboard.size() == 0) {
log.error("JInput couldn't find any keyboard.");
@@ -81,11 +87,19 @@
return;
} else if(listKeyboard.size() >= 2) {
log.debug(listKeyboard.size() + " keyboards are found by JInput. (#0 -
#" + (listKeyboard.size()-1) + ")");
+ for(int i = 0; i < listKeyboard.size(); i++) {
+ Keyboard kb = listKeyboard.get(i);
+ log.trace("Keyboard #" + i + " : " + kb.toString());
+ }
}

- if(keyboardID < 0) {
- log.trace("Preferred keyboard ID is less than 0. Last Keyboard (#" +
(listKeyboard.size()-1) + ") will be used.");
- keyboard = listKeyboard.get(listKeyboard.size()-1);
+ if(keyboardID == -1) {
+ log.trace("Preferred keyboard ID is -1. Keyboard will be
auto-detected.");
+ keyboard = null;
+ isAutoDetect = true;
+ } else if(keyboardID < -1) {
+ log.trace("Preferred keyboard ID is less than -1. All keyboards will be
used.");
+ keyboard = null;
} else if(keyboardID >= listKeyboard.size()) {
log.warn("Keyboard #" + keyboardID + " doesn't exist. " +
"Last Keyboard (#" + (listKeyboard.size()-1) + ") will be used
instead.");
@@ -234,16 +248,6 @@
initJInput(keyboardID);
}
}
-
- public boolean isKeyDown(int key) {
- if(keyboard != null) {
- Component.Identifier.Key jiKey = keyMap.get(key);
- if((jiKey != null) && (jiKey != Component.Identifier.Key.VOID)) {
- return keyboard.isKeyDown(jiKey);
- }
- }
- return false;
- }

public String getKeyName(int key) {
return KeyEvent.getKeyText(key);
@@ -283,25 +287,56 @@
}
}
}
+
+ public boolean isKeyDown(int key) {
+ for(int i = 0; i < listKeyboard.size(); i++) {
+ Keyboard kb = listKeyboard.get(i);
+ if(keyboard == null || kb == keyboard) {
+ if(isKeyDown(key, kb)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ public boolean isKeyDown(int key, Keyboard kb) {
+ if(kb != null) {
+ Component.Identifier.Key jiKey = keyMap.get(key);
+ if((jiKey != null) && (jiKey != Component.Identifier.Key.VOID)) {
+ return kb.isKeyDown(jiKey);
+ }
+ }
+ return false;
+ }

public void poll() {
- if(keyboard != null) {
- keyboard.poll();
-
- for(int i = 0; i < KeyEvent.KEY_LAST; i++) {
- if(isKeySupported(i)) {
- boolean down = isKeyDown(i);
-
- if(down != keyDownFlagArray[i]) {
- if(down) {
- dispatchKeyPressed(i, (char)0);
- } else {
- dispatchKeyReleased(i, (char)0);
- }
- keyDownFlagArray[i] = down;
+ for(int i = 0; i < listKeyboard.size(); i++) {
+ Keyboard kb = listKeyboard.get(i);
+ if(keyboard == null || kb == keyboard) {
+ kb.poll();
+
+ for(int j = 0; j < KeyEvent.KEY_LAST; j++) {
+ if(isKeySupported(j)) {
+ boolean down = isKeyDown(j, kb);
+
+ if(down != keyDownFlagArray[i][j]) {
+ if(isAutoDetect && (keyboard == null)) {
+ log.debug("Keyboard #" + i + " (" + kb.toString() + ") is
autodetected");
+ keyboard = kb;
+ }
+ if(down) {
+ dispatchKeyPressed(j, (char)0);
+ } else {
+ dispatchKeyReleased(j, (char)0);
+ }
+ keyDownFlagArray[i][j] = down;
+ }
}
}
}
}
}
-}
+
+}
=======================================
--- /branches/nm8/src/cx/it/nullpo/nm8/neuro/core/NEUROCore.java Thu Nov 17
23:26:52 2011
+++ /branches/nm8/src/cx/it/nullpo/nm8/neuro/core/NEUROCore.java Mon Jan 30
23:22:36 2012
@@ -9,9 +9,6 @@
import cx.it.nullpo.nm8.gui.framework.NFMouse;
import cx.it.nullpo.nm8.gui.framework.NFMouseListener;
import cx.it.nullpo.nm8.gui.framework.NFSystem;
-import cx.it.nullpo.nm8.gui.niftygui.NFInputSystem;
-import cx.it.nullpo.nm8.gui.niftygui.NFRenderDevice;
-import cx.it.nullpo.nm8.gui.niftygui.NFSoundDevice;
import cx.it.nullpo.nm8.neuro.event.DebugEvent;
import cx.it.nullpo.nm8.neuro.event.JoyAxisEvent;
import cx.it.nullpo.nm8.neuro.event.JoyButtonEvent;
@@ -28,8 +25,6 @@
import cx.it.nullpo.nm8.neuro.gui.ScreenManager;
import cx.it.nullpo.nm8.neuro.network.NetworkCommunicator;
import cx.it.nullpo.nm8.neuro.plugin.NEUROPlugin;
-import de.lessvoid.nifty.Nifty;
-import de.lessvoid.nifty.tools.TimeProvider;

/**
* Implements some common functionality in all NEURO implementations, such
as passing events.
@@ -58,16 +53,25 @@
protected ScreenManager manager;

/** The render device that will be used by this NEURO. */
- private NFRenderDevice renderDevice;
+ //private NFRenderDevice renderDevice;

/** The sound device that will be used by this NEURO. */
- private NFSoundDevice soundDevice;
+ //private NFSoundDevice soundDevice;

/** The input system that will be used by this NEURO. */
- private NFInputSystem inputSys;
+ //private NFInputSystem inputSys;

/** The time provider that will be used by this NEURO. */
- private TimeProvider timeProvider;
+ //private TimeProvider timeProvider;
+
+ /** true if keyboard manager becomes available */
+ private boolean keyboardAvailable;
+
+ /** true if mouse manager becomes available */
+ private boolean mouseAvailable;
+
+ /** true if joystick manager becomes available */
+ private boolean joystickAvailable;

/**
* Constructor for NEUROCore.
@@ -77,14 +81,8 @@
// Set up system and input handling
this.sys = sys;
if (sys != null) {
- sys.getKeyboard().addKeyListener(this);
- if(sys.getMouse() != null) {
- sys.getMouse().addMouseListener(this);
- }
- if(sys.getJoystickManager() != null &&
sys.getJoystickManager().isInited()) {
- sys.getJoystickManager().addListener(this);
- }
- inputSys = new NFInputSystem(sys.getKeyboard(),sys.getMouse());
+ checkDeviceAvailable();
+ //inputSys = new NFInputSystem(sys.getKeyboard(),sys.getMouse());
}

overlayUpdateFlag = false;
@@ -92,18 +90,40 @@

manager = new DummyManager();

- renderDevice = new NFRenderDevice(sys);
- soundDevice = new NFSoundDevice(sys);
- timeProvider = new TimeProvider();
+ //renderDevice = new NFRenderDevice(sys);
+ //soundDevice = new NFSoundDevice(sys);
+ //timeProvider = new TimeProvider();

}
+
+ /**
+ * Check if additional device manager becomes available
+ * (We need to run this code multiple times as mouse and joysticks are
not available when NEURO is inited)
+ */
+ protected void checkDeviceAvailable() {
+ if(!keyboardAvailable && sys.getKeyboard() != null) {
+ dispatchEvent(new DebugEvent(this, DebugEvent.TYPE_DEBUG, "Keyboard
manager is available"));
+ sys.getKeyboard().addKeyListener(this);
+ keyboardAvailable = true;
+ }
+ if(!mouseAvailable && sys.getMouse() != null) {
+ dispatchEvent(new DebugEvent(this, DebugEvent.TYPE_DEBUG, "Mouse
manager is available"));
+ sys.getMouse().addMouseListener(this);
+ mouseAvailable = true;
+ }
+ if(!joystickAvailable && sys.getJoystickManager() != null &&
sys.getJoystickManager().isInited()) {
+ dispatchEvent(new DebugEvent(this, DebugEvent.TYPE_DEBUG, "Joystick
manager is available"));
+ sys.getJoystickManager().addListener(this);
+ joystickAvailable = true;
+ }
+ }

@Override
public void addPlugin(NEUROPlugin p) {
if (p instanceof NFGame) {
game = (NFGame) p;
}
- p.initGUI(new Nifty(renderDevice,soundDevice,inputSys,timeProvider));
+ //p.initGUI(new Nifty(renderDevice,soundDevice,inputSys,timeProvider));
super.addPlugin(p);
}

@@ -125,6 +145,8 @@

@Override
public void update(long delta) {
+ // Check more devices
+ checkDeviceAvailable();
// Update the game
game.update(sys, delta);
// Update the overlay if applicable
=======================================
--- /branches/nm8/src/cx/it/nullpo/nm8/neuro/gui/ScreenSet.java Wed Nov 9
19:53:13 2011
+++ /branches/nm8/src/cx/it/nullpo/nm8/neuro/gui/ScreenSet.java Mon Jan 30
23:22:36 2012
@@ -5,6 +5,8 @@
import java.util.Set;
import java.util.Stack;

+import de.lessvoid.nifty.Nifty;
+
/**
* A ScreenSet allows switching between various screens. In this way, you
can have multiple
* plugins running at once, and go between the screens. If you close the
current screen, you
@@ -13,13 +15,13 @@
*
*/
public class ScreenSet implements ScreenManager {
-
+
/** The set of registered plugins. */
Set<ScreenHolder> set;
-
+
/** The stack of last-used plugins. */
Stack<ScreenHolder> stack;
-
+
public ScreenSet() {
set = new HashSet<ScreenHolder>();
stack = new Stack<ScreenHolder>();
@@ -63,7 +65,8 @@

@Override
public void render() {
- stack.peek().getGUI().render(true);
+ Nifty gui = stack.peek().getGUI();
+ if(gui != null) gui.render(true);
}

}
=======================================
--- /branches/nm8/src/cx/it/nullpo/nm8/neuro/gui/ScreenStack.java Wed Nov
9 19:53:13 2011
+++ /branches/nm8/src/cx/it/nullpo/nm8/neuro/gui/ScreenStack.java Mon Jan
30 23:22:36 2012
@@ -3,6 +3,8 @@
import java.util.Collection;
import java.util.Stack;

+import de.lessvoid.nifty.Nifty;
+
/**
* The ScreenStack is a manager which pushes new screens on top of the
stack. It doesn't allow manual
* switching, and only allows the user to remove the top screen. It is
essentially an implementation of
@@ -11,9 +13,9 @@
*
*/
public class ScreenStack implements ScreenManager {
-
+
private Stack<ScreenHolder> stack;
-
+
public ScreenStack() {
stack = new Stack<ScreenHolder>();
}
@@ -22,7 +24,7 @@
public void register(ScreenHolder s) {
if (s.getGUI() != null) {
stack.push(s);
- }
+ }
}

@Override
@@ -38,12 +40,12 @@
public void remove() {
stack.pop();
}
-
+
@Override
public void remove(ScreenHolder s) {
StackUtils.remove(stack,s);
}
-
+
@Override
public void removeAll() {
while (!stack.isEmpty()) {
@@ -53,7 +55,8 @@

@Override
public void render() {
- stack.peek().getGUI().render(true);
+ Nifty gui = stack.peek().getGUI();
+ if(gui != null) gui.render(true);
}

}
=======================================
--- /branches/nm8/src/cx/it/nullpo/nm8/neuro/light/NEUROLight.java Thu Jul
28 21:53:42 2011
+++ /branches/nm8/src/cx/it/nullpo/nm8/neuro/light/NEUROLight.java Mon Jan
30 23:22:36 2012
@@ -28,14 +28,14 @@
dispatchEvent(new DebugEvent(this,DebugEvent.TYPE_WARNING,"Unable to
load NEURO font"));
}
}
-
+
public static NEURO create(NFSystem sys) {
NEUROLight neuro = new NEUROLight(sys);
-
+
try {
new Nullterm().init(neuro);
} catch (PluginInitializationException e) {}
-
+
return neuro;
}

@@ -62,7 +62,8 @@
String str = "POWERED BY "+getName().toUpperCase()+" "+getVersion();
int width = g.getStringWidth(str);
int x = (sys.getOriginalWidth() - width) / 2;
- g.drawString(str,x,450);
+ int y = sys.getOriginalHeight() - 30;
+ g.drawString(str,x,y);
}
}

Reply all
Reply to author
Forward
0 new messages