2022-11-14 03:16:15 +01:00
|
|
|
function Panel_Collection() : PanelContent() constructor {
|
|
|
|
expandable = false;
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2022-11-03 11:44:49 +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
|
|
|
|
|
|
|
function initSize() {
|
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] ];
|
|
|
|
mode = 0;
|
|
|
|
root = roots[mode][1];
|
|
|
|
context = root;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-01-25 10:58:11 +01:00
|
|
|
search_list = ds_list_create();
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
file_dragging = noone;
|
|
|
|
_menu_node = noone;
|
2022-01-25 10:58:11 +01:00
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
updated_path = noone;
|
|
|
|
updated_prog = 0;
|
2023-02-14 02:51:14 +01:00
|
|
|
data_path = "";
|
2023-01-01 02:06:02 +01:00
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
static initMenu = function() {
|
|
|
|
contentMenu = [
|
|
|
|
[ get_text("panel_collection_replace", "Replace with selected"), function() {
|
|
|
|
saveCollection(_menu_node.path, false, _menu_node.meta);
|
|
|
|
} ],
|
|
|
|
[ get_text("panel_collection_edit_meta", "Edit metadata") + "...", function() {
|
|
|
|
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.updating = _menu_node;
|
|
|
|
dia.expand();
|
|
|
|
} ],
|
|
|
|
-1,
|
|
|
|
[ get_text("delete", "Delete"), function() {
|
|
|
|
file_delete(_menu_node.path);
|
|
|
|
refreshContext();
|
|
|
|
} ],
|
|
|
|
];
|
|
|
|
|
|
|
|
if(DEMO) array_delete(contentMenu, 0, 3);
|
|
|
|
else if(_menu_node && STEAM_ENABLED) {
|
|
|
|
var meta = _menu_node.getMetadata();
|
|
|
|
|
|
|
|
if(!meta.steam) {
|
2023-02-15 10:04:49 +01:00
|
|
|
array_insert(contentMenu, 2, [ get_text("panel_collection_workshop_upload", "Upload to Steam Workshop") + "...", function() {
|
2023-02-14 02:51:14 +01:00
|
|
|
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.ugc = 1;
|
|
|
|
dia.updating = _menu_node;
|
|
|
|
dia.expand();
|
|
|
|
} ]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(meta.steam && meta.author_steam_id == STEAM_USER_ID && meta.file_id != 0) {
|
2023-02-15 10:04:49 +01:00
|
|
|
array_insert(contentMenu, 2, [get_text("panel_collection_workshop_update", "Update Steam Workshop content") + "...", function() {
|
2023-02-14 02:51:14 +01:00
|
|
|
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.ugc = 2;
|
|
|
|
dia.updating = _menu_node;
|
|
|
|
dia.expand();
|
|
|
|
} ]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
initMenu();
|
2022-01-25 10:58:11 +01:00
|
|
|
|
|
|
|
search_string = "";
|
|
|
|
tb_search = new textBox(TEXTBOX_INPUT.text, function(str) {
|
|
|
|
search_string = string(str);
|
|
|
|
searchCollection(search_list, search_string);
|
|
|
|
});
|
|
|
|
tb_search.auto_update = true;
|
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
contentView = 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
contentPane = new scrollPane(content_w, content_h, function(_y, _m) {
|
2022-09-21 06:09:40 +02:00
|
|
|
draw_clear_alpha(c_white, 0);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
var nodes = search_string == ""? context.content : search_list;
|
2023-02-15 10:04:49 +01:00
|
|
|
if(mode == 0 && context == root) nodes = STEAM_COLLECTION;
|
2023-02-14 02:51:14 +01:00
|
|
|
var steamNode = [];
|
2023-02-15 10:04:49 +01:00
|
|
|
for( var i = 0; i < ds_list_size(STEAM_COLLECTION); i++ ) {
|
|
|
|
var meta = STEAM_COLLECTION[| i].meta;
|
2023-02-14 02:51:14 +01:00
|
|
|
if(array_exists(meta.tags, context.name))
|
2023-02-15 10:04:49 +01:00
|
|
|
array_push(steamNode, STEAM_COLLECTION[| i]);
|
2023-02-14 02:51:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var node_list = ds_list_size(nodes);
|
|
|
|
var node_count = node_list + array_length(steamNode);
|
2022-09-21 06:09:40 +02:00
|
|
|
var hh = 0;
|
|
|
|
var frame = current_time * PREF_MAP[? "collection_preview_speed"] / 3000;
|
2022-12-16 09:18:09 +01:00
|
|
|
var _cw = contentPane.surface_w;
|
2022-12-19 13:35:30 +01:00
|
|
|
var _hover = pHOVER && contentPane.hover;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
updated_prog = lerp_linear(updated_prog, 0, 0.01);
|
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
if(contentView == 0) {
|
2022-11-03 11:44:49 +01:00
|
|
|
var grid_size = ui(64);
|
|
|
|
var grid_width = ui(80);
|
|
|
|
var grid_space = ui(12);
|
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;
|
|
|
|
|
|
|
|
hh += grid_space;
|
|
|
|
|
|
|
|
for(var i = 0; i < row; i++) {
|
|
|
|
name_height = 0;
|
|
|
|
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? nodes[| index] : steamNode[index - node_list];
|
|
|
|
var _nx = grid_space + (grid_width + grid_space) * j;
|
|
|
|
var _boxx = _nx + (grid_width - grid_size) / 2;
|
|
|
|
|
|
|
|
BLEND_OVERRIDE;
|
|
|
|
draw_sprite_stretched(THEME.node_bg, 0, _boxx, yy, grid_size, grid_size);
|
|
|
|
BLEND_NORMAL;
|
2022-09-27 06:37:28 +02:00
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
var meta = noone;
|
|
|
|
if(variable_struct_exists(_node, "getMetadata"))
|
|
|
|
meta = _node.getMetadata();
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
if(_hover && point_in_rectangle(_m[0], _m[1], _nx, yy, _nx + grid_width, yy + grid_size)) {
|
|
|
|
draw_sprite_stretched_ext(THEME.node_active, 0, _boxx, yy, grid_size, grid_size, COLORS._main_accent, 1);
|
|
|
|
if(mouse_press(mb_left, pFOCUS))
|
|
|
|
file_dragging = _node;
|
2022-12-12 09:08:03 +01:00
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
if(mouse_press(mb_right, pFOCUS)) {
|
|
|
|
_menu_node = _node;
|
|
|
|
initMenu();
|
|
|
|
var dia = dialogCall(o_dialog_menubox, mouse_mx + 8, mouse_my + 8);
|
|
|
|
dia.setMenu(contentMenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!instance_exists(o_dialog_menubox) && meta != noone && meta != undefined) {
|
|
|
|
meta.name = _node.name;
|
|
|
|
TOOLTIP = meta;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2023-02-14 02:51:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(_node.path == updated_path && updated_prog > 0)
|
|
|
|
draw_sprite_stretched_ext(THEME.node_glow, 0, _boxx - 9, yy - 9, grid_size + 18, grid_size + 18, COLORS._main_value_positive, updated_prog);
|
2022-09-27 06:37:28 +02:00
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
if(variable_struct_exists(_node, "getSpr")) _node.getSpr();
|
2023-01-01 02:06:02 +01:00
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
if(sprite_exists(_node.spr)) {
|
|
|
|
var sw = sprite_get_width(_node.spr);
|
|
|
|
var sh = sprite_get_height(_node.spr);
|
|
|
|
var ss = ui(32) / max(sw, sh);
|
2022-09-27 06:37:28 +02:00
|
|
|
|
2023-02-14 02:51:14 +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-02-14 02:51:14 +01:00
|
|
|
draw_sprite_ext(_node.spr, frame, sx, sy, ss, ss, 0, c_white, 1);
|
|
|
|
} else
|
|
|
|
draw_sprite_ui_uniform(THEME.group, 0, _boxx + grid_size / 2, yy + grid_size / 2, 1, c_white);
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
if(meta != noone && mode == 0) {
|
2023-02-14 02:51:14 +01:00
|
|
|
if(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-02-14 02:51:14 +01:00
|
|
|
if(meta.version < SAVEFILE_VERSION) {
|
|
|
|
draw_set_color(COLORS._main_accent);
|
|
|
|
draw_circle(_boxx + grid_size - ui(8), yy + grid_size - ui(8), 3, false);
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2023-02-14 02:51:14 +01:00
|
|
|
|
|
|
|
draw_set_text(f_p2, fa_center, fa_top, COLORS._main_text);
|
|
|
|
name_height = max(name_height, string_height_ext(_node.name, -1, grid_size) + 8);
|
|
|
|
draw_text_ext_over(_boxx + grid_size / 2, yy + grid_size + ui(4), _node.name, -1, grid_width);
|
2022-09-21 06:09:40 +02:00
|
|
|
}
|
|
|
|
var hght = grid_size + grid_space + name_height;
|
|
|
|
hh += hght;
|
|
|
|
yy += hght;
|
|
|
|
}
|
|
|
|
} 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++) {
|
2023-02-14 02:51:14 +01:00
|
|
|
var _node = i < node_list? nodes[| i] : steamNode[i - node_list];
|
2022-09-21 06:09:40 +02:00
|
|
|
if(!_node) continue;
|
|
|
|
|
|
|
|
if(i % 2) {
|
2023-02-14 02:51:14 +01:00
|
|
|
BLEND_OVERRIDE;
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_stretched_ext(THEME.node_bg, 0, ui(4), yy, list_width - 8, list_height, c_white, 0.2);
|
2023-02-14 02:51:14 +01:00
|
|
|
BLEND_NORMAL;
|
2022-09-21 06:09:40 +02:00
|
|
|
}
|
|
|
|
|
2022-12-19 13:35:30 +01:00
|
|
|
if(_hover && point_in_rectangle(_m[0], _m[1], 0, yy, list_width, yy + list_height - 1)) {
|
2022-11-21 06:38:44 +01:00
|
|
|
draw_sprite_stretched_ext(THEME.node_active, 0, ui(4), yy, list_width - ui(8), list_height, COLORS._main_accent, 1);
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_press(mb_left, pFOCUS))
|
2022-09-21 06:09:40 +02:00
|
|
|
file_dragging = _node;
|
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_press(mb_right, pFOCUS)) {
|
2022-09-21 06:09:40 +02:00
|
|
|
_menu_node = _node;
|
2023-02-14 02:51:14 +01:00
|
|
|
initMenu();
|
2022-11-03 11:44:49 +01:00
|
|
|
var dia = dialogCall(o_dialog_menubox, mouse_mx + ui(8), mouse_my + ui(8));
|
2023-01-01 02:06:02 +01:00
|
|
|
dia.setMenu(contentMenu);
|
2022-09-21 06:09:40 +02:00
|
|
|
}
|
|
|
|
}
|
2022-09-27 06:37:28 +02:00
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
var spr_x = list_height / 2 + ui(14);
|
2022-09-21 06:09:40 +02:00
|
|
|
var spr_y = yy + list_height / 2;
|
2022-11-03 11:44:49 +01:00
|
|
|
var spr_s = list_height - ui(8);
|
2023-01-17 08:11:55 +01:00
|
|
|
if(variable_struct_exists(_node, "getSpr")) _node.getSpr();
|
|
|
|
if(sprite_exists(_node.spr)) {
|
2022-09-27 06:37:28 +02:00
|
|
|
var sw = sprite_get_width(_node.spr);
|
|
|
|
var sh = sprite_get_height(_node.spr);
|
|
|
|
var ss = spr_s / max(sw, sh);
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
draw_sprite_ext(_node.spr, frame, sx, sy, ss, ss, 0, c_white, 1);
|
2022-11-03 11:44:49 +01:00
|
|
|
} else
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.group, 0, spr_x, spr_y, 0.75, c_white);
|
2022-09-21 06:09:40 +02:00
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
|
2023-02-14 02:51:14 +01:00
|
|
|
draw_text_over(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-12-16 09:18:09 +01:00
|
|
|
folderPane = new scrollPane(group_w - ui(4), content_h, function(_y, _m) {
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_clear(COLORS.panel_bg_clear);
|
2022-11-03 11:44:49 +01:00
|
|
|
var hh = ui(8);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-09-27 06:37:28 +02:00
|
|
|
for(var i = 0; i < ds_list_size(root.subDir); i++) {
|
2022-12-19 13:35:30 +01:00
|
|
|
var hg = root.subDir[| i].draw(self, ui(8), _y, _m, folderPane.w - ui(20), pHOVER && folderPane.hover, pFOCUS, root);
|
2022-01-25 04:05:30 +01:00
|
|
|
hh += hg;
|
|
|
|
_y += hg;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return hh;
|
|
|
|
});
|
|
|
|
|
2022-01-18 05:31:19 +01:00
|
|
|
function onResize() {
|
2022-12-16 09:18:09 +01:00
|
|
|
initSize();
|
2023-01-17 08:11:55 +01:00
|
|
|
|
|
|
|
folderPane.resize(group_w - ui(4), content_h);
|
2022-01-13 05:24:03 +01:00
|
|
|
contentPane.resize(content_w, content_h);
|
2022-12-16 09:18:09 +01:00
|
|
|
folderPane.resize(group_w - ui(4), content_h);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-01-25 04:05:30 +01:00
|
|
|
function setContext(cont) {
|
|
|
|
context = cont;
|
|
|
|
contentPane.scroll_y_raw = 0;
|
|
|
|
contentPane.scroll_y_to = 0;
|
|
|
|
}
|
|
|
|
|
2022-01-25 10:58:11 +01:00
|
|
|
function refreshContext() {
|
2022-09-27 06:37:28 +02:00
|
|
|
context.scan([".json", ".pxcc"]);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
function saveCollection(_name, save_surface = true, metadata = noone) {
|
2022-01-13 05:24:03 +01:00
|
|
|
if(PANEL_INSPECTOR.inspecting == noone) return;
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
var _pre_name = (data_path == ""? "" : data_path + "\\") + _name;
|
|
|
|
var ext = filename_ext(_pre_name);
|
|
|
|
var _path = ext == ".pxcc"? _pre_name : _pre_name + ".pxcc";
|
|
|
|
|
2022-12-21 02:30:23 +01:00
|
|
|
if(ds_list_empty(PANEL_GRAPH.nodes_select_list))
|
2023-02-14 02:51:14 +01:00
|
|
|
SAVE_COLLECTION(PANEL_INSPECTOR.inspecting, _path, save_surface, metadata);
|
2022-12-21 02:30:23 +01:00
|
|
|
else
|
2023-02-14 02:51:14 +01:00
|
|
|
SAVE_COLLECTIONS(PANEL_GRAPH.nodes_select_list, _path, save_surface, metadata);
|
2023-01-01 02:06:02 +01:00
|
|
|
|
|
|
|
updated_path = _path;
|
|
|
|
updated_prog = 1;
|
2023-02-14 02:51:14 +01:00
|
|
|
|
|
|
|
refreshContext();
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-11-14 03:16:15 +01:00
|
|
|
function drawContent(panel) {
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_clear_alpha(COLORS.panel_bg_clear, 0);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
var content_y = ui(48);
|
2022-12-16 09:18:09 +01:00
|
|
|
draw_sprite_stretched(THEME.ui_panel_bg, 1, group_w, content_y, content_w, content_h);
|
2022-11-14 03:16:15 +01:00
|
|
|
contentPane.active = pHOVER;
|
2023-02-14 02:51:14 +01:00
|
|
|
contentPane.draw(group_w, content_y, mx - group_w, my - content_y);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-11-14 03:16:15 +01:00
|
|
|
folderPane.active = pHOVER;
|
2022-01-25 10:58:11 +01:00
|
|
|
folderPane.draw(0, content_y, mx, my - content_y);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
#region resize width
|
|
|
|
if(group_w_dragging) {
|
|
|
|
CURSOR = cr_size_we;
|
|
|
|
|
|
|
|
var _gw = group_w_sx + (mx - group_w_mx);
|
|
|
|
_gw = max(ui(180), _gw);
|
|
|
|
group_w = _gw;
|
|
|
|
|
|
|
|
onResize();
|
|
|
|
|
|
|
|
if(mouse_release(mb_left)) {
|
|
|
|
group_w_dragging = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
var _x = ui(16);
|
|
|
|
var _y = ui(24);
|
|
|
|
var bh = line_height(f_p0b, 8);
|
2023-02-14 02:51:14 +01:00
|
|
|
var rootx = 0;
|
2022-09-27 06:37:28 +02:00
|
|
|
|
|
|
|
for( var i = 0; i < array_length(roots); i++ ) {
|
|
|
|
var r = roots[i];
|
2022-11-18 03:20:31 +01:00
|
|
|
var b = buttonInstant(THEME.button_hide_fill, _x - ui(8), _y - bh / 2, string_width(r[0]) + ui(20), bh, [mx, my], pFOCUS, pHOVER);
|
2022-09-27 06:37:28 +02:00
|
|
|
if(b == 2) {
|
|
|
|
mode = i;
|
|
|
|
root = r[1];
|
2022-11-14 03:16:15 +01:00
|
|
|
context = root;
|
2022-09-27 06:37:28 +02:00
|
|
|
}
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_text(f_p0b, fa_left, fa_center, i == mode? COLORS._main_text
|
|
|
|
: COLORS._main_text_sub);
|
2022-09-27 06:37:28 +02:00
|
|
|
draw_text(_x, _y, r[0]);
|
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
_x += string_width(r[0]) + ui(20);
|
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;
|
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
var bx = w - ui(40);
|
|
|
|
var by = ui(12);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-01-25 10:58:11 +01:00
|
|
|
if(search_string == "") {
|
2023-02-14 02:51:14 +01:00
|
|
|
if(bx > rootx) {
|
|
|
|
var txt = contentView? get_text("view_grid", "Grid view") : get_text("view_list", "List view");
|
|
|
|
if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), [mx, my], pFOCUS, pHOVER, txt, THEME.view_mode, contentView) == 2) {
|
|
|
|
contentView = !contentView;
|
|
|
|
}
|
2022-09-21 06:09:40 +02:00
|
|
|
}
|
2022-11-03 11:44:49 +01:00
|
|
|
bx -= ui(32);
|
2022-09-21 06:09:40 +02:00
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
if(mode == 0 && !DEMO) {
|
|
|
|
if(bx > rootx) {
|
|
|
|
if(context != root) {
|
|
|
|
var txt = get_text("panel_collection_add_node", "Add selecting node as collection");
|
|
|
|
if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), [mx, my], pFOCUS, pHOVER, txt, THEME.add, 0, COLORS._main_value_positive) == 2) {
|
|
|
|
if(PANEL_INSPECTOR.inspecting != noone) {
|
|
|
|
data_path = context.path;
|
|
|
|
var dia = dialogCall(o_dialog_file_name_collection, mouse_mx + ui(8), mouse_my + ui(8));
|
|
|
|
if(PANEL_INSPECTOR.inspecting)
|
|
|
|
dia.meta.name = PANEL_INSPECTOR.inspecting.display_name;
|
|
|
|
}
|
2022-09-27 06:37:28 +02:00
|
|
|
}
|
2023-02-14 02:51:14 +01:00
|
|
|
} else {
|
|
|
|
draw_sprite_ui_uniform(THEME.add, 0, bx + ui(12), by + ui(12), 1, COLORS._main_icon_dark);
|
2022-01-25 10:58:11 +01:00
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2022-11-03 11:44:49 +01:00
|
|
|
bx -= ui(32);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
if(bx > rootx) {
|
|
|
|
var txt = get_text("panel_collection_add_folder", "Add folder");
|
|
|
|
if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), [mx, my], pFOCUS, pHOVER, txt) == 2) {
|
|
|
|
var dia = dialogCall(o_dialog_file_name, mouse_mx + 8, mouse_my + 8);
|
|
|
|
dia.onModify = function (txt) {
|
|
|
|
directory_create(txt);
|
|
|
|
refreshContext();
|
|
|
|
};
|
|
|
|
dia.path = context.path + "\\";
|
|
|
|
}
|
|
|
|
draw_sprite_ui_uniform(THEME.folder_add, 0, bx + ui(12), by + ui(12), 1, COLORS._main_icon);
|
|
|
|
draw_sprite_ui_uniform(THEME.folder_add, 1, bx + ui(12), by + ui(12), 1, COLORS._main_value_positive);
|
2022-09-27 06:37:28 +02:00
|
|
|
}
|
2022-11-03 11:44:49 +01:00
|
|
|
bx -= ui(32);
|
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) {
|
|
|
|
var txt = get_text("panel_collection_open_file", "Open in file explorer");
|
|
|
|
if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), [mx, my], pFOCUS, pHOVER, txt, THEME.folder) == 2)
|
|
|
|
shellOpenExplorer(context.path);
|
2022-01-25 10:58:11 +01:00
|
|
|
}
|
2022-11-03 11:44:49 +01:00
|
|
|
bx -= ui(32);
|
2023-02-14 02:51:14 +01:00
|
|
|
|
|
|
|
if(bx > rootx) {
|
|
|
|
var txt = get_text("refresh", "Refresh");
|
|
|
|
if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), [mx, my], pFOCUS, pHOVER, txt, THEME.refresh) == 2)
|
|
|
|
refreshContext();
|
|
|
|
}
|
2022-11-03 11:44:49 +01:00
|
|
|
bx -= ui(32);
|
2022-01-25 10:58:11 +01:00
|
|
|
} 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
|
|
|
}
|
|
|
|
|
|
|
|
if(file_dragging) {
|
2022-09-27 06:37:28 +02:00
|
|
|
if(file_dragging.spr)
|
2022-01-13 05:24:03 +01:00
|
|
|
draw_sprite_ext(file_dragging.spr, 0, mx, my, 1, 1, 0, c_white, 0.5);
|
|
|
|
|
2022-11-14 03:16:15 +01:00
|
|
|
if(panelHover(PANEL_GRAPH))
|
2022-09-27 06:37:28 +02:00
|
|
|
dragToGraph();
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
if(mouse_release(mb_left))
|
2022-01-13 05:24:03 +01:00
|
|
|
file_dragging = noone;
|
|
|
|
}
|
|
|
|
}
|
2022-09-27 06:37:28 +02:00
|
|
|
|
|
|
|
static dragToGraph = function() {
|
|
|
|
var path = file_dragging.path;
|
|
|
|
ds_list_clear(PANEL_GRAPH.nodes_select_list);
|
|
|
|
|
2023-02-14 02:51:14 +01:00
|
|
|
if(string_lower(filename_ext(path)) == ".png") {
|
2022-09-27 06:37:28 +02:00
|
|
|
var app = Node_create_Image_path(0, 0, path);
|
|
|
|
|
|
|
|
PANEL_GRAPH.node_focus = app;
|
|
|
|
PANEL_GRAPH.node_dragging = app;
|
|
|
|
PANEL_GRAPH.node_drag_sx = app.x;
|
|
|
|
PANEL_GRAPH.node_drag_sy = app.y;
|
|
|
|
} else {
|
|
|
|
var app = APPEND(file_dragging.path);
|
|
|
|
|
|
|
|
if(!is_struct(app) && ds_exists(app, ds_type_list)) {
|
|
|
|
PANEL_GRAPH.node_focus = noone;
|
|
|
|
ds_list_copy(PANEL_GRAPH.nodes_select_list, app);
|
|
|
|
|
|
|
|
if(!ds_list_empty(app)) {
|
|
|
|
PANEL_GRAPH.node_dragging = app[| 0];
|
|
|
|
PANEL_GRAPH.node_drag_sx = app[| 0].x;
|
|
|
|
PANEL_GRAPH.node_drag_sy = app[| 0].y;
|
|
|
|
}
|
|
|
|
ds_list_destroy(app);
|
|
|
|
} else {
|
|
|
|
PANEL_GRAPH.node_focus = app;
|
|
|
|
PANEL_GRAPH.node_dragging = app;
|
|
|
|
PANEL_GRAPH.node_drag_sx = app.x;
|
|
|
|
PANEL_GRAPH.node_drag_sy = app.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PANEL_GRAPH.node_drag_mx = 0;
|
|
|
|
PANEL_GRAPH.node_drag_my = 0;
|
|
|
|
|
|
|
|
PANEL_GRAPH.node_drag_ox = 0;
|
|
|
|
PANEL_GRAPH.node_drag_oy = 0;
|
|
|
|
|
|
|
|
file_dragging = false;
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|