use of com.badlogic.gdx.InputMultiplexer in project libgdx-inGameConsole by StrongJoshua.
the class GUIConsole method resetInputProcessing.
/* (non-Javadoc)
* @see com.strongjoshua.console.Console#resetInputProcessing()
*/
@Override
public void resetInputProcessing() {
usesMultiplexer = true;
appInput = Gdx.input.getInputProcessor();
if (appInput != null) {
if (hasStage(appInput)) {
log("Console already added to input processor!", LogLevel.ERROR);
Gdx.app.log("Console", "Already added to input processor!");
return;
}
multiplexer = new InputMultiplexer();
multiplexer.addProcessor(stage);
multiplexer.addProcessor(appInput);
Gdx.input.setInputProcessor(multiplexer);
} else {
Gdx.input.setInputProcessor(stage);
}
}
use of com.badlogic.gdx.InputMultiplexer in project libgdx-inGameConsole by StrongJoshua.
the class GUIConsole method hasStage.
/** Compares the given processor to the console's stage. If given a multiplexer, it is iterated through recursively to check all
* of the multiplexer's processors for comparison.
* @param processor
* @return processor == this.stage */
private boolean hasStage(InputProcessor processor) {
if (!(processor instanceof InputMultiplexer)) {
return processor == stage;
}
InputMultiplexer im = (InputMultiplexer) processor;
Array<InputProcessor> ips = im.getProcessors();
for (InputProcessor ip : ips) {
if (hasStage(ip)) {
return true;
}
}
return false;
}
use of com.badlogic.gdx.InputMultiplexer in project libgdx by libgdx.
the class BulletTestCollection method create.
@Override
public void create() {
if (app == null) {
app = Gdx.app;
tests[testIndex].create();
}
cameraController = new CameraInputController(tests[testIndex].camera);
cameraController.activateKey = Keys.CONTROL_LEFT;
cameraController.autoUpdate = false;
cameraController.forwardTarget = false;
cameraController.translateTarget = false;
Gdx.input.setInputProcessor(new InputMultiplexer(cameraController, this, new GestureDetector(this)));
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
hud = new Stage();
hud.addActor(fpsLabel = new Label(" ", new Label.LabelStyle(font, Color.WHITE)));
fpsLabel.setPosition(0, 0);
hud.addActor(titleLabel = new Label(tests[testIndex].getClass().getSimpleName(), new Label.LabelStyle(font, Color.WHITE)));
titleLabel.setY(hud.getHeight() - titleLabel.getHeight());
hud.addActor(instructLabel = new Label("A\nB\nC\nD\nE\nF", new Label.LabelStyle(font, Color.WHITE)));
instructLabel.setY(titleLabel.getY() - instructLabel.getHeight());
instructLabel.setAlignment(Align.top | Align.left);
instructLabel.setText(tests[testIndex].instructions);
}
use of com.badlogic.gdx.InputMultiplexer in project libgdx by libgdx.
the class ViewportTest1 method create.
public void create() {
stage = new Stage();
Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
label = new Label("", skin);
Table root = new Table(skin);
root.setFillParent(true);
root.setBackground(skin.getDrawable("default-pane"));
root.debug().defaults().space(6);
root.add(new TextButton("Button 1", skin));
root.add(new TextButton("Button 2", skin)).row();
root.add("Press spacebar to change the viewport:").colspan(2).row();
root.add(label).colspan(2);
stage.addActor(root);
viewports = getViewports(stage.getCamera());
names = getViewportNames();
stage.setViewport(viewports.first());
label.setText(names.first());
Gdx.input.setInputProcessor(new InputMultiplexer(new InputAdapter() {
public boolean keyDown(int keycode) {
if (keycode == Input.Keys.SPACE) {
int index = (viewports.indexOf(stage.getViewport(), true) + 1) % viewports.size;
label.setText(names.get(index));
Viewport viewport = viewports.get(index);
stage.setViewport(viewport);
resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
return false;
}
}, stage));
}
use of com.badlogic.gdx.InputMultiplexer in project libgdx by libgdx.
the class TextureRegion3DTest method create.
@Override
public void create() {
Gdx.gl.glClearColor(0.2f, 0.3f, 1.0f, 0.f);
atlas = new TextureAtlas(Gdx.files.internal("data/testpack"));
regions = atlas.getRegions();
modelBatch = new ModelBatch(new DefaultShaderProvider());
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .4f, .4f, .4f, 1f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(10f, 10f, 10f);
cam.lookAt(0, 0, 0);
cam.near = 0.1f;
cam.far = 300f;
cam.update();
ModelBuilder modelBuilder = new ModelBuilder();
final Material material = new Material(ColorAttribute.createDiffuse(1f, 1f, 1f, 1f), new TextureAttribute(TextureAttribute.Diffuse));
model = modelBuilder.createBox(5f, 5f, 5f, material, Usage.Position | Usage.Normal | Usage.TextureCoordinates);
instance = new ModelInstance(model);
attribute = instance.materials.get(0).get(TextureAttribute.class, TextureAttribute.Diffuse);
Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
}
Aggregations