Skip to content

Commit c9d48ea

Browse files
committed
- Text inputpanel types
- Added 'once' param to dialog option
1 parent 1b946b8 commit c9d48ea

File tree

7 files changed

+69
-10
lines changed

7 files changed

+69
-10
lines changed

adventure-composer/src/main/java/com/bladecoder/engineeditor/ui/EditActionDialog.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.w3c.dom.Element;
2121

2222
import com.badlogic.gdx.scenes.scene2d.Actor;
23+
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
2324
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox;
2425
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
2526
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
@@ -147,7 +148,8 @@ private void setAction() {
147148

148149
addInputPanel(parameters[i]);
149150

150-
if (parameters[i].getField() instanceof TextField && params[i].name.toLowerCase().endsWith("text")) {
151+
if ((parameters[i].getField() instanceof TextField && params[i].name.toLowerCase().endsWith("text")) ||
152+
parameters[i].getField() instanceof ScrollPane) {
151153
parameters[i].getCell(parameters[i].getField()).fillX();
152154
}
153155
}

adventure-composer/src/main/java/com/bladecoder/engineeditor/ui/EditDialogOptionDialog.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
2121
import com.bladecoder.engine.actions.Param;
22+
import com.bladecoder.engine.actions.Param.Type;
2223
import com.bladecoder.engineeditor.model.BaseDocument;
2324
import com.bladecoder.engineeditor.ui.components.EditElementDialog;
2425
import com.bladecoder.engineeditor.ui.components.InputPanel;
@@ -28,20 +29,21 @@ public class EditDialogOptionDialog extends EditElementDialog {
2829

2930
private InputPanel[] inputs;
3031

31-
String attrs[] = { "text", "response_text", "verb", "next", "visible" };
32+
String attrs[] = { "text", "response_text", "verb", "next", "visible", "once" };
3233

3334
public EditDialogOptionDialog(Skin skin, BaseDocument doc,
3435
Element parent, Element e) {
3536
super(skin);
3637

37-
inputs = new InputPanel[5];
38+
inputs = new InputPanel[attrs.length];
3839

39-
inputs[0] = InputPanelFactory.createInputPanel(skin, "Text", "The sentence of the dialog to say by the player");
40-
inputs[1] = InputPanelFactory.createInputPanel(skin, "Response Text", "The response by the character");
40+
inputs[0] = InputPanelFactory.createInputPanel(skin, "Text", "The sentence of the dialog to say by the player", Type.SMALL_TEXT, true);
41+
inputs[1] = InputPanelFactory.createInputPanel(skin, "Response Text", "The response by the character", Type.TEXT, false);
4142
inputs[2] = InputPanelFactory.createInputPanel(skin, "Verb", "The verb to execute when choosing this option");
4243
inputs[3] = InputPanelFactory.createInputPanel(skin, "Next Option",
4344
"The next option to show when this option is selected");
4445
inputs[4] = InputPanelFactory.createInputPanel(skin, "Visible", "The visibility", Param.Type.BOOLEAN, false);
46+
inputs[5] = InputPanelFactory.createInputPanel(skin, "Once", "When true, the option is hidden after selection", Param.Type.BOOLEAN, false);
4547

4648
setInfo("A dialog is composed of an option tree. Each option is a dialog sentence that the user can choose to say");
4749

adventure-composer/src/main/java/com/bladecoder/engineeditor/ui/components/BooleanInputPanel.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919

2020
public class BooleanInputPanel extends OptionsInputPanel {
2121
private static final String[] booleanValues = {"true", "false"};
22-
private static final String[] booleanNotMandatoryValues = {"", "true", "false"};
2322

2423
BooleanInputPanel(Skin skin, String title, String desc, boolean mandatory, String defaultValue) {
25-
super(skin, title, desc, mandatory, defaultValue, mandatory?booleanValues:booleanNotMandatoryValues);
24+
super(skin, title, desc, mandatory, defaultValue, booleanValues);
2625

2726
if(defaultValue != null)
2827
setText(defaultValue);

adventure-composer/src/main/java/com/bladecoder/engineeditor/ui/components/InputPanelFactory.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,17 @@ public static InputPanel createInputPanel(Skin skin, String title, String desc,
8181
case VECTOR3:
8282
break;
8383
case FILE:
84-
break;
84+
break;
85+
case TEXT:
86+
return new TextInputPanel(skin, title, desc, mandatory, defaultValue);
87+
case BIG_TEXT:
88+
TextInputPanel i = new TextInputPanel(skin, title, desc, mandatory, defaultValue);
89+
i.setRows(20);
90+
return i;
91+
case SMALL_TEXT:
92+
TextInputPanel i2 = new TextInputPanel(skin, title, desc, mandatory, defaultValue);
93+
i2.setRows(5);
94+
return i2;
8595
}
8696

8797
return new StringInputPanel(skin, title, desc, mandatory, defaultValue);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*******************************************************************************
2+
* Copyright 2014 Rafael Garcia Moreno.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
******************************************************************************/
16+
package com.bladecoder.engineeditor.ui.components;
17+
18+
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
19+
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
20+
import com.badlogic.gdx.scenes.scene2d.ui.TextArea;
21+
22+
public class TextInputPanel extends InputPanel {
23+
TextArea input;
24+
25+
TextInputPanel(Skin skin, String title, String desc, boolean mandatory, String defaultValue) {
26+
input = new TextArea("", skin);
27+
input.setPrefRows(10);
28+
29+
ScrollPane scroll = new ScrollPane(input, skin);
30+
31+
init(skin, title, desc, scroll, mandatory, defaultValue);
32+
}
33+
34+
public String getText() {
35+
return input.getText().replaceAll("\n", "\\\\n");
36+
}
37+
38+
public void setText(String s) {
39+
input.setText(s.replaceAll("\\\\n", "\n"));
40+
}
41+
42+
public void setRows(float rows) {
43+
input.setPrefRows(rows);
44+
}
45+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121

2222
public class Param {
2323
public enum Type {
24-
STRING, BOOLEAN, FLOAT, INTEGER, VECTOR2, VECTOR3, DIMENSION, ACTOR, SCENE, CHAPTER, FILE, OPTION, SCENE_ACTOR, ACTOR_ANIMATION, LAYER, EDITABLE_OPTION
24+
STRING, BOOLEAN, FLOAT, INTEGER, VECTOR2, VECTOR3, DIMENSION, ACTOR, SCENE, CHAPTER, FILE, OPTION, SCENE_ACTOR, ACTOR_ANIMATION, LAYER, EDITABLE_OPTION,
25+
TEXT, SMALL_TEXT, BIG_TEXT
2526
};
2627

2728
public static final String NUMBER_PARAM_SEPARATOR = ",";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class SayAction extends BaseCallbackAction {
3434
public static final String INFO = "Says a text";
3535
public static final Param[] PARAMS = {
3636
new Param("actor", "The target actor", Type.ACTOR, false),
37-
new Param("text", "The 'text' to show", Type.STRING),
37+
new Param("text", "The 'text' to show", Type.TEXT),
3838
new Param(
3939
"pos",
4040
"The position of the text. If null, the position will be calc based in actor",

0 commit comments

Comments
 (0)