- [Graph Panel] Display parameter now saved per projects.

This commit is contained in:
Tanasart 2024-08-02 19:30:35 +07:00
parent 5ce4ab19cf
commit f285ada4d0
33 changed files with 550 additions and 204 deletions

View file

@ -1073,6 +1073,7 @@
{"name":"node_shard_noise","order":12,"path":"scripts/node_shard_noise/node_shard_noise.yy",},
{"name":"node_shell","order":13,"path":"scripts/node_shell/node_shell.yy",},
{"name":"node_skew","order":11,"path":"scripts/node_skew/node_skew.yy",},
{"name":"node_slideshow","order":28,"path":"scripts/node_slideshow/node_slideshow.yy",},
{"name":"node_smear","order":12,"path":"scripts/node_smear/node_smear.yy",},
{"name":"node_smoke_add_collider","order":6,"path":"scripts/node_smoke_add_collider/node_smoke_add_collider.yy",},
{"name":"node_smoke_add","order":4,"path":"scripts/node_smoke_add/node_smoke_add.yy",},

View file

@ -1653,6 +1653,7 @@
{"id":{"name":"node_shard_noise","path":"scripts/node_shard_noise/node_shard_noise.yy",},},
{"id":{"name":"node_shell","path":"scripts/node_shell/node_shell.yy",},},
{"id":{"name":"node_skew","path":"scripts/node_skew/node_skew.yy",},},
{"id":{"name":"node_slideshow","path":"scripts/node_slideshow/node_slideshow.yy",},},
{"id":{"name":"node_smear","path":"scripts/node_smear/node_smear.yy",},},
{"id":{"name":"node_smoke_add_collider","path":"scripts/node_smoke_add_collider/node_smoke_add_collider.yy",},},
{"id":{"name":"node_smoke_add","path":"scripts/node_smoke_add/node_smoke_add.yy",},},

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View file

@ -233,7 +233,7 @@ event_inherited();
gradient.keys = [];
for( var i = 0, n = array_length(_p); i < n; i++ )
gradient.keys[i] = new gradientKey(i / (n - 1), _p[i]);
gradient.keys[i] = new gradientKey(i / (n - 1), cola(_p[i]));
}),
]);
}

View file

@ -372,3 +372,15 @@
log_console($"Open port: {TCP_PORT}");
}
#endregion
#region random debug
// var s = "1,2,23423,423,423,543,564,6,435,34,5"
// var t = get_timer();
// repeat(1000000) { string_split(s, ","); }
// print($"{(get_timer() - t) / 1000} ms");
// var t = get_timer();
// repeat(1000000) { string_splice(s, ","); }
// print($"{(get_timer() - t) / 1000} ms");
#endregion

View file

@ -4,14 +4,13 @@ winManStep()
//print("===== Step start =====");
if(PROJECT.active && !PROJECT.safeMode) { #region node step
PROJECT.animator.step();
PROJECT.globalNode.step();
if(PROJECT.active && !PROJECT.safeMode) { //node step
PROJECT.step();
LIVE_UPDATE = false;
try {
if(PANEL_MAIN != 0) PANEL_MAIN.step();
array_foreach(PROJECT.allNodes, function(_node) {
array_foreach(PROJECT.allNodes, function(_node) /*=>*/ {
if(!_node.active) return;
_node.triggerCheck();
_node.step();
@ -20,8 +19,9 @@ if(PROJECT.active && !PROJECT.safeMode) { #region node step
noti_warning("Step error: " + exception_print(e));
}
PROJECT.postStep();
IS_SAVING = false;
} #endregion
}
#region hotkey
if(!instance_exists(o_dialog_preference) && !HOTKEY_BLOCK) {

View file

@ -191,7 +191,7 @@ _FILE_DROPPED = false;
dc_check -= DELTA_TIME;
#endregion
#region step
#region actions
if(array_length(action_last_frame) > 0) {
ds_stack_push(UNDO_STACK, action_last_frame);
ds_stack_clear(REDO_STACK);

View file

@ -230,7 +230,7 @@ function color_diff(c1, c2) {
function merge_color_ext(c0, c1, t) {
INLINE
if(is_real(c0)) return __merge_color(c0, c1, t);
if(is_real(c0) && is_real(c1)) return __merge_color(c0, c1, t);
return make_color_rgba(
clamp(round(lerp(color_get_red(c0), color_get_red(c1), t)), 0, 255),
@ -240,6 +240,16 @@ function color_diff(c1, c2) {
);
}
function merge_color_a(c0, c1, t) {
INLINE
return make_color_rgba(
clamp(round(lerp(color_get_red(c0), color_get_red(c1), t)), 0, 255),
clamp(round(lerp(color_get_green(c0), color_get_green(c1), t)), 0, 255),
clamp(round(lerp(color_get_blue(c0), color_get_blue(c1), t)), 0, 255),
clamp(round(lerp(color_get_alpha(c0), color_get_alpha(c1), t)), 0, 255),
);
}
function merge_color_hsv(c0, c1, t) {
INLINE
if(is_real(c0)) return make_color_hsv(

View file

@ -26,6 +26,30 @@ function draw_text_add_float(_x, _y, _text, scale = 1) {
BLEND_NORMAL;
}
function draw_text_bm_add(_x, _y, _text, scale = 1) {
INLINE
if(scale == 1) {
gpu_set_colorwriteenable(1, 1, 1, 0);
BLEND_OVERRIDE
draw_text(_x, _y, _text);
BLEND_NORMAL
gpu_set_colorwriteenable(1, 1, 1, 1);
draw_text(_x, _y, _text);
} else {
gpu_set_colorwriteenable(1, 1, 1, 0);
BLEND_OVERRIDE
draw_text_transformed(_x, _y, _text, scale, scale, 0);
BLEND_NORMAL
gpu_set_colorwriteenable(1, 1, 1, 1);
draw_text_transformed(_x, _y, _text, scale, scale, 0);
}
}
function draw_text_lang_add(_x, _y, _text, scale = 1) {
INLINE
BLEND_ALPHA_MULP;

View file

@ -92,7 +92,7 @@ function gradientObject(color = c_black) constructor {
var rat = (position - _pkey.time) / (_key.time - _pkey.time);
switch(type) {
case GRADIENT_INTER.smooth : return merge_color (_pkey.value, _key.value, rat);
case GRADIENT_INTER.smooth : return merge_color_a (_pkey.value, _key.value, rat);
case GRADIENT_INTER.hue : return merge_color_hsv (_pkey.value, _key.value, rat);
case GRADIENT_INTER.oklab : return merge_color_oklab(_pkey.value, _key.value, rat);
case GRADIENT_INTER.srgb : return merge_color_srgb (_pkey.value, _key.value, rat);
@ -262,8 +262,6 @@ function gradientObject(color = c_black) constructor {
for( var i = 0, n = array_length(keys); i < n; i++ )
s.keys[i] = keys[i].serialize();
// print(s);
return json_stringify(s, false);
}
@ -285,8 +283,6 @@ function gradientObject(color = c_black) constructor {
type = struct_try_get(s, "type");
keys = array_create(array_length(s.keys));
// print(s.keys);
for( var i = 0, n = array_length(s.keys); i < n; i++ ) {
var _time = s.keys[i].time;
var _value = s.keys[i].value;

View file

@ -5,7 +5,7 @@ function __loadParams(readonly = false, override = false, apply_layout = false)
self.apply_layout = apply_layout;
}
function LOAD(safe = false) { #region
function LOAD(safe = false) {
if(DEMO) return false;
var path = get_open_filename_pxc("Pixel Composer project (.pxc)|*.pxc;*.cpxc", "");
@ -15,18 +15,18 @@ function LOAD(safe = false) { #region
gc_collect();
var proj = LOAD_PATH(path, false, safe);
} #endregion
}
function TEST_PATH(path) { #region
function TEST_PATH(path) {
TESTING = true;
TEST_ERROR = true;
PROJECT.cleanup();
PROJECT = new Project();
PANEL_GRAPH.setProject(PROJECT);
LOAD_AT(path);
} #endregion
PANEL_GRAPH.setProject(PROJECT);
}
function LOAD_PATH(path, readonly = false, safe_mode = false) {
var _rep = false;
@ -44,6 +44,9 @@ function LOAD_PATH(path, readonly = false, safe_mode = false) {
var _PROJECT = PROJECT;
PROJECT = new Project();
var res = LOAD_AT(path, new __loadParams(readonly));
if(!res) return false;
if(_PROJECT == noone) {
PROJECTS = [ PROJECT ];
@ -63,9 +66,6 @@ function LOAD_PATH(path, readonly = false, safe_mode = false) {
array_push(PROJECTS, PROJECT);
}
var res = LOAD_AT(path, new __loadParams(readonly));
if(!res) return false;
PROJECT.safeMode = safe_mode;
if(!IS_CMD) setFocus(PANEL_GRAPH.panel);

View file

@ -177,11 +177,13 @@ function Node_Color_adjust(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
var r = _color_get_red(_c);
var g = _color_get_green(_c);
var b = _color_get_blue(_c);
var a = color_get_alpha(_c);
_c = make_color_rgb(
_c = make_color_rgba(
clamp((.5 + _con * 2 * (r - .5) + _bri) * _exp, 0, 1) * 255,
clamp((.5 + _con * 2 * (g - .5) + _bri) * _exp, 0, 1) * 255,
clamp((.5 + _con * 2 * (b - .5) + _bri) * _exp, 0, 1) * 255,
a
);
var h = _color_get_hue(_c);
@ -193,8 +195,8 @@ function Node_Color_adjust(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
v = clamp((v + _val) * (1 + _sat * s * 0.5), 0, 1);
s = clamp(s * (_sat + 1), 0, 1);
_c = make_color_hsv(h * 255, s * 255, v * 255);
_c = merge_color(_c, _bl, _bla);
_c = make_color_hsva(h * 255, s * 255, v * 255, a);
_c = merge_color_a(_c, _bl, _bla);
_col[i] = _c;
}

View file

@ -28,7 +28,7 @@ function Node_Color_Mix(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
return c;
}
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);
if(bbox.h < 1) return;
@ -40,5 +40,5 @@ function Node_Color_Mix(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
}
drawColor(col, bbox.x0, bbox.y0, bbox.w, bbox.h);
} #endregion
}
}

View file

@ -50,9 +50,10 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
search_match = -9999;
onDoubleClick = -1;
is_controller = false;
#endregion
static resetInternalName = function() { #region
static resetInternalName = function() {
var str = string_replace_all(name, " ", "_");
str = string_replace_all(str, "/", "");
str = string_replace_all(str, "-", "");
@ -60,9 +61,9 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
ds_map_delete(PROJECT.nodeNameMap, internalName);
internalName = str + string(irandom_range(10000, 99999));
PROJECT.nodeNameMap[? internalName] = self;
} #endregion
}
if(!LOADING && !APPENDING) { #region
if(!LOADING && !APPENDING) {
recordAction(ACTION_TYPE.node_added, self);
PROJECT.nodeMap[? node_id] = self;
PROJECT.modified = true;
@ -76,7 +77,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
});
RENDER_ALL_REORDER
} #endregion
}
#region ---- display ----
color = c_white;

View file

@ -151,9 +151,8 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
index++;
switch(_ch) {
case "<" :
_mode = 1;
continue;
case "<" : _mode = 1; continue;
case ">" :
var _c = string_splice(_cmd, " ");
@ -161,11 +160,13 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
switch(_c[0]) {
case "bt" :
var _bch = "";
for( var i = 1; i < array_length(_c); i++ ) {
if(i > 1) _bch += " ";
_bch += _c[i];
}
_tw = string_width(_bch) * _s * fsize;
for( var i = 1; i < array_length(_c); i++ )
_bch += i > 1? " " + _c[i] : _c[i];
var _bw = string_width(_bch);
_tx += 4 * _s;
_tw = _bw * _s * fsize;
_th = string_height(_bch) * _s * fsize;
draw_sprite_stretched_points(THEME.ui_panel_bg, 0, _tx - 4, _y - 4, _tx + _tw + 4, _y + _th + 4, COLORS._main_icon_light);
@ -185,9 +186,31 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
draw_set_color(_cc);
}
_tx += _tw;
width += string_width(_bch) * fsize;
_tx += _tw + 4 * _s;
width += _bw * fsize + 8;
break;
case "node" :
var _bch = "";
for( var i = 1; i < array_length(_c); i++ )
_bch += i > 1? " " + _c[i] : _c[i];
var _bw = string_width(_bch);
_tx += 4 * _s;
_tw = _bw * _s * fsize;
_th = string_height(_bch) * _s * fsize;
draw_sprite_stretched_ext(THEME.node_bg, 0, _tx - 4, _y - 4, _tw + 8, _th + 8, c_white, .75);
draw_sprite_stretched_add(THEME.node_bg, 0, _tx - 4, _y - 4, _tw + 8, _th + 8, c_white, .10);
draw_set_color(_cc);
draw_text_add_float(_tx, _y, _bch, _s * fsize);
_tx += _tw + 4 * _s;
width += _bw * fsize + 8;
break;
case "panel" :
var _key = _c[1] + " panel";
var _tss = 11 / 32;
@ -207,7 +230,7 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
case "preview" : FOCUSING_PANEL = PANEL_PREVIEW; break;
case "inspector" : FOCUSING_PANEL = PANEL_INSPECTOR; break;
case "animation" : FOCUSING_PANEL = PANEL_ANIMATION; break;
case "collection" : FOCUSING_PANEL = findPanel("Panel_Collection"); break;
case "collection" : FOCUSING_PANEL = PANEL_COLLECTION; break;
}
}
@ -220,6 +243,7 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
draw_set_color(_cc);
draw_set_alpha(_aa);
break;
case "spr" :
var _spr_t = _c[1];
if(!variable_struct_exists(THEME, _spr_t)) break;
@ -251,13 +275,19 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
_tw = string_width(_ch);
_th = string_height(_ch);
gpu_set_colorwriteenable(1, 1, 1, 0);
BLEND_OVERRIDE
draw_text_add_float(_tx, _y, _ch, _s * fsize);
BLEND_NORMAL
gpu_set_colorwriteenable(1, 1, 1, 1);
draw_text_add_float(_tx, _y, _ch, _s * fsize);
_tx += _tw * _s * fsize;
width += _tw * fsize;
break;
case 1 :
_cmd += _ch;
break;
case 1 : _cmd += _ch; break;
}
}
@ -269,29 +299,29 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
var _len = string_length(txt);
var _ch = "";
var _mode = 0;
var ss = "";
var ch_str = "";
var b = buffer_create(1, buffer_grow, 1);
while(index <= _len) {
_ch = string_char_at(txt, index);
index++;
switch(_ch) {
case "<" :
_mode = 1; continue;
case "<" : _mode = 1; continue;
case ">" :
var _c = string_splice(ch_str, " ");
if(array_length(_c) > 1) {
switch(_c[0]) {
case "bt" :
case "node" :
var _bch = "";
for( var i = 1; i < array_length(_c); i++ ) {
if(i > 1) _bch += " ";
_bch += _c[i];
}
for( var i = 1; i < array_length(_c); i++ )
_bch += i > 1? " " + _c[i] : _c[i];
ss += _bch;
buffer_write(b, buffer_text, _bch);
break;
}
}
@ -302,11 +332,15 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
}
switch(_mode) {
case 0 : ss += _ch; break;
case 0 : buffer_write(b, buffer_text, _ch); break;
case 1 : ch_str += _ch; break;
}
}
buffer_to_start(b);
var ss = buffer_read(b, buffer_text);
buffer_delete(b);
return ss;
}
@ -331,12 +365,14 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
var _ps = string_copy(_tx, 1, sp);
_tx = string_copy(_tx, sp + 1, string_length(_tx) - sp);
if(line_width > 0 && string_width(string_raw(ss + _ps)) * fsize >= line_width) {
var fullStr = ss + _ps;
if(line_width > 0 && string_width(string_raw(fullStr)) * fsize >= line_width) {
array_push(_lines, ss);
ss = _ps;
} else if(string_length(_tx) <= 0) {
array_push(_lines, ss + _ps);
array_push(_lines, fullStr);
ss = "";
} else
@ -365,7 +401,10 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
var _iny = yy + (junction_draw_hei_y * 0.5) * _s;
for( var i = 0, n = ds_list_size(inputs); i < n; i++ ) { inputs[| i].x = xx; inputs[| i].y = _iny; }
for( var i = 0, n = ds_list_size(inputs); i < n; i++ ) {
inputs[| i].x = xx;
inputs[| i].y = _iny;
}
for(var i = 0; i < in_cache_len; i++) {
jun = inputDisplayList[i];

View file

@ -10,28 +10,24 @@ function Node_Particle(_x, _y, _group = noone) : Node_VFX_Spawner_Base(_x, _y, _
.setDisplay(VALUE_DISPLAY.area, { onSurfaceSize });
inputs[| input_len + 0] = nodeValue("Output dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF)
.rejectArray()
.setDisplay(VALUE_DISPLAY.vector);
inputs[| input_len + 1] = nodeValue("Round position", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true, "Round position to the closest integer value to avoid jittering.")
.rejectArray();
inputs[| input_len + 1] = nodeValue("Round position", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true, "Round position to the closest integer value to avoid jittering.");
inputs[| input_len + 2] = nodeValue("Blend mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 )
.rejectArray()
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Normal", "Alpha", "Additive" ]);
inputs[| input_len + 3] = nodeValue("Background", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone )
.rejectArray();
inputs[| input_len + 3] = nodeValue("Background", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone );
inputs[| input_len + 4] = nodeValue("Render Type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, PARTICLE_RENDER_TYPE.surface )
.setDisplay(VALUE_DISPLAY.enum_button, [ "Surface", "Line" ])
.rejectArray();
.setDisplay(VALUE_DISPLAY.enum_button, [ "Surface", "Line" ]);
inputs[| input_len + 5] = nodeValue("Line life", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 4 )
.rejectArray()
inputs[| input_len + 5] = nodeValue("Line life", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 4 );
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
for(var i = input_len, n = ds_list_size(inputs); i < n; i++) inputs[| i].rejectArray();
attribute_surface_depth();
attribute_interpolation();
@ -48,7 +44,7 @@ function Node_Particle(_x, _y, _group = noone) : Node_VFX_Spawner_Base(_x, _y, _
static onInspector2Update = function() { clearCache(); }
static onValueUpdate = function(index = 0) { #region
static onValueUpdate = function(index = 0) {
if(index == input_len + 0) {
var _dim = getInputData(input_len + 0);
var _outSurf = outputs[| 0].getValue();
@ -59,9 +55,9 @@ function Node_Particle(_x, _y, _group = noone) : Node_VFX_Spawner_Base(_x, _y, _
if(PROJECT.animator.is_playing)
PROJECT.animator.firstFrame();
} #endregion
}
static reLoop = function() { #region
static reLoop = function() {
var _loop = getInputData(21);
var _type = getInputData(input_len + 4);
@ -73,9 +69,9 @@ function Node_Particle(_x, _y, _group = noone) : Node_VFX_Spawner_Base(_x, _y, _
}
seed = getInputData(32);
} #endregion
}
static onStep = function() { #region
static onStep = function() {
var _dim = getInputData(input_len + 0);
var _typ = getInputData(input_len + 4);
@ -87,9 +83,9 @@ function Node_Particle(_x, _y, _group = noone) : Node_VFX_Spawner_Base(_x, _y, _
curr_dimension[0] = _dim[0];
curr_dimension[1] = _dim[1];
}
} #endregion
}
static onUpdate = function(frame = CURRENT_FRAME) { #region
static onUpdate = function(frame = CURRENT_FRAME) {
var _inSurf = getInputData(0);
var _dim = getInputData(input_len + 0);
var _bg = getInputData(input_len + 3);
@ -109,9 +105,9 @@ function Node_Particle(_x, _y, _group = noone) : Node_VFX_Spawner_Base(_x, _y, _
}
if(IS_PLAYING) runVFX(frame);
} #endregion
}
function render(_time = CURRENT_FRAME) { #region
function render(_time = CURRENT_FRAME) {
var _dim = inputs[| input_len + 0].getValue(_time);
var _exact = inputs[| input_len + 1].getValue(_time);
var _blend = inputs[| input_len + 2].getValue(_time);
@ -146,5 +142,5 @@ function Node_Particle(_x, _y, _group = noone) : Node_VFX_Spawner_Base(_x, _y, _
if(PROJECT.animator.is_playing)
cacheCurrentFrame(_outSurf);
} #endregion
}
}

View file

@ -1037,6 +1037,7 @@ function __initNodes() {
addNodeObject(node, "Print", s_node_print, "Node_Print", [1, Node_Print], ["debug log"], "Display text to notification.").setVersion(1145);
addNodeObject(node, "Widget Test", s_node_print, "Node_Widget_Test", [1, Node_Widget_Test]);
addNodeObject(node, "Graph Preview", s_node_image, "Node_Graph_Preview", [1, Node_Graph_Preview]);
addNodeObject(node, "Slideshow", s_node_image, "Node_Slideshow", [1, Node_Slideshow]);
//addNodeObject(node, "Module Test", s_node_print, "Node_Module_Test", [1, Node_Module_Test]);
ds_list_add(node, "Project");

View file

@ -314,7 +314,7 @@ function Node_Repeat(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
var aa = _color_get_alpha(cc);
if(_an_use) {
cc = merge_color(cc, colorMultiply(cc, _an_bld), _inf);
cc = merge_color_a(cc, colorMultiply(cc, _an_bld), _inf);
aa += _an_alp * _inf;
}

View file

@ -0,0 +1,12 @@
{
"isDnD": false,
"isCompatibility": false,
"parent": {
"name": "process",
"path": "folders/nodes/data/process.yy",
},
"resourceVersion": "1.0",
"name": "node_outline",
"tags": [],
"resourceType": "GMScript",
}

View file

@ -0,0 +1,28 @@
function Node_Slideshow(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Slideshow";
project = PROJECT;
is_controller = true;
setDimension(128, 32);
inputs[| 0] = nodeValue("Order", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0);
inputs[| 1] = nodeValue("Title", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "");
inputs[| 2] = nodeValue("Anchor", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Center", "Top left" ]);
slide_title = "";
slide_anchor = 0;
static step = function() {
var _ord = inputs[| 0].getValue();
project.slideShow[$ _ord] = self;
slide_title = inputs[| 1].getValue();
slide_anchor = inputs[| 2].getValue();
setDisplayName($"Slide-{slide_title}");
}
}

View file

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

View file

@ -34,7 +34,9 @@ function Panel_Collection() : PanelContent() constructor {
view_tooltip = new tooltipSelector("View", [ "Grid", "List" ])
static initMenu = function() { #region
PANEL_COLLECTION = self;
static initMenu = function() {
if(_menu_node == noone) return;
var meta = _menu_node.getMetadata();
@ -131,7 +133,7 @@ function Panel_Collection() : PanelContent() constructor {
}));
}
}
} #endregion
}
initMenu();
search_string = "";
@ -145,7 +147,7 @@ function Panel_Collection() : PanelContent() constructor {
grid_size_to = grid_size;
contentView = 0;
contentPane = new scrollPane(content_w - ui(6), content_h, function(_y, _m) { #region
contentPane = new scrollPane(content_w - ui(6), content_h, function(_y, _m) {
draw_clear_alpha(c_white, 0);
var content;
@ -356,9 +358,9 @@ function Panel_Collection() : PanelContent() constructor {
}
return hh;
}); #endregion
});
folderPane = new scrollPane(group_w - ui(8), content_h, function(_y, _m) { #region
folderPane = new scrollPane(group_w - ui(8), content_h, function(_y, _m) {
draw_clear_alpha(COLORS.panel_bg_clear, 1);
var hh = ui(8);
_y += ui(8);
@ -386,34 +388,33 @@ function Panel_Collection() : PanelContent() constructor {
}
return hh + ui(28);
}); #endregion
});
function onFocusBegin() { PANEL_COLLECTION = self; }
function onResize() { #region
function onResize() {
initSize();
folderPane.resize(group_w - ui(8), content_h);
if(mode == 2) contentPane.resize(w - ui(16), content_h);
else contentPane.resize(content_w - ui(6), content_h);
} #endregion
}
function setContext(cont) { #region
function setContext(cont) {
context = cont;
contentPane.scroll_y_raw = 0;
contentPane.scroll_y_to = 0;
} #endregion
}
function refreshContext() { #region
function refreshContext() {
if(mode == 0) context.scan([ ".json", ".pxcc" ]);
else if(mode == 1) context.scan([ ".png", ".jpg", ".gif" ]);
if(STEAM_ENABLED)
steamUCGload();
} #endregion
if(STEAM_ENABLED) steamUCGload();
}
function drawContent(panel) { #region
function drawContent(panel) {
draw_clear_alpha(COLORS.panel_bg_clear, 1);
var content_y = ui(48);
@ -433,7 +434,6 @@ function Panel_Collection() : PanelContent() constructor {
folderPane.setFocusHover(pFOCUS, pHOVER);
folderPane.draw(0, content_y, mx, my - content_y);
#region resize width
if(group_w_dragging) {
CURSOR = cr_size_we;
group_w = max(ui(128), group_w_sx + (mx - group_w_mx));
@ -452,7 +452,6 @@ function Panel_Collection() : PanelContent() constructor {
group_w_sx = group_w;
}
}
#endregion
}
@ -488,7 +487,7 @@ function Panel_Collection() : PanelContent() constructor {
var by = ui(9);
var bs = ui(32);
if(search_string == "") { #region
if(search_string == "") {
if(bx > rootx) {
view_tooltip.index = contentView;
if(buttonInstant(THEME.button_hide, bx, by, bs, bs, [mx, my], pFOCUS, pHOVER, view_tooltip, THEME.view_mode, contentView) == 2)
@ -551,14 +550,14 @@ function Panel_Collection() : PanelContent() constructor {
dialogPanelCall(new Panel_Collections_Setting(), x + bx, y + by - 8, { anchor: ANCHOR.bottom | ANCHOR.left });
}
bx -= ui(36);
#endregion
} else { #region
} else {
var tb_w = ui(200);
var tb_x = w - ui(10) - tb_w;
var tb_y = ui(10);
tb_search.draw(tb_x, tb_y, tb_w, TEXTBOX_HEIGHT, search_string, [mx, my]);
#endregion
}
}
} #endregion
}

View file

@ -54,8 +54,8 @@
case "Panel_Animation" : var p = (create || findPanel(name))? new Panel_Animation() : PANEL_ANIMATION; if(focus) { PANEL_ANIMATION = p; } return p;
case "Panel_Preview" : var p = (create || findPanel(name))? new Panel_Preview() : PANEL_PREVIEW; if(focus) { PANEL_PREVIEW = p; } return p;
case "Panel_Graph" : var p = (create || findPanel(name))? new Panel_Graph() : PANEL_GRAPH; if(focus) { PANEL_GRAPH = p; } return p;
case "Panel_Collection" : var p = (create || findPanel(name))? new Panel_Collection(): PANEL_COLLECTION;if(focus) { PANEL_COLLECTION = p; } return p;
case "Panel_Collection" : return new Panel_Collection();
case "Panel_Workspace" : return new Panel_Workspace();
case "Panel_Tunnels" : return new Panel_Tunnels();
case "Panel_History" : return new Panel_History();

View file

@ -162,20 +162,11 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
title = title_raw + (project.modified? "*" : "");
}
static setProject = function(project) {
self.project = project;
nodes_list = project.nodes;
setTitle();
}
static reset = function() {
onFocusBegin();
resetContext();
}
setProject(project);
#region ---- display ----
display_parameter = {
show_grid : true,
@ -185,6 +176,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
avoid_label : true,
preview_scale : 100,
highlight : false,
show_control : false,
}
connection_param = new connectionParameter();
@ -199,6 +192,10 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
graph_cx = 0;
graph_cy = 0;
graph_autopan = false;
graph_pan_x_to = 0;
graph_pan_y_to = 0;
scale = [ 0.01, 0.02, 0.05, 0.10, 0.15, 0.20, 0.25, 0.33, 0.50, 0.65, 0.80, 1, 1.2, 1.35, 1.5, 2.0 ];
graph_s = 1;
graph_s_to = graph_s;
@ -244,6 +241,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
#region ---- nodes ----
node_context = [];
nodes_list = [];
node_dragging = noone;
node_drag_mx = 0;
@ -371,7 +369,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
// print($"{cx}, {cy} / {graph_x}, {graph_y}");
}
function initSize() { toCenterNode(); } initSize();
function initSize() { toCenterNode(); }
#region ++++ hotkeys ++++
addHotkey("Graph", "Add node", "A", MOD_KEY.none, panel_graph_add_node);
@ -759,6 +757,17 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
menu_junc_color.spacing = ui(24);
#endregion
//// ============ Project ============
static setProject = function(project) {
self.project = project;
nodes_list = project.nodes;
setTitle();
run_in(2, function() /*=>*/ { setSlideShow(0, true); });
struct_override(display_parameter, project.graph_display_parameter);
}
//// ============ Views ============
function onFocusBegin() { #region
@ -778,12 +787,21 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
fullView();
} #endregion
function fullView() { #region
function fullView() {
INLINE
toCenterNode(array_empty(nodes_selecting)? nodes_list : nodes_selecting);
} #endregion
}
function dragGraph() {
if(graph_autopan) {
graph_x = lerp_float(graph_x, graph_pan_x_to, 16, 1);
graph_y = lerp_float(graph_y, graph_pan_y_to, 16, 1);
if(graph_x == graph_pan_x_to && graph_y == graph_pan_y_to)
graph_autopan = false;
return;
}
function dragGraph() { #region
if(graph_dragging) {
if(!MOUSE_WRAPPING) {
var dx = mx - graph_drag_mx;
@ -905,15 +923,53 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
graph_draggable = true;
graph_x = round(graph_x);
graph_y = round(graph_y);
} #endregion
}
function autoPanTo(_x, _y) {
graph_autopan = true;
graph_pan_x_to = _x;
graph_pan_y_to = _y;
}
function setSlideShow(index, skip = false) {
var _targ = project.slideShowSet(index);
if(_targ == noone) return;
var _gx = w / 2 / graph_s;
var _gy = h / 2 / graph_s;
var _tx = _gx;
var _ty = _gy;
switch(_targ.slide_anchor) {
case 0 :
_tx = _gx - _targ.x;
_ty = _gy - _targ.y;
break;
case 1 :
_tx = 64 * graph_s - _targ.x;
_ty = 64 * graph_s - _targ.y;
break;
}
if(skip) {
graph_x = _tx;
graph_y = _ty;
} else
autoPanTo(_tx, _ty, skip);
}
//// =========== Context ==========
function resetContext() { #region
function resetContext() {
node_context = [];
nodes_list = project.nodes;
toCenterNode();
} #endregion
}
function addContext(node) {
var _node = node.getNodeBase();
@ -1105,19 +1161,21 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
frame_hovering = noone;
for(var i = 0; i < array_length(nodes_list); i++) {
var _nl = nodes_list[i];
var _node = nodes_list[i];
if(!display_parameter.show_control && _node.is_controller) continue;
_nl.cullCheck(gr_x, gr_y, graph_s, -32, -32, w + 32, h + 64);
_nl.preDraw(gr_x, gr_y, graph_s, gr_x, gr_y);
_node.cullCheck(gr_x, gr_y, graph_s, -32, -32, w + 32, h + 64);
_node.preDraw(gr_x, gr_y, graph_s, gr_x, gr_y);
}
printIf(log, $"Predraw time: {get_timer() - t}"); t = get_timer();
#region draw frame
for(var i = 0; i < array_length(nodes_list); i++) {
var _nl = nodes_list[i];
var _node = nodes_list[i];
if(!display_parameter.show_control && _node.is_controller) continue;
if(_nl.drawNodeBG(gr_x, gr_y, mx, my, graph_s, display_parameter, self))
frame_hovering = _nl;
if(_node.drawNodeBG(gr_x, gr_y, mx, my, graph_s, display_parameter, self))
frame_hovering = _node;
}
#endregion
printIf(log, $"Frame draw time: {get_timer() - t}"); t = get_timer();
@ -1127,6 +1185,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(pHOVER)
for(var i = 0; i < array_length(nodes_list); i++) {
var _node = nodes_list[i];
if(!display_parameter.show_control && _node.is_controller) continue;
_node.branch_drawing = false;
if(_node.pointIn(gr_x, gr_y, mx, my, graph_s))
@ -1192,6 +1252,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
for(var i = 0; i < array_length(nodes_list); i++) { //select content
var _node = nodes_list[i];
if(_node == node_hovering) continue;
if(!display_parameter.show_control && _node.is_controller) continue;
if(!_node.selectable) continue;
@ -1390,9 +1451,12 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
param.setDraw(aa, bg_color);
for(var i = 0; i < array_length(nodes_list); i++) {
var _node = nodes_list[i];
if(!display_parameter.show_control && _node.is_controller) continue;
param.cur_layer = i + 1;
var _hov = nodes_list[i].drawConnections(param);
var _hov = _node.drawConnections(param);
if(_hov != noone && is_struct(_hov)) hov = _hov;
}
@ -1438,12 +1502,17 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
value_focus = noone;
var t = get_timer();
for(var i = 0; i < array_length(nodes_list); i++)
for(var i = 0; i < array_length(nodes_list); i++) {
var _node = nodes_list[i];
if(!display_parameter.show_control && _node.is_controller) continue;
nodes_list[i].drawNodeBehind(gr_x, gr_y, mx, my, graph_s);
}
for(var i = 0; i < array_length(nodes_list); i++) {
var _node = nodes_list[i];
if(!display_parameter.show_control && _node.is_controller) continue;
if(is_instanceof(_node, Node_Frame)) continue;
try {
var val = _node.drawNode(gr_x, gr_y, mx, my, graph_s, display_parameter, self);
@ -1456,12 +1525,20 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
}
}
for(var i = 0; i < array_length(nodes_list); i++)
for(var i = 0; i < array_length(nodes_list); i++) {
var _node = nodes_list[i];
if(!display_parameter.show_control && _node.is_controller) continue;
if(!is_instanceof(nodes_list[i], Node_Frame))
nodes_list[i].drawBadge(gr_x, gr_y, graph_s);
}
for(var i = 0; i < array_length(nodes_list); i++)
for(var i = 0; i < array_length(nodes_list); i++) {
var _node = nodes_list[i];
if(!display_parameter.show_control && _node.is_controller) continue;
nodes_list[i].drawNodeFG(gr_x, gr_y, mx, my, graph_s, display_parameter, self);
}
if(PANEL_INSPECTOR && PANEL_INSPECTOR.prop_hover != noone)
value_focus = PANEL_INSPECTOR.prop_hover;
@ -1563,6 +1640,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
for(var i = 0; i < array_length(nodes_list); i++) {
var _node = nodes_list[i];
if(!display_parameter.show_control && _node.is_controller) continue;
if(!_node.selectable) continue;
if(is_instanceof(_node, Node_Frame) && !nodes_select_frame) continue;
@ -1879,8 +1957,12 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
var gr_x = graph_x * graph_s;
var gr_y = graph_y * graph_s;
for(var i = 0; i < array_length(nodes_list); i++)
nodes_list[i].drawJunctionNames(gr_x, gr_y, mx, my, graph_s);
for(var i = 0; i < array_length(nodes_list); i++) {
var _node = nodes_list[i];
if(!display_parameter.show_control && _node.is_controller) continue;
_node.drawJunctionNames(gr_x, gr_y, mx, my, graph_s);
}
} #endregion
@ -2212,6 +2294,70 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
draw_set_alpha(1);
}
function drawSlideShow() {
if(!project.useSlideShow) return;
var amo = project.slideShow_amount;
var ind = project.slideShow_index;
var cur = project.slideShow_current;
var _sl_w = (amo - 1) * ui(16) + ui(16 * 2);
var _sl_h = ui(32);
var _sl_x = w / 2 - _sl_w / 2;
var _ss_x = _sl_x;
var _sl_y = h - toolbar_height - ui(8) - _sl_h;
var _ss_y = _sl_y + _sl_h - ui(16);
if(cur != noone) {
draw_set_text(f_p2, fa_center, fa_top, COLORS._main_icon_light);
var _txtw = string_width(cur.slide_title) + ui(32);
_sl_w = max(_sl_w, _txtw);
_sl_h = _sl_h + ui(8 + 12);
_sl_x = w / 2 - _sl_w / 2;
_sl_y = h - toolbar_height - ui(8) - _sl_h;
}
draw_sprite_stretched(THEME.ui_panel_bg, 3, _sl_x, _sl_y, _sl_w, _sl_h);
if(cur != noone) draw_text_add(round(w / 2), round(_sl_y + ui(8)), cur.slide_title);
var _hv = false;
for(var i = 0; i < amo; i++) {
var _sx = _ss_x + ui(16) + i * ui(16);
var _sy = _ss_y;
var cc = i == ind? COLORS._main_accent : COLORS._main_icon;
var aa = i == ind? 1 : .5;
var ss = i == ind? 1 : .8;
if(pHOVER && point_in_circle(mx, my, _sx, _sy, ui(8))) {
_hv = true;
aa = 1;
if(mouse_press(mb_left, pFOCUS))
setSlideShow(i);
}
draw_sprite_ext(THEME.circle, 0, _sx, _sy, ss, ss, 0, cc, aa);
}
if(point_in_rectangle(mx, my, _sl_x, _sl_y, _sl_x + _sl_w, _sl_y + _sl_h)) {
mouse_on_graph = false;
if(pHOVER && !_hv) {
draw_sprite_stretched_add(THEME.ui_panel_bg, 4, _sl_x, _sl_y, _sl_w, _sl_h, COLORS._main_icon, 0.05);
draw_sprite_stretched_add(THEME.ui_panel_fg, 1, _sl_x, _sl_y, _sl_w, _sl_h, c_white, 0.1);
if(mouse_press(mb_left, pFOCUS))
setSlideShow((ind + 1) % amo);
}
}
}
function drawContent(panel) { #region //// Main Draw
if(!project.active) return;
@ -2269,6 +2415,8 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
draw_text(w - 8, h - toolbar_height, "Live Update");
}
drawSlideShow();
////////////////////////////////// File drop //////////////////////////////////
if(pHOVER) {
@ -2973,6 +3121,9 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
var dia = dialogCall(o_dialog_save);
dia.project = project;
} #endregion
setProject(project);
initSize();
}
//// ========== File Drop ==========

View file

@ -22,7 +22,7 @@ function Panel_Graph_View_Setting(graphPanel, display) : Panel_Linear_Setting()
true,
),
new __Panel_Linear_Setting_Item(
__txtx("graph_visibility_compute", "Compute time"),
__txtx("graph_visibility_compute", "Compute Time"),
new checkBox(function() { display_parameter.show_compute = !display_parameter.show_compute; }),
function() { return display_parameter.show_compute },
function(val) { display_parameter.show_compute = val; },
@ -35,6 +35,16 @@ function Panel_Graph_View_Setting(graphPanel, display) : Panel_Linear_Setting()
function(val) { display_parameter.avoid_label = val; },
true,
),
new __Panel_Linear_Setting_Item(
__txtx("graph_visibility_slideshow", "Show Controller"),
new checkBox(function() { display_parameter.show_control = !display_parameter.show_control; }),
function() { return display_parameter.show_control },
function(val) { display_parameter.show_control = val; },
false,
),
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
new __Panel_Linear_Setting_Item(
__txtx("graph_visibility_preview_scale", "Preview Scale"),
slider(50, 100, 1, function(val) { display_parameter.preview_scale = val; }),

View file

@ -38,7 +38,7 @@
load_layout = false;
previewGrid = { #region
previewGrid = {
show : false,
snap : false,
size : [ 16, 16 ],
@ -46,9 +46,9 @@
color : COLORS.panel_preview_grid,
pixel : false,
} #endregion
}
graphGrid = { #region
graphGrid = {
show : true,
show_origin : false,
snap : true,
@ -56,18 +56,29 @@
opacity : 0.05,
color : c_white,
highlight : 12,
} #endregion
}
graph_display_parameter = {
show_grid : true,
show_dimension : true,
show_compute : true,
avoid_label : true,
preview_scale : 100,
highlight : false,
show_control : false,
}
addons = {};
onion_skin = { #region
onion_skin = {
enabled: false,
range: [ -1, 1 ],
step: 1,
color: [ c_red, c_blue ],
alpha: 0.5,
on_top: true,
}; #endregion
};
#region =================== ATTRIBUTES ===================
attributes = variable_clone(PROJECT_ATTRIBUTES);
@ -142,7 +153,42 @@
notes = [];
static cleanup = function() { #region
static step = function() {
slideShowPreStep();
animator.step();
globalNode.step();
}
static postStep = function() {
slideShowPostStep();
}
useSlideShow = false;
slideShow = {};
slideShow_keys = 0;
slideShow_index = 0;
slideShow_amount = 0;
slideShow_current = noone;
static slideShowPreStep = function() { slideShow = {}; }
static slideShowPostStep = function() {
slideShow_keys = variable_struct_get_names(slideShow);
array_sort(slideShow_keys, true);
slideShow_amount = array_length(slideShow_keys);
useSlideShow = slideShow_amount > 0;
slideShow_current = struct_try_get(slideShow, array_safe_get(slideShow_keys, slideShow_index, 0), noone);
}
static slideShowSet = function(index) {
slideShow_index = index;
slideShow_current = struct_try_get(slideShow, array_safe_get(slideShow_keys, slideShow_index, 0), noone);
return slideShow_current;
}
static cleanup = function() {
array_foreach(allNodes, function(_node) {
_node.active = false;
_node.cleanUp();
@ -152,7 +198,7 @@
ds_map_destroy(nodeNameMap);
gc_collect();
} #endregion
}
static toString = function() { return $"ProjectObject [{path}]"; }
@ -181,6 +227,8 @@
_map.composer = composer;
_map.load_layout = load_layout;
_map.graph_display_parameter = graph_display_parameter;
__node_list = [];
array_foreach(allNodes, function(node) { if(node.active) array_push(__node_list, node.serialize()); })
_map.nodes = __node_list;
@ -215,6 +263,8 @@
if(struct_has(_map, "metadata")) meta.deserialize(_map.metadata);
if(struct_has(_map, "composer")) composer = _map.composer;
if(struct_has(_map, "graph_display_parameter")) struct_override(graph_display_parameter, _map.graph_display_parameter);
load_layout = struct_try_get(_map, "load_layout", load_layout);
setPalette();