use of com.badlogic.gdx.scenes.scene2d.ui.Table 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.ui.Table in project Eidolons by IDemiurge.
the class ScrollPanel method init.
private void init() {
this.setTouchable(Touchable.enabled);
left().bottom();
setClip(true);
table = new Table();
table.setFillParent(true);
table.align(Align.left);
table.setLayoutEnabled(true);
table.pack();
innerScrollContainer = new InnerScrollContainer<>();
innerScrollContainer.left().bottom();
innerScrollContainer.setActor(table);
innerScrollContainer.setX(0);
innerScrollContainer.setY(0);
super.setActor(innerScrollContainer);
addCaptureListener(new InputListener() {
private float yy;
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
event.stop();
yy = y;
instantOffsetY = 0;
offsetY = 0;
return true;
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
offsetY += instantOffsetY * 6;
instantOffsetY = 0;
}
@Override
public void touchDragged(InputEvent event, float x, float y, int pointer) {
instantOffsetY += y - yy;
}
public boolean scrolled(InputEvent event, float x, float y, int amount) {
offsetY += amount * 3500;
return true;
}
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
getStage().setScrollFocus(ScrollPanel.this);
}
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
getStage().setScrollFocus(null);
}
});
}
use of com.badlogic.gdx.scenes.scene2d.ui.Table in project Eidolons by IDemiurge.
the class MultiValueContainer method init.
protected void init(TextureRegion texture, String name, String[] values) {
super.init(texture, name, null);
if (values != null) {
Table table = new Table();
// super.init() initialize value field as empty Container
this.valueContainer.setActor(table);
for (String value : values) {
Container<Label> labelContainer = new Container<>(new Label(value, getDefaultLabelStyle()));
this.values.add(labelContainer);
table.add(labelContainer);
if (isVertical()) {
table.row();
}
}
}
}
use of com.badlogic.gdx.scenes.scene2d.ui.Table in project skin-composer by raeleus.
the class DialogColors method populate.
private void populate(Main main, boolean selectingForTintedDrawable, DialogColorsListener listener) {
this.main = main;
this.listener = listener;
this.selectingForTintedDrawable = selectingForTintedDrawable;
colors = main.getJsonData().getColors();
getContentTable().defaults().expandX();
if (styleProperty != null || customProperty != null) {
Label label = new Label("Select a color...", getSkin(), "title");
label.setAlignment(Align.center);
getContentTable().add(label);
getContentTable().row();
} else if (selectingForTintedDrawable) {
Label label = new Label("Select a color for tinted drawable...", getSkin(), "title");
label.setAlignment(Align.center);
getContentTable().add(label);
getContentTable().row();
} else {
Label label = new Label("Colors", getSkin(), "title");
label.setAlignment(Align.center);
getContentTable().add(label);
getContentTable().row();
}
Table table = new Table();
table.defaults().pad(2.0f);
table.add(new Label("Sort by: ", getSkin())).padLeft(20.0f);
selectBox = new SelectBox<String>(getSkin());
selectBox.setItems(new String[] { "A-Z", "Z-A" });
selectBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
sortBySelectedMode();
}
});
selectBox.addListener(main.getHandListener());
selectBox.getList().addListener(main.getHandListener());
table.add(selectBox);
TextButton imageButton = new TextButton("New Color", getSkin(), "new");
imageButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
showColorPicker();
}
});
imageButton.addListener(main.getHandListener());
table.add(imageButton).expandX().left();
getContentTable().add(table).left().expandX();
getContentTable().row();
colorTable = new Table();
refreshTable();
table = new Table();
table.add(colorTable).pad(5.0f);
scrollPane = new ScrollPane(table, getSkin());
scrollPane.setFadeScrollBars(false);
getContentTable().add(scrollPane).grow();
if (styleProperty != null || customProperty != null) {
button("Clear Color", true);
button("Cancel", false);
getButtonTable().getCells().get(0).getActor().addListener(main.getHandListener());
getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
} else if (selectingForTintedDrawable) {
button("Cancel", false);
getButtonTable().getCells().get(0).getActor().addListener(main.getHandListener());
} else {
button("Close", false);
getButtonTable().getCells().get(0).getActor().addListener(main.getHandListener());
}
getButtonTable().padBottom(15.0f);
key(Keys.ESCAPE, false);
}
use of com.badlogic.gdx.scenes.scene2d.ui.Table in project skin-composer by raeleus.
the class DialogDrawables method tiledDrawableSettingsDialog.
private void tiledDrawableSettingsDialog(DrawableData drawable) {
DialogColors dialog = new DialogColors(main, (StyleProperty) null, true, (ColorData colorData) -> {
if (colorData != null) {
final Spinner minWidthSpinner = new Spinner(0.0f, 1.0f, true, Spinner.Orientation.HORIZONTAL, getSkin());
final Spinner minHeightSpinner = new Spinner(0.0f, 1.0f, true, Spinner.Orientation.HORIZONTAL, getSkin());
TextField textField = new TextField("", getSkin()) {
@Override
public void next(boolean up) {
if (up) {
getStage().setKeyboardFocus(minHeightSpinner.getTextField());
minHeightSpinner.getTextField().selectAll();
} else {
getStage().setKeyboardFocus(minWidthSpinner.getTextField());
minWidthSpinner.getTextField().selectAll();
}
}
};
Dialog tileDialog = new Dialog("Tiled Drawable Settings", getSkin(), "bg") {
@Override
protected void result(Object object) {
super.result(object);
if (object instanceof Boolean && (boolean) object == true) {
tiledDrawableSettings(drawable, colorData, (float) minWidthSpinner.getValue(), (float) minHeightSpinner.getValue(), textField.getText());
}
getStage().setScrollFocus(scrollPane);
}
@Override
public Dialog show(Stage stage) {
Dialog dialog = super.show(stage);
stage.setKeyboardFocus(textField);
return dialog;
}
};
tileDialog.getTitleTable().padLeft(5.0f);
tileDialog.getContentTable().padLeft(10.0f).padRight(10.0f).padTop(5.0f);
tileDialog.getButtonTable().padBottom(15.0f);
tileDialog.getContentTable().add(new Label("Please enter a name for the TiledDrawable: ", getSkin()));
tileDialog.button("OK", true);
tileDialog.button("Cancel", false).key(Keys.ESCAPE, false);
TextButton okButton = (TextButton) tileDialog.getButtonTable().getCells().first().getActor();
okButton.addListener(main.getHandListener());
tileDialog.getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener());
tileDialog.getContentTable().row();
textField.setText(drawable.name);
textField.selectAll();
tileDialog.getContentTable().add(textField);
tileDialog.getContentTable().row();
Table table = new Table();
table.defaults().space(10.0f);
tileDialog.getContentTable().add(table);
Label label = new Label("MinWidth:", getSkin());
table.add(label);
minWidthSpinner.setValue(drawable.minWidth);
minWidthSpinner.setMinimum(0.0f);
table.add(minWidthSpinner).minWidth(150.0f);
minWidthSpinner.setTransversalPrevious(textField);
minWidthSpinner.setTransversalNext(minHeightSpinner.getTextField());
table.row();
label = new Label("MinHeight:", getSkin());
table.add(label);
minHeightSpinner.setValue(drawable.minHeight);
minHeightSpinner.setMinimum(0.0f);
table.add(minHeightSpinner).minWidth(150.0f);
minHeightSpinner.setTransversalPrevious(minWidthSpinner.getTextField());
minHeightSpinner.setTransversalNext(textField);
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeListener.ChangeEvent event, Actor actor) {
boolean disable = !DrawableData.validate(textField.getText());
if (!disable) {
if (!drawable.name.equals(textField.getText())) {
for (DrawableData data : main.getAtlasData().getDrawables()) {
if (data.name.equals(textField.getText())) {
disable = true;
break;
}
}
}
}
okButton.setDisabled(disable);
}
});
textField.setTextFieldListener(new TextField.TextFieldListener() {
@Override
public void keyTyped(TextField textField, char c) {
if (c == '\n') {
if (!okButton.isDisabled()) {
tiledDrawableSettings(drawable, colorData, (float) minWidthSpinner.getValue(), (float) minHeightSpinner.getValue(), textField.getText());
tileDialog.hide();
}
}
}
});
textField.addListener(main.getIbeamListener());
tileDialog.show(getStage());
}
});
dialog.setFillParent(true);
dialog.show(getStage());
dialog.refreshTable();
}
Aggregations