Created
August 15, 2020 21:18
-
-
Save Mr00Anderson/a5424131bd9d71fbebb26142b878dff5 to your computer and use it in GitHub Desktop.
simple-application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
maven { | |
url "https://plugins.gradle.org/m2/" | |
} | |
} | |
dependencies { | |
classpath "org.beryx:badass-runtime-plugin:1.8.5" | |
} | |
} | |
apply plugin: 'application' | |
apply plugin: 'org.beryx.runtime' | |
sourceSets.main.resources.srcDirs += [ rootProject.file('assets').path ] | |
mainClassName = 'com.virtual_hex.gdx.engine.editor.Lwjgl3Launcher' | |
eclipse.project.name = appName + '-test-client-lwjgl3' | |
configurations { | |
pluginsPackage.extendsFrom runtimeClasspath | |
} | |
dependencies { | |
api project(':lwjgl3') | |
api project(':core-xerox-scene2d-json') | |
api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" | |
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" | |
api "com.badlogicgames.gdx:gdx-tools:$gdxVersion" | |
api "com.badlogicgames.gdx:gdx-controllers-lwjgl3:$gdxVersion" | |
api "de.golfgl.gdxcontrollerutils:gdx-controllers-jamepad:$controllerUtilsVersion" | |
api 'org.eclipse.jgit:org.eclipse.jgit:5.8.0.202006091008-r' | |
// implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8' | |
} | |
import org.gradle.internal.os.OperatingSystem | |
run { | |
workingDir = rootProject.file('assets').path | |
setIgnoreExitValue(true) | |
if (OperatingSystem.current() == OperatingSystem.MAC_OS) { | |
// Required to run LWJGL3 Java apps on MacOS | |
jvmArgs += "-XstartOnFirstThread" | |
} | |
} | |
jar { | |
destinationDirectory = file("$buildDir/lib") | |
archiveFileName = "${eclipse.project.name}-${project.version}.jar" | |
manifest { | |
attributes 'Main-Class': project.mainClassName | |
} | |
} | |
runtime { | |
options = ['--strip-debug', | |
'--compress', '2', | |
'--no-header-files', | |
'--no-man-pages', | |
'--strip-native-commands', | |
'--vm', 'server'] | |
modules = ['java.base' , | |
'java.desktop', | |
'jdk.unsupported'] | |
jpackage { | |
installerOptions += [ '--vendor', 'com.virtual-hex', '--description', 'Gdx Engine Editor - Game Designer' ] | |
mainJar = jar.archiveFileName.get() | |
installerName = imageName = appName | |
if (org.gradle.internal.os.OperatingSystem.current().windows) { | |
imageOptions += [ "--icon", file("../assets/icon.ico") ] | |
installerOptions += ['--win-per-user-install', '--win-dir-chooser', '--win-menu', '--win-shortcut', '--win-upgrade-uuid', '93757012-479c-4864-91c8-c47b25c7add8'] | |
} else { | |
//imageOptions += ["--icon", file("../assets/icons/Icon-32.png")] | |
installerOptions += ['--linux-menu-group', '--linux-shortcut'] | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.virtual_hex.gdx.engine.test; | |
import com.kotcrab.vis.ui.VisUI; | |
import com.virtual_hex.app.AppLauncher; | |
import com.virtual_hex.gdx.engine.app.GdxEngAppScreenBuilder; | |
import com.virtual_hex.gdx.engine.app.GdxEngScreenManagerApp; | |
import com.virtual_hex.gdx.engine.assets.EngineAssetManager; | |
// Core for all devices - Which will be basic tools, the web will be different though until file system | |
/** | |
* Move this to engine core - We do not want to mix the editor files in with the engine files, might | |
* get confusing. Though some editor files are withing the package the lib is in so that the | |
* engine can be launched into an editor | |
*/ | |
public class DefaultTestClientApp<T extends DefaultTestClientApp> extends GdxEngScreenManagerApp { | |
/** | |
* Application main assets? or not need to check code type of task | |
*/ | |
protected EngineAssetManager virtualHexAssetManager; | |
// Class creator interface | |
public DefaultTestClientApp(AppLauncher<T> appLauncher, GdxEngAppScreenBuilder mainScreenBuilder) { | |
super("virtual-hex", "engine-editor", appLauncher, mainScreenBuilder); | |
// Screen meta data here would be we wouldnt need a supplier | |
} | |
// Class creator interface | |
public DefaultTestClientApp(AppLauncher<T> appLauncher) { | |
super("virtual-hex", "engine-editor", appLauncher, getMainStartingScreen(appLauncher)); | |
// Screen meta data here would be we wouldnt need a supplier | |
} | |
@Override | |
public void loadState() { | |
} | |
@Override | |
public void saveState() { | |
} | |
@Override | |
public void loadingCompleted() { | |
} | |
/** | |
* | |
*/ | |
@Override | |
public void create() { | |
this.virtualHexAssetManager = new EngineAssetManager(); | |
if(!VisUI.isLoaded()) VisUI.load(); // Load this before the App | |
// TODO This has to be called after because get screen used the batch. THIS probably should be change soon | |
super.create(); | |
} | |
@Override | |
public void dispose() { | |
super.dispose(); | |
if(!VisUI.isLoaded()) VisUI.dispose(); // Unload this after the app unloads, ensure not in use | |
this.virtualHexAssetManager.dispose(); | |
} | |
// TODO - This is dependant on the platform, however for now we want to have a way to test stuff on all platforms | |
public static <T extends GdxEngScreenManagerApp> GdxEngAppScreenBuilder getMainStartingScreen(AppLauncher<T> appLauncher) { | |
return null; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.virtual_hex.gdx.engine.test; | |
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; | |
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; | |
import com.virtual_hex.app.DesktopAppLauncher; | |
import com.virtual_hex.meta.ComplexVersion; | |
import com.virtual_hex.meta.State; | |
import com.virtual_hex.system.JarProperties; | |
import com.virtual_hex.system.JvmStartedBy; | |
/** Launches the desktop (LWJGL3) application. | |
* | |
* This editor will be the only full version of the editor. | |
* Other platforms may support specific tools. | |
* | |
*/ | |
public class Lwjgl3Launcher implements DesktopAppLauncher<Lwjgl3TestClientApp> { | |
public final String[] args; | |
public final Lwjgl3TestClientApp app; | |
public final Lwjgl3Application backendApp; | |
public final JvmStartedBy jvmStartedBy; | |
public final JarProperties jarProperties; | |
public Lwjgl3Launcher(String[] args) { | |
this.args = args; | |
this.app = new Lwjgl3TestClientApp(this); | |
this.backendApp = createApplication(); | |
this.jvmStartedBy = JvmStartedBy.discover(app); | |
// this.jarProperties = new JarProperties(app.getClass()); | |
// This is running as IDE TODO FIX THIS PERM | |
jarProperties = new JarProperties("", | |
this.getClass(), | |
new ComplexVersion(0,1,0, State.ALPHA, 0), "","", | |
0); | |
} | |
public static void main(String[] args) { | |
Lwjgl3Launcher desktopLauncher = new Lwjgl3Launcher(args); | |
} | |
private Lwjgl3Application createApplication(){ | |
// We never go past here so the app launcher has to set the app? Hmm | |
return new Lwjgl3Application(app, getDefaultConfiguration()); | |
} | |
private Lwjgl3ApplicationConfiguration getDefaultConfiguration() { | |
Lwjgl3ApplicationConfiguration configuration = new Lwjgl3ApplicationConfiguration(); | |
configuration.setTitle("Virtual Hex - Engine Editor"); | |
configuration.setWindowedMode(1024, 780); | |
configuration.setWindowIcon( | |
"icons/vhex-2-128-bg-black.png", | |
"icons/vhex-2-64-bg-black.png", | |
"icons/vhex-2-32-bg-black.png", | |
"icons/vhex-2-16-bg-black.png"); | |
return configuration; | |
} | |
@Override | |
public String[] getArgs() { | |
return args; | |
} | |
@Override | |
public Lwjgl3TestClientApp getEngineApp() { | |
return app; | |
} | |
@Override | |
public JvmStartedBy getJvmStartedBy() { | |
return jvmStartedBy; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.virtual_hex.gdx.engine.test; | |
import com.badlogic.gdx.Gdx; | |
import com.badlogic.gdx.graphics.GL20; | |
import com.badlogic.gdx.scenes.scene2d.XeStage; | |
import com.badlogic.gdx.scenes.scene2d.ui.Skin; | |
import com.badlogic.gdx.utils.viewport.ScreenViewport; | |
import com.virtual_hex.app.AppLauncher; | |
import com.virtual_hex.gdx.engine.app.GdxEngAppScreenBuilder; | |
import com.virtual_hex.gdx.engine.app.GdxEngScreenManagerApp; | |
import com.virtual_hex.gdx.engine.screens.ClearColor; | |
import com.virtual_hex.gdx.engine.screens.GdxEngAppScreen; | |
import com.virtual_hex.gdx.engine.screens.MixedLayeredGdxEngScreen; | |
import com.virtual_hex.gdx.engine.screens.Pure2DViewportLayer; | |
import com.virtual_hex.gdx.engine.screens.ScreenLayer; | |
import com.virtual_hex.gdx.engine.screens.ScreenMetaData; | |
import com.virtual_hex.gdx.engine.xerox.json.XeUiJson; | |
/** | |
* This platform supports the full editor | |
*/ | |
public class Lwjgl3TestClientApp extends DefaultTestClientApp<Lwjgl3TestClientApp> { | |
public static final String ENGINE_STATE_FILE_STRING = "test-client-state.json"; | |
private static final ScreenMetaData SCREEN_META = new ScreenMetaData( | |
"test-client", | |
"Test Client", | |
GL20.GL_COLOR_BUFFER_BIT, | |
new ClearColor() | |
); | |
private boolean setup; | |
public Lwjgl3TestClientApp(AppLauncher<Lwjgl3TestClientApp> appLauncher) { | |
super(appLauncher, new GdxEngAppScreenBuilder(SCREEN_META, new GdxEngAppScreenBuilder.GdxEngScreenSupplier() { | |
@Override | |
public GdxEngAppScreen getEngineScreen(ScreenMetaData screenMetaData, GdxEngScreenManagerApp screenManagerApp, int screenId, int typeId) { | |
Pure2DViewportLayer pure2DViewportLayer = new Pure2DViewportLayer("test-client-main-screen", new ScreenViewport(), true) { | |
@Override | |
public void drawLayer(float delta) { | |
} | |
@Override | |
public void reload() { | |
Skin skin = new Skin(Gdx.files.internal("uiskin.json")); | |
XeStage testStage = new XeStage(); | |
XeUiJson json = new XeUiJson(skin); | |
String stageString = json.toJson(testStage); | |
String prettyPrintStageString = json.prettyPrint(stageString); | |
System.out.println(prettyPrintStageString); | |
XeStage xeStage = json.fromJson(XeStage.class, prettyPrintStageString); | |
} | |
}; | |
return new MixedLayeredGdxEngScreen(appLauncher, SCREEN_META, new ScreenLayer[]{ | |
pure2DViewportLayer | |
}); | |
} | |
})); | |
} | |
@Override | |
public void loadState() { | |
} | |
@Override | |
public void saveState(){ | |
} | |
@Override | |
public void loadingCompleted() { | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment