Skip to content

Instantly share code, notes, and snippets.

@Mr00Anderson
Created August 15, 2020 21:17
Show Gist options
  • Select an option

  • Save Mr00Anderson/933d1d752dbb318f64fa951d8fe9f9f2 to your computer and use it in GitHub Desktop.

Select an option

Save Mr00Anderson/933d1d752dbb318f64fa951d8fe9f9f2 to your computer and use it in GitHub Desktop.
simple-application
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;
}
}
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;
}
}
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