Pixel-Composer/objects/o_dialog_release_note/Create_0.gml

109 lines
3.1 KiB
Text
Raw Normal View History

2022-01-13 05:24:03 +01:00
/// @description init
event_inherited();
#region data
2022-12-18 03:20:38 +01:00
dialog_w = ui(720);
dialog_h = ui(480);
2022-01-13 05:24:03 +01:00
destroy_on_click_out = true;
note = "";
2023-08-16 20:16:31 +02:00
var _link = $"https://gist.githubusercontent.com/Ttanasart-pt/f21a140906a60c6e12c99ebfecec1645/raw/{VERSION_STRING}";
note_get = http_get(_link);
2022-01-13 05:24:03 +01:00
2022-11-03 11:44:49 +01:00
sp_note = new scrollPane(dialog_w - ui(80), dialog_h - ui(88), function(_y, _m) {
2022-11-18 03:20:31 +01:00
draw_clear_alpha(COLORS.panel_bg_clear, 0);
2023-08-16 20:16:31 +02:00
BLEND_ALPHA_MULP
var xx = ui(8);
var yy = ui(8);
var ww = sp_note.surface_w - ui(16);
2022-01-13 05:24:03 +01:00
var txt = note;
2023-08-16 20:16:31 +02:00
var lines = string_split(txt, "\n");
for( var i = 0, n = array_length(lines); i < n; i++ ) {
var line = lines[i];
var _stx = string_split(string_trim(line), " ");
var _line = line;
2022-01-13 05:24:03 +01:00
2023-08-16 20:16:31 +02:00
if(array_length(_stx) <= 1) {
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
draw_text_line(xx + 0, _y + yy, line, -1, ww);
yy += string_height_ext(_line, -1, ww);
2022-01-13 05:24:03 +01:00
} else {
2023-08-16 20:16:31 +02:00
var _cont = array_create(array_length(_stx) - 1);
for( var j = 1, m = array_length(_stx); j < m; j++ )
_cont[j - 1] = _stx[j];
_line = string_join_ext(" ", _cont);
switch(_stx[0]) {
case "#" :
draw_set_text(f_h3, fa_left, fa_top, COLORS._main_text_sub);
yy += (!!i) * ui(16);
draw_text_line(xx, _y + yy, _line, -1, ww);
2022-01-13 05:24:03 +01:00
2023-08-16 20:16:31 +02:00
yy += ui(4);
break;
case "##" :
draw_set_text(f_h5, fa_left, fa_top, COLORS._main_text_sub);
var _h = string_height_ext(_line, -1, ww);
yy += (!!i) * ui(16);
2023-09-02 12:47:27 +02:00
draw_sprite_stretched_ext(THEME.group_label, 1, xx, _y + yy - ui(4), ww, _h + ui(8), COLORS._main_icon, 1);
2023-08-16 20:16:31 +02:00
draw_text_line(xx + ui(16), _y + yy, _line, -1, ww);
yy += ui(8);
break;
case "###" :
draw_set_text(f_p0b, fa_left, fa_top, COLORS._main_accent);
yy += (!!i) * ui(8);
draw_text_line(xx + ui(16), _y + yy, _line, -1, ww);
yy += ui(4);
break;
case "-" :
var _x = xx + ui(28);
if(string_char_at(line, 1) == "\t")
_x += ui(16);
draw_sprite_ui_uniform(THEME.text_bullet, 0, _x - ui(12), _y + yy + ui(18), 1, COLORS._main_icon);
var _lx = _x;
2023-09-17 13:23:24 +02:00
var _topic = false;
2023-08-16 20:16:31 +02:00
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
for( var j = 1, m = array_length(_stx); j < m; j++ ) {
var _word = (j > 1? " " : "") + _stx[j];
if(_x + string_width(_word) > ww) {
yy += line_get_height();
_x = _lx;
}
if(string_char_at(_word, 1) == "[")
2023-09-17 13:23:24 +02:00
_topic = true;
draw_set_color(_topic? COLORS._main_text_accent : COLORS._main_text);
draw_text_add(_x, _y + yy, _word);
2023-08-16 20:16:31 +02:00
_x += string_width(_word);
2023-09-17 13:23:24 +02:00
if(string_char_last(_word) == "]")
_topic = false;
2023-08-16 20:16:31 +02:00
}
yy += line_get_height();
break;
default :
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
draw_text_line(xx + 0, _y + yy, _line, -1, ww);
break;
}
if(_stx[0] != "-")
yy += string_height_ext(_line, -1, ww);
2022-01-13 05:24:03 +01:00
}
}
2022-12-18 03:20:38 +01:00
BLEND_NORMAL
2022-11-03 11:44:49 +01:00
return yy + ui(64);
2022-01-13 05:24:03 +01:00
})
#endregion