use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project bladecoder-adventure-engine by bladecoder.
the class TabPanel method addTab.
public void addTab(String name, Actor panel) {
Button button = new TextButton(name, skin);
buttonGroup.add(button);
header.addActor(button);
tabs.add(new Tab(button, panel));
button.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
setTab((Button) event.getListenerActor());
}
});
if (tabs.size() == 1)
setTab(0);
}
use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project bladecoder-adventure-engine by bladecoder.
the class DebugScreen method show.
@Override
public void show() {
float size = DPIUtils.getPrefButtonSize();
float margin = DPIUtils.getMarginSize();
stage = new Stage(new ScreenViewport());
table = new Table(ui.getSkin());
table.setFillParent(true);
table.left().top();
table.pad(margin);
table.addListener(new InputListener() {
@Override
public boolean keyUp(InputEvent event, int keycode) {
if (keycode == Input.Keys.ESCAPE || keycode == Input.Keys.BACK)
ui.setCurrentScreen(Screens.SCENE_SCREEN);
return true;
}
});
stage.setKeyboardFocus(table);
Button back = new Button(ui.getSkin(), "back");
back.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
ui.setCurrentScreen(Screens.SCENE_SCREEN);
}
});
Label title = new Label("DEBUG SCREEN", ui.getSkin(), "title");
Table header = new Table();
header.padBottom(margin);
Container<Button> cont = new Container<Button>(back);
cont.size(size);
header.add(cont);
header.add(title).fillX().expandX().left();
table.add(header).colspan(3).fillX().expandX().left();
// ------------- SPEED
speedText = new TextField(Float.toString(((SceneScreen) ui.getScreen(Screens.SCENE_SCREEN)).getSpeed()), ui.getSkin());
TextButton speedButton = new TextButton("Set Speed", ui.getSkin());
speedButton.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
SceneScreen scnScr = (SceneScreen) ui.getScreen(Screens.SCENE_SCREEN);
scnScr.setSpeed(Float.parseFloat(speedText.getText()));
}
});
speedButton.pad(2, 3, 2, 3);
HorizontalGroup sGroup = new HorizontalGroup();
sGroup.space(10);
sGroup.addActor(speedText);
sGroup.addActor(speedButton);
table.row().pad(5).align(Align.left);
table.add(new Label("Game Speed: ", ui.getSkin(), "debug"));
table.add(sGroup);
// ------------- RECORDING
final Recorder r = ui.getRecorder();
TextButton play = new TextButton(r.isPlaying() ? "Stop" : "Play", ui.getSkin());
rec = new TextButton(r.isRecording() ? "Stop Rec" : "Rec", ui.getSkin());
play.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
final Recorder r = ui.getRecorder();
if (!r.isPlaying()) {
r.setFilename(recordings.getSelected());
r.load();
r.setPlaying(true);
ui.setCurrentScreen(Screens.SCENE_SCREEN);
} else {
r.setPlaying(false);
ui.setCurrentScreen(Screens.SCENE_SCREEN);
}
}
});
rec.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
final Recorder r = ui.getRecorder();
if (r.isPlaying()) {
r.setPlaying(false);
}
if (!r.isRecording())
r.setFilename(recFilename.getText());
r.setRecording(!r.isRecording());
rec.setText(r.isRecording() ? "Stop Rec" : "Rec");
if (r.isRecording())
ui.setCurrentScreen(Screens.SCENE_SCREEN);
}
});
recordings = new SelectBox<String>(ui.getSkin());
String[] testFiles = EngineAssetManager.getInstance().listAssetFiles("tests");
ArrayList<String> al = new ArrayList<String>();
for (String file : testFiles) if (file.endsWith(Recorder.RECORD_EXT))
al.add(file.substring(0, file.indexOf(Recorder.RECORD_EXT)));
FileHandle[] testFiles2 = EngineAssetManager.getInstance().getUserFolder().list();
for (FileHandle file : testFiles2) if (file.name().endsWith(Recorder.RECORD_EXT))
al.add(file.name().substring(0, file.name().indexOf(Recorder.RECORD_EXT)));
recordings.setItems(al.toArray(new String[al.size()]));
play.pad(2, 3, 2, 3);
rec.pad(2, 3, 2, 3);
recFilename = new TextField(r.getFileName(), ui.getSkin());
HorizontalGroup rGroup = new HorizontalGroup();
rGroup.space(10);
rGroup.addActor(recordings);
rGroup.addActor(play);
rGroup.addActor(new Label("Rec. Filename", ui.getSkin(), "debug"));
rGroup.addActor(recFilename);
rGroup.addActor(rec);
table.row().pad(5).align(Align.left);
table.add(new Label("Game Recording: ", ui.getSkin(), "debug"));
table.add(rGroup);
// ------------- LOAD CHAPTER
table.row().pad(5).align(Align.left);
table.add(new Label("Load Chapter: ", ui.getSkin(), "debug"));
HorizontalGroup chGroup = new HorizontalGroup();
chGroup.space(10);
final TextField chapter = new TextField("", ui.getSkin());
chGroup.addActor(chapter);
TextButton loadButton = new TextButton("Load", ui.getSkin());
loadButton.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
String c = chapter.getText();
if (!c.isEmpty()) {
try {
World.getInstance().loadChapter(c);
ui.setCurrentScreen(Screens.SCENE_SCREEN);
} catch (IOException e) {
EngineLogger.error("Loading chapter.", e);
}
}
}
});
chGroup.addActor(loadButton);
table.add(chGroup);
// ------------- SCENES
final TextButton testScene = new TextButton("Run Test Verb", ui.getSkin(), "toggle");
TextButton go = new TextButton("Go", ui.getSkin());
go.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
World.getInstance().resume();
World.getInstance().setCutMode(false);
if (testScene.isChecked())
World.getInstance().setTestScene(scenes.getSelected());
World.getInstance().setCurrentScene(scenes.getSelected());
ui.setCurrentScreen(Screens.SCENE_SCREEN);
}
});
go.pad(2, 3, 2, 3);
scenes = new SelectBox<String>(ui.getSkin());
scenes.setItems(World.getInstance().getScenes().keySet().toArray(new String[World.getInstance().getScenes().size()]));
HorizontalGroup scGroup = new HorizontalGroup();
scGroup.space(10);
scGroup.addActor(scenes);
scGroup.addActor(go);
scGroup.addActor(testScene);
table.row().pad(5).align(Align.left);
table.add(new Label("Go to Scene: ", ui.getSkin(), "debug"));
table.add(scGroup);
// ------------- TESTERBOT
final TesterBot bot = ui.getTesterBot();
TextButton runBot = new TextButton(bot.isEnabled() ? "Stop" : "Run", ui.getSkin());
runBot.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
final TesterBot bot = ui.getTesterBot();
bot.setMaxWaitInverval(Float.parseFloat(testerTimeConf.getText()));
bot.setInSceneTime(Float.parseFloat(inSceneTimeConf.getText()));
bot.setExcludeList(testerExcludeList.getText());
bot.setEnabled(!bot.isEnabled());
ui.setCurrentScreen(Screens.SCENE_SCREEN);
}
});
runBot.pad(2, 3, 2, 3);
testerTimeConf = new TextField(Float.toString(bot.getMaxWaitInverval()), ui.getSkin());
inSceneTimeConf = new TextField(Float.toString(bot.getInSceneTime()), ui.getSkin());
testerExcludeList = new TextField(bot.getExcludeList(), ui.getSkin());
TextButton testerLeaveConf = new TextButton("Leave", ui.getSkin(), "toggle");
testerLeaveConf.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
final TesterBot bot = ui.getTesterBot();
bot.setRunLeaveVerbs(!bot.isRunLeaveVerbs());
}
});
testerLeaveConf.setChecked(bot.isRunLeaveVerbs());
TextButton testerGotoConf = new TextButton("Goto", ui.getSkin(), "toggle");
testerGotoConf.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
final TesterBot bot = ui.getTesterBot();
bot.setRunGoto(!bot.isRunGoto());
}
});
testerGotoConf.setChecked(bot.isRunGoto());
TextButton testerPassText = new TextButton("Pass Texts", ui.getSkin(), "toggle");
testerPassText.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
final TesterBot bot = ui.getTesterBot();
bot.setPassTexts(!bot.isPassTexts());
}
});
testerPassText.setChecked(bot.isPassTexts());
TextButton testerWaitWhenWalking = new TextButton("Wait When Walking", ui.getSkin(), "toggle");
testerWaitWhenWalking.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
final TesterBot bot = ui.getTesterBot();
bot.setWaitWhenWalking(!bot.isWaitWhenWalking());
}
});
testerWaitWhenWalking.setChecked(bot.isWaitWhenWalking());
HorizontalGroup botGroup = new HorizontalGroup();
botGroup.space(10);
botGroup.addActor(testerLeaveConf);
botGroup.addActor(testerGotoConf);
botGroup.addActor(testerPassText);
botGroup.addActor(testerWaitWhenWalking);
HorizontalGroup botGroup2 = new HorizontalGroup();
botGroup2.space(10);
botGroup2.addActor(new Label("Excl. List: ", ui.getSkin(), "debug"));
botGroup2.addActor(testerExcludeList);
botGroup2.addActor(new Label("Interval: ", ui.getSkin(), "debug"));
botGroup2.addActor(testerTimeConf);
botGroup2.addActor(new Label("Scn Time: ", ui.getSkin(), "debug"));
botGroup2.addActor(inSceneTimeConf);
botGroup2.addActor(runBot);
table.row().pad(5).align(Align.left);
table.add(new Label("Tester Bot: ", ui.getSkin(), "debug"));
table.add(botGroup);
table.row().pad(5).align(Align.left);
table.add();
table.add(botGroup2);
// ------------- VERSION LABEL NOT IN TABLE
String versionString = Config.getProperty(Config.TITLE_PROP, "title unspecified") + " v" + Config.getProperty(Config.VERSION_PROP, "unspecified") + "\n" + "Blade Engine: v" + Config.getProperty(Config.BLADE_ENGINE_VERSION_PROP, "unspecified") + "\n" + "libGdx: v" + Config.getProperty("gdxVersion", "unspecified") + "\n" + "RoboVM: v" + Config.getProperty("roboVMVersion", "unspecified") + "\n";
// + "Gdx.app.getVersion: " + Gdx.app.getVersion();
Label version = new Label(versionString, ui.getSkin(), "debug");
version.setColor(Color.LIGHT_GRAY);
Table versionStack = new Table();
versionStack.defaults().pad(DPIUtils.getSpacing());
versionStack.pad(0);
versionStack.add(version);
versionStack.bottom().left();
versionStack.setFillParent(true);
versionStack.pack();
table.row();
table.add(versionStack).colspan(3).left();
table.pack();
ScrollPane scrollPane = new ScrollPane(table);
scrollPane.setFillParent(true);
stage.addActor(scrollPane);
pointer = new Pointer(ui.getSkin());
stage.addActor(pointer);
Gdx.input.setInputProcessor(stage);
}
use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project Eidolons by IDemiurge.
the class PlaceTooltip method updateAct.
@Override
public void updateAct(float delta) {
clearChildren();
TextureRegion r = TextureCache.getOrCreateR(place.getImagePath());
ValueContainer container = new ValueContainer(r, place.getName());
float size = GdxMaster.adjustSize(128);
if (size < r.getRegionHeight() && size < r.getRegionWidth())
container.overrideImageSize(size, size);
add(container);
setBackground(new NinePatchDrawable(NinePatchFactory.getTooltip()));
// return ;
if (place.getRoutes().isEmpty()) {
return;
}
row();
TablePanel<ValueContainer> routesInfo = new TablePanel<>();
routesInfo.defaults().space(5);
add(routesInfo);
routesInfo.addListener(new ClickListener() {
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
if (toActor == routesInfo)
return;
if (toActor == null) {
if (getWidth() >= x)
return;
if (getWidth() >= y)
return;
}
if (GdxMaster.getAncestors(toActor).contains(routesInfo))
return;
if (!checkActorExitRemoves(toActor))
return;
super.exit(event, x, y, pointer, toActor);
GuiEventManager.trigger(MapEvent.ROUTES_PANEL_HOVER_OFF);
}
});
int i = 0;
for (Route sub : place.getRoutes()) {
// reverse pic pos
TextureRegion tex = TextureCache.getOrCreateR(sub.getImagePath());
ValueContainer routeInfo = new ValueContainer(tex, sub.getName(), sub.getLength() + " leagues");
routeInfo.setBackground(new NinePatchDrawable(NinePatchFactory.getTooltip()));
routesInfo.add(routeInfo).left().padLeft(5).uniform(true, false);
routeInfo.setUserObject(sub);
routeInfo.addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
// getTapCount()
GuiEventManager.trigger(MapEvent.ROUTE_HOVERED, sub);
return super.touchDown(event, x, y, pointer, button);
}
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
super.exit(event, x, y, pointer, toActor);
GuiEventManager.trigger(MapEvent.ROUTE_HOVERED, null);
}
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
super.enter(event, x, y, pointer, fromActor);
GuiEventManager.trigger(MapEvent.ROUTE_HOVERED, sub);
}
});
if (i % 2 == 1)
routesInfo.row();
i++;
}
}
use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project Eidolons by IDemiurge.
the class EditorParticleMaster method clicked.
public void clicked(int x, int y) {
String path = EditorMapView.getInstance().getGuiStage().getEmitterPalette().getSelectedEmitterPath();
EmitterActor last = particles.create(path, x, y);
last.start();
stack.push(last);
final DAY_TIME time = this.time;
last.addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if (button == 1) {
removeEmitter(last, time);
}
return super.touchDown(event, x, y, pointer, button);
}
});
MapMaster.addToListMap(map, time, last);
// layer
// centering? emitters probably self-center...
last.setPosition(x, y);
layers.get(time).addActor(last);
GuiEventManager.trigger(MapEvent.EMITTER_CREATED, last);
}
use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project Eidolons by IDemiurge.
the class EmitterPalette method init.
public void init() {
clear();
setSize(GdxMaster.getWidth() - 300, 256);
// int columns = (int) (getWidth() / 64);
defaults().padLeft(200).top().right().width(GdxMaster.getWidth() - 300);
Map<String, List<File>> presets = new LinkedHashMap<>();
List<File> subfolders = FileManager.getFilesFromDirectory(PathFinder.getSfxPath(), true);
subfolders.forEach(file -> {
if (!file.isDirectory()) {
MapMaster.addToListMap(presets, "main", file);
} else
presets.put(file.getName(), FileManager.getFilesFromDirectory(file.getPath(), false));
});
LabelStyle style = StyleHolder.getSizedLabelStyle(FONT.MAIN, 15);
for (String sub : presets.keySet()) {
HorizontalFlowGroup table = new HorizontalFlowGroup(0);
table.setWidth(getWidth() - 100);
boolean bg = presets.get(sub).size() < 55;
for (File preset : presets.get(sub)) {
// textButton?
ValueContainer label = new ValueContainer(new Label(preset.getName(), style));
NinePatch patch = NinePatchFactory.getTooltip();
patch.scale(0.7f, 0.7f);
if (bg)
label.setBackground(new NinePatchDrawable(patch));
label.addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if (Gdx.input.isKeyPressed(Keys.SHIFT_LEFT)) {
// EmitterMaster.
}
EditorManager.setMode(MAP_EDITOR_MOUSE_MODE.EMITTER);
if (selectedLabel != null)
selectedLabel.setColor(1, 1, 1, 1);
if (sub.equals("main"))
selected = preset.getName();
else
selected = StrPathBuilder.build(sub, preset.getName());
selectedLabel = label;
label.setColor(1, 0.3f, 0.8f, 1);
return super.touchDown(event, x, y, pointer, button);
}
});
table.addActor(label);
}
addTab(table, sub);
}
}
Aggregations