GuiGlobals.initialize(app);
// Load the 'glass' style
// BaseStyles.loadGlassStyle();
BaseStyles.loadStyleResources("mygame/styles/PolyStyles.groovy");
// Set 'glass' as the default style when not specified
GuiGlobals.getInstance().getStyles().setDefaultStyle("poly");
No matter where I put PolyStyles.groovy outside of the Assets folder, it will not find it.
INFO: Interface/Fonts/Console.png (Flipped)
[jME3 Main] INFO com.simsilica.lemur.GuiGlobals - Initializing GuiGlobals with:com.simsilica.lemur.GuiGlobals@402e87a5
[jME3 Main] INFO com.simsilica.lemur.GuiGlobals - Lemur build date:20181119
[jME3 Main] INFO com.simsilica.lemur.style.BaseStyles - loadStyleResource(mygame/styles/PolyStyles.groovy)
[jME3 Main] INFO com.simsilica.lemur.style.BaseStyles - Loading base resource:null
Nov 25, 2018 6:41:16 PM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.NullPointerException
at com.simsilica.lemur.style.StyleLoader.loadStyle(StyleLoader.java:162)
at com.simsilica.lemur.style.BaseStyles.loadStyleResources(BaseStyles.java:78)
at mygame.states.LobbyState.initialize(LobbyState.java:43)
at com.jme3.app.state.BaseAppState.initialize(BaseAppState.java:124)
at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:251)
at com.jme3.app.state.AppStateManager.update(AppStateManager.java:281)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:236)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:197)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232)
at java.lang.Thread.run(Thread.java:748)
[jME3 Main] INFO com.simsilica.lemur.style.BaseStyles - loadStyleResource(mygame/styles/PolyStyles.groovy)
[jME3 Main] INFO com.simsilica.lemur.style.BaseStyles - Loading base resource:null
I have tried every path conceivable and it will only find the file if its inside the Assets folder. Problem with that is then it cant load the assets, they all come up null, even when I copied all the files into the assets folder.
Groovy does not like being inside the asset folder period. The SDK wont even let you create a new file there. You cant even move the file there. Copy and paste is all you got.
Something is messed up with netbeans or the way I am doing this. I have read every forum post and the wiki over and over and it seems no one else even has a problem.
Also copied your groovy file and tried with no changes, then changed all the file links and copied everything to the folders shown in the first pict. Still wont get past the load.
Ah, yeah… I guess I already add the /. Sorry for the misdirection.
I guess it would be nicer to do something other than throw an NPE in that case.
I wonder if it’s because I’m looking it up relative to the BaseTyle.class and the classloader setup is not letting that load from the assets folder (Note that it would generally work from other jars). Does this also error out when running your app outside of the SDK?
That’s really strange. Once the assets are in an assets.jar then I’d have expected it to work. After all, that’s a really common use-case for me. Even Lemur itself will load styles from the lemur jar and the lemur-proto.jar if present and I load custom styles from my own code all the time. (Those are generally also in the src directory they are in jars other than the Lemur jar at the time of running.)
I haven’t run the SDK in probably 2-3 years or more so I can’t help specifically with that other than to say that it “shouldn’t” be a Java issue… some kind of classloader setup issue it seems like.
I just ran in a new test case and does exactly same thing. With or without a groovy file it does at same place,
// Create a simple container for our elements
// Initialize the globals access so that the defualt
// components can find what they need.
GuiGlobals.initialize(app);
// Load the 'glass' style
// BaseStyles.loadGlassStyle();
BaseStyles.loadStyleResources("mygame/PolyStyles.groovy");
This line is null always so when it calls loadStyle(baseResource);
What’s messed up is I can see the compiled classes in the build file and dist file jar. I can move the classes around by changing the package declaration in the groovy file. Just can’t get the dam horse to drink the water.
…but we don’t want a compiled groovy class. We want the actual .groovy file.
Sounds like the SDK is trying to build it instead of just copying it as a resource. The .groovy file is executed at runtime.
There is not yet any facility in lemur to run a precompiled groovy style… though something like that is on my to-do list to better support android. (It’s tricky because of the ability to extend styles with multiple groovy files.)
Cant find a way to exclude it from build so I created another project, placed the groovy script and assests for icons there, and added it to the library as a folder.
This seems to work. It looks like its loading the assets.
[jME3 Main] INFO com.simsilica.lemur.GuiGlobals - Initializing GuiGlobals with:com.simsilica.lemur.GuiGlobals@71c963a8
[jME3 Main] INFO com.simsilica.lemur.GuiGlobals - Lemur build date:20181119
[jME3 Main] INFO com.simsilica.lemur.style.BaseStyles - loadStyleResource(PolyStyles.groovy)
[jME3 Main] INFO com.simsilica.lemur.style.BaseStyles - Loading base resource:file:/C:/Users/Robert/Documents/JMonkey/GroovyStyles/src/mygame/PolyStyles.groovy
Nov 26, 2018 1:59:42 PM mygame.Main$1 assetRequested
INFO: bordered-gradient.png (Flipped)
Nov 26, 2018 1:59:42 PM mygame.Main$1 assetRequested
INFO: bevel-quad.png (Flipped)
Nov 26, 2018 1:59:42 PM mygame.Main$1 assetRequested
INFO: border.png (Flipped)
Nov 26, 2018 1:59:42 PM mygame.Main$1 assetRequested
INFO: border.png (Flipped)
Nov 26, 2018 1:59:42 PM mygame.Main$1 assetRequested
INFO: double-gradient-128.png (Flipped)
Nov 26, 2018 1:59:42 PM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.RuntimeException: Error running resource:file:/C:/Users/Robert/Documents/JMonkey/GroovyStyles/src/mygame/PolyStyles.groovy
at com.simsilica.lemur.style.StyleLoader.loadStyle(StyleLoader.java:183)
at com.simsilica.lemur.style.StyleLoader.loadStyle(StyleLoader.java:162)
at com.simsilica.lemur.style.BaseStyles.loadStyleResources(BaseStyles.java:78)
at mygame.states.LobbyState.initialize(LobbyState.java:56)
at com.jme3.app.state.BaseAppState.initialize(BaseAppState.java:124)
at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:251)
at com.jme3.app.state.AppStateManager.update(AppStateManager.java:281)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:236)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:197)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232)
at java.lang.Thread.run(Thread.java:748)
Caused by: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: ButtonAction for class: Script2
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:349)
at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:41)
at javax.script.CompiledScript.eval(CompiledScript.java:92)
at com.simsilica.lemur.style.StyleLoader.loadStyle(StyleLoader.java:177)
... 11 more
Caused by: groovy.lang.MissingPropertyException: No such property: ButtonAction for class: Script2
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
at Script2.run(Script2.groovy:92)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:346)
... 14 more
AL lib: (EE) alc_cleanup: 1 device not closed
Exception: java.lang.NullPointerException thrown from the UncaughtExceptionHandler in thread "jME3 Main"
The problem in the groovy file was the def pressedCommand and def repeatCommand. Removed those and it works now.
Nothing I can find lets you exclude compiling a groovy file in netbeans. Search shows others trying and nothing works, seems to be netbeans 8 fail or I’m just not experienced enough to figure it out.
I’m not sure if placing the groovy file inside a test folder would also work since I don’t have one setup.
I created a new project just to hold the groovy file.
Added that project folder to my main project libraries through add>jar/folder, selecting the folder that holds the groovy file.
This stops the compile from copying the class files.
Not copying library C:\Users\Robert\Documents\JMonkey\GroovyStyles\src\mygame , it's a directory.
And everything seems to work now. I am using the TabbedPanelDemoState.java code and it looks to be working just fine. I havenet changed any graphics but since it compiles clean and that works I don’t see a problem. If one arises, I will post it.
I would like to know if anyone else using the SDK had this happen or if I’m just screwing things up and defensive coding this.
Would also be nice to know of a way to exclude the groovy file from build inside the main project.
Edit: forgot to mention, I created an icon folder in my main project and lemur loads its images from there. Only has to place the groovy file in the other project.
Note: there is nothing in Lemur style loading that requires the .groovy extension. So you could give it a different extension and maybe the SDK won’t try to build it. .style or something.