2023-02-28 09:43:01 +01:00
|
|
|
function Node_create_Display_Image(_x, _y, _group = noone) {
|
2022-12-10 05:06:01 +01:00
|
|
|
var path = "";
|
2023-01-17 08:11:55 +01:00
|
|
|
if(!LOADING && !APPENDING && !CLONING) {
|
2022-12-10 05:06:01 +01:00
|
|
|
path = get_open_filename(".png", "");
|
2023-02-28 09:43:01 +01:00
|
|
|
key_release();
|
2022-12-10 05:06:01 +01:00
|
|
|
if(path == "") return noone;
|
|
|
|
}
|
|
|
|
|
2022-12-13 09:20:36 +01:00
|
|
|
var node = new Node_Display_Image(_x, _y, _group);
|
2022-12-10 05:06:01 +01:00
|
|
|
node.inputs[| 0].setValue(path);
|
|
|
|
node.doUpdate();
|
|
|
|
|
2022-12-13 09:20:36 +01:00
|
|
|
//ds_list_add(PANEL_GRAPH.nodes_list, node);
|
2022-12-10 05:06:01 +01:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
function Node_create_Display_Image_path(_x, _y, path) {
|
|
|
|
if(!file_exists(path)) return noone;
|
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
var node = new Node_Display_Image(_x, _y, PANEL_GRAPH.getCurrentContext());
|
2022-12-10 05:06:01 +01:00
|
|
|
node.inputs[| 0].setValue(path);
|
|
|
|
node.doUpdate();
|
|
|
|
|
2022-12-13 09:20:36 +01:00
|
|
|
//ds_list_add(PANEL_GRAPH.nodes_list, node);
|
2022-12-10 05:06:01 +01:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2023-02-28 09:43:01 +01:00
|
|
|
function Node_Display_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
2022-12-10 05:06:01 +01:00
|
|
|
name = "";
|
|
|
|
always_output = true;
|
|
|
|
auto_height = false;
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 0] = nodeValue("Path", self, JUNCTION_CONNECT.input, VALUE_TYPE.path, "")
|
|
|
|
.setDisplay(VALUE_DISPLAY.path_load, ["*.png", ""])
|
|
|
|
.rejectArray();
|
2022-12-10 05:06:01 +01:00
|
|
|
|
|
|
|
spr = noone;
|
|
|
|
path_current = "";
|
|
|
|
|
|
|
|
first_update = false;
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
static onInspectorUpdate = function() {
|
2023-01-17 08:11:55 +01:00
|
|
|
var path = inputs[| 0].getValue();
|
|
|
|
if(path == "") return;
|
|
|
|
updatePaths(path);
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
function updatePaths(path) {
|
|
|
|
path = try_get_path(path);
|
|
|
|
if(path == -1) return false;
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
var ext = string_lower(filename_ext(path));
|
2022-12-10 05:06:01 +01:00
|
|
|
var _name = string_replace(filename_name(path), filename_ext(path), "");
|
|
|
|
|
|
|
|
switch(ext) {
|
|
|
|
case ".png":
|
|
|
|
case ".jpg":
|
|
|
|
case ".jpeg":
|
|
|
|
case ".gif":
|
|
|
|
name = _name;
|
|
|
|
|
|
|
|
if(spr) sprite_delete(spr);
|
|
|
|
spr = sprite_add(path, 1, false, false, 0, 0);
|
|
|
|
|
|
|
|
if(path_current == "")
|
|
|
|
first_update = true;
|
|
|
|
path_current = path;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
static update = function(frame = ANIMATOR.current_frame) {
|
2022-12-10 05:06:01 +01:00
|
|
|
var path = inputs[| 0].getValue();
|
|
|
|
if(path == "") return;
|
2023-01-17 08:11:55 +01:00
|
|
|
if(path_current != path) updatePaths(path);
|
2022-12-10 05:06:01 +01:00
|
|
|
|
|
|
|
if(!spr || !sprite_exists(spr)) return;
|
|
|
|
|
|
|
|
w = sprite_get_width(spr);
|
|
|
|
h = sprite_get_height(spr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static drawNodeBase = function(xx, yy, _s) {
|
|
|
|
if(!spr || !sprite_exists(spr)) return;
|
|
|
|
|
|
|
|
draw_sprite_uniform(spr, 0, xx, yy, _s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static drawNode = function(_x, _y, _mx, _my, _s) {
|
|
|
|
var xx = x * _s + _x;
|
|
|
|
var yy = y * _s + _y;
|
|
|
|
|
|
|
|
drawNodeBase(xx, yy, _s);
|
|
|
|
|
|
|
|
if(active_draw_index > -1) {
|
|
|
|
draw_sprite_stretched_ext(bg_sel_spr, 0, xx, yy, w * _s, h * _s, COLORS._main_accent, 1);
|
|
|
|
active_draw_index = -1;
|
|
|
|
}
|
|
|
|
return noone;
|
|
|
|
}
|
|
|
|
}
|