file explorer panel

This commit is contained in:
Tanasart 2024-05-16 14:42:34 +07:00
parent d576d2e43c
commit 976577fe77
23 changed files with 657 additions and 81 deletions

View file

@ -700,6 +700,7 @@
{"name":"node_de_stray","order":1,"path":"scripts/node_de_stray/node_de_stray.yy",},
{"name":"node_delay","order":5,"path":"scripts/node_delay/node_delay.yy",},
{"name":"node_diffuse","order":2,"path":"scripts/node_diffuse/node_diffuse.yy",},
{"name":"node_directory_search","order":23,"path":"scripts/node_directory_search/node_directory_search.yy",},
{"name":"node_displace","order":1,"path":"scripts/node_displace/node_displace.yy",},
{"name":"node_display_image","order":4,"path":"scripts/node_display_image/node_display_image.yy",},
{"name":"node_display_text","order":3,"path":"scripts/node_display_text/node_display_text.yy",},
@ -768,7 +769,6 @@
{"name":"node_image_grid","order":3,"path":"scripts/node_image_grid/node_image_grid.yy",},
{"name":"node_image_sequence","order":1,"path":"scripts/node_image_sequence/node_image_sequence.yy",},
{"name":"node_image_sheet","order":4,"path":"scripts/node_image_sheet/node_image_sheet.yy",},
{"name":"node_directory_search","order":23,"path":"scripts/node_directory_search/node_directory_search.yy",},
{"name":"node_interpret_number","order":3,"path":"scripts/node_interpret_number/node_interpret_number.yy",},
{"name":"node_invert","order":6,"path":"scripts/node_invert/node_invert.yy",},
{"name":"node_isosurf","order":3,"path":"scripts/node_isosurf/node_isosurf.yy",},
@ -1099,6 +1099,7 @@
{"name":"panel_preview_window","order":1,"path":"scripts/panel_preview_window/panel_preview_window.yy",},
{"name":"panel_test","order":8,"path":"scripts/panel_test/panel_test.yy",},
{"name":"panel_text_editor","order":9,"path":"scripts/panel_text_editor/panel_text_editor.yy",},
{"name":"panel_file_explorer","order":12,"path":"scripts/panel_file_explorer/panel_file_explorer.yy",},
{"name":"panel_tunnels","order":1,"path":"scripts/panel_tunnels/panel_tunnels.yy",},
{"name":"panel_workspace","order":4,"path":"scripts/panel_workspace/panel_workspace.yy",},
{"name":"path_function","order":4,"path":"scripts/path_function/path_function.yy",},
@ -1633,6 +1634,7 @@
{"name":"s_node_destray","order":16,"path":"sprites/s_node_destray/s_node_destray.yy",},
{"name":"s_node_diffuse","order":41,"path":"sprites/s_node_diffuse/s_node_diffuse.yy",},
{"name":"s_node_dilate","order":17,"path":"sprites/s_node_dilate/s_node_dilate.yy",},
{"name":"s_node_directory","order":35,"path":"sprites/s_node_directory/s_node_directory.yy",},
{"name":"s_node_displace","order":18,"path":"sprites/s_node_displace/s_node_displace.yy",},
{"name":"s_node_dithering","order":19,"path":"sprites/s_node_dithering/s_node_dithering.yy",},
{"name":"s_node_dot_product","order":13,"path":"sprites/s_node_dot_product/s_node_dot_product.yy",},

View file

@ -1116,6 +1116,7 @@
{"id":{"name":"node_delay","path":"scripts/node_delay/node_delay.yy",},},
{"id":{"name":"node_diffuse","path":"scripts/node_diffuse/node_diffuse.yy",},},
{"id":{"name":"node_dilate","path":"scripts/node_dilate/node_dilate.yy",},},
{"id":{"name":"node_directory_search","path":"scripts/node_directory_search/node_directory_search.yy",},},
{"id":{"name":"node_displace","path":"scripts/node_displace/node_displace.yy",},},
{"id":{"name":"node_display_image","path":"scripts/node_display_image/node_display_image.yy",},},
{"id":{"name":"node_display_text","path":"scripts/node_display_text/node_display_text.yy",},},
@ -1190,7 +1191,6 @@
{"id":{"name":"node_image_sequence","path":"scripts/node_image_sequence/node_image_sequence.yy",},},
{"id":{"name":"node_image_sheet","path":"scripts/node_image_sheet/node_image_sheet.yy",},},
{"id":{"name":"node_image","path":"scripts/node_image/node_image.yy",},},
{"id":{"name":"node_directory_search","path":"scripts/node_directory_search/node_directory_search.yy",},},
{"id":{"name":"node_interpret_number","path":"scripts/node_interpret_number/node_interpret_number.yy",},},
{"id":{"name":"node_invert","path":"scripts/node_invert/node_invert.yy",},},
{"id":{"name":"node_isosurf","path":"scripts/node_isosurf/node_isosurf.yy",},},
@ -1569,6 +1569,7 @@
{"id":{"name":"panel_preview","path":"scripts/panel_preview/panel_preview.yy",},},
{"id":{"name":"panel_test","path":"scripts/panel_test/panel_test.yy",},},
{"id":{"name":"panel_text_editor","path":"scripts/panel_text_editor/panel_text_editor.yy",},},
{"id":{"name":"panel_file_explorer","path":"scripts/panel_file_explorer/panel_file_explorer.yy",},},
{"id":{"name":"panel_tunnels","path":"scripts/panel_tunnels/panel_tunnels.yy",},},
{"id":{"name":"panel_workspace","path":"scripts/panel_workspace/panel_workspace.yy",},},
{"id":{"name":"path_function","path":"scripts/path_function/path_function.yy",},},
@ -2190,6 +2191,7 @@
{"id":{"name":"s_node_destray","path":"sprites/s_node_destray/s_node_destray.yy",},},
{"id":{"name":"s_node_diffuse","path":"sprites/s_node_diffuse/s_node_diffuse.yy",},},
{"id":{"name":"s_node_dilate","path":"sprites/s_node_dilate/s_node_dilate.yy",},},
{"id":{"name":"s_node_directory","path":"sprites/s_node_directory/s_node_directory.yy",},},
{"id":{"name":"s_node_displace","path":"sprites/s_node_displace/s_node_displace.yy",},},
{"id":{"name":"s_node_dithering","path":"sprites/s_node_dithering/s_node_dithering.yy",},},
{"id":{"name":"s_node_dot_product","path":"sprites/s_node_dot_product/s_node_dot_product.yy",},},

Binary file not shown.

View file

@ -4,19 +4,22 @@ event_inherited();
#region data
destroy_on_click_out = true;
dialog_w = ui(290);
dialog_h = ui(172);
dialog_h = ui(180);
paths = "";
is_dir = false;
dir_recursive = false;
dir_filter = "*";
dir_filter = ".png";
function setPath(path) {
paths = path;
is_dir = directory_exists(path[0]);
if(is_dir)
if(is_dir) {
dialog_h += ui(96);
dialog_w += ui(80);
array_push(nodes, ALL_NODES[? "Node_Directory_Search"]);
}
}
cb_recursive = new checkBox(function(val) { dir_recursive = !dir_recursive; });

View file

@ -11,7 +11,7 @@ if !ready exit;
#endregion
#region nodes
draw_sprite_stretched(THEME.ui_panel_bg, 1, dialog_x + ui(16), dialog_y + ui(44), dialog_w - ui(32), ui(112));
draw_sprite_stretched(THEME.ui_panel_bg, 1, dialog_x + ui(16), dialog_y + ui(44), dialog_w - ui(32), ui(120));
var grid_size = ui(64);
var grid_space = ui(16);
var grid_width = grid_size + grid_space;
@ -29,21 +29,20 @@ if !ready exit;
if(sHOVER && point_in_rectangle(mouse_mx, mouse_my, xx, yy, xx + grid_width, yy + grid_size)) {
draw_sprite_stretched_ext(THEME.node_active, 0, xx, yy, grid_size, grid_size, COLORS._main_accent, 1);
if(mouse_press(mb_left, sFOCUS)) {
var path_arr = path_search(paths, dir_recursive, dir_filter);
switch(i) {
case 0 :
var path_arr = paths_to_array_ext(paths, dir_filter);
switch(_node.node) {
case "Node_Image" :
for( var i = 0, n = array_length(path_arr); i < n; i++ ) {
var path = path_arr[i];
Node_create_Image_path(nx, ny, path);
ny += 160;
}
break;
case 1 :
Node_create_Image_Sequence_path(nx, ny, path_arr);
break;
case 2 :
Node_create_Image_Animated_path(nx, ny, path_arr);
break;
case "Node_Image_Sequence" : Node_create_Image_Sequence_path(nx, ny, path_arr); break;
case "Node_Image_Animated" : Node_create_Image_Animated_path(nx, ny, path_arr); break;
case "Node_Directory_Search" : Node_create_Directory_path(nx, ny, paths[0]); break;
}
PANEL_GRAPH.fullView();
instance_destroy();
@ -52,14 +51,14 @@ if !ready exit;
draw_sprite_ui_uniform(_node.spr, 0, xx + grid_size / 2, yy + grid_size / 2, 0.5);
draw_set_text(f_p2, fa_center, fa_top, COLORS._main_text);
draw_text(xx + grid_size / 2, yy + grid_size + 4, _node.name);
draw_set_text(f_p3, fa_center, fa_top, COLORS._main_text);
draw_text_ext(xx + grid_size / 2, yy + grid_size + 4, _node.name, -1, grid_size + grid_space / 2);
}
#endregion
#region directory option
if(is_dir) {
var dir_y = dialog_y + ui(172);
var dir_y = dialog_y + ui(180);
cb_recursive.setFocusHover(sFOCUS, sHOVER);
cb_recursive.draw(dialog_x + dialog_w - ui(48), dir_y, dir_recursive, mouse_ui);

View file

@ -9,7 +9,7 @@ event_inherited();
target = noone;
dir_paths = "";
dir_recursive = false;
dir_filter = "*";
dir_filter = ".png";
cb_recursive = new checkBox(function(val) { dir_recursive = !dir_recursive; });

View file

@ -31,7 +31,7 @@ if !ready exit;
if(buttonInstant(THEME.button_def, bx, dir_y, ui(100), ui(40), mouse_ui, sFOCUS, sHOVER) == 2) {
if(target) {
var paths = paths_to_array(dir_paths, dir_recursive, dir_filter);
var paths = paths_to_array_ext(dir_paths, dir_filter);
target.updatePaths(paths);
target.doUpdate();
}

View file

@ -34,7 +34,7 @@ if !target exit;
key_release();
if(path != "") {
var paths = paths_to_array(path);
var paths = paths_to_array_ext(path, ".png;.jpg");
var arr = target.getInputData(0);
for( var i = 0, n = array_length(paths); i < n; i++ )

View file

@ -14,6 +14,7 @@ if(winMan_isMinimized()) exit;
if(is_method(content)) content = content();
switch(type) {
case VALUE_TYPE.float :
case VALUE_TYPE.integer :
case VALUE_TYPE.text :

View file

@ -156,6 +156,9 @@ function draw_tooltip_surface(surf) { #region
function draw_tooltip_sprite(spr) { #region
if(!sprite_exists(spr)) return;
var ox = sprite_get_xoffset(spr);
var oy = sprite_get_yoffset(spr);
var sw = sprite_get_width(spr);
var sh = sprite_get_height(spr);
var sn = sprite_get_number(spr);
@ -171,8 +174,8 @@ function draw_tooltip_sprite(spr) { #region
draw_sprite_stretched(THEME.textbox, 3, mx, my, ww + ui(16), hh + ui(16));
draw_sprite_stretched(THEME.textbox, 0, mx, my, ww + ui(16), hh + ui(16));
var sx = mx + ui(8);
var sy = my + ui(8);
var sx = mx + ui(8) + ox * ss;
var sy = my + ui(8) + oy * ss;
for( var i = 0; i < sn; i++ )
draw_sprite_ext(spr, i, sx + i * (sw * ss + 2), sy, ss, ss, 0, c_white, 1);

View file

@ -13,6 +13,15 @@ function Node_create_Directory_Search(_x, _y, _group = noone) { #region
return node;
} #endregion
function Node_create_Directory_path(_x, _y, path) { #region
if(!directory_exists(path)) return noone;
var node = new Node_Directory_Search(_x, _y, PANEL_GRAPH.getCurrentContext());
node.inputs[| 0].setValue(path);
node.doUpdate();
return node;
} #endregion
function Node_Directory_Search(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Directory Search";
color = COLORS.node_blend_input;
@ -90,8 +99,7 @@ function Node_Directory_Search(_x, _y, _group = noone) : Node(_x, _y, _group) co
deleteSprite(paths[$ _paths[i]]);
paths = {};
var _paths = paths_to_array_ext(path, filter);
print(array_length(_paths));
var _paths = path_dir_get_files(path, filter);
for (var i = 0, n = array_length(_paths); i < n; i++) {
var _path = _paths[i];
@ -100,6 +108,8 @@ function Node_Directory_Search(_x, _y, _group = noone) : Node(_x, _y, _group) co
if(type == 0) refreshSprite(paths[$ _path]);
else if(type == 1) refreshText(paths[$ _path]);
}
setDisplayName(filename_name_only(path));
} #endregion
insp1UpdateTooltip = __txt("Refresh");

View file

@ -94,7 +94,7 @@ function Node_Image_Animated(_x, _y, _group = noone) : Node(_x, _y, _group) cons
return true;
}
var paths = paths_to_array(path);
var paths = paths_to_array_ext(path);
inputs[| 0].setValue(paths);
if(updatePaths(paths)) {

View file

@ -78,7 +78,7 @@ function Node_Image_Sequence(_x, _y, _group = noone) : Node(_x, _y, _group) cons
return true;
}
var paths = paths_to_array(path);
var paths = paths_to_array_ext(path);
inputs[| 0].setValue(path);
if(updatePaths(paths)) {

View file

@ -0,0 +1,73 @@
function Panel_Console() : PanelContent() constructor {
title = "Console";
w = ui(640);
h = ui(320);
command = "";
history = [];
cmd_history = [];
cmd_index = 0;
keyboard_string = "";
static submit_command = function() {
if(command == "") return;
array_push(history, { txt: command, color: COLORS._main_text_sub });
array_push(cmd_history, command);
var cmd = string_splice(command, " ");
switch(cmd[0]) {
case "flag":
if(array_length(cmd) < 2) break;
var flg = array_safe_get(cmd, 1, "");
global.FLAG[$ flg] = !global.FLAG[$ flg];
array_push(history, { txt: $"Toggled debug flag: {flg} = {global.FLAG[$ flg]? "True" : "False"}", color: COLORS._main_value_positive });
break;
}
keyboard_string = "";
command = "";
}
function drawContent(panel) {
HOTKEY_BLOCK = true;
command = keyboard_string;
draw_clear_alpha(CDEF.main_dkblack, 1);
draw_set_color(c_black);
draw_set_alpha(0.75);
draw_rectangle(0, h - ui(28), w, h, false);
draw_set_alpha(1);
draw_set_text(f_code, fa_left, fa_bottom, COLORS._main_text);
draw_text(ui(8), h - ui(4), command);
draw_set_color(COLORS._main_text_sub);
draw_text(ui(8) + string_width(command), h - ui(4), "_");
var hy = h - ui(32);
for( var i = 0; i < array_length(history); i++ ) {
var his = history[array_length(history) - i - 1];
var txt = his.txt;
draw_set_color(his.color);
draw_text_ext(ui(8), hy, txt, -1, w - ui(16));
hy -= string_height_ext(txt, -1, w - ui(16));
if(hy <= 0) break;
}
if(keyboard_check_pressed(vk_enter))
submit_command();
if(keyboard_check_pressed(vk_up)) {
cmd_index = max(0, cmd_index - 1);
keyboard_string = array_safe_get(cmd_history, cmd_index, "");
command = keyboard_string;
} else if(keyboard_check_pressed(vk_anykey))
cmd_index = array_length(cmd_history);
}
}

View file

@ -0,0 +1,399 @@
enum FILE_EXPLORER_VIEW {
list,
grid
}
global.__temp_fileMap = {}
function ExpCreateFile(path) {
INLINE
if(struct_has(global.__temp_fileMap, path)) return global.__temp_fileMap[$ path];
var f;
if(directory_exists(path))
f = new ExpDir(path);
else
f = new ExpFile(path);
global.__temp_fileMap[$ path] = f;
return f;
}
function ExpFile(path) constructor {
self.path = string_trim(path, [ "/", "\\" ]);
name = filename_name_only(path);
ext = string_lower(filename_ext(path));
load_thumb = false;
thumbnail = noone;
th_w = 1;
th_h = 1;
static getThumbnail = function() {
if(thumbnail == -1)
return noone;
else if(thumbnail != noone)
return thumbnail;
thumbnail = -1;
switch(ext) {
case ".png" :
case ".jpg" :
thumbnail = sprite_add(path, 0, 0, 0, 0, 0);
if(thumbnail) {
load_thumb = true;
th_w = sprite_get_width(thumbnail);
th_h = sprite_get_height(thumbnail);
sprite_set_offset(thumbnail, th_w / 2, th_h / 2);
}
break;
case ".pxc":
case ".pxcc":
thumbnail = THEME.icon_64;
th_w = 64;
th_h = 64;
break;
}
return thumbnail;
}
static destroy = function() {
if(load_thumb) sprite_delete(thumbnail);
}
}
function ExpDir(path) : ExpFile(path) constructor {
directories = [];
files = [];
open = -1;
static getContent = function() {
directories = [];
files = [];
if(!directory_exists(path)) return;
var f = file_find_first(path + "\\*", fa_directory);
while (f != "") {
var _fp = $"{path}\\{f}";
if(directory_exists(_fp))
array_push(directories, ExpCreateFile(_fp));
f = file_find_next();
}
file_find_close();
var f = file_find_first(path + "\\*", fa_none);
while (f != "") {
var _fp = $"{path}\\{f}";
if(file_exists(_fp) && !directory_exists(_fp))
array_push(files, ExpCreateFile(_fp));
f = file_find_next();
}
file_find_close();
return self;
}
static destroy = function() {
array_foreach(directories, function(dir) { dir.destroy(); return true; });
array_foreach(files, function(fil) { fil.destroy(); return true; });
}
}
function ExpRoot() constructor {
name = "Computer";
directories = [];
files = [];
open = -1;
static getContent = function() {
directories = [];
for(var i = 0; i < 26; i++) {
var _dr = $"{chr(ord("A") + i)}:";
if(directory_exists(_dr))
array_push(directories, new ExpDir(_dr));
}
} getContent();
static destroy = function() {
array_foreach(directories, function(dir) { dir.destroy(); return true; });
}
}
function Panel_File_Explorer() : PanelContent() constructor {
title = "File Explorer";
w = ui(320);
h = ui(540);
auto_pin = true;
fileMap = {};
global.__temp_fileMap = fileMap;
rootFile = noone;
function setRoot(_root = "") {
if(rootFile)
rootFile.destroy();
if(_root != "" && directory_exists(_root)) {
root = _root;
rootFile = new ExpDir(root).getContent();
PREFERENCES.file_explorer = root;
return;
}
rootFile = new ExpRoot();
root = "";
PREFERENCES.file_explorer = root;
} setRoot(PREFERENCES.file_explorer);
scroll_y = 0;
scroll_y_to = 0;
scroll_y_max = 0;
item_height = ui(20);
cntPad = ui(4);
padding = ui(8);
top_bar = ui(44);
tb_root = new textBox(TEXTBOX_INPUT.text, function(val) {
setRoot(val);
});
file_selectings = [];
file_hovering = noone;
file_dragging = false;
file_drag_mx = 0;
file_drag_my = 0;
frame_dragging = false;
frame_drag_mx = false;
frame_drag_my = false;
path_dragging = -1;
contentPane = new scrollPane(w - padding - padding - cntPad * 2, h - padding - top_bar - cntPad * 2, function(_y, _m, _r) {
draw_clear_alpha(COLORS.panel_bg_clear, 0);
if(frame_dragging) {
draw_sprite_stretched_points_clamp(THEME.ui_selection, 0, frame_drag_mx, frame_drag_my, _m[0], _m[1], COLORS._main_accent);
file_selectings = [];
}
file_hovering = noone;
var _h = drawDir(rootFile, 0, _y, contentPane.surface_w, _m);
if(mouse_press(mb_left, pFOCUS)) {
if(file_hovering == noone) {
file_selectings = [];
frame_dragging = true;
frame_drag_mx = _m[0];
frame_drag_my = _m[1];
} else {
if(!array_exists(file_selectings, file_hovering))
file_selectings = [ file_hovering ];
path_dragging = -1;
file_dragging = true;
file_drag_mx = mouse_mx;
file_drag_my = mouse_my;
}
}
if(mouse_release(mb_left)) frame_dragging = false;
if(file_dragging) {
if(path_dragging == -1 && point_distance(file_drag_mx, file_drag_my, mouse_mx, mouse_my) > 8) {
path_dragging = [];
for (var i = 0, n = array_length(file_selectings); i < n; i++)
path_dragging[i] = file_selectings[i].path;
}
if(mouse_release(mb_left)) {
file_dragging = false;
if(path_dragging != -1)
o_main.load_file_path(path_dragging);
path_dragging = -1;
}
}
return _h;
} );
function onResize() { #region
initSize();
contentPane.resize(w - padding - padding - cntPad * 2, h - padding - top_bar - cntPad * 2);
} #endregion
function drawDir(dirObject, _x, _y, _w, _m) {
var _h = 0;
var _sy = _y;
draw_set_text(f_p2, fa_left, fa_top, COLORS._main_text);
var _ith = line_get_height() + ui(4);
for (var i = 0, n = array_length(dirObject.directories); i < n; i++) {
var _dir = dirObject.directories[i];
var _px = _x + ui(2);
var _py = _sy + ui(2);
var _pw = _w - ui(4);
var _ph = _ith;
var _ind = 0;
var _ppw = _pw;
if(contentPane.hover && point_in_rectangle(_m[0], _m[1], _px, _py, _px + _ppw, _py + _ph)) {
file_hovering = _dir;
_ind = 3;
if(mouse_press(mb_left)) {
if(_dir.open == -1)
_dir.getContent();
_dir.open = !_dir.open;
}
}
draw_sprite_stretched(THEME.ui_panel_bg, _ind, _px, _py, _pw, _ph);
var _tx = _px + ui(2);
var _ty = _py + ui(2);
draw_sprite_ext(THEME.arrow, _dir.open? 3 : 0, _tx + _ph / 2, _py + _ph / 2, 1, 1, 0, COLORS._main_icon, 1);
_tx += _ph + ui(2);
draw_set_color(merge_color(COLORS._main_text, COLORS._main_text_sub, 0.5));
draw_text_add(_tx, _ty, _dir.name);
_h += _ith + ui(2);
_sy += _ith + ui(2);
if(_dir.open) {
var _drh = drawDir(_dir, _x + ui(8), _sy, _w - ui(8), _m);
_h += _drh;
_sy += _drh;
}
}
for (var i = 0, n = array_length(dirObject.files); i < n; i++) {
var _fil = dirObject.files[i];
var _px = _x + ui(2);
var _py = _sy + ui(2);
var _pw = _w - ui(4);
var _ph = _ith;
var _tw = ui(4) + _ph + string_width(_fil.name) + ui(8);
if(frame_dragging && rectangle_in_rectangle(_px, _py, _px + _tw, _py + _ph, frame_drag_mx, frame_drag_my, _m[0], _m[1]))
array_push(file_selectings, _fil);
var _sel = array_exists(file_selectings, _fil);
var _tx = _px + ui(2);
var _ty = _py + ui(2);
var _th = _fil.getThumbnail();
draw_set_color(c_white);
gpu_set_colorwriteenable(1, 1, 1, 0);
draw_rectangle(_px, _py, _px + _tw, _py + _ph, false);
gpu_set_colorwriteenable(1, 1, 1, 1);
if(_sel) draw_sprite_stretched_ext(THEME.ui_panel_bg, 4, _px, _py, _tw, _ph, merge_color(COLORS._main_icon_dark, COLORS._main_icon, 0.3), 1);
if(contentPane.hover && point_in_rectangle(_m[0], _m[1], _px, _py, _px + _tw, _py + _ph)) {
if(!mouse_click(mb_left)) {
draw_sprite_stretched_ext(THEME.ui_panel_fg, 1, _px, _py, _tw, _ph, COLORS._main_icon_light, 1);
TOOLTIP = [ _th, "sprite" ];
}
file_hovering = _fil;
if(mouse_press(mb_left) && key_mod_press(CTRL)) {
if(_sel) array_remove(file_selectings, _fil);
else array_push(file_selectings, _fil);
}
}
if(sprite_exists(_th)) {
var _ths = min(1, (_ph - ui(4)) / _fil.th_w, (_ph - ui(4)) / _fil.th_h);
draw_sprite_ext(_th, 0, _tx + _ph / 2, _py + _ph / 2, _ths, _ths, 0, c_white, 1);
}
_tx += _ph + ui(4);
draw_set_color(COLORS._main_text);
draw_text_add(_tx, _ty, _fil.name);
_h += _ith + ui(2);
_sy += _ith + ui(2);
}
return _h;
}
function drawContent(panel) {
draw_clear_alpha(COLORS.panel_bg_clear, 0);
var pad = padding;
var cnt_x = pad;
var cnt_y = top_bar;
var cnt_w = w - pad - cnt_x;
var cnt_h = h - pad - cnt_y;
draw_sprite_stretched(THEME.ui_panel_bg, 1, cnt_x, cnt_y, cnt_w, cnt_h);
var bs = top_bar - pad - ui(8);
if(buttonInstant(THEME.button_hide, pad, pad, bs, bs, [mx, my], pFOCUS, pHOVER, "Go up", THEME.arrow, 1, root != ""? COLORS._main_icon : COLORS._main_icon_dark) == 2)
if(root != "") setRoot(filename_dir(root));
var tb_x = cnt_x + ui(32);
var tb_y = pad;
var tb_w = w - pad - tb_x;
var tb_h = top_bar - pad - ui(8);
tb_root.setFocusHover(pFOCUS, pHOVER);
tb_root.font = f_p2;
tb_root.draw(tb_x, tb_y, tb_w, tb_h, root, [mx, my]);
contentPane.setFocusHover(pFOCUS, pHOVER);
contentPane.draw(cnt_x + cntPad, cnt_y + cntPad, mx - cnt_x - cntPad, my - cnt_y - cntPad);
}
function drawGUI() {
if(path_dragging != -1) {
for (var i = 0, n = array_length(file_selectings); i < n; i++) {
var f = file_selectings[i];
if(is_instanceof(f, ExpDir)) {
draw_sprite_ext(THEME.folder_content, 0, mouse_mx + 20 + 8 * i,
mouse_my + 20 + 8 * i,
1, 1, 0, c_white, 1);
} else if(is_instanceof(f, ExpDir)) {
var _s = 64 / max(f.th_w, f.th_h);
if(f.thumbnail) draw_sprite_ext(f.thumbnail, 0, mouse_mx + f.th_w * _s / 2 + 8 * i,
mouse_my + f.th_h * _s / 2 + 8 * i,
_s, _s, 0, c_white, 1);
}
}
}
}
}

View file

@ -0,0 +1,13 @@
{
"$GMScript":"",
"%Name":"panel_file_explorer",
"isCompatibility":false,
"isDnD":false,
"name":"panel_file_explorer",
"parent":{
"name":"_others",
"path":"folders/panels/_others.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",
}

View file

@ -61,6 +61,7 @@
case "Panel_Nodes" : return new Panel_Nodes();
case "Panel_Globalvar" : return new Panel_Globalvar();
case "Panel_Node_Align" : return new Panel_Node_Align();
case "Panel_File_Explorer" : return new Panel_File_Explorer();
case "Panel_Color" : return new Panel_Color();
case "Panel_Palette" : return new Panel_Palette();

View file

@ -208,7 +208,8 @@ function Panel_Menu() : PanelContent() constructor {
menuItem(__txt("Workspace"), function() { panelAdd("Panel_Workspace", true) }, noone, ["", "Workspace Panel"], function() { return findPanel("Panel_Workspace") != noone; } ),
menuItem(__txt("Animation"), function() { panelAdd("Panel_Animation", true) }, noone, ["", "Animation Panel"], function() { return findPanel("Panel_Animation") != noone; } ),
menuItem(__txt("Notifications"), function() { panelAdd("Panel_Notification", true) }, noone, ["", "Notification Panel"], function() { return findPanel("Panel_Notification") != noone; } ),
menuItem(__txtx("panel_globalvar", "Global Variables"), function() { panelAdd("Panel_Globalvar", true) }, noone, noone, function() { return findPanel("Panel_Globalvar") != noone; } ),
menuItem(__txt("Global Variables"), function() { panelAdd("Panel_Globalvar", true) }, noone, noone, function() { return findPanel("Panel_Globalvar") != noone; } ),
menuItem(__txt("File Explorer"), function() { panelAdd("Panel_File_Explorer", true) },noone, noone, function() { return findPanel("Panel_File_Explorer") != noone; } ),
menuItem(__txt("Nodes"), function(_dat) {
return submenuCall(_dat, [

View file

@ -1,60 +1,11 @@
function path_search(paths, recur = false, _filter = "") {
function path_search(paths, _filter = ".png") {
var _paths = [];
for( var i = 0, n = array_length(paths); i < n; i++ )
array_append(_paths, paths_to_array(paths[i], recur, _filter));
array_append(_paths, paths_to_array_ext(paths[i], _filter));
return _paths;
}
function paths_to_array(paths, recur = false, _filter = "") {
paths = string_trim_end(paths, ["/", "\\"]);
var _paths = [];
var in = 0;
var regx = new regex_tree(_filter);
if(directory_exists(paths)) {
var st = ds_stack_create();
ds_stack_push(st, paths);
while(!ds_stack_empty(st)) {
var curr_path = ds_stack_pop(st);
var file = file_find_first(curr_path + "/*", fa_directory);
while(file != "") {
var file_full = curr_path + "/" + file;
if(directory_exists(file_full) && recur) {
ds_stack_push(st, file_full);
} else if(path_is_image(file_full) && regx.isMatch(file_full)) {
array_push(_paths, file_full);
}
file = file_find_next();
}
file_find_close();
}
ds_stack_destroy(st);
} else if(file_exists_empty(paths) && regx.isMatch(paths))
array_push(_paths, paths);
return _paths;
}
function path_is_image(path) {
if(!file_exists_empty(path)) return false;
var ext = filename_ext(path);
switch(ext) {
case ".png":
case ".jpg":
case ".jpeg":
case ".gif":
return true;
}
return false;
}
function paths_to_array_ext(paths, _extension = "") {
function path_dir_get_files(paths, _extension = ".png") {
paths = string_trim_end(paths, ["/", "\\"]);
var _ext = string_splice(_extension, ";", false, false);
var _paths = [];
@ -85,4 +36,30 @@ function paths_to_array_ext(paths, _extension = "") {
ds_stack_destroy(st);
return _paths;
}
}
function paths_to_array_ext(paths, _extension = ".png") {
var _ext = string_splice(_extension, ";", false, false);
var _p = [];
for(var i = array_length(paths) - 1; i >= 0; i--) {
if(file_exists(paths[i]) && array_exists(_ext, filename_ext(paths[i])))
array_push(_p, paths[i]);
}
return _p;
}
function path_is_image(path) {
if(!file_exists_empty(path)) return false;
var ext = filename_ext(path);
switch(ext) {
case ".png":
case ".jpg":
case ".jpeg":
case ".gif":
return true;
}
return false;
}

View file

@ -135,6 +135,8 @@
PREFERENCES.gifski_path = "%APP%/gifski/";
PREFERENCES.ffmpeg_path = "%APP%/ffmpeg/";
PREFERENCES.file_explorer = "";
PREFERENCES.versions = {};
#endregion

Binary file not shown.

After

Width:  |  Height:  |  Size: 972 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 972 B

View file

@ -0,0 +1,90 @@
{
"$GMSprite":"",
"%Name":"s_node_directory",
"bboxMode":0,
"bbox_bottom":56,
"bbox_left":3,
"bbox_right":60,
"bbox_top":7,
"collisionKind":1,
"collisionTolerance":0,
"DynamicTexturePage":false,
"edgeFiltering":false,
"For3D":false,
"frames":[
{"$GMSpriteFrame":"","%Name":"b9a014be-d2a5-4725-9d3c-779de519ff6e","name":"b9a014be-d2a5-4725-9d3c-779de519ff6e","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
],
"gridX":0,
"gridY":0,
"height":64,
"HTile":false,
"layers":[
{"$GMImageLayer":"","%Name":"1dd1935f-f223-48c4-b746-a8149a03c1c6","blendMode":0,"displayName":"default","isLocked":false,"name":"1dd1935f-f223-48c4-b746-a8149a03c1c6","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
],
"name":"s_node_directory",
"nineSlice":null,
"origin":4,
"parent":{
"name":"IO",
"path":"folders/nodes/icons/IO.yy",
},
"preMultiplyAlpha":false,
"resourceType":"GMSprite",
"resourceVersion":"2.0",
"sequence":{
"$GMSequence":"",
"%Name":"s_node_directory",
"autoRecord":true,
"backdropHeight":768,
"backdropImageOpacity":0.5,
"backdropImagePath":"",
"backdropWidth":1366,
"backdropXOffset":0.0,
"backdropYOffset":0.0,
"events":{
"$KeyframeStore<MessageEventKeyframe>":"",
"Keyframes":[],
"resourceType":"KeyframeStore<MessageEventKeyframe>",
"resourceVersion":"2.0",
},
"eventStubScript":null,
"eventToFunction":{},
"length":1.0,
"lockOrigin":false,
"moments":{
"$KeyframeStore<MomentsEventKeyframe>":"",
"Keyframes":[],
"resourceType":"KeyframeStore<MomentsEventKeyframe>",
"resourceVersion":"2.0",
},
"name":"s_node_directory",
"playback":1,
"playbackSpeed":30.0,
"playbackSpeedType":0,
"resourceType":"GMSequence",
"resourceVersion":"2.0",
"showBackdrop":true,
"showBackdropImage":false,
"timeUnits":1,
"tracks":[
{"$GMSpriteFramesTrack":"","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"$KeyframeStore<SpriteFrameKeyframe>":"","Keyframes":[
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"b9a014be-d2a5-4725-9d3c-779de519ff6e","path":"sprites/s_node_directory/s_node_directory.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
},"Disabled":false,"id":"6bb3519f-1d76-4830-bd8c-ed8874890eb5","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
],"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"2.0",},"modifiers":[],"name":"frames","resourceType":"GMSpriteFramesTrack","resourceVersion":"2.0","spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
],
"visibleRange":null,
"volume":1.0,
"xorigin":32,
"yorigin":32,
},
"swatchColours":null,
"swfPrecision":0.5,
"textureGroupId":{
"name":"Default",
"path":"texturegroups/Default",
},
"type":0,
"VTile":false,
"width":64,
}