Deltarune (Chapter 3) script viewer

← back to main script listing

gml_Object_obj_battleblcon_Draw_0

(view raw script w/o annotations or w/e)
1
if (i_ex(mywriter))
2
{
3
    mywriter.depth = depth - 5;
4
    if (remmsgno != obj_writer.msgno)
5
        reformatted = 0;
6
    if (auto_length == 0)
7
    {
8
        init = 1;
9
        reformatted = 1;
10
    }
11
    if (reformatted == 0)
12
    {
13
        if (mywriter.formatted == 0)
14
        {
15
            with (mywriter)
16
                event_user(5);
17
        }
18
        if (mywriter.formatted == 1)
19
        {
20
            if (init == 0)
21
            {
22
                initwritingx = mywriter.writingx;
23
                initwritingy = mywriter.writingy;
24
                init = 1;
25
            }
26
            writingx = mywriter.writingx;
27
            writingy = mywriter.writingy;
28
            stringmax = mywriter.stringmax;
29
            hspace = mywriter.hspace;
30
            vspace = mywriter.vspace;
31
            linecount = mywriter.linecount;
32
            balloonwidth = (stringmax * hspace) + 10;
33
            balloonheight = ((linecount + 1) * vspace) + 5;
34
            if (global.lang == "ja")
35
            {
36
                var checkstring = mywriter.mystring;
37
                var spacing = mywriter.hspace;
38
                var stringlength = string_length(checkstring);
39
                var newmaxlength = 0;
40
                var currentlength = 0;
41
                for (var ii = 1; ii < (stringlength + 1); ii += 1)
42
                {
43
                    var mychar = string_char_at(checkstring, ii);
44
                    if (mychar == "&" || mychar == "\n")
45
                    {
46
                        currentlength = 0;
47
                    }
48
                    else if (mychar == "^" || mychar == "*")
49
                    {
50
                        ii++;
51
                    }
52
                    else if (mychar == "\\")
53
                    {
54
                        ii += 2;
55
                    }
56
                    else if (mychar == "/" || mychar == "%")
57
                    {
58
                    }
59
                    else if (ord(mychar) < 256 || (ord(mychar) >= 65377 && ord(mychar) <= 65439))
60
                    {
61
                        currentlength += (spacing * 0.5);
62
                    }
63
                    else
64
                    {
65
                        currentlength += spacing;
66
                    }
67
                    if (currentlength >= newmaxlength)
68
                        newmaxlength = currentlength;
69
                }
70
                balloonwidth = newmaxlength + 10;
71
            }
72
            if (side == 1)
73
            {
74
                mywriter.writingx = initwritingx - (balloonwidth + 20);
75
                mywriter.writingy = initwritingy - (balloonheight / 2);
76
                writingx = initwritingx - (balloonwidth + 20);
77
                writingy = initwritingy - (balloonheight / 2);
78
            }
79
            if (side == -1)
80
            {
81
                xoffset = 20;
82
                mywriter.writingx = initwritingx;
83
                mywriter.writingy = initwritingy - (balloonheight / 2);
84
                writingx = initwritingx;
85
                writingy = initwritingy - (balloonheight / 2);
86
            }
87
            if (side == 2)
88
            {
89
                mywriter.writingx = initwritingx - (balloonwidth / 2);
90
                mywriter.writingy = initwritingy - (balloonheight + 20);
91
                writingx = initwritingx - (balloonwidth / 2);
92
                writingy = initwritingy - (balloonheight + 20);
93
            }
94
        }
95
    }
96
    if (auto_length == 0)
97
        draw_self();
98
    if (auto_length == 1 && init == 1)
99
    {
100
        blconscale = 1;
101
        if (balloonheight < 40)
102
            blconscale = 0.5;
103
        if (side == 1)
104
            draw_sprite_ext(spr_battleblcon_parts, 4, x, y, 1, blconscale, 0, c_white, 1);
105
        if (side == -1)
106
            draw_sprite_ext(spr_battleblcon_parts, 4, x - xoffset, y, -1, blconscale, 0, c_white, 1);
107
        if (side == 2)
108
            draw_sprite_ext(spr_battleblcon_parts, 4, x, y, 1, 1, -90, c_white, 1);
109
        draw_set_color(c_white);
110
        var _y = 0;
111
        if (global.lang == "ja")
112
            _y = 1;
113
        draw_rectangle(writingx - 10, (writingy - 5) + _y, writingx + balloonwidth, ((writingy + balloonheight) - 5) + _y, false);
114
        draw_rectangle(writingx - 5, (writingy - 10) + _y, (writingx + balloonwidth) - 5, writingy + balloonheight + _y, false);
115
    }
116
    remmsgno = mywriter.msgno;
117
}