Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
loeasy68
GitHub Repository: loeasy68/loeasy68.github.io
Path: blob/main/website/GAUSS/js/dialog-manager.js
2941 views
1
var editorMapIdDialog = {};
2
var editorDialogsCount = 0;
3
4
var Dialog = function(id)
5
{
6
this.id = id;
7
this.currentSubDialog = 'root';
8
this.subdialogs = { 'root' : [] };
9
this.hidden = false;
10
};
11
12
//TODO: fix dialog lines ordering
13
Dialog.prototype.addDialogChoice = function(subDialogId, choice, pos)
14
{
15
if(subDialogId.length == 0)
16
subDialogId = 'root';
17
else if(this.subdialogs[subDialogId] == undefined)
18
this.subdialogs[subDialogId] = [];
19
if(!pos)
20
{
21
this.subdialogs[subDialogId].push(choice);
22
return;
23
}
24
this.subdialogs[subDialogId].splice(pos, 0, choice);
25
};
26
27
Dialog.prototype.removeDialogChoice = function(subDialogId, pos)
28
{
29
if(this.subdialogs[subDialogId] && this.subdialogs[subDialogId].length)
30
this.subdialogs[subDialogId].splice(pos, 1);
31
};
32
33
Dialog.prototype.copy = function(d)
34
{
35
this.id = d.id;
36
this.currentSubDialog = d.currentSubDialog;
37
this.subdialogs = d.subdialogs;
38
};
39
40
var DialogChoice = function(text, script, quit, open, hidden, showOnce, hideOnce)
41
{
42
this.sentence = text;
43
this.script = script;
44
this.quit = quit;
45
this.open = open;
46
this.hidden = hidden;
47
this.showOnce = showOnce;
48
this.chooseOnce = hideOnce;
49
};
50
51
var deleteDialog = function(id)
52
{
53
delete editorMapIdDialog[id];
54
};
55
56
57