use of com.badlogic.gdx.scenes.scene2d.Stage in project ultimate-java by pantinor.
the class SpriteAtlasTool method create.
@Override
public void create() {
Pixmap pixmap = new Pixmap(dim, dim, Format.RGBA8888);
pixmap.setColor(new Color(1, 1, 0, .8f));
int w = 1;
pixmap.fillRectangle(0, 0, w, dim);
pixmap.fillRectangle(dim - w, 0, w, dim);
pixmap.fillRectangle(w, 0, dim - 2 * w, w);
pixmap.fillRectangle(w, dim - w, dim - 2 * w, w);
box = new Texture(pixmap);
Texture tx = new Texture(Gdx.files.absolute("D:\\work\\gdx-andius\\src\\main\\resources\\assets\\data\\uf_heroes.png"));
canvasGridWidth = tx.getWidth() / dim;
canvasGridHeight = tx.getHeight() / dim;
sprBg = new Sprite(tx, 0, 0, tx.getWidth(), tx.getHeight());
gridItems = new ArrayList<>();
font = new BitmapFont();
font.setColor(Color.WHITE);
batch = new SpriteBatch();
skin = new Skin(Gdx.files.internal("assets/skin/uiskin.json"));
stage = new Stage();
readAtlas();
final List<MyListItem> list = new List<>(skin);
try {
MyListItem[] tileNames = new MyListItem[Tile.values().length];
int x = 0;
for (Tile t : Tile.values()) {
tileNames[x] = new MyListItem(t.toString(), 0, 0);
x++;
}
list.setItems(tileNames);
} catch (Exception ex) {
}
list.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
selectedTileName = list.getSelected();
}
});
ScrollPane scrollPane = new ScrollPane(list, skin);
scrollPane.setScrollingDisabled(true, false);
TextButton makeButton = new TextButton("Make Atlas", skin, "default");
makeButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
makeAtlas();
}
});
Table table = new Table(skin);
table.defaults().pad(2);
table.add(makeButton).expandX().left().width(175);
table.row();
table.add(scrollPane).expandX().left().width(175).maxHeight(screenHeight);
table.setPosition(screenWidth - 175, 0);
table.setFillParent(true);
stage.addActor(table);
Gdx.input.setInputProcessor(new InputMultiplexer(stage, this));
}
use of com.badlogic.gdx.scenes.scene2d.Stage in project ultimate-java by pantinor.
the class ConversationDialog method hide.
public void hide(Action action) {
Stage stage = getStage();
if (stage != null) {
removeListener(focusListener);
if (previousKeyboardFocus != null && previousKeyboardFocus.getStage() == null) {
previousKeyboardFocus = null;
}
Actor actor = stage.getKeyboardFocus();
if (actor == null || actor.isDescendantOf(this)) {
stage.setKeyboardFocus(previousKeyboardFocus);
}
if (previousScrollFocus != null && previousScrollFocus.getStage() == null) {
previousScrollFocus = null;
}
actor = stage.getScrollFocus();
if (actor == null || actor.isDescendantOf(this)) {
stage.setScrollFocus(previousScrollFocus);
}
}
if (action != null) {
addCaptureListener(ignoreTouchDown);
addAction(sequence(action, Actions.removeListener(ignoreTouchDown, true), Actions.removeActor()));
} else {
remove();
}
Gdx.input.setInputProcessor(new InputMultiplexer(screen, stage));
screen.gameTimer.active = true;
if (screen.context.getCurrentMap().getCity() != null) {
screen.context.getCurrentMap().getCity().resetTalkingFlags();
}
if (vendor != null && vendor instanceof InnService) {
InnService inn = (InnService) vendor;
if (inn.rentedRoom) {
SequenceAction seq = Actions.action(SequenceAction.class);
seq.addAction(Actions.delay(1f));
seq.addAction(Actions.run(new Runnable() {
public void run() {
CombatScreen.holeUp(Maps.get(screen.context.getCurrentMap().getId()), 0, 0, screen, screen.context, Ultima4.creatures, Ultima4.standardAtlas, true);
}
}));
screen.getStage().addAction(seq);
}
}
}
use of com.badlogic.gdx.scenes.scene2d.Stage in project ultimate-java by pantinor.
the class ConversationDialog method initialize.
private void initialize() {
screen.gameTimer.active = false;
setModal(true);
defaults().space(10);
add(internalTable = new Table(Ultima4.skin)).expand().fill();
row();
internalTable.defaults().pad(1);
scrollPane = new LogScrollPane(Ultima4.skin, width);
scrollPane.setHeight(height);
input = new TextField("", Ultima4.skin);
input.setTextFieldListener(new TextFieldListener() {
@Override
public void keyTyped(TextField tf, char key) {
if (key == '\r') {
if (tf.getText().length() == 0) {
if (!cancelHide) {
hide();
}
cancelHide = false;
}
Conversation conversation = person.getConversation();
if (conversation != null) {
if (conversation instanceof CustomInputConversation) {
((CustomInputConversation) conversation).setParty(screen.context.getParty());
}
String query = tf.getText();
Topic t = conversation.matchTopic(query);
if (t != null) {
if (t.getQuery() != null && t.getQuery().equals("join")) {
String name = conversation.getName();
Virtue virtue = screen.context.getParty().getVirtueForJoinable(name);
if (virtue != null) {
CannotJoinError join = screen.context.getParty().join(name);
if (join == CannotJoinError.JOIN_SUCCEEDED) {
scrollPane.add("I am honored to join thee!");
screen.context.getCurrentMap().removeJoinedPartyMemberFromPeopleList(screen.context.getParty());
} else {
scrollPane.add("Thou art not " + (join == CannotJoinError.JOIN_NOT_VIRTUOUS ? virtue.getDescription() : "experienced") + " enough for me to join thee.");
}
} else {
scrollPane.add("I cannot join thee.");
}
} else {
if (!conversation.isStandardQuery(query)) {
screen.context.addEntry(conversation.getName(), conversation.getMap(), t.getPhrase());
}
scrollPane.add(t.getPhrase());
if (t.getQuestion() != null) {
scrollPane.add(t.getQuestion());
}
}
previousTopic = t;
} else {
if (previousTopic != null && previousTopic.getQuestion() != null) {
if (query.toLowerCase().contains("y")) {
screen.context.addEntry(conversation.getName(), conversation.getMap(), previousTopic.getYesResponse());
scrollPane.add(previousTopic.getYesResponse());
if (conversation.getRespAffectsHumility() > 0) {
screen.context.getParty().adjustKarma(KarmaAction.BRAGGED);
}
} else {
screen.context.addEntry(conversation.getName(), conversation.getMap(), previousTopic.getNoResponse());
scrollPane.add(previousTopic.getNoResponse());
if (previousTopic.isLbHeal()) {
for (PartyMember pm : screen.context.getParty().getMembers()) {
pm.heal(HealType.CURE);
pm.heal(HealType.FULLHEAL);
}
Sounds.play(Sound.HEALING);
}
if (conversation.getRespAffectsHumility() > 0) {
screen.context.getParty().adjustKarma(KarmaAction.HUMBLE);
}
}
} else {
scrollPane.add("That I cannot help thee with.");
}
previousTopic = null;
}
} else if (person.getRole() != null && vendor != null) {
String input = tf.getText();
vendor.setResponse(input);
vendor.nextDialog();
}
tf.setText("");
}
}
});
defaults().pad(5);
internalTable.add(scrollPane).maxWidth(width).width(width);
internalTable.row();
internalTable.add(input).maxWidth(width).width(width);
focusListener = new FocusListener() {
@Override
public void keyboardFocusChanged(FocusEvent event, Actor actor, boolean focused) {
if (!focused) {
focusChanged(event);
}
}
@Override
public void scrollFocusChanged(FocusEvent event, Actor actor, boolean focused) {
if (!focused) {
focusChanged(event);
}
}
private void focusChanged(FocusEvent event) {
Stage stage = getStage();
if (isModal() && stage != null && stage.getRoot().getChildren().size > 0 && stage.getRoot().getChildren().peek() == ConversationDialog.this) {
Actor newFocusedActor = event.getRelatedActor();
if (newFocusedActor != null && !newFocusedActor.isDescendantOf(ConversationDialog.this) && !(newFocusedActor.equals(previousKeyboardFocus) || newFocusedActor.equals(previousScrollFocus))) {
event.cancel();
}
}
}
};
person.setTalking(true);
if (person.getConversation() != null) {
if (person.getRole() != null && person.getRole().getRole().equals("lordbritish")) {
LordBritishConversation conv = (LordBritishConversation) person.getConversation();
scrollPane.add(conv.intro(screen.context));
SequenceAction seq = Actions.action(SequenceAction.class);
Party party = screen.context.getParty();
if (party.getMember(0).getPlayer().status == StatusType.DEAD) {
party.getMember(0).heal(HealType.RESURRECT);
party.getMember(0).heal(HealType.FULLHEAL);
seq.addAction(Actions.run(new LBAction(Sound.HEALING, "I resurrect thee.")));
seq.addAction(Actions.delay(3f));
}
for (int i = 0; i < party.getMembers().size(); i++) {
PartyMember pm = party.getMember(i);
if (pm.getPlayer().advanceLevel()) {
seq.addAction(Actions.run(new LBAction(Sound.MAGIC, pm.getPlayer().name + " thou art now level " + pm.getPlayer().getLevel())));
seq.addAction(Actions.delay(3f));
}
}
stage.addAction(seq);
} else if (person.getRole() != null && person.getRole().getRole().equals("hawkwind")) {
HawkwindConversation conv = (HawkwindConversation) person.getConversation();
conv.setParty(screen.context.getParty());
scrollPane.add(conv.intro());
} else {
scrollPane.add("You meet " + person.getConversation().getDescription().toLowerCase() + ".");
}
} else if (person.getRole() != null && person.getRole().getInventoryType() != null) {
vendor = Ultima4.vendorClassSet.getVendorImpl(person.getRole().getInventoryType(), Maps.get(screen.context.getCurrentMap().getId()), screen.context);
vendor.setScreen(screen);
vendor.setScrollPane(scrollPane);
vendor.nextDialog();
}
}
use of com.badlogic.gdx.scenes.scene2d.Stage in project AnotherMonekyParadox by SantiagoMille.
the class PantallaCredits method crearMenu.
private void crearMenu() {
stageMenu = new Stage(vista);
title = new Texto(1, 1, 1);
Adrian = new Texto(1, 1, 1);
Santi = new Texto(1, 1, 1);
Fer = new Texto(1, 1, 1);
Brian = new Texto(1, 1, 1);
Diego = new Texto(1, 1, 1);
imgBackground = new Texture("space.png");
adrian = new Texture("pp.jpg");
santi = new Texture("pp.jpg");
fernando = new Texture("pp.jpg");
diego = new Texture("pp.jpg");
brian = new Texture("pp.jpg");
spriteBackground = new Sprite(imgBackground);
// spriteBackground.setAlpha(0.7f);
adr = new Sprite(adrian);
bri = new Sprite(brian);
die = new Sprite(diego);
fer = new Sprite(fernando);
san = new Sprite(santi);
adr.setScale(.15f);
san.setScale(.15f);
die.setScale(.15f);
fer.setScale(.15f);
bri.setScale(.15f);
adr.setPosition(600, 250);
bri.setPosition(600, 130);
die.setPosition(600, 20);
san.setPosition(600, -100);
fer.setPosition(600, -220);
// Boton Return
TextureRegionDrawable trdReturn = new TextureRegionDrawable(new TextureRegion(new Texture("go-back.png")));
ImageButton btnReturn = new ImageButton(trdReturn);
btnReturn.setPosition(30, ALTO - 30 - btnReturn.getHeight());
btnReturn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
// Gdx.app.log("ClickListener","Si se clickeoooo");
main.setScreen(new PantallaDeveloper(main));
}
});
// Fotos
foto.setScaling(Scaling.fit);
stageMenu.addActor(btnReturn);
Gdx.input.setInputProcessor(stageMenu);
}
use of com.badlogic.gdx.scenes.scene2d.Stage in project AnotherMonekyParadox by SantiagoMille.
the class PantallaDeveloper method crearMenu.
private void crearMenu() {
stageMenu = new Stage(vista);
prefs = Gdx.app.getPreferences("AnotherMonkeyPreferenceStory");
Skin skin = new Skin(Gdx.files.internal("skin/comic-ui.json"));
imgBackground = new Texture("pantalla_config.png");
spriteBackground = new Sprite(imgBackground);
spriteBackground.setAlpha(0.7f);
container = new Table();
stageMenu.addActor(container);
container.setFillParent(true);
container.setPosition(0, 30);
Table table = new Table();
final ScrollPane scroll = new ScrollPane(table, skin);
// Boton Return
TextureRegionDrawable trdReturn = new TextureRegionDrawable(new TextureRegion(new Texture("go-back.png")));
ImageButton btnReturn = new ImageButton(trdReturn);
btnReturn.setPosition(ANCHO - 80, ALTO - 30 - btnReturn.getHeight());
// Click en boton Return
btnReturn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
prefs.putFloat("Difficulty", difficulty);
prefs.putFloat("Sensitivity", sensitivity);
main.setScreen(new PantallaMenu(main));
}
});
InputListener stopTouchDown = new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
event.stop();
difficulty = x;
return false;
}
};
InputListener stopTouchDown2 = new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
event.stop();
sensitivity = x;
return false;
}
};
table.pad(10).defaults().expandX().space(4);
titulo = new Texto(1, 1, 1);
table.row();
table.row();
table.row();
table.row();
table.add(new Label("\n\n\n\n\n\n\n\n\n\n\n ", skin));
table.row();
table.add(new Label("\n\n\n\n\n\n\n\n\n\n\n ", skin));
TextButton buttonVolumen = new TextButton("Difficulty", skin);
table.add(buttonVolumen);
buttonVolumen.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
System.out.println("click " + x + ", " + y);
}
});
Slider sliderDif = new Slider(0, 100, 1, false, skin);
// Stops touchDown events from propagating to the FlickScrollPane.
sliderDif.addListener(stopTouchDown);
table.add(sliderDif);
table.add(new Label(" ", skin));
table.row();
table.add(new Label(" ", skin));
table.row();
table.add(new Label(" ", skin));
table.row();
table.add(new Label(" ", skin)).expandX().fillX();
TextButton buttonSensitivity = new TextButton("Sensitivity", skin);
table.add(buttonSensitivity);
buttonSensitivity.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
System.out.println("click " + x + ", " + y);
}
});
Slider sliderSens = new Slider(0, 100, 1, false, skin);
// Stops touchDown events from propagating to the FlickScrollPane.
sliderSens.addListener(stopTouchDown2);
table.add(sliderSens);
table.add(new Label(" ", skin));
final TextButton creditsButton = new TextButton("Creditos", skin.get("default", TextButton.TextButtonStyle.class));
creditsButton.setChecked(true);
creditsButton.addListener(new ChangeListener() {
public void changed(ChangeEvent event, Actor actor) {
scroll.setFlickScroll(creditsButton.isChecked());
prefs.putFloat("Difficulty", difficulty);
prefs.putFloat("Sensitivity", sensitivity);
main.setScreen(new PantallaCredits(main));
}
});
container.add(scroll).expand().fill().colspan(4);
container.row().space(10).padBottom(10);
container.add(new Label(" ", skin));
table.row();
table.add(new Label("\n\n\n\n\n\n\n\n\n\n\n ", skin));
table.row();
table.add(new Label("\n\n\n\n\n\n\n\n\n\n\n ", skin));
table.row();
container.add(creditsButton).left().expandX();
stageMenu.addActor(btnReturn);
Gdx.input.setInputProcessor(stageMenu);
float ddiiff = prefs.getFloat("Difficulty");
sliderDif.setX(ddiiff);
sliderSens.setX(prefs.getFloat("Sensitivity"));
}
Aggregations