Deltarune (Chapter 2) script viewer

← back to main script listing

gml_Object_obj_custommenu_Draw_0

(view raw script w/o annotations or w/e)
1
xx = __view_get(e__VW.XView, 0);
2
yy = __view_get(e__VW.YView, 0);
3
for (m = 0; m < menuMax; m++)
4
{
5
    drawmenu = 1;
6
    if (menuDisplayCondition[m] == 1 && menu != m)
7
        drawmenu = 0;
8
    if (menuDisplayCondition[m] == 2 && menu < m)
9
        drawmenu = 0;
10
    if (drawmenu)
11
    {
12
        wrap = 0;
13
        vwrap = 0;
14
        minj = menuMinimumID[m] + menuScrollCurrent[m];
15
        maxj = menuMinimumID[m] + menuScrollCurrent[m] + menuPageSize[m];
16
        if (maxj >= (menuMaximumID[m] + 1))
17
            maxj = menuMaximumID[m] + 1;
18
        if (menuBoxDraw[m] == 1)
19
        {
20
            draw_set_color(c_white);
21
            draw_rectangle(xx + menuBoxDrawX1[m], yy + menuBoxDrawY1[m], xx + menuBoxDrawX2[m], yy + menuBoxDrawY2[m], false);
22
            draw_set_color(c_black);
23
            draw_rectangle(xx + menuBoxDrawX1[m] + 4, yy + menuBoxDrawY1[m] + 4, (xx + menuBoxDrawX2[m]) - 4, (yy + menuBoxDrawY2[m]) - 4, false);
24
            trimove = round((sin(siner / 6) * 2) / 2) * 2;
25
            if (menuVEdgeBehavior[m] == 2 && menu == m)
26
            {
27
                if (maxj < (menuMaximumID[m] + 1))
28
                    draw_sprite_ext(spr_custommenu_arrow, 0, xx + ((menuBoxDrawX1[m] + menuBoxDrawX2[m]) / 2), yy + menuBoxDrawY2[m] + trimove, 2, 2, 0, c_white, 1);
29
                if (minj > menuMinimumID[m])
30
                    draw_sprite_ext(spr_custommenu_arrow, 0, xx + ((menuBoxDrawX1[m] + menuBoxDrawX2[m]) / 2), (yy + menuBoxDrawY1[m]) - trimove, 2, -2, 0, c_white, 1);
31
            }
32
            if (menuHEdgeBehavior[m] == 2 && menu == m)
33
            {
34
                draw_sprite_ext(spr_custommenu_arrow, 0, xx + menuBoxDrawX1[m] + trimove, yy + ((menuBoxDrawY1[m] + menuBoxDrawY2[m]) / 2), 2, 2, 270, c_white, 1);
35
                draw_sprite_ext(spr_custommenu_arrow, 0, (xx + menuBoxDrawX2[m]) - trimove, yy + ((menuBoxDrawY1[m] + menuBoxDrawY2[m]) / 2), 2, -2, 270, c_white, 1);
36
            }
37
        }
38
        draw_set_font(menuTextFont[m]);
39
        for (j = 0; j < menuHeaderTextAmount[m]; j++)
40
        {
41
            draw_set_color(menuHeaderColor[m][j]);
42
            textxscale = 1;
43
            textyscale = 1;
44
            if (menuHeaderWidth[m][j] > 0)
45
                textxscale = menuHeaderWidth[m][j];
46
            if (menuHeaderWidth[m][j] >= 5)
47
                textxscale = clamp(menuHeaderWidth[m] / string_width(string_hash_to_newline(menuHeaderText[m][j])), 0.5, 1);
48
            if (menuHeaderHeight[m][j] > 0)
49
                textyscale = menuHeaderHeight[m][j];
50
            draw_text_transformed(xx + menuHeaderX[m][j], yy + menuHeaderY[m][j], string_hash_to_newline(menuHeaderText[m][j]), textxscale, textyscale, 0);
51
        }
52
        if (m == menu)
53
        {
54
            if (optionTopComment[m][menuCoord[m]] != " ")
55
            {
56
                scr_84_set_draw_font
scr_84_set_draw_font

function scr_84_set_draw_font(arg0) { global.chemg_font = arg0; draw_set_font(scr_84_get_font(arg0)); }
("mainbig");
57
                draw_set_color(c_black);
58
                draw_rectangle(xx - 10, yy - 10, xx + 700, yy + 120, false);
59
                draw_set_color(c_white);
60
                if (display_buttons)
61
                {
62
                    draw_sprite_ext(scr_getbuttonsprite
scr_getbuttonsprite

function scr_getbuttonsprite(arg0, arg1) { var control = arg0; var isString = arg1; var button = noone; var is_dualshock = os_type == os_ps4 || global.gamepad_type == "Sony DualShock 4"; var is_dualsense = os_type == os_ps5 || global.gamepad_type == "DualSense Wireless Controller"; var button_sprite = button_questionmark; var invert = is_dualshock && (global.typer == 50 || global.typer == 70 || global.typer == 71); if (isString) { if (control == "A") { button_sprite = button_xbox_left; if (scr_is_switch_os()) { button_sprite = button_switch_left_0; } else if (is_dualshock || is_dualsense) { button_sprite = invert ? button_ps4_dpad_left_dark : button_ps4_dpad_left; if (is_dualsense) button_sprite = invert ? button_ps4_dpad_left_dark : button_ps5_dpad_left; } return button_sprite; } if (control == "D") { button_sprite = button_xbox_right; if (scr_is_switch_os()) { button_sprite = button_switch_right_0; } else if (is_dualshock || is_dualsense) { button_sprite = invert ? button_ps4_dpad_right_dark : button_ps4_dpad_right; if (is_dualsense) button_sprite = invert ? button_ps4_dpad_right_dark : button_ps5_dpad_right; } return button_sprite; } if (control == "W") { button_sprite = button_xbox_up; if (scr_is_switch_os()) { button_sprite = button_switch_up_0; } else if (is_dualshock || is_dualsense) { button_sprite = invert ? button_ps4_dpad_up_dark : button_ps4_dpad_up; if (is_dualsense) button_sprite = invert ? button_ps4_dpad_up_dark : button_ps5_dpad_up; } return button_sprite; } if (control == "S") { button_sprite = button_xbox_down; if (scr_is_switch_os()) { button_sprite = button_switch_down_0; } else if (is_dualshock || is_dualsense) { button_sprite = invert ? button_ps4_dpad_down_dark : button_ps4_dpad_down; if (is_dualsense) button_sprite = invert ? button_ps4_dpad_down_dark : button_ps5_dpad_down; } return button_sprite; } if (control == "l") { button_sprite = button_xbox_left_bumper; if (is_dualshock || is_dualsense) { button_sprite = button_ps4_l1; if (is_dualsense) button_sprite = button_ps5_l1; } if (scr_is_switch_os()) button_sprite = button_switch_l_0; return button_sprite; } if (control == "L") { button_sprite = button_xbox_left_trigger; if (is_dualshock || is_dualsense) { button_sprite = button_ps4_l2; if (is_dualsense) button_sprite = button_ps5_l2; } if (scr_is_switch_os()) button_sprite = button_switch_zl_0; return button_sprite; } if (control == "r") { button_sprite = button_xbox_right_bumper; if (is_dualshock || is_dualsense) ...
(global.input_g[4], false), 0, xx + 20, yy + 22, 2, 2, 0, c_white, 1);
63
                    var button_x_offset = (global.lang == "en") ? 0 : -40;
64
                    draw_sprite_ext(scr_getbuttonsprite
scr_getbuttonsprite

function scr_getbuttonsprite(arg0, arg1) { var control = arg0; var isString = arg1; var button = noone; var is_dualshock = os_type == os_ps4 || global.gamepad_type == "Sony DualShock 4"; var is_dualsense = os_type == os_ps5 || global.gamepad_type == "DualSense Wireless Controller"; var button_sprite = button_questionmark; var invert = is_dualshock && (global.typer == 50 || global.typer == 70 || global.typer == 71); if (isString) { if (control == "A") { button_sprite = button_xbox_left; if (scr_is_switch_os()) { button_sprite = button_switch_left_0; } else if (is_dualshock || is_dualsense) { button_sprite = invert ? button_ps4_dpad_left_dark : button_ps4_dpad_left; if (is_dualsense) button_sprite = invert ? button_ps4_dpad_left_dark : button_ps5_dpad_left; } return button_sprite; } if (control == "D") { button_sprite = button_xbox_right; if (scr_is_switch_os()) { button_sprite = button_switch_right_0; } else if (is_dualshock || is_dualsense) { button_sprite = invert ? button_ps4_dpad_right_dark : button_ps4_dpad_right; if (is_dualsense) button_sprite = invert ? button_ps4_dpad_right_dark : button_ps5_dpad_right; } return button_sprite; } if (control == "W") { button_sprite = button_xbox_up; if (scr_is_switch_os()) { button_sprite = button_switch_up_0; } else if (is_dualshock || is_dualsense) { button_sprite = invert ? button_ps4_dpad_up_dark : button_ps4_dpad_up; if (is_dualsense) button_sprite = invert ? button_ps4_dpad_up_dark : button_ps5_dpad_up; } return button_sprite; } if (control == "S") { button_sprite = button_xbox_down; if (scr_is_switch_os()) { button_sprite = button_switch_down_0; } else if (is_dualshock || is_dualsense) { button_sprite = invert ? button_ps4_dpad_down_dark : button_ps4_dpad_down; if (is_dualsense) button_sprite = invert ? button_ps4_dpad_down_dark : button_ps5_dpad_down; } return button_sprite; } if (control == "l") { button_sprite = button_xbox_left_bumper; if (is_dualshock || is_dualsense) { button_sprite = button_ps4_l1; if (is_dualsense) button_sprite = button_ps5_l1; } if (scr_is_switch_os()) button_sprite = button_switch_l_0; return button_sprite; } if (control == "L") { button_sprite = button_xbox_left_trigger; if (is_dualshock || is_dualsense) { button_sprite = button_ps4_l2; if (is_dualsense) button_sprite = button_ps5_l2; } if (scr_is_switch_os()) button_sprite = button_switch_zl_0; return button_sprite; } if (control == "r") { button_sprite = button_xbox_right_bumper; if (is_dualshock || is_dualsense) ...
(global.input_g[5], false), 0, xx + 190 + button_x_offset, yy + 22, 2, 2, 0, c_white, 1);
65
                    var x_offset = (global.lang == "en") ? 0 : -36;
66
                    draw_text(xx + 18 + x_offset, yy + 20, string_hash_to_newline(optionTopComment[m][menuCoord[m]]));
67
                }
68
                else
69
                {
70
                    draw_text(xx + 20, yy + 20, string_hash_to_newline(optionTopComment[m][menuCoord[m]]));
71
                }
72
            }
73
        }
74
        draw_set_font(menuTextFont[m]);
75
        for (j = minj; j < maxj; j++)
76
        {
77
            if (m == menu)
78
            {
79
                if (optionSelectable[m][j] == 0)
80
                    draw_set_color(menuTextColorUnselectable[m]);
81
                else if (menuCoord[m] == j)
82
                    draw_set_color(menuTextColorHover[m]);
83
                else
84
                    draw_set_color(menuTextColor[m]);
85
            }
86
            else if (optionSelected[m][j] == 1)
87
            {
88
                draw_set_color(menuTextColorSelected[m]);
89
            }
90
            else
91
            {
92
                draw_set_color(menuTextColorInactive[m]);
93
            }
94
            if (menuSpacingOverride[m] == 0)
95
            {
96
                optionX[m][j] = menuX[m] + (wrap * menuSpacingX[m]);
97
                optionY[m][j] = menuY[m] + (vwrap * menuSpacingY[m]);
98
            }
99
            textx = optionX[m][j] + menuTextOffsetX[m];
100
            texty = optionY[m][j] + menuTextOffsetY[m];
101
            textxscale = 1;
102
            textyscale = 1;
103
            if (menuTextXScale[m] > 0)
104
                textxscale = menuTextXScale[m];
105
            if (menuTextXScale[m] >= 5)
106
                textxscale = clamp(menuTextXScale[m] / string_width(string_hash_to_newline(optionText[m][j])), 0.5, 1);
107
            if (menuTextYScale[m] > 0)
108
                textyscale = menuTextYScale[m];
109
            draw_text_transformed(textx, texty, string_hash_to_newline(optionText[m][j]), textxscale, textyscale, 0);
110
            wrap++;
111
            if (wrap >= menuWidth[m])
112
            {
113
                wrap = 0;
114
                vwrap++;
115
            }
116
            if (optionCommentA[m][j] != " ")
117
            {
118
                draw_set_color(optionCommentAColor[m][j]);
119
                textxscale = 1;
120
                textyscale = 1;
121
                if (optionCommentAWidth[m][j] > 0)
122
                    textxscale = optionCommentAWidth[m][j];
123
                if (optionCommentAWidth[m][j] >= 5)
124
                    textxscale = clamp(optionCommentAWidth[m][j] / string_width(string(optionText[m][j])), 0.5, 1);
125
                if (optionCommentAHeight[m][j] > 0)
126
                    textyscale = optionCommentAHeight[m][j];
127
                draw_text_transformed(textx + optionCommentAXOffset[m][j], texty + optionCommentAYOffset[m][j], string(optionCommentA[m][j]), textxscale, textyscale, 0);
128
            }
129
            if (optionCommentB[m][j] != " ")
130
            {
131
                draw_set_color(optionCommentBColor[m][j]);
132
                textxscale = 1;
133
                textyscale = 1;
134
                if (optionCommentBWidth[m][j] > 0)
135
                    textxscale = optionCommentBWidth[m][j];
136
                if (optionCommentBWidth[m][j] >= 5)
137
                    textxscale = clamp(optionCommentBWidth[m][j] / string_width(string(optionText[m][j])), 0.5, 1);
138
                if (optionCommentBHeight[m][j] > 0)
139
                    textyscale = optionCommentBHeight[m][j];
140
                draw_text_transformed(textx + optionCommentBXOffset[m][j], texty + optionCommentBYOffset[m][j], string(optionCommentB[m][j]), textxscale, textyscale, 0);
141
            }
142
            if (optionCommentC[m][j] != " ")
143
            {
144
                draw_set_color(optionCommentCColor[m][j]);
145
                textxscale = 1;
146
                textyscale = 1;
147
                if (optionCommentCWidth[m][j] > 0)
148
                    textxscale = optionCommentCWidth[m][j];
149
                if (optionCommentCWidth[m][j] >= 5)
150
                    textxscale = clamp(optionCommentCWidth[m][j] / string_width(string(optionText[m][j])), 0.5, 1);
151
                if (optionCommentCHeight[m][j] > 0)
152
                    textyscale = optionCommentCHeight[m][j];
153
                draw_text_transformed(textx + optionCommentCXOffset[m][j], texty + optionCommentCYOffset[m][j], string(optionCommentC[m][j]), textxscale, textyscale, 0);
154
            }
155
        }
156
    }
157
}
158
idealHeartX = optionX[menu][menuCoord[menu]];
159
heartX = lerp(heartX, idealHeartX, 0.5);
160
if (abs(heartX - idealHeartX) < 2)
161
    heartX = idealHeartX;
162
idealHeartY = optionY[menu][menuCoord[menu]];
163
heartY = lerp(heartY, idealHeartY, 0.5);
164
if (abs(heartY - idealHeartY) < 2)
165
    heartY = idealHeartY;
166
draw_sprite(menuSprite, 0, heartX, heartY + 8);
167
if (menuCoord[menu] >= ((menuWidth[menu] * (menuHeight[menu] - 1)) + menuScrollCurrent[menu]))
168
    draw_set_color(c_lime);
169
if (menuCoord[menu] < (menuWidth[menu] + menuScrollCurrent[menu]))
170
    draw_set_color(c_fuchsia);
171
if ((menuCoord[menu] % menuWidth[menu]) == (menuWidth[menu] - 1))
172
    draw_set_color(c_orange);
173
siner++;
174
175
enum e__VW
176
{
177
    XView,
178
    YView,
179
    WView,
180
    HView,
181
    Angle,
182
    HBorder,
183
    VBorder,
184
    HSpeed,
185
    VSpeed,
186
    Object,
187
    Visible,
188
    XPort,
189
    YPort,
190
    WPort,
191
    HPort,
192
    Camera,
193
    SurfaceID
194
}