collection settings

This commit is contained in:
Tanasart 2023-12-09 15:00:35 +07:00
parent 1c5255146e
commit 79672e9765
11 changed files with 147 additions and 79 deletions

View file

@ -246,6 +246,7 @@
{"name":"button","order":34,"path":"folders/widgets/button.yy",}, {"name":"button","order":34,"path":"folders/widgets/button.yy",},
{"name":"rotator","order":35,"path":"folders/widgets/rotator.yy",}, {"name":"rotator","order":35,"path":"folders/widgets/rotator.yy",},
{"name":"text","order":36,"path":"folders/widgets/text.yy",}, {"name":"text","order":36,"path":"folders/widgets/text.yy",},
{"name":"collection","order":11,"path":"folders/panels/collection.yy",},
], ],
"ResourceOrderSettings": [ "ResourceOrderSettings": [
{"name":"s_node_corner","order":16,"path":"sprites/s_node_corner/s_node_corner.yy",}, {"name":"s_node_corner","order":16,"path":"sprites/s_node_corner/s_node_corner.yy",},

View file

@ -281,6 +281,7 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"button","folderPath":"folders/widgets/button.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"button","folderPath":"folders/widgets/button.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"rotator","folderPath":"folders/widgets/rotator.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"rotator","folderPath":"folders/widgets/rotator.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"text","folderPath":"folders/widgets/text.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"text","folderPath":"folders/widgets/text.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"collection","folderPath":"folders/panels/collection.yy",},
], ],
"IncludedFiles": [ "IncludedFiles": [
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ApolloHelp.html","ConfigValues":{"Itch":{"CopyToMask":"0",},},"CopyToMask":-1,"filePath":"datafiles",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ApolloHelp.html","ConfigValues":{"Itch":{"CopyToMask":"0",},},"CopyToMask":-1,"filePath":"datafiles",},
@ -2854,6 +2855,7 @@
{"id":{"name":"node_level","path":"scripts/node_level/node_level.yy",},}, {"id":{"name":"node_level","path":"scripts/node_level/node_level.yy",},},
{"id":{"name":"node_pb","path":"scripts/node_pb/node_pb.yy",},}, {"id":{"name":"node_pb","path":"scripts/node_pb/node_pb.yy",},},
{"id":{"name":"panel_test","path":"scripts/panel_test/panel_test.yy",},}, {"id":{"name":"panel_test","path":"scripts/panel_test/panel_test.yy",},},
{"id":{"name":"panel_collections_settings","path":"scripts/panel_collections_settings/panel_collections_settings.yy",},},
{"id":{"name":"o_dialog_warning","path":"objects/o_dialog_warning/o_dialog_warning.yy",},}, {"id":{"name":"o_dialog_warning","path":"objects/o_dialog_warning/o_dialog_warning.yy",},},
{"id":{"name":"s_node_group_output","path":"sprites/s_node_group_output/s_node_group_output.yy",},}, {"id":{"name":"s_node_group_output","path":"sprites/s_node_group_output/s_node_group_output.yy",},},
{"id":{"name":"node_path_l_system","path":"scripts/node_path_l_system/node_path_l_system.yy",},}, {"id":{"name":"node_path_l_system","path":"scripts/node_path_l_system/node_path_l_system.yy",},},

View file

@ -130,7 +130,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
insp2UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ]; insp2UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ];
static inspector1Update = function() { onInspector1Update(); } static inspector1Update = function() { onInspector1Update(); }
static onInspector1Update = function() { RenderListAction(nodes, group); } static onInspector1Update = function() { RenderList(nodes, true); }
static hasInspector1Update = function(group = false) { #region static hasInspector1Update = function(group = false) { #region
for( var i = 0; i < ds_list_size(nodes); i++ ) { for( var i = 0; i < ds_list_size(nodes); i++ ) {
if(nodes[| i].hasInspector1Update()) if(nodes[| i].hasInspector1Update())

View file

@ -111,7 +111,7 @@ function Node_Iterate_Sort(_x, _y, _group = noone) : Node_Collection(_x, _y, _gr
inputNodes[1].setValue(val2,,, false); inputNodes[1].setValue(val2,,, false);
resetRender(true); resetRender(true);
RenderList(topoList, false); RenderList(topoList);
var res = outputNode.getValue(); var res = outputNode.getValue();
LOG_IF(global.FLAG.render == 1, $"Iterating | Comparing {val1}, {val2} = {res}"); LOG_IF(global.FLAG.render == 1, $"Iterating | Comparing {val1}, {val2} = {res}");

View file

@ -658,7 +658,7 @@ function __initNodes() {
ds_list_add(values, "Numbers"); ds_list_add(values, "Numbers");
addNodeObject(values, "Number", s_node_number, "Node_Number", [1, Node_Number]); addNodeObject(values, "Number", s_node_number, "Node_Number", [1, Node_Number]);
addNodeObject(values, "To Number", s_node_to_number, "Node_To_Number", [1, Node_To_Number]).setVersion(1145); addNodeObject(values, "To Number", s_node_to_number, "Node_To_Number", [1, Node_To_Number]).setVersion(1145);
addNodeObject(values, "Math", s_node_math, "Node_Math", [0, Node_create_Math], [ "add", "subtract", "multiply", "divide", "power", "modulo", "round", "ceiling", "floor", "sin", "cos", "tan", "abs" ]); addNodeObject(values, "Math", s_node_math, "Node_Math", [0, Node_create_Math], [ "add", "subtract", "multiply", "divide", "power", "root", "modulo", "round", "ceiling", "floor", "sin", "cos", "tan", "lerp", "abs" ]);
addNodeObject(values, "Equation", s_node_equation, "Node_Equation", [0, Node_create_Equation],, "Evaluate string of equation. With an option for setting variables."); addNodeObject(values, "Equation", s_node_equation, "Node_Equation", [0, Node_create_Equation],, "Evaluate string of equation. With an option for setting variables.");
addNodeObject(values, "Random", s_node_random, "Node_Random", [1, Node_Random]); addNodeObject(values, "Random", s_node_random, "Node_Random", [1, Node_Random]);
addNodeObject(values, "Statistic", s_node_statistic, "Node_Statistic", [0, Node_create_Statistic], ["sum", "average", "mean", "median", "min", "max"]); addNodeObject(values, "Statistic", s_node_statistic, "Node_Statistic", [0, Node_create_Statistic], ["sum", "average", "mean", "median", "min", "max"]);
@ -670,11 +670,11 @@ function __initNodes() {
addNodeObject(values, "Scatter Points", s_node_scatter_point, "Node_Scatter_Points", [1, Node_Scatter_Points],, "Generate array of vector 2 points for scattering.").setVersion(1120); addNodeObject(values, "Scatter Points", s_node_scatter_point, "Node_Scatter_Points", [1, Node_Scatter_Points],, "Generate array of vector 2 points for scattering.").setVersion(1120);
addNodeObject(values, "Translate Point",s_node_translate_point, "Node_Move_Point", [1, Node_Move_Point]).setVersion(1141); addNodeObject(values, "Translate Point",s_node_translate_point, "Node_Move_Point", [1, Node_Move_Point]).setVersion(1141);
addNodeObject(values, "Dot product", s_node_dot_product, "Node_Vector_Dot", [1, Node_Vector_Dot]).setVersion(1141); addNodeObject(values, "Dot product", s_node_dot_product, "Node_Vector_Dot", [1, Node_Vector_Dot]).setVersion(1141);
addNodeObject(values, "Cross product 3D", s_node_cross_product_2d, "Node_Vector_Cross_3D", [1, Node_Vector_Cross_3D]).setVersion(1141); addNodeObject(values, "Cross product 3D", s_node_cross_product_2d, "Node_Vector_Cross_3D", [1, Node_Vector_Cross_3D]).setVersion(1141);
addNodeObject(values, "Cross product 2D", s_node_cross_product_3d, "Node_Vector_Cross_2D", [1, Node_Vector_Cross_2D]).setVersion(1141); addNodeObject(values, "Cross product 2D", s_node_cross_product_3d, "Node_Vector_Cross_2D", [1, Node_Vector_Cross_2D]).setVersion(1141);
addNodeObject(values, "FFT", s_node_FFT, "Node_FFT", [1, Node_FFT], ["frequency analysis"], "Perform fourier transform on number array.").setVersion(1144); addNodeObject(values, "FFT", s_node_FFT, "Node_FFT", [1, Node_FFT], ["frequency analysis"], "Perform fourier transform on number array.").setVersion(1144);
addNodeObject(values, "Transform Array",s_node_transform_array, "Node_Transform_Array", [1, Node_Transform_Array]).setVersion(1146); addNodeObject(values, "Transform Array", s_node_transform_array, "Node_Transform_Array", [1, Node_Transform_Array]).setVersion(1146);
ds_list_add(values, "Texts"); ds_list_add(values, "Texts");
addNodeObject(values, "Text", s_node_text, "Node_String", [1, Node_String]); addNodeObject(values, "Text", s_node_text, "Node_String", [1, Node_String]);
addNodeObject(values, "To Text", s_node_to_text, "Node_To_Text", [1, Node_To_Text]).setVersion(1145); addNodeObject(values, "To Text", s_node_to_text, "Node_To_Text", [1, Node_To_Text]).setVersion(1145);

View file

@ -164,8 +164,11 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
var vCol = array_exists(useV, "Color"); var vCol = array_exists(useV, "Color");
var _posDist = []; var _posDist = [];
if(_dist == 2 && is_surface(_distMap)) if(_dist == NODE_SCATTER_DIST.map) {
if(!is_surface(_distMap))
return _outSurf;
_posDist = get_points_from_dist(_distMap, _amount, seed); _posDist = get_points_from_dist(_distMap, _amount, seed);
}
if(_dist == 4) { if(_dist == 4) {
var path_valid = path != noone && struct_has(path, "getPointRatio"); var path_valid = path != noone && struct_has(path, "getPointRatio");
@ -204,13 +207,13 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
sp = area_get_random_point(_area, _dist, _scat, i, _amount, _sed); _sed += 20; sp = area_get_random_point(_area, _dist, _scat, i, _amount, _sed); _sed += 20;
_x = sp[0]; _x = sp[0];
_y = sp[1]; _y = sp[1];
} else if(_dist == NODE_SCATTER_DIST.data) { } else if(_dist == NODE_SCATTER_DIST.map) {
sp = array_safe_get(_posDist, i); sp = array_safe_get(_posDist, i);
if(!is_array(sp)) continue; if(!is_array(sp)) continue;
_x = _area[0] + _area[2] * (sp[0] * 2 - 1.); _x = _area[0] + _area[2] * (sp[0] * 2 - 1.);
_y = _area[1] + _area[3] * (sp[1] * 2 - 1.); _y = _area[1] + _area[3] * (sp[1] * 2 - 1.);
} else if(_dist == NODE_SCATTER_DIST.map) { } else if(_dist == NODE_SCATTER_DIST.data) {
sp = array_safe_get(_distData, i); sp = array_safe_get(_distData, i);
if(!is_array(sp)) continue; if(!is_array(sp)) continue;

View file

@ -220,7 +220,7 @@ function Panel_Collection() : PanelContent() constructor {
if(sprite_exists(_node.spr)) { if(sprite_exists(_node.spr)) {
var sw = sprite_get_width(_node.spr); var sw = sprite_get_width(_node.spr);
var sh = sprite_get_height(_node.spr); var sh = sprite_get_height(_node.spr);
var ss = (grid_size - ui(10)) / max(sw, sh); var ss = (grid_size - ui(10)) * PREFERENCES.collection_scale / max(sw, sh);
var xo = (sprite_get_xoffset(_node.spr) - sw / 2) * ss; var xo = (sprite_get_xoffset(_node.spr) - sw / 2) * ss;
var yo = (sprite_get_yoffset(_node.spr) - sh / 2) * ss; var yo = (sprite_get_yoffset(_node.spr) - sh / 2) * ss;
@ -426,7 +426,7 @@ function Panel_Collection() : PanelContent() constructor {
var by = ui(9); var by = ui(9);
var bs = ui(32); var bs = ui(32);
if(search_string == "") { if(search_string == "") { #region
if(bx > rootx) { if(bx > rootx) {
view_tooltip.index = contentView; view_tooltip.index = contentView;
if(buttonInstant(THEME.button_hide, bx, by, bs, bs, [mx, my], pFOCUS, pHOVER, view_tooltip, THEME.view_mode, contentView) == 2) if(buttonInstant(THEME.button_hide, bx, by, bs, bs, [mx, my], pFOCUS, pHOVER, view_tooltip, THEME.view_mode, contentView) == 2)
@ -483,12 +483,21 @@ function Panel_Collection() : PanelContent() constructor {
refreshContext(); refreshContext();
} }
bx -= ui(36); bx -= ui(36);
} else {
if(bx > rootx) {
var txt = __txt("Settings");
if(buttonInstant(THEME.button_hide, bx, by, bs, bs, [mx, my], pFOCUS, pHOVER, txt, THEME.gear) == 2)
dialogPanelCall(new Panel_Collections_Setting(), x + bx, y + by - 8, { anchor: ANCHOR.bottom | ANCHOR.left });
}
bx -= ui(36);
#endregion
} else { #region
var tb_w = ui(200); var tb_w = ui(200);
var tb_x = w - ui(10) - tb_w; var tb_x = w - ui(10) - tb_w;
var tb_y = ui(10); var tb_y = ui(10);
tb_search.draw(tb_x, tb_y, tb_w, TEXTBOX_HEIGHT, search_string, [mx, my]); tb_search.draw(tb_x, tb_y, tb_w, TEXTBOX_HEIGHT, search_string, [mx, my]);
#endregion
} }
} #endregion } #endregion
} }

View file

@ -0,0 +1,27 @@
function Panel_Collections_Setting() : Panel_Linear_Setting() constructor {
title = __txtx("collection_settings", "Collection Settings");
w = ui(380);
#region data
properties = [
new __Panel_Linear_Setting_Item_Preference(
__txtx("coll_animated", "Animated thumbnail"),
"collection_animated",
new checkBox(function() { PREFERENCES.collection_animated = !PREFERENCES.collection_animated; PREF_SAVE(); }),
),
new __Panel_Linear_Setting_Item_Preference(
__txtx("coll_animated_speed", "Animation speed"),
"collection_preview_speed",
new textBox(TEXTBOX_INPUT.number, function(val) { PREFERENCES.collection_preview_speed = val; PREF_SAVE(); }),
),
new __Panel_Linear_Setting_Item_Preference(
__txtx("coll_thumbnail_scale", "Thumbnail scale"),
"collection_scale",
new slider(0, 1, 0.01, function(val) { PREFERENCES.collection_scale = clamp(val, 0.1, 1); PREF_SAVE(); }),
),
];
setHeight();
#endregion
}

View file

@ -0,0 +1,11 @@
{
"resourceType": "GMScript",
"resourceVersion": "1.0",
"name": "panel_collections_settings",
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "collection",
"path": "folders/panels/collection.yy",
},
}

View file

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

View file

@ -249,7 +249,7 @@ function __renderListReset(list) { #region
} }
} #endregion } #endregion
function RenderList(list, skipInLoop = true) { #region function RenderList(list, runAction = false) { #region
LOG_BLOCK_START(); LOG_BLOCK_START();
LOG_IF(global.FLAG.render == 1, "=============== RENDER LIST START ==============="); LOG_IF(global.FLAG.render == 1, "=============== RENDER LIST START ===============");
var queue = ds_queue_create(); var queue = ds_queue_create();
@ -287,18 +287,20 @@ function RenderList(list, skipInLoop = true) { #region
while(!ds_queue_empty(queue)) { while(!ds_queue_empty(queue)) {
LOG_BLOCK_START(); LOG_BLOCK_START();
rendering = ds_queue_dequeue(queue) rendering = ds_queue_dequeue(queue)
if(!ds_list_exist(list, rendering)) continue;
var renderable = rendering.isRenderable(); var renderable = rendering.isRenderable();
LOG_IF(global.FLAG.render == 1, $"Rendering {rendering.internalName} ({rendering.display_name}) : {renderable? "Update" : "Pass"}"); LOG_IF(global.FLAG.render == 1, $"Rendering {rendering.internalName} ({rendering.display_name}) : {renderable? "Update" : "Pass"}");
if(renderable) { if(renderable) {
if(runAction && rendering.hasInspector1Update()) rendering.inspector1Update();
rendering.doUpdate(); rendering.doUpdate();
var nextNodes = rendering.getNextNodes(); var nextNodes = rendering.getNextNodes();
for( var i = 0, n = array_length(nextNodes); i < n; i++ ) for( var i = 0, n = array_length(nextNodes); i < n; i++ ) {
if(nextNodes[i].isRenderable()) var _node = nextNodes[i];
ds_queue_enqueue(queue, nextNodes[i]); if(ds_list_exist(list, _node) && _node.isRenderable())
ds_queue_enqueue(queue, _node);
}
} }
LOG_BLOCK_END(); LOG_BLOCK_END();
@ -312,64 +314,4 @@ function RenderList(list, skipInLoop = true) { #region
LOG_END(); LOG_END();
ds_queue_destroy(queue); ds_queue_destroy(queue);
} #endregion
function RenderListAction(list, context = PANEL_GRAPH.getCurrentContext()) { #region
printIf(global.FLAG.render, "=== RENDER LIST ACTION START [frame " + string(CURRENT_FRAME) + "] ===");
try {
var rendering = noone;
var error = 0;
var t = current_time;
__renderListReset(list);
// get leaf node
RENDER_QUEUE.clear();
for( var i = 0; i < ds_list_size(list); i++ ) {
var _node = list[| i];
if(is_undefined(_node)) continue;
if(!is_struct(_node)) continue;
if(!_node.active) continue;
if(!_node.isRenderActive()) continue;
if(_node.rendered) continue;
if(_node.isRenderable()) {
RENDER_QUEUE.enqueue(_node);
printIf(global.FLAG.render, $" > Push {_node.internalName} node to queue");
}
}
// render forward
while(!RENDER_QUEUE.empty()) {
LOG_BLOCK_START();
LOG_IF(global.FLAG.render == 1, $"➤➤➤➤➤➤ CURRENT RENDER QUEUE {RENDER_QUEUE}");
rendering = RENDER_QUEUE.dequeue();
if(!ds_list_exist(list, rendering)) continue;
var renderable = rendering.isRenderable();
LOG_IF(global.FLAG.render == 1, $"Rendering {rendering.internalName} ({rendering.display_name}) : {renderable? "Update" : "Pass"}");
if(renderable) {
rendering.doUpdate();
var nextNodes = rendering.getNextNodes();
for( var i = 0, n = array_length(nextNodes); i < n; i++ )
RENDER_QUEUE.enqueue(nextNodes[i]);
if(runAction && rendering.hasInspector1Update())
rendering.inspector1Update();
} else if(rendering.isRenderActive()) {
RENDER_QUEUE.enqueue(rendering);
}
LOG_BLOCK_END();
}
printIf(global.FLAG.render, "=== RENDER COMPLETE IN {" + string(current_time - t) + "ms} ===\n");
} catch(e) {
noti_warning(exception_print(e));
}
} #endregion } #endregion