Pixel-Composer/objects/o_dialog_release_note/Create_0.gml

196 lines
5.9 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;
2024-04-09 05:32:00 +02:00
pages = [ "Release note", "Downloads" ];
page = 0;
2022-01-13 05:24:03 +01:00
2024-04-09 05:32:00 +02:00
#endregion
#region note
note_get = http_get($"https://gist.githubusercontent.com/Ttanasart-pt/f21a140906a60c6e12c99ebfecec1645/raw/{VERSION_STRING}");
note = "";
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) {
2024-04-09 05:32:00 +02:00
draw_clear_alpha(COLORS.dialog_splash_badge, 1);
2023-08-16 20:16:31 +02:00
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-11-03 11:44:49 +01:00
return yy + ui(64);
2022-01-13 05:24:03 +01:00
})
2024-04-09 05:32:00 +02:00
#endregion
#region downloads
dl_get = http_get(global.KEYS.download_links);
dls = [];
downloading = {};
sp_dl = new scrollPane(dialog_w - ui(80), dialog_h - ui(88), function(_y, _m) {
draw_clear_alpha(COLORS.dialog_splash_badge, 1);
var xx = ui(8);
var yy = _y + ui(8);
var ww = sp_dl.surface_w - ui(16);
var hh = ui(56);
for( var i = 0, n = array_length(dls); i < n; i++ ) {
var dl = dls[i];
var vr = dl.version;
2024-05-07 10:54:34 +02:00
hh = dl.status == 0? ui(36) : ui(56);
2024-04-09 05:32:00 +02:00
var hov = sHOVER && point_in_rectangle(_m[0], _m[1], xx, yy, xx + ww, yy + hh);
draw_sprite_stretched(THEME.ui_panel_bg, 0, xx, yy, ww, hh);
if(dl.status == 0 && hov) {
draw_sprite_stretched_ext(THEME.ui_panel_fg, 1, xx, yy, ww, hh, COLORS._main_accent, 1);
if(mouse_press(mb_left, sFOCUS)) {
2024-04-10 05:02:23 +02:00
var path = get_save_filename_ext("Compressed zip (.zip)| *.zip", $"PixelComposer {vr}.zip", "", "Download location");
2024-04-09 05:32:00 +02:00
if(path != "") {
dl.status = 1;
dl.download_path = path;
var _get = http_get_file(dl.link, path);
downloading[$ _get] = dl;
}
}
} else if(dl.status == 2 && hov) {
draw_sprite_stretched_ext(THEME.ui_panel_fg, 1, xx, yy, ww, hh, COLORS._main_accent, 1);
if(mouse_press(mb_left, sFOCUS))
shellOpenExplorer(filename_dir(dl.download_path));
2024-05-07 10:54:34 +02:00
} else if(dl.status == -1 && hov) {
draw_sprite_stretched_ext(THEME.ui_panel_fg, 1, xx, yy, ww, hh, COLORS._main_accent, 1);
if(mouse_press(mb_left, sFOCUS))
url_open(dl.download_path);
2024-04-09 05:32:00 +02:00
} else
draw_sprite_stretched_ext(THEME.ui_panel_fg, 1, xx, yy, ww, hh, COLORS.node_display_text_frame_outline, 1);
draw_set_text(f_p0b, fa_left, fa_top, dl.status == 2? COLORS._main_text : COLORS._main_text_sub);
draw_text(xx + ui(8), yy + ui(8), vr);
if(dl.status == 1) {
var _bw = ww - ui(16);
var _bh = ui(12);
var _bx = xx + ui(8);
var _by = yy + hh - _bh - ui(8);
var _prg = dl.size_total == 0? 0 : dl.size_downloaded / dl.size_total;
draw_sprite_stretched(THEME.progress_bar, 0, _bx, _by, _bw, _bh);
draw_sprite_stretched(THEME.progress_bar, 1, _bx, _by, _bw * _prg, _bh);
} else if(dl.status == 2) {
draw_set_text(f_p1, fa_left, fa_top, COLORS._main_text_sub);
draw_text_cut(xx + ui(8), yy + ui(32), dl.download_path, ww - ui(16));
2024-05-07 10:54:34 +02:00
} else if(dl.status == -1) {
draw_set_text(f_p1, fa_left, fa_top, COLORS._main_value_negative);
draw_text_cut(xx + ui(8), yy + ui(32), $"HTTP get error : open the download link in browser.", ww - ui(16));
2024-04-09 05:32:00 +02:00
}
if(dl.status) {
draw_set_text(f_p1, fa_right, fa_top, COLORS._main_text_sub);
draw_text(xx + ww - ui(8), yy + ui(10), string_byte_format(dl.size_total));
}
yy += hh + ui(4);
}
return yy + ui(64) - _y;
})
2022-01-13 05:24:03 +01:00
#endregion