Skip to content

Commit 9e37fe9

Browse files
committed
Merge branch 'voices'
2 parents 006b259 + c7c0939 commit 9e37fe9

File tree

14 files changed

+253
-19
lines changed

14 files changed

+253
-19
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
public class EditOptionDialog extends EditModelDialog<Dialog, DialogOption> {
3131

3232
private InputPanel text;
33+
private InputPanel voice;
3334
private InputPanel responseText;
35+
private InputPanel responseVoice;
3436
private InputPanel verb;
3537
private InputPanel next;
3638
private InputPanel visible;
@@ -45,8 +47,12 @@ public EditOptionDialog(Skin skin, Dialog parent, DialogOption e, int pos) {
4547

4648
text = InputPanelFactory.createInputPanel(skin, "Text", "The sentence of the dialog to say by the player",
4749
Type.SMALL_TEXT, true);
48-
responseText = InputPanelFactory.createInputPanel(skin, "Response Text", "The response by the character",
50+
voice = InputPanelFactory.createInputPanel(skin, "Voice", "The voice filename",
51+
Type.VOICE, true);
52+
responseText = InputPanelFactory.createInputPanel(skin, "Response Text", "The response said by the character",
4953
Type.TEXT, false);
54+
responseVoice = InputPanelFactory.createInputPanel(skin, "Response Voice", "The voice filename for the response",
55+
Type.VOICE, false);
5056
verb = InputPanelFactory.createInputPanel(skin, "Verb", "The verb to execute when choosing this option");
5157
next = InputPanelFactory.createInputPanel(skin, "Next Dialog",
5258
"The next dialog to show when this option is selected",
@@ -60,7 +66,7 @@ public EditOptionDialog(Skin skin, Dialog parent, DialogOption e, int pos) {
6066
text.getCell(text.getField()).fillX();
6167
responseText.getCell(responseText.getField()).fillX();
6268

63-
init(parent, e, new InputPanel[] { text, responseText, verb, next, visible, once });
69+
init(parent, e, new InputPanel[] { text, voice, responseText, responseVoice, verb, next, visible, once });
6470
}
6571

6672
@Override
@@ -101,6 +107,9 @@ protected void inputsToModel(boolean create) {
101107
e.setNext(next.getText());
102108
e.setVisible(Boolean.parseBoolean(visible.getText()));
103109
e.setOnce(Boolean.parseBoolean(once.getText()));
110+
e.setVoiceId(voice.getText());
111+
e.setResponseVoiceId(responseVoice.getText());
112+
104113

105114
// TODO UNDO OP
106115
// UndoOp undoOp = new UndoAddElement(doc, e);
@@ -121,6 +130,8 @@ protected void modelToInputs() {
121130

122131
visible.setText(Boolean.toString(e.isVisible()));
123132
once.setText(Boolean.toString(e.isOnce()));
133+
voice.setText(e.getVoiceId());
134+
responseVoice.setText(e.getResponseVoiceId());
124135
}
125136

126137
private String[] getActorDialogs(CharacterActor actor) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ private static InputPanel createInputPanel(Skin skin, String title, String desc,
9696
case COLOR:
9797
return new ColorInputPanel(skin, title, desc, mandatory, defaultValue);
9898
case SOUND:
99+
case VOICE:
99100
case TEXT_STYLE:
100101
case STRING:
101102
if (options != null)

blade-engine/src/com/bladecoder/engine/actions/LookAtAction.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ public String getDirection() {
5151
@ActionPropertyDescription("The 'text' to show")
5252
@ActionProperty(type = Type.SMALL_TEXT)
5353
private String text;
54+
55+
@ActionPropertyDescription("The 'voice' file to play if selected.")
56+
@ActionProperty(type = Type.VOICE)
57+
private String voiceId;
5458

5559
@ActionProperty
5660
@ActionPropertyDescription("The direction to lookat. If empty, the player lookat to the actor")
@@ -81,7 +85,7 @@ else if (a != null && player != null) {
8185
String actorId = World.getInstance().getCurrentScene().getPlayer() != null? World.getInstance().getCurrentScene().getPlayer().getId():null;
8286

8387
World.getInstance().getTextManager().addText(text, TextManager.POS_SUBTITLE, TextManager.POS_SUBTITLE,
84-
false, Text.Type.SUBTITLE, null, null, actorId, wait ? cb : null);
88+
false, Text.Type.SUBTITLE, null, null, actorId, voiceId, wait ? cb : null);
8589

8690
return wait;
8791
}

blade-engine/src/com/bladecoder/engine/actions/Param.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
public class Param {
2424
public enum Type {
25-
STRING, BOOLEAN, FLOAT, INTEGER, VECTOR2, VECTOR3, DIMENSION, ACTOR, CHARACTER_ACTOR, INTERACTIVE_ACTOR, SPRITE_ACTOR, SCENE, CHAPTER, FILE, OPTION, SCENE_ACTOR, ACTOR_ANIMATION, LAYER, EDITABLE_OPTION, SCENE_CHARACTER_ACTOR, SCENE_INTERACTIVE_ACTOR, SCENE_SPRITE_ACTOR, TEXT, SMALL_TEXT, BIG_TEXT, COLOR, SOUND, TEXT_STYLE, ATLAS_ASSET, MUSIC_ASSET, SOUND_ASSET, PARTICLE_ASSET, FONT_ASSET, NOT_SET
25+
STRING, BOOLEAN, FLOAT, INTEGER, VECTOR2, VECTOR3, DIMENSION, ACTOR, CHARACTER_ACTOR, INTERACTIVE_ACTOR, SPRITE_ACTOR, SCENE, CHAPTER, FILE, OPTION, SCENE_ACTOR, ACTOR_ANIMATION, LAYER, EDITABLE_OPTION, SCENE_CHARACTER_ACTOR, SCENE_INTERACTIVE_ACTOR, SCENE_SPRITE_ACTOR, TEXT, SMALL_TEXT, BIG_TEXT, COLOR, SOUND, TEXT_STYLE, ATLAS_ASSET, MUSIC_ASSET, SOUND_ASSET, PARTICLE_ASSET, FONT_ASSET, NOT_SET, VOICE
2626
}
2727

2828
public static final String NUMBER_PARAM_SEPARATOR = ",";

blade-engine/src/com/bladecoder/engine/actions/SayAction.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public class SayAction extends BaseCallbackAction {
3939
@ActionProperty(type = Type.SMALL_TEXT)
4040
private String text;
4141

42-
@ActionPropertyDescription("The 'soundId' to play if selected.")
43-
@ActionProperty(type = Type.SOUND)
44-
private String soundId;
42+
@ActionPropertyDescription("The 'voice' file to play if selected.")
43+
@ActionProperty(type = Type.VOICE)
44+
private String voiceId;
4545

4646
@ActionProperty(required = true, defaultValue = "SUBTITLE")
4747
@ActionPropertyDescription("The type of the text.")
@@ -65,8 +65,8 @@ public boolean run(VerbRunner cb) {
6565
setVerbCb(cb);
6666
InteractiveActor a = (InteractiveActor) World.getInstance().getCurrentScene().getActor(actor, false);
6767

68-
if (soundId != null)
69-
a.playSound(soundId);
68+
if (voiceId != null)
69+
a.playSound(voiceId);
7070

7171
if (text != null) {
7272
if (type == Text.Type.TALK && a != null) {
@@ -82,7 +82,7 @@ public boolean run(VerbRunner cb) {
8282
}
8383

8484
World.getInstance().getTextManager().addText(text, x, y, queue, type, color, null,
85-
a != null? a.getId(): actor, this);
85+
a != null? a.getId(): actor, voiceId, this);
8686
}
8787

8888
return getWait();

blade-engine/src/com/bladecoder/engine/actions/SayDialogAction.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class SayDialogAction extends BaseCallbackAction {
3636
private boolean characterTurn = false;
3737
private String characterName;
3838
private String responseText;
39+
private String responseVoiceId;
3940

4041
private String previousAnim;
4142

@@ -54,6 +55,7 @@ public boolean run(VerbRunner cb) {
5455
String playerText = o.getText();
5556

5657
responseText = o.getResponseText();
58+
responseVoiceId = o.getResponseVoiceId();
5759
characterName = w.getCurrentDialog().getActor();
5860

5961
characterTurn = true;
@@ -73,7 +75,7 @@ public boolean run(VerbRunner cb) {
7375
float y = boundingRectangle.getY() + boundingRectangle.getHeight();
7476

7577
w.getTextManager().addText(playerText, x, y, false,
76-
Text.Type.TALK, player.getTextColor(), null, player.getId(), this);
78+
Text.Type.TALK, player.getTextColor(), null, player.getId(), o.getVoiceId(), this);
7779

7880
startTalkAnim(player);
7981

@@ -105,7 +107,7 @@ public void resume() {
105107

106108
World.getInstance().getTextManager().addText(responseText, x,
107109
y, false, Text.Type.TALK,
108-
((CharacterActor) actor).getTextColor(), null, actor.getId(), this);
110+
((CharacterActor) actor).getTextColor(), null, actor.getId(), responseVoiceId, this);
109111

110112

111113
if(actor instanceof CharacterActor) {
@@ -144,6 +146,7 @@ private void startTalkAnim(CharacterActor a) {
144146
public void write(Json json) {
145147
json.writeValue("previousFA", previousAnim);
146148
json.writeValue("responseText", responseText);
149+
json.writeValue("responseSoundId", responseVoiceId);
147150
json.writeValue("characterTurn", characterTurn);
148151
json.writeValue("characterName", characterName);
149152
super.write(json);
@@ -153,6 +156,7 @@ public void write(Json json) {
153156
public void read (Json json, JsonValue jsonData) {
154157
previousAnim = json.readValue("previousFA", String.class, jsonData);
155158
responseText = json.readValue("responseText", String.class, jsonData);
159+
responseVoiceId = json.readValue("responseSoundId", String.class, jsonData);
156160
characterTurn = json.readValue("characterTurn", boolean.class, false, jsonData);
157161
characterName = json.readValue("characterName", String.class, jsonData);
158162
super.read(json, jsonData);

blade-engine/src/com/bladecoder/engine/actions/TextAction.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public class TextAction implements Action {
3232
@ActionPropertyDescription("The 'text' to show")
3333
@ActionProperty(type = Type.SMALL_TEXT)
3434
private String text;
35+
36+
@ActionPropertyDescription("The 'voice' file to play if selected.")
37+
@ActionProperty(type = Type.VOICE)
38+
private String voiceId;
3539

3640
@ActionPropertyDescription("The style to use (an entry in your `ui.json` in the `com.bladecoder.engine.ui.TextManagerUI$TextManagerUIStyle` section)")
3741
@ActionProperty(type = Type.TEXT_STYLE, required = true, defaultValue = "default")
@@ -104,7 +108,7 @@ public boolean run(VerbRunner cb) {
104108
}
105109

106110
World.getInstance().getTextManager()
107-
.addText(text, x, y, queue, type, color, style, null, wait?cb:null);
111+
.addText(text, x, y, queue, type, color, style, null, voiceId, wait?cb:null);
108112
}
109113

110114
return wait;

blade-engine/src/com/bladecoder/engine/assets/EngineAssetManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class EngineAssetManager extends AssetManager {
6868
public static final String SPINE_DIR = "spine/";
6969
public static final String PARTICLE_DIR = "particles/";
7070
public static final String FONT_DIR = "ui/fonts/";
71+
public static final String VOICE_DIR = "voices/";
7172

7273
public static final String MODEL3D_EXT = ".g3db";
7374
public static final String SPINE_EXT = ".skel";

blade-engine/src/com/bladecoder/engine/model/DialogOption.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class DialogOption implements Serializable {
2828
private String next;
2929
private boolean visible = true;
3030
private boolean once = false;
31+
private String voiceId;
32+
private String responseVoiceId;
3133

3234
public boolean isVisible() {
3335
return visible;
@@ -52,6 +54,22 @@ public String getText() {
5254
public void setText(String text) {
5355
this.text = text;
5456
}
57+
58+
public String getVoiceId() {
59+
return voiceId;
60+
}
61+
62+
public void setVoiceId(String voiceId) {
63+
this.voiceId = voiceId;
64+
}
65+
66+
public String getResponseVoiceId() {
67+
return responseVoiceId;
68+
}
69+
70+
public void setResponseVoiceId(String soundId) {
71+
this.responseVoiceId = soundId;
72+
}
5573

5674
public void setResponseText(String responseText) {
5775
this.responseText = responseText;
@@ -86,6 +104,8 @@ public void write(Json json) {
86104
json.writeValue("verbId", verbId);
87105
json.writeValue("next", next);
88106
json.writeValue("once", once);
107+
json.writeValue("soundId", voiceId);
108+
json.writeValue("responseSoundId", responseVoiceId);
89109
} else {
90110

91111
}
@@ -102,6 +122,8 @@ public void read(Json json, JsonValue jsonData) {
102122
verbId = json.readValue("verbId", String.class, jsonData);
103123
next = json.readValue("next", String.class, jsonData);
104124
once = json.readValue("once", Boolean.class, jsonData);
125+
voiceId = json.readValue("soundId", String.class, jsonData);
126+
responseVoiceId = json.readValue("responseSoundId", String.class, jsonData);
105127
} else {
106128

107129
}

blade-engine/src/com/bladecoder/engine/model/MusicEngine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* Simple music engine.
1313
*
14-
* Plays a music file, if another music is playing, stop it before playing the
14+
* Plays a music file, if another music is playing, stops it before playing the
1515
* new music.
1616
*
1717
* @author rgarcia

0 commit comments

Comments
 (0)