Deltarune (Chapter Select) script viewer

← back to main script listing

gml_Object_obj_ui_chapter_Create_0

(view raw script w/o annotations or w/e)
1
_chapter = 0;
2
_init = false;
3
_parent = -4;
4
_chapter_choice = -4;
5
_chapter_title = "";
6
_title_enabled = true;
7
_choices = [];
8
_choice_index = 0;
9
_scroll_enabled = false;
10
_input_enabled = false;
11
_enabled = false;
12
_enable_select = false;
13
_enable_confirm = false;
14
_is_highlighted = false;
15
_alpha = 0;
16
_scale = 2;
17
_color = 8421504;
18
_font = (global.lang == "en") ? 2 : 1;
19
_icon_index = UnknownEnum.Value_0;
20
_completed_files = [];
21
_fade_in = false;
22
23
init = function(arg0, arg1)
24
{
25
    _parent = arg0;
26
    _chapter = arg1;
27
    _chapter_title = get_chapter_title(_chapter);
28
    var chapter_text = "Chapter " + string(_chapter);
29
    _chapter_choice = instance_create(x + 20, y + 26, obj_ui_choice);
30
    _chapter_choice.init(id, chapter_text, UnknownEnum.Value_0);
31
    _chapter_choice.y -= 40;
32
    _chapter_choice.disable();
33
    _chapter_choice.set_font(2);
34
    _chapter_choice.set_alpha(0);
35
    var play_text = (global.lang == "en") ? "Play" : "プレイする";
36
    var cancel_text = (global.lang == "en") ? "Do Not" : "もどる";
37
    var confirm_choice = instance_create(x + 220, y + 26, obj_ui_choice);
38
    confirm_choice.init(id, play_text, UnknownEnum.Value_2);
39
    confirm_choice.y -= 40;
40
    confirm_choice.set_alpha(0);
41
    var cancel_choice = instance_create(confirm_choice.x + 180, y + 26, obj_ui_choice);
42
    cancel_choice.init(id, cancel_text, UnknownEnum.Value_3);
43
    cancel_choice.y -= 40;
44
    cancel_choice.set_alpha(0);
45
    _choices = [confirm_choice, cancel_choice];
46
    hide_choices();
47
    y -= 40;
48
    _init = true;
49
};
50
51
get_chapter = function()
52
{
53
    return _chapter;
54
};
55
56
fade_in = function()
57
{
58
    _fade_in = true;
59
};
60
61
enable = function()
62
{
63
    _enabled = true;
64
    _icon_index = get_chapter_icon_index(_chapter);
65
    _chapter_choice.enable();
66
    for (var i = 0; i < 3; i++)
67
    {
68
        var is_completed = scr_completed_chapter_in_slot(_chapter, i);
69
        _completed_files[array_length(_completed_files)] = is_completed;
70
    }
71
    for (var i = 0; i < array_length(_completed_files); i++)
72
    {
73
        var completed = _completed_files[i] == 1;
74
        var current_exists = scr_chapter_save_file_exists_in_slot(_chapter, i);
75
        if (completed && !current_exists)
76
            _completed_files[i] = 2;
77
    }
78
};
79
80
trigger_event = function(arg0, arg1)
81
{
82
    switch (arg1)
83
    {
84
        case UnknownEnum.Value_0:
85
            _chapter_choice.hide_heart();
86
            _chapter_choice.disable_input();
87
            hide_title();
88
            show_choices();
89
            _parent.trigger_event("disable_scroll", arg1);
90
            break;
91
        case UnknownEnum.Value_3:
92
            _chapter_choice.show_heart();
93
            _chapter_choice.enable_input();
94
            hide_choices();
95
            show_title();
96
            _parent.trigger_event("enable_scroll", arg1);
97
            break;
98
        case UnknownEnum.Value_2:
99
            _scroll_enabled = false;
100
            disable_input();
101
            _parent.trigger_event("launch_game", _chapter);
102
            break;
103
    }
104
};
105
106
hide_title = function()
107
{
108
    _title_enabled = false;
109
};
110
111
show_title = function()
112
{
113
    _title_enabled = true;
114
};
115
116
hide_choices = function()
117
{
118
    _scroll_enabled = false;
119
    for (var i = 0; i < array_length(_choices); i++)
120
    {
121
        var choice = _choices[i];
122
        choice.reset();
123
        choice.visible = false;
124
    }
125
};
126
127
show_choices = function()
128
{
129
    _scroll_enabled = true;
130
    _choice_index = 0;
131
    highlight_choice();
132
};
133
134
highlight_choice = function()
135
{
136
    for (var i = 0; i < array_length(_choices); i++)
137
    {
138
        var choice = _choices[i];
139
        choice.visible = true;
140
        choice.reset();
141
        if (i == _choice_index)
142
            choice.highlight();
143
    }
144
};
145
146
enable_input = function()
147
{
148
    _input_enabled = true;
149
};
150
151
disable_input = function()
152
{
153
    _input_enabled = false;
154
};
155
156
disable_all = function()
157
{
158
    disable_input();
159
    _chapter_choice.disable_input();
160
    for (var i = 0; i < array_length(_choices); i++)
161
    {
162
        var choice = _choices[i];
163
        choice.disable_input();
164
    }
165
};
166
167
highlight = function()
168
{
169
    _is_highlighted = true;
170
    _color = 65535;
171
    _chapter_choice.highlight();
172
    enable_input();
173
};
174
175
reset = function()
176
{
177
    _is_highlighted = false;
178
    _color = 16777215;
179
    _chapter_choice.reset();
180
    disable_input();
181
};
182
183
enum UnknownEnum
184
{
185
    Value_0,
186
    Value_2 = 2,
187
    Value_3
188
}