Skip to content

Commit 2ad287d

Browse files
committed
editor: fix dialog id collision testing.
1 parent 7129c4a commit 2ad287d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

adventure-editor/src/main/java/com/bladecoder/engineeditor/ui/EditDialogDialog.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.bladecoder.engineeditor.ui.components.EditModelDialog;
2323
import com.bladecoder.engineeditor.ui.components.InputPanel;
2424
import com.bladecoder.engineeditor.ui.components.InputPanelFactory;
25+
import com.bladecoder.engineeditor.utils.ElementUtils;
2526

2627
public class EditDialogDialog extends EditModelDialog<CharacterActor, Dialog> {
2728
public static final String INFO = "Actors can have several dialogs defined. Dialogs have a tree of options to choose";
@@ -44,13 +45,13 @@ protected void inputsToModel(boolean create) {
4445

4546
if(create) {
4647
e = new Dialog();
48+
} else {
49+
parent.getDialogs().remove(e.getId());
4750
}
4851

49-
e.setId(id.getText());
52+
e.setId(ElementUtils.getCheckedId(id.getText(), parent.getDialogs().keySet().toArray(new String[0])));
5053

51-
if(create) {
52-
parent.addDialog(e);
53-
}
54+
parent.addDialog(e);
5455

5556
// TODO UNDO OP
5657
// UndoOp undoOp = new UndoAddElement(doc, e);

adventure-editor/src/main/java/com/bladecoder/engineeditor/ui/SoundList.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.Arrays;
2121

2222
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
23-
import com.bladecoder.engine.model.Dialog;
2423
import com.bladecoder.engine.model.InteractiveActor;
2524
import com.bladecoder.engine.model.SoundFX;
2625
import com.bladecoder.engineeditor.Ctx;
@@ -40,7 +39,7 @@ public SoundList(Skin skin) {
4039
Ctx.project.addPropertyChangeListener(Project.NOTIFY_ELEMENT_CREATED, new PropertyChangeListener() {
4140
@Override
4241
public void propertyChange(PropertyChangeEvent evt) {
43-
if (evt.getNewValue() instanceof Dialog && !(evt.getSource() instanceof EditDialogDialog) && parent instanceof InteractiveActor) {
42+
if (evt.getNewValue() instanceof SoundFX && !(evt.getSource() instanceof EditSoundDialog) && parent instanceof InteractiveActor) {
4443
addElements(parent, Arrays.asList(parent.getSounds().values().toArray(new SoundFX[0])));
4544
}
4645
}

0 commit comments

Comments
 (0)