Pixel-Composer/objects/o_dialog_file_name_collection/Draw_64.gml

203 lines
7.0 KiB
Plaintext
Raw Normal View History

2023-02-14 02:48:33 +01:00
/// @description init
#region base UI
2024-09-12 12:42:35 +02:00
// DIALOG_DRAW_BG
// if(sFOCUS)
// DIALOG_DRAW_FOCUS
draw_sprite_stretched(THEME.textbox, 3, dialog_x, dialog_y, dialog_w, dialog_h);
if(sFOCUS) draw_sprite_stretched_ext(THEME.textbox, 2, dialog_x, dialog_y, dialog_w, dialog_h, COLORS._main_accent);
else draw_sprite_stretched(THEME.textbox, 1, dialog_x, dialog_y, dialog_w, dialog_h);
2023-02-14 02:48:33 +01:00
#endregion
#region draw TB
2024-09-12 12:42:35 +02:00
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_icon);
draw_text_add(dialog_x + ui(8), dialog_y + ui(24), __txt("Name"));
2023-02-14 02:48:33 +01:00
t_desc.interactable = !STEAM_UGC_ITEM_UPLOADING;
2023-02-17 04:48:54 +01:00
t_auth.interactable = !STEAM_UGC_ITEM_UPLOADING;
t_cont.interactable = !STEAM_UGC_ITEM_UPLOADING;
2023-02-14 02:48:33 +01:00
t_tags.interactable = !STEAM_UGC_ITEM_UPLOADING;
t_alias.interactable = !STEAM_UGC_ITEM_UPLOADING;
tb_name.interactable = !STEAM_UGC_ITEM_UPLOADING;
2023-06-21 20:36:53 +02:00
tb_name.setFocusHover(sFOCUS, sHOVER);
2023-02-14 02:48:33 +01:00
tb_name.register();
2024-09-12 12:42:35 +02:00
tb_name.draw(dialog_x + ui(64), dialog_y + ui(8), dialog_w - ui(172), ui(32), meta.name, mouse_ui);
var bw = ui(28);
var bh = ui(28);
2023-02-14 02:48:33 +01:00
2024-09-12 12:42:35 +02:00
var bx = dialog_x + dialog_w - ui(8) - bw;
var by = dialog_y + ui(24) - bh / 2;
2023-02-14 02:48:33 +01:00
2024-09-12 12:42:35 +02:00
if(buttonInstant(THEME.button_hide, bx, by, bw, bh, mouse_ui, sFOCUS, sHOVER, __txt("Close"), THEME.cross_16, 0, COLORS._main_value_negative) == 2)
instance_destroy();
bx -= bw + ui(4);
2023-06-04 18:28:29 +02:00
var txt = __txtx("new_collection_create", "Create collection");
2024-09-12 12:42:35 +02:00
var icon = THEME.accept_16;
2023-02-17 11:31:33 +01:00
var clr = COLORS._main_value_positive;
2023-10-01 06:17:39 +02:00
if(updating != noone)
2023-06-05 18:27:53 +02:00
txt = __txtx("new_collection_update", "Update collection");
2023-02-17 11:31:33 +01:00
2023-02-14 02:48:33 +01:00
if(ugc == 1) {
2023-06-05 18:27:53 +02:00
txt = __txtx("panel_inspector_workshop_upload", "Upload to Steam Workshop");
2023-02-14 02:48:33 +01:00
icon = THEME.workshop_upload;
2023-02-17 11:31:33 +01:00
clr = c_white;
2023-02-14 02:48:33 +01:00
} else if(ugc == 2) {
2023-06-05 18:27:53 +02:00
txt = __txtx("panel_inspector_workshop_update", "Update Steam Workshop");
2023-02-14 02:48:33 +01:00
icon = THEME.workshop_update;
2023-02-17 11:31:33 +01:00
clr = c_white;
2023-02-14 02:48:33 +01:00
}
if(ugc_loading) {
steam_ugc_get_item_update_progress(STEAM_UGC_UPDATE_HANDLE, STEAM_UGC_UPDATE_MAP);
destroy_on_click_out = false;
draw_sprite_ui(THEME.loading_s, 0, bx + ui(16), by + ui(16),,, current_time / 5, COLORS._main_icon);
if(STEAM_UGC_ITEM_UPLOADING == false)
instance_destroy();
2023-02-14 02:48:33 +01:00
} else {
2023-02-17 11:31:33 +01:00
if(buttonInstant(THEME.button_hide, bx, by, bw, bh, mouse_ui, sFOCUS, sHOVER, txt, icon, 0, clr) == 2) {
2023-02-14 02:48:33 +01:00
if(meta.author_steam_id == 0)
meta.author_steam_id = STEAM_USER_ID;
2023-11-26 13:16:38 +01:00
if(updating == noone && node != noone) {
2023-04-21 19:08:10 +02:00
saveCollection(node, data_path, meta.name, true, meta);
2023-02-14 02:48:33 +01:00
} else {
2023-08-10 11:51:16 +02:00
var _map = json_load_struct(updating.path);
var _meta = meta.serialize();
_map.metadata = _meta;
json_save_struct(updating.path, _map);
json_save_struct(updating.meta_path, _meta);
2023-02-14 02:48:33 +01:00
2023-11-26 13:16:38 +01:00
var _newPath = $"{filename_dir(updating.path)}/{meta.name}.pxcc";
var _newMeta = $"{filename_dir(updating.meta_path)}/{meta.name}.meta";
var _oldSpr = $"{filename_dir(updating.path)}/{filename_name_only(updating.path)}.png";
var _newSpr = $"{filename_dir(updating.path)}/{meta.name}.png";
if(_newPath != updating.path) {
file_rename(updating.path, _newPath);
file_rename(updating.meta_path, _newMeta);
2023-12-08 03:50:09 +01:00
if(file_exists_empty(_oldSpr)) file_rename(_oldSpr, _newSpr);
2023-11-26 13:16:38 +01:00
}
updating.path = _newPath;
updating.meta_path = _newMeta;
updating.spr_path[0] = _newSpr;
updating.meta = meta;
2023-02-14 02:48:33 +01:00
PANEL_COLLECTION.refreshContext();
}
if(ugc == 1) {
steam_ugc_create_collection(updating);
ugc_loading = true;
2024-09-12 12:42:35 +02:00
2023-02-14 02:48:33 +01:00
} else if(ugc == 2) {
2023-04-21 19:08:10 +02:00
saveCollection(node, data_path, updating.path, false, updating.meta);
2023-11-26 13:16:38 +01:00
steam_ugc_update_collection(updating, false, update_note);
2023-02-14 02:48:33 +01:00
ugc_loading = true;
2024-09-12 12:42:35 +02:00
2023-02-14 02:48:33 +01:00
} else
instance_destroy();
}
}
2024-09-12 12:42:35 +02:00
bx -= bw + ui(4);
2023-06-04 18:28:29 +02:00
var txt = __txtx("new_collection_meta_edit", "Edit metadata");
2024-09-12 12:42:35 +02:00
if(buttonInstant(THEME.button_hide, bx, by, bw, bh, mouse_ui, sFOCUS, sHOVER, txt, THEME.arrow, meta_expand? 3 : 0) == 2)
2023-02-28 09:43:01 +01:00
doExpand();
2023-02-14 02:48:33 +01:00
#endregion
2023-11-26 13:16:38 +01:00
#region display
2024-09-12 12:42:35 +02:00
dialog_h = ui(48);
2023-02-14 02:48:33 +01:00
if(meta_expand) {
2024-09-12 12:42:35 +02:00
var dx = dialog_x + ui(8);
var dw = dialog_w - ui(16);
var yy = dialog_y + ui(48);
2023-02-14 02:48:33 +01:00
2023-10-18 14:58:55 +02:00
if(ugc == 2) {
2024-09-12 12:42:35 +02:00
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_icon);
draw_text(dx, yy + ui(12), __txt("Update note"));
2023-10-18 14:58:55 +02:00
yy += line_get_height() + ui(4);
dialog_h += line_get_height() + ui(4);
var wd_h = ui(160);
t_update.setFocusHover(sFOCUS, sHOVER);
t_update.register();
2024-09-12 12:42:35 +02:00
t_update.draw(dx, yy, dw, wd_h, update_note, mouse_ui);
2023-10-18 14:58:55 +02:00
yy += wd_h + ui(8);
dialog_h += wd_h + ui(8);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
2024-09-12 12:42:35 +02:00
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_icon);
draw_text(dx, yy + ui(12), __txt("Description"));
2023-05-28 20:00:51 +02:00
yy += line_get_height() + ui(4);
dialog_h += line_get_height() + ui(4);
2023-02-14 02:48:33 +01:00
2023-10-18 14:58:55 +02:00
var wd_h = ugc == 2? ui(100) : ui(200);
2023-06-21 20:36:53 +02:00
t_desc.setFocusHover(sFOCUS, sHOVER);
2023-02-14 02:48:33 +01:00
t_desc.register();
2024-09-12 12:42:35 +02:00
t_desc.draw(dx, yy, dw, wd_h, meta.description, mouse_ui);
2023-10-18 14:58:55 +02:00
yy += wd_h + ui(8);
dialog_h += wd_h + ui(8);
2023-02-14 02:48:33 +01:00
2023-10-18 14:58:55 +02:00
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
2024-09-12 12:42:35 +02:00
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_icon);
draw_text(dx, yy + ui(12), __txt("Author"));
2023-05-28 20:00:51 +02:00
yy += line_get_height() + ui(4);
dialog_h += line_get_height() + ui(4);
2023-02-14 02:48:33 +01:00
2023-10-18 14:58:55 +02:00
var wd_h = TEXTBOX_HEIGHT;
2023-06-21 20:36:53 +02:00
t_auth.setFocusHover(sFOCUS, sHOVER);
2023-02-14 02:48:33 +01:00
t_auth.register();
2024-09-12 12:42:35 +02:00
t_auth.draw(dx, yy, dw, wd_h, meta.author, mouse_ui);
2023-10-18 14:58:55 +02:00
yy += wd_h + ui(8);
dialog_h += wd_h + ui(8);
2023-02-14 02:48:33 +01:00
2023-10-18 14:58:55 +02:00
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
2024-09-12 12:42:35 +02:00
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_icon);
draw_text(dx, yy + ui(12), __txt("Contact info"));
2023-05-28 20:00:51 +02:00
yy += line_get_height() + ui(4);
dialog_h += line_get_height() + ui(4);
2023-02-14 02:48:33 +01:00
2023-10-18 14:58:55 +02:00
var wd_h = TEXTBOX_HEIGHT;
2023-06-21 20:36:53 +02:00
t_cont.setFocusHover(sFOCUS, sHOVER);
2023-02-14 02:48:33 +01:00
t_cont.register();
2024-09-12 12:42:35 +02:00
t_cont.draw(dx, yy, dw, wd_h, meta.contact, mouse_ui);
2023-10-18 14:58:55 +02:00
yy += wd_h + ui(8);
dialog_h += wd_h + ui(8);
2023-02-14 02:48:33 +01:00
2023-10-18 14:58:55 +02:00
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
2024-09-12 12:42:35 +02:00
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_icon);
draw_text(dx, yy + ui(12), __txt("Alias"));
2023-05-28 20:00:51 +02:00
yy += line_get_height() + ui(4);
dialog_h += line_get_height() + ui(4);
2023-02-14 02:48:33 +01:00
2023-10-18 14:58:55 +02:00
var wd_h = TEXTBOX_HEIGHT;
2023-06-21 20:36:53 +02:00
t_alias.setFocusHover(sFOCUS, sHOVER);
2023-02-14 02:48:33 +01:00
t_alias.register();
2024-09-12 12:42:35 +02:00
t_alias.draw(dx, yy, dw, wd_h, meta.alias, mouse_ui);
2023-10-18 14:58:55 +02:00
yy += wd_h + ui(8);
dialog_h += wd_h + ui(8);
2023-02-14 02:48:33 +01:00
2023-10-18 14:58:55 +02:00
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
2024-09-12 12:42:35 +02:00
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_icon);
draw_text(dx, yy + ui(12), __txt("Tags"));
2023-05-28 20:00:51 +02:00
yy += line_get_height() + ui(4);
dialog_h += line_get_height() + ui(4);
2023-02-14 02:48:33 +01:00
2023-10-18 14:58:55 +02:00
var wd_h = TEXTBOX_HEIGHT;
2023-06-21 20:36:53 +02:00
t_tags.setFocusHover(sFOCUS, sHOVER);
2023-02-14 02:48:33 +01:00
t_tags.register();
2024-09-12 12:42:35 +02:00
var hh = t_tags.draw(dx, yy, dw, wd_h, mouse_ui);
2023-02-14 02:48:33 +01:00
yy += hh + ui(8);
dialog_h += hh + ui(8);
}
dialog_y = clamp(dialog_y, ui(16), WIN_H - ui(16) - dialog_h);
#endregion