Controller mapper

This commit is contained in:
Tanasart 2023-05-07 20:55:13 +02:00
parent 35db049a89
commit ab82009078
49 changed files with 633 additions and 399 deletions

View file

@ -386,7 +386,7 @@
{"name":"spr_gameframe_caption","order":2,"path":"sprites/spr_gameframe_caption/spr_gameframe_caption.yy",},
{"name":"o_dialog_splash","order":9,"path":"objects/o_dialog_splash/o_dialog_splash.yy",},
{"name":"json_file","order":4,"path":"scripts/json_file/json_file.yy",},
{"name":"_addon_custom","order":5,"path":"objects/_addon_custom/_addon_custom.yy",},
{"name":"_addon_custom","order":4,"path":"objects/_addon_custom/_addon_custom.yy",},
{"name":"s_node_3d_export","order":10,"path":"sprites/s_node_3d_export/s_node_3d_export.yy",},
{"name":"s_node_curve_edit","order":1,"path":"sprites/s_node_curve_edit/s_node_curve_edit.yy",},
{"name":"textBox","order":17,"path":"scripts/textBox/textBox.yy",},
@ -554,6 +554,7 @@
{"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":"s_node_3d_array","order":7,"path":"sprites/s_node_3d_array/s_node_3d_array.yy",},
{"name":"addon_lua_constant","order":5,"path":"scripts/addon_lua_constant/addon_lua_constant.yy",},
{"name":"sh_fd_velocity_combine","order":21,"path":"shaders/sh_fd_velocity_combine/sh_fd_velocity_combine.yy",},
{"name":"sh_scale2x","order":27,"path":"shaders/sh_scale2x/sh_scale2x.yy",},
{"name":"ds_priority","order":3,"path":"scripts/ds_priority/ds_priority.yy",},

View file

@ -501,6 +501,7 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_action_history.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_add_24.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_add_32.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_addon_setting.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_addon.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_animate_clock_strip3.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_animate_node_go.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
@ -511,6 +512,7 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_button_path_icon.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_button_path_not_found_icon.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_cache.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_checkbox_on_start.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_circle_12.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_circle_16.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_color_picker_dropper.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
@ -1307,6 +1309,7 @@
{"id":{"name":"node_noise","path":"scripts/node_noise/node_noise.yy",},},
{"id":{"name":"mtl_reader","path":"scripts/mtl_reader/mtl_reader.yy",},},
{"id":{"name":"s_node_3d_array","path":"sprites/s_node_3d_array/s_node_3d_array.yy",},},
{"id":{"name":"addon_lua_constant","path":"scripts/addon_lua_constant/addon_lua_constant.yy",},},
{"id":{"name":"sh_fd_velocity_combine","path":"shaders/sh_fd_velocity_combine/sh_fd_velocity_combine.yy",},},
{"id":{"name":"sh_scale2x","path":"shaders/sh_scale2x/sh_scale2x.yy",},},
{"id":{"name":"ds_priority","path":"scripts/ds_priority/ds_priority.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

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.

View file

@ -2,7 +2,7 @@
event_inherited();
#region init
function init(directory) {
function init(directory, _openDialog = true) {
ID = UUID_generate();
global.ADDON_ID[? ID] = self;
ready = false;
@ -22,15 +22,15 @@ event_inherited();
var meta = json_load_struct(propPath);
if(struct_has(meta, "panels")) {
panels = meta.panels;
var arr = variable_struct_get_names(meta.panels);
for( var i = 0; i < array_length(arr); i++ ) {
var _key = arr[i];
var pane = meta.panels[$ _key];
if(_openDialog) {
var arr = variable_struct_get_names(panels);
for( var i = 0; i < array_length(arr); i++ ) {
var _key = arr[i];
var pane = panels[$ _key];
if(pane.create) {
var panel = new addonPanel(self, pane, pane.drawFn, struct_has(pane, "drawFn")? pane.drawUIFn : "");
dialogPanelCall(panel);
if(struct_has(pane, "main") && pane.main)
dialogPanelCall(new addonPanel(self, pane));
}
}
}

View file

@ -11,8 +11,8 @@
"managed": true,
"overriddenProperties": [],
"parent": {
"name": "addons",
"path": "folders/addons.yy",
"name": "custom",
"path": "folders/addons/custom.yy",
},
"parentObjectId": {
"name": "addon",

View file

@ -45,6 +45,7 @@ if(!ready) exit;
if(instanceof(_menuItem) == "MenuItem" && sFOCUS && (mouse_release(mb_left) || keyboard_check_released(vk_enter))) {
var _dat = {
_x: dialog_x,
x: dialog_x + dialog_w,
y: yy,
depth: depth,

View file

@ -137,20 +137,24 @@ event_inherited();
draw_sprite_stretched(THEME.node_bg, 0, _boxx, yy, grid_width, grid_heigh);
if(sHOVER && sp_sample.hover && point_in_rectangle(_m[0], _m[1], _nx, yy, _nx + grid_width, yy + grid_heigh)) {
var _meta = _project.getMetadata();
if(project_page == 1)
TOOLTIP = _meta;
draw_sprite_stretched_ext(THEME.node_active, 0, _boxx, yy, grid_width, grid_heigh, COLORS._main_accent, 1);
if(mouse_press(mb_left, sFOCUS)) {
LOAD_PATH(_project.path, true);
METADATA.steam = project_page;
if(project_page == 1)
METADATA.file_id = _project.getMetadata().file_id;
METADATA.file_id = _meta.file_id;
instance_destroy();
}
}
var spr = _project.getSpr();
if(spr) {
var gw = grid_width - ui(4);
var gh = grid_heigh - ui(4);
var gw = grid_width - ui(16);
var gh = grid_heigh - ui(16);
var sw = sprite_get_width(spr);
var sh = sprite_get_height(spr);

View file

@ -74,8 +74,10 @@ if !ready exit;
bx = x0;
for( var i = 0; i < array_length(pages); i++ ) {
draw_set_text(f_p0, fa_left, fa_bottom, COLORS._main_text_sub);
var tw = string_width(pages[i]) + ui(16);
draw_set_text(f_p0, fa_left, fa_bottom, project_page == i? COLORS._main_text : COLORS._main_text_sub);
var list = i == 1? STEAM_PROJECTS : SAMPLE_PROJECTS;
var amo = ds_list_size(list);
var tw = ui(16) + string_width(pages[i]) + ui(8) + string_width(amo) + ui(8);
if(project_page == i)
draw_sprite_stretched(THEME.ui_panel_bg, 0, bx, y0 - ui(32), tw, ui(40));
@ -86,7 +88,15 @@ if !ready exit;
project_page = i;
}
draw_text(bx + ui(8), y0 - ui(4), pages[i]);
var _btx = bx + ui(8);
draw_text(_btx, y0 - ui(4), pages[i]);
_btx += ui(8) + string_width(pages[i]);
draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, _btx, y0 - ui(26), string_width(amo) + ui(8), ui(24), COLORS._main_icon, 0.5);
_btx += ui(4);
draw_set_color(COLORS._main_text_sub);
draw_text(_btx, y0 - ui(4), amo);
bx += tw;
}

View file

@ -51,6 +51,7 @@
#endregion
#region Set up
var t = current_time;
PREF_LOAD();
log_clear();
@ -60,18 +61,18 @@
//window_set_showborder(false);
log_message("SESSION", "SurfaceFormat"); __initSurfaceFormat();
log_message("SESSION", "Locale"); __initLocale();
log_message("SESSION", "Theme"); __initTheme();
log_message("SESSION", "Collection"); __initCollection();
log_message("SESSION", "Assets"); __initAssets();
log_message("SESSION", "Presets"); __initPresets();
log_message("SESSION", "FontFolder"); __initFontFolder();
log_message("SESSION", "Lua"); __initLua();
log_message("SESSION", "NodeData"); __initNodeData();
log_message("SESSION", "Nodes"); __initNodes();
log_message("SESSION", "SteamUGC"); __initSteamUGC();
log_message("SESSION", "Addon"); __initAddon();
log_message("SESSION", "> init SurfaceFormat"); __initSurfaceFormat();
log_message("SESSION", "> init Locale"); __initLocale();
log_message("SESSION", "> init Theme"); __initTheme();
log_message("SESSION", "> init Collection"); __initCollection();
log_message("SESSION", "> init Assets"); __initAssets();
log_message("SESSION", "> init Presets"); __initPresets();
log_message("SESSION", "> init FontFolder"); __initFontFolder();
log_message("SESSION", "> init Lua"); __initLua();
log_message("SESSION", "> init NodeData"); __initNodeData();
log_message("SESSION", "> init Nodes"); __initNodes();
log_message("SESSION", "> init SteamUGC"); __initSteamUGC();
log_message("SESSION", "> init Addon"); __initAddon();
PREF_APPLY();
loadFonts();
@ -79,6 +80,7 @@
loadColor(PREF_MAP[? "theme"]);
setPanel();
loadAddon();
if(file_exists("icon.png"))
file_copy("icon.png", DIRECTORY + "icon.png");
@ -90,6 +92,8 @@
var cmd = ".pxcc=\"" + string(program_directory) + "PixelComposer.exe\"";
execute_shell("assoc", cmd);
print($"Setup time = {current_time - t}");
#endregion
#region parameter

View file

@ -1,7 +1,8 @@
function __initAddon() {
function __initAddon() {
var dirPath = DIRECTORY + "Addons";
globalvar ADDONS;
globalvar ADDONS, ADDONS_ON_START;
ADDONS = [];
ADDONS_ON_START = [];
if(!directory_exists(dirPath)) {
directory_create(dirPath);
@ -9,11 +10,18 @@ function __initAddon() {
}
var f = file_find_first(dirPath + "\\*", fa_directory);
while(f != "") {
var _f = "";
while(f != "" && f != _f) {
_f = f;
var _path = dirPath + "\\" + f;
var _meta = _path + "\\meta.json";
if(!file_exists(_meta)) continue;
if(!file_exists(_meta)) {
f = file_find_next();
continue;
}
var _mSrt = json_load_struct(_meta);
var _str = {
name: f,
@ -26,4 +34,15 @@ function __initAddon() {
array_push(ADDONS, _str);
f = file_find_next();
}
file_find_close();
}
function loadAddon() {
var _path = DIRECTORY + "Addons\\__init.json";
if(!file_exists(_path)) return;
ADDONS_ON_START = json_load_struct(_path);
for( var i = 0; i < array_length(ADDONS_ON_START); i++ )
addonTrigger(ADDONS_ON_START[i], false);
}

View file

@ -1,12 +1,14 @@
global.ADDON_WIDGET = ds_map_create();
global.ADDON_ID = ds_map_create();
function addonPanel(_addon, pane, _callFn, _callUIFn = "") : PanelContent() constructor {
function addonPanel(_addon, pane) : PanelContent() constructor {
ID = UUID_generate();
self._addon = _addon;
self.pane = pane;
callFn = _callFn;
callUIFn = _callUIFn;
self.pane = pane;
drawFn = struct_has(pane, "drawFn")? pane.drawFn : "";
drawUIFn = struct_has(pane, "drawUIFn")? pane.drawUIFn : "";
closeFn = struct_has(pane, "closeFn")? pane.closeFn : "";
title = filename_name_only(_addon.directory);
__addon_lua_panel_variable(_addon.thread, self);
@ -17,10 +19,10 @@ function addonPanel(_addon, pane, _callFn, _callUIFn = "") : PanelContent() cons
h = pane.h;
function drawGUI() {
if(callUIFn == "") return;
if(drawUIFn == "") return;
if(!_addon.ready) return;
lua_add_code(_addon.thread, "panelID = '" + string(ID) + "'");
var runResult = lua_call(_addon.thread, callUIFn);
var runResult = lua_call(_addon.thread, drawUIFn);
}
function onResize() {
@ -28,13 +30,16 @@ function addonPanel(_addon, pane, _callFn, _callUIFn = "") : PanelContent() cons
}
function drawContent(panel) {
if(drawFn == "") return;
if(!_addon.ready) return;
lua_add_code(_addon.thread, "panelID = '" + string(ID) + "'");
__addon_lua_panel_variable(_addon.thread, self);
var runResult = lua_call(_addon.thread, callFn);
var runResult = lua_call(_addon.thread, drawFn);
}
function onClose() {
if(closeFn == "") return;
if(!_addon.ready) return;
var runResult = lua_call(_addon.thread, closeFn);
}
}

View file

@ -11,9 +11,20 @@ function addonContextGenerator(_addon, _function) constructor {
if(_item == -1)
array_push(arr, -1);
else {
var _addonItem = new addonContextItem(_addon, _item.name, _item.callback);
array_push(arr, _addonItem.menu_item);
}
if(struct_has(_item, "callback")) {
var _addonItem = new addonContextItem(_addon, _item.name, _item.callback);
array_push(arr, _addonItem.menu_item);
} else if(struct_has(_item, "content")) {
var _subArr = []
for( var j = 0; j < array_length(_item.content); j++ ) {
var _addonItem = new addonContextItem(_addon, _item.content[j].name, _item.content[j].callback);
array_push(_subArr, _addonItem.menu_item);
}
var _addonItem = new addonContextSubMenu(_item.name, _subArr);
array_push(arr, _addonItem.menu_item);
}
}
}
return arr;
@ -25,11 +36,22 @@ function addonContextItem(_addon, _name, _function) constructor {
self._name = _name;
self._function = _function;
menu_item = menuItem(_name, function() { lua_call(_addon.thread, self._function); })
.setColor(COLORS._main_accent);
menu_item = menuItem(_name, function(_data) {
lua_call(_addon.thread, self._function, lua_byref(_data.context, true));
}).setColor(COLORS._main_accent);
}
function addonTrigger(_addon) {
function addonContextSubMenu(_name, _content) constructor {
self.name = _name;
self.content = _content;
menu_item = menuItem(name, function(_dat) {
return submenuCall(_dat, content);
}).setColor(COLORS._main_accent)
.setIsShelf();
}
function addonTrigger(_addon, _openDialog = true) {
var _name = filename_name_only(_addon);
with(_addon_custom) {
if(name != _name)
@ -40,8 +62,10 @@ function addonTrigger(_addon) {
}
var addonPath = DIRECTORY + "Addons\\" + _name;
if(!directory_exists(addonPath)) return;
with(instance_create(0, 0, _addon_custom))
init(addonPath);
init(addonPath, _openDialog);
}
function addonActivated(_addon) {

View file

@ -8,124 +8,15 @@
}
#endregion
#region constant
function __addon_lua_setup_constants(lua, context) {
lua_add_code(lua, "ID = '" + string(context.ID) + "'");
lua_add_code(lua, "c_aqua = " + string(c_aqua));
lua_add_code(lua, "c_black = " + string(c_black));
lua_add_code(lua, "c_blue = " + string(c_blue));
lua_add_code(lua, "c_dkgray = " + string(c_dkgray));
lua_add_code(lua, "c_fuchsia = " + string(c_fuchsia));
lua_add_code(lua, "c_gray = " + string(c_gray));
lua_add_code(lua, "c_green = " + string(c_green));
lua_add_code(lua, "c_lime = " + string(c_lime));
lua_add_code(lua, "c_ltgray = " + string(c_ltgray));
lua_add_code(lua, "c_maroon = " + string(c_maroon));
lua_add_code(lua, "c_navy = " + string(c_navy));
lua_add_code(lua, "c_olive = " + string(c_olive));
lua_add_code(lua, "c_orange = " + string(c_orange));
lua_add_code(lua, "c_purple = " + string(c_purple));
lua_add_code(lua, "c_red = " + string(c_red));
lua_add_code(lua, "c_silver = " + string(c_silver));
lua_add_code(lua, "c_teal = " + string(c_teal));
lua_add_code(lua, "c_white = " + string(c_white));
lua_add_code(lua, "c_yellow = " + string(c_yellow));
lua_add_code(lua, "fa_left = " + string(fa_left));
lua_add_code(lua, "fa_middle = " + string(fa_middle));
lua_add_code(lua, "fa_right = " + string(fa_right));
//
lua_add_code(lua, "fa_top = " + string(fa_top));
lua_add_code(lua, "fa_center = " + string(fa_center));
lua_add_code(lua, "fa_bottom = " + string(fa_bottom));
lua_add_code(lua, "mb_left = " + string(mb_left));
lua_add_code(lua, "mb_middle = " + string(mb_middle));
lua_add_code(lua, "mb_right = " + string(mb_right));
lua_add_code(lua, "vk_nokey = " + string(vk_nokey));
lua_add_code(lua, "vk_anykey = " + string(vk_anykey));
lua_add_code(lua, "vk_left = " + string(vk_left));
lua_add_code(lua, "vk_right = " + string(vk_right));
lua_add_code(lua, "vk_up = " + string(vk_up));
lua_add_code(lua, "vk_down = " + string(vk_down));
lua_add_code(lua, "vk_enter = " + string(vk_enter));
lua_add_code(lua, "vk_escape = " + string(vk_escape));
lua_add_code(lua, "vk_space = " + string(vk_space));
lua_add_code(lua, "vk_shift = " + string(vk_shift));
lua_add_code(lua, "vk_control = " + string(vk_control));
lua_add_code(lua, "vk_alt = " + string(vk_alt));
lua_add_code(lua, "vk_backspace = " + string(vk_backspace));
lua_add_code(lua, "vk_tab = " + string(vk_tab));
lua_add_code(lua, "vk_home = " + string(vk_home));
lua_add_code(lua, "vk_end = " + string(vk_end));
lua_add_code(lua, "vk_delete = " + string(vk_delete));
lua_add_code(lua, "vk_insert = " + string(vk_insert));
lua_add_code(lua, "vk_pageup = " + string(vk_pageup));
lua_add_code(lua, "vk_pagedown = " + string(vk_pagedown));
lua_add_code(lua, "vk_pause = " + string(vk_pause));
lua_add_code(lua, "vk_printscreen = " + string(vk_printscreen));
lua_add_code(lua, "vk_f1 = " + string(vk_f1));
lua_add_code(lua, "vk_f2 = " + string(vk_f2));
lua_add_code(lua, "vk_f3 = " + string(vk_f3));
lua_add_code(lua, "vk_f4 = " + string(vk_f4));
lua_add_code(lua, "vk_f5 = " + string(vk_f5));
lua_add_code(lua, "vk_f6 = " + string(vk_f6));
lua_add_code(lua, "vk_f7 = " + string(vk_f7));
lua_add_code(lua, "vk_f8 = " + string(vk_f8));
lua_add_code(lua, "vk_f9 = " + string(vk_f9));
lua_add_code(lua, "vk_f10 = " + string(vk_f10));
lua_add_code(lua, "vk_f11 = " + string(vk_f11));
lua_add_code(lua, "vk_f12 = " + string(vk_f12));
lua_add_code(lua, "vk_numpad0 = " + string(vk_numpad0));
lua_add_code(lua, "vk_numpad1 = " + string(vk_numpad1));
lua_add_code(lua, "vk_numpad2 = " + string(vk_numpad2));
lua_add_code(lua, "vk_numpad3 = " + string(vk_numpad3));
lua_add_code(lua, "vk_numpad4 = " + string(vk_numpad4));
lua_add_code(lua, "vk_numpad5 = " + string(vk_numpad5));
lua_add_code(lua, "vk_numpad6 = " + string(vk_numpad6));
lua_add_code(lua, "vk_numpad7 = " + string(vk_numpad7));
lua_add_code(lua, "vk_numpad8 = " + string(vk_numpad8));
lua_add_code(lua, "vk_numpad9 = " + string(vk_numpad9));
lua_add_code(lua, "vk_multiply = " + string(vk_multiply));
lua_add_code(lua, "vk_divide = " + string(vk_divide));
lua_add_code(lua, "vk_add = " + string(vk_add));
lua_add_code(lua, "vk_subtract = " + string(vk_subtract));
lua_add_code(lua, "vk_decimal = " + string(vk_decimal));
lua_add_code(lua, "tb_text = " + string(TEXTBOX_INPUT.text));
lua_add_code(lua, "tb_number = " + string(TEXTBOX_INPUT.number));
lua_add_code(lua, "Panel = {};");
lua_add_code(lua, "Animator = {};");
}
function __addon_lua_panel_variable(lua, panel) {
lua_add_code(lua,
"Panel.mouse = {" + string(panel.mx) + ", " + string(panel.my) + "}\n" +
"Panel.x = " + string(panel.x ) + "\n" +
"Panel.y = " + string(panel.y ) + "\n" +
"Panel.w = " + string(panel.w ) + "\n" +
"Panel.h = " + string(panel.h ) + "\n" +
"Panel.hoverable = " + string(panel.pHOVER) + "\n" +
"Panel.clickable = " + string(panel.pFOCUS) + "\n"
);
lua_add_code(lua,
"Animator.frame_current = " + string(ANIMATOR.current_frame) + "\n" +
"Animator.frame_total = " + string(ANIMATOR.frames_total) + "\n" +
"Animator.frame_rate = " + string(ANIMATOR.framerate) + "\n"
);
}
#endregion
#region API
function __addon_lua_setup_functions(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]);
if(is_string(_func))
lua_add_code(lua, _func);
else if(is_array(_func))
lua_add_function(lua, _func[0], _func[1]);
}
}
@ -197,6 +88,11 @@
[ "gpu_set_state", gpu_set_state],
// basic form
[ "draw_set_color", draw_set_color ],
[ "draw_set_alpha", draw_set_alpha ],
[ "gpu_set_blendmode", gpu_set_blendmode ],
[ "gpu_set_blendmode_ext", gpu_set_blendmode_ext ],
[ "draw_arrow", draw_arrow ],
[ "draw_circle", draw_circle ],
[ "draw_circle_colour", draw_circle_colour ],
@ -206,6 +102,8 @@
[ "draw_line_colour", draw_line_colour ],
[ "draw_line_width", draw_line_width ],
[ "draw_line_width_colour", draw_line_width_colour ],
[ "draw_line_round", draw_line_round ],
[ "draw_line_round_color", draw_line_round_color ],
[ "draw_point", draw_point ],
[ "draw_point_colour", draw_point_colour ],
[ "draw_rectangle", draw_rectangle ],
@ -333,8 +231,41 @@
[ "buffer_get_surface", buffer_get_surface ],
[ "buffer_set_surface", buffer_set_surface ],
//sprite
[ "sprite_collision_mask", sprite_collision_mask ],
[ "sprite_set_offset", sprite_set_offset ],
[ "sprite_set_bbox_mode", sprite_set_bbox_mode ],
[ "sprite_set_bbox", sprite_set_bbox ],
[ "sprite_set_speed", sprite_set_speed ],
[ "sprite_set_nineslice", sprite_set_nineslice ],
//variable
[ "__sprite_add", function(_ID, _path, _amo, rem = false, smt = false, xoff = 0, yoff = 0) {
var _addon = noone;
with(_addon_custom) if(self.ID == _ID) _addon = self;
if(_addon == noone) return 0;
_path = string_replace(_path, "./", _addon.directory + "/");
return sprite_add(_path, _amo, rem, smt, xoff, yoff);
}],
@"function sprite_add(path, _amo, rem, smt, xoff, yoff)
rem = rem or false
smt = smt or false
xoff = xoff or 0
yoff = yoff or 0
return __sprite_add(ID, path, _amo, rem, smt, xoff, yoff)
end",
[ "sprite_delete", sprite_delete ],
[ "sprite_replace", sprite_replace ],
[ "sprite_duplicate", sprite_duplicate ],
[ "sprite_assign", sprite_assign ],
[ "sprite_merge", sprite_merge ],
[ "sprite_set_alpha_from_sprite", sprite_set_alpha_from_sprite ],
[ "sprite_nineslice_create", sprite_nineslice_create ],
[ "sprite_create_from_surface", sprite_create_from_surface ],
[ "sprite_add_from_surface", sprite_add_from_surface ],
//variable
[ "variable_instance_exists", variable_instance_exists ],
[ "variable_instance_get_names", variable_instance_get_names ],
[ "variable_instance_names_count", variable_instance_names_count ],
@ -897,7 +828,30 @@
return node.outputMap[? input].getValue();
}],
[ "get_hovering_element", function() { return HOVERING_ELEMENT; }],
[ "element_get", function() { return HOVERING_ELEMENT; }],
[ "__panel_create", function(ID, panel = "") {
var _addon = noone;
with(_addon_custom) if(self.ID == ID) _addon = self;
if(_addon == noone) return noone;
var arr = variable_struct_get_names(_addon.panels);
for( var i = 0; i < array_length(arr); i++ ) {
if(arr[i] != panel) continue;
var pane = _addon.panels[$ arr[i]];
dialogPanelCall(new addonPanel(_addon, pane));
}
return noone;
}],
@"
function panel_create(panel)
__panel_create(ID, panel)
end
",
];
#endregion
@ -909,8 +863,16 @@
global.ADDON_WIDGET[? wd].setActiveFocus(focus, hover);
} ],
[ "__textBox", function(type, onModify) {
var wd = new textBox(type, onModify);
[ "__textBox", function(ID, type, onModify) {
var _addon = noone;
with(_addon_custom) if(self.ID == ID) _addon = self;
if(_addon == noone) return noone;
var wd = new textBox(type, noone);
wd.setLua(_addon.thread, onModify, function(txt) {
return lua_call(lua_thread, lua_thread_key, txt);
});
var key = UUID_generate();
global.ADDON_WIDGET[? key] = wd;
@ -922,35 +884,31 @@
global.ADDON_WIDGET[? wd].draw(_x, _y, _w, _h, _text, _m);
} ],
[ "__textBox_apply", function(wd) {
if(!ds_map_exists(global.ADDON_WIDGET, wd)) return;
global.ADDON_WIDGET[? wd].apply();
return global.ADDON_WIDGET[? wd].current_value;
} ],
@"
TextBox = {}
TextBox.new = function(type, onModify)
local self = {}
self.id = __textBox(type, onModify)
self.id = __textBox(ID, type, onModify)
function self.draw(self, _x, _y, _w, _h, _text)
__widget_wake(self.id, Panel.hoverable, Panel.clickable)
__textBox_draw(self.id, _x, _y, _w, _h, _text, Panel.mouse)
if(keyboard_check_pressed(vk_enter) == 1) then
onModify(__textBox_apply(self.id))
end
end
return self
end",
[ "__vectorBox", function(size, onModify) {
var wd = new vectorBox(size, onModify);
[ "__vectorBox", function(ID, size, onModify) {
var _addon = noone;
with(_addon_custom) if(self.ID == ID) _addon = self;
if(_addon == noone) return noone;
var wd = new vectorBox(size, noone);
wd.setLua(_addon.thread, onModify, function(i, v) {
return lua_call(lua_thread, lua_thread_key, i + 1, v);
});
var key = UUID_generate();
global.ADDON_WIDGET[? key] = wd;
@ -962,35 +920,32 @@ end",
global.ADDON_WIDGET[? wd].draw(_x, _y, _w, _h, _vector, _m);
} ],
[ "__vectorBox_apply", function(wd) {
if(!ds_map_exists(global.ADDON_WIDGET, wd)) return;
global.ADDON_WIDGET[? wd].apply();
return global.ADDON_WIDGET[? wd].current_value;
} ],
@"
VectorBox = {}
VectorBox.new = function(size, onModify)
local self = {}
self.id = __vectorBox(size, onModify)
self.id = __vectorBox(ID, size, onModify)
function self.draw(self, _x, _y, _w, _h, _vector)
__widget_wake(self.id, Panel.hoverable, Panel.clickable)
__vectorBox_draw(self.id, _x, _y, _w, _h, _vector, Panel.mouse)
if(keyboard_check_pressed(vk_enter) == 1) then
onModify(__vectorBox_apply(self.id))
end
end
return self
end",
[ "__checkBox", function(onModify) {
[ "__checkBox", function(ID, onModify) {
var _addon = noone;
with(_addon_custom) if(self.ID == ID) _addon = self;
if(_addon == noone) return noone;
var wd = new checkBox(onModify);
wd.setLua(_addon.thread, onModify, function() {
return lua_call(lua_thread, lua_thread_key);
});
var key = UUID_generate();
global.ADDON_WIDGET[? key] = wd;
@ -1002,42 +957,32 @@ end",
global.ADDON_WIDGET[? wd].draw(_x, _y, _value);
} ],
[ "__checkBox_apply", function(wd) {
if(!ds_map_exists(global.ADDON_WIDGET, wd)) return;
global.ADDON_WIDGET[? wd].trigger();
return true;
} ],
[ "__checkBox_trigger", function(wd) {
if(!ds_map_exists(global.ADDON_WIDGET, wd)) return;
return global.ADDON_WIDGET[? wd].isTriggered();
} ],
@"
CheckBox = {}
CheckBox.new = function(onModify)
local self = {}
self.id = __checkBox(onModify)
self.id = __checkBox(ID, onModify)
function self.draw(self, _x, _y, _value)
__widget_wake(self.id, Panel.hoverable, Panel.clickable)
__checkBox_draw(self.id, _x, _y, _value, Panel.mouse)
if(__checkBox_trigger()) then
__checkBox_apply(self.id)
onModify()
end
end
return self
end",
[ "__button", function(onModify, txt = "") {
[ "__button", function(ID, onModify, txt = "") {
var _addon = noone;
with(_addon_custom) if(self.ID == ID) _addon = self;
if(_addon == noone) return noone;
var wd = new button(onModify).setText(txt);
wd.setLua(_addon.thread, onModify, function() {
return lua_call(lua_thread, lua_thread_key);
});
var key = UUID_generate();
global.ADDON_WIDGET[? key] = wd;
@ -1049,94 +994,30 @@ end",
global.ADDON_WIDGET[? wd].draw(_x, _y, _w, _h);
} ],
[ "__button_apply", function(wd) {
if(!ds_map_exists(global.ADDON_WIDGET, wd)) return;
global.ADDON_WIDGET[? wd].trigger();
return true;
} ],
[ "__button_trigger", function(wd) {
if(!ds_map_exists(global.ADDON_WIDGET, wd)) return;
return global.ADDON_WIDGET[? wd].isTriggered();
} ],
@"
Button = {}
Button.new = function(onModify, txt)
local self = {}
self.id = __button(onModify, txt)
self.id = __button(ID, onModify, txt)
function self.draw(self, _x, _y, _w, _h)
__widget_wake(self.id, Panel.hoverable, Panel.clickable)
__button_draw(self.id, _x, _y, _w, _h, Panel.mouse)
if(__button_trigger()) then
__button_apply(self.id)
onModify()
end
end
return self
end",
[ "__button_color", function(onModify, txt = "") {
var wd = new button(onModify).setText(txt);
var key = UUID_generate();
global.ADDON_WIDGET[? key] = wd;
return key;
} ],
[ "__button_color_draw", function(wd, _x, _y, _w, _h, _value, _m) {
if(!ds_map_exists(global.ADDON_WIDGET, wd)) return;
global.ADDON_WIDGET[? wd].draw(_x, _y, _w, _h, _value);
} ],
[ "__button_color_apply", function(wd) {
if(!ds_map_exists(global.ADDON_WIDGET, wd)) return;
global.ADDON_WIDGET[? wd].trigger();
return global.ADDON_WIDGET[? wd].current_value;
} ],
[ "__button_color_trigger", function(wd) {
if(!ds_map_exists(global.ADDON_WIDGET, wd)) return;
return global.ADDON_WIDGET[? wd].isTriggered();
} ],
@"
ButtonColor = {}
ButtonColor.new = function(onModify, txt)
local self = {}
self.id = __button_color(onModify, txt)
function self.draw(self, _x, _y, _w, _h, _value)
__widget_wake(self.id, Panel.hoverable, Panel.clickable)
__button_color_draw(self.id, _x, _y, _w, _h, _value, Panel.mouse)
if(__button_color_trigger()) then
onModify(__button_color_apply(self.id))
end
end
return self
end",
];
function __addon_lua_setup_widget(lua, context) {
for( var i = 0; i < array_length(global.__lua_widget_functions); i++ ) {
var _func = global.__lua_widget_functions[i];
if(is_string(_func)) {
if(is_string(_func))
lua_add_code(lua, _func);
} else if(is_array(_func))
else if(is_array(_func))
lua_add_function(lua, _func[0], _func[1]);
}
}

View file

@ -0,0 +1,161 @@
function __addon_lua_setup_constants(lua, context) {
lua_add_code(lua, $"ID = '{context.ID}'");
lua_add_code(lua, $"c_aqua = {c_aqua}");
lua_add_code(lua, $"c_black = {c_black}");
lua_add_code(lua, $"c_blue = {c_blue}");
lua_add_code(lua, $"c_dkgray = {c_dkgray}");
lua_add_code(lua, $"c_fuchsia = {c_fuchsia}");
lua_add_code(lua, $"c_gray = {c_gray}");
lua_add_code(lua, $"c_green = {c_green}");
lua_add_code(lua, $"c_lime = {c_lime}");
lua_add_code(lua, $"c_ltgray = {c_ltgray}");
lua_add_code(lua, $"c_maroon = {c_maroon}");
lua_add_code(lua, $"c_navy = {c_navy}");
lua_add_code(lua, $"c_olive = {c_olive}");
lua_add_code(lua, $"c_orange = {c_orange}");
lua_add_code(lua, $"c_purple = {c_purple}");
lua_add_code(lua, $"c_red = {c_red}");
lua_add_code(lua, $"c_silver = {c_silver}");
lua_add_code(lua, $"c_teal = {c_teal}");
lua_add_code(lua, $"c_white = {c_white}");
lua_add_code(lua, $"c_yellow = {c_yellow}");
lua_add_code(lua, $"color_accent = {COLORS._main_accent}");
lua_add_code(lua, $"color_icon = {COLORS._main_icon}");
lua_add_code(lua, $"color_icon_dark = {COLORS._main_icon_dark}");
lua_add_code(lua, $"color_icon_light = {COLORS._main_icon_light}");
lua_add_code(lua, $"color_text = {COLORS._main_text}");
lua_add_code(lua, $"color_text_sub = {COLORS._main_text_sub}");
lua_add_code(lua, $"color_positive = {COLORS._main_value_positive}");
lua_add_code(lua, $"color_negative = {COLORS._main_value_negative}");
lua_add_code(lua, $"color_dkblack = {CDEF.main_dkblack}");
lua_add_code(lua, $"color_mdblack = {CDEF.main_mdblack}");
lua_add_code(lua, $"color_black = {CDEF.main_black}");
lua_add_code(lua, $"color_dkgrey = {CDEF.main_dkgrey}");
lua_add_code(lua, $"color_dark = {CDEF.main_dark}");
lua_add_code(lua, $"color_grey = {CDEF.main_grey}");
lua_add_code(lua, $"color_ltgrey = {CDEF.main_ltgrey}");
lua_add_code(lua, $"color_white = {CDEF.main_white}");
lua_add_code(lua, $"fa_left = {fa_left}");
lua_add_code(lua, $"fa_middle = {fa_middle}");
lua_add_code(lua, $"fa_right = {fa_right}");
//
lua_add_code(lua, $"fa_top = {fa_top}");
lua_add_code(lua, $"fa_center = {fa_center}");
lua_add_code(lua, $"fa_bottom = {fa_bottom}");
lua_add_code(lua, $"mb_left = {mb_left}");
lua_add_code(lua, $"mb_middle = {mb_middle}");
lua_add_code(lua, $"mb_right = {mb_right}");
lua_add_code(lua, $"vk_nokey = {vk_nokey}");
lua_add_code(lua, $"vk_anykey = {vk_anykey}");
lua_add_code(lua, $"vk_left = {vk_left}");
lua_add_code(lua, $"vk_right = {vk_right}");
lua_add_code(lua, $"vk_up = {vk_up}");
lua_add_code(lua, $"vk_down = {vk_down}");
lua_add_code(lua, $"vk_enter = {vk_enter}");
lua_add_code(lua, $"vk_escape = {vk_escape}");
lua_add_code(lua, $"vk_space = {vk_space}");
lua_add_code(lua, $"vk_shift = {vk_shift}");
lua_add_code(lua, $"vk_control = {vk_control}");
lua_add_code(lua, $"vk_alt = {vk_alt}");
lua_add_code(lua, $"vk_backspace = {vk_backspace}");
lua_add_code(lua, $"vk_tab = {vk_tab}");
lua_add_code(lua, $"vk_home = {vk_home}");
lua_add_code(lua, $"vk_end = {vk_end}");
lua_add_code(lua, $"vk_delete = {vk_delete}");
lua_add_code(lua, $"vk_insert = {vk_insert}");
lua_add_code(lua, $"vk_pageup = {vk_pageup}");
lua_add_code(lua, $"vk_pagedown = {vk_pagedown}");
lua_add_code(lua, $"vk_pause = {vk_pause}");
lua_add_code(lua, $"vk_printscreen = {vk_printscreen}");
lua_add_code(lua, $"vk_f1 = {vk_f1}");
lua_add_code(lua, $"vk_f2 = {vk_f2}");
lua_add_code(lua, $"vk_f3 = {vk_f3}");
lua_add_code(lua, $"vk_f4 = {vk_f4}");
lua_add_code(lua, $"vk_f5 = {vk_f5}");
lua_add_code(lua, $"vk_f6 = {vk_f6}");
lua_add_code(lua, $"vk_f7 = {vk_f7}");
lua_add_code(lua, $"vk_f8 = {vk_f8}");
lua_add_code(lua, $"vk_f9 = {vk_f9}");
lua_add_code(lua, $"vk_f10 = {vk_f10}");
lua_add_code(lua, $"vk_f11 = {vk_f11}");
lua_add_code(lua, $"vk_f12 = {vk_f12}");
lua_add_code(lua, $"vk_numpad0 = {vk_numpad0}");
lua_add_code(lua, $"vk_numpad1 = {vk_numpad1}");
lua_add_code(lua, $"vk_numpad2 = {vk_numpad2}");
lua_add_code(lua, $"vk_numpad3 = {vk_numpad3}");
lua_add_code(lua, $"vk_numpad4 = {vk_numpad4}");
lua_add_code(lua, $"vk_numpad5 = {vk_numpad5}");
lua_add_code(lua, $"vk_numpad6 = {vk_numpad6}");
lua_add_code(lua, $"vk_numpad7 = {vk_numpad7}");
lua_add_code(lua, $"vk_numpad8 = {vk_numpad8}");
lua_add_code(lua, $"vk_numpad9 = {vk_numpad9}");
lua_add_code(lua, $"vk_multiply = {vk_multiply}");
lua_add_code(lua, $"vk_divide = {vk_divide}");
lua_add_code(lua, $"vk_add = {vk_add}");
lua_add_code(lua, $"vk_subtract = {vk_subtract}");
lua_add_code(lua, $"vk_decimal = {vk_decimal}");
lua_add_code(lua, $"gp_face1 = {gp_face1}");
lua_add_code(lua, $"gp_face2 = {gp_face2}");
lua_add_code(lua, $"gp_face3 = {gp_face3}");
lua_add_code(lua, $"gp_face4 = {gp_face4}");
lua_add_code(lua, $"gp_shoulderl = {gp_shoulderl}");
lua_add_code(lua, $"gp_shoulderlb = {gp_shoulderlb}");
lua_add_code(lua, $"gp_shoulderr = {gp_shoulderr}");
lua_add_code(lua, $"gp_shoulderrb = {gp_shoulderrb}");
lua_add_code(lua, $"gp_select = {gp_select}");
lua_add_code(lua, $"gp_start = {gp_start}");
lua_add_code(lua, $"gp_stickl = {gp_stickl}");
lua_add_code(lua, $"gp_stickr = {gp_stickr}");
lua_add_code(lua, $"gp_padu = {gp_padu}");
lua_add_code(lua, $"gp_padd = {gp_padd}");
lua_add_code(lua, $"gp_padl = {gp_padl}");
lua_add_code(lua, $"gp_padr = {gp_padr}");
lua_add_code(lua, $"gp_axislh = {gp_axislh}");
lua_add_code(lua, $"gp_axislv = {gp_axislv}");
lua_add_code(lua, $"gp_axisrh = {gp_axisrh}");
lua_add_code(lua, $"gp_axisrv = {gp_axisrv}");
lua_add_code(lua, $"bm_normal = {bm_normal}");
lua_add_code(lua, $"bm_add = {bm_add}");
lua_add_code(lua, $"bm_subtract = {bm_subtract}");
lua_add_code(lua, $"bm_max = {bm_max}");
lua_add_code(lua, $"tb_text = {TEXTBOX_INPUT.text}");
lua_add_code(lua, $"tb_number = {TEXTBOX_INPUT.number}");
lua_add_code(lua, "Panel = {};");
lua_add_code(lua, "Animator = {};");
lua_add_code(lua, $"s_ui_panel_active = {THEME.ui_panel_active}");
lua_add_code(lua, $"s_ui_panel_bg = {THEME.ui_panel_bg}");
lua_add_code(lua, $"s_ui_panel_bg_dark = {THEME.ui_panel_bg_dark}");
lua_add_code(lua, $"s_ui_scrollbar = {THEME.ui_scrollbar}");
}
function __addon_lua_panel_variable(lua, panel) {
lua_add_code(lua,
"Panel.mouse = {" + string(panel.mx) + ", " + string(panel.my) + "}\n" +
"Panel.x = " + string(panel.x ) + "\n" +
"Panel.y = " + string(panel.y ) + "\n" +
"Panel.w = " + string(panel.w ) + "\n" +
"Panel.h = " + string(panel.h ) + "\n" +
"Panel.hoverable = " + string(panel.pHOVER) + "\n" +
"Panel.clickable = " + string(panel.pFOCUS) + "\n"
);
lua_add_code(lua,
"Animator.frame_current = " + string(ANIMATOR.current_frame) + "\n" +
"Animator.frame_total = " + string(ANIMATOR.frames_total) + "\n" +
"Animator.frame_rate = " + string(ANIMATOR.framerate) + "\n"
);
}

View file

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

View file

@ -10,13 +10,13 @@
directory_create(root);
var _l = root + "/version";
//if(file_exists(_l)) {
// var res = json_load_struct(_l);
// if(!is_struct(res) || !struct_has(res, "version") || res.version != VERSION)
// zip_unzip("data/Assets.zip", root);
//} else
if(file_exists(_l)) {
var res = json_load_struct(_l);
if(!is_struct(res) || !struct_has(res, "version") || res.version != BUILD_NUMBER)
zip_unzip("data/Assets.zip", root);
} else
zip_unzip("data/Assets.zip", root);
json_save_struct(_l, { version: VERSION });
json_save_struct(_l, { version: BUILD_NUMBER });
global.ASSETS = new DirectoryObject("Assets", root);
global.ASSETS.scan([".png"]);

View file

@ -14,8 +14,15 @@ function buttonClass(_onClick, _icon = noone) : widget() constructor {
onClick = _onClick;
triggered = false;
static setLua = function(_lua_thread, _lua_key, _lua_func) {
lua_thread = _lua_thread;
lua_thread_key = _lua_key;
onClick = method(self, _lua_func);
}
static trigger = function() {
if(!onClick) return;
if(!is_callable(onClick))
return noone;
triggered = true;
onClick();
}

View file

@ -3,8 +3,15 @@ function checkBox(_onClick) : widget() constructor {
spr = THEME.checkbox;
triggered = false;
static setLua = function(_lua_thread, _lua_key, _lua_func) {
lua_thread = _lua_thread;
lua_thread_key = _lua_key;
onClick = method(self, _lua_func);
}
static trigger = function() {
if(!onClick) return;
if(!is_callable(onClick))
return noone;
triggered = true;
onClick();
}

View file

@ -9,14 +9,13 @@ function __initCollection() {
directory_create(root);
var _l = root + "/version";
//if(file_exists(_l)) {
// var res = json_load_struct(_l);
// if(!is_struct(res) || !struct_has(res, "version") || res.version != COLLECTION_VERSION)
// zip_unzip("data/Collections.zip", root);
//} else
if(file_exists(_l)) {
var res = json_load_struct(_l);
if(!is_struct(res) || !struct_has(res, "version") || res.version != BUILD_NUMBER)
zip_unzip("data/Collections.zip", root);
} else
zip_unzip("data/Collections.zip", root);
json_save_struct(_l, { version: COLLECTION_VERSION });
json_save_struct(_l, { version: BUILD_NUMBER });
refreshCollections();
}

View file

@ -18,7 +18,12 @@
function submenuCall(_data, menu = []) {
var dia = instance_create_depth(_data.x - ui(4), _data.y, _data.depth - 1, o_dialog_menubox);
dia.context = _data.context;
dia.setMenu(menu);
if(_data.x - ui(4) + dia.dialog_w > WIN_W - ui(2))
dia.dialog_x = _data._x - dia.dialog_w + ui(4);
return dia;
}

View file

@ -70,9 +70,8 @@ function FileObject(_name, _path) constructor {
meta = new MetaDataManager();
if(ds_map_exists(m, "metadata"))
meta.deserialize(m[? "metadata"]);
if(ds_map_exists(m, "preview")) {
if(ds_map_exists(m, "preview"))
thumbnail_data = json_try_parse(m[? "preview"], -1);
}
meta.version = m[? "version"];
meta.name = name;

View file

@ -30,14 +30,12 @@
THEME = {};
COLOR_KEYS = [];
globalvar VERSION, SAVEFILE_VERSION, VERSION_STRING;
globalvar COLLECTION_VERSION, THEME_VERSION;
globalvar VERSION, SAVEFILE_VERSION, VERSION_STRING, BUILD_NUMBER;
VERSION = 1144;
SAVEFILE_VERSION = 1420;
COLLECTION_VERSION = 1140.090;
THEME_VERSION = 1140.090;
VERSION_STRING = "1.14.4";
VERSION = 1143;
SAVEFILE_VERSION = 1420;
VERSION_STRING = "1.14.3.2";
BUILD_NUMBER = 114301;
globalvar NODES, NODE_MAP, APPEND_MAP, NODE_NAME_MAP;
globalvar HOTKEYS, HOTKEY_CONTEXT, NODE_INSTANCES;

View file

@ -10,8 +10,17 @@
if(!directory_exists(root))
directory_create(root);
file_copy(lfile, path);
var _l = root + "/version";
if(file_exists(_l)) {
var res = json_load_struct(_l);
if(!is_struct(res) || !struct_has(res, "version") || res.version != BUILD_NUMBER)
file_copy(lfile, path);
} else
file_copy(lfile, path);
LOCALE = json_load_struct(path);
json_save_struct(_l, { version: BUILD_NUMBER });
}
function get_text(key, def = "") {

View file

@ -45,12 +45,12 @@ function MetaDataManager() constructor {
}
static deserialize = function(m, readonly = false) {
description = ds_map_try_get(m, "description", "");
author = ds_map_try_get(m, "author", "");
contact = ds_map_try_get(m, "contact", "");
alias = ds_map_try_get(m, "alias", "");
author_steam_id = ds_map_try_get(m, "aut_id");
file_id = ds_map_try_get(m, "file_id");
description = ds_map_try_get(m, "description", description);
author = ds_map_try_get(m, "author", author);
contact = ds_map_try_get(m, "contact", contact);
alias = ds_map_try_get(m, "alias", alias);
author_steam_id = ds_map_try_get(m, "aut_id", author_steam_id);
file_id = ds_map_try_get(m, "file_id", file_id);
if(ds_map_exists(m, "tags"))
tags = array_create_from_list(m[? "tags"]);

View file

@ -5,7 +5,7 @@ function Node_Array(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
w = 96;
inputs[| 0] = nodeValue("Type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 )
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Any", "Surface", "Number", "Color", "Text" ])
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Any", "Surface", "Number", "Color", "Text" ], { update_hover: false })
.rejectArray();
inputs[| 1] = nodeValue("Spread array", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false )
@ -56,7 +56,7 @@ function Node_Array(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
return _h;
});
input_display_list = [ 0, 1, array_adjust_tool ];
input_display_list = [ 0, array_adjust_tool, 1 ];
input_fix_len = ds_list_size(inputs);
input_display_list_len = array_length(input_display_list);
@ -92,9 +92,9 @@ function Node_Array(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
if(!LOADING && !APPENDING) createNewInput();
static refreshDynamicInput = function() {
var _l = ds_list_create();
var amo = attributes[? "size"];
var extra = true;
var _l = ds_list_create();
var amo = attributes[? "size"];
var extra = true;
var lastNode = noone;
for( var i = 0; i < ds_list_size(inputs); i++ ) {
@ -130,16 +130,25 @@ function Node_Array(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
static onValueUpdate = function(index = 0) {
if(index != 0) return;
var _typ = getType();
for( var i = input_fix_len; i < ds_list_size(inputs); i++ ) {
if(_typ != VALUE_TYPE.any)
inputs[| i].type = _typ;
inputs[| i].resetDisplay();
var ls = ds_list_create();
ls[| 0] = inputs[| 0];
ls[| 1] = inputs[| 1];
ds_list_destroy(inputs);
inputs = ls;
input_display_list = [ 0, array_adjust_tool, 1 ];
//var _typ = getType();
//for( var i = input_fix_len; i < ds_list_size(inputs); i++ ) {
// if(_typ != VALUE_TYPE.any)
// inputs[| i].type = _typ;
// inputs[| i].resetDisplay();
if(_typ && inputs[| i].value_from && (value_bit(inputs[| i].value_from.type) & value_bit(_typ) == 0))
inputs[| i].removeFrom();
}
// if(_typ && inputs[| i].value_from && (value_bit(inputs[| i].value_from.type) & value_bit(_typ) == 0))
// inputs[| i].removeFrom();
//}
refreshDynamicInput();
}

View file

@ -24,6 +24,11 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
name = "";
display_name = "";
internalName = "";
run_in(1, function() {
internalName = string_replace_all(name, " ", "_") + string(irandom_range(10000, 99999));
NODE_NAME_MAP[? internalName] = self;
});
tooltip = "";
x = _x;
y = _y;

View file

@ -75,9 +75,9 @@ function __initNodeData() {
if(file_exists(_l)) {
var res = json_load_struct(_l);
if(res.version == VERSION) return;
if(res.version == BUILD_NUMBER) return;
}
json_save_struct(_l, { version: VERSION });
json_save_struct(_l, { version: BUILD_NUMBER });
if(file_exists("data/tooltip.zip"))
zip_unzip("data/tooltip.zip", nodeDir);

View file

@ -17,7 +17,6 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
inputs[| 3] = nodeValue("Round anchor", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false)
.rejectArray();
input_display_list = [
["Path", false], 0, 2, 1, 3,
["Anchors", false],
@ -31,6 +30,9 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
inputs[| index] = nodeValue("Anchor", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ _x, _y, _dxx, _dxy, _dyx, _dyy ])
.setDisplay(VALUE_DISPLAY.vector);
recordAction(ACTION_TYPE.var_modify, self, [ array_clone(input_display_list), "input_display_list" ]);
recordAction(ACTION_TYPE.list_insert, inputs, [ inputs[| index], index, "add path anchor point" ]);
array_push(input_display_list, index);
return inputs[| index];
@ -595,10 +597,13 @@ function Node_Path(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
drag_point_sy = _a[1];
}
}
} else if(hover_type == 0 && key_mod_press(SHIFT)) {
} else if(hover_type == 0 && key_mod_press(SHIFT)) { //remove
draw_sprite_ui_uniform(THEME.cursor_path_remove, 0, _mx + 16, _my + 16);
if(mouse_press(mb_left, active)) {
recordAction(ACTION_TYPE.var_modify, self, [ array_clone(input_display_list), "input_display_list" ]);
recordAction(ACTION_TYPE.list_delete, inputs, [ inputs[| input_fix_len + anchor_hover], input_fix_len + anchor_hover, "remove path anchor point" ]);
ds_list_delete(inputs, input_fix_len + anchor_hover);
array_remove(input_display_list, input_fix_len + anchor_hover);
doUpdate();

View file

@ -341,6 +341,8 @@ function nodeValue(_name, _node, _connect, _type, _value, _tooltip = "") {
function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constructor {
name = _name;
internalName = string_replace_all(name, " ", "_");
node = _node;
x = node.x;
y = node.y;
@ -348,8 +350,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
type = _type;
if(struct_has(node, "inputMap")) {
if(_connect == JUNCTION_CONNECT.input) node.inputMap[? string_replace_all(name, " ", "_")] = self;
else if(_connect == JUNCTION_CONNECT.output) node.outputMap[? string_replace_all(name, " ", "_")] = self;
if(_connect == JUNCTION_CONNECT.input) node.inputMap[? internalName] = self;
else if(_connect == JUNCTION_CONNECT.output) node.outputMap[? internalName] = self;
}
tooltip = _tooltip;
@ -1191,7 +1193,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
if(updated) {
if(connect_type == JUNCTION_CONNECT.input) {
node.triggerRender();
if(_update) node.valueUpdate(index);
if(_update) node.valueUpdate(self.index);
node.clearCacheForward();
UPDATE |= RENDER_TYPE.partial;

View file

@ -7,7 +7,7 @@ function Panel_Addon() : PanelContent() constructor {
padding = 24;
#region data
w = ui(320);
w = ui(400);
h = ui(480);
search_string = "";
@ -46,7 +46,7 @@ function Panel_Addon() : PanelContent() constructor {
draw_clear_alpha(COLORS.panel_bg_clear, 0);
var _h = 0;
var ww = sc_addon.surface_w;
var hg = ui(36);
var hg = ui(40);
var i = 0;
var arr = search_string == ""? ADDONS : search_res;
@ -57,7 +57,7 @@ function Panel_Addon() : PanelContent() constructor {
var bw = ui(28);
var bh = ui(28);
var bx = ww - ui(4) - bw;
var by = _y + (hg - bh) / 2;
var by = _y;
var hh = hg;
var _act = addonActivated(_addon.name);
@ -76,33 +76,66 @@ function Panel_Addon() : PanelContent() constructor {
var cc = merge_color(COLORS._main_icon_light, COLORS._main_icon, hover? 0 : 0.25);
draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, 0, by, ww, hg, cc, 1);
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
draw_text_add(ui(36), by + ui(6), _addon.name);
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
draw_text_add(ui(44), by + hg / 2, _addon.name);
var chx0 = ui(8);
var chy0 = by + ui(8);
var chx0 = ui(6);
var chy0 = by + ui(6);
var chx1 = chx0 + ui(20);
var chy1 = chy0 + ui(20);
var _onStart = array_exists(ADDONS_ON_START, _addon.name);
if(pHOVER && point_in_rectangle(_m[0], _m[1], chx0, chy0, chx1, chy1)) {
draw_sprite_stretched_ext(THEME.checkbox, 1, chx0, chy0, ui(20), ui(20), c_white, 1);
if(!_act) TOOLTIP = "Not activated";
else if(!_onStart) TOOLTIP = "Activated";
else TOOLTIP = "Run on start";
draw_sprite_stretched_ext(THEME.checkbox, 1, chx0, chy0, ui(28), ui(28), c_white, 1);
hover = false;
if(mouse_press(mb_left, pFOCUS))
addonTrigger(_addon.name);
if(mouse_press(mb_left, pFOCUS)) {
if(!_act)
addonTrigger(_addon.name);
else if(!_onStart) {
array_push(ADDONS_ON_START, _addon.name);
} else {
addonTrigger(_addon.name);
array_remove(ADDONS_ON_START, _addon.name);
}
json_save_struct(DIRECTORY + "Addons\\__init.json", ADDONS_ON_START);
}
} else
draw_sprite_stretched_ext(THEME.checkbox, 0, chx0, chy0, ui(20), ui(20), c_white, 1);
draw_sprite_stretched_ext(THEME.checkbox, 0, chx0, chy0, ui(28), ui(28), c_white, 1);
if(_act) draw_sprite_stretched_ext(THEME.checkbox, 2, chx0, chy0, ui(20), ui(20), COLORS._main_accent, 1);
if(_onStart)
draw_sprite_stretched_ext(THEME.checkbox_on_start, 0, chx0, chy0, ui(28), ui(28), COLORS._main_value_positive, 1);
else if(_act)
draw_sprite_stretched_ext(THEME.checkbox, 2, chx0, chy0, ui(28), ui(28), COLORS._main_accent, 1);
var _bx = bx - ui(4);
var _by = by + ui(4);
var _bx = bx - ui(2);
var _by = by + ui(2);
var b = buttonInstant(THEME.button_hide, _bx, _by, ui(32), ui(32), _m, pFOCUS, pHOVER, "Open in explorer", THEME.folder_content);
if(b) hover = false;
if(b == 2) shellOpenExplorer(DIRECTORY + "Addons\\" + _addon.name);
if(pHOVER && hover)
_bx -= ui(36)
if(_act && buttonInstant(THEME.button_hide, _bx, _by, ui(32), ui(32), _m, pFOCUS, pHOVER, "Addon settings", THEME.addon_setting) == 2) {
var _addObj = noone;
with(_addon_custom) if(name == _addon.name) _addObj = self;
if(_addObj) {
var arr = variable_struct_get_names(_addObj.panels);
for( var i = 0; i < array_length(arr); i++ ) {
var pane = _addObj.panels[$ arr[i]];
if(struct_has(pane, "main") && pane.main)
dialogPanelCall(new addonPanel(_addObj, pane));
}
}
}
if(pHOVER && hover && _m[0] < _bx)
if(mouse_press(mb_left, pFOCUS)) _addon.open = !_addon.open;
if(_addon.open) {

View file

@ -66,6 +66,12 @@ function Panel_Collection() : PanelContent() constructor {
if(STEAM_ENABLED) {
if(!meta.steam) {
array_push(contentMenu, menuItem(get_text("panel_collection_workshop_upload", "Upload to Steam Workshop") + "...", function() {
var s = PANEL_PREVIEW.getNodePreviewSurface();
if(!is_surface(s)) {
noti_warning("Please send any node to preview panel to use as a thumbnail.")
return;
}
var dia = dialogCall(o_dialog_file_name_collection, mouse_mx + ui(8), mouse_my + ui(-320));
var meta = _menu_node.getMetadata();
if(meta != noone && meta != undefined)
@ -162,7 +168,10 @@ function Panel_Collection() : PanelContent() constructor {
var _node = index < node_list? nodes[| index] : steamNode[index - node_list];
var _nx = grid_space + (grid_width + grid_space) * j;
var _boxx = _nx + (grid_width - grid_size) / 2;
var gr_x1 = _boxx + grid_size;
var gr_y1 = yy + grid_size;
BLEND_OVERRIDE;
draw_sprite_stretched(THEME.node_bg, 0, _boxx, yy, grid_size, grid_size);
BLEND_NORMAL;
@ -210,8 +219,11 @@ function Panel_Collection() : PanelContent() constructor {
if(meta != noone && mode == 0) {
if(meta.steam) {
draw_sprite_ui_uniform(THEME.steam, 0, _boxx + ui(12), yy + ui(12), 1, COLORS._main_icon_dark, 1);
if(meta.author_steam_id == STEAM_USER_ID)
if(meta.author_steam_id == STEAM_USER_ID) {
draw_sprite_ui_uniform(THEME.steam_creator, 0, _boxx + grid_size - ui(8), yy + ui(12), 1, COLORS._main_icon_dark, 1);
if(point_in_rectangle(_m[0], _m[1], gr_x1 - ui(24), yy, gr_x1, yy + ui(24)))
TOOLTIP = "You created this item";
}
}
if(meta.version != SAVEFILE_VERSION) {

View file

@ -13,7 +13,7 @@ function Panel_Inspector() : PanelContent() constructor {
locked = false;
inspecting = noone;
top_bar_h = ui(96);
top_bar_h = ui(100);
prop_hover = noone;
prop_selecting = noone;
@ -544,7 +544,7 @@ function Panel_Inspector() : PanelContent() constructor {
draw_set_text(f_p3, fa_center, fa_center, COLORS._main_text_sub);
draw_set_alpha(0.65);
draw_text(w / 2, ui(74), inspecting.internalName);
draw_text(w / 2, ui(76), inspecting.internalName);
draw_set_alpha(1);
var lx = w / 2 - string_width(inspecting.name) / 2 - ui(16);
@ -615,12 +615,16 @@ function Panel_Inspector() : PanelContent() constructor {
if(CURRENT_PATH == "") {
buttonInstant(noone, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, get_text("panel_inspector_workshop_save", "Save file before upload"), THEME.workshop_upload, 0, COLORS._main_icon, 0.5);
} else {
if(!METADATA.steam) {
if(!METADATA.steam) { //project made locally
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS, pHOVER, get_text("panel_inspector_workshop_upload", "Upload to Steam Workshop"), THEME.workshop_upload, 0, COLORS._main_icon) == 2) {
METADATA.author_steam_id = STEAM_USER_ID;
SAVE();
steam_ugc_create_project();
workshop_uploading = true;
var s = PANEL_PREVIEW.getNodePreviewSurface();
if(is_surface(s)) {
METADATA.author_steam_id = STEAM_USER_ID;
SAVE();
steam_ugc_create_project();
workshop_uploading = true;
} else
noti_warning("Please send any node to preview panel to use as a thumbnail.")
}
}

View file

@ -11,14 +11,14 @@
var _l = root + "/version";
var _preset_path = "data/Preset.zip";
if(file_exists(_preset_path)) {
//if(file_exists(_l)) {
// var res = json_load_struct(_l);
// if(!is_struct(res) || !struct_has(res, "version") || res.version != VERSION)
// zip_unzip(_preset_path, root);
//} else
if(file_exists(_l)) {
var res = json_load_struct(_l);
if(!is_struct(res) || !struct_has(res, "version") || res.version != BUILD_NUMBER)
zip_unzip(_preset_path, root);
} else
zip_unzip(_preset_path, root);
}
json_save_struct(_l, { version: VERSION });
json_save_struct(_l, { version: BUILD_NUMBER });
global.PRESETS = new DirectoryObject("Presets", root);
global.PRESETS.scan([".json"]);

View file

@ -4,11 +4,11 @@ function __initTheme() {
directory_create(root);
var _l = root + "/version";
//if(file_exists(_l)) {
// var res = json_load_struct(_l);
// if(res.version == THEME_VERSION) return;
//}
json_save_struct(_l, { version: THEME_VERSION });
if(file_exists(_l)) {
var res = json_load_struct(_l);
if(res.version == BUILD_NUMBER) return;
}
//json_save_struct(_l, { version: BUILD_NUMBER });
log_message("THEME", "unzipping default theme to DIRECTORY.");
zip_unzip("data/themes/default.zip", root);

View file

@ -63,7 +63,7 @@ function __loadSteamUGC(file_id, item_map) {
}
}
function __loadSteamUGCCollection(file_id, f, path) {
function __loadSteamUGCCollection(file_id, f, path) {
var name = string_replace(filename_name(f), ".pxcc", "");
var file = new FileObject(name, path + "/" + f);
var icon_path = string_replace(path + "/" + f, ".pxcc", ".png");
@ -83,7 +83,7 @@ function __loadSteamUGCCollection(file_id, f, path) {
meta.file_id = file_id;
}
function __loadSteamUGCProject(file_id, f, path) {
function __loadSteamUGCProject(file_id, f, path) {
var name = string_replace(filename_name(f), ".pxc", "");
var file = new FileObject(name, path + "/" + f);
var icon_path = path + "/thumbnail.png";

View file

@ -3,21 +3,22 @@ function steam_ugc_create_project() {
var file = new FileObject(string_replace(filename_name(CURRENT_PATH), filename_ext(CURRENT_PATH), ""), CURRENT_PATH);
file.getMetadata();
file.spr_path = "steamUGC/thumbnail.png";
file.spr_path = DIRECTORY + "steamUGC/thumbnail.png";
STEAM_UGC_UPDATE = false;
STEAM_UGC_ITEM_UPLOADING = true;
STEAM_UGC_ITEM_FILE = file;
STEAM_UGC_TYPE = STEAM_UGC_FILE_TYPE.project;
directory_destroy("steamUGC");
directory_create("steamUGC");
file_copy(file.path, "steamUGC/" + filename_name(file.path));
directory_destroy(DIRECTORY + "steamUGC");
directory_create(DIRECTORY + "steamUGC");
file_copy(file.path, DIRECTORY + "steamUGC/" + filename_name(file.path));
steam_ugc_project_generate();
file_copy("steamUGCthumbnail.png", "steamUGC/thumbnail.png");
var preview_surface = PANEL_PREVIEW.getNodePreviewSurface();
surface_save_safe(preview_surface, DIRECTORY + "steamUGC/thumbnail.png");
print(filename_dir("steamUGCthumbnail.png"))
print(filename_dir(DIRECTORY + "steamUGCthumbnail.png"))
STEAM_UGC_ITEM_ID = steam_ugc_create_item(STEAM_APP_ID, ugc_filetype_community);
}
@ -27,17 +28,17 @@ function steam_ugc_update_project(update_preview = false) {
var file = new FileObject(string_replace(filename_name(CURRENT_PATH), filename_ext(CURRENT_PATH), ""), CURRENT_PATH);
file.getMetadata();
file.spr_path = "steamUGC/thumbnail.png";
file.spr_path = DIRECTORY + "steamUGC/thumbnail.png";
STEAM_UGC_UPDATE = true;
STEAM_UGC_ITEM_UPLOADING = true;
STEAM_UGC_ITEM_FILE = file;
STEAM_UGC_TYPE = STEAM_UGC_FILE_TYPE.project;
directory_destroy("steamUGC");
directory_create("steamUGC");
file_copy(file.path, "steamUGC/" + filename_name(file.path));
file_copy(file.spr_path[0], "steamUGC/thumbnail.png");
directory_destroy(DIRECTORY + "steamUGC");
directory_create(DIRECTORY + "steamUGC");
file_copy(file.path, DIRECTORY + "steamUGC/" + filename_name(file.path));
file_copy(file.spr_path[0], DIRECTORY + "steamUGC/thumbnail.png");
STEAM_UGC_PUBLISH_ID = file.meta.file_id;
STEAM_UGC_UPDATE_HANDLE = steam_ugc_start_item_update(STEAM_APP_ID, STEAM_UGC_PUBLISH_ID);
@ -47,12 +48,12 @@ function steam_ugc_update_project(update_preview = false) {
array_insert(STEAM_UGC_ITEM_FILE.meta.tags, 0, "Project");
steam_ugc_set_item_tags(STEAM_UGC_UPDATE_HANDLE, STEAM_UGC_ITEM_FILE.meta.tags);
steam_ugc_set_item_content(STEAM_UGC_UPDATE_HANDLE, "steamUGC");
steam_ugc_set_item_content(STEAM_UGC_UPDATE_HANDLE, DIRECTORY + "steamUGC");
STEAM_UGC_SUBMIT_ID = steam_ugc_submit_item_update(STEAM_UGC_UPDATE_HANDLE, "Updated");
}
function steam_ugc_project_generate(dest_path = "steamUGCthumbnail.png") {
function steam_ugc_project_generate(dest_path = DIRECTORY + "steamUGCthumbnail.png") {
file_delete(dest_path);
var preview_surface = PANEL_PREVIEW.getNodePreviewSurface();

View file

@ -88,7 +88,7 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi
_input_text_current = _last_text;
current_value = _input_text_current;
if(onModify)
if(is_callable(onModify))
return onModify(_input_text_current);
return false;
}

View file

@ -18,12 +18,18 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor {
if(linked) {
var modi = false;
for( var i = 0; i < size; i++ )
modi |= onModify(i, v);
for( var i = 0; i < size; i++ ) {
tb[i]._input_text = v;
if(is_callable(onModify))
modi |= onModify(i, v);
}
return modi;
}
return onModify(index, v);
if(is_callable(onModify))
return onModify(index, v);
return noone;
}
axis = [ "x", "y", "z", "w" ];
@ -121,7 +127,7 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor {
static apply = function() {
for( var i = 0; i < size; i++ ) {
tb[i].apply();
current_value[i] = tb[i]._input_text;
current_value[i] = toNumber(tb[i]._input_text);
}
}
}

View file

@ -6,11 +6,20 @@ function widget() constructor {
parent = noone;
interactable = true;
lua_thread = noone;
lua_thread_key = "";
x = 0;
y = 0;
w = 0;
h = 0;
static setLua = function(_lua_thread, _lua_key, _lua_func) {
lua_thread = _lua_thread;
lua_thread_key = _lua_key;
onModify = method(self, _lua_func);
}
static setInteract = function(interactable = noone) {
self.interactable = interactable;
}