file watcher crash

This commit is contained in:
Tanasart 2024-05-16 15:37:44 +07:00
parent 976577fe77
commit a01a979bb3
6 changed files with 51 additions and 72 deletions

View file

@ -154,7 +154,6 @@ _HOVERING_ELEMENT = noone;
else if(UPDATE & RENDER_TYPE.partial) else if(UPDATE & RENDER_TYPE.partial)
Render(true); Render(true);
} }
} }
} }

View file

@ -25,7 +25,7 @@ function get_open_filenames_compat(ext, sel) { #region
function file_get_modify_s(path) { #region function file_get_modify_s(path) { #region
INLINE INLINE
if(!file_exists(path)) return 0; if(!file_exists_empty(path)) return 0;
var _y = file_datetime_modified_year(path); var _y = file_datetime_modified_year(path);
var _m = file_datetime_modified_month(path); var _m = file_datetime_modified_month(path);

View file

@ -659,8 +659,6 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
if(cached_manual || (use_cache == CACHE_USE.auto && recoverCache())) { if(cached_manual || (use_cache == CACHE_USE.auto && recoverCache())) {
render_cached = true; render_cached = true;
// if(_updateRender) setRenderStatus(true);
} else { } else {
render_cached = false; render_cached = false;
getInputs(frame); getInputs(frame);
@ -668,8 +666,6 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
LOG_BLOCK_START(); LOG_BLOCK_START();
LOG_IF(global.FLAG.render == 1, $">>>>>>>>>> DoUpdate called from {INAME} <<<<<<<<<<"); LOG_IF(global.FLAG.render == 1, $">>>>>>>>>> DoUpdate called from {INAME} <<<<<<<<<<");
// if(_updateRender) setRenderStatus(true);
var sBase = surface_get_target(); var sBase = surface_get_target();
try { try {

View file

@ -38,11 +38,10 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
attribute_surface_depth(); attribute_surface_depth();
first_update = false; spr = noone;
spr = []; edit_time = 0;
path_current = [];
edit_time = 0;
attributes.check_splice = true;
attributes.file_checker = true; attributes.file_checker = true;
array_push(attributeEditors, [ "File Watcher", function() { return attributes.file_checker; }, array_push(attributeEditors, [ "File Watcher", function() { return attributes.file_checker; },
new checkBox(function() { attributes.file_checker = !attributes.file_checker; }) ]); new checkBox(function() { attributes.file_checker = !attributes.file_checker; }) ]);
@ -59,7 +58,8 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
} #endregion } #endregion
function createSprite(path) { #region function createSprite(path) { #region
if(path == -1) return noone; if(!file_exists(path))
return noone;
var ext = string_lower(filename_ext(path)); var ext = string_lower(filename_ext(path));
var _name = filename_name_only(path); var _name = filename_name_only(path);
@ -70,35 +70,26 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
case ".jpeg": case ".jpeg":
case ".gif": case ".gif":
setDisplayName(_name); setDisplayName(_name);
var spr = sprite_add(path, 1, false, false, 0, 0); var _spr = sprite_add(path, 1, false, false, 0, 0);
if(spr == -1) { if(_spr == -1) {
noti_warning($"Image node: File not a valid image."); noti_warning($"Image node: File not a valid image.");
break; break;
} }
edit_time = max(edit_time, file_get_modify_s(path)); edit_time = file_get_modify_s(path);
return spr; return _spr;
} }
return noone; return noone;
} #endregion } #endregion
function updatePaths(path = path_current) { #region function updatePaths(path) { #region
if(array_empty(path_current)) first_update = true;
for( var i = 0, n = array_length(spr); i < n; i++ ) if(sprite_exists(spr))
sprite_delete(spr[i]); sprite_delete(spr);
spr = [];
if(!is_array(path)) path = [ path ]; spr = createSprite(path);
for( var i = 0, n = array_length(path); i < n; i++ ) {
path_current[i] = path_get(path[i]);
var s = createSprite(path[i]);
if(s) array_push(spr, s);
}
} #endregion } #endregion
insp1UpdateTooltip = __txt("Refresh"); insp1UpdateTooltip = __txt("Refresh");
@ -110,54 +101,42 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
} #endregion } #endregion
static step = function() { #region static step = function() { #region
if(attributes.file_checker) var path = path_get(getInputData(0));
for( var i = 0, n = array_length(path_current); i < n; i++ ) {
if(file_get_modify_s(path_current[i]) > edit_time) { if(!file_exists_empty(path)) return;
updatePaths();
triggerRender(); if(attributes.file_checker && file_get_modify_s(path) > edit_time) {
break; updatePaths(path);
} triggerRender();
} }
} #endregion } #endregion
static update = function(frame = CURRENT_FRAME) { #region static update = function(frame = CURRENT_FRAME) { #region
var path = path_get(getInputData(0)); var path = path_get(getInputData(0));
var pad = getInputData(1); var pad = getInputData(1);
outputs[| 1].setValue(path); outputs[| 1].setValue(path);
if(!array_equals(path_current, path)) updatePaths(path);
updatePaths(path);
if(array_empty(spr)) return; if(!sprite_exists(spr)) return;
var _arr = array_length(spr) > 1;
var _outsurf = outputs[| 0].getValue(); var _outsurf = outputs[| 0].getValue();
if(!is_array(_outsurf)) _outsurf = [ _outsurf ]; var ww = sprite_get_width(spr) + pad[0] + pad[2];
var hh = sprite_get_height(spr) + pad[1] + pad[3];
for( var i = 0, n = array_length(spr); i < n; i++ ) { _outsurf = surface_verify(_outsurf, ww, hh, attrDepth());
var _spr = spr[i];
if(!sprite_exists(_spr)) continue;
var ww = sprite_get_width(_spr) + pad[0] + pad[2];
var hh = sprite_get_height(_spr) + pad[1] + pad[3];
var _surf = array_safe_get_fast(_outsurf, i);
_surf = surface_verify(_surf, ww, hh, attrDepth());
surface_set_shader(_surf, noone);
draw_sprite(_spr, 0, pad[2], pad[1]);
surface_reset_shader();
_outsurf[i] = _surf;
}
outputs[| 0].setValue(_arr? _outsurf : _outsurf[0]); surface_set_shader(_outsurf, noone);
draw_sprite(spr, 0, pad[2], pad[1]);
surface_reset_shader();
outputs[| 0].setValue(_outsurf);
#region splice #region splice
if(!first_update) return; if(!attributes.check_splice) return;
first_update = false; attributes.check_splice = false;
if(LOADING || APPENDING) return; if(LOADING || APPENDING) return;
if(string_pos("strip", display_name) == 0) return; if(string_pos("strip", display_name) == 0) return;
@ -168,8 +147,8 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
if(amo == 0) return; if(amo == 0) return;
var ww = sprite_get_width(spr[0]) / amo; var ww = sprite_get_width(spr) / amo;
var hh = sprite_get_height(spr[0]); var hh = sprite_get_height(spr);
var _splice = nodeBuild("Node_Image_Sheet", x + w + 64, y); var _splice = nodeBuild("Node_Image_Sheet", x + w + 64, y);
_splice.inputs[| 0].setFrom(outputs[| 0], false); _splice.inputs[| 0].setFrom(outputs[| 0], false);

View file

@ -185,14 +185,13 @@ function Panel_File_Explorer() : PanelContent() constructor {
contentPane = new scrollPane(w - padding - padding - cntPad * 2, h - padding - top_bar - cntPad * 2, function(_y, _m, _r) { 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); draw_clear_alpha(COLORS.panel_bg_clear, 0);
if(frame_dragging) { if(frame_dragging) file_selectings = [];
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; file_hovering = noone;
var _h = drawDir(rootFile, 0, _y, contentPane.surface_w, _m); var _h = drawDir(rootFile, 0, _y, contentPane.surface_w, _m);
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);
if(mouse_press(mb_left, pFOCUS)) { if(mouse_press(mb_left, pFOCUS)) {
if(file_hovering == noone) { if(file_hovering == noone) {
file_selectings = []; file_selectings = [];
@ -221,11 +220,10 @@ function Panel_File_Explorer() : PanelContent() constructor {
} }
if(mouse_release(mb_left)) { if(mouse_release(mb_left)) {
file_dragging = false; if(path_dragging != -1 && !pHOVER)
if(path_dragging != -1)
o_main.load_file_path(path_dragging); o_main.load_file_path(path_dragging);
file_dragging = false;
path_dragging = -1; path_dragging = -1;
} }
} }
@ -260,6 +258,13 @@ function Panel_File_Explorer() : PanelContent() constructor {
var _ind = 0; var _ind = 0;
var _ppw = _pw; var _ppw = _pw;
if(point_in_rectangle(_m[0], _m[1], _px, _py, _px + _pw, _py + _ph)) {
if(buttonInstant(THEME.button_hide, _px + _ppw - _ph, _py, _ph, _ph, _m, pFOCUS, pHOVER, "", THEME.path_open_20) == 2) {
setRoot(_dir.path);
}
_ppw -= _ph + ui(4);
}
if(contentPane.hover && point_in_rectangle(_m[0], _m[1], _px, _py, _px + _ppw, _py + _ph)) { if(contentPane.hover && point_in_rectangle(_m[0], _m[1], _px, _py, _px + _ppw, _py + _ph)) {
file_hovering = _dir; file_hovering = _dir;
_ind = 3; _ind = 3;
@ -271,7 +276,7 @@ function Panel_File_Explorer() : PanelContent() constructor {
} }
} }
draw_sprite_stretched(THEME.ui_panel_bg, _ind, _px, _py, _pw, _ph); draw_sprite_stretched(THEME.ui_panel_bg, _ind, _px, _py, _ppw, _ph);
var _tx = _px + ui(2); var _tx = _px + ui(2);
var _ty = _py + ui(2); var _ty = _py + ui(2);

View file

@ -8,7 +8,7 @@ function __path_get(path) {
if(file_exists_empty(local_path)) if(file_exists_empty(local_path))
return local_path; return local_path;
return -1; return "";
} }
function path_get(path) { function path_get(path) {