As some of you know, I’m replacing my old menuing system with something more JME-friendly than nifty. It’s far enough along that I actually have something to show for it. I thought some might find it interesting.
[video]http://www.youtube.com/watch?v=3hxe2iLEEWE&feature=youtu.be[/video]
There are sort of a few levels here. There is the base GUI toolkit (which I hope to release to the monkeys someday) that for the most part acts a lot like swing except with CSS-like style support:
[java]
// Some elements using some kind of “paper” style
Container c = new Container( “paper” );
c.addChild( new Label( “Hello, world.”, “paper” );
c.addChild( new Button( “Exit”, “paper” );
[/java]
The menu system is actually another layer of abstraction created from “MenuElements” that have a loosely hierarchical organization. Some of these relate to meta-components like a slider + a label. Basically, the “menu elements” are created in groovy scripts and are visualization independent. The UI side takes these menu elements and makes a UI out of them in some implementation specific way (in this case pages of parchment).
Menu system groovy files look like: (with dummy code in the event handlers)
[java]
section( “Single Player” ) {
action( "Continue last game" ).onClick {
println "Continue last game."
}
action( "Create new world" ).onClick {
println "Create new world."
}
action( "Load existing world" ).onClick {
println "Load existing world."
}
}
[/java]
That part is kind of Mythruna-specific (or at least specific to my game’s engine) but will make it easier to support total conversions later.