Java tutorial
/****************************************************************************** * Copyright (C) 2014 Yevgeny Krasik * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * ******************************************************************************/ package com.github.ykrasik.jaci.cli.libgdx; import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.backends.lwjgl.LwjglApplication; import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.scenes.scene2d.Stage; /** * @author Yevgeny Krasik */ public class LibGdxCliExample extends ApplicationAdapter { private Stage stage; public static void main(String[] args) { final LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.title = "Jerminal"; config.setFromDisplayMode(LwjglApplicationConfiguration.getDesktopDisplayMode()); config.fullscreen = false; config.height -= 150; config.width -= 100; config.resizable = true; config.x = 50; config.y = 50; new LwjglApplication(new LibGdxCliExample(), config); } @Override public void create() { final LibGdxCli cli = new LibGdxCli.Builder() .processClasses(BasicCommands.class, PathCommands1.class, PathCommands2.class, MandatoryParamsCommands.class) .process(new OptionalParamsCommands(), new StringParamCommands(), new ToggleCommands()) // Just to show that this is also possible. .build(); stage = new Stage(); stage.addActor(cli); // Add an InputListener that will toggle the CLI's visibility on and off // on the default Ctrl+` key-combination. stage.addListener(new LibGdxVisibilityToggler(cli)); Gdx.input.setInputProcessor(stage); } @Override public void resize(int width, int height) { stage.getViewport().update(width, height); } @Override public void render() { Gdx.gl.glClearColor(0f, 0f, 0f, 1f); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); stage.act(); stage.draw(); } }