- [Graph Panel] Add file drop directly to input node to replace its content (image, image array, * file ins).

This commit is contained in:
Tanasart 2024-07-29 10:59:46 +07:00
parent 686785cd08
commit dcfc41379c
17 changed files with 253 additions and 157 deletions

View file

@ -408,4 +408,11 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
if(struct_has(attr, "layer_visible")) if(struct_has(attr, "layer_visible"))
attributes.layer_visible = attr.layer_visible; attributes.layer_visible = attr.layer_visible;
} }
static dropPath = function(path) {
if(is_array(path)) path = array_safe_get(path, 0);
if(!file_exists_empty(path)) return;
inputs[| 0].setValue(path);
}
} }

View file

@ -14,7 +14,7 @@ function Node_Byte_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
content = noone; content = noone;
on_drop_file = function(path) { #region on_drop_file = function(path) {
path = path_get(path); path = path_get(path);
inputs[| 0].setValue(path); inputs[| 0].setValue(path);
@ -24,7 +24,7 @@ function Node_Byte_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
} }
return false; return false;
} #endregion }
path_current = ""; path_current = "";
edit_time = 0; edit_time = 0;
@ -36,12 +36,12 @@ function Node_Byte_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
insp1UpdateTooltip = __txt("Refresh"); insp1UpdateTooltip = __txt("Refresh");
insp1UpdateIcon = [ THEME.refresh_icon, 1, COLORS._main_value_positive ]; insp1UpdateIcon = [ THEME.refresh_icon, 1, COLORS._main_value_positive ];
static onInspector1Update = function() { #region static onInspector1Update = function() {
updatePaths(path_get(getInputData(0))); updatePaths(path_get(getInputData(0)));
triggerRender(); triggerRender();
} #endregion }
function updatePaths(path = path_current) { #region function updatePaths(path = path_current) {
if(path == -1) return false; if(path == -1) return false;
path_current = path; path_current = path;
@ -51,9 +51,9 @@ function Node_Byte_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
content = buffer_load(path_current); content = buffer_load(path_current);
return true; return true;
} #endregion }
static step = function() { #region static step = function() {
if(attributes.file_checker && file_exists_empty(path_current)) { if(attributes.file_checker && file_exists_empty(path_current)) {
var _modi = file_get_modify_s(path_current); var _modi = file_get_modify_s(path_current);
@ -63,21 +63,28 @@ function Node_Byte_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
run_in(2, function() { updatePaths(); triggerRender(); }); run_in(2, function() { updatePaths(); triggerRender(); });
} }
} }
} #endregion }
static update = function(frame = CURRENT_FRAME) { #region static update = function(frame = CURRENT_FRAME) {
var path = path_get(getInputData(0)); var path = path_get(getInputData(0));
if(path_current != path) if(path_current != path)
updatePaths(path); updatePaths(path);
outputs[| 0].setValue(content); outputs[| 0].setValue(content);
} #endregion }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
var bbox = drawGetBbox(xx, yy, _s); var bbox = drawGetBbox(xx, yy, _s);
var str = filename_name(getInputData(0)); var str = filename_name(getInputData(0));
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text); draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
draw_text_bbox(bbox, str); draw_text_bbox(bbox, str);
} #endregion }
static dropPath = function(path) {
if(is_array(path)) path = array_safe_get(path, 0);
if(!file_exists_empty(path)) return;
inputs[| 0].setValue(path);
}
} }

View file

@ -1180,6 +1180,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
} #endregion } #endregion
static dropPath = function(path) { static dropPath = function(path) {
if(is_array(path)) path = array_safe_get(path, 0);
if(!file_exists_empty(path)) return noone; if(!file_exists_empty(path)) return noone;
if(tool_selection.is_selected) if(tool_selection.is_selected)

View file

@ -1,4 +1,4 @@
function Node_create_CSV_File_Read(_x, _y, _group = noone) { #region function Node_create_CSV_File_Read(_x, _y, _group = noone) {
var path = ""; var path = "";
if(NODE_NEW_MANUAL) { if(NODE_NEW_MANUAL) {
path = get_open_filename_pxc("comma separated value|*.csv", ""); path = get_open_filename_pxc("comma separated value|*.csv", "");
@ -11,9 +11,9 @@ function Node_create_CSV_File_Read(_x, _y, _group = noone) { #region
node.doUpdate(); node.doUpdate();
return node; return node;
} #endregion }
function Node_create_CSV_File_Read_path(_x, _y, path) { #region function Node_create_CSV_File_Read_path(_x, _y, path) {
if(!file_exists_empty(path)) return noone; if(!file_exists_empty(path)) return noone;
var node = new Node_CSV_File_Read(_x, _y, PANEL_GRAPH.getCurrentContext()); var node = new Node_CSV_File_Read(_x, _y, PANEL_GRAPH.getCurrentContext());
@ -21,7 +21,7 @@ function Node_create_CSV_File_Read_path(_x, _y, path) { #region
node.doUpdate(); node.doUpdate();
return node; return node;
} #endregion }
function Node_CSV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_CSV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "CSV File In"; name = "CSV File In";
@ -51,16 +51,16 @@ function Node_CSV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
first_update = false; first_update = false;
on_drop_file = function(path) { #region on_drop_file = function(path) {
if(updatePaths(path)) { if(updatePaths(path)) {
doUpdate(); doUpdate();
return true; return true;
} }
return false; return false;
} #endregion }
function updatePaths(path = path_current) { #region function updatePaths(path = path_current) {
path = path_get(path); path = path_get(path);
if(path == -1) return false; if(path == -1) return false;
@ -94,17 +94,17 @@ function Node_CSV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
edit_time = max(edit_time, file_get_modify_s(path_current)); edit_time = max(edit_time, file_get_modify_s(path_current));
return true; return true;
} #endregion }
insp1UpdateTooltip = __txt("Refresh"); insp1UpdateTooltip = __txt("Refresh");
insp1UpdateIcon = [ THEME.refresh_icon, 1, COLORS._main_value_positive ]; insp1UpdateIcon = [ THEME.refresh_icon, 1, COLORS._main_value_positive ];
static onInspector1Update = function() { #region static onInspector1Update = function() {
updatePaths(path_get(getInputData(0))); updatePaths(path_get(getInputData(0)));
triggerRender(); triggerRender();
} #endregion }
static step = function() { #region static step = function() {
if(attributes.file_checker && file_exists_empty(path_current)) { if(attributes.file_checker && file_exists_empty(path_current)) {
var _modi = file_get_modify_s(path_current); var _modi = file_get_modify_s(path_current);
@ -114,21 +114,28 @@ function Node_CSV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
run_in(2, function() { updatePaths(); triggerRender(); }); run_in(2, function() { updatePaths(); triggerRender(); });
} }
} }
} #endregion }
static update = function(frame = CURRENT_FRAME) { #region static update = function(frame = CURRENT_FRAME) {
var path = path_get(getInputData(0)); var path = path_get(getInputData(0));
if(path_current != path) updatePaths(path); if(path_current != path) updatePaths(path);
outputs[| 0].setValue(content); outputs[| 0].setValue(content);
} #endregion }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
var bbox = drawGetBbox(xx, yy, _s); var bbox = drawGetBbox(xx, yy, _s);
var str = filename_name(path_current); var str = filename_name(path_current);
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text); draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
var ss = string_scale(str, bbox.w, bbox.h); var ss = string_scale(str, bbox.w, bbox.h);
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0); draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
} #endregion }
static dropPath = function(path) {
if(is_array(path)) path = array_safe_get(path, 0);
if(!file_exists_empty(path)) return;
inputs[| 0].setValue(path);
}
} }

View file

@ -1770,7 +1770,9 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
} }
if(draw_droppable) { if(draw_droppable) {
draw_sprite_stretched_ext(THEME.ui_panel_active, 0, xx, yy, w * _s, h * _s, COLORS._main_value_positive, 1); // draw_sprite_stretched_ext(THEME.ui_panel_active, 0, xx, yy, w * _s, h * _s, COLORS._main_value_positive, 1);
draw_sprite_stretched_ext(THEME.color_picker_box, 0, xx - 2 * _s, yy - 2 * _s, w * _s + 4 * _s, h * _s + 4 * _s, COLORS._main_value_positive, 1);
draw_droppable = false; draw_droppable = false;
} }

View file

@ -1,4 +1,4 @@
function Node_create_Directory_Search(_x, _y, _group = noone) { #region function Node_create_Directory_Search(_x, _y, _group = noone) {
var path = ""; var path = "";
if(NODE_NEW_MANUAL) { if(NODE_NEW_MANUAL) {
path = get_directory(""); path = get_directory("");
@ -11,16 +11,16 @@ function Node_create_Directory_Search(_x, _y, _group = noone) { #region
if(NODE_NEW_MANUAL) node.doUpdate(); if(NODE_NEW_MANUAL) node.doUpdate();
return node; return node;
} #endregion }
function Node_create_Directory_path(_x, _y, path) { #region function Node_create_Directory_path(_x, _y, path) {
if(!directory_exists(path)) return noone; if(!directory_exists(path)) return noone;
var node = new Node_Directory_Search(_x, _y, PANEL_GRAPH.getCurrentContext()); var node = new Node_Directory_Search(_x, _y, PANEL_GRAPH.getCurrentContext());
node.inputs[| 0].setValue(path); node.inputs[| 0].setValue(path);
node.doUpdate(); node.doUpdate();
return node; return node;
} #endregion }
function Node_Directory_Search(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Directory_Search(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Directory Search"; name = "Directory Search";
@ -51,12 +51,12 @@ function Node_Directory_Search(_x, _y, _group = noone) : Node(_x, _y, _group) co
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; }) ]);
function deleteSprite(pathObj) { #region function deleteSprite(pathObj) {
if(sprite_exists(pathObj.spr)) if(sprite_exists(pathObj.spr))
sprite_delete(pathObj.spr); sprite_delete(pathObj.spr);
} #endregion }
function refreshSprite(pathObj) { #region function refreshSprite(pathObj) {
var path = pathObj.path; var path = pathObj.path;
var ext = string_lower(filename_ext(path)); var ext = string_lower(filename_ext(path));
@ -80,9 +80,9 @@ function Node_Directory_Search(_x, _y, _group = noone) : Node(_x, _y, _group) co
} }
return pathObj; return pathObj;
} #endregion }
function refreshText(pathObj) { #region function refreshText(pathObj) {
var path = pathObj.path; var path = pathObj.path;
var ext = string_lower(filename_ext(path)); var ext = string_lower(filename_ext(path));
@ -90,9 +90,9 @@ function Node_Directory_Search(_x, _y, _group = noone) : Node(_x, _y, _group) co
pathObj.edit_time = file_get_modify_s(path); pathObj.edit_time = file_get_modify_s(path);
return pathObj; return pathObj;
} #endregion }
function updatePaths() { #region function updatePaths() {
var path = getInputData(0); var path = getInputData(0);
var filter = getInputData(1); var filter = getInputData(1);
var type = getInputData(2); var type = getInputData(2);
@ -121,17 +121,17 @@ function Node_Directory_Search(_x, _y, _group = noone) : Node(_x, _y, _group) co
var _p = string_trim_end(path, ["/", "\\"]); var _p = string_trim_end(path, ["/", "\\"]);
setDisplayName(filename_name_only(_p)); setDisplayName(filename_name_only(_p));
} #endregion }
insp1UpdateTooltip = __txt("Refresh"); insp1UpdateTooltip = __txt("Refresh");
insp1UpdateIcon = [ THEME.refresh_icon, 1, COLORS._main_value_positive ]; insp1UpdateIcon = [ THEME.refresh_icon, 1, COLORS._main_value_positive ];
static onInspector1Update = function() { #region static onInspector1Update = function() {
updatePaths(); updatePaths();
triggerRender(); triggerRender();
} #endregion }
static step = function() { #region static step = function() {
if(attributes.file_checker) { if(attributes.file_checker) {
var _update = false; var _update = false;
var _paths = struct_get_names(paths); var _paths = struct_get_names(paths);
@ -147,9 +147,9 @@ function Node_Directory_Search(_x, _y, _group = noone) : Node(_x, _y, _group) co
if(_update) triggerRender(); if(_update) triggerRender();
} }
} #endregion }
static update = function(frame = CURRENT_FRAME) { #region static update = function(frame = CURRENT_FRAME) {
updatePaths(); updatePaths();
var type = getInputData(2); var type = getInputData(2);
@ -186,5 +186,12 @@ function Node_Directory_Search(_x, _y, _group = noone) : Node(_x, _y, _group) co
outputs[| 0].setType(type == 0? VALUE_TYPE.surface : VALUE_TYPE.text); outputs[| 0].setType(type == 0? VALUE_TYPE.surface : VALUE_TYPE.text);
outputs[| 0].setValue(_outsurf); outputs[| 0].setValue(_outsurf);
outputs[| 1].setValue(_imgPaths); outputs[| 1].setValue(_imgPaths);
} #endregion }
static dropPath = function(path) {
if(is_array(path)) path = array_safe_get(path, 0);
if(!directory_exists(path)) return;
inputs[| 0].setValue(path);
}
} }

View file

@ -161,6 +161,9 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
} #endregion } #endregion
static dropPath = function(path) { static dropPath = function(path) {
if(is_array(path)) path = array_safe_get(path, 0);
if(!file_exists_empty(path)) return;
inputs[| 0].setValue(path); inputs[| 0].setValue(path);
} }
} }

View file

@ -290,4 +290,9 @@ function timelineItemNode_Image_Animated(node) : timelineItemNode(node) construc
static onSerialize = function(_map) { static onSerialize = function(_map) {
_map.type = "timelineItemNode_Image_Animated"; _map.type = "timelineItemNode_Image_Animated";
} }
static dropPath = function(path) {
if(!is_array(path)) path = [ path ];
inputs[| 0].setValue(path);
}
} }

View file

@ -234,6 +234,9 @@ function Node_Image_gif(_x, _y, _group = noone) : Node(_x, _y, _group) construct
} #endregion } #endregion
static dropPath = function(path) { static dropPath = function(path) {
if(is_array(path)) path = array_safe_get(path, 0);
if(!file_exists_empty(path)) return;
inputs[| 0].setValue(path); inputs[| 0].setValue(path);
} }
} }

View file

@ -69,7 +69,7 @@ function Node_Image_Sequence(_x, _y, _group = noone) : Node(_x, _y, _group) cons
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; }) ]);
on_drop_file = function(path) { #region on_drop_file = function(path) {
if(directory_exists(path)) { if(directory_exists(path)) {
with(dialogCall(o_dialog_drag_folder, WIN_W / 2, WIN_H / 2)) { with(dialogCall(o_dialog_drag_folder, WIN_W / 2, WIN_H / 2)) {
dir_paths = path; dir_paths = path;
@ -87,17 +87,17 @@ function Node_Image_Sequence(_x, _y, _group = noone) : Node(_x, _y, _group) cons
} }
return false; return false;
} #endregion }
insp1UpdateTooltip = __txt("Refresh"); insp1UpdateTooltip = __txt("Refresh");
insp1UpdateIcon = [ THEME.refresh_icon, 1, COLORS._main_value_positive ]; insp1UpdateIcon = [ THEME.refresh_icon, 1, COLORS._main_value_positive ];
static onInspector1Update = function() { #region static onInspector1Update = function() {
updatePaths(path_get(getInputData(0))); updatePaths(path_get(getInputData(0)));
triggerRender(); triggerRender();
} #endregion }
function updatePaths(paths = path_current) { #region function updatePaths(paths = path_current) {
for(var i = 0; i < array_length(spr); i++) { for(var i = 0; i < array_length(spr); i++) {
if(spr[i] && sprite_exists(spr[i])) if(spr[i] && sprite_exists(spr[i]))
sprite_delete(spr[i]); sprite_delete(spr[i]);
@ -136,9 +136,9 @@ function Node_Image_Sequence(_x, _y, _group = noone) : Node(_x, _y, _group) cons
outputs[| 1].setValue(paths); outputs[| 1].setValue(paths);
return true; return true;
} #endregion }
static step = function() { #region static step = function() {
if(attributes.file_checker) if(attributes.file_checker)
for( var i = 0, n = array_length(path_current); i < n; i++ ) { for( var i = 0, n = array_length(path_current); i < n; i++ ) {
var _ed = file_get_modify_s(path_current[i]); var _ed = file_get_modify_s(path_current[i]);
@ -149,9 +149,9 @@ function Node_Image_Sequence(_x, _y, _group = noone) : Node(_x, _y, _group) cons
break; break;
} }
} }
} #endregion }
static update = function(frame = CURRENT_FRAME) { #region static update = function(frame = CURRENT_FRAME) {
var path = path_get(getInputData(0)); var path = path_get(getInputData(0));
if(!array_equals(path_current, path)) if(!array_equals(path_current, path))
@ -246,5 +246,10 @@ function Node_Image_Sequence(_x, _y, _group = noone) : Node(_x, _y, _group) cons
} }
outputs[| 0].setValue(surfs); outputs[| 0].setValue(surfs);
} #endregion }
static dropPath = function(path) {
if(!is_array(path)) path = [ path ];
inputs[| 0].setValue(path);
}
} }

View file

@ -1,4 +1,4 @@
function Node_create_Json_File_Read(_x, _y, _group = noone) { #region function Node_create_Json_File_Read(_x, _y, _group = noone) {
var path = ""; var path = "";
if(NODE_NEW_MANUAL) { if(NODE_NEW_MANUAL) {
path = get_open_filename_pxc("JSON file|*.json", ""); path = get_open_filename_pxc("JSON file|*.json", "");
@ -11,9 +11,9 @@ function Node_create_Json_File_Read(_x, _y, _group = noone) { #region
node.doUpdate(); node.doUpdate();
return node; return node;
} #endregion }
function Node_create_Json_File_Read_path(_x, _y, path) { #region function Node_create_Json_File_Read_path(_x, _y, path) {
if(!file_exists_empty(path)) return noone; if(!file_exists_empty(path)) return noone;
var node = new Node_Json_File_Read(_x, _y, PANEL_GRAPH.getCurrentContext()); var node = new Node_Json_File_Read(_x, _y, PANEL_GRAPH.getCurrentContext());
@ -21,7 +21,7 @@ function Node_create_Json_File_Read_path(_x, _y, path) { #region
node.doUpdate(); node.doUpdate();
return node; return node;
} #endregion }
function Node_Json_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Json_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "JSON File In"; name = "JSON File In";
@ -48,24 +48,24 @@ function Node_Json_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
first_update = false; first_update = false;
on_drop_file = function(path) { #region on_drop_file = function(path) {
if(updatePaths(path)) { if(updatePaths(path)) {
doUpdate(); doUpdate();
return true; return true;
} }
return false; return false;
} #endregion }
insp1UpdateTooltip = __txt("Refresh"); insp1UpdateTooltip = __txt("Refresh");
insp1UpdateIcon = [ THEME.refresh_icon, 1, COLORS._main_value_positive ]; insp1UpdateIcon = [ THEME.refresh_icon, 1, COLORS._main_value_positive ];
static onInspector1Update = function() { #region static onInspector1Update = function() {
updatePaths(path_get(getInputData(0))); updatePaths(path_get(getInputData(0)));
triggerRender(); triggerRender();
} #endregion }
function updatePaths(path) { #region function updatePaths(path) {
if(path == -1) return false; if(path == -1) return false;
var ext = string_lower(filename_ext(path)); var ext = string_lower(filename_ext(path));
@ -83,9 +83,9 @@ function Node_Json_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
edit_time = max(edit_time, file_get_modify_s(path_current)); edit_time = max(edit_time, file_get_modify_s(path_current));
return true; return true;
} #endregion }
static step = function() { #region static step = function() {
if(attributes.file_checker && file_exists_empty(path_current)) { if(attributes.file_checker && file_exists_empty(path_current)) {
var _modi = file_get_modify_s(path_current); var _modi = file_get_modify_s(path_current);
@ -95,20 +95,27 @@ function Node_Json_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
run_in(2, function() { updatePaths(); triggerRender(); }); run_in(2, function() { updatePaths(); triggerRender(); });
} }
} }
} #endregion }
static update = function(frame = CURRENT_FRAME) { #region static update = function(frame = CURRENT_FRAME) {
var path = path_get(getInputData(0)); var path = path_get(getInputData(0));
if(path_current != path) updatePaths(path); if(path_current != path) updatePaths(path);
outputs[| 1].setValue(content); outputs[| 1].setValue(content);
} #endregion }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text); draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
var str = filename_name(path_current); var str = filename_name(path_current);
var bbox = drawGetBbox(xx, yy, _s); var bbox = drawGetBbox(xx, yy, _s);
var ss = string_scale(str, bbox.w, bbox.h); var ss = string_scale(str, bbox.w, bbox.h);
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0); draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
} #endregion }
static dropPath = function(path) {
if(is_array(path)) path = array_safe_get(path, 0);
if(!file_exists_empty(path)) return;
inputs[| 0].setValue(path);
}
} }

View file

@ -116,6 +116,9 @@ function Node_SVG(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
} }
static dropPath = function(path) { static dropPath = function(path) {
if(is_array(path)) path = array_safe_get(path, 0);
if(!file_exists_empty(path)) return;
inputs[| 0].setValue(path); inputs[| 0].setValue(path);
} }
} }

View file

@ -1,4 +1,4 @@
function Node_create_Text_File_Read(_x, _y, _group = noone) { #region function Node_create_Text_File_Read(_x, _y, _group = noone) {
var path = ""; var path = "";
if(NODE_NEW_MANUAL) { if(NODE_NEW_MANUAL) {
path = get_open_filename_pxc("text file|*.txt", ""); path = get_open_filename_pxc("text file|*.txt", "");
@ -11,9 +11,9 @@ function Node_create_Text_File_Read(_x, _y, _group = noone) { #region
node.doUpdate(); node.doUpdate();
return node; return node;
} #endregion }
function Node_create_Text_File_Read_path(_x, _y, path) { #region function Node_create_Text_File_Read_path(_x, _y, path) {
if(!file_exists_empty(path)) return noone; if(!file_exists_empty(path)) return noone;
var node = new Node_Text_File_Read(_x, _y, PANEL_GRAPH.getCurrentContext()); var node = new Node_Text_File_Read(_x, _y, PANEL_GRAPH.getCurrentContext());
@ -21,7 +21,7 @@ function Node_create_Text_File_Read_path(_x, _y, path) { #region
node.doUpdate(); node.doUpdate();
return node; return node;
} #endregion }
function Node_Text_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_Text_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Text File In"; name = "Text File In";
@ -47,24 +47,24 @@ function Node_Text_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
first_update = false; first_update = false;
on_drop_file = function(path) { #region on_drop_file = function(path) {
if(updatePaths(path)) { if(updatePaths(path)) {
doUpdate(); doUpdate();
return true; return true;
} }
return false; return false;
} #endregion }
insp1UpdateTooltip = __txt("Refresh"); insp1UpdateTooltip = __txt("Refresh");
insp1UpdateIcon = [ THEME.refresh_icon, 1, COLORS._main_value_positive ]; insp1UpdateIcon = [ THEME.refresh_icon, 1, COLORS._main_value_positive ];
static onInspector1Update = function() { #region static onInspector1Update = function() {
updatePaths(path_get(getInputData(0))); updatePaths(path_get(getInputData(0)));
triggerRender(); triggerRender();
} #endregion }
function updatePaths(path = path_current) { #region function updatePaths(path = path_current) {
if(path == -1) return false; if(path == -1) return false;
var ext = string_lower(filename_ext(path)); var ext = string_lower(filename_ext(path));
@ -80,9 +80,9 @@ function Node_Text_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
edit_time = max(edit_time, file_get_modify_s(path_current)); edit_time = max(edit_time, file_get_modify_s(path_current));
return true; return true;
} #endregion }
static step = function() { #region static step = function() {
if(attributes.file_checker && file_exists_empty(path_current)) { if(attributes.file_checker && file_exists_empty(path_current)) {
var _modi = file_get_modify_s(path_current); var _modi = file_get_modify_s(path_current);
@ -92,21 +92,28 @@ function Node_Text_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
run_in(2, function() { updatePaths(); triggerRender(); }); run_in(2, function() { updatePaths(); triggerRender(); });
} }
} }
} #endregion }
static update = function(frame = CURRENT_FRAME) { #region static update = function(frame = CURRENT_FRAME) {
var path = path_get(getInputData(0)); var path = path_get(getInputData(0));
if(path_current != path) updatePaths(path); if(path_current != path) updatePaths(path);
outputs[| 0].setValue(content); outputs[| 0].setValue(content);
} #endregion }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
var bbox = drawGetBbox(xx, yy, _s); var bbox = drawGetBbox(xx, yy, _s);
var str = filename_name(path_current); var str = filename_name(path_current);
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text); draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
var ss = string_scale(str, bbox.w, bbox.h); var ss = string_scale(str, bbox.w, bbox.h);
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0); draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
} #endregion }
static dropPath = function(path) {
if(is_array(path)) path = array_safe_get(path, 0);
if(!file_exists_empty(path)) return;
inputs[| 0].setValue(path);
}
} }

View file

@ -1,4 +1,4 @@
function Node_create_WAV_File_Read(_x, _y, _group = noone) { #region function Node_create_WAV_File_Read(_x, _y, _group = noone) {
var path = ""; var path = "";
if(NODE_NEW_MANUAL) { if(NODE_NEW_MANUAL) {
path = get_open_filename_pxc("audio|*.wav", ""); path = get_open_filename_pxc("audio|*.wav", "");
@ -11,9 +11,9 @@ function Node_create_WAV_File_Read(_x, _y, _group = noone) { #region
if(NODE_NEW_MANUAL) node.doUpdate(); if(NODE_NEW_MANUAL) node.doUpdate();
return node; return node;
} #endregion }
function Node_create_WAV_File_Read_path(_x, _y, path) { #region function Node_create_WAV_File_Read_path(_x, _y, path) {
if(!file_exists_empty(path)) return noone; if(!file_exists_empty(path)) return noone;
var node = new Node_WAV_File_Read(_x, _y, PANEL_GRAPH.getCurrentContext()); var node = new Node_WAV_File_Read(_x, _y, PANEL_GRAPH.getCurrentContext());
@ -21,7 +21,7 @@ function Node_create_WAV_File_Read_path(_x, _y, path) { #region
node.doUpdate(); node.doUpdate();
return node; return node;
} #endregion }
function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "WAV File In"; name = "WAV File In";
@ -89,16 +89,16 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
})]); })]);
#endregion #endregion
on_drop_file = function(path) { #region on_drop_file = function(path) {
if(updatePaths(path)) { if(updatePaths(path)) {
doUpdate(); doUpdate();
return true; return true;
} }
return false; return false;
} #endregion }
function updatePaths(path) { #region function updatePaths(path) {
if(path == -1) return false; if(path == -1) return false;
if(path_current == "") if(path_current == "")
@ -117,9 +117,9 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
content = file_read_wav(path); content = file_read_wav(path);
return true; return true;
} #endregion }
function readSoundComplete() { #region function readSoundComplete() {
outputs[| 0].setValue(content); outputs[| 0].setValue(content);
outputs[| 2].setValue(content.sample); outputs[| 2].setValue(content.sample);
outputs[| 3].setValue(content.channels); outputs[| 3].setValue(content.channels);
@ -140,7 +140,7 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
preview_audio = audio_create_buffer_sound(bufferId, buffer_s16, content.sample, 0, content.packet * 2, audio_mono); preview_audio = audio_create_buffer_sound(bufferId, buffer_s16, content.sample, 0, content.packet * 2, audio_mono);
var surf = content.checkPreview(320, 128, true); var surf = content.checkPreview(320, 128, true);
} #endregion }
#region ++++ inspector ++++ #region ++++ inspector ++++
insp1UpdateTooltip = __txt("Refresh"); insp1UpdateTooltip = __txt("Refresh");
@ -162,7 +162,7 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
} }
#endregion #endregion
static step = function() { #region static step = function() {
if(file_read_wav_step()) { if(file_read_wav_step()) {
print("Load audio complete"); print("Load audio complete");
readSoundComplete(); readSoundComplete();
@ -202,9 +202,9 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
run_in(2, function() { updatePaths(); triggerRender(); }); run_in(2, function() { updatePaths(); triggerRender(); });
} }
} }
} #endregion }
static update = function(frame = CURRENT_FRAME) { #region static update = function(frame = CURRENT_FRAME) {
var path = path_get(getInputData(0)); var path = path_get(getInputData(0));
var mono = getInputData(2); var mono = getInputData(2);
@ -212,9 +212,9 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
if(!is_instanceof(content, audioObject)) return; if(!is_instanceof(content, audioObject)) return;
content.mono = mono; content.mono = mono;
} #endregion }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
if(content == noone) return; if(content == noone) return;
var bbox = drawGetBbox(xx, yy, _s); var bbox = drawGetBbox(xx, yy, _s);
var surf = content.checkPreview(320, 128); var surf = content.checkPreview(320, 128);
@ -248,9 +248,9 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
draw_set_text(f_sdf, fa_center, fa_bottom, COLORS._main_text); draw_set_text(f_sdf, fa_center, fa_bottom, COLORS._main_text);
var ss = string_scale(str, bbox.w, bbox.h); var ss = string_scale(str, bbox.w, bbox.h);
draw_text_transformed(bbox.xc, bbox.y1, str, ss, ss, 0); draw_text_transformed(bbox.xc, bbox.y1, str, ss, ss, 0);
} #endregion }
static drawAnimationTimeline = function(_shf, _w, _h, _s) { #region static drawAnimationTimeline = function(_shf, _w, _h, _s) {
if(content == noone) return; if(content == noone) return;
draw_set_color(COLORS._main_icon_dark); draw_set_color(COLORS._main_icon_dark);
draw_set_alpha(1); draw_set_alpha(1);
@ -274,5 +274,12 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
} }
draw_set_alpha(1); draw_set_alpha(1);
} #endregion }
static dropPath = function(path) {
if(is_array(path)) path = array_safe_get(path, 0);
if(!file_exists_empty(path)) return;
inputs[| 0].setValue(path);
}
} }

View file

@ -1,4 +1,4 @@
function Node_create_XML_File_Read(_x, _y, _group = noone) { #region function Node_create_XML_File_Read(_x, _y, _group = noone) {
var path = ""; var path = "";
if(NODE_NEW_MANUAL) { if(NODE_NEW_MANUAL) {
path = get_open_filename_pxc("xml|*.xml", ""); path = get_open_filename_pxc("xml|*.xml", "");
@ -11,9 +11,9 @@ function Node_create_XML_File_Read(_x, _y, _group = noone) { #region
node.doUpdate(); node.doUpdate();
return node; return node;
} #endregion }
function Node_create_XML_File_Read_path(_x, _y, path) { #region function Node_create_XML_File_Read_path(_x, _y, path) {
if(!file_exists_empty(path)) return noone; if(!file_exists_empty(path)) return noone;
var node = new Node_XML_File_Read(_x, _y, PANEL_GRAPH.getCurrentContext()); var node = new Node_XML_File_Read(_x, _y, PANEL_GRAPH.getCurrentContext());
@ -21,7 +21,7 @@ function Node_create_XML_File_Read_path(_x, _y, path) { #region
node.doUpdate(); node.doUpdate();
return node; return node;
} #endregion }
function Node_XML_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function Node_XML_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "XML File In"; name = "XML File In";
@ -46,16 +46,16 @@ function Node_XML_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
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; }) ]);
on_drop_file = function(path) { #region on_drop_file = function(path) {
if(updatePaths(path)) { if(updatePaths(path)) {
doUpdate(); doUpdate();
return true; return true;
} }
return false; return false;
} #endregion }
function updatePaths(path = path_current) { #region function updatePaths(path = path_current) {
path = path_get(path); path = path_get(path);
if(path == -1) return false; if(path == -1) return false;
@ -74,17 +74,17 @@ function Node_XML_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
edit_time = max(edit_time, file_get_modify_s(path_current)); edit_time = max(edit_time, file_get_modify_s(path_current));
return true; return true;
} #endregion }
insp1UpdateTooltip = __txt("Refresh"); insp1UpdateTooltip = __txt("Refresh");
insp1UpdateIcon = [ THEME.refresh_icon, 1, COLORS._main_value_positive ]; insp1UpdateIcon = [ THEME.refresh_icon, 1, COLORS._main_value_positive ];
static onInspector1Update = function() { #region static onInspector1Update = function() {
updatePaths(getInputData(0)); updatePaths(getInputData(0));
triggerRender(); triggerRender();
} #endregion }
static step = function() { #region static step = function() {
if(attributes.file_checker && file_exists_empty(path_current)) { if(attributes.file_checker && file_exists_empty(path_current)) {
var _modi = file_get_modify_s(path_current); var _modi = file_get_modify_s(path_current);
@ -94,21 +94,28 @@ function Node_XML_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
run_in(2, function() { updatePaths(); triggerRender(); }); run_in(2, function() { updatePaths(); triggerRender(); });
} }
} }
} #endregion }
static update = function(frame = CURRENT_FRAME) { #region static update = function(frame = CURRENT_FRAME) {
var path = getInputData(0); var path = getInputData(0);
if(path_current != path) updatePaths(path); if(path_current != path) updatePaths(path);
outputs[| 0].setValue(content); outputs[| 0].setValue(content);
} #endregion }
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
var bbox = drawGetBbox(xx, yy, _s); var bbox = drawGetBbox(xx, yy, _s);
var str = filename_name(path_current); var str = filename_name(path_current);
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text); draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
var ss = string_scale(str, bbox.w, bbox.h); var ss = string_scale(str, bbox.w, bbox.h);
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0); draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
} #endregion }
static dropPath = function(path) {
if(is_array(path)) path = array_safe_get(path, 0);
if(!file_exists_empty(path)) return;
inputs[| 0].setValue(path);
}
} }

View file

@ -2271,32 +2271,44 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
////////////////////////////////// File drop ////////////////////////////////// ////////////////////////////////// File drop //////////////////////////////////
if(pHOVER) { if(pHOVER) {
if(DRAGGING) { // file dropping var gr_x = graph_x * graph_s;
draw_sprite_stretched_ext(THEME.ui_panel_selection, 0, 8, 8, w - 16, h - 16, COLORS._main_value_positive, 1); var gr_y = graph_y * graph_s;
var _gx = mx / graph_s - graph_x;
if(node_hovering && node_hovering.droppable(DRAGGING)) { var _gy = my / graph_s - graph_y;
node_hovering.draw_droppable = true; var _node_hover = noone;
if(mouse_release(mb_left))
node_hovering.onDrop(DRAGGING);
} else {
if(mouse_release(mb_left))
checkDropItem();
}
}
var _mx = (FILE_IS_DROPPING? FILE_DROPPING_X : mouse_mx) - x; var _mx = (FILE_IS_DROPPING? FILE_DROPPING_X : mouse_mx) - x;
var _my = (FILE_IS_DROPPING? FILE_DROPPING_Y : mouse_my) - y; var _my = (FILE_IS_DROPPING? FILE_DROPPING_Y : mouse_my) - y;
var _gx = _mx / graph_s - graph_x; for(var i = 0; i < array_length(nodes_list); i++) {
var _gy = _my / graph_s - graph_y; var _n = nodes_list[i];
if(is_instanceof(_n, Node_Frame)) continue;
if(FILE_IS_DROPPING) if(_n.pointIn(gr_x, gr_y, _mx, _my, graph_s))
_node_hover = _n;
}
if(DRAGGING || FILE_IS_DROPPING)
draw_sprite_stretched_ext(THEME.ui_panel_selection, 0, 8, 8, w - 16, h - 16, COLORS._main_value_positive, 1); draw_sprite_stretched_ext(THEME.ui_panel_selection, 0, 8, 8, w - 16, h - 16, COLORS._main_value_positive, 1);
if(DRAGGING) { // file dropping
if(_node_hover && _node_hover.droppable(DRAGGING)) {
_node_hover.draw_droppable = true;
if(mouse_release(mb_left)) _node_hover.onDrop(DRAGGING);
} else {
if(mouse_release(mb_left)) checkDropItem();
}
}
if(FILE_IS_DROPPING && _node_hover && _node_hover.dropPath != noone)
_node_hover.draw_droppable = true;
if(FILE_DROPPED && !array_empty(FILE_DROPPING)) { if(FILE_DROPPED && !array_empty(FILE_DROPPING)) {
_gx = mx / graph_s - graph_x; if(_node_hover && _node_hover.dropPath != noone)
_gy = my / graph_s - graph_y; _node_hover.dropPath(FILE_DROPPING);
run_in(1, load_file_path, [ FILE_DROPPING, _gx, _gy ]); else
run_in(1, load_file_path, [ FILE_DROPPING, _gx, _gy ]);
} }
} }

View file

@ -637,7 +637,9 @@ function Panel_Inspector() : PanelContent() constructor {
var yy = hh + _y; var yy = hh + _y;
if(i < amoIn) { // inputs if(i < amoIn) { // inputs
jun = _inspecting.input_display_list == -1? jun = _inspecting.inputs[| i] : _inspecting.inputs[| _inspecting.input_display_list[i]]; if(_inspecting.input_display_list == -1) jun = _inspecting.inputs[| i];
else if(is_real(_inspecting.input_display_list[i])) jun = _inspecting.inputs[| _inspecting.input_display_list[i]];
else jun = _inspecting.input_display_list[i];
} else if(i == amoIn) { // output label } else if(i == amoIn) { // output label
hh += ui(8 + 32 + 8); hh += ui(8 + 32 + 8);
@ -648,11 +650,15 @@ function Panel_Inspector() : PanelContent() constructor {
continue; continue;
} else { // outputs } else { // outputs
var outInd = i - amoIn - 1; var _oi = i - amoIn - 1;
jun = _inspecting.output_display_list == -1? _inspecting.outputs[| outInd] : _inspecting.outputs[| _inspecting.output_display_list[outInd]];
if(_inspecting.output_display_list == -1) jun = _inspecting.outputs[| _oi];
else if(is_real(_inspecting.output_display_list[i])) jun = _inspecting.outputs[| _inspecting.output_display_list[_oi]];
else jun = _inspecting.output_display_list[_oi];
} }
#region draw custom displayer #region draw custom displayer
if(is_instanceof(jun, Inspector_Spacer)) { // SPACER if(is_instanceof(jun, Inspector_Spacer)) { // SPACER
var _hh = ui(jun.h); var _hh = ui(jun.h);
var _yy = yy + _hh / 2 - ui(2); var _yy = yy + _hh / 2 - ui(2);
@ -685,6 +691,14 @@ function Panel_Inspector() : PanelContent() constructor {
hh += _sh + ui(8); hh += _sh + ui(8);
continue; continue;
} else if(is_instanceof(jun, Inspector_Custom_Renderer)) {
jun.register(contentPane);
jun.rx = ui(16) + x;
jun.ry = top_bar_h + y;
var _wdh = jun.draw(ui(6), yy, con_w - ui(12), _m, _hover, pFOCUS) + ui(8);
if(!is_undefined(_wdh)) hh += _wdh;
continue;
} else if(is_array(jun)) { // LABEL } else if(is_array(jun)) { // LABEL
var pad = i && _colsp == false? ui(4) : 0 var pad = i && _colsp == false? ui(4) : 0
_colsp = false; _colsp = false;
@ -757,19 +771,11 @@ function Panel_Inspector() : PanelContent() constructor {
continue; continue;
} else if(is_struct(jun) && is_instanceof(jun, Inspector_Custom_Renderer)) {
jun.register(contentPane);
jun.rx = ui(16) + x;
jun.ry = top_bar_h + y;
var _wdh = jun.draw(ui(6), yy, con_w - ui(12), _m, _hover, pFOCUS) + ui(8);
if(!is_undefined(_wdh)) hh += _wdh;
continue;
} }
#endregion #endregion
if(!is_struct(jun)) continue; if(!is_instanceof(jun, NodeValue)) continue;
if(instanceof(jun) != "NodeValue") continue;
if(!jun.show_in_inspector || jun.type == VALUE_TYPE.object) continue; if(!jun.show_in_inspector || jun.type == VALUE_TYPE.object) continue;
if(filter_text != "") { if(filter_text != "") {