|
@@ -14,6 +14,7 @@ var con =
|
|
['dialogue.Text', 'dialogue.Function'],
|
|
['dialogue.Text', 'dialogue.Function'],
|
|
['dialogue.Text', 'dialogue.Tree'],
|
|
['dialogue.Text', 'dialogue.Tree'],
|
|
['dialogue.Text', 'dialogue.GoToLabel'],
|
|
['dialogue.Text', 'dialogue.GoToLabel'],
|
|
|
|
+ ['dialogue.Text', 'dialogue.ConditionalBranch'],
|
|
['dialogue.Node', 'dialogue.Text'],
|
|
['dialogue.Node', 'dialogue.Text'],
|
|
['dialogue.Node', 'dialogue.Node'],
|
|
['dialogue.Node', 'dialogue.Node'],
|
|
['dialogue.Node', 'dialogue.Choice'],
|
|
['dialogue.Node', 'dialogue.Choice'],
|
|
@@ -22,6 +23,7 @@ var con =
|
|
['dialogue.Node', 'dialogue.Function'],
|
|
['dialogue.Node', 'dialogue.Function'],
|
|
['dialogue.Node', 'dialogue.Tree'],
|
|
['dialogue.Node', 'dialogue.Tree'],
|
|
['dialogue.Node', 'dialogue.GoToLabel'],
|
|
['dialogue.Node', 'dialogue.GoToLabel'],
|
|
|
|
+ ['dialogue.Node', 'dialogue.ConditionalBranch'],
|
|
['dialogue.Tree', 'dialogue.Node'],
|
|
['dialogue.Tree', 'dialogue.Node'],
|
|
['dialogue.Tree', 'dialogue.Text'],
|
|
['dialogue.Tree', 'dialogue.Text'],
|
|
['dialogue.Tree', 'dialogue.Choice'],
|
|
['dialogue.Tree', 'dialogue.Choice'],
|
|
@@ -30,6 +32,7 @@ var con =
|
|
['dialogue.Tree', 'dialogue.Function'],
|
|
['dialogue.Tree', 'dialogue.Function'],
|
|
['dialogue.Tree', 'dialogue.Tree'],
|
|
['dialogue.Tree', 'dialogue.Tree'],
|
|
['dialogue.Tree', 'dialogue.GoToLabel'],
|
|
['dialogue.Tree', 'dialogue.GoToLabel'],
|
|
|
|
+ ['dialogue.Tree', 'dialogue.ConditionalBranch'],
|
|
['dialogue.StartNode', 'dialogue.Text'],
|
|
['dialogue.StartNode', 'dialogue.Text'],
|
|
['dialogue.StartNode', 'dialogue.Node'],
|
|
['dialogue.StartNode', 'dialogue.Node'],
|
|
['dialogue.StartNode', 'dialogue.Choice'],
|
|
['dialogue.StartNode', 'dialogue.Choice'],
|
|
@@ -38,6 +41,7 @@ var con =
|
|
['dialogue.StartNode', 'dialogue.Function'],
|
|
['dialogue.StartNode', 'dialogue.Function'],
|
|
['dialogue.StartNode', 'dialogue.Tree'],
|
|
['dialogue.StartNode', 'dialogue.Tree'],
|
|
['dialogue.StartNode', 'dialogue.GoToLabel'],
|
|
['dialogue.StartNode', 'dialogue.GoToLabel'],
|
|
|
|
+ ['dialogue.StartNode', 'dialogue.ConditionalBranch'],
|
|
['dialogue.Choice', 'dialogue.Text'],
|
|
['dialogue.Choice', 'dialogue.Text'],
|
|
['dialogue.Choice', 'dialogue.Node'],
|
|
['dialogue.Choice', 'dialogue.Node'],
|
|
['dialogue.Choice', 'dialogue.Set'],
|
|
['dialogue.Choice', 'dialogue.Set'],
|
|
@@ -45,6 +49,7 @@ var con =
|
|
['dialogue.Choice', 'dialogue.Function'],
|
|
['dialogue.Choice', 'dialogue.Function'],
|
|
['dialogue.Choice', 'dialogue.Tree'],
|
|
['dialogue.Choice', 'dialogue.Tree'],
|
|
['dialogue.Choice', 'dialogue.GoToLabel'],
|
|
['dialogue.Choice', 'dialogue.GoToLabel'],
|
|
|
|
+ ['dialogue.Choice', 'dialogue.ConditionalBranch'],
|
|
['dialogue.Set', 'dialogue.Text'],
|
|
['dialogue.Set', 'dialogue.Text'],
|
|
['dialogue.Set', 'dialogue.Node'],
|
|
['dialogue.Set', 'dialogue.Node'],
|
|
['dialogue.Set', 'dialogue.Set'],
|
|
['dialogue.Set', 'dialogue.Set'],
|
|
@@ -52,6 +57,7 @@ var con =
|
|
['dialogue.Set', 'dialogue.Function'],
|
|
['dialogue.Set', 'dialogue.Function'],
|
|
['dialogue.Set', 'dialogue.Tree'],
|
|
['dialogue.Set', 'dialogue.Tree'],
|
|
['dialogue.Set', 'dialogue.GoToLabel'],
|
|
['dialogue.Set', 'dialogue.GoToLabel'],
|
|
|
|
+ ['dialogue.Set', 'dialogue.ConditionalBranch'],
|
|
['dialogue.Function', 'dialogue.Text'],
|
|
['dialogue.Function', 'dialogue.Text'],
|
|
['dialogue.Function', 'dialogue.Node'],
|
|
['dialogue.Function', 'dialogue.Node'],
|
|
['dialogue.Function', 'dialogue.Set'],
|
|
['dialogue.Function', 'dialogue.Set'],
|
|
@@ -59,6 +65,7 @@ var con =
|
|
['dialogue.Function', 'dialogue.Function'],
|
|
['dialogue.Function', 'dialogue.Function'],
|
|
['dialogue.Function', 'dialogue.Tree'],
|
|
['dialogue.Function', 'dialogue.Tree'],
|
|
['dialogue.Function', 'dialogue.GoToLabel'],
|
|
['dialogue.Function', 'dialogue.GoToLabel'],
|
|
|
|
+ ['dialogue.Function', 'dialogue.ConditionalBranch'],
|
|
['dialogue.Branch', 'dialogue.Text'],
|
|
['dialogue.Branch', 'dialogue.Text'],
|
|
['dialogue.Branch', 'dialogue.Node'],
|
|
['dialogue.Branch', 'dialogue.Node'],
|
|
['dialogue.Branch', 'dialogue.Set'],
|
|
['dialogue.Branch', 'dialogue.Set'],
|
|
@@ -66,6 +73,15 @@ var con =
|
|
['dialogue.Branch', 'dialogue.Function'],
|
|
['dialogue.Branch', 'dialogue.Function'],
|
|
['dialogue.Branch', 'dialogue.Tree'],
|
|
['dialogue.Branch', 'dialogue.Tree'],
|
|
['dialogue.Branch', 'dialogue.GoToLabel'],
|
|
['dialogue.Branch', 'dialogue.GoToLabel'],
|
|
|
|
+ ['dialogue.Branch', 'dialogue.ConditionalBranch'],
|
|
|
|
+ ['dialogue.ConditionalBranch', 'dialogue.Text'],
|
|
|
|
+ ['dialogue.ConditionalBranch', 'dialogue.Node'],
|
|
|
|
+ ['dialogue.ConditionalBranch', 'dialogue.Set'],
|
|
|
|
+ ['dialogue.ConditionalBranch', 'dialogue.ConditionalBranch'],
|
|
|
|
+ ['dialogue.ConditionalBranch', 'dialogue.Branch'],
|
|
|
|
+ ['dialogue.ConditionalBranch', 'dialogue.Function'],
|
|
|
|
+ ['dialogue.ConditionalBranch', 'dialogue.Tree'],
|
|
|
|
+ ['dialogue.ConditionalBranch', 'dialogue.GoToLabel'],
|
|
],
|
|
],
|
|
|
|
|
|
default_link: new joint.dia.Link(
|
|
default_link: new joint.dia.Link(
|
|
@@ -381,6 +397,112 @@ joint.shapes.dialogue.BranchView = joint.shapes.dialogue.BaseView.extend(
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+joint.shapes.dialogue.ConditionalBranch = joint.shapes.devs.Model.extend(
|
|
|
|
+ {
|
|
|
|
+ defaults: joint.util.deepSupplement
|
|
|
|
+ (
|
|
|
|
+ {
|
|
|
|
+ type: 'dialogue.ConditionalBranch',
|
|
|
|
+ size: { width: 200, height: 55, },
|
|
|
|
+ inPorts: ['input'],
|
|
|
|
+ outPorts: ['output0'],
|
|
|
|
+ values: [],
|
|
|
|
+ },
|
|
|
|
+ joint.shapes.dialogue.Base.prototype.defaults
|
|
|
|
+ ),
|
|
|
|
+ });
|
|
|
|
+joint.shapes.dialogue.ConditionalBranchView = joint.shapes.dialogue.BaseView.extend(
|
|
|
|
+ {
|
|
|
|
+ template:
|
|
|
|
+ [
|
|
|
|
+ '<div class="node">',
|
|
|
|
+ '<span class="label"></span>',
|
|
|
|
+ '<button class="delete">x</button>',
|
|
|
|
+ '<button class="add">+</button>',
|
|
|
|
+ '<button class="remove">-</button>',
|
|
|
|
+ '<input type="text" value="Default" readonly/>',
|
|
|
|
+ '</div>',
|
|
|
|
+ ].join(''),
|
|
|
|
+
|
|
|
|
+ initialize: function()
|
|
|
|
+ {
|
|
|
|
+ joint.shapes.dialogue.BaseView.prototype.initialize.apply(this, arguments);
|
|
|
|
+ this.$box.find('.add').on('click', _.bind(this.addPort, this));
|
|
|
|
+ this.$box.find('.remove').on('click', _.bind(this.removePort, this));
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ removePort: function()
|
|
|
|
+ {
|
|
|
|
+ if (this.model.get('outPorts').length > 1)
|
|
|
|
+ {
|
|
|
|
+ var outPorts = this.model.get('outPorts').slice(0);
|
|
|
|
+ outPorts.pop();
|
|
|
|
+ this.model.set('outPorts', outPorts);
|
|
|
|
+ var values = this.model.get('values').slice(0);
|
|
|
|
+ values.pop();
|
|
|
|
+ this.model.set('values', values);
|
|
|
|
+ this.updateSize();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ addPort: function()
|
|
|
|
+ {
|
|
|
|
+ var outPorts = this.model.get('outPorts').slice(0);
|
|
|
|
+ outPorts.push('output' + outPorts.length.toString());
|
|
|
|
+ this.model.set('outPorts', outPorts);
|
|
|
|
+ var values = this.model.get('values').slice(0);
|
|
|
|
+ values.push(null);
|
|
|
|
+ this.model.set('values', values);
|
|
|
|
+ this.updateSize();
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ updateBox: function()
|
|
|
|
+ {
|
|
|
|
+ joint.shapes.dialogue.BaseView.prototype.updateBox.apply(this, arguments);
|
|
|
|
+ var values = this.model.get('values');
|
|
|
|
+ var valueFields = this.$box.find('input.value');
|
|
|
|
+
|
|
|
|
+ // Add value fields if necessary
|
|
|
|
+ for (var i = valueFields.length; i < values.length; i++)
|
|
|
|
+ {
|
|
|
|
+ // Prevent paper from handling pointerdown.
|
|
|
|
+ var $field = $('<input type="text" class="value" />');
|
|
|
|
+ $field.attr('placeholder', 'Condition ' + (i + 1).toString());
|
|
|
|
+ $field.attr('index', i);
|
|
|
|
+ this.$box.append($field);
|
|
|
|
+ $field.on('mousedown click', function(evt) { evt.stopPropagation(); });
|
|
|
|
+
|
|
|
|
+ // This is an example of reacting on the input change and storing the input data in the cell model.
|
|
|
|
+ $field.on('change', _.bind(function(evt)
|
|
|
|
+ {
|
|
|
|
+ var values = this.model.get('values').slice(0);
|
|
|
|
+ values[$(evt.target).attr('index')] = $(evt.target).val();
|
|
|
|
+ this.model.set('values', values);
|
|
|
|
+ }, this));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Remove value fields if necessary
|
|
|
|
+ for (var i = values.length; i < valueFields.length; i++)
|
|
|
|
+ $(valueFields[i]).remove();
|
|
|
|
+
|
|
|
|
+ // Update value fields
|
|
|
|
+ valueFields = this.$box.find('input.value');
|
|
|
|
+ for (var i = 0; i < valueFields.length; i++)
|
|
|
|
+ {
|
|
|
|
+ var field = $(valueFields[i]);
|
|
|
|
+ if (!field.is(':focus'))
|
|
|
|
+ field.val(values[i]);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ updateSize: function()
|
|
|
|
+ {
|
|
|
|
+ var textField = this.$box.find('input');
|
|
|
|
+ var height = textField.outerHeight(true);
|
|
|
|
+ this.model.set('size', { width: 200, height: 95 + Math.max(0, (this.model.get('outPorts').length - 1) * height) });
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
|
|
joint.shapes.dialogue.StartNode = joint.shapes.devs.Model.extend(
|
|
joint.shapes.dialogue.StartNode = joint.shapes.devs.Model.extend(
|
|
{
|
|
{
|
|
@@ -390,7 +512,7 @@ joint.shapes.dialogue.StartNode = joint.shapes.devs.Model.extend(
|
|
type: 'dialogue.StartNode',
|
|
type: 'dialogue.StartNode',
|
|
inPorts: [],
|
|
inPorts: [],
|
|
outPorts: ['output'],
|
|
outPorts: ['output'],
|
|
- size: { width: 100, height: 30, },
|
|
|
|
|
|
+ size: { width: 100, height: 32, },
|
|
value: 'DialogueNode.START',
|
|
value: 'DialogueNode.START',
|
|
attrs:
|
|
attrs:
|
|
{
|
|
{
|
|
@@ -437,7 +559,7 @@ joint.shapes.dialogue.Choice = joint.shapes.devs.Model.extend(
|
|
type: 'dialogue.Choice',
|
|
type: 'dialogue.Choice',
|
|
inPorts: ['input'],
|
|
inPorts: ['input'],
|
|
outPorts: ['output'],
|
|
outPorts: ['output'],
|
|
- size: { width: 175, height: 95, },
|
|
|
|
|
|
+ size: { width: 175, height: 93, },
|
|
value: '',
|
|
value: '',
|
|
},
|
|
},
|
|
joint.shapes.dialogue.Base.prototype.defaults
|
|
joint.shapes.dialogue.Base.prototype.defaults
|
|
@@ -531,7 +653,7 @@ joint.shapes.dialogue.AIHook = joint.shapes.devs.Model.extend(
|
|
type: 'dialogue.AIHook',
|
|
type: 'dialogue.AIHook',
|
|
inPorts: [],
|
|
inPorts: [],
|
|
outPorts: [],
|
|
outPorts: [],
|
|
- size: { width: 300, height: 124, },
|
|
|
|
|
|
+ size: { width: 300, height: 126, },
|
|
value: '',
|
|
value: '',
|
|
},
|
|
},
|
|
joint.shapes.dialogue.Base.prototype.defaults
|
|
joint.shapes.dialogue.Base.prototype.defaults
|
|
@@ -545,7 +667,13 @@ joint.shapes.dialogue.AIHookView = joint.shapes.dialogue.BaseView.extend(
|
|
'<div class="node">',
|
|
'<div class="node">',
|
|
'<span class="label"></span>',
|
|
'<span class="label"></span>',
|
|
'<button class="delete">x</button>',
|
|
'<button class="delete">x</button>',
|
|
- '<input type="text" class="hooktype" placeholder="AskAbout/Circumstance/Informative/Critical" />',
|
|
|
|
|
|
+ '<select class="hooktype">',
|
|
|
|
+ '<option value="" selected disabled hidden>Choose Type</option>',
|
|
|
|
+ '<option value="askabout">Investigate Option</option>',
|
|
|
|
+ '<option value="circumstance">Common Dialogue Option</option>',
|
|
|
|
+ '<option value="informative">Pre-Dialogue Dialogue</option>',
|
|
|
|
+ '<option value="critical">Override Dialogue</option>',
|
|
|
|
+ '</select>',
|
|
'<input type="text" class="identifier" placeholder="Selection Text" />',
|
|
'<input type="text" class="identifier" placeholder="Selection Text" />',
|
|
'<input type="text" class="conditions" placeholder="Conditions (greeter, answerer)" />',
|
|
'<input type="text" class="conditions" placeholder="Conditions (greeter, answerer)" />',
|
|
'</div>',
|
|
'</div>',
|
|
@@ -558,7 +686,7 @@ joint.shapes.dialogue.AIHookView = joint.shapes.dialogue.BaseView.extend(
|
|
{
|
|
{
|
|
this.model.set('conditions', $(evt.target).val());
|
|
this.model.set('conditions', $(evt.target).val());
|
|
}, this));
|
|
}, this));
|
|
- this.$box.find('input.hooktype').on('change', _.bind(function(evt)
|
|
|
|
|
|
+ this.$box.find('select.hooktype').on('change', _.bind(function(evt)
|
|
{
|
|
{
|
|
this.model.set('hooktype', $(evt.target).val());
|
|
this.model.set('hooktype', $(evt.target).val());
|
|
}, this));
|
|
}, this));
|
|
@@ -571,7 +699,7 @@ joint.shapes.dialogue.AIHookView = joint.shapes.dialogue.BaseView.extend(
|
|
updateBox: function()
|
|
updateBox: function()
|
|
{
|
|
{
|
|
joint.shapes.dialogue.BaseView.prototype.updateBox.apply(this, arguments);
|
|
joint.shapes.dialogue.BaseView.prototype.updateBox.apply(this, arguments);
|
|
- var field = this.$box.find('input.hooktype');
|
|
|
|
|
|
+ var field = this.$box.find('select.hooktype');
|
|
if (!field.is(':focus'))
|
|
if (!field.is(':focus'))
|
|
field.val(this.model.get('hooktype'));
|
|
field.val(this.model.get('hooktype'));
|
|
var field = this.$box.find('input.conditions');
|
|
var field = this.$box.find('input.conditions');
|
|
@@ -686,6 +814,15 @@ func.optimized_data = function()
|
|
node.branches[branch] = null;
|
|
node.branches[branch] = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ else if (node.type === 'ConditionalBranch')
|
|
|
|
+ {
|
|
|
|
+ node.branches = {};
|
|
|
|
+ for (var j = 0; j < cell.values.length; j++)
|
|
|
|
+ {
|
|
|
|
+ var branch = cell.values[j];
|
|
|
|
+ node.branches[branch] = null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
else if (node.type === 'Set')
|
|
else if (node.type === 'Set')
|
|
{
|
|
{
|
|
node.variable = cell.name;
|
|
node.variable = cell.name;
|
|
@@ -952,12 +1089,26 @@ func.ts_data = function(nodes, name) {
|
|
}
|
|
}
|
|
finalString += "tree.addNode(branch);\n";
|
|
finalString += "tree.addNode(branch);\n";
|
|
addDeclaration("let branch : DialogueBranch;\n");
|
|
addDeclaration("let branch : DialogueBranch;\n");
|
|
|
|
+ } else if (node.type == "ConditionalBranch") {
|
|
|
|
+ finalString += "branch = new DialogueBranch(" + JSON.stringify(node.id) + ");\n";
|
|
|
|
+ //finalString += "branch.setVariable(() => { return " + node.variable + ";});\n";
|
|
|
|
+ for (let key in node.branches) {
|
|
|
|
+ let branchCondition = key;
|
|
|
|
+ let branchTarget = node.branches[key];
|
|
|
|
+ if (branchCondition == "_default") {
|
|
|
|
+ finalString += "branch.setNext(" + JSON.stringify(branchTarget) + ");\n";
|
|
|
|
+ } else {
|
|
|
|
+ finalString += "branch.addBranch(" + JSON.stringify(branchTarget) + ", () => { return " + branchCondition + ";});\n";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ finalString += "tree.addNode(branch);\n";
|
|
|
|
+ addDeclaration("let branch : DialogueBranch;\n");
|
|
} else if (node.type == "Set" || node.type == "Function") {
|
|
} else if (node.type == "Set" || node.type == "Function") {
|
|
finalString += "set = new DialogueSet(" + JSON.stringify(node.id) + ");\n";
|
|
finalString += "set = new DialogueSet(" + JSON.stringify(node.id) + ");\n";
|
|
if (node.type == "Function") {
|
|
if (node.type == "Function") {
|
|
- finalString += "set.setFunction(() => {" + node.name + "});\n";
|
|
|
|
|
|
+ finalString += "set.setFunction(() => {\n" + node.name + "\n});\n";
|
|
} else {
|
|
} else {
|
|
- finalString += "set.setFunction(() => { " + node.variable + " = " + node.value + ";});\n";
|
|
|
|
|
|
+ finalString += "set.setFunction(() => {\n " + node.variable + " = " + node.value + ";\n});\n";
|
|
}
|
|
}
|
|
if (node.next != null && node.next != undefined) {
|
|
if (node.next != null && node.next != undefined) {
|
|
finalString += "set.setNext(" + JSON.stringify(node.next) + ");\n";
|
|
finalString += "set.setNext(" + JSON.stringify(node.next) + ");\n";
|
|
@@ -1142,7 +1293,8 @@ func.ts_data = function(nodes, name) {
|
|
state.menu = new nw.Menu();
|
|
state.menu = new nw.Menu();
|
|
state.menu.append(new nw.MenuItem({ label: 'Text', click: func.add_node(joint.shapes.dialogue.Text) }));
|
|
state.menu.append(new nw.MenuItem({ label: 'Text', click: func.add_node(joint.shapes.dialogue.Text) }));
|
|
state.menu.append(new nw.MenuItem({ label: 'Choice', click: func.add_node(joint.shapes.dialogue.Choice) }));
|
|
state.menu.append(new nw.MenuItem({ label: 'Choice', click: func.add_node(joint.shapes.dialogue.Choice) }));
|
|
- state.menu.append(new nw.MenuItem({ label: 'Branch', click: func.add_node(joint.shapes.dialogue.Branch) }));
|
|
|
|
|
|
+ state.menu.append(new nw.MenuItem({ label: 'Switch', click: func.add_node(joint.shapes.dialogue.Branch) }));
|
|
|
|
+ state.menu.append(new nw.MenuItem({ label: 'Branch', click: func.add_node(joint.shapes.dialogue.ConditionalBranch) }));
|
|
state.menu.append(new nw.MenuItem({ label: 'Set', click: func.add_node(joint.shapes.dialogue.Set) }));
|
|
state.menu.append(new nw.MenuItem({ label: 'Set', click: func.add_node(joint.shapes.dialogue.Set) }));
|
|
state.menu.append(new nw.MenuItem({ label: 'Function', click: func.add_node(joint.shapes.dialogue.Function) }));
|
|
state.menu.append(new nw.MenuItem({ label: 'Function', click: func.add_node(joint.shapes.dialogue.Function) }));
|
|
state.menu.append(new nw.MenuItem({ label: 'GoToLabel', click: func.add_node(joint.shapes.dialogue.GoToLabel) }));
|
|
state.menu.append(new nw.MenuItem({ label: 'GoToLabel', click: func.add_node(joint.shapes.dialogue.GoToLabel) }));
|