Deltarune (Chapter Select) script viewer

← back to main script listing

gml_Object_obj_screen_start_Create_0

(view raw script w/o annotations or w/e)
1
_parent = -4;
2
_init = false;
3
_text = "";
4
_y_pos = 220;
5
_input_enabled = false;
6
_choices = [];
7
_choice_index = 0;
8
_alpha = 0;
9
_scale = 1;
10
_color = 16777215;
11
_font = (global.lang == "en") ? 2 : 1;
12
_text_prompt_y_pos = (global.lang == "en") ? 16 : 8;
13
_line_height = (global.lang == "en") ? 16 : 18;
14
_fade_in = false;
15
_timer = 0;
16
_version_display = -4;
17
_register_display = false;
18
_register_text = [];
19
_prompt_text = [];
20
21
init = function(arg0, arg1, arg2 = [], arg3 = 0, arg4 = 0)
22
{
23
    _parent = arg0;
24
    _text = arg1;
25
    if (string_pos("~", _text) != 0)
26
    {
27
        _register_display = true;
28
        _prompt_text = string_split(_text, "#");
29
        _register_text = string_split(_prompt_text[0], "~");
30
    }
31
    _y_pos -= 40;
32
    for (var i = 0; i < array_length(arg2); i++)
33
    {
34
        var choice_data = arg2[i];
35
        var choice = instance_create(280 + arg3, 260 + (i * 40) + arg4, obj_ui_choice);
36
        choice.init(id, choice_data.choice_text, choice_data.choice_value);
37
        choice.set_alpha(0);
38
        choice.align_center();
39
        choice.y -= 40;
40
        _choices[array_length(_choices)] = choice;
41
    }
42
    _version_display = instance_create(x, 410, obj_ui_version);
43
    _version_display.set_alpha(0);
44
    init = true;
45
    for (var i = 0; i < array_length(_choices); i++)
46
    {
47
        var choice = _choices[i];
48
        if (i == _choice_index)
49
        {
50
            choice.highlight();
51
            choice.disable_input();
52
        }
53
        else
54
        {
55
            choice.reset();
56
        }
57
    }
58
};
59
60
fade_in = function()
61
{
62
    _fade_in = true;
63
};
64
65
set_alpha = function(arg0)
66
{
67
    _alpha = arg0;
68
};
69
70
enable_input = function()
71
{
72
    _input_enabled = true;
73
};
74
75
disable_input = function()
76
{
77
    _input_enabled = false;
78
    for (var i = 0; i < array_length(_choices); i++)
79
    {
80
        var choice = _choices[i];
81
        choice.disable_input();
82
    }
83
};
84
85
trigger_event = function(arg0, arg1)
86
{
87
    disable_input();
88
    _parent.trigger_event(arg0, arg1);
89
};
90
91
enable_select = function()
92
{
93
    for (var i = 0; i < array_length(_choices); i++)
94
    {
95
        var choice = _choices[i];
96
        if (i == _choice_index)
97
            choice.highlight();
98
        else
99
            choice.reset();
100
    }
101
};
102
103
clean_up = function()
104
{
105
    var i = array_length(_choices) - 1;
106
    while (i >= 0)
107
    {
108
        var choice = _choices[i];
109
        with (choice)
110
            instance_destroy();
111
        i--;
112
    }
113
    _choices = [];
114
    instance_destroy();
115
};