use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project bladecoder-adventure-engine by bladecoder.
the class VerbUI method createArrowPanel.
private Table createArrowPanel() {
Table arrows = new Table();
arrows.defaults().pad(MARGIN);
ImageButton.ImageButtonStyle s = new ImageButton.ImageButtonStyle(style.inventoryButtonStyle);
s.imageUp = style.upArrow;
ImageButton up = new ImageButton(s);
arrows.add(up).fillY().expandY();
up.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
if (scroll > 0)
scroll--;
}
});
arrows.row();
ImageButton.ImageButtonStyle s2 = new ImageButton.ImageButtonStyle(style.inventoryButtonStyle);
s2.imageUp = style.downArrow;
ImageButton down = new ImageButton(s2);
arrows.add(down).fillY().expandY();
down.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
Inventory inv = World.getInstance().getInventory();
int itemsLeft = inv.getNumItems() - scroll * INVENTORY_COLS;
if (itemsLeft > inventorySlots.size())
scroll++;
}
});
return arrows;
}
use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project bladecoder-adventure-engine by bladecoder.
the class VerbUI method createVerbPanel.
private Table createVerbPanel() {
Table verbs = new Table();
verbs.defaults().pad(MARGIN);
for (int i = 0; i < VERBS.size(); i++) {
if (i % VERB_COLS == 0)
verbs.row();
TextButton b = new TextButton(VERBS_DESC.get(i), style.verbButtonStyle);
b.setName(VERBS.get(i));
b.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
currentVerb = event.getListenerActor().getName();
infoLine.setText(((TextButton) event.getListenerActor()).getText());
target = null;
}
});
verbs.add(b).fill().expand();
}
return verbs;
}
use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project bladecoder-adventure-engine by bladecoder.
the class RetroSceneScreen method show.
@Override
public void show() {
retrieveAssets(ui.getUIAtlas());
stage = new Stage(screenViewport);
// stage.addActor(textManagerUI);
stage.addActor(dialogUI);
stage.addActor(menuButton);
stage.addActor(verbUI);
stage.addActor(pointer);
menuButton.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
ui.setCurrentScreen(Screens.MENU_SCREEN);
}
});
worldViewportStage = new Stage(worldViewport);
worldViewportStage.addActor(textManagerUI);
final InputMultiplexer multiplexer = new InputMultiplexer();
multiplexer.addProcessor(stage);
multiplexer.addProcessor(inputProcessor);
Gdx.input.setInputProcessor(multiplexer);
if (World.getInstance().isDisposed()) {
try {
World.getInstance().load();
} catch (Exception e) {
EngineLogger.error("ERROR LOADING GAME", e);
dispose();
Gdx.app.exit();
}
}
World.getInstance().resume();
}
use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project bladecoder-adventure-engine by bladecoder.
the class MenuScreen method show.
@Override
public void show() {
stage = new Stage(new ScreenViewport());
final Skin skin = ui.getSkin();
final World world = World.getInstance();
final MenuScreenStyle style = getStyle();
final BitmapFont f = skin.get(style.textButtonStyle, TextButtonStyle.class).font;
float buttonWidth = f.getCapHeight() * 15f;
// Image background = new Image(style.background);
Drawable bg = style.background;
float scale = 1;
if (bg == null && style.bgFile != null) {
bgTexFile = new Texture(EngineAssetManager.getInstance().getResAsset(style.bgFile));
bgTexFile.setFilter(TextureFilter.Linear, TextureFilter.Linear);
scale = (float) bgTexFile.getHeight() / (float) stage.getViewport().getScreenHeight();
int width = (int) (stage.getViewport().getScreenWidth() * scale);
int x0 = (int) ((bgTexFile.getWidth() - width) / 2);
bg = new TextureRegionDrawable(new TextureRegion(bgTexFile, x0, 0, width, bgTexFile.getHeight()));
}
menuButtonTable.clear();
if (bg != null)
menuButtonTable.setBackground(bg);
menuButtonTable.addListener(new InputListener() {
@Override
public boolean keyUp(InputEvent event, int keycode) {
if (keycode == Input.Keys.ESCAPE || keycode == Input.Keys.BACK)
if (world.getCurrentScene() != null)
ui.setCurrentScreen(Screens.SCENE_SCREEN);
return true;
}
});
menuButtonTable.align(getAlign());
menuButtonTable.pad(DPIUtils.getMarginSize() * 2);
menuButtonTable.defaults().pad(DPIUtils.getSpacing()).width(buttonWidth).align(getAlign());
// menuButtonTable.debug();
stage.setKeyboardFocus(menuButtonTable);
if (style.showTitle && style.titleStyle != null) {
Label title = new Label(Config.getProperty(Config.TITLE_PROP, "Adventure Blade Engine"), skin, style.titleStyle);
title.setAlignment(getAlign());
menuButtonTable.add(title).padBottom(DPIUtils.getMarginSize() * 2);
menuButtonTable.row();
}
if (style.titleFile != null) {
titleTexFile = new Texture(EngineAssetManager.getInstance().getResAsset(style.titleFile));
titleTexFile.setFilter(TextureFilter.Linear, TextureFilter.Linear);
Image img = new Image(titleTexFile);
menuButtonTable.add(img).width((float) titleTexFile.getWidth() / scale).height((float) titleTexFile.getHeight() / scale).padBottom(DPIUtils.getMarginSize() * 2);
menuButtonTable.row();
}
if (world.savedGameExists() || world.getCurrentScene() != null) {
TextButton continueGame = new TextButton(I18N.getString("ui.continue"), skin, style.textButtonStyle);
continueGame.getLabel().setAlignment(getAlign());
continueGame.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
if (world.getCurrentScene() == null)
try {
world.load();
} catch (Exception e) {
Gdx.app.exit();
}
ui.setCurrentScreen(Screens.SCENE_SCREEN);
}
});
menuButtonTable.add(continueGame);
menuButtonTable.row();
}
TextButton newGame = new TextButton(I18N.getString("ui.new"), skin, style.textButtonStyle);
newGame.getLabel().setAlignment(getAlign());
newGame.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
if (world.savedGameExists()) {
Dialog d = new Dialog("", skin) {
protected void result(Object object) {
if (((Boolean) object).booleanValue()) {
try {
world.newGame();
ui.setCurrentScreen(Screens.SCENE_SCREEN);
} catch (Exception e) {
EngineLogger.error("IN NEW GAME", e);
Gdx.app.exit();
}
}
}
};
d.pad(DPIUtils.getMarginSize());
d.getButtonTable().padTop(DPIUtils.getMarginSize());
d.getButtonTable().defaults().padLeft(DPIUtils.getMarginSize()).padRight(DPIUtils.getMarginSize());
Label l = new Label(I18N.getString("ui.override"), ui.getSkin(), "ui-dialog");
l.setWrap(true);
l.setAlignment(Align.center);
d.getContentTable().add(l).prefWidth(Gdx.graphics.getWidth() * .7f);
d.button(I18N.getString("ui.yes"), true, ui.getSkin().get("ui-dialog", TextButtonStyle.class));
d.button(I18N.getString("ui.no"), false, ui.getSkin().get("ui-dialog", TextButtonStyle.class));
d.key(Keys.ENTER, true).key(Keys.ESCAPE, false);
d.show(stage);
} else {
try {
world.newGame();
ui.setCurrentScreen(Screens.SCENE_SCREEN);
} catch (Exception e) {
EngineLogger.error("IN NEW GAME", e);
Gdx.app.exit();
}
}
}
});
menuButtonTable.add(newGame);
menuButtonTable.row();
TextButton loadGame = new TextButton(I18N.getString("ui.load"), skin, style.textButtonStyle);
loadGame.getLabel().setAlignment(getAlign());
loadGame.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
ui.setCurrentScreen(Screens.LOAD_GAME_SCREEN);
}
});
menuButtonTable.add(loadGame);
menuButtonTable.row();
TextButton quit = new TextButton(I18N.getString("ui.quit"), skin, style.textButtonStyle);
quit.getLabel().setAlignment(getAlign());
quit.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
Gdx.app.exit();
}
});
menuButtonTable.add(quit);
menuButtonTable.row();
menuButtonTable.pack();
stage.addActor(menuButtonTable);
// BOTTOM-RIGHT BUTTON STACK
credits = new Button(skin, "credits");
credits.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
ui.setCurrentScreen(Screens.CREDIT_SCREEN);
}
});
help = new Button(skin, "help");
help.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
ui.setCurrentScreen(Screens.HELP_SCREEN);
}
});
debug = new Button(skin, "debug");
debug.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
DebugScreen debugScr = new DebugScreen();
debugScr.setUI(ui);
ui.setCurrentScreen(debugScr);
}
});
iconStackTable.clear();
iconStackTable.defaults().pad(DPIUtils.getSpacing()).size(DPIUtils.getPrefButtonSize(), DPIUtils.getPrefButtonSize());
iconStackTable.pad(DPIUtils.getMarginSize() * 2);
if (EngineLogger.debugMode() && world.getCurrentScene() != null) {
iconStackTable.add(debug);
iconStackTable.row();
}
iconStackTable.add(help);
iconStackTable.row();
iconStackTable.add(credits);
iconStackTable.bottom().right();
iconStackTable.setFillParent(true);
iconStackTable.pack();
stage.addActor(iconStackTable);
Label version = new Label("v" + Config.getProperty(Config.VERSION_PROP, " unspecified"), skin);
version.setPosition(DPIUtils.getMarginSize(), DPIUtils.getMarginSize());
version.addListener(new ClickListener() {
int count = 0;
long time = System.currentTimeMillis();
public void clicked(InputEvent event, float x, float y) {
if (System.currentTimeMillis() - time < 500) {
count++;
} else {
count = 0;
}
time = System.currentTimeMillis();
if (count == 4) {
EngineLogger.toggle();
if (World.getInstance().isDisposed())
return;
if (EngineLogger.debugMode()) {
iconStackTable.row();
iconStackTable.add(debug);
} else {
Cell<?> cell = iconStackTable.getCell(debug);
iconStackTable.removeActor(debug);
cell.reset();
}
}
}
});
stage.addActor(version);
debug.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
DebugScreen debugScr = new DebugScreen();
debugScr.setUI(ui);
ui.setCurrentScreen(debugScr);
}
});
pointer = new Pointer(skin);
stage.addActor(pointer);
Gdx.input.setInputProcessor(stage);
if (style.musicFile != null) {
music = Gdx.audio.newMusic(EngineAssetManager.getInstance().getAsset(style.musicFile));
music.setLooping(true);
music.play();
}
}
use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project bladecoder-adventure-engine by bladecoder.
the class ScopePanel method addButton.
private void addButton(String name) {
TextButton button = new TextButton(name, skin);
buttonGroup.add(button);
hPanel.addActor(button);
button.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
changeScope((TextButton) event.getListenerActor());
}
});
}
Aggregations