use of objects.Conversation.Topic 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 objects.Conversation.Topic in project ultimate-java by pantinor.
the class MapSet method init.
public void init(TileSet ts) {
for (BaseMap m : maps) {
Maps map = Maps.get(m.getId());
map.setMap(m);
String tlkName = m.getCity() == null ? null : m.getCity().getTlk_fname();
if (tlkName != null) {
if (tlkName.endsWith(".tmx")) {
Utils.setTMXMap(m, map, tlkName, ts);
} else {
List<Conversation> conv = Utils.getDialogs(tlkName);
m.getCity().setConversations(conv);
List<Person> people = Utils.getPeople(m.getFname(), map, ts);
m.getCity().setPeople(people);
for (Person p : people) {
if (p != null) {
for (Conversation c : conv) {
c.setMap(map);
if (c.getIndex() == p.getDialogId()) {
p.setConversation(c);
}
}
if (m.getCity().getPersonRoles() != null) {
for (PersonRole pr : m.getCity().getPersonRoles()) {
if (p.getId() == pr.getId()) {
p.setRole(pr);
}
}
}
// set beggars give conversations
if (p.getTile().getIndex() == 88 || p.getTile().getIndex() == 89) {
Topic giveTopic = p.getConversation().matchTopic("give");
giveTopic.setPhrase("How much?");
CustomInputConversation cic = new CustomInputConversation(p.getTile(), p.getConversation());
cic.setCustomInputQuery("give");
p.setConversation(cic);
}
}
}
}
}
try {
// only for the original ULT or world data files, no-op for TMX files
Utils.setMapTiles(m, ts);
} catch (Exception e) {
e.printStackTrace();
}
if (m.getType() == MapType.world || m.getType() == MapType.city) {
float[][] shadowMap = new float[m.getWidth()][m.getHeight()];
for (int y = 0; y < m.getHeight(); y++) {
for (int x = 0; x < m.getWidth(); x++) {
shadowMap[x][y] = (m.getTile(x, y).isOpaque() ? 1 : 0);
}
}
m.setShadownMap(shadowMap);
}
}
}
Aggregations