public void loadGame() {
getState(OptionPanelState.class).show("Load","load games",
new CallMethodAction("Load saved game1", this, "instantAction")
);
When executed gets
nov 02, 2017 2:36:51 PM com.jme3.app.LegacyApplication handleError
GRAVE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.RuntimeException: Error invoking action method:loadGame
at com.simsilica.lemur.CallMethodAction.execute(CallMethodAction.java:208)
at com.simsilica.lemur.ActionButton$ClickCommand.execute(ActionButton.java:132)
at com.simsilica.lemur.ActionButton$ClickCommand.execute(ActionButton.java:127)
at com.simsilica.lemur.core.CommandMap.runCommands(CommandMap.java:61)
at com.simsilica.lemur.Button.runClick(Button.java:333)
at com.simsilica.lemur.Button$ButtonMouseHandler.mouseButtonEvent(Button.java:410)
at com.simsilica.lemur.event.MouseEventControl.mouseButtonEvent(MouseEventControl.java:122)
at com.simsilica.lemur.event.PickEventSession.buttonEvent(PickEventSession.java:624)
at com.simsilica.lemur.event.MouseAppState.dispatch(MouseAppState.java:98)
at com.simsilica.lemur.event.MouseAppState$MouseObserver.onMouseButtonEvent(MouseAppState.java:114)
at com.jme3.input.InputManager.processQueue(InputManager.java:831)
at com.jme3.input.InputManager.update(InputManager.java:907)
at com.jme3.app.LegacyApplication.update(LegacyApplication.java:725)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:227)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:193)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.simsilica.lemur.CallMethodAction.execute(CallMethodAction.java:195)
... 17 more
Caused by: java.lang.NullPointerException
at com.pesegato.p8s.appstates.MainMenuAppState.loadGame(MainMenuAppState.java:234)
... 22 more
This can be avoided with this
getStateManager().attach(new OptionPanelState());
Which is a bit strange to me… However the button options don’t respond to mouse clicks.
I don’t know what I did wrong, please help!
Thanks
I’ve checked “your” MainMenuState and I didn’t see the attach on your code, so I thought it wasn’t needed.
EDIT: I’ve seen it now
I see the optionpane, but hovering with the mouse don’t highlight the options, and clicking on the options don’t do anything. The “CallMethodAction” isn’t executed here, but is executed on other buttons on the main menu
99.99999999999999999999999999999999999999999999999999999999999% of my system-level app states like this will be attached in the application constructor like they should be.
And it uses the standard glass style? ie: highlighting won’t be screwed up for some other reason.
I’m not sure why it’s not working. Have you tried running my apps that use it to see if it still works there?
public class HelloJME3 extends FullHDApplication {
public static void main(String[] args){
HelloJME3 app = new HelloJME3();
app.start(); // start the game
}
@Override
public void finalizeInit() {
getStateManager().attachAll(
new OptionPanelState(),
new MainMenuAppState());
GuiGlobals.initialize(this);
GuiGlobals globals = GuiGlobals.getInstance();
BaseStyles.loadGlassStyle();
globals.getStyles().setDefaultStyle("glass");
}
}
public abstract class FullHDApplication extends SimpleApplication {
public static String TITLE;
public static final String DISPLAY_VERSION = "December 17 beta";
public static boolean COOKED_BUILD;
public static String BUILD_REVISION;
public static String BUILD_DATE;
public Node scaledGuiNode = new Node("ScaledGUINode");
public static Properties props = new Properties();
BitmapText version;
public static String defPath;
static Logger log = LoggerFactory.getLogger(FullHDApplication.class);
public static String mod = null;
public FullHDApplication(AppState... appstates) {
super(appstates);
}
static void runApplication(FullHDApplication app, AppSettings settings) throws IOException {
app.setSettings(settings);
app.start();
}
@Override
public void simpleInitApp() {
guiNode.attachChild(scaledGuiNode);
float scalingFactor = Display.getWidth() / 1920f;
scaledGuiNode.scale(scalingFactor);
finalizeInit();
version = new BitmapText(guiFont, false);
version.setBox(new Rectangle(0, 0, Display.getWidth(), 215));
version.setAlignment(BitmapFont.Align.Right);
version.setLocalTranslation(0, version.getLineHeight(), 1000);
version.setText(DISPLAY_VERSION + "/" + BUILD_REVISION + "@" + BUILD_DATE);
//if I comment the next line the error goes away!!!
guiNode.attachChild(version);
}
public abstract void finalizeInit();
}
It looks like that a Quad is hijacking the events!? But it’s not even registered…
Honestly, I barely have time to read the forum these days. Not sure when I’d get to look at it. If not the week of Thanksgiving then it wouldn’t be until Christmas.
It’s way easier for you to debug the issue locally, probably. Just look in the PickEventSession stuff… but it’s really only paying attention to things with listeners added.
No, I’m implying that adding or not adding that BitmapText isn’t really the issue. Could be that if you added a second BitmapText then it would start working. Or if you added it first… etc…
It’s something probably unrelated to Lemur. Could be related to the empty node you have attached to the guiNode. Who knows?
Are you really sure?
To me, this looks like that the offending code shows an issue with either JME or Lemur (or LWJGL)… I do think that I’m using the APIs as they are intended, but feel free to prove me wrong.
The code posted on the Lemur issue tracker gets rid of the empty node and other unneeded stuff.
I’ve solved “my” issue because I realized that I don’t really need the OptionPane, so this probably will be my last post on this matter.
Yes, you are using the API correctly. I mean that it may be a bug in JME.
Lemur is not doing anything strange here. If those things are unclickable then it means that picking is messed up somewhere. Adding a BitmapText shouldn’t cause other collisions to fail.