Custom addon framework

This commit is contained in:
Tanasart 2023-04-22 16:23:51 +02:00
parent c72d3c8e9b
commit 830b60eed1
21 changed files with 266 additions and 54 deletions

View File

@ -12,8 +12,8 @@
{"name":"menu","order":10,"path":"folders/dialog/menu.yy",}, {"name":"menu","order":10,"path":"folders/dialog/menu.yy",},
{"name":"preview","order":7,"path":"folders/dialog/preview.yy",}, {"name":"preview","order":7,"path":"folders/dialog/preview.yy",},
{"name":"widget","order":9,"path":"folders/dialog/widget.yy",}, {"name":"widget","order":9,"path":"folders/dialog/widget.yy",},
{"name":"Extensions","order":9,"path":"folders/Extensions.yy",}, {"name":"_Extensions","order":9,"path":"folders/_Extensions.yy",},
{"name":"MAC","order":7,"path":"folders/Extensions/MAC.yy",}, {"name":"MAC","order":7,"path":"folders/_Extensions/MAC.yy",},
{"name":"font","order":7,"path":"folders/font.yy",}, {"name":"font","order":7,"path":"folders/font.yy",},
{"name":"functions","order":6,"path":"folders/functions.yy",}, {"name":"functions","order":6,"path":"folders/functions.yy",},
{"name":"animation","order":19,"path":"folders/functions/animation.yy",}, {"name":"animation","order":19,"path":"folders/functions/animation.yy",},
@ -143,6 +143,7 @@
{"name":"sprites","order":12,"path":"folders/sprites.yy",}, {"name":"sprites","order":12,"path":"folders/sprites.yy",},
{"name":"gameframe","order":2,"path":"folders/sprites/gameframe.yy",}, {"name":"gameframe","order":2,"path":"folders/sprites/gameframe.yy",},
{"name":"widgets","order":5,"path":"folders/widgets.yy",}, {"name":"widgets","order":5,"path":"folders/widgets.yy",},
{"name":"custom","order":4,"path":"folders/addons/custom.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",},
@ -288,6 +289,7 @@
{"name":"sh_cell_noise_round","order":9,"path":"shaders/sh_cell_noise_round/sh_cell_noise_round.yy",}, {"name":"sh_cell_noise_round","order":9,"path":"shaders/sh_cell_noise_round/sh_cell_noise_round.yy",},
{"name":"s_node_cross_product_2d","order":12,"path":"sprites/s_node_cross_product_2d/s_node_cross_product_2d.yy",}, {"name":"s_node_cross_product_2d","order":12,"path":"sprites/s_node_cross_product_2d/s_node_cross_product_2d.yy",},
{"name":"s_node_path_plot","order":12,"path":"sprites/s_node_path_plot/s_node_path_plot.yy",}, {"name":"s_node_path_plot","order":12,"path":"sprites/s_node_path_plot/s_node_path_plot.yy",},
{"name":"__initAddon","order":2,"path":"scripts/__initAddon/__initAddon.yy",},
{"name":"json_functions","order":8,"path":"scripts/json_functions/json_functions.yy",}, {"name":"json_functions","order":8,"path":"scripts/json_functions/json_functions.yy",},
{"name":"event_recorder","order":4,"path":"scripts/event_recorder/event_recorder.yy",}, {"name":"event_recorder","order":4,"path":"scripts/event_recorder/event_recorder.yy",},
{"name":"s_node_path_l_system","order":10,"path":"sprites/s_node_path_l_system/s_node_path_l_system.yy",}, {"name":"s_node_path_l_system","order":10,"path":"sprites/s_node_path_l_system/s_node_path_l_system.yy",},
@ -535,6 +537,7 @@
{"name":"__background_get_internal","order":2,"path":"scripts/__background_get_internal/__background_get_internal.yy",}, {"name":"__background_get_internal","order":2,"path":"scripts/__background_get_internal/__background_get_internal.yy",},
{"name":"sh_combine_hsv","order":41,"path":"shaders/sh_combine_hsv/sh_combine_hsv.yy",}, {"name":"sh_combine_hsv","order":41,"path":"shaders/sh_combine_hsv/sh_combine_hsv.yy",},
{"name":"s_node_array_insert","order":4,"path":"sprites/s_node_array_insert/s_node_array_insert.yy",}, {"name":"s_node_array_insert","order":4,"path":"sprites/s_node_array_insert/s_node_array_insert.yy",},
{"name":"addon_lua","order":1,"path":"scripts/addon_lua/addon_lua.yy",},
{"name":"nodeValue_drawer","order":1,"path":"scripts/nodeValue_drawer/nodeValue_drawer.yy",}, {"name":"nodeValue_drawer","order":1,"path":"scripts/nodeValue_drawer/nodeValue_drawer.yy",},
{"name":"node_noise","order":17,"path":"scripts/node_noise/node_noise.yy",}, {"name":"node_noise","order":17,"path":"scripts/node_noise/node_noise.yy",},
{"name":"mtl_reader","order":6,"path":"scripts/mtl_reader/mtl_reader.yy",}, {"name":"mtl_reader","order":6,"path":"scripts/mtl_reader/mtl_reader.yy",},

View File

@ -31,9 +31,9 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"menu","folderPath":"folders/dialog/menu.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"menu","folderPath":"folders/dialog/menu.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"preview","folderPath":"folders/dialog/preview.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"preview","folderPath":"folders/dialog/preview.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"widget","folderPath":"folders/dialog/widget.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"widget","folderPath":"folders/dialog/widget.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"Extensions","folderPath":"folders/Extensions.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"_Extensions","folderPath":"folders/_Extensions.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"Gameframe","folderPath":"folders/Extensions/Gameframe.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"Gameframe","folderPath":"folders/_Extensions/Gameframe.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"MAC","folderPath":"folders/Extensions/MAC.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"MAC","folderPath":"folders/_Extensions/MAC.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"font","folderPath":"folders/font.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"font","folderPath":"folders/font.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"functions","folderPath":"folders/functions.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"functions","folderPath":"folders/functions.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"3d","folderPath":"folders/functions/3d.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"3d","folderPath":"folders/functions/3d.yy",},
@ -179,6 +179,7 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"Steamworks","folderPath":"folders/Steamworks.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"Steamworks","folderPath":"folders/Steamworks.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"UGC","folderPath":"folders/Steamworks/UGC.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"UGC","folderPath":"folders/Steamworks/UGC.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"widgets","folderPath":"folders/widgets.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"widgets","folderPath":"folders/widgets.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"custom","folderPath":"folders/addons/custom.yy",},
], ],
"IncludedFiles": [ "IncludedFiles": [
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ApolloHelp.html","CopyToMask":-1,"filePath":"datafiles",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ApolloHelp.html","CopyToMask":-1,"filePath":"datafiles",},
@ -998,6 +999,7 @@
{"id":{"name":"sh_cell_noise_round","path":"shaders/sh_cell_noise_round/sh_cell_noise_round.yy",},}, {"id":{"name":"sh_cell_noise_round","path":"shaders/sh_cell_noise_round/sh_cell_noise_round.yy",},},
{"id":{"name":"s_node_cross_product_2d","path":"sprites/s_node_cross_product_2d/s_node_cross_product_2d.yy",},}, {"id":{"name":"s_node_cross_product_2d","path":"sprites/s_node_cross_product_2d/s_node_cross_product_2d.yy",},},
{"id":{"name":"s_node_path_plot","path":"sprites/s_node_path_plot/s_node_path_plot.yy",},}, {"id":{"name":"s_node_path_plot","path":"sprites/s_node_path_plot/s_node_path_plot.yy",},},
{"id":{"name":"__initAddon","path":"scripts/__initAddon/__initAddon.yy",},},
{"id":{"name":"json_functions","path":"scripts/json_functions/json_functions.yy",},}, {"id":{"name":"json_functions","path":"scripts/json_functions/json_functions.yy",},},
{"id":{"name":"event_recorder","path":"scripts/event_recorder/event_recorder.yy",},}, {"id":{"name":"event_recorder","path":"scripts/event_recorder/event_recorder.yy",},},
{"id":{"name":"s_node_path_l_system","path":"sprites/s_node_path_l_system/s_node_path_l_system.yy",},}, {"id":{"name":"s_node_path_l_system","path":"sprites/s_node_path_l_system/s_node_path_l_system.yy",},},
@ -1278,6 +1280,7 @@
{"id":{"name":"__background_get_internal","path":"scripts/__background_get_internal/__background_get_internal.yy",},}, {"id":{"name":"__background_get_internal","path":"scripts/__background_get_internal/__background_get_internal.yy",},},
{"id":{"name":"sh_combine_hsv","path":"shaders/sh_combine_hsv/sh_combine_hsv.yy",},}, {"id":{"name":"sh_combine_hsv","path":"shaders/sh_combine_hsv/sh_combine_hsv.yy",},},
{"id":{"name":"s_node_array_insert","path":"sprites/s_node_array_insert/s_node_array_insert.yy",},}, {"id":{"name":"s_node_array_insert","path":"sprites/s_node_array_insert/s_node_array_insert.yy",},},
{"id":{"name":"addon_lua","path":"scripts/addon_lua/addon_lua.yy",},},
{"id":{"name":"nodeValue_drawer","path":"scripts/nodeValue_drawer/nodeValue_drawer.yy",},}, {"id":{"name":"nodeValue_drawer","path":"scripts/nodeValue_drawer/nodeValue_drawer.yy",},},
{"id":{"name":"node_noise","path":"scripts/node_noise/node_noise.yy",},}, {"id":{"name":"node_noise","path":"scripts/node_noise/node_noise.yy",},},
{"id":{"name":"mtl_reader","path":"scripts/mtl_reader/mtl_reader.yy",},}, {"id":{"name":"mtl_reader","path":"scripts/mtl_reader/mtl_reader.yy",},},
@ -1891,6 +1894,7 @@
{"id":{"name":"s_node_regex_replace","path":"sprites/s_node_regex_replace/s_node_regex_replace.yy",},}, {"id":{"name":"s_node_regex_replace","path":"sprites/s_node_regex_replace/s_node_regex_replace.yy",},},
{"id":{"name":"paddingBox","path":"scripts/paddingBox/paddingBox.yy",},}, {"id":{"name":"paddingBox","path":"scripts/paddingBox/paddingBox.yy",},},
{"id":{"name":"fd_rectangle_set_visualization_shader","path":"scripts/fd_rectangle_set_visualization_shader/fd_rectangle_set_visualization_shader.yy",},}, {"id":{"name":"fd_rectangle_set_visualization_shader","path":"scripts/fd_rectangle_set_visualization_shader/fd_rectangle_set_visualization_shader.yy",},},
{"id":{"name":"addonPanel","path":"scripts/addonPanel/addonPanel.yy",},},
{"id":{"name":"s_node_ase_layer","path":"sprites/s_node_ase_layer/s_node_ase_layer.yy",},}, {"id":{"name":"s_node_ase_layer","path":"sprites/s_node_ase_layer/s_node_ase_layer.yy",},},
{"id":{"name":"_f_p1","path":"fonts/_f_p1/_f_p1.yy",},}, {"id":{"name":"_f_p1","path":"fonts/_f_p1/_f_p1.yy",},},
{"id":{"name":"tuple_functions","path":"scripts/tuple_functions/tuple_functions.yy",},}, {"id":{"name":"tuple_functions","path":"scripts/tuple_functions/tuple_functions.yy",},},

View File

@ -34,6 +34,8 @@ if !ready exit;
gpu_set_blendmode(bm_normal); gpu_set_blendmode(bm_normal);
surface_reset_target(); surface_reset_target();
content.drawGUI();
draw_surface(panel, cx, cy); draw_surface(panel, cx, cy);
} }
#endregion #endregion

View File

@ -20,13 +20,13 @@ event_inherited();
if(!ds_map_exists(global.PRESETS_MAP, folder)) return 0; if(!ds_map_exists(global.PRESETS_MAP, folder)) return 0;
var pres = global.PRESETS_MAP[? folder]; var pres = global.PRESETS_MAP[? folder];
var amo = array_length(pres); var amo = array_length(pres);
var hh = line_height() + ui(8); var hh = line_height() + ui(8);
var _h = amo * hh; var _h = amo * (hh + ui(4)) + ui(32);
for( var i = 0; i < amo; i++ ) { for( var i = 0; i < amo; i++ ) {
var preset = pres[i]; var preset = pres[i];
var _yy = _y + hh * i; var _yy = _y + (hh + ui(4)) * i;
if(sHOVER && sc_presets.hover && point_in_rectangle(_m[0], _m[1], 0, _yy, sc_presets.w, _yy + hh)) { if(sHOVER && sc_presets.hover && point_in_rectangle(_m[0], _m[1], 0, _yy, sc_presets.w, _yy + hh)) {
draw_sprite_stretched(THEME.node_bg, 0, 0, _yy, sc_presets.w - ui(12), hh); draw_sprite_stretched(THEME.node_bg, 0, 0, _yy, sc_presets.w - ui(12), hh);

View File

@ -71,6 +71,7 @@
__initNodeData(); __initNodeData();
__initNodes(); __initNodes();
__initSteamUGC(); __initSteamUGC();
__initAddon();
PREF_APPLY(); PREF_APPLY();
loadFonts(); loadFonts();

View File

@ -0,0 +1,16 @@
function __initAddon() {
var dirPath = DIRECTORY + "Addons";
globalvar ADDONS;
ADDONS = [];
if(!directory_exists(dirPath)) {
directory_create(dirPath);
return;
}
var f = file_find_first(dirPath + "\\*", fa_directory);
while(f != "") {
array_push(ADDONS, f);
f = file_find_next();
}
}

View File

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

View File

@ -0,0 +1,60 @@
function addonPanel(directory) : PanelContent() constructor {
thread = lua_create();
lua_error_handler = _lua_error;
__addon_lua_setup(thread);
self.directory = directory;
title = filename_name_only(directory);
showHeader = true;
var propPath = directory + "\\meta.json";
if(file_exists(propPath)) {
var meta = json_load_struct(propPath);
w = meta[$ "w"];
h = meta[$ "h"];
}
icon = THEME.addon;
var iconPath = directory + "\\icon.png";
if(file_exists(iconPath)) {
icon = sprite_add(iconPath, 0, false, false, 0, 0);
sprite_set_offset(icon, sprite_get_width(icon) / 2, sprite_get_height(icon) / 2);
}
scriptPath = directory + "\\script.lua";
if(!file_exists(scriptPath)) {
noti_warning(title + " Addon error: script.lua not found.");
return self;
}
static init = function() {
lua_add_file(thread, scriptPath);
var runResult = lua_call(thread, "init");
}
init();
function stepBegin() {
var runResult = lua_call(thread, "step");
}
function drawGUI() {
var runResult = lua_call(thread, "drawUI");
}
//
function onResize() {
}
function drawContent(panel) {
var runResult = lua_call(thread, "draw");
}
//
static cleanUp = function() {
lua_state_destroy(thread);
}
}

View File

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

View File

@ -0,0 +1,30 @@
#region
global.__lua_functions = [
[ "print", print ],
[ "draw_sprite", draw_sprite ],
[ "draw_sprite_ext", draw_sprite_ext ],
[ "draw_sprite_stretched", draw_sprite_stretched ],
[ "draw_sprite_stretched_ext", draw_sprite_stretched_ext ],
[ "draw_surface", draw_surface ],
[ "draw_surface_ext", draw_surface_ext ],
[ "draw_surface_stretched", draw_surface_stretched ],
[ "draw_surface_stretched_ext", draw_surface_stretched_ext ],
[ "draw_set_color", draw_set_color ],
[ "draw_set_alpha", draw_set_alpha ],
[ "draw_circle", draw_circle ],
[ "draw_rectangle", draw_rectangle ],
[ "draw_line", draw_line ],
[ "draw_line_width", draw_line_width ],
];
#endregion
function __addon_lua_setup(lua) {
for( var i = 0; i < array_length(global.__lua_functions); i++ ) {
var _func = global.__lua_functions[i];
lua_add_function(lua, _func[0], _func[1]);
}
}

View File

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

View File

@ -6,6 +6,6 @@
"isDnD": false, "isDnD": false,
"parent": { "parent": {
"name": "Gameframe", "name": "Gameframe",
"path": "folders/Extensions/Gameframe.yy", "path": "folders/_Extensions/Gameframe.yy",
}, },
} }

View File

@ -6,6 +6,6 @@
"isDnD": false, "isDnD": false,
"parent": { "parent": {
"name": "Gameframe", "name": "Gameframe",
"path": "folders/Extensions/Gameframe.yy", "path": "folders/_Extensions/Gameframe.yy",
}, },
} }

View File

@ -34,7 +34,7 @@
globalvar COLLECTION_VERSION, THEME_VERSION; globalvar COLLECTION_VERSION, THEME_VERSION;
VERSION = 1142; VERSION = 1142;
SAVEFILE_VERSION = 1400; SAVEFILE_VERSION = 1420;
COLLECTION_VERSION = 1140.090; COLLECTION_VERSION = 1140.090;
THEME_VERSION = 1140.090; THEME_VERSION = 1140.090;
VERSION_STRING = "1.14.2"; VERSION_STRING = "1.14.2";

View File

@ -136,11 +136,28 @@ function gradientObject(color = c_black) constructor {
} }
static serialize = function() { static serialize = function() {
return json_stringify(self); return json_stringify(self, false);
} }
static deserialize = function(str) { static deserialize = function(str) {
var s = json_try_parse(str); var s;
if(is_string(str))
s = json_try_parse(str);
else if(is_struct(str))
s = str;
else if(ds_exists(str, ds_type_list)) {
keys = [];
for( var i = 0; i < ds_list_size(str); i++ ) {
if(!ds_exists(str[| i], ds_type_map)) continue;
keys[i] = new gradientKey(str[| i][? "time"], str[| i][? "value"]);
}
return self;
}
type = s.type; type = s.type;
keys = []; keys = [];
for( var i = 0; i < array_length(s.keys); i++ ) for( var i = 0; i < array_length(s.keys); i++ )

View File

@ -1270,6 +1270,13 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
doDeserialize(); doDeserialize();
processDeserialize(); processDeserialize();
if(preset) {
postDeserialize();
applyDeserialize();
triggerRender();
}
} }
static doDeserialize = function() {} static doDeserialize = function() {}

View File

@ -86,10 +86,10 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
if(array_length(points) < 2) continue; if(array_length(points) < 2) continue;
for( var j = 1; j < array_length(points); j++ ) { for( var j = 1; j < array_length(points); j++ ) {
var x0 = points[j - 1][0]; var x0 = points[j - 1].x;
var y0 = points[j - 1][1]; var y0 = points[j - 1].y;
var x1 = points[j][0]; var x1 = points[j].x;
var y1 = points[j][1]; var y1 = points[j].y;
x0 = _x + x0 * _s; x0 = _x + x0 * _s;
y0 = _y + y0 * _s; y0 = _y + y0 * _s;
@ -176,7 +176,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth()); _outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
var _ox, _nx, _nx1, _oy, _ny, _ny1; var _ox, _nx, _nx1, _oy, _ny, _ny1;
var _ow, _nw, _oa, _na, _oc, _nc; var _ow, _nw, _oa, _na, _oc, _nc, _owg, _nwg;
lines = []; lines = [];
if(_use_path) { if(_use_path) {
@ -208,7 +208,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
var _prog = _prog_curr + 1; //Record previous position to delete from _total var _prog = _prog_curr + 1; //Record previous position to delete from _total
var _prog_total = 0; //Record how far the pointer have moved so far var _prog_total = 0; //Record how far the pointer have moved so far
var points = []; var points = [];
var p; var p, wght;
if(_useDistance) { if(_useDistance) {
_pathStr *= _pathLength; _pathStr *= _pathLength;
@ -237,11 +237,19 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
_prog_next = min(_prog_curr + _stepLen, 1); //Move forward _stepLen or _total (if less) stop at 1 _prog_next = min(_prog_curr + _stepLen, 1); //Move forward _stepLen or _total (if less) stop at 1
} }
if(_useDistance) wght = 1;
if(_useDistance) {
p = _pat.getPointDistance(_prog_curr, i); p = _pat.getPointDistance(_prog_curr, i);
else if(!_useDistance)
if(struct_has(_pat, "getWeightRatio"))
wght = _pat.getWeightRatio(_prog_curr, i);
} else if(!_useDistance) {
p = _pat.getPointRatio(_prog_curr, i); p = _pat.getPointRatio(_prog_curr, i);
if(struct_has(_pat, "getWeightDistance"))
wght = _pat.getWeightDistance(_prog_curr, i);
}
_nx = p.x; _nx = p.x;
_ny = p.y; _ny = p.y;
@ -251,9 +259,8 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
_ny += lengthdir_y(random1D(_sed + _sedIndex, -_wig, _wig), _d + 90); _sedIndex++; _ny += lengthdir_y(random1D(_sed + _sedIndex, -_wig, _wig), _d + 90); _sedIndex++;
} }
if(_prog_total >= _pathStr) { //Do not add point before range start. Do this instead of starting at _rtStr to prevent wiggle. if(_prog_total >= _pathStr) //Do not add point before range start. Do this instead of starting at _rtStr to prevent wiggle.
array_push(points, [ _nx, _ny, _prog_total / _pathEnd, _prog_curr / _pathLength ]); array_push(points, { x: _nx, y: _ny, prog: _prog_total / _pathEnd, progCrop: _prog_curr / _pathLength, weight: wght });
}
if(_prog_next > _prog_curr) { if(_prog_next > _prog_curr) {
_prog_total += _prog_next - _prog_curr; _prog_total += _prog_next - _prog_curr;
@ -302,7 +309,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
_ny += lengthdir_y(wgLen, _d + 90); _ny += lengthdir_y(wgLen, _d + 90);
if(_prog_total > _rtStr) //prevent drawing point before range start. if(_prog_total > _rtStr) //prevent drawing point before range start.
array_push(points, [_nx, _ny, _prog_total / _rtMax, _prog_curr]); array_push(points, { x: _nx, y: _ny, prog: _prog_total / _rtMax, progCrop: _prog_curr, weight: 1 });
if(_prog_curr > _prog) if(_prog_curr > _prog)
_total -= (_prog_curr - _prog); _total -= (_prog_curr - _prog);
@ -338,10 +345,10 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
for( var j = 0; j < array_length(points); j++ ) { for( var j = 0; j < array_length(points); j++ ) {
var p0 = points[j]; var p0 = points[j];
var _nx = p0[0]; var _nx = p0.x;
var _ny = p0[1]; var _ny = p0.y;
var prog = p0[2]; var prog = p0.prog;
var prgc = p0[3]; var prgc = p0.progCrop;
if(_1px) { if(_1px) {
_nx = _nx - 0.5; _nx = _nx - 0.5;
@ -350,6 +357,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
_nw = random_range(_wid[0], _wid[1]); _nw = random_range(_wid[0], _wid[1]);
_nw *= eval_curve_x(_widc, _widap? prog : prgc); _nw *= eval_curve_x(_widc, _widap? prog : prgc);
_nw *= p0.weight;
_nc = _color.eval(_colP? prog : prgc); _nc = _color.eval(_colP? prog : prgc);
@ -391,8 +399,8 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
if(j < array_length(points) - 1) { if(j < array_length(points) - 1) {
var p2 = points[j + 1]; var p2 = points[j + 1];
var _nnx = p2[0]; var _nnx = p2.x;
var _nny = p2[1]; var _nny = p2.y;
_nd1 = point_direction(_nx, _ny, _nnx, _nny); _nd1 = point_direction(_nx, _ny, _nnx, _nny);
_nd = _nd0 + angle_difference(_nd1, _nd0) / 2; _nd = _nd0 + angle_difference(_nd1, _nd0) / 2;
@ -420,7 +428,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
draw_line_width2_angle(_ox, _oy, _nx, _ny, _ow, _nw, _od + 90, _nd + 90, _oc, _nc, _colW); draw_line_width2_angle(_ox, _oy, _nx, _ny, _ow, _nw, _od + 90, _nd + 90, _oc, _nc, _colW);
} else { } else {
var p1 = points[j + 1]; var p1 = points[j + 1];
_nd = point_direction(_nx, _ny, p1[0], p1[1]); _nd = point_direction(_nx, _ny, p1.x, p1.y);
} }
_ox = _nx; _ox = _nx;

View File

@ -184,7 +184,7 @@ function Node_Lua_Compute(_x, _y, _group = noone) : Node(_x, _y, _group) constru
lua_projectData(getState()); lua_projectData(getState());
var res = 0; var res = 0;
try res = lua_call_w(getState(), _func, argument_val); try res = lua_call_w(getState(), _func, argument_val);
catch(e) noti_warning(exception_print(e),, self); catch(e) noti_warning(exception_print(e),, self);
outputs[| 1].setValue(res); outputs[| 1].setValue(res);

View File

@ -1,10 +1,12 @@
function L_Turtle(x = 0, y = 0, ang = 90) constructor { function L_Turtle(x = 0, y = 0, ang = 90, w = 1, color = c_white) constructor {
self.x = x; self.x = x;
self.y = y; self.y = y;
self.ang = ang; self.ang = ang;
self.w = w;
self.color = color;
static clone = function() { static clone = function() {
return new L_Turtle(x, y, ang); return new L_Turtle(x, y, ang, w, color);
} }
} }
@ -121,9 +123,9 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node(_x, _y, _group) const
inputs[| 2].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); inputs[| 2].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
draw_set_color(COLORS._main_accent); draw_set_color(COLORS._main_accent);
for( var i = 0; i < array_length(lines); i += 2 ) { for( var i = 0; i < array_length(lines); i++ ) {
var p0 = lines[i + 0]; var p0 = lines[i][0];
var p1 = lines[i + 1]; var p1 = lines[i][1];
var x0 = p0[0]; var x0 = p0[0];
var y0 = p0[1]; var y0 = p0[1];
@ -141,18 +143,32 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node(_x, _y, _group) const
static getBoundary = function() { return boundary; } static getBoundary = function() { return boundary; }
static getLineCount = function() { return floor(array_length(lines) / 2); } static getLineCount = function() { return array_length(lines); }
static getSegmentCount = function() { return 1; } static getSegmentCount = function() { return 1; }
static getLength = function() { return current_length; } static getLength = function() { return current_length; }
static getAccuLength = function() { return [ 0, current_length ]; } static getAccuLength = function() { return [ 0, current_length ]; }
static getPointDistance = function(_dist, ind = 0) { static getWeightDistance = function (_dist, _ind = 0) {
return getPointRatio(_dist / current_length, ind); return getWeightRatio(_dist / current_length, _ind);
}
static getWeightRatio = function (_rat, _ind = 0) {
var _p0 = lines[_ind][0];
var _p1 = lines[_ind][1];
if(!is_array(_p0) || array_length(_p0) < 2) return 1;
if(!is_array(_p1) || array_length(_p1) < 2) return 1;
return lerp(_p0[2], _p1[2], _rat);
}
static getPointDistance = function(_dist, _ind = 0) {
return getPointRatio(_dist / current_length, _ind);
} }
static getPointRatio = function(_rat, _ind = 0) { static getPointRatio = function(_rat, _ind = 0) {
var _p0 = array_safe_get(lines, _ind * 2 + 0,, ARRAY_OVERFLOW._default); var _p0 = lines[_ind][0];
var _p1 = array_safe_get(lines, _ind * 2 + 1,, ARRAY_OVERFLOW._default); var _p1 = lines[_ind][1];
if(!is_array(_p0) || array_length(_p0) < 2) return new Point(); if(!is_array(_p0) || array_length(_p0) < 2) return new Point();
if(!is_array(_p1) || array_length(_p1) < 2) return new Point(); if(!is_array(_p1) || array_length(_p1) < 2) return new Point();
@ -226,7 +242,7 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node(_x, _y, _group) const
var nx = t.x + lengthdir_x(_len, t.ang); var nx = t.x + lengthdir_x(_len, t.ang);
var ny = t.y + lengthdir_y(_len, t.ang); var ny = t.y + lengthdir_y(_len, t.ang);
array_push(lines, [t.x, t.y], [nx, ny]); array_push(lines, [ [t.x, t.y, t.w], [nx, ny, t.w] ]);
t.x = nx; t.x = nx;
t.y = ny; t.y = ny;
@ -239,7 +255,7 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node(_x, _y, _group) const
var nx = t.x + lengthdir_x(_len * frac(_itr), t.ang); var nx = t.x + lengthdir_x(_len * frac(_itr), t.ang);
var ny = t.y + lengthdir_y(_len * frac(_itr), t.ang); var ny = t.y + lengthdir_y(_len * frac(_itr), t.ang);
array_push(lines, [t.x, t.y], [nx, ny]); array_push(lines, [ [t.x, t.y, t.w], [nx, ny, t.w] ]);
t.x = nx; t.x = nx;
t.y = ny; t.y = ny;
@ -249,6 +265,9 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node(_x, _y, _group) const
case "|": t.ang += 180; break; case "|": t.ang += 180; break;
case "[": ds_stack_push(st, t.clone()); break; case "[": ds_stack_push(st, t.clone()); break;
case "]": t = ds_stack_pop(st); break; case "]": t = ds_stack_pop(st); break;
case ">": t.w += 0.1; break;
case "<": t.w -= 0.1; break;
} }
} }
@ -256,7 +275,7 @@ function Node_Path_L_System(_x, _y, _group = noone) : Node(_x, _y, _group) const
boundary = new BoundingBox(); boundary = new BoundingBox();
for( var i = 0; i < array_length(lines); i++ ) for( var i = 0; i < array_length(lines); i++ )
boundary.addPoint(lines[i][0], lines[i][1]); boundary.addPoint(lines[i][0][0], lines[i][0][1], lines[i][1][0], lines[i][1][1]);
outputs[| 0].setValue(self); outputs[| 0].setValue(self);
} }

View File

@ -32,7 +32,7 @@ function Panel_Menu() : PanelContent() constructor {
menuItem(get_text("panel_menu_splash_screen", "Splash screen"), function() { dialogCall(o_dialog_splash); }), menuItem(get_text("panel_menu_splash_screen", "Splash screen"), function() { dialogCall(o_dialog_splash); }),
-1, -1,
menuItem(get_text("panel_menu_addons", "Addons"), function(_x, _y, _depth) { menuItem(get_text("panel_menu_addons", "Addons"), function(_x, _y, _depth) {
return submenuCall(_x, _y, _depth, [ var arr = [
menuItem(get_text("panel_menu_addons_key", "Key displayer"), function() { menuItem(get_text("panel_menu_addons_key", "Key displayer"), function() {
if(instance_exists(addon_key_displayer)) { if(instance_exists(addon_key_displayer)) {
instance_destroy(addon_key_displayer); instance_destroy(addon_key_displayer);
@ -41,7 +41,19 @@ function Panel_Menu() : PanelContent() constructor {
instance_create_depth(0, 0, 0, addon_key_displayer); instance_create_depth(0, 0, 0, addon_key_displayer);
}), }),
]); -1
];
for( var i = 0; i < array_length(ADDONS); i++ ) {
var _dir = ADDONS[i];
array_push(arr, menuItem(_dir, function(_x, _y, _depth, _path) {
var addonPath = DIRECTORY + "Addons\\" + _path;
dialogPanelCall(new addonPanel(addonPath));
} ));
}
return submenuCall(_x, _y, _depth, arr);
}, THEME.addon ).setIsShelf(), }, THEME.addon ).setIsShelf(),
-1, -1,
menuItem(get_text("fullscreen", "Toggle fullscreen"), function() { menuItem(get_text("fullscreen", "Toggle fullscreen"), function() {

View File

@ -409,7 +409,7 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod
if(self == WIDGET_CURRENT) { if(self == WIDGET_CURRENT) {
draw_set_text(font, fa_left, fa_top, COLORS._main_text); draw_set_text(font, fa_left, fa_top, COLORS._main_text);
draw_sprite_stretched_ext(THEME.textbox, 2, _x, _y, _w, hh, boxColor, 1); draw_sprite_stretched_ext(THEME.textbox, 2, _x, _y, _w, hh, COLORS._main_accent, 1);
editText(); editText();
#region cursor #region cursor