Pixel-Composer/scripts/panel_collection/panel_collection.gml

612 lines
20 KiB
Text
Raw Normal View History

2024-08-09 13:30:09 +02:00
#region funtion calls
function __fnInit_Collection() {
2024-08-10 07:30:41 +02:00
registerFunction("Collection", "Replace", "", MOD_KEY.none, panel_collection_replace ).setMenu("collection_replace")
registerFunction("Collection", "Edit Meta", "", MOD_KEY.none, panel_collection_edit_meta ).setMenu("collection_edit_meta")
registerFunction("Collection", "Update Thumbnail", "", MOD_KEY.none, panel_collection_update_thumbnail ).setMenu("collection_update_thumbnail")
registerFunction("Collection", "Delete Collection", "", MOD_KEY.none, panel_collection_delete_collection ).setMenu("collection_delete_collection", THEME.cross)
2024-08-09 13:30:09 +02:00
registerFunction("Collection", "Upload To Steam", "", MOD_KEY.none, panel_collection_steam_file_upload ).setMenu("collection_upload_to_steam", THEME.workshop_upload)
registerFunction("Collection", "Update Steam", "", MOD_KEY.none, panel_collection_steam_file_update ).setMenu("collection_update_steam", THEME.workshop_update)
2024-08-10 07:30:41 +02:00
registerFunction("Collection", "Unsubscribe", "", MOD_KEY.none, panel_collection_steam_unsubscribe ).setMenu("collection_unsubscribe")
2024-08-09 13:30:09 +02:00
}
function panel_collection_replace() { CALL("collection_replace"); PANEL_COLLECTION.replace(); }
function panel_collection_edit_meta() { CALL("collection_edit_meta"); PANEL_COLLECTION.edit_meta(); }
function panel_collection_update_thumbnail() { CALL("collection_update_thumbnail"); PANEL_COLLECTION.update_thumbnail(); }
function panel_collection_delete_collection() { CALL("collection_delete_collection"); PANEL_COLLECTION.delete_collection(); }
function panel_collection_steam_file_upload() { CALL("collection_steam_file_upload"); PANEL_COLLECTION.steam_file_upload(); }
function panel_collection_steam_file_update() { CALL("collection_steam_file_update"); PANEL_COLLECTION.steam_file_update(); }
function panel_collection_steam_unsubscribe() { CALL("collection_steam_unsubscribe"); PANEL_COLLECTION.steam_unsubscribe(); }
#endregion
2022-11-14 03:16:15 +01:00
function Panel_Collection() : PanelContent() constructor {
2023-06-04 18:28:29 +02:00
title = __txt("Collections");
2022-11-14 03:16:15 +01:00
expandable = false;
2023-01-17 08:11:55 +01:00
group_w = ui(180);
2023-01-17 08:11:55 +01:00
group_w_dragging = false;
group_w_sx = false;
group_w_mx = false;
2022-11-14 03:16:15 +01:00
2023-06-23 15:39:24 +02:00
static initSize = function() {
2022-12-16 09:18:09 +01:00
content_w = w - ui(8) - group_w;
2022-11-14 03:16:15 +01:00
content_h = h - ui(40) - ui(16);
}
initSize();
2022-01-13 05:24:03 +01:00
2022-11-03 11:44:49 +01:00
min_w = group_w + ui(40);
min_h = ui(40);
2022-01-13 05:24:03 +01:00
2022-09-27 06:37:28 +02:00
roots = [ ["Collections", COLLECTIONS] , ["Assets", global.ASSETS] ];
2024-04-08 14:52:24 +02:00
if(STEAM_ENABLED) array_push(roots, ["Projects", STEAM_PROJECTS]);
2024-04-08 07:13:46 +02:00
page = 0;
root = roots[page][1];
2022-09-27 06:37:28 +02:00
context = root;
2022-01-13 05:24:03 +01:00
search_list = ds_list_create();
2022-01-13 05:24:03 +01:00
file_dragging = noone;
2023-03-25 12:27:04 +01:00
_menu_node = noone;
updated_path = noone;
updated_prog = 0;
data_path = "";
view_tooltip = new tooltipSelector("View", [ "Grid", "List" ])
2023-11-24 10:41:53 +01:00
PANEL_COLLECTION = self;
2024-08-09 13:30:09 +02:00
#region ++++++++++++ Actions ++++++++++++
function replace() {
if(_menu_node == noone) return;
var _path = filename_dir(_menu_node.path);
var _name = filename_name(_menu_node.path);
saveCollection(PANEL_INSPECTOR.getInspecting(), _path, _name, false, _menu_node.meta);
}
function edit_meta() {
if(_menu_node == noone) return;
var dia = dialogCall(o_dialog_file_name_collection, mouse_mx + ui(8), mouse_my + ui(-320));
var meta = _menu_node.getMetadata();
if(meta != noone && meta != undefined)
dia.meta = meta;
dia.node = PANEL_INSPECTOR.getInspecting();
dia.data_path = data_path;
dia.updating = _menu_node;
dia.doExpand();
}
function update_thumbnail() {
if(_menu_node == noone) return;
var _path = _menu_node.path;
var preview_surface = PANEL_PREVIEW.getNodePreviewSurface();
if(!is_surface(preview_surface)) {
noti_warning("Please send any node to preview panel to use as a thumbnail.")
return;
}
var icon_path = string_replace(_path, filename_ext(_path), ".png");
surface_save_safe(preview_surface, icon_path);
refreshContext();
}
function delete_collection() {
if(_menu_node == noone) return;
file_delete(_menu_node.path);
refreshContext();
}
function steam_file_upload() {
if(_menu_node == noone) return;
var dia = dialogCall(o_dialog_file_name_collection, mouse_mx + ui(8), mouse_my + ui(-320));
var meta = _menu_node.getMetadata();
if(meta != noone && meta != undefined)
dia.meta = meta;
dia.data_path = data_path;
dia.ugc = 1;
dia.updating = _menu_node;
dia.doExpand();
}
function steam_file_update() {
if(_menu_node == noone) return;
var _node = PANEL_INSPECTOR.getInspecting();
if(_node == noone) {
noti_warning("No node selected. Select a node in graph panel to update workshop content.");
return;
}
var dia = dialogCall(o_dialog_file_name_collection, mouse_mx + ui(8), mouse_my + ui(-320));
var meta = _menu_node.getMetadata();
if(meta != noone && meta != undefined)
dia.meta = meta;
dia.node = _node;
dia.data_path = data_path;
dia.ugc = 2;
dia.updating = _menu_node;
dia.doExpand();
}
function steam_unsubscribe() {
if(_menu_node == noone) return;
2024-08-12 13:42:05 +02:00
var meta = _menu_node.getMetadata();
2024-08-09 13:30:09 +02:00
var del_id = meta.file_id;
for( var i = 0; i < ds_list_size(STEAM_COLLECTION); i++ ) {
2024-08-12 13:42:05 +02:00
if(STEAM_COLLECTION[| i].getMetadata().file_id != del_id) continue;
ds_list_delete(STEAM_COLLECTION, i);
break;
2024-08-09 13:30:09 +02:00
}
2024-08-12 13:42:05 +02:00
2024-08-09 13:30:09 +02:00
steam_ugc_unsubscribe_item(del_id);
}
#endregion
static initMenu = function() {
2023-02-17 11:31:33 +01:00
if(_menu_node == noone) return;
var meta = _menu_node.getMetadata();
contentMenu = [];
if(meta == noone || !meta.steam) {
contentMenu = [
2024-08-10 07:30:41 +02:00
MENU_ITEMS.collection_replace,
MENU_ITEMS.collection_edit_meta,
MENU_ITEMS.collection_update_thumbnail,
2023-02-17 11:31:33 +01:00
-1,
2024-08-10 07:30:41 +02:00
MENU_ITEMS.collection_delete_collection,
2023-02-17 11:31:33 +01:00
];
2023-02-19 13:49:20 +01:00
if(STEAM_ENABLED)
array_push(contentMenu, -1);
}
if(STEAM_ENABLED) {
2023-11-27 14:50:20 +01:00
if(meta.steam == FILE_STEAM_TYPE.local) {
2024-08-10 07:30:41 +02:00
array_push(contentMenu, MENU_ITEMS.collection_upload_to_steam);
2024-08-12 13:42:05 +02:00
2023-02-17 11:31:33 +01:00
} else {
2024-08-12 13:42:05 +02:00
if(meta.author_steam_id && meta.author_steam_id == STEAM_USER_ID)
2024-08-10 07:30:41 +02:00
array_push(contentMenu, MENU_ITEMS.collection_update_steam);
array_push(contentMenu, MENU_ITEMS.collection_unsubscribe);
2023-02-14 02:51:14 +01:00
}
}
}
2023-02-14 02:51:14 +01:00
initMenu();
2022-01-25 10:58:11 +01:00
search_string = "";
tb_search = new textBox(TEXTBOX_INPUT.text, function(str) /*=>*/ {
2022-01-25 10:58:11 +01:00
search_string = string(str);
searchCollection(search_list, search_string);
});
tb_search.auto_update = true;
2024-06-09 06:27:50 +02:00
grid_size = ui(64);
grid_size_to = grid_size;
2022-09-21 06:09:40 +02:00
contentView = 0;
contentPane = new scrollPane(content_w - ui(6), content_h, function(_y, _m) {
2023-11-24 10:41:53 +01:00
draw_clear_alpha(c_white, 0);
2022-01-13 05:24:03 +01:00
var content;
2023-02-14 02:51:14 +01:00
var steamNode = [];
2024-04-08 07:13:46 +02:00
switch(page) {
case 0 :
if(!COLLECTIONS.scanned)
COLLECTIONS.scan([".json", ".pxcc"]);
if(context == root) content = STEAM_COLLECTION;
else content = context.content;
for( var i = 0; i < ds_list_size(STEAM_COLLECTION); i++ ) {
var meta = STEAM_COLLECTION[| i].meta;
if(array_exists(meta.tags, context.name))
array_push(steamNode, STEAM_COLLECTION[| i]);
}
break;
case 1 : content = context.content; break;
case 2 : content = context; break;
2023-02-14 02:51:14 +01:00
}
if(search_string != "") content = search_list;
2024-04-08 07:13:46 +02:00
var node_list = ds_list_size(content);
2023-02-14 02:51:14 +01:00
var node_count = node_list + array_length(steamNode);
2024-04-08 07:13:46 +02:00
var frame = PREFERENCES.collection_animated? current_time * PREFERENCES.collection_preview_speed / 3000 : 0;
var _cw = contentPane.surface_w;
var _hover = pHOVER && contentPane.hover;
2022-01-13 05:24:03 +01:00
updated_prog = lerp_linear(updated_prog, 0, 0.01);
var hh = 0;
2023-01-01 02:06:02 +01:00
2022-09-21 06:09:40 +02:00
if(contentView == 0) {
2024-06-09 06:27:50 +02:00
var grid_width = round(grid_size * 1.25);
if(grid_width > ui(80)) grid_width = grid_size;
var grid_space = round(grid_size * 0.1875);
2024-04-08 07:13:46 +02:00
2022-12-16 09:18:09 +01:00
var col = max(1, floor(_cw / (grid_width + grid_space)));
2022-09-27 06:37:28 +02:00
var row = ceil(node_count / col);
var yy = _y + grid_space;
2022-09-21 06:09:40 +02:00
var name_height = 0;
2023-02-23 07:02:19 +01:00
2023-03-25 12:27:04 +01:00
grid_width = round(contentPane.surface_w - grid_space) / col - grid_space;
2023-03-24 05:55:34 +01:00
2022-09-21 06:09:40 +02:00
hh += grid_space;
2023-02-23 07:02:19 +01:00
2022-09-21 06:09:40 +02:00
for(var i = 0; i < row; i++) {
name_height = 0;
2024-04-08 07:13:46 +02:00
2022-09-21 06:09:40 +02:00
for(var j = 0; j < col; j++) {
var index = i * col + j;
2023-02-14 02:51:14 +01:00
if(index >= node_count) break;
var _node = index < node_list? content[| index] : steamNode[index - node_list];
2023-02-14 02:51:14 +01:00
var _nx = grid_space + (grid_width + grid_space) * j;
var _boxx = _nx + (grid_width - grid_size) / 2;
2023-05-28 20:00:51 +02:00
_boxx = round(_boxx);
2023-05-07 20:55:13 +02:00
var gr_x1 = _boxx + grid_size;
var gr_y1 = yy + grid_size;
2023-11-25 08:54:35 +01:00
if(yy + grid_size >= 0 && yy <= contentPane.surface_h) {
BLEND_OVERRIDE;
draw_sprite_stretched(THEME.node_bg, 0, _boxx, yy, grid_size, grid_size);
BLEND_NORMAL;
2023-11-25 08:54:35 +01:00
var meta = noone;
if(variable_struct_exists(_node, "getMetadata"))
meta = _node.getMetadata();
2022-01-13 05:24:03 +01:00
2023-11-25 08:54:35 +01:00
if(_hover && point_in_rectangle(_m[0], _m[1], _nx, yy, _nx + grid_width, yy + grid_size)) {
2024-07-28 13:55:57 +02:00
contentPane.hover_content = true;
draw_sprite_stretched_ext(THEME.node_bg, 1, _boxx, yy, grid_size, grid_size, COLORS._main_accent, 1);
2024-04-08 07:13:46 +02:00
if(mouse_press(mb_left, pFOCUS)) {
var _typ = "";
switch(_node.type) {
case FILE_TYPE.collection : _typ = "Collection"; break;
case FILE_TYPE.assets : _typ = "Asset"; break;
case FILE_TYPE.project : _typ = "Project"; break;
}
DRAGGING = { type : _typ, data : _node }
}
2022-12-12 09:08:03 +01:00
2023-11-25 08:54:35 +01:00
if(!DEMO && mouse_press(mb_right, pFOCUS)) {
_menu_node = _node;
initMenu();
2024-08-10 11:04:14 +02:00
menuCall("collection_menu", contentMenu);
2023-11-25 08:54:35 +01:00
}
2023-11-25 08:54:35 +01:00
if(!instance_exists(o_dialog_menubox) && meta != noone && meta != undefined)
TOOLTIP = meta;
}
2022-09-27 06:37:28 +02:00
2023-11-25 08:54:35 +01:00
if(_node.path == updated_path && updated_prog > 0)
2024-03-31 05:36:11 +02:00
draw_sprite_stretched_ext(THEME.node_glow_border, 0, _boxx - 9, yy - 9, grid_size + 18, grid_size + 18, COLORS._main_value_positive, updated_prog);
2023-01-01 02:06:02 +01:00
2023-11-25 08:54:35 +01:00
if(variable_struct_exists(_node, "getSpr")) _node.getSpr();
2023-11-25 08:54:35 +01:00
if(sprite_exists(_node.spr)) {
var sw = sprite_get_width(_node.spr);
var sh = sprite_get_height(_node.spr);
2023-12-09 09:00:35 +01:00
var ss = (grid_size - ui(10)) * PREFERENCES.collection_scale / max(sw, sh);
2022-09-27 06:37:28 +02:00
2023-11-25 08:54:35 +01:00
var xo = (sprite_get_xoffset(_node.spr) - sw / 2) * ss;
var yo = (sprite_get_yoffset(_node.spr) - sh / 2) * ss;
var sx = _boxx + grid_size / 2 + xo;
var sy = yy + grid_size / 2 + yo;
2022-09-27 06:37:28 +02:00
2023-11-25 08:54:35 +01:00
BLEND_ALPHA_MULP
draw_sprite_ext(_node.spr, frame, sx, sy, ss, ss, 0, c_white, 1);
BLEND_NORMAL
} else
draw_sprite_ui_uniform(THEME.group, 0, _boxx + grid_size / 2, yy + grid_size / 2, 1, c_white);
2023-02-14 02:51:14 +01:00
if(meta != noone && page == 0) {
2023-11-25 08:54:35 +01:00
if(struct_try_get(meta, "steam")) {
draw_sprite_ui_uniform(THEME.steam, 0, _boxx + ui(12), yy + ui(12), 1, COLORS._main_icon_dark, 1);
if(meta.author_steam_id == STEAM_USER_ID)
draw_sprite_ui_uniform(THEME.steam_creator, 0, _boxx + grid_size - ui(8), yy + ui(12), 1, COLORS._main_icon_dark, 1);
}
2022-11-03 11:44:49 +01:00
2023-12-05 04:28:49 +01:00
if(floor(meta.version) != floor(SAVE_VERSION)) {
2023-11-25 08:54:35 +01:00
draw_set_color(COLORS._main_accent);
draw_circle_prec(_boxx + grid_size - ui(8), yy + grid_size - ui(8), 3, false);
}
2023-02-14 02:51:14 +01:00
}
2022-01-13 05:24:03 +01:00
}
2023-02-14 02:51:14 +01:00
2023-08-06 16:00:59 +02:00
draw_set_text(f_p3, fa_center, fa_top, COLORS._main_text_inner);
2024-06-09 06:27:50 +02:00
var _txtH = draw_text_ext_add(_boxx + grid_size / 2, yy + grid_size + ui(4), _node.name, -1, grid_width, 1, true);
2023-11-24 10:41:53 +01:00
name_height = max(name_height, _txtH + 8);
2022-09-21 06:09:40 +02:00
}
2023-02-23 07:02:19 +01:00
var hght = grid_size + name_height + ui(8);
2022-09-21 06:09:40 +02:00
hh += hght;
yy += hght;
}
2024-04-08 07:13:46 +02:00
2024-06-09 06:27:50 +02:00
if(pHOVER && key_mod_press(CTRL) && point_in_rectangle(_m[0], _m[1], 0, 0, contentPane.surface_w, contentPane.surface_h)) {
if(mouse_wheel_down()) grid_size_to = clamp(grid_size_to - ui(4), ui(32), ui(160));
if(mouse_wheel_up()) grid_size_to = clamp(grid_size_to + ui(4), ui(32), ui(160));
}
grid_size = lerp_float(grid_size, grid_size_to, 5);
2022-09-21 06:09:40 +02:00
} else {
2022-12-16 09:18:09 +01:00
var list_width = _cw;
2022-11-03 11:44:49 +01:00
var list_height = ui(28);
2022-09-21 06:09:40 +02:00
var yy = _y + list_height / 2;
hh += list_height;
for(var i = 0; i < node_count; i++) {
var _node = i < node_list? content[| i] : steamNode[i - node_list];
2022-09-21 06:09:40 +02:00
if(!_node) continue;
2023-11-25 08:54:35 +01:00
if(yy + list_height >= 0 && yy <= contentPane.surface_h) {
if(i % 2) {
BLEND_OVERRIDE;
draw_sprite_stretched_ext(THEME.node_bg, 0, ui(4), yy, list_width - 8, list_height, c_white, 0.2);
BLEND_NORMAL;
}
2022-09-21 06:09:40 +02:00
2023-11-25 08:54:35 +01:00
if(_hover && point_in_rectangle(_m[0], _m[1], 0, yy, list_width, yy + list_height - 1)) {
2024-07-28 13:55:57 +02:00
contentPane.hover_content = true;
draw_sprite_stretched_ext(THEME.node_bg, 1, ui(4), yy, list_width - ui(8), list_height, COLORS._main_accent, 1);
2023-11-25 08:54:35 +01:00
if(mouse_press(mb_left, pFOCUS))
DRAGGING = { type : _node.type == FILE_TYPE.collection? "Collection" : "Asset", data : _node }
2022-09-21 06:09:40 +02:00
2023-11-25 08:54:35 +01:00
if(!DEMO && mouse_press(mb_right, pFOCUS)) {
_menu_node = _node;
initMenu();
2024-08-10 11:04:14 +02:00
menuCall("collection_menu", contentMenu);
2023-11-25 08:54:35 +01:00
}
2022-09-21 06:09:40 +02:00
}
2022-09-27 06:37:28 +02:00
2023-11-25 08:54:35 +01:00
var spr_x = list_height / 2 + ui(14);
var spr_y = yy + list_height / 2;
var spr_s = list_height - ui(8);
if(variable_struct_exists(_node, "getSpr")) _node.getSpr();
if(sprite_exists(_node.spr)) {
var sw = sprite_get_width(_node.spr);
var sh = sprite_get_height(_node.spr);
var ss = spr_s / max(sw, sh);
2022-09-27 06:37:28 +02:00
2023-11-25 08:54:35 +01:00
var xo = (sprite_get_xoffset(_node.spr) - sw / 2) * ss;
var yo = (sprite_get_yoffset(_node.spr) - sh / 2) * ss;
var sx = spr_x + xo;
var sy = spr_y + yo;
2022-09-27 06:37:28 +02:00
2023-11-25 08:54:35 +01:00
draw_sprite_ext(_node.spr, frame, sx, sy, ss, ss, 0, c_white, 1);
} else
draw_sprite_ui_uniform(THEME.group, 0, spr_x, spr_y, 0.75, c_white);
2022-09-21 06:09:40 +02:00
2023-11-25 08:54:35 +01:00
draw_set_text(f_p3, fa_left, fa_center, COLORS._main_text_inner);
draw_text_add(list_height + ui(20), yy + list_height / 2, _node.name);
}
2022-09-21 06:09:40 +02:00
yy += list_height;
hh += list_height;
2022-01-13 05:24:03 +01:00
}
}
return hh;
});
2022-01-13 05:24:03 +01:00
folderPane = new scrollPane(group_w - ui(8), content_h, function(_y, _m) {
2023-11-13 15:42:14 +01:00
draw_clear_alpha(COLORS.panel_bg_clear, 1);
2022-11-03 11:44:49 +01:00
var hh = ui(8);
2023-03-12 02:28:21 +01:00
_y += ui(8);
2022-01-13 05:24:03 +01:00
2024-07-28 13:55:57 +02:00
folderPane.hover_content = true;
2023-11-16 02:49:52 +01:00
if(pHOVER && folderPane.hover && point_in_rectangle(_m[0], _m[1], ui(32), _y - ui(2), group_w - ui(32), _y + ui(24))) {
draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, ui(32), _y - ui(2), group_w - ui(64), ui(24), CDEF.main_white, 1);
if(mouse_press(mb_left, pFOCUS))
setContext(root);
}
draw_set_alpha(0.25 + (context == root) * 0.5);
draw_set_text(f_p2, fa_center, fa_top, context == root? COLORS._main_text_accent : COLORS._main_text_inner);
draw_text(group_w / 2, _y, __txt("uncategorized"));
draw_set_alpha(1);
_y += ui(24);
2024-05-22 04:46:29 +02:00
var _font = f_p0;
var _param = { font : _font };
2022-09-27 06:37:28 +02:00
for(var i = 0; i < ds_list_size(root.subDir); i++) {
2024-05-22 04:46:29 +02:00
var hg = root.subDir[| i].draw(self, ui(8 + in_dialog * 8), _y, _m, folderPane.w - ui(20), pHOVER && folderPane.hover, pFOCUS, root, _param);
hh += hg;
_y += hg;
2022-01-13 05:24:03 +01:00
}
2023-11-25 08:54:35 +01:00
return hh + ui(28);
});
2022-01-13 05:24:03 +01:00
2023-03-13 10:45:56 +01:00
function onFocusBegin() { PANEL_COLLECTION = self; }
function onResize() {
2022-12-16 09:18:09 +01:00
initSize();
2023-01-17 08:11:55 +01:00
2023-03-25 12:27:04 +01:00
folderPane.resize(group_w - ui(8), content_h);
2024-04-08 07:13:46 +02:00
if(page == 2) contentPane.resize(w - ui(16), content_h);
2024-04-08 07:13:46 +02:00
else contentPane.resize(content_w - ui(6), content_h);
}
2022-01-13 05:24:03 +01:00
function setContext(cont) {
context = cont;
contentPane.scroll_y_raw = 0;
contentPane.scroll_y_to = 0;
}
function refreshContext() {
if(page == 0) context.scan([ ".json", ".pxcc" ]);
else if(page == 1) context.scan([ ".png", ".jpg", ".gif" ]);
2023-02-17 11:31:33 +01:00
if(STEAM_ENABLED) steamUCGload();
}
2022-01-13 05:24:03 +01:00
function drawContent(panel) {
2023-11-13 15:42:14 +01:00
draw_clear_alpha(COLORS.panel_bg_clear, 1);
2022-01-13 05:24:03 +01:00
2022-11-03 11:44:49 +01:00
var content_y = ui(48);
2022-01-13 05:24:03 +01:00
if(page == 2) {
2024-04-08 07:13:46 +02:00
var pad = ui(8);
draw_sprite_stretched(THEME.ui_panel_bg, 1, pad, content_y, w - pad * 2, content_h);
contentPane.setFocusHover(pFOCUS, pHOVER);
contentPane.draw(pad, content_y, mx - pad, my - content_y);
} else {
draw_sprite_stretched(THEME.ui_panel_bg, 1, group_w, content_y, content_w, content_h);
contentPane.setFocusHover(pFOCUS, pHOVER);
contentPane.draw(group_w, content_y, mx - group_w, my - content_y);
2022-01-13 05:24:03 +01:00
2024-04-08 07:13:46 +02:00
folderPane.setFocusHover(pFOCUS, pHOVER);
folderPane.draw(0, content_y, mx, my - content_y);
if(group_w_dragging) {
CURSOR = cr_size_we;
group_w = max(ui(128), group_w_sx + (mx - group_w_mx));
2023-01-17 08:11:55 +01:00
onResize();
if(mouse_release(mb_left))
group_w_dragging = false;
}
2024-04-08 07:13:46 +02:00
if(pHOVER && point_in_rectangle(mx, my, group_w - ui(2), content_y, group_w + ui(2), content_y + content_h)) {
CURSOR = cr_size_we;
if(pFOCUS && mouse_press(mb_left)) {
group_w_dragging = true;
group_w_mx = mx;
group_w_sx = group_w;
}
}
2024-04-08 07:13:46 +02:00
}
var _x = ui(20);
var _y = ui(24);
var bh = line_get_height(f_p0b, 8);
2023-02-14 02:51:14 +01:00
var rootx = 0;
2022-09-27 06:37:28 +02:00
draw_set_font(f_p0b);
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(roots); i < n; i++ ) {
var r = roots[i];
var _bx = _x - ui(8);
var _by = _y - bh / 2;
var _bw = string_width(r[0]) + ui(20);
if(buttonInstant(THEME.button_hide_fill, _bx, _by, _bw, bh, [ mx, my ], pFOCUS, pHOVER) == 2) {
page = i;
2022-09-27 06:37:28 +02:00
root = r[1];
2022-11-14 03:16:15 +01:00
context = root;
2024-04-08 07:13:46 +02:00
onResize();
2022-09-27 06:37:28 +02:00
}
draw_set_text(f_p0b, fa_left, fa_center, i == page? COLORS._main_text : COLORS._main_text_sub);
2023-06-04 18:28:29 +02:00
draw_text(_x, _y, __txt(r[0]));
2022-09-27 06:37:28 +02:00
2023-06-10 13:59:45 +02:00
_x += string_width(r[0]) + ui(24);
2022-09-27 06:37:28 +02:00
}
2022-01-13 05:24:03 +01:00
2023-02-14 02:51:14 +01:00
rootx = _x;
var bx = w - ui(40);
var by = ui(9);
2023-06-10 13:59:45 +02:00
var bs = ui(32);
2022-01-13 05:24:03 +01:00
if(search_string == "") {
2023-02-14 02:51:14 +01:00
if(bx > rootx) {
2023-11-24 10:41:53 +01:00
view_tooltip.index = contentView;
if(buttonInstant(THEME.button_hide, bx, by, bs, bs, [mx, my], pFOCUS, pHOVER, view_tooltip, THEME.view_mode, contentView) == 2)
2023-02-14 02:51:14 +01:00
contentView = !contentView;
2022-09-21 06:09:40 +02:00
}
2023-06-10 13:59:45 +02:00
bx -= ui(36);
2022-09-21 06:09:40 +02:00
if(page == 0 && !DEMO) {
2023-02-14 02:51:14 +01:00
if(bx > rootx) {
if(context != root) {
2023-06-04 18:28:29 +02:00
var txt = __txtx("panel_collection_add_node", "Add selecting node as collection");
2023-06-10 13:59:45 +02:00
if(buttonInstant(THEME.button_hide, bx, by, bs, bs, [mx, my], pFOCUS, pHOVER, txt, THEME.add, 0, COLORS._main_value_positive) == 2) {
if(PANEL_INSPECTOR.getInspecting() != noone) {
2023-02-14 02:51:14 +01:00
data_path = context.path;
var dia = dialogCall(o_dialog_file_name_collection, mouse_mx + ui(8), mouse_my + ui(8));
if(PANEL_INSPECTOR.getInspecting()) {
dia.meta.name = PANEL_INSPECTOR.getInspecting().display_name;
dia.node = PANEL_INSPECTOR.getInspecting();
2023-04-21 19:08:10 +02:00
dia.data_path = data_path;
}
2023-02-14 02:51:14 +01:00
}
2022-09-27 06:37:28 +02:00
}
2023-06-10 13:59:45 +02:00
} else
draw_sprite_ui_uniform(THEME.add, 0, bx + bs / 2, by + bs / 2, 1, COLORS._main_icon_dark);
2022-01-13 05:24:03 +01:00
}
2023-06-10 13:59:45 +02:00
bx -= ui(36);
2023-11-24 10:41:53 +01:00
2023-02-14 02:51:14 +01:00
if(bx > rootx) {
2023-06-04 18:28:29 +02:00
var txt = __txtx("panel_collection_add_folder", "Add folder");
2023-06-10 13:59:45 +02:00
if(buttonInstant(THEME.button_hide, bx, by, bs, bs, [mx, my], pFOCUS, pHOVER, txt) == 2) {
2024-05-22 04:46:29 +02:00
fileNameCall(context.path, function (txt) {
2023-02-14 02:51:14 +01:00
directory_create(txt);
refreshContext();
2024-05-22 04:46:29 +02:00
});
2023-02-14 02:51:14 +01:00
}
2023-06-10 13:59:45 +02:00
draw_sprite_ui_uniform(THEME.folder_add, 0, bx + bs / 2, by + bs / 2, 1, COLORS._main_icon);
draw_sprite_ui_uniform(THEME.folder_add, 1, bx + bs / 2, by + bs / 2, 1, COLORS._main_value_positive);
2022-09-27 06:37:28 +02:00
}
2023-06-10 13:59:45 +02:00
bx -= ui(36);
2022-01-25 10:58:11 +01:00
}
2022-01-13 05:24:03 +01:00
2023-02-14 02:51:14 +01:00
if(bx > rootx) {
2023-06-04 18:28:29 +02:00
var txt = __txtx("panel_collection_open_file", "Open in file explorer");
2023-12-29 14:30:54 +01:00
if(buttonInstant(THEME.button_hide, bx, by, bs, bs, [mx, my], pFOCUS, pHOVER, txt, THEME.path_open) == 2)
2023-02-14 02:51:14 +01:00
shellOpenExplorer(context.path);
2023-12-29 14:30:54 +01:00
draw_sprite_ui_uniform(THEME.path_open, 1, bx + bs / 2, by + bs / 2, 1, c_white);
2022-01-25 10:58:11 +01:00
}
2023-06-10 13:59:45 +02:00
bx -= ui(36);
2023-02-14 02:51:14 +01:00
if(bx > rootx) {
2023-06-04 18:28:29 +02:00
var txt = __txt("Refresh");
2024-03-31 05:36:11 +02:00
if(buttonInstant(THEME.button_hide, bx, by, bs, bs, [mx, my], pFOCUS, pHOVER, txt, THEME.refresh_icon) == 2)
2023-02-14 02:51:14 +01:00
refreshContext();
}
2023-06-10 13:59:45 +02:00
bx -= ui(36);
2023-12-09 09:00:35 +01:00
if(bx > rootx) {
var txt = __txt("Settings");
if(buttonInstant(THEME.button_hide, bx, by, bs, bs, [mx, my], pFOCUS, pHOVER, txt, THEME.gear) == 2)
dialogPanelCall(new Panel_Collections_Setting(), x + bx, y + by - 8, { anchor: ANCHOR.bottom | ANCHOR.left });
}
bx -= ui(36);
} else {
2022-11-03 11:44:49 +01:00
var tb_w = ui(200);
var tb_x = w - ui(10) - tb_w;
var tb_y = ui(10);
2022-01-25 10:58:11 +01:00
2022-11-03 11:44:49 +01:00
tb_search.draw(tb_x, tb_y, tb_w, TEXTBOX_HEIGHT, search_string, [mx, my]);
2022-01-13 05:24:03 +01:00
}
}
2022-01-13 05:24:03 +01:00
}