Test case which loads minimum SimEthereal, Lemur and displays the same behavior.
// Make sure JUL logging goes to our log4j configuration
LogAdapter.initialize();
Requires gradle 5.4.+ unless you tweak it.
A single Lemur Checkbox with attached listener.
Build.gradle
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'idea'
mainClassName='mygame.TestIsPressed'
repositories {
//This is where jme3 dependencies are stored.
jcenter()
//Uncomment this if you install local dependencies.
mavenLocal()
//Uncomment this if you use external dependencies
mavenCentral()
maven { url "https://www.jitpack.io" }
//Uncomment this if you use jme3-niftygui
//maven{url 'http://nifty-gui.sourceforge.net/nifty-maven-repo'}
}
ext.jmeVersion = '[3.2,)'
project(":assets") {
apply plugin: "java"
buildDir = rootProject.file("build/assets")
sourceSets {
main {
resources {
srcDir '.'
}
}
}
}
dependencies {
implementation "org.jmonkeyengine:jme3-core:$jmeVersion"
implementation "org.jmonkeyengine:jme3-desktop:$jmeVersion"
implementation "org.jmonkeyengine:jme3-lwjgl:$jmeVersion"
//Those are jme3 additional library uncomment the ones you need
//compile "org.jmonkeyengine:jme3-android-native:$jmeVersion"
//compile "org.jmonkeyengine:jme3-android:$jmeVersion"
//compile "org.jmonkeyengine:jme3-bullet-native-android:$jmeVersion"
//compile "org.jmonkeyengine:jme3-blender:$jmeVersion"
//compile "org.jmonkeyengine:jme3-bullet-native:$jmeVersion"
//compile "org.jmonkeyengine:jme3-bullet:$jmeVersion"
//compile "org.jmonkeyengine:jme3-effects:$jmeVersion"
implementation "org.jmonkeyengine:jme3-jogg:$jmeVersion"
//compile "org.jmonkeyengine:jme3-jogl:$jmeVersion"
//compile "org.jmonkeyengine:jme3-lwjgl3:$jmeVersion"
implementation "org.jmonkeyengine:jme3-networking:$jmeVersion"
implementation "org.jmonkeyengine:jme3-plugins:$jmeVersion"
//compile "org.jmonkeyengine:jme3-terrain:$jmeVersion"
//You need to uncomment nifty repository in the repositories section if you use this dependency
//compile "org.jmonkeyengine:jme3-niftygui:$jmeVersion"
//SimEthereal
implementation 'com.github.Simsilica:SimEthereal:master-SNAPSHOT'
// implementation "com.simsilica:sim-ethereal-v1.5.0"
//SimMath
implementation 'com.github.Simsilica:SimMath:master-SNAPSHOT'
// implementation 'com.simsilica:sim-math-v1.4.0'
//SiO2
implementation 'com.github.Simsilica:SiO2:master-SNAPSHOT'
// implementation 'com.simsilica:sio2:1.3.0'
//Logging
implementation 'org.slf4j:slf4j-api:1.7.26'
runtimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl:2.11.2'
//Lemur
implementation 'com.github.jMonkeyEngine-Contributions.Lemur:lemur:master-SNAPSHOT'
// implementation "com.simsilica:lemur:1.13.0"
implementation "com.simsilica:lemur-proto:1.11.0"
implementation 'com.simsilica:lemur-props:1.1.0'
runtime project(':assets')
}
task (createDirs).doLast {
def pkg = 'mygame'
def dirs = [
file("./src/main/java/$pkg"),
file("./src/main/resources"),
file("./assets/Interface"),
file("./assets/MatDefs"),
file("./assets/Materials"),
file("./assets/Models"),
file("./assets/Scenes"),
file("./assets/Shaders"),
file("./assets/Sounds"),
file("./assets/Textures"),
]
dirs.each {
if( !it.exists() ) {
println "Creating " + it
it.mkdirs()
}
if( it.listFiles().length == 0 ) {
def stub = new File(it, 'removeme.txt')
println "Creating stub file to allow git checkin, file:$stub"
stub.text = "Remove me when there are files here."
}
}
}
TestIsPressed.java
package mygame;
import com.jme3.app.BasicProfilerState;
import com.jme3.app.DebugKeysAppState;
import com.jme3.app.LostFocusBehavior;
import com.jme3.app.SimpleApplication;
import com.jme3.app.StatsAppState;
import com.jme3.input.event.MouseButtonEvent;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;
import com.jme3.system.AppSettings;
import com.simsilica.lemur.Button;
import com.simsilica.lemur.Checkbox;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.GuiGlobals;
import com.simsilica.lemur.OptionPanelState;
import com.simsilica.lemur.anim.AnimationState;
import com.simsilica.lemur.event.DefaultMouseListener;
import com.simsilica.lemur.event.MouseEventControl;
import com.simsilica.lemur.style.BaseStyles;
import com.simsilica.util.LogAdapter;
/**
*
* @author mitm
*/
public class TestIsPressed extends SimpleApplication {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// Make sure JUL logging goes to our log4j configuration
LogAdapter.initialize();
TestIsPressed main = new TestIsPressed();
main.setLostFocusBehavior(LostFocusBehavior.Disabled);
AppSettings settings = new AppSettings(true);
// Set some defaults that will get overwritten if
// there were previously saved settings from the last time the user
// ran.
settings.setResolution(1280, 720);
settings.setVSync(true);
settings.setGammaCorrection(true);
settings.setTitle("TestIsPressed");
settings.setUseJoysticks(false);
main.setSettings(settings);
main.start();
}
public TestIsPressed() {
super(new StatsAppState(), new DebugKeysAppState(), new BasicProfilerState(false),
new AnimationState(), // from Lemur
new OptionPanelState() );// from Lemur
}
@Override
public void simpleInitApp() {
setPauseOnLostFocus(false);
setDisplayFps(false);
setDisplayStatView(false);
GuiGlobals.initialize(this);
GuiGlobals globals = GuiGlobals.getInstance();
BaseStyles.loadGlassStyle();
globals.getStyles().setDefaultStyle("glass");
Container cont = new Container();
Checkbox checkBox = cont.addChild(new Checkbox("checkbox"));
MouseEventControl.addListenersToSpatial(checkBox, new DefaultMouseListener() {
@Override
protected void click( MouseButtonEvent event, Spatial target, Spatial capture ) {
System.out.println("Checkbox Pressed " + event.isPressed());
System.out.println("Checkbox Released " + event.isReleased());
}
});
Button button = cont.addChild(new Button("Button"));
MouseEventControl.addListenersToSpatial(button, new DefaultMouseListener() {
@Override
protected void click( MouseButtonEvent event, Spatial target, Spatial capture ) {
System.out.println("Button Pressed " + event.isPressed());
System.out.println("Button Released " + event.isReleased());
}
});
center(cont);
guiNode.attachChild(cont);
}
private void center(Container cont) {
// Position the panel
Vector3f pref = cont.getPreferredSize().clone();
cont.setLocalTranslation((getCamera().getWidth() - pref.x)/2,
(getCamera().getHeight() + pref.y)/2, 0);
}
}
Probably something I did wrong.
Edit: Forgot to mention, uses jitpack so changes will be accessible immediately upon push.