context menu hotkey

This commit is contained in:
Tanasart 2024-08-09 18:30:09 +07:00
parent 3c165588d3
commit 5644cffee8
86 changed files with 1614 additions and 1302 deletions

View file

@ -1171,6 +1171,7 @@
{"name":"node_value_palette","order":2,"path":"scripts/node_value_palette/node_value_palette.yy",}, {"name":"node_value_palette","order":2,"path":"scripts/node_value_palette/node_value_palette.yy",},
{"name":"node_value_particle","order":4,"path":"scripts/node_value_particle/node_value_particle.yy",}, {"name":"node_value_particle","order":4,"path":"scripts/node_value_particle/node_value_particle.yy",},
{"name":"node_value_path_anchor","order":18,"path":"scripts/node_value_path_anchor/node_value_path_anchor.yy",}, {"name":"node_value_path_anchor","order":18,"path":"scripts/node_value_path_anchor/node_value_path_anchor.yy",},
{"name":"node_value_path","order":34,"path":"scripts/node_value_path/node_value_path.yy",},
{"name":"node_value_pathnode","order":5,"path":"scripts/node_value_pathnode/node_value_pathnode.yy",}, {"name":"node_value_pathnode","order":5,"path":"scripts/node_value_pathnode/node_value_pathnode.yy",},
{"name":"node_value_quarterion","order":19,"path":"scripts/node_value_quarterion/node_value_quarterion.yy",}, {"name":"node_value_quarterion","order":19,"path":"scripts/node_value_quarterion/node_value_quarterion.yy",},
{"name":"node_value_range","order":2,"path":"scripts/node_value_range/node_value_range.yy",}, {"name":"node_value_range","order":2,"path":"scripts/node_value_range/node_value_range.yy",},

View file

@ -1777,6 +1777,7 @@
{"id":{"name":"node_value_palette","path":"scripts/node_value_palette/node_value_palette.yy",},}, {"id":{"name":"node_value_palette","path":"scripts/node_value_palette/node_value_palette.yy",},},
{"id":{"name":"node_value_particle","path":"scripts/node_value_particle/node_value_particle.yy",},}, {"id":{"name":"node_value_particle","path":"scripts/node_value_particle/node_value_particle.yy",},},
{"id":{"name":"node_value_path_anchor","path":"scripts/node_value_path_anchor/node_value_path_anchor.yy",},}, {"id":{"name":"node_value_path_anchor","path":"scripts/node_value_path_anchor/node_value_path_anchor.yy",},},
{"id":{"name":"node_value_path","path":"scripts/node_value_path/node_value_path.yy",},},
{"id":{"name":"node_value_pathnode","path":"scripts/node_value_pathnode/node_value_pathnode.yy",},}, {"id":{"name":"node_value_pathnode","path":"scripts/node_value_pathnode/node_value_pathnode.yy",},},
{"id":{"name":"node_value_quarterion","path":"scripts/node_value_quarterion/node_value_quarterion.yy",},}, {"id":{"name":"node_value_quarterion","path":"scripts/node_value_quarterion/node_value_quarterion.yy",},},
{"id":{"name":"node_value_range","path":"scripts/node_value_range/node_value_range.yy",},}, {"id":{"name":"node_value_range","path":"scripts/node_value_range/node_value_range.yy",},},

View file

@ -12,8 +12,8 @@ event_inherited();
show_graph = false; show_graph = false;
menu = [ menu = [
menuItem("Toggle double click bar", function() /*=>*/ { show_doubleclick = !show_doubleclick; }), menuItemAction("Toggle double click bar", function() /*=>*/ { show_doubleclick = !show_doubleclick; }),
menuItem("Toggle graph", function() /*=>*/ { show_graph = !show_graph; }), menuItemAction("Toggle graph", function() /*=>*/ { show_graph = !show_graph; }),
]; ];
extra_keys = [ extra_keys = [

View file

@ -60,21 +60,25 @@ event_inherited();
category_width = maxLen + ui(56); category_width = maxLen + ui(56);
#endregion #endregion
function trigger_favourite() {
if(node_menu_selecting == noone) return;
var _node = node_menu_selecting.node;
if(!is_array(global.FAV_NODES)) global.FAV_NODES = [];
if(array_exists(global.FAV_NODES, _node)) array_remove(global.FAV_NODES, _node);
else array_push(global.FAV_NODES, _node);
}
registerFunction("Add Node", "Trigger Favourite", "", MOD_KEY.none, trigger_favourite);
function rightClick(node) { function rightClick(node) {
if(!is_instanceof(node, NodeObject)) return; if(!is_instanceof(node, NodeObject)) return;
node_menu_selecting = node; node_menu_selecting = node;
var fav = array_exists(global.FAV_NODES, node.node); var fav = array_exists(global.FAV_NODES, node.node);
var menu = [ var menu = [
menuItem(fav? __txtx("add_node_remove_favourite", "Remove from favourite") : __txtx("add_node_add_favourite", "Add to favourite"), menuItemAction(fav? __txtx("add_node_remove_favourite", "Remove from favourite") : __txtx("add_node_add_favourite", "Add to favourite"), trigger_favourite, THEME.star)
function() {
if(!is_array(global.FAV_NODES)) global.FAV_NODES = [];
if(array_exists(global.FAV_NODES, node_menu_selecting.node))
array_remove(global.FAV_NODES, node_menu_selecting.node);
else
array_push(global.FAV_NODES, node_menu_selecting.node);
}, THEME.star)
]; ];
menuCall("add_node_window_manu",,, menu,, node_menu_selecting); menuCall("add_node_window_manu",,, menu,, node_menu_selecting);

View file

@ -101,10 +101,10 @@ event_inherited();
hovering = pal; hovering = pal;
menuCall("palette_window_preset_menu",,, [ menuCall("palette_window_preset_menu",,, [
menuItem(__txtx("palette_editor_set_default", "Set as default"), function() { menuItemAction(__txtx("palette_editor_set_default", "Set as default"), function() {
PROJECT.setPalette(array_clone(hovering.palette)); PROJECT.setPalette(array_clone(hovering.palette));
}), }),
menuItem(__txtx("palette_editor_delete", "Delete palette"), function() { menuItemAction(__txtx("palette_editor_delete", "Delete palette"), function() {
file_delete(hovering.path); file_delete(hovering.path);
__initPalette(); __initPalette();
}), }),

View file

@ -138,7 +138,7 @@ event_inherited();
if(mouse_press(mb_right, interactable && sFOCUS)) { if(mouse_press(mb_right, interactable && sFOCUS)) {
hovering_name = _gradient.path; hovering_name = _gradient.path;
menuCall("gradient_window_preset_menu",,, [ menuCall("gradient_window_preset_menu",,, [
menuItem(__txtx("gradient_editor_delete", "Delete gradient"), function() { menuItemAction(__txtx("gradient_editor_delete", "Delete gradient"), function() {
file_delete(hovering_name); file_delete(hovering_name);
__initGradient(); __initGradient();
}) })
@ -227,7 +227,7 @@ event_inherited();
hovering = pal; hovering = pal;
menuCall("palette_window_preset_menu",,, [ menuCall("palette_window_preset_menu",,, [
menuItem(__txtx("gradient_set_palette", "Convert to Gradient"), function() { menuItemAction(__txtx("gradient_set_palette", "Convert to Gradient"), function() {
var _p = hovering.palette; var _p = hovering.palette;
if(array_length(_p) < 2) return; if(array_length(_p) < 2) return;

View file

@ -100,11 +100,11 @@ if !ready exit;
if(buttonInstant(THEME.button_hide, bx, by, ui(28), ui(28), mouse_ui, interactable && sFOCUS, sHOVER, __txtx("gradient_editor_key_blend", "Key blending"), THEME.grad_blend) == 2) { if(buttonInstant(THEME.button_hide, bx, by, ui(28), ui(28), mouse_ui, interactable && sFOCUS, sHOVER, __txtx("gradient_editor_key_blend", "Key blending"), THEME.grad_blend) == 2) {
menuCall("gradient_window_blend_menu", bx + ui(32), by, [ menuCall("gradient_window_blend_menu", bx + ui(32), by, [
menuItem(__txtx("gradient_editor_blend_hard", "Solid"), function() { gradient.type = 1; onApply(gradient); }), menuItemAction(__txtx("gradient_editor_blend_hard", "Solid"), function() { gradient.type = 1; onApply(gradient); }),
menuItem(__txtx("gradient_editor_blend_RGB", "RGB"), function() { gradient.type = 0; onApply(gradient); }), menuItemAction(__txtx("gradient_editor_blend_RGB", "RGB"), function() { gradient.type = 0; onApply(gradient); }),
menuItem(__txtx("gradient_editor_blend_sRGB", "sRGB"), function() { gradient.type = 4; onApply(gradient); }), menuItemAction(__txtx("gradient_editor_blend_sRGB", "sRGB"), function() { gradient.type = 4; onApply(gradient); }),
menuItem(__txtx("gradient_editor_blend_HSV", "HSV"), function() { gradient.type = 2; onApply(gradient); }), menuItemAction(__txtx("gradient_editor_blend_HSV", "HSV"), function() { gradient.type = 2; onApply(gradient); }),
menuItem(__txtx("gradient_editor_blend_OKLAB", "OKLAB"), function() { gradient.type = 3; onApply(gradient); }), menuItemAction(__txtx("gradient_editor_blend_OKLAB", "OKLAB"), function() { gradient.type = 3; onApply(gradient); }),
],, gradient); ],, gradient);
} }
bx -= ui(32); bx -= ui(32);

View file

@ -112,7 +112,7 @@ event_inherited();
if(menu > -1) { if(menu > -1) {
menuCall("image_array_edit_menu",,, [ menuCall("image_array_edit_menu",,, [
menuItem(__txt("Remove"), function() { menuItemAction(__txt("Remove"), function() {
var arr = target.getValue(); var arr = target.getValue();
array_delete(arr, menuOn, 1); array_delete(arr, menuOn, 1);

View file

@ -2,26 +2,28 @@
event_inherited(); event_inherited();
#region data #region data
menu_id = "";
destroy_on_click_out = false; destroy_on_click_out = false;
draggable = false; draggable = false;
mouse_inside = false; mouse_init_inside = false;
selecting = -1; selecting = -1;
alarm[0] = -1; menu_id = "";
menu = 1; alarm[0] = -1;
hght = ui(36); menu = 1;
hght = ui(36);
tooltips = []; tooltips = [];
show_icon = false; show_icon = false;
context = noone; context = noone;
_hovering_ch = true; _hovering_ch = true;
init_pressing = false; init_pressing = false;
setFocus(self.id); setFocus(self.id);
remove_parents = true;
selecting_menu = noone;
hk_editing = noone;
function setMenu(_menu, align = fa_left) { function setMenu(_menu, align = fa_left) {
with(_p_dialog) { if(on_top) continue; other.depth = min(depth - 1, other.depth); } with(_p_dialog) { if(on_top) continue; other.depth = min(depth - 1, other.depth); }
@ -45,6 +47,13 @@ event_inherited();
continue; continue;
} }
if(is_string(_menuItem)) {
draw_set_font(f_p3);
dialog_w = max(dialog_w, string_width(_menuItem) + ui(24));
dialog_h += string_height(_menuItem) + ui(8);
continue;
}
draw_set_font(f_p0); draw_set_font(f_p0);
var ww = string_width(_menuItem.name) + ui(64); var ww = string_width(_menuItem.name) + ui(64);
@ -85,7 +94,7 @@ event_inherited();
case fa_right: dialog_x = round(max(dialog_x - dialog_w, 2)); break; case fa_right: dialog_x = round(max(dialog_x - dialog_w, 2)); break;
} }
mouse_inside = point_in_rectangle(mouse_mx, mouse_my, dialog_x, dialog_y, dialog_x + dialog_w, dialog_y + dialog_h); mouse_init_inside = point_in_rectangle(mouse_mx, mouse_my, dialog_x, dialog_y, dialog_x + dialog_w, dialog_y + dialog_h);
ready = true; ready = true;
} }
#endregion #endregion

View file

@ -3,16 +3,26 @@ if(!ready) exit;
#region draw #region draw
var yy = dialog_y; var yy = dialog_y;
var _lclick = sFOCUS && (!mouse_init_inside && mouse_release(mb_left)) || (keyboard_check_pressed(vk_enter) && hk_editing == noone);
var _rclick = sFOCUS && (!mouse_init_inside && mouse_release(mb_right));
draw_sprite_stretched(THEME.s_box_r2_clr, 0, dialog_x, dialog_y, dialog_w, dialog_h); draw_sprite_stretched(THEME.s_box_r2_clr, 0, dialog_x, dialog_y, dialog_w, dialog_h);
for(var i = 0; i < array_length(menu); i++) { for(var i = 0; i < array_length(menu); i++) {
var _menuItem = menu[i]; var _menuItem = menu[i];
if(is_string(_menuItem)) {
draw_set_text(f_p3, fa_left, fa_top, COLORS._main_text_sub);
draw_text(dialog_x + ui(8), yy + ui(4), _menuItem);
yy += string_height(_menuItem) + ui(8);
continue;
}
if(is_instanceof(_menuItem, MenuItem) && _menuItem.shiftMenu != noone && key_mod_press(SHIFT)) if(is_instanceof(_menuItem, MenuItem) && _menuItem.shiftMenu != noone && key_mod_press(SHIFT))
_menuItem = _menuItem.shiftMenu; _menuItem = _menuItem.shiftMenu;
if(_menuItem == -1) { #region if(_menuItem == -1) {
var bx = dialog_x + ui(8); var bx = dialog_x + ui(8);
var bw = dialog_w - ui(16); var bw = dialog_w - ui(16);
draw_set_color(CDEF.main_mdblack); draw_set_color(CDEF.main_mdblack);
@ -20,12 +30,14 @@ if(!ready) exit;
yy += ui(8); yy += ui(8);
continue; continue;
} #endregion }
var label = _menuItem.name; var label = _menuItem.name;
var _h = is_instanceof(_menuItem, MenuItemGroup)? hght * 2 : hght; var _h = is_instanceof(_menuItem, MenuItemGroup)? hght * 2 : hght;
var cc = struct_try_get(_menuItem, "color", c_white); var cc = struct_try_get(_menuItem, "color", c_white);
var _key = _menuItem.hotkey != noone? find_hotkey(_menuItem.hotkey[0], _menuItem.hotkey[1]) : noone;
_menuItem.hoykeyObject = _key;
if(sHOVER && point_in_rectangle(mouse_mx, mouse_my, dialog_x, yy + 1, dialog_x + dialog_w, yy + _h - 1)) { if(sHOVER && point_in_rectangle(mouse_mx, mouse_my, dialog_x, yy + 1, dialog_x + dialog_w, yy + _h - 1)) {
selecting = i; selecting = i;
var tips = array_safe_get_fast(tooltips, i, noone); var tips = array_safe_get_fast(tooltips, i, noone);
@ -38,25 +50,53 @@ if(!ready) exit;
draw_sprite_stretched_ext(THEME.textbox, 3, dialog_x, yy, dialog_w, _h, _hc, _ha); draw_sprite_stretched_ext(THEME.textbox, 3, dialog_x, yy, dialog_w, _h, _hc, _ha);
var _click = sFOCUS && (!mouse_inside && mouse_release(mb_left)) || keyboard_check_released(vk_enter); if(is_instanceof(_menuItem, MenuItem) && _menuItem.active && _hovering_ch) {
if(_hovering_ch && is_instanceof(_menuItem, MenuItem) && _menuItem.active && _click) { if(_lclick) {
var _dat = {
_x: dialog_x,
x: dialog_x + dialog_w,
y: yy,
depth: depth,
name: _menuItem.name,
index: i,
context: context,
params: _menuItem.params,
};
var _dat = { var _res = _menuItem.func(_dat);
_x: dialog_x, if(_menuItem.isShelf) array_push(children, _res.id); // open child
x: dialog_x + dialog_w, else if(remove_parents) instance_destroy(o_dialog_menubox); // close all
y: yy, else instance_destroy(); // close self
depth: depth, }
name: _menuItem.name,
index: i,
context: context,
params: _menuItem.params,
};
var _res = _menuItem.func(_dat);
if(_menuItem.isShelf) array_push(children, _res.id);
else instance_destroy(o_dialog_menubox);
if(_key && _rclick) {
var _dat = {
_x: dialog_x,
x: mouse_mx + ui(4),
y: mouse_my + ui(4),
depth: depth,
name: _menuItem.name,
index: i,
context: context,
params: _menuItem.params,
};
selecting_menu = _menuItem;
var _loadKey = $"{_key.context}.{_key.name}";
var context_menu_settings = [
_loadKey,
menuItemAction("Edit hotkey", function() /*=>*/ {
hk_editing = selecting_menu;
keyboard_lastchar = hk_editing.hoykeyObject.key;
}),
];
with(o_dialog_menubox) { if(!remove_parents) instance_destroy(); }
var _menu = submenuCall(_dat, context_menu_settings);
_menu.remove_parents = false;
}
} }
} else if(cc != c_white) } else if(cc != c_white)
draw_sprite_stretched_ext(THEME.textbox, 3, dialog_x, yy, dialog_w, _h, cc, 0.5); draw_sprite_stretched_ext(THEME.textbox, 3, dialog_x, yy, dialog_w, _h, cc, 0.5);
@ -92,6 +132,7 @@ if(!ready) exit;
_sw = string_width(_str) + ui(12); _sw = string_width(_str) + ui(12);
_sh = string_height(_str) + ui(8); _sh = string_height(_str) + ui(8);
} else { } else {
if(is_array(_sprs)) { if(is_array(_sprs)) {
_spr = _sprs[0]; _spr = _sprs[0];
@ -120,6 +161,7 @@ if(!ready) exit;
if(_str != "") if(_str != "")
draw_text(_bx, _by, _str); draw_text(_bx, _by, _str);
} }
} else { } else {
if(_menuItem.spr != noone) { if(_menuItem.spr != noone) {
var spr = is_array(_menuItem.spr)? _menuItem.spr[0] : _menuItem.spr; var spr = is_array(_menuItem.spr)? _menuItem.spr[0] : _menuItem.spr;
@ -140,21 +182,47 @@ if(!ready) exit;
if(_menuItem.isShelf) { if(_menuItem.isShelf) {
draw_sprite_ui_uniform(THEME.arrow, 0, dialog_x + dialog_w - ui(20), yy + hght / 2, 1, COLORS._main_icon); draw_sprite_ui_uniform(THEME.arrow, 0, dialog_x + dialog_w - ui(20), yy + hght / 2, 1, COLORS._main_icon);
} else if(_menuItem.hotkey != noone) {
var _key = find_hotkey(_menuItem.hotkey[0], _menuItem.hotkey[1]);
if(_key) { } else if(_key) {
var _hx = dialog_x + dialog_w - ui(16); var _hx = dialog_x + dialog_w - ui(16);
var _hy = yy + hght / 2 + ui(2); var _hy = yy + hght / 2 + ui(2);
hotkey_draw(key_get_name(_key.key, _key.modi), _hx, _hy);
} draw_set_font(f_p1);
var _ktxt = key_get_name(_key.key, _key.modi);
var _tw = string_width(_ktxt);
var _th = line_get_height();
var _bx = _hx - _tw - ui(4);
var _by = _hy - _th / 2 - ui(3);
var _bw = _tw + ui(8);
var _bh = _th + ui(3);
if(hk_editing == _menuItem) {
draw_set_text(f_p1, fa_right, fa_center, COLORS._main_accent);
draw_sprite_stretched_ext(THEME.ui_panel, 1, _bx, _by, _bw, _bh, COLORS._main_text_accent);
} else if(_ktxt != "") {
draw_set_text(f_p1, fa_right, fa_center, COLORS._main_text_sub);
draw_sprite_stretched_ext(THEME.ui_panel, 1, _bx, _by, _bw, _bh, CDEF.main_dkgrey);
}
draw_text(_hx, _hy, _ktxt);
} }
} }
yy += _h; yy += _h;
} }
if(sFOCUS) { if(hk_editing != noone) {
if(keyboard_check_pressed(vk_enter))
hk_editing = noone;
else if(keyboard_check_pressed(vk_escape))
hk_editing = noone;
else
hotkey_editing(hk_editing.hoykeyObject);
} else if(sFOCUS) {
if(keyboard_check_pressed(vk_up)) { if(keyboard_check_pressed(vk_up)) {
selecting--; selecting--;
if(selecting < 0) selecting = array_length(menu) - 1; if(selecting < 0) selecting = array_length(menu) - 1;
@ -162,14 +230,14 @@ if(!ready) exit;
if(keyboard_check_pressed(vk_down)) if(keyboard_check_pressed(vk_down))
selecting = safe_mod(selecting + 1, array_length(menu)); selecting = safe_mod(selecting + 1, array_length(menu));
if(keyboard_check_pressed(vk_escape)) if(keyboard_check_pressed(vk_escape))
instance_destroy(); instance_destroy();
} }
draw_sprite_stretched(THEME.s_box_r2_clr, 1, dialog_x, dialog_y, dialog_w, dialog_h); draw_sprite_stretched(THEME.s_box_r2_clr, 1, dialog_x, dialog_y, dialog_w, dialog_h);
if(mouse_inside && (mouse_release(mb_left) || mouse_release(mb_right))) mouse_inside = false; if(mouse_init_inside && (mouse_release(mb_left) || mouse_release(mb_right))) mouse_init_inside = false;
#endregion #endregion
#region debug #region debug

View file

@ -122,10 +122,10 @@ event_inherited();
hovering = pal; hovering = pal;
menuCall("palette_window_preset_menu",,, [ menuCall("palette_window_preset_menu",,, [
menuItem(__txtx("palette_editor_set_default", "Set as default"), function() { menuItemAction(__txtx("palette_editor_set_default", "Set as default"), function() {
PROJECT.setPalette(array_clone(hovering.palette)); PROJECT.setPalette(array_clone(hovering.palette));
}), }),
menuItem(__txtx("palette_editor_delete", "Delete palette"), function() { menuItemAction(__txtx("palette_editor_delete", "Delete palette"), function() {
file_delete(hovering.path); file_delete(hovering.path);
__initPalette(); __initPalette();
}), }),

View file

@ -87,12 +87,12 @@ if palette == 0 exit;
if(b) mouse_draggable = false; if(b) mouse_draggable = false;
if(b == 2) { if(b == 2) {
menuCall("palette_window_sort_menu", bx + ui(32), by, [ menuCall("palette_window_sort_menu", bx + ui(32), by, [
menuItem(__txtx("palette_editor_sort_brighter", "Brighter"), function() { sortPalette(__sortBright); }), menuItemAction(__txtx("palette_editor_sort_brighter", "Brighter"), function() { sortPalette(__sortBright); }),
menuItem(__txtx("palette_editor_sort_darker", "Darker"), function() { sortPalette(__sortDark); }), menuItemAction(__txtx("palette_editor_sort_darker", "Darker"), function() { sortPalette(__sortDark); }),
-1, -1,
menuItem(__txtx("palette_editor_sort_hue", "Hue"), function() { sortPalette(__sortHue); }), menuItemAction(__txtx("palette_editor_sort_hue", "Hue"), function() { sortPalette(__sortHue); }),
menuItem(__txtx("palette_editor_sort_sat", "Saturation"), function() { sortPalette(__sortSat); }), menuItemAction(__txtx("palette_editor_sort_sat", "Saturation"), function() { sortPalette(__sortSat); }),
menuItem(__txtx("palette_editor_sort_val", "Value"), function() { sortPalette(__sortVal); }), menuItemAction(__txtx("palette_editor_sort_val", "Value"), function() { sortPalette(__sortVal); }),
],, palette); ],, palette);
} }
bx -= ui(32); bx -= ui(32);

View file

@ -100,7 +100,7 @@ if !ready exit;
instance_destroy(); instance_destroy();
} else if(mouse_press(mb_right)) { } else if(mouse_press(mb_right)) {
menuCall("panel_window_menu",,, [ menuCall("panel_window_menu",,, [
menuItem(__txt("Move"), function() { menuItemAction(__txt("Move"), function() {
content.dragSurface = surface_clone(panel); content.dragSurface = surface_clone(panel);
o_main.panel_dragging = content; o_main.panel_dragging = content;
content.in_dialog = false; content.in_dialog = false;

View file

@ -635,11 +635,6 @@ event_inherited();
}) })
]); ]);
vk_list = [
vk_left, vk_right, vk_up, vk_down, vk_space, vk_backspace, vk_tab, vk_home, vk_end, vk_delete, vk_insert,
vk_pageup, vk_pagedown, vk_pause, vk_printscreen,
vk_f1, vk_f2, vk_f3, vk_f4, vk_f5, vk_f6, vk_f7, vk_f8, vk_f9, vk_f10, vk_f11, vk_f12,
];
hk_editing = noone; hk_editing = noone;
sp_hotkey = new scrollPane(dialog_w - ui(padding + padding) - page_width, dialog_h - ui(title_height + padding), function(_y, _m) { sp_hotkey = new scrollPane(dialog_w - ui(padding + padding) - page_width, dialog_h - ui(title_height + padding), function(_y, _m) {
@ -694,11 +689,13 @@ event_inherited();
th = line_get_height(f_p1); th = line_get_height(f_p1);
ind = 0; ind = 0;
var _hov = sHOVER && sp_hotkey.hover;
for(var j = 0; j < ds_list_size(HOTKEY_CONTEXT); j++) { for(var j = 0; j < ds_list_size(HOTKEY_CONTEXT); j++) {
var ll = HOTKEYS[? HOTKEY_CONTEXT[| j]]; var ll = HOTKEYS[? HOTKEY_CONTEXT[| j]];
for(var i = 0; i < ds_list_size(ll); i++) { for(var i = 0; i < ds_list_size(ll); i++) {
var key = ll[| i]; var key = ll[| i];
var group = key.context; var group = key.context;
var name = __txt(key.name); var name = __txt(key.name);
var pkey = key.key; var pkey = key.key;
@ -729,39 +726,46 @@ event_inherited();
} }
var _yy = yy + hh; var _yy = yy + hh;
if(ind++ % 2 == 0)
draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, 0, _yy - padd, sp_hotkey.surface_w, th + padd * 2, COLORS.dialog_preference_prop_bg, 1);
var _lb_y = _yy; var _lb_y = _yy;
if(ind++ % 2 == 0) draw_sprite_stretched_ext(THEME.ui_panel_bg, 0, 0, _yy - padd, sp_hotkey.surface_w, th + padd * 2, COLORS.dialog_preference_prop_bg, 1);
draw_set_text(f_p1, fa_left, fa_top, COLORS._main_text); draw_set_text(f_p1, fa_left, fa_top, COLORS._main_text);
draw_text_add(ui(24), _lb_y, name); draw_text_add(ui(24), _lb_y, name);
var dk = key_get_name(key.key, key.modi); var dk = key_get_name(key.key, key.modi);
var kw = string_width(dk); var kw = string_width(dk);
var tx = key_x1 - ui(24);
var bx = tx - kw - ui(8);
var by = _yy - ui(4);
var bw = kw + ui(16);
var bh = th + ui(8);
var cc = c_white;
if(hk_editing == key) { if(hk_editing == key) {
dk = key_get_name(key.key, key.modi); draw_sprite_stretched_ext(THEME.ui_panel, 1, bx, by, bw, bh, COLORS._main_accent);
kw = string_width(dk); cc = COLORS._main_text_accent;
draw_sprite_stretched(THEME.button_hide, 2, key_x1 - ui(40) - kw, _yy, kw + ui(32), th);
} else { } else {
var bx = key_x1 - ui(40) - kw; if(_hov && point_in_rectangle(_m[0], _m[1], bx, by, bx + bw, by + bh)) {
var by = _yy; draw_sprite_stretched_ext(THEME.ui_panel, 1, bx, by, bw, bh, CDEF.main_ltgrey);
var b = buttonInstant(THEME.button_hide, bx, by, kw + ui(32), th, _m, sFOCUS, sHOVER && sp_hotkey.hover) sp_hotkey.hover_content = true;
cc = CDEF.main_ltgrey;
if(b) sp_hotkey.hover_content = true; if(mouse_press(mb_left, sFOCUS)) {
if(b == 2) { hk_editing = key;
hk_editing = key; keyboard_lastchar = pkey;
keyboard_lastchar = pkey; }
} else {
draw_sprite_stretched_ext(THEME.ui_panel, 1, bx, by, bw, bh, CDEF.main_dkgrey, 1);
cc = COLORS._main_text_sub;
} }
} }
var cc = (key.key == 0 && key.modi == MOD_KEY.none)? COLORS._main_text_sub : COLORS._main_text;
if(hk_editing == key) cc = COLORS._main_text_accent;
draw_set_text(f_p1, fa_right, fa_top, cc); draw_set_text(f_p1, fa_right, fa_top, cc);
draw_text_add(key_x1 - ui(24), _lb_y, dk); draw_text_add(tx, _lb_y, dk);
if(key.key != dkey || key.modi != dmod) { if(key.key != dkey || key.modi != dmod) {
modified = true; modified = true;
@ -782,7 +786,7 @@ event_inherited();
} }
draw_set_text(f_p0b, fa_left, fa_top, COLORS._main_text_sub); draw_set_text(f_p0b, fa_left, fa_top, COLORS._main_text_sub);
draw_text_add(ui(8), yy + hh, "Nodes (Single key only)"); draw_text_add(ui(8), yy + hh, "Nodes");
array_push(sect, [ "Nodes", sp_hotkey, hh + ui(12) ]); array_push(sect, [ "Nodes", sp_hotkey, hh + ui(12) ]);
hh += string_height("l") + ui(16); hh += string_height("l") + ui(16);
@ -862,65 +866,7 @@ event_inherited();
} }
} }
if(hk_editing != noone) { if(hk_editing != noone) hotkey_editing(hk_editing);
var _mod_prs = 0;
if(keyboard_check(vk_control)) _mod_prs |= MOD_KEY.ctrl;
if(keyboard_check(vk_shift)) _mod_prs |= MOD_KEY.shift;
if(keyboard_check(vk_alt)) _mod_prs |= MOD_KEY.alt;
if(keyboard_check_pressed(vk_escape)) {
hk_editing.key = 0;
hk_editing.modi = 0;
PREF_SAVE();
} else if(keyboard_check_pressed(vk_anykey)) {
hk_editing.modi = _mod_prs;
hk_editing.key = 0;
var press = false;
for(var a = 0; a < array_length(vk_list); a++) {
if(!keyboard_check_pressed(vk_list[a])) continue;
hk_editing.key = vk_list[a];
press = true;
break;
}
if(!press) {
var k = ds_map_find_first(global.KEY_STRING_MAP);
var amo = ds_map_size(global.KEY_STRING_MAP);
repeat(amo) {
if(!keyboard_check_pressed(k)) {
k = ds_map_find_next(global.KEY_STRING_MAP, k);
continue;
}
hk_editing.key = k;
press = true;
break;
}
}
PREF_SAVE();
}
}
//if(modified) {
// var bx = x1 - ui(32);
// var by = yy + ui(2);
// if(buttonInstant(THEME.button_hide, bx, by, ui(24), ui(24), _m, sFOCUS, sHOVER && sp_hotkey.hover, __txt("Reset all"), THEME.refresh_16) == 2) {
// for(var j = 0; j < ds_list_size(HOTKEY_CONTEXT); j++) {
// var ll = HOTKEYS[? HOTKEY_CONTEXT[| j]];
// for(var i = 0; i < ds_list_size(ll); i++) {
// var key = ll[| i];
// key.key = key.dKey;
// key.modi = key.dModi;
// PREF_SAVE();
// }
// }
// }
//}
sections[page_current] = sect; sections[page_current] = sect;
return hh; return hh;

View file

@ -53,7 +53,7 @@ event_inherited();
if(mouse_click(mb_right, sFOCUS)) { if(mouse_click(mb_right, sFOCUS)) {
var dia = menuCall("preset_window_menu",,, [ var dia = menuCall("preset_window_menu",,, [
menuItem(__txt("Delete"), function() { menuItemAction(__txt("Delete"), function() {
file_delete(o_dialog_menubox.path); file_delete(o_dialog_menubox.path);
__initPresets(); __initPresets();
}), }),

View file

@ -60,29 +60,6 @@
panelInit(); panelInit();
addHotkey("", "New file", "N", MOD_KEY.ctrl, NEW);
if(!DEMO) {
addHotkey("", "Save", "S", MOD_KEY.ctrl, SAVE);
addHotkey("", "Save as", "S", MOD_KEY.ctrl | MOD_KEY.shift, SAVE_AS);
addHotkey("", "Save all", "S", MOD_KEY.ctrl | MOD_KEY.alt, SAVE_ALL);
addHotkey("", "Open", "O", MOD_KEY.ctrl, LOAD);
}
addHotkey("", "Undo", "Z", MOD_KEY.ctrl, UNDO);
addHotkey("", "Redo", "Z", MOD_KEY.ctrl | MOD_KEY.shift, REDO);
addHotkey("", "Full panel", "`", MOD_KEY.none, set_focus_fullscreen);
addHotkey("", "Reset layout", vk_f10, MOD_KEY.ctrl, resetPanel);
addHotkey("", "Open notification", vk_f12, MOD_KEY.none, function() { dialogPanelCall(new Panel_Notification()); });
addHotkey("", "Fullscreen", vk_f11, MOD_KEY.none, global_fullscreen);
addHotkey("", "Render all", vk_f5, MOD_KEY.none, global_render_all);
addHotkey("", "Close file", "Q", MOD_KEY.ctrl, global_project_close);
addHotkey("", "Close program", vk_f4, MOD_KEY.alt, window_close);
addHotkey("", "Reload theme", vk_f10, MOD_KEY.ctrl | MOD_KEY.shift, global_theme_reload);
globalvar HOTKEY_MOD, HOTKEY_BLOCK; globalvar HOTKEY_MOD, HOTKEY_BLOCK;
HOTKEY_MOD = 0; HOTKEY_MOD = 0;
HOTKEY_BLOCK = false; HOTKEY_BLOCK = false;

View file

@ -4,7 +4,7 @@ function __Node_3D_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constru
inputs[0] = nodeValue("Vertex data", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3vertex, [] ) inputs[0] = nodeValue("Vertex data", self, JUNCTION_CONNECT.input, VALUE_TYPE.d3vertex, [] )
.setVisible(true, true); .setVisible(true, true);
inputs[1] = nodeValue_Text("Path", self, "", "Export location without '.obj' extension." ) inputs[1] = nodeValue_Path("Path", self, "", "Export location without '.obj' extension." )
.setDisplay(VALUE_DISPLAY.path_save, { filter: "3d object|*.obj" }); .setDisplay(VALUE_DISPLAY.path_save, { filter: "3d object|*.obj" });
inputs[2] = nodeValue_Bool("Export texture", self, true ); inputs[2] = nodeValue_Bool("Export texture", self, true );

View file

@ -1,7 +1,7 @@
function __Node_3D_Obj(_x, _y, _group = noone) : Node(_x, _y, _group) constructor { function __Node_3D_Obj(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "3D Object"; name = "3D Object";
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_load, { filter: "3d object|*.obj" }) .setDisplay(VALUE_DISPLAY.path_load, { filter: "3d object|*.obj" })
.rejectArray(); .rejectArray();

View file

@ -13,7 +13,7 @@ function __NodeValue_Object(_name, _node, _type, _value, _tooltip = "") : NodeVa
return val; return val;
} }
static __getAnimValue = function(_time = CURRENT_FRAME) { return array_empty(animator.values)? 0 : animator.values[0].value; } static __getAnimValue = function(_time = CURRENT_FRAME) { return array_empty(animator.values)? noone : animator.values[0].value; }
static arrayLength = arrayLengthSimple; static arrayLength = arrayLengthSimple;
} }

View file

@ -41,7 +41,7 @@ function addonContextItem(_addon, _name, _function) constructor {
self._name = _name; self._name = _name;
self._function = _function; self._function = _function;
menu_item = menuItem(_name, function(_data) { menu_item = menuItemAction(_name, function(_data) {
lua_call(_addon.thread, self._function, lua_byref(_data.context, true)); lua_call(_addon.thread, self._function, lua_byref(_data.context, true));
})//.setColor(COLORS._main_accent); })//.setColor(COLORS._main_accent);
} }
@ -50,7 +50,7 @@ function addonContextSubMenu(_name, _content) constructor {
self.name = _name; self.name = _name;
self.content = _content; self.content = _content;
menu_item = menuItem(name, function(_dat) { menu_item = menuItemAction(name, function(_dat) {
return submenuCall(_dat, content); return submenuCall(_dat, content);
})//.setColor(COLORS._main_accent) })//.setColor(COLORS._main_accent)
.setIsShelf(); .setIsShelf();

View file

@ -1,116 +1,90 @@
#region context menu #region data
globalvar CONTEXT_MENU_CALLBACK; globalvar CONTEXT_MENU_CALLBACK;
CONTEXT_MENU_CALLBACK = ds_map_create(); CONTEXT_MENU_CALLBACK = ds_map_create();
#endregion
function menuCall(menu_id = "", _x = mouse_mx + ui(4), _y = mouse_my + ui(4), menu = [], align = fa_left, context = noone) {
var dia = dialogCall(o_dialog_menubox, _x, _y);
if(menu_id != "" && ds_map_exists(CONTEXT_MENU_CALLBACK, menu_id)) {
var callbacks = CONTEXT_MENU_CALLBACK[? menu_id];
for( var i = 0, n = array_length(callbacks); i < n; i++ )
array_append(menu, callbacks[i].populate());
}
dia.menu_id = menu_id;
dia.context = context;
dia.setMenu(menu, align);
return dia;
}
function pieMenuCall(menu_id = "", _x = mouse_mx, _y = mouse_my, menu = [], context = noone) {
var dia = instance_create(_x, _y, o_pie_menu);
if(menu_id != "" && ds_map_exists(CONTEXT_MENU_CALLBACK, menu_id)) {
var callbacks = CONTEXT_MENU_CALLBACK[? menu_id];
for( var i = 0, n = array_length(callbacks); i < n; i++ )
array_append(menu, callbacks[i].populate());
}
dia.menu_id = menu_id;
dia.context = context;
dia.setMenu(menu);
return dia;
}
function submenuCall(_data, menu = []) { function menuCall(menu_id = "", _x = mouse_mx + ui(4), _y = mouse_my + ui(4), menu = [], align = fa_left, context = noone) {
var dia = instance_create_depth(_data.x - ui(4), _data.y, _data.depth - 1, o_dialog_menubox); var dia = dialogCall(o_dialog_menubox, _x, _y);
dia.context = _data.context; if(menu_id != "" && ds_map_exists(CONTEXT_MENU_CALLBACK, menu_id)) {
dia.setMenu(menu); var callbacks = CONTEXT_MENU_CALLBACK[? menu_id];
if(_data.x - ui(4) + dia.dialog_w > WIN_W - ui(2)) for( var i = 0, n = array_length(callbacks); i < n; i++ )
dia.dialog_x = _data._x - dia.dialog_w + ui(4); array_append(menu, callbacks[i].populate());
return dia;
} }
function fileNameCall(path, onModify, _x = mouse_mx + 8, _y = mouse_my + 8) { dia.menu_id = menu_id;
var dia = dialogCall(o_dialog_file_name, _x, _y); dia.context = context;
dia.onModify = onModify; dia.setMenu(menu, align);
dia.path = string_trim_end(path, [ "\\", "/" ]) + "/"; return dia;
}
return dia;
}
function menuItem(name, func, spr = noone, hotkey = noone, toggle = noone, params = {}) {
INLINE
return new MenuItem(name, func, spr, hotkey, toggle, params);
}
function MenuItem(name, func, spr = noone, hotkey = noone, toggle = noone, params = {}) constructor {
active = true;
self.name = name;
self.func = func;
self.spr = spr;
self.hotkey = hotkey;
self.toggle = toggle;
self.params = params;
color = c_white;
isShelf = false;
shelfObject = noone;
shiftMenu = noone;
static setIsShelf = function() {
INLINE
isShelf = true;
return self;
}
static setActive = function(active) {
INLINE
self.active = active;
return self;
}
static setColor = function(color) {
INLINE
self.color = color;
return self;
}
static setShiftMenu = function(shiftMenu) {
INLINE
self.shiftMenu = shiftMenu;
return self;
}
static deactivate = function() {
INLINE
active = false;
return self;
}
}
function menuItemGroup(name, group) { function pieMenuCall(menu_id = "", _x = mouse_mx, _y = mouse_my, menu = [], context = noone) {
return new MenuItemGroup(name, group); var dia = instance_create(_x, _y, o_pie_menu);
if(menu_id != "" && ds_map_exists(CONTEXT_MENU_CALLBACK, menu_id)) {
var callbacks = CONTEXT_MENU_CALLBACK[? menu_id];
for( var i = 0, n = array_length(callbacks); i < n; i++ )
array_append(menu, callbacks[i].populate());
} }
function MenuItemGroup(name, group) constructor { dia.menu_id = menu_id;
active = true; dia.context = context;
self.name = name; dia.setMenu(menu);
self.group = group; return dia;
}
spacing = ui(36);
} function submenuCall(_data, menu = []) {
#endregion 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;
}
function fileNameCall(path, onModify, _x = mouse_mx + 8, _y = mouse_my + 8) {
var dia = dialogCall(o_dialog_file_name, _x, _y);
dia.onModify = onModify;
dia.path = string_trim_end(path, [ "\\", "/" ]) + "/";
return dia;
}
function menuItem(name, func, spr = noone, hotkey = noone, toggle = noone, params = {}) { return new MenuItem(name, func, spr, hotkey, toggle, params); }
function menuItemAction(name, func, spr = noone, toggle = noone) { return new MenuItem(name, func, spr, struct_try_get(ACTION_MAP, func, noone), toggle); }
function MenuItem(_name, _func, _spr = noone, _hotkey = noone, _toggle = noone, _params = {}) constructor {
active = true;
name = _name;
func = _func;
spr = _spr;
hotkey = _hotkey;
toggle = _toggle;
params = _params;
color = c_white;
isShelf = false;
shelfObject = noone;
shiftMenu = noone;
hoykeyObject = noone;
static deactivate = function() /*=>*/ { INLINE active = false; return self; }
static setIsShelf = function() /*=>*/ { INLINE isShelf = true; return self; }
static setActive = function(_active) /*=>*/ { INLINE active = _active; return self; }
static setColor = function(_color) /*=>*/ { INLINE color = _color; return self; }
static setShiftMenu = function(_shiftMenu) /*=>*/ { INLINE shiftMenu = _shiftMenu; return self; }
}
function menuItemGroup(_name, _group) { return new MenuItemGroup(_name, _group); }
function MenuItemGroup(_name, _group) constructor {
active = true;
name = _name;
group = _group;
hotkey = noone;
spacing = ui(36);
}

View file

@ -482,12 +482,12 @@ function curveBox(_onModify) : widget() constructor {
[ [THEME.curve_presets, 3], function() { onModify(CURVE_DEF_10); } ], [ [THEME.curve_presets, 3], function() { onModify(CURVE_DEF_10); } ],
]), ]),
-1, -1,
menuItem(__txt("Reset View"), function() { menuItemAction(__txt("Reset View"), function() {
minx = 0; maxx = 1; minx = 0; maxx = 1;
miny = 0; maxy = 1; miny = 0; maxy = 1;
}), }),
menuItem(grid_show? __txt("Hide grid") : __txt("Show grid"), function() { grid_show = !grid_show; }), menuItemAction(grid_show? __txt("Hide grid") : __txt("Show grid"), function() { grid_show = !grid_show; }),
menuItem(__txt("Snap to grid"), function() { grid_snap = !grid_snap; },,, function() { return grid_snap } ), menuItemAction(__txt("Snap to grid"), function() { grid_snap = !grid_snap; },,, function() { return grid_snap } ),
menuItemGroup(__txt("Grid size"), [ menuItemGroup(__txt("Grid size"), [
[ "1%", function() { grid_step = 0.01; } ], [ "1%", function() { grid_step = 0.01; } ],
[ "5%", function() { grid_step = 0.05; } ], [ "5%", function() { grid_step = 0.05; } ],

View file

@ -11,41 +11,38 @@
} }
function __fnInit() { function __fnInit() {
globalvar CMD_FUNCTIONS; globalvar CMD_FUNCTIONS, ACTION_MAP;
CMD_FUNCTIONS = {}; CMD_FUNCTIONS = {};
ACTION_MAP = {};
__registerFunction("new", NEW);
__registerFunction("save", SAVE_AT, [ ARG("project", function() { return PROJECT; }, true), ARG("path", ""), ARG("log", "save at ") ]);
__registerFunction("load", LOAD_AT, [ ARG("path", ""), ARG("readonly", false), ARG("override", false) ]);
__registerFunction("close", closeProject, [ ARG("project", function() { return PROJECT; }, true) ]);
__registerFunction("append", APPEND, [ ARG("path", ""), ARG("context", function() { return PANEL_GRAPH.getCurrentContext(); }, true) ]);
__registerFunction("undo", UNDO);
__registerFunction("redo", REDO);
__registerFunction("exit", window_close);
__fnInit_Global(); __fnInit_Global();
__fnInit_Preview(); __fnInit_Preview();
__fnInit_Inspector(); __fnInit_Inspector();
__fnInit_Animation(); __fnInit_Animation();
__fnInit_Graph(); __fnInit_Graph();
__fnInit_Collection();
} }
#endregion #endregion
function __registerFunction(name, fn, args = []) { #region function registerFunction(_context, _name, _key, _mod, _action, _args = []) {
INLINE addHotkey(_context, _name, _key, _mod, _action);
CMD_FUNCTIONS[$ name] = { fn, args };
} #endregion var _fnName = _context == ""? _name : $"{_context} {_name}";
_fnName = string_to_var(_fnName);
CMD_FUNCTIONS[$ _fnName] = { _action, _args };
ACTION_MAP[$ _action] = [ _context, _name ];
}
function callStatusFunction(name) { #region function callStatusFunction(name) {
INLINE INLINE
var command = $"{name} {string_join_ext(",", _args)}"; var command = $"{name} {string_join_ext(",", _args)}";
array_push(CMD, cmdLine(command, COLORS._main_text_sub)); array_push(CMD, cmdLine(command, COLORS._main_text_sub));
array_push(CMDIN, command); array_push(CMDIN, command);
} #endregion }
function callFunction(name, args) { #region function callFunction(name, args) {
INLINE INLINE
var _f = CMD_FUNCTIONS[$ name]; var _f = CMD_FUNCTIONS[$ name];
@ -71,5 +68,5 @@ function callFunction(name, args) { #region
} }
return true; return true;
} #endregion }

View file

@ -24,9 +24,9 @@
globalvar CMD, CMDIN; globalvar CMD, CMDIN;
globalvar FPS_REAL; globalvar FPS_REAL;
OS = os_type; OS = os_type;
CMD = []; CMD = [];
CMDIN = []; CMDIN = [];
FPS_REAL = 0; FPS_REAL = 0;
DEBUG = false; DEBUG = false;
@ -39,7 +39,7 @@
LATEST_VERSION = 11700; LATEST_VERSION = 11700;
VERSION = 11790; VERSION = 11790;
SAVE_VERSION = 11700; SAVE_VERSION = 11700;
VERSION_STRING = "1.17.10.002"; VERSION_STRING = "1.17.10.003";
BUILD_NUMBER = 11790; BUILD_NUMBER = 11790;
HOTKEYS = ds_map_create(); HOTKEYS = ds_map_create();
@ -54,15 +54,16 @@
#endregion #endregion
#region input #region input
globalvar FOCUS, FOCUS_STR, HOVER, HOVERING_ELEMENT, _HOVERING_ELEMENT; globalvar FOCUS, FOCUS_STR, FOCUS_CONTENT, HOVER, HOVERING_ELEMENT, _HOVERING_ELEMENT;
globalvar DOUBLE_CLICK, DOUBLE_CLICK_POS; globalvar DOUBLE_CLICK, DOUBLE_CLICK_POS;
globalvar DIALOG_CLICK; globalvar DIALOG_CLICK;
DOUBLE_CLICK_POS = [ 0, 0 ]; DOUBLE_CLICK_POS = [ 0, 0 ];
DOUBLE_CLICK = false; DOUBLE_CLICK = false;
FOCUS = noone; FOCUS = noone;
FOCUS_STR = ""; FOCUS_CONTENT = noone;
FOCUS_STR = "";
HOVER = noone; HOVER = noone;
HOVERING_ELEMENT = noone; HOVERING_ELEMENT = noone;
@ -178,19 +179,59 @@
#endregion #endregion
#region functions #region functions
function __fnInit_Global() { function global_fullscreen() { CALL("fullscreen"); winMan_setFullscreen(!window_is_fullscreen); }
__registerFunction("fullscreen", global_fullscreen); function global_project_close() { CALL("close_project"); PANEL_GRAPH.close(); }
__registerFunction("render_all", global_render_all); function global_project_close_all() { CALL("close_project_all"); for( var i = array_length(PROJECTS) - 1; i >= 0; i-- ) closeProject(PROJECTS[i]); }
__registerFunction("project_close", global_project_close); function global_theme_reload() { CALL("reload_theme"); loadGraphic(PREFERENCES.theme); resetPanel(); }
__registerFunction("theme_reload", global_theme_reload); function global_render_all() { CALL("render_all"); RENDER_ALL_REORDER }
function global_export_all() {
for (var i = 0, n = array_length(PROJECT.allNodes); i < n; i++) {
var node = PROJECT.allNodes[i];
if(!node.active) continue;
if(instanceof(node) != "Node_Export") continue;
node.doInspectorAction();
}
} }
function global_fullscreen() { CALL("fullscreen"); winMan_setFullscreen(!window_is_fullscreen); } function __fnInit_Global() {
function global_render_all() { CALL("render_all"); RENDER_ALL_REORDER } registerFunction("", "New file", "N", MOD_KEY.ctrl, NEW);
function global_project_close() { CALL("project_close"); PANEL_GRAPH.close(); }
if(!DEMO) {
registerFunction("", "Save", "S", MOD_KEY.ctrl, SAVE);
registerFunction("", "Save as", "S", MOD_KEY.ctrl | MOD_KEY.shift, SAVE_AS);
registerFunction("", "Save at", "", MOD_KEY.none, SAVE_AT, [ ARG("project", function() { return PROJECT; }, true), ARG("path", ""), ARG("log", "save at ") ]);
registerFunction("", "Save all", "S", MOD_KEY.ctrl | MOD_KEY.alt, SAVE_ALL);
registerFunction("", "Open", "O", MOD_KEY.ctrl, LOAD);
registerFunction("", "Open Safe", "", MOD_KEY.none, LOAD_SAFE);
registerFunction("", "Open at", "", MOD_KEY.none, LOAD_AT, [ ARG("path", ""), ARG("readonly", false), ARG("override", false) ]);
registerFunction("", "Append", "", MOD_KEY.none, APPEND, [ ARG("path", ""), ARG("context", function() { return PANEL_GRAPH.getCurrentContext(); }, true) ]);
registerFunction("", "Import .zip", "", MOD_KEY.none, __IMPORT_ZIP);
registerFunction("", "Export .zip", "", MOD_KEY.none, __EXPORT_ZIP);
}
registerFunction("", "Undo", "Z", MOD_KEY.ctrl, UNDO);
registerFunction("", "Redo", "Z", MOD_KEY.ctrl | MOD_KEY.shift, REDO);
registerFunction("", "Full panel", "`", MOD_KEY.none, set_focus_fullscreen);
registerFunction("", "Reset layout", vk_f10, MOD_KEY.ctrl, resetPanel);
registerFunction("", "Open notification", vk_f12, MOD_KEY.none, function() /*=>*/ { dialogPanelCall(new Panel_Notification()); });
registerFunction("", "Fullscreen", vk_f11, MOD_KEY.none, global_fullscreen);
registerFunction("", "Render all", vk_f5, MOD_KEY.none, global_render_all);
registerFunction("", "Export all", "", MOD_KEY.none, global_export_all);
registerFunction("", "Close file", "Q", MOD_KEY.ctrl, global_project_close);
registerFunction("", "Close all files", "", MOD_KEY.none, global_project_close_all);
registerFunction("", "Close program", vk_f4, MOD_KEY.alt, window_close);
registerFunction("", "Close project", "", MOD_KEY.none, closeProject, [ ARG("project", function() { return PROJECT; }, true) ]);
registerFunction("", "Reload theme", vk_f10, MOD_KEY.ctrl | MOD_KEY.shift, global_theme_reload);
}
function global_theme_reload() { CALL("theme_reload"); loadGraphic(PREFERENCES.theme); resetPanel(); }
#endregion #endregion
#region debug #region debug

View file

@ -287,6 +287,8 @@ function gradientObject(color = c_black) constructor {
var _time = s.keys[i].time; var _time = s.keys[i].time;
var _value = s.keys[i].value; var _value = s.keys[i].value;
if(LOADING_VERSION < 11660) _value = cola(_value);
keys[i] = new gradientKey(_time, _value); keys[i] = new gradientKey(_time, _value);
} }

View file

@ -1,177 +1,242 @@
#region globalvar HOTKEYS_CUSTOM;
globalvar HOTKEYS_CUSTOM;
function __initHotKey() {
HOTKEYS_CUSTOM = {
"Node_Canvas": {
"Selection": new hotkeySimple("S"),
"Magic Selection": new hotkeySimple("W"),
"Pencil": new hotkeySimple("B"),
"Eraser": new hotkeySimple("E"),
"Rectangle": new hotkeySimple("N"),
"Ellipse": new hotkeySimple("M"),
"Iso Cube": new hotkeySimple(""),
"Curve": new hotkeySimple(""),
"Freeform": new hotkeySimple("Q"),
"Fill": new hotkeySimple("G"),
"Outline": new hotkeySimple("O", MOD_KEY.alt),
"Extrude": new hotkeySimple("E", MOD_KEY.alt),
"Inset": new hotkeySimple("I", MOD_KEY.alt),
"Skew": new hotkeySimple("S", MOD_KEY.alt),
"Corner": new hotkeySimple("C", MOD_KEY.alt),
},
"Node_Mesh_Warp": {
"Edit control point": new hotkeySimple("V"),
"Pin mesh": new hotkeySimple("P"),
"Mesh edit": new hotkeySimple("M"),
"Anchor remove": new hotkeySimple("E"),
},
"Node_Armature": {
"Move": new hotkeySimple("V"),
"Scale": new hotkeySimple("S"),
"Add bones": new hotkeySimple("A"),
"Remove bones": new hotkeySimple("E"),
"Detach bones": new hotkeySimple("D"),
"IK": new hotkeySimple("K"),
},
"Node_Path": {
"Transform": new hotkeySimple("T"),
"Anchor add / remove": new hotkeySimple("A"),
"Edit Control point": new hotkeySimple("C"),
"Draw path": new hotkeySimple("B"),
"Rectangle path": new hotkeySimple("N"),
"Circle path": new hotkeySimple("M"),
},
"Node_Rigid_Object": {
"Mesh edit": new hotkeySimple("A"),
"Anchor remove": new hotkeySimple("E"),
},
"Node_Strand_Create": {
"Push": new hotkeySimple("P"),
"Comb": new hotkeySimple("C"),
"Stretch": new hotkeySimple("S"),
"Shorten": new hotkeySimple("D"),
"Grab": new hotkeySimple("G"),
},
"Node_Path_Anchor": {
"Adjust control point": new hotkeySimple("A"),
},
"Node_3D_Object": {
"Transform": new hotkeySimple("G"),
"Rotate": new hotkeySimple("R"),
"Scale": new hotkeySimple("S"),
},
"Node_3D_Camera": {
"Move Target": new hotkeySimple("T"),
},
};
}
function getToolHotkey(_group, _key) {
INLINE
if(!struct_has(HOTKEYS_CUSTOM, _group)) return noone;
var _grp = HOTKEYS_CUSTOM[$ _group];
if(!struct_has(_grp, _key)) return noone;
return _grp[$ _key];
}
#endregion
#region hotkeys function __initHotKey() {
function hotkeySimple(_key, modi = MOD_KEY.none) constructor { HOTKEYS_CUSTOM = {
self.key = key_get_index(_key); "Node_Canvas": {
self.modi = modi; "Selection": new hotkeySimple("S"),
"Magic Selection": new hotkeySimple("W"),
"Pencil": new hotkeySimple("B"),
"Eraser": new hotkeySimple("E"),
"Rectangle": new hotkeySimple("N"),
"Ellipse": new hotkeySimple("M"),
"Iso Cube": new hotkeySimple(""),
"Curve": new hotkeySimple(""),
"Freeform": new hotkeySimple("Q"),
"Fill": new hotkeySimple("G"),
"Outline": new hotkeySimple("O", MOD_KEY.alt),
"Extrude": new hotkeySimple("E", MOD_KEY.alt),
"Inset": new hotkeySimple("I", MOD_KEY.alt),
"Skew": new hotkeySimple("S", MOD_KEY.alt),
"Corner": new hotkeySimple("C", MOD_KEY.alt),
},
dKey = key; "Node_Mesh_Warp": {
dModi = modi; "Edit control point": new hotkeySimple("V"),
"Pin mesh": new hotkeySimple("P"),
"Mesh edit": new hotkeySimple("M"),
"Anchor remove": new hotkeySimple("E"),
},
static isPressing = function() { "Node_Armature": {
if(is_string(key)) key = key_get_index(key); "Move": new hotkeySimple("V"),
return key == noone? false : key_press(key, modi); "Scale": new hotkeySimple("S"),
} "Add bones": new hotkeySimple("A"),
"Remove bones": new hotkeySimple("E"),
"Detach bones": new hotkeySimple("D"),
"IK": new hotkeySimple("K"),
},
static getName = function() { "Node_Path": {
if(is_string(key)) key = key_get_index(key); "Transform": new hotkeySimple("T"),
return key_get_name(key, modi); "Anchor add / remove": new hotkeySimple("A"),
"Edit Control point": new hotkeySimple("C"),
"Draw path": new hotkeySimple("B"),
"Rectangle path": new hotkeySimple("N"),
"Circle path": new hotkeySimple("M"),
},
"Node_Rigid_Object": {
"Mesh edit": new hotkeySimple("A"),
"Anchor remove": new hotkeySimple("E"),
},
"Node_Strand_Create": {
"Push": new hotkeySimple("P"),
"Comb": new hotkeySimple("C"),
"Stretch": new hotkeySimple("S"),
"Shorten": new hotkeySimple("D"),
"Grab": new hotkeySimple("G"),
},
"Node_Path_Anchor": {
"Adjust control point": new hotkeySimple("A"),
},
"Node_3D_Object": {
"Transform": new hotkeySimple("G"),
"Rotate": new hotkeySimple("R"),
"Scale": new hotkeySimple("S"),
},
"Node_3D_Camera": {
"Move Target": new hotkeySimple("T"),
},
};
}
function getToolHotkey(_group, _key) {
INLINE
if(!struct_has(HOTKEYS_CUSTOM, _group)) return noone;
var _grp = HOTKEYS_CUSTOM[$ _group];
if(!struct_has(_grp, _key)) return noone;
return _grp[$ _key];
}
function hotkeySimple(_key, modi = MOD_KEY.none) constructor {
self.key = key_get_index(_key);
self.modi = modi;
dKey = key;
dModi = modi;
static isPressing = function() {
if(is_string(key)) key = key_get_index(key);
return key == noone? false : key_press(key, modi);
}
static getName = function() {
if(is_string(key)) key = key_get_index(key);
return key_get_name(key, modi);
}
}
function hotkeyObject(_context, _name, _key, _mod = MOD_KEY.none, _action = noone) constructor {
context = _context;
name = _name;
key = _key;
modi = _mod;
action = _action;
dKey = _key;
dModi = _mod;
static serialize = function() { return { context, name, key, modi }; }
static deserialize = function(ll) {
key = is_struct(ll)? ll.key : ll[2];
modi = is_struct(ll)? ll.modi : ll[3];
}
var _loadKey = $"{context}_{name}";
if(struct_has(HOTKEYS_DATA, _loadKey))
deserialize(HOTKEYS_DATA[$ _loadKey]);
}
function addHotkey(_context, _name, _key, _mod, _action) {
if(is_string(_key)) _key = key_get_index(_key);
var key = new hotkeyObject(_context, _name, _key, _mod, _action);
if(!ds_map_exists(HOTKEYS, _context)) {
HOTKEYS[? _context] = ds_list_create();
if(!ds_list_exist(HOTKEY_CONTEXT, _context))
ds_list_add(HOTKEY_CONTEXT, _context);
}
for(var i = 0; i < ds_list_size(HOTKEYS[? _context]); i++) {
var hotkey = HOTKEYS[? _context][| i];
if(hotkey.name == key.name) {
delete HOTKEYS[? _context][| i];
HOTKEYS[? _context][| i] = key;
return;
} }
} }
function hotkeyObject(_context, _name, _key, _mod = MOD_KEY.none, _action = noone) constructor { if(_context == "") ds_list_insert(HOTKEYS[? _context], 0, key);
context = _context; else ds_list_add(HOTKEYS[? _context], key);
name = _name; }
key = _key;
modi = _mod; function find_hotkey(_context, _name) {
action = _action; if(!ds_map_exists(HOTKEYS, _context)) return noone;
dKey = _key;
dModi = _mod;
static serialize = function() { return { context, name, key, modi }; }
static deserialize = function(ll) {
key = is_struct(ll)? ll.key : ll[2];
modi = is_struct(ll)? ll.modi : ll[3];
}
var _loadKey = $"{context}_{name}";
if(struct_has(HOTKEYS_DATA, _loadKey))
deserialize(HOTKEYS_DATA[$ _loadKey]);
}
function addHotkey(_context, _name, _key, _mod, _action) { for(var j = 0; j < ds_list_size(HOTKEYS[? _context]); j++) {
if(is_string(_key)) _key = key_get_index(_key); if(HOTKEYS[? _context][| j].name == _name)
return HOTKEYS[? _context][| j];
}
}
function hotkey_editing(hotkey) {
static vk_list = [
vk_left, vk_right, vk_up, vk_down, vk_space, vk_backspace, vk_tab, vk_home, vk_end, vk_delete, vk_insert,
vk_pageup, vk_pagedown, vk_pause, vk_printscreen,
vk_f1, vk_f2, vk_f3, vk_f4, vk_f5, vk_f6, vk_f7, vk_f8, vk_f9, vk_f10, vk_f11, vk_f12,
];
var _mod_prs = 0;
if(keyboard_check(vk_control)) _mod_prs |= MOD_KEY.ctrl;
if(keyboard_check(vk_shift)) _mod_prs |= MOD_KEY.shift;
if(keyboard_check(vk_alt)) _mod_prs |= MOD_KEY.alt;
if(keyboard_check_pressed(vk_escape)) {
hotkey.key = 0;
hotkey.modi = 0;
var key = new hotkeyObject(_context, _name, _key, _mod, _action); PREF_SAVE();
if(!ds_map_exists(HOTKEYS, _context)) { } else if(keyboard_check_pressed(vk_anykey)) {
HOTKEYS[? _context] = ds_list_create(); hotkey.modi = _mod_prs;
if(!ds_list_exist(HOTKEY_CONTEXT, _context)) hotkey.key = 0;
ds_list_add(HOTKEY_CONTEXT, _context); var press = false;
for(var a = 0; a < array_length(vk_list); a++) {
if(!keyboard_check_pressed(vk_list[a])) continue;
hotkey.key = vk_list[a];
press = true;
break;
} }
for(var i = 0; i < ds_list_size(HOTKEYS[? _context]); i++) { if(!press) {
var hotkey = HOTKEYS[? _context][| i]; var k = ds_map_find_first(global.KEY_STRING_MAP);
if(hotkey.name == key.name) { var amo = ds_map_size(global.KEY_STRING_MAP);
delete HOTKEYS[? _context][| i]; repeat(amo) {
HOTKEYS[? _context][| i] = key; if(!keyboard_check_pressed(k)) {
return; k = ds_map_find_next(global.KEY_STRING_MAP, k);
continue;
}
hotkey.key = k;
press = true;
break;
} }
} }
if(_context == "") ds_list_insert(HOTKEYS[? _context], 0, key); PREF_SAVE();
else ds_list_add(HOTKEYS[? _context], key);
} }
}
function find_hotkey(_context, _name) { #region
if(!ds_map_exists(HOTKEYS, _context)) return noone;
for(var j = 0; j < ds_list_size(HOTKEYS[? _context]); j++) {
if(HOTKEYS[? _context][| j].name == _name)
return HOTKEYS[? _context][| j];
}
} #endregion
#endregion
function hotkey_draw(keyStr, _x, _y) { function hotkey_draw(keyStr, _x, _y, _status = 0) {
if(keyStr == "") return; if(keyStr == "") return;
draw_set_text(f_p1, fa_right, fa_center, COLORS._main_text_sub); var bc = c_white;
var tc = c_white;
switch(_status) {
case 0 :
bc = CDEF.main_dkgrey;
tc = COLORS._main_text_sub;
break;
case 1 :
bc = CDEF.main_ltgrey;
tc = CDEF.main_ltgrey;
break;
case 2 :
bc = COLORS._main_accent;
tc = COLORS._main_text_accent;
break;
}
draw_set_text(f_p1, fa_right, fa_center, tc);
var _tw = string_width( keyStr); var _tw = string_width( keyStr);
var _th = string_height(keyStr); var _th = string_height(keyStr);
draw_sprite_stretched_ext(THEME.ui_panel, 1, _x - _tw - ui(4), _y - _th / 2 - ui(3), _tw + ui(8), _th + ui(3), COLORS._main_text_sub, 0.5); draw_sprite_stretched_ext(THEME.ui_panel, 1, _x - _tw - ui(4), _y - _th / 2 - ui(3), _tw + ui(8), _th + ui(3), bc);
draw_text(_x, _y, keyStr); draw_text(_x, _y, keyStr);
} }

View file

@ -5,6 +5,8 @@ function __loadParams(readonly = false, override = false, apply_layout = false)
self.apply_layout = apply_layout; self.apply_layout = apply_layout;
} }
function LOAD_SAFE() { LOAD(true); }
function LOAD(safe = false) { function LOAD(safe = false) {
if(DEMO) return false; if(DEMO) return false;
@ -271,7 +273,8 @@ function LOAD_AT(path, params = new __loadParams()) { #region
return true; return true;
} #endregion } #endregion
function __IMPORT_ZIP() { #region function __EXPORT_ZIP() { exportPortable(PROJECT); }
function __IMPORT_ZIP() {
var path = get_open_filename_pxc("Pixel Composer portable project (.zip)|*.zip", ""); var path = get_open_filename_pxc("Pixel Composer portable project (.zip)|*.zip", "");
var _fname = filename_name_only(path); var _fname = filename_name_only(path);
@ -289,4 +292,4 @@ function __IMPORT_ZIP() { #region
if(!file_exists_empty(_proj)) return false; if(!file_exists_empty(_proj)) return false;
LOAD_PATH(_proj, true); LOAD_PATH(_proj, true);
} #endregion }

View file

@ -4,7 +4,7 @@ function Node_3D_Mesh_Export(_x, _y, _group = noone) : Node(_x, _y, _group) cons
inputs[0] = nodeValue_D3Mesh("Mesh", self, noone) inputs[0] = nodeValue_D3Mesh("Mesh", self, noone)
.setVisible(true, true); .setVisible(true, true);
inputs[1] = nodeValue_Text("Paths", self, "") inputs[1] = nodeValue_Path("Paths", self, "")
.setDisplay(VALUE_DISPLAY.path_save, { filter: "Obj (.obj)|*.obj" }) .setDisplay(VALUE_DISPLAY.path_save, { filter: "Obj (.obj)|*.obj" })
.setVisible(true); .setVisible(true);

View file

@ -25,7 +25,7 @@ function Node_3D_Mesh_Obj(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group)
object = noone; object = noone;
object_class = __3dObject; object_class = __3dObject;
inputs[in_mesh + 0] = nodeValue_Text("File Path", self, "" ) inputs[in_mesh + 0] = nodeValue_Path("File Path", self, "" )
.setDisplay(VALUE_DISPLAY.path_load, { filter: "3d object|*.obj" }) .setDisplay(VALUE_DISPLAY.path_load, { filter: "3d object|*.obj" })
.rejectArray(); .rejectArray();

View file

@ -29,7 +29,7 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
w = 128; w = 128;
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_load, { filter: "Aseprite file|*.ase;*.aseprite" }); .setDisplay(VALUE_DISPLAY.path_load, { filter: "Aseprite file|*.ase;*.aseprite" });
inputs[1] = nodeValue_Trigger("Generate layers", self, false ) inputs[1] = nodeValue_Trigger("Generate layers", self, false )

View file

@ -4,7 +4,7 @@ function Node_Byte_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
w = 128; w = 128;
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_load, { filter: "any file|*" }) .setDisplay(VALUE_DISPLAY.path_load, { filter: "any file|*" })
.rejectArray(); .rejectArray();

View file

@ -4,7 +4,7 @@ function Node_Byte_File_Write(_x, _y, _group = noone) : Node(_x, _y, _group) con
w = 128; w = 128;
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_save, { filter: "any file|*" }) .setDisplay(VALUE_DISPLAY.path_save, { filter: "any file|*" })
.rejectArray(); .rejectArray();

View file

@ -29,7 +29,7 @@ function Node_CSV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
w = 128; w = 128;
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_load, { filter: "CSV file|*.csv" }) .setDisplay(VALUE_DISPLAY.path_load, { filter: "CSV file|*.csv" })
.rejectArray(); .rejectArray();

View file

@ -14,7 +14,7 @@ function Node_CSV_File_Write(_x, _y, _group = noone) : Node(_x, _y, _group) cons
w = 128; w = 128;
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_save, { filter: "csv file|*.csv" }) .setDisplay(VALUE_DISPLAY.path_save, { filter: "csv file|*.csv" })
.rejectArray(); .rejectArray();

View file

@ -637,14 +637,11 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
NODE_SET_INPUT_SIZE NODE_SET_INPUT_SIZE
w = SHOW_PARAM? attributes.node_param_width : min_w; w = SHOW_PARAM? attributes.node_param_width : min_w;
if(!auto_height) return; if(!auto_height) return;
var _ss = getGraphPreviewSurface(); var _ss = getGraphPreviewSurface();
var _ps = is_surface(_ss); var _ps = is_surface(_ss);
var _ou = preview_channel >= 0 && preview_channel < output_list_size && outputs[preview_channel].type == VALUE_TYPE.surface; var _ou = preview_channel >= 0 && preview_channel < output_list_size && outputs[preview_channel].type == VALUE_TYPE.surface;
// print($"{previewable} && {preview_draw} && ([{_ss}] {_ps} || {_ou})");
var _prev_surf = previewable && preview_draw && (_ps || _ou); var _prev_surf = previewable && preview_draw && (_ps || _ou);
junction_draw_hei_y = SHOW_PARAM? 32 : 24; junction_draw_hei_y = SHOW_PARAM? 32 : 24;
@ -653,8 +650,13 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
var _hi, _ho; var _hi, _ho;
if(previewable) { if(previewable) {
_hi = junction_draw_pad_y + SHOW_PARAM * 4; _hi = junction_draw_pad_y;
_ho = junction_draw_pad_y + SHOW_PARAM * 4; _ho = junction_draw_pad_y;
if(SHOW_PARAM) {
_hi = con_h;
_ho = con_h;
}
} else { } else {
junction_draw_hei_y = 16; junction_draw_hei_y = 16;
@ -1183,14 +1185,24 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
in_cache_len = array_length(inputDisplayList); in_cache_len = array_length(inputDisplayList);
out_cache_len = output_list_size; out_cache_len = output_list_size;
} }
var _iny = yy + (junction_draw_pad_y + junction_draw_hei_y * 0.5 * SHOW_PARAM) * _s; var _junRy = junction_draw_pad_y;
var rx = x, ry = y + junction_draw_pad_y + junction_draw_hei_y * 0.5 * SHOW_PARAM; var _junSy = yy + _junRy * _s;
if(SHOW_PARAM) {
_junRy = con_h + junction_draw_hei_y / 2;
_junSy = yy + _junRy * _s;
}
var _ix = xx;
var _iy = _junSy;
var rx = x;
var ry = y + _junRy;
for( var i = 0, n = input_list_size; i < n; i++ ) { for( var i = 0, n = input_list_size; i < n; i++ ) {
jun = inputs[i]; jun = inputs[i];
jun.x = xx; jun.x = _ix;
jun.y = _iny; jun.y = _iy;
jun.rx = rx; jun.rx = rx;
jun.ry = ry; jun.ry = ry;
@ -1199,26 +1211,28 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
for(var i = 0; i < in_cache_len; i++) { for(var i = 0; i < in_cache_len; i++) {
jun = inputDisplayList[i]; jun = inputDisplayList[i];
jun.x = xx; jun.x = _ix;
jun.y = _iny; jun.y = _iy;
_iny += junction_draw_hei_y * _s; _iy += junction_draw_hei_y * _s;
jun.rx = rx; jun.rx = rx;
jun.ry = ry; jun.ry = ry;
ry += junction_draw_hei_y; ry += junction_draw_hei_y;
} }
xx = xx + w * _s; var _ox = xx + w * _s;
var _outy = yy + (junction_draw_pad_y + junction_draw_hei_y * 0.5 * SHOW_PARAM) * _s; var _oy = _junSy;
var rx = x + w, ry = y + junction_draw_pad_y + junction_draw_hei_y * 0.5 * SHOW_PARAM; var rx = x + w;
var ry = y + _junRy;
var idx;
for(var i = 0; i < outputs_amount; i++) { for(var i = 0; i < outputs_amount; i++) {
var idx = outputs_index[i]; idx = outputs_index[i];
jun = outputs[idx]; jun = outputs[idx];
jun.x = xx; jun.x = _ox;
jun.y = _outy; jun.y = _oy;
_outy += junction_draw_hei_y * _s * jun.isVisible(); _oy += junction_draw_hei_y * _s * jun.isVisible();
jun.rx = rx; jun.rx = rx;
jun.ry = ry; jun.ry = ry;
@ -1227,7 +1241,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
if(SHOW_PARAM) h = h_param; if(SHOW_PARAM) h = h_param;
onPreDraw(_x, _y, _s, _iny, _outy); onPreDraw(_x, _y, _s, _iy, _oy);
} }
static onPreDraw = function(_x, _y, _s, _iny, _outy) {} static onPreDraw = function(_x, _y, _s, _iny, _outy) {}
@ -1365,7 +1379,8 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
} }
if(jun.value_from || wd == noone) { if(jun.value_from || wd == noone) {
jy += wh; extY += junction_draw_hei_y;
jy += wh;
continue; continue;
} }
@ -1398,7 +1413,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
if(wd.isHovering()) draggable = false; if(wd.isHovering()) draggable = false;
} }
h = con_h + extY + 4; h = con_h + extY + 4;
h_param = h; h_param = h;
} }

View file

@ -26,7 +26,7 @@ function Node_Directory_Search(_x, _y, _group = noone) : Node(_x, _y, _group) co
name = "Directory Search"; name = "Directory Search";
color = COLORS.node_blend_input; color = COLORS.node_blend_input;
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_load, { filter: "dir" }); .setDisplay(VALUE_DISPLAY.path_load, { filter: "dir" });
inputs[1] = nodeValue_Text("Extensions", self, ".png"); inputs[1] = nodeValue_Text("Extensions", self, ".png");

View file

@ -26,7 +26,7 @@ function Node_Display_Image(_x, _y, _group = noone) : Node(_x, _y, _group) const
name = "Display Image"; name = "Display Image";
auto_height = false; auto_height = false;
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setVisible(false) .setVisible(false)
.setDisplay(VALUE_DISPLAY.path_load, { filter: "image|*.png;*.jpg" }) .setDisplay(VALUE_DISPLAY.path_load, { filter: "image|*.png;*.jpg" })
.rejectArray(); .rejectArray();

View file

@ -48,7 +48,7 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
inputs[0] = nodeValue_Surface("Surface", self); inputs[0] = nodeValue_Surface("Surface", self);
inputs[1] = nodeValue_Text("Paths", self, "") inputs[1] = nodeValue_Path("Paths", self, "")
.setDisplay(VALUE_DISPLAY.path_save, _format_still) .setDisplay(VALUE_DISPLAY.path_save, _format_still)
.setVisible(true); .setVisible(true);

View file

@ -26,7 +26,7 @@ function Node_Image(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Image"; name = "Image";
color = COLORS.node_blend_input; color = COLORS.node_blend_input;
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_load, { filter: "image|*.png;*.jpg" }); .setDisplay(VALUE_DISPLAY.path_load, { filter: "image|*.png;*.jpg" });
inputs[1] = nodeValue_Padding("Padding", self, [0, 0, 0, 0]); inputs[1] = nodeValue_Padding("Padding", self, [0, 0, 0, 0]);

View file

@ -38,7 +38,7 @@ function Node_Image_Animated(_x, _y, _group = noone) : Node(_x, _y, _group) cons
update_on_frame = true; update_on_frame = true;
inputs[0] = nodeValue_Text("Path", self, []) inputs[0] = nodeValue_Path("Path", self, [])
.setDisplay(VALUE_DISPLAY.path_array, { filter: ["image|*.png;*.jpg", ""] }); .setDisplay(VALUE_DISPLAY.path_array, { filter: ["image|*.png;*.jpg", ""] });
inputs[1] = nodeValue_Padding("Padding", self, [0, 0, 0, 0]) inputs[1] = nodeValue_Padding("Padding", self, [0, 0, 0, 0])

View file

@ -29,7 +29,7 @@ function Node_Image_gif(_x, _y, _group = noone) : Node(_x, _y, _group) construct
update_on_frame = true; update_on_frame = true;
setAlwaysTimeline(new timelineItemNode_Image_gif(self)); setAlwaysTimeline(new timelineItemNode_Image_gif(self));
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_load, { filter: "Animated gif|*.gif" }); .setDisplay(VALUE_DISPLAY.path_load, { filter: "Animated gif|*.gif" });
inputs[1] = nodeValue_Trigger("Set animation length to gif", self, false ) inputs[1] = nodeValue_Trigger("Set animation length to gif", self, false )

View file

@ -39,7 +39,7 @@ function Node_Image_Sequence(_x, _y, _group = noone) : Node(_x, _y, _group) cons
spr = []; spr = [];
color = COLORS.node_blend_input; color = COLORS.node_blend_input;
inputs[0] = nodeValue_Text("Paths", self, []) inputs[0] = nodeValue_Path("Paths", self, [])
.setDisplay(VALUE_DISPLAY.path_array, { filter: ["image|*.png;*.jpg", ""] }); .setDisplay(VALUE_DISPLAY.path_array, { filter: ["image|*.png;*.jpg", ""] });
inputs[1] = nodeValue_Padding("Padding", self, [0, 0, 0, 0]) inputs[1] = nodeValue_Padding("Padding", self, [0, 0, 0, 0])

View file

@ -29,7 +29,7 @@ function Node_Json_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
w = 128; w = 128;
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_load, { filter: "JSON file|*.json" }) .setDisplay(VALUE_DISPLAY.path_load, { filter: "JSON file|*.json" })
.rejectArray(); .rejectArray();

View file

@ -4,7 +4,7 @@ function Node_Json_File_Write(_x, _y, _group = noone) : Node(_x, _y, _group) con
w = 128; w = 128;
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_save, { filter: "json file|*.json" }) .setDisplay(VALUE_DISPLAY.path_save, { filter: "json file|*.json" })
.rejectArray(); .rejectArray();

View file

@ -158,7 +158,7 @@ function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
var _wig = _data[4]; var _wig = _data[4];
var _sed = _data[5]; var _sed = _data[5];
var _ang = _data[6]; var _ang = _data[6];
var _pat = _data[7]; var _pat = _data[7]; print(_pat);
var _ratio = _data[8]; var _ratio = _data[8];
var _shift = _data[9]; var _shift = _data[9];

View file

@ -3,7 +3,7 @@ function Node_Path_Separate_Folder(_x, _y, _group = noone) : Node_Processor(_x,
setDimension(96, 48); setDimension(96, 48);
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setVisible(true, true); .setVisible(true, true);
inputs[1] = nodeValue_Bool("Keep extension", self, true); inputs[1] = nodeValue_Bool("Keep extension", self, true);

View file

@ -151,9 +151,10 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
#endregion #endregion
for(var l = 0; l < process_amount; l++) { for(var l = 0; l < process_amount; l++) {
__l = l;
_data[i] = array_map(inputs, function(_in, i) /*=>*/ {return all_inputs[i][__l]});
for(var i = input_list_size - 1; i >= 0; i--)
_data[i] = all_inputs[i][l];
if(_output.type == VALUE_TYPE.surface) { #region // Output surface verification if(_output.type == VALUE_TYPE.surface) { #region // Output surface verification
if(manage_atlas) { if(manage_atlas) {
_pAtl = _data[atlas_index]; _pAtl = _data[atlas_index];

View file

@ -2,7 +2,7 @@ function Node_Shell(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Execute Shell"; name = "Execute Shell";
setDimension(96, 32 + 24 * 1); setDimension(96, 32 + 24 * 1);
inputs[0] = nodeValue_Text("Path", self, ""); inputs[0] = nodeValue_Path("Path", self, "");
inputs[1] = nodeValue_Text("Script", self, ""); inputs[1] = nodeValue_Text("Script", self, "");

View file

@ -11,7 +11,7 @@ function Node_SVG(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "SVG"; name = "SVG";
color = COLORS.node_blend_input; color = COLORS.node_blend_input;
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_load, { filter: "Scalable Vector Graphics|*.svg" }); .setDisplay(VALUE_DISPLAY.path_load, { filter: "Scalable Vector Graphics|*.svg" });
inputs[1] = nodeValue_Float("Scale", self, 1); inputs[1] = nodeValue_Float("Scale", self, 1);

View file

@ -29,7 +29,7 @@ function Node_Text_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) cons
w = 128; w = 128;
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_load, { filter: "any file|*" }) .setDisplay(VALUE_DISPLAY.path_load, { filter: "any file|*" })
.rejectArray(); .rejectArray();

View file

@ -4,7 +4,7 @@ function Node_Text_File_Write(_x, _y, _group = noone) : Node(_x, _y, _group) con
w = 128; w = 128;
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_save, { filter: "text file|*.txt" }) .setDisplay(VALUE_DISPLAY.path_save, { filter: "text file|*.txt" })
.rejectArray(); .rejectArray();

View file

@ -370,10 +370,13 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
mappedJunc = noone; mappedJunc = noone;
mapped_vec4 = false; mapped_vec4 = false;
static setMappable = function(index, vec4 = false) { #region static setMappable = function(index, vec4 = false) {
attributes.mapped = false; attributes.mapped = false;
attributes.map_index = index; attributes.map_index = index;
mapped_vec4 = vec4; mapped_vec4 = vec4;
if(arrayLength == arrayLengthSimple)
arrayLength = __arrayLength;
mapButton = button(function() { mapButton = button(function() {
attributes.mapped = !attributes.mapped; attributes.mapped = !attributes.mapped;
@ -405,7 +408,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
editWidget.side_button = mapButton; editWidget.side_button = mapButton;
return self; return self;
} #endregion }
static setMapped = function(junc) { #region static setMapped = function(junc) { #region
mappedJunc = junc; mappedJunc = junc;
@ -1159,7 +1162,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
var val = __curr_get_val[0]; var val = __curr_get_val[0];
var nod = __curr_get_val[1]; var nod = __curr_get_val[1];
var typ = nod == undefined? VALUE_TYPE.any : nod.type; var typ = nod.type;
var dis = nod.display_type; var dis = nod.display_type;
if(connect_type == JUNCTION_CONNECT.output) return val; if(connect_type == JUNCTION_CONNECT.output) return val;
@ -1359,8 +1362,10 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
return __array_get_depth(val) > array_depth + type_array; return __array_get_depth(val) > array_depth + type_array;
} }
__is_array = false; __is_array = false;
static arrayLength = function(val = undefined) { __array_length = -1;
static __arrayLength = function(val = undefined) {
val ??= getValue(); val ??= getValue();
__is_array = false; __is_array = false;
@ -1386,6 +1391,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
return __is_array? array_length(val) : -1; return __is_array? array_length(val) : -1;
} }
arrayLength = __arrayLength;
/////============== SET ============= /////============== SET =============
static onValidate = function() { #region static onValidate = function() { #region

View file

@ -13,7 +13,7 @@ function NodeValue_D3Material(_name, _node, _value, _tooltip = "") : NodeValue(_
var val = __curr_get_val[0]; var val = __curr_get_val[0];
var nod = __curr_get_val[1]; var nod = __curr_get_val[1];
var typ = nod == undefined? VALUE_TYPE.any : nod.type; var typ = nod.type;
var dis = nod.display_type; var dis = nod.display_type;
if(nod == self) if(nod == self)

View file

@ -19,7 +19,7 @@ function NodeValue_Dimension(_node, value) : NodeValue("Dimension", _node, JUNCT
var val = __curr_get_val[0]; var val = __curr_get_val[0];
var nod = __curr_get_val[1]; var nod = __curr_get_val[1];
var typ = nod == undefined? VALUE_TYPE.any : nod.type; var typ = nod.type;
var dis = nod.display_type; var dis = nod.display_type;
if(typ != VALUE_TYPE.surface) { if(typ != VALUE_TYPE.surface) {

View file

@ -9,7 +9,7 @@ function NodeValue_Float(_name, _node, _value, _tooltip = "") : NodeValue(_name,
var val = __curr_get_val[0]; var val = __curr_get_val[0];
var nod = __curr_get_val[1]; var nod = __curr_get_val[1];
var typ = nod == undefined? VALUE_TYPE.any : nod.type; var typ = nod.type;
var dis = nod.display_type; var dis = nod.display_type;
if(typ != VALUE_TYPE.surface) { if(typ != VALUE_TYPE.surface) {

View file

@ -1,7 +1,6 @@
function nodeValue_Gradient(_name, _node, _value, _tooltip = "") { return new NodeValue_Gradient(_name, _node, _value, _tooltip); } function nodeValue_Gradient(_name, _node, _value, _tooltip = "") { return new NodeValue_Gradient(_name, _node, _value, _tooltip); }
function NodeValue_Gradient(_name, _node, _value, _tooltip = "") : NodeValue(_name, _node, JUNCTION_CONNECT.input, VALUE_TYPE.gradient, _value, _tooltip) constructor { function NodeValue_Gradient(_name, _node, _value, _tooltip = "") : NodeValue(_name, _node, JUNCTION_CONNECT.input, VALUE_TYPE.gradient, _value, _tooltip) constructor {
setDisplay(VALUE_DISPLAY.palette);
/////============== GET ============= /////============== GET =============
@ -11,7 +10,7 @@ function NodeValue_Gradient(_name, _node, _value, _tooltip = "") : NodeValue(_na
var nod = __curr_get_val[1]; var nod = __curr_get_val[1];
if(is_instanceof(val, gradientObject)) return val; if(is_instanceof(val, gradientObject)) return val;
if(typeFrom != VALUE_TYPE.color) return val; if(nod.type != VALUE_TYPE.color) return val;
if(is_array(val)) { if(is_array(val)) {
var amo = array_length(val); var amo = array_length(val);

View file

@ -9,7 +9,7 @@ function NodeValue_Int(_name, _node, _value, _tooltip = "") : NodeValue(_name, _
var val = __curr_get_val[0]; var val = __curr_get_val[0];
var nod = __curr_get_val[1]; var nod = __curr_get_val[1];
var typ = nod == undefined? VALUE_TYPE.any : nod.type; var typ = nod.type;
var dis = nod.display_type; var dis = nod.display_type;
if(typ != VALUE_TYPE.surface) { if(typ != VALUE_TYPE.surface) {

View file

@ -4,7 +4,7 @@ function NodeValue_Output(_name, _node, _type, _value, _tooltip = "") : NodeValu
/////============== GET ============= /////============== GET =============
output_value = 0; output_value = _value;
static getValue = function(_time = CURRENT_FRAME, applyUnit = true, arrIndex = 0, useCache = false, log = false) { //// Get value static getValue = function(_time = CURRENT_FRAME, applyUnit = true, arrIndex = 0, useCache = false, log = false) { //// Get value
return output_value; return output_value;

View file

@ -0,0 +1,19 @@
function nodeValue_Path(_name, _node, _value, _tooltip = "") { return new NodeValue_Path(_name, _node, _value, _tooltip); }
function NodeValue_Path(_name, _node, _value, _tooltip = "") : NodeValue(_name, _node, JUNCTION_CONNECT.input, VALUE_TYPE.path, _value, _tooltip) constructor {
/////============== GET =============
static getValue = function(_time = CURRENT_FRAME, applyUnit = true, arrIndex = 0, useCache = false, log = false) { //// Get value
getValueRecursive(self.__curr_get_val, _time);
var val = __curr_get_val[0];
return val;
}
static __getAnimValue = function(_time = CURRENT_FRAME) {
if(is_anim) return animator.getValue(_time);
return array_empty(animator.values)? 0 : animator.values[0].value;
}
static arrayLength = arrayLengthSimple;
}

View file

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

View file

@ -10,7 +10,7 @@ function NodeValue_Quaternion(_name, _node, _value, _tooltip = "") : NodeValue_A
var val = __curr_get_val[0]; var val = __curr_get_val[0];
var nod = __curr_get_val[1]; var nod = __curr_get_val[1];
var typ = nod == undefined? VALUE_TYPE.any : nod.type; var typ = nod.type;
var dis = nod.display_type; var dis = nod.display_type;
if(!is_array(val)) return [ val, val, val, val ]; if(!is_array(val)) return [ val, val, val, val ];

View file

@ -9,7 +9,7 @@ function NodeValue_Rotation(_name, _node, _value, _tooltip = "") : NodeValue(_na
getValueRecursive(self.__curr_get_val, _time); getValueRecursive(self.__curr_get_val, _time);
var val = __curr_get_val[0]; var val = __curr_get_val[0];
var nod = __curr_get_val[1]; var nod = __curr_get_val[1];
var typ = nod == undefined? VALUE_TYPE.any : nod.type; var typ = nod.type;
if(typ == VALUE_TYPE.text) val = toNumber(val); if(typ == VALUE_TYPE.text) val = toNumber(val);
return val; return val;

View file

@ -19,14 +19,20 @@ function NodeValue_Vec2(_name, _node, _value, _data = {}) : NodeValue(_name, _no
var val = __curr_get_val[0]; var val = __curr_get_val[0];
var nod = __curr_get_val[1]; var nod = __curr_get_val[1];
var typ = nod == undefined? VALUE_TYPE.any : nod.type; var typ = nod.type;
var dis = nod.display_type; var dis = nod.display_type;
if(typ != VALUE_TYPE.surface) { if(typ != VALUE_TYPE.surface) {
if(!is_array(val)) val = [ val, val ]; if(!is_array(val)) return [ val, val ];
if(array_length(val) != 2) val = [ array_safe_get_fast(val, 0), array_safe_get_fast(val, 1) ];
return valueProcess(val, nod, applyUnit, arrIndex); var _d = array_get_depth(val);
if(_d == 1) return valueProcess(val, nod, applyUnit, arrIndex);
if(_d == 2) {
for (var i = 0, n = array_length(val); i < n; i++)
val[i] = valueProcess(val[1], nod, applyUnit, arrIndex);
}
return val;
} }
// Dimension conversion // Dimension conversion
@ -49,8 +55,10 @@ function NodeValue_Vec2(_name, _node, _value, _data = {}) : NodeValue(_name, _no
if(eqSize) return _osZ; if(eqSize) return _osZ;
return sArr; return sArr;
} else if (is_surface(val)) } else if (is_surface(val))
return [ surface_get_width_safe(val), surface_get_height_safe(val) ]; return [ surface_get_width_safe(val), surface_get_height_safe(val) ];
return [ 1, 1 ]; return [ 1, 1 ];
} }

View file

@ -36,13 +36,13 @@ function Node_Vector2(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
wd_pan_my = 0; wd_pan_my = 0;
coordinate_menu = [ coordinate_menu = [
menuItem(__txt("Reset view"), function() { menuItemAction(__txt("Reset view"), function() {
wd_minx = -1; wd_minx = -1;
wd_miny = -1; wd_miny = -1;
wd_maxx = 1; wd_maxx = 1;
wd_maxy = 1; wd_maxy = 1;
}), }),
menuItem(__txt("Focus value"), function() { menuItemAction(__txt("Focus value"), function() {
var _x = getInputData(0); var _x = getInputData(0);
var _y = getInputData(1); var _y = getInputData(1);

View file

@ -27,7 +27,7 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
name = "WAV File In"; name = "WAV File In";
color = COLORS.node_blend_input; color = COLORS.node_blend_input;
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_load, { filter: "audio|*.wav" }) .setDisplay(VALUE_DISPLAY.path_load, { filter: "audio|*.wav" })
.rejectArray(); .rejectArray();

View file

@ -3,7 +3,7 @@ function Node_WAV_File_Write(_x, _y, _group = noone) : Node(_x, _y, _group) cons
color = COLORS.node_blend_input; color = COLORS.node_blend_input;
setDimension(, 72); setDimension(, 72);
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_save, { filter: "audio file|*.wav" }) .setDisplay(VALUE_DISPLAY.path_save, { filter: "audio file|*.wav" })
.rejectArray() .rejectArray()
.setVisible(true); .setVisible(true);

View file

@ -9,7 +9,7 @@ function Node_Websocket_Sender(_x, _y, _group = noone) : Node(_x, _y, _group) co
inputs[3] = nodeValue_Surface("Surface", self); inputs[3] = nodeValue_Surface("Surface", self);
inputs[4] = nodeValue_Text("Path", self, "") inputs[4] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_load) .setDisplay(VALUE_DISPLAY.path_load)
.nonValidate(); .nonValidate();

View file

@ -29,7 +29,7 @@ function Node_XML_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
w = 128; w = 128;
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_load, { filter: "XML file|*.xml" }) .setDisplay(VALUE_DISPLAY.path_load, { filter: "XML file|*.xml" })
.rejectArray(); .rejectArray();

View file

@ -4,7 +4,7 @@ function Node_XML_File_Write(_x, _y, _group = noone) : Node(_x, _y, _group) cons
w = 128; w = 128;
inputs[0] = nodeValue_Text("Path", self, "") inputs[0] = nodeValue_Path("Path", self, "")
.setDisplay(VALUE_DISPLAY.path_save, { filter: "xml file|*.xml" }) .setDisplay(VALUE_DISPLAY.path_save, { filter: "xml file|*.xml" })
.rejectArray(); .rejectArray();

View file

@ -1,32 +1,77 @@
#region funtion calls #region funtion calls
function __fnInit_Animation() { function __fnInit_Animation() {
__registerFunction("animation_play_pause", panel_animation_play_pause); registerFunction("", "Play/Pause", vk_space, MOD_KEY.none, panel_animation_play_pause);
__registerFunction("animation_resume", panel_animation_resume); registerFunction("", "Resume/Pause", vk_space, MOD_KEY.shift, panel_animation_resume);
registerFunction("", "First frame", vk_home, MOD_KEY.none, panel_animation_first_frame);
registerFunction("", "Last frame", vk_end, MOD_KEY.none, panel_animation_last_frame);
registerFunction("", "Next frame", vk_right, MOD_KEY.none, panel_animation_next_frame);
registerFunction("", "Previous frame", vk_left, MOD_KEY.none, panel_animation_prev_frame);
registerFunction("Animation", "Delete keys", vk_delete, MOD_KEY.none, panel_animation_delete_key);
registerFunction("Animation", "Duplicate", "D", MOD_KEY.ctrl, panel_animation_duplicate);
registerFunction("Animation", "Copy", "C", MOD_KEY.ctrl, panel_animation_copy);
registerFunction("Animation", "Paste", "V", MOD_KEY.ctrl, panel_animation_paste);
registerFunction("Animation", "Collapse Toggle", "C", MOD_KEY.none, panel_animation_collapseToggle);
registerFunction("Animation", "Toggle Nodes", "H", MOD_KEY.none, panel_animation_show_nodes);
__registerFunction("animation_first_frame", panel_animation_first_frame); registerFunction("Animation", "Settings", "S", MOD_KEY.ctrl | MOD_KEY.shift, panel_animation_settings);
__registerFunction("animation_last_frame", panel_animation_last_frame); registerFunction("Animation", "Scaler", "", MOD_KEY.none, panel_animation_scale);
__registerFunction("animation_next_frame", panel_animation_next_frame);
__registerFunction("animation_prev_frame", panel_animation_prev_frame);
__registerFunction("animation_delete_key", panel_animation_delete_key); registerFunction("Animation", "Edit Keyframe Value","", MOD_KEY.none, panel_animation_edit_keyframe_value);
__registerFunction("animation_duplicate", panel_animation_duplicate); registerFunction("Animation", "Lock Keyframe Y", "", MOD_KEY.none, panel_animation_edit_keyframe_lock_y);
__registerFunction("animation_copy", panel_animation_copy); registerFunction("Animation", "Stagger", "", MOD_KEY.none, panel_animation_edit_keyframe_stagger);
__registerFunction("animation_paste", panel_animation_paste); registerFunction("Animation", "Driver", "", MOD_KEY.none, panel_animation_keyframe_driver);
registerFunction("Animation", "New Folder", "", MOD_KEY.none, panel_animation_dopesheet_new_folder);
registerFunction("Animation", "Dopesheet Expand", "", MOD_KEY.none, panel_animation_dopesheet_expand);
registerFunction("Animation", "Dopesheet Collapse", "", MOD_KEY.none, panel_animation_dopesheet_collapse);
registerFunction("Animation", "Rename Group", "", MOD_KEY.none, panel_animation_group_rename);
registerFunction("Animation", "Remove Group", "", MOD_KEY.none, panel_animation_group_remove);
registerFunction("Animation", "Separate Axis", "", MOD_KEY.none, panel_animation_separate_axis);
registerFunction("Animation", "Combine Axis", "", MOD_KEY.none, panel_animation_combine_axis);
registerFunction("Animation", "Set Range Start", "", MOD_KEY.none, panel_animation_range_set_start);
registerFunction("Animation", "Set Range End", "", MOD_KEY.none, panel_animation_range_set_end);
registerFunction("Animation", "Reset Range", "", MOD_KEY.none, panel_animation_range_reset);
} }
function panel_animation_play_pause() { CALL("animation_play_pause"); if(IS_RENDERING) return; if(IS_PLAYING) PROJECT.animator.pause() else PROJECT.animator.play(); } function panel_animation_settings() { var dia = dialogPanelCall(new Panel_Animation_Setting()); dia.anchor = ANCHOR.none; }
function panel_animation_resume() { CALL("animation_resume"); if(IS_RENDERING) return; if(PROJECT.animator.is_playing) PROJECT.animator.pause() else PROJECT.animator.resume(); } function panel_animation_scale() { dialogPanelCall(new Panel_Animation_Scaler()); }
function panel_animation_first_frame() { CALL("animation_first_frame"); if(IS_RENDERING) return; PROJECT.animator.firstFrame(); } function panel_animation_play_pause() { CALL("play_pause"); if(IS_RENDERING) return; if(IS_PLAYING) PROJECT.animator.pause() else PROJECT.animator.play(); }
function panel_animation_last_frame() { CALL("animation_last_frame"); if(IS_RENDERING) return; PROJECT.animator.lastFrame(); } function panel_animation_resume() { CALL("resume_pause"); if(IS_RENDERING) return; if(PROJECT.animator.is_playing) PROJECT.animator.pause() else PROJECT.animator.resume(); }
function panel_animation_next_frame() { CALL("animation_next_frame"); if(IS_RENDERING) return; PROJECT.animator.setFrame(min(PROJECT.animator.real_frame + 1, TOTAL_FRAMES - 1)); }
function panel_animation_prev_frame() { CALL("animation_prev_frame"); if(IS_RENDERING) return; PROJECT.animator.setFrame(max(PROJECT.animator.real_frame - 1, 0)); }
function panel_animation_delete_key() { CALL("animation_delete_key"); PANEL_ANIMATION.deleteKeys(); } function panel_animation_first_frame() { CALL("first_frame"); if(IS_RENDERING) return; PROJECT.animator.firstFrame(); }
function panel_animation_duplicate() { CALL("animation_duplicate"); PANEL_ANIMATION.doDuplicate(); } function panel_animation_last_frame() { CALL("last_frame"); if(IS_RENDERING) return; PROJECT.animator.lastFrame(); }
function panel_animation_copy() { CALL("animation_copy"); PANEL_ANIMATION.doCopy(); } function panel_animation_next_frame() { CALL("next_frame"); if(IS_RENDERING) return; PROJECT.animator.setFrame(min(PROJECT.animator.real_frame + 1, TOTAL_FRAMES - 1)); }
function panel_animation_paste() { CALL("animation_paste"); PANEL_ANIMATION.doPaste(PANEL_ANIMATION.value_focusing); } function panel_animation_prev_frame() { CALL("previous_frame"); if(IS_RENDERING) return; PROJECT.animator.setFrame(max(PROJECT.animator.real_frame - 1, 0)); }
function panel_animation_show_nodes() { CALL("animation_paste"); PANEL_ANIMATION.show_nodes = !PANEL_ANIMATION.show_nodes; }
function panel_animation_collapseToggle(){ CALL("animation_collapse_toggle"); PANEL_ANIMATION.collapseToggle(); }
function panel_animation_delete_key() { CALL("animation_delete_key"); PANEL_ANIMATION.deleteKeys(); }
function panel_animation_duplicate() { CALL("animation_duplicate"); PANEL_ANIMATION.doDuplicate(); }
function panel_animation_copy() { CALL("animation_copy"); PANEL_ANIMATION.doCopy(); }
function panel_animation_paste() { CALL("animation_paste"); PANEL_ANIMATION.doPaste(PANEL_ANIMATION.value_focusing); }
function panel_animation_show_nodes() { CALL("animation_toggle_nodes"); PANEL_ANIMATION.show_nodes = !PANEL_ANIMATION.show_nodes; }
function panel_animation_edit_keyframe_value() { CALL("animation_edit_keyframe_value"); PANEL_ANIMATION.edit_keyframe_value(); }
function panel_animation_edit_keyframe_lock_y() { CALL("animation_edit_lock_keyframe_y"); PANEL_ANIMATION.edit_keyframe_lock_y(); }
function panel_animation_edit_keyframe_stagger() { CALL("animation_stagger"); PANEL_ANIMATION.edit_keyframe_stagger(); }
function panel_animation_keyframe_driver() { CALL("animation_driver"); PANEL_ANIMATION.edit_keyframe_driver(); }
function panel_animation_dopesheet_new_folder() { CALL("animation_new_folder"); PANEL_ANIMATION.dopesheet_new_folder(); }
function panel_animation_dopesheet_expand() { CALL("animation_dopesheet_expand"); PANEL_ANIMATION.dopesheet_expand(); }
function panel_animation_dopesheet_collapse() { CALL("animation_dopesheet_collapse"); PANEL_ANIMATION.dopesheet_collapse(); }
function panel_animation_group_rename() { CALL("animation_rename_group"); PANEL_ANIMATION.group_rename(); }
function panel_animation_group_remove() { CALL("animation_remove_group"); PANEL_ANIMATION.group_remove(); }
function panel_animation_separate_axis() { CALL("animation_separate_axis"); PANEL_ANIMATION.separate_axis(); }
function panel_animation_combine_axis() { CALL("animation_combine_axis"); PANEL_ANIMATION.combine_axis(); }
function panel_animation_range_set_start() { CALL("animation_range_set_start"); PANEL_ANIMATION.range_set_start(); }
function panel_animation_range_set_end() { CALL("animation_range_set_end"); PANEL_ANIMATION.range_set_end(); }
function panel_animation_range_reset() { CALL("animation_range_reset"); PANEL_ANIMATION.range_reset(); }
#endregion #endregion
enum KEYFRAME_DRAG_TYPE { enum KEYFRAME_DRAG_TYPE {
@ -48,19 +93,19 @@ function Panel_Animation() : PanelContent() constructor {
tool_width = ui(224); tool_width = ui(224);
#endregion #endregion
static initSize = function() { #region static initSize = function() {
timeline_w = w - tool_width - ui(80); timeline_w = w - tool_width - ui(80);
timeline_surface = surface_create_valid(timeline_w, timeline_h); timeline_surface = surface_create_valid(timeline_w, timeline_h);
timeline_mask = surface_create_valid(timeline_w, timeline_h); timeline_mask = surface_create_valid(timeline_w, timeline_h);
dope_sheet_w = w - tool_width; dope_sheet_w = w - tool_width;
dope_sheet_h = h - timeline_h - ui(20); dope_sheet_h = h - timeline_h - ui(20);
dope_sheet_surface = surface_create_valid(dope_sheet_w, 1); dope_sheet_surface = surface_create_valid(dope_sheet_w, 1);
dope_sheet_mask = surface_create_valid(dope_sheet_w, 1); dope_sheet_mask = surface_create_valid(dope_sheet_w, 1);
dope_sheet_name_mask = surface_create_valid(tool_width, 1); dope_sheet_name_mask = surface_create_valid(tool_width, 1);
dope_sheet_name_surface = surface_create_valid(tool_width, 1); dope_sheet_name_surface = surface_create_valid(tool_width, 1);
} #endregion }
initSize(); initSize();
#region ---- position ---- #region ---- position ----
@ -177,54 +222,27 @@ function Panel_Animation() : PanelContent() constructor {
tool_width_mx = 0; tool_width_mx = 0;
#endregion #endregion
on_end_dragging_anim = noone; on_end_dragging_anim = noone;
onion_dragging = noone;
prev_cache = array_create(TOTAL_FRAMES);
copy_clipboard = ds_list_create();
onion_dragging = noone; __collapse = false;
function collapseToggle() {
PANEL_ANIMATION.__collapse = !PANEL_ANIMATION.__collapse;
prev_cache = array_create(TOTAL_FRAMES); for( var i = 0, n = array_length(PANEL_ANIMATION.timeline_contents); i < n; i++ )
PANEL_ANIMATION.timeline_contents[i].item.show = PANEL_ANIMATION.__collapse;
copy_clipboard = ds_list_create(); }
#region ++++ hotkeys ++++
__collapse = false;
function collapseToggle() { #region
PANEL_ANIMATION.__collapse = !PANEL_ANIMATION.__collapse;
for( var i = 0, n = array_length(PANEL_ANIMATION.timeline_contents); i < n; i++ )
PANEL_ANIMATION.timeline_contents[i].item.show = PANEL_ANIMATION.__collapse;
} #endregion
addHotkey("", "Play/Pause", vk_space, MOD_KEY.none, panel_animation_play_pause);
addHotkey("", "Resume/Pause", vk_space, MOD_KEY.shift, panel_animation_resume);
addHotkey("", "First frame", vk_home, MOD_KEY.none, panel_animation_first_frame);
addHotkey("", "Last frame", vk_end, MOD_KEY.none, panel_animation_last_frame);
addHotkey("", "Next frame", vk_right, MOD_KEY.none, panel_animation_next_frame);
addHotkey("", "Previous frame", vk_left, MOD_KEY.none, panel_animation_prev_frame);
addHotkey("Animation", "Delete keys", vk_delete, MOD_KEY.none, panel_animation_delete_key);
addHotkey("Animation", "Duplicate", "D", MOD_KEY.ctrl, panel_animation_duplicate);
addHotkey("Animation", "Copy", "C", MOD_KEY.ctrl, panel_animation_copy);
addHotkey("Animation", "Paste", "V", MOD_KEY.ctrl, panel_animation_paste);
addHotkey("Animation", "Collapse Toggle", "C", MOD_KEY.none, collapseToggle);
addHotkey("Animation", "Toggle nodes", "H", MOD_KEY.none, panel_animation_show_nodes);
addHotkey("Animation", "Settings", "S", MOD_KEY.ctrl | MOD_KEY.shift, function() {
var dia = dialogPanelCall(new Panel_Animation_Setting());
dia.anchor = ANCHOR.none;
});
tooltip_toggle_nodes = new tooltipHotkey(__txtx("panel_animation_show_node", "Toggle node label"), "Animation", "Toggle nodes");
#endregion
#region ++++ control_buttons ++++ #region ++++ control_buttons ++++
tooltip_resume = new tooltipHotkey(__txt("Resume"), "", "Resume/Pause"); tooltip_toggle_nodes = new tooltipHotkey(__txtx("panel_animation_show_node", "Toggle node label"), "Animation", "Toggle nodes");
tooltip_pause = new tooltipHotkey(__txt("Pause"), "", "Resume/Pause"); tooltip_resume = new tooltipHotkey(__txt("Resume"), "", "Resume/Pause");
tooltip_fr_first = new tooltipHotkey(__txtx("panel_animation_go_to_first_frame", "Go to first frame"), "", "First frame"); tooltip_pause = new tooltipHotkey(__txt("Pause"), "", "Resume/Pause");
tooltip_fr_last = new tooltipHotkey(__txtx("panel_animation_go_to_last_frame", "Go to last frame"), "", "Last frame"); tooltip_fr_first = new tooltipHotkey(__txtx("panel_animation_go_to_first_frame", "Go to first frame"), "", "First frame");
tooltip_fr_prev = new tooltipHotkey(__txtx("panel_animation_previous_frame", "Previous frame"), "", "Previous frame"); tooltip_fr_last = new tooltipHotkey(__txtx("panel_animation_go_to_last_frame", "Go to last frame"), "", "Last frame");
tooltip_fr_next = new tooltipHotkey(__txtx("panel_animation_next_frame", "Next frame"), "", "Next frame"); tooltip_fr_prev = new tooltipHotkey(__txtx("panel_animation_previous_frame", "Previous frame"), "", "Previous frame");
tooltip_fr_next = new tooltipHotkey(__txtx("panel_animation_next_frame", "Next frame"), "", "Next frame");
control_buttons = [ control_buttons = [
[ [
@ -268,19 +286,38 @@ function Panel_Animation() : PanelContent() constructor {
#region ++++ context menu ++++ #region ++++ context menu ++++
keyframe_menu = [ #region actions
function edit_keyframe_value() { if(array_empty(keyframe_selecting)) return; editKeyFrame(keyframe_selecting[0]); }
menuItem(__txtx("panel_animation_keyframe_edit", "Edit Value..."), function() { function edit_keyframe_lock_y() {
if(array_empty(keyframe_selecting)) return;
editKeyFrame(keyframe_selecting[0]);
}),
menuItem(__txtx("panel_animation_lock_y", "Lock/Unlock Y easing"), function() {
for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) { for( var i = 0, n = array_length(keyframe_selecting); i < n; i++ ) {
var k = keyframe_selecting[i]; var k = keyframe_selecting[i];
k.ease_y_lock = !k.ease_y_lock; k.ease_y_lock = !k.ease_y_lock;
} }
}), }
function edit_keyframe_stagger() { stagger_mode = 1; }
function edit_keyframe_driver() { dialogPanelCall(new Panel_Keyframe_Driver(keyframe_selecting[0]), mouse_mx + ui(8), mouse_my + ui(8)); }
function dopesheet_new_folder() { var _dir = new timelineItemGroup(); PROJECT.timelines.addItem(_dir); }
function dopesheet_expand() { for( var i = 0, n = array_length(timeline_contents); i < n; i++ ) timeline_contents[i].item.show = true; }
function dopesheet_collapse() { for( var i = 0, n = array_length(timeline_contents); i < n; i++ ) timeline_contents[i].item.show = false; }
function group_rename() { context_selecting_item.item.rename(); }
function group_remove() { context_selecting_item.item.destroy(); }
function separate_axis() { context_selecting_prop.sep_axis = true; }
function combine_axis() { context_selecting_prop.sep_axis = false; }
function range_set_start() { if(FRAME_RANGE == noone) FRAME_RANGE = [ __selecting_frame, TOTAL_FRAMES ]; else FRAME_RANGE[0] = __selecting_frame; }
function range_set_end() { if(FRAME_RANGE == noone) FRAME_RANGE = [ 0, __selecting_frame ]; else FRAME_RANGE[1] = __selecting_frame; }
function range_reset() { FRAME_RANGE = noone; }
#endregion
keyframe_menu = [
menuItemAction(__txtx("panel_animation_keyframe_edit", "Edit Value..."), panel_animation_edit_keyframe_value),
menuItemAction(__txtx("panel_animation_lock_y", "Lock/Unlock Y easing"), panel_animation_edit_keyframe_lock_y),
menuItemGroup(__txtx("panel_animation_ease_in", "Ease in"), [ menuItemGroup(__txtx("panel_animation_ease_in", "Ease in"), [
[ [THEME.timeline_ease, 0], function() { [ [THEME.timeline_ease, 0], function() {
@ -355,36 +392,27 @@ function Panel_Animation() : PanelContent() constructor {
[ [THEME.object_halign, 1], function() { alignKeys(fa_center); } ], [ [THEME.object_halign, 1], function() { alignKeys(fa_center); } ],
[ [THEME.object_halign, 2], function() { alignKeys(fa_right); } ], [ [THEME.object_halign, 2], function() { alignKeys(fa_right); } ],
]), ]),
menuItem(__txtx("panel_animation_stagger", "Stagger"), function() { stagger_mode = 1; }), menuItemAction(__txtx("panel_animation_stagger", "Stagger"), panel_animation_edit_keyframe_stagger),
menuItem(__txtx("panel_driver", "Driver..."), function() { dialogPanelCall(new Panel_Keyframe_Driver(keyframe_selecting[0]), mouse_mx + ui(8), mouse_my + ui(8)); }), menuItemAction(__txtx("panel_driver", "Driver..."), panel_animation_keyframe_driver),
-1, -1,
menuItem(__txt("Delete"), function() { deleteKeys(); }, noone, [ "Animation", "Delete keys" ]), menuItemAction(__txt("Delete"), panel_animation_delete_key),
menuItem(__txt("Duplicate"), function() { doDuplicate(); }, THEME.duplicate, [ "Animation", "Duplicate" ]), menuItemAction(__txt("Duplicate"), panel_animation_duplicate, THEME.duplicate),
menuItem(__txt("Copy"), function() { doCopy(); }, THEME.copy, [ "Animation", "Copy" ]), menuItemAction(__txt("Copy"), panel_animation_copy, THEME.copy),
menuItem(__txt("Paste"), function() { doPaste(value_focusing); }, THEME.paste, [ "Animation", "Paste" ]), menuItemAction(__txt("Paste"), panel_animation_paste, THEME.paste),
]; ];
keyframe_menu_empty = [ keyframe_menu_empty = [
menuItem(__txt("Paste"), function() { doPaste(value_focusing); }, THEME.paste, [ "Animation", "Paste" ]), menuItemAction(__txt("Paste"), panel_animation_paste, THEME.paste),
]; ];
context_selecting_item = noone; context_selecting_item = noone;
context_selecting_prop = noone; context_selecting_prop = noone;
name_menu_empty = [ name_menu_empty = [
menuItem(__txt("New folder"), function() { menuItemAction(__txt("New folder"), panel_animation_dopesheet_new_folder, THEME.folder_content),
var _dir = new timelineItemGroup();
PROJECT.timelines.addItem(_dir);
}, THEME.folder_content),
-1, -1,
menuItem(__txt("Expand all"), function() { menuItemAction(__txt("Expand all"), panel_animation_dopesheet_expand),
for( var i = 0, n = array_length(timeline_contents); i < n; i++ ) menuItemAction(__txt("Collapse all"), panel_animation_dopesheet_collapse),
timeline_contents[i].item.show = true;
}),
menuItem(__txt("Collapse all"), function() {
for( var i = 0, n = array_length(timeline_contents); i < n; i++ )
timeline_contents[i].item.show = false;
}),
]; ];
var _clrs = COLORS.labels; var _clrs = COLORS.labels;
@ -417,21 +445,21 @@ function Panel_Animation() : PanelContent() constructor {
name_menu_group = [ name_menu_group = [
clr, clr,
menuItem(__txt("Rename"), function() { context_selecting_item.item.rename(); }), menuItemAction(__txt("Rename"), panel_animation_group_rename),
menuItem(__txt("Delete"), function() { context_selecting_item.item.destroy(); }, THEME.cross), menuItemAction(__txt("Delete"), panel_animation_group_remove, THEME.cross),
-1, -1,
name_menu_empty[0] name_menu_empty[0]
]; ];
name_menu_prop_sep = [ name_menu_prop_sep = [
menuItem(__txtx("panel_inspector_axis_separate", "Separate axis"), function() { context_selecting_prop.sep_axis = true; }), menuItemAction(__txtx("panel_inspector_axis_separate", "Separate axis"), panel_animation_separate_axis),
-1, -1,
name_menu_empty[2], name_menu_empty[2],
name_menu_empty[3], name_menu_empty[3],
]; ];
name_menu_prop_join = [ name_menu_prop_join = [
menuItem(__txtx("panel_inspector_axis_combine", "Combine axis"), function() { context_selecting_prop.sep_axis = false; }), menuItemAction(__txtx("panel_inspector_axis_combine", "Combine axis"), panel_animation_combine_axis),
-1, -1,
name_menu_empty[2], name_menu_empty[2],
name_menu_empty[3], name_menu_empty[3],
@ -448,7 +476,7 @@ function Panel_Animation() : PanelContent() constructor {
keyframe_selecting = []; keyframe_selecting = [];
} }
function alignKeys(halign = fa_left) { #region function alignKeys(halign = fa_left) {
if(array_empty(keyframe_selecting)) return; if(array_empty(keyframe_selecting)) return;
var tt = 0; var tt = 0;
@ -476,13 +504,13 @@ function Panel_Animation() : PanelContent() constructor {
var k = keyframe_selecting[i]; var k = keyframe_selecting[i];
k.anim.setKeyTime(k, tt,, true); k.anim.setKeyTime(k, tt,, true);
} }
} #endregion }
function arrangeKeys() { #region function arrangeKeys() {
//keyframe_selecting = l; //keyframe_selecting = l;
} #endregion }
function staggerKeys(_index, _stag) { #region function staggerKeys(_index, _stag) {
var modified = false; var modified = false;
var t = keyframe_selecting[_index].time; var t = keyframe_selecting[_index].time;
@ -494,11 +522,11 @@ function Panel_Animation() : PanelContent() constructor {
} }
if(modified) UNDO_HOLDING = true; if(modified) UNDO_HOLDING = true;
} #endregion }
function onFocusBegin() { PANEL_ANIMATION = self; } function onFocusBegin() { PANEL_ANIMATION = self; }
function surfaceVerify() { #region function surfaceVerify() {
if(w - tool_width > 1) { if(w - tool_width > 1) {
timeline_mask = surface_verify(timeline_mask, timeline_w, timeline_h); timeline_mask = surface_verify(timeline_mask, timeline_w, timeline_h);
timeline_surface = surface_verify(timeline_surface, timeline_w, timeline_h); timeline_surface = surface_verify(timeline_surface, timeline_w, timeline_h);
@ -513,16 +541,16 @@ function Panel_Animation() : PanelContent() constructor {
dope_sheet_name_mask = surface_verify(dope_sheet_name_mask, tool_width, dope_sheet_h); dope_sheet_name_mask = surface_verify(dope_sheet_name_mask, tool_width, dope_sheet_h);
dope_sheet_name_surface = surface_verify(dope_sheet_name_surface, tool_width, dope_sheet_h); dope_sheet_name_surface = surface_verify(dope_sheet_name_surface, tool_width, dope_sheet_h);
} }
} #endregion }
function onResize() { #region function onResize() {
initSize(); initSize();
surfaceVerify(); surfaceVerify();
resetTimelineMask(); resetTimelineMask();
} #endregion }
function resetTimelineMask() { #region function resetTimelineMask() {
timeline_mask = surface_verify(timeline_mask, timeline_w, timeline_h); timeline_mask = surface_verify(timeline_mask, timeline_w, timeline_h);
surface_set_target(timeline_mask); surface_set_target(timeline_mask);
@ -547,7 +575,7 @@ function Panel_Animation() : PanelContent() constructor {
gpu_set_blendmode(bm_normal); gpu_set_blendmode(bm_normal);
} }
} #endregion }
resetTimelineMask(); resetTimelineMask();
function getTimelineContentFolder(folder, _context = [], _depth = 0, _show = true) { #region function getTimelineContentFolder(folder, _context = [], _depth = 0, _show = true) { #region
@ -802,9 +830,9 @@ function Panel_Animation() : PanelContent() constructor {
__selecting_frame = clamp(round((mx - bar_x - timeline_shift) / timeline_scale), 0, TOTAL_FRAMES - 1); __selecting_frame = clamp(round((mx - bar_x - timeline_shift) / timeline_scale), 0, TOTAL_FRAMES - 1);
menuCall("animation_summary_menu",,, [ menuCall("animation_summary_menu",,, [
menuItem(__txtx("panel_animation_range_start", "Set start"), function() { if(FRAME_RANGE == noone) FRAME_RANGE = [ __selecting_frame, TOTAL_FRAMES ]; else FRAME_RANGE[0] = __selecting_frame; }, [ THEME.frame_range, 0 ]), menuItemAction(__txtx("panel_animation_range_start", "Set start"), panel_animation_range_set_start, [ THEME.frame_range, 0 ]),
menuItem(__txtx("panel_animation_range_end", "Set end"), function() { if(FRAME_RANGE == noone) FRAME_RANGE = [ 0, __selecting_frame ]; else FRAME_RANGE[1] = __selecting_frame; }, [ THEME.frame_range, 1 ]), menuItemAction(__txtx("panel_animation_range_end", "Set end"), panel_animation_range_set_end, [ THEME.frame_range, 1 ]),
menuItem(__txtx("panel_animation_range_reset", "Reset range"), function() { FRAME_RANGE = noone; }), menuItemAction(__txtx("panel_animation_range_reset", "Reset range"), panel_animation_range_reset),
]); ]);
} }
} }
@ -1300,9 +1328,9 @@ function Panel_Animation() : PanelContent() constructor {
var key_hover = noone; var key_hover = noone;
var key_list = animator.values; var key_list = animator.values;
if((animator.prop.on_end == KEYFRAME_END.loop || animator.prop.on_end == KEYFRAME_END.ping) && ds_list_size(key_list) > 1) { if((animator.prop.on_end == KEYFRAME_END.loop || animator.prop.on_end == KEYFRAME_END.ping) && array_length(key_list) > 1) {
var keyframe_s = animator.prop.loop_range == -1? key_list[| 0].time : key_list[| ds_list_size(key_list) - 1 - animator.prop.loop_range].time; var keyframe_s = animator.prop.loop_range == -1? key_list[0].time : key_list[array_length(key_list) - 1 - animator.prop.loop_range].time;
var keyframe_e = key_list[| ds_list_size(key_list) - 1].time; var keyframe_e = key_list[array_length(key_list) - 1].time;
var ks_x = (keyframe_s + 1) * timeline_scale + timeline_shift; var ks_x = (keyframe_s + 1) * timeline_scale + timeline_shift;
var ke_x = (keyframe_e + 1) * timeline_scale + timeline_shift; var ke_x = (keyframe_e + 1) * timeline_scale + timeline_shift;
@ -1313,8 +1341,8 @@ function Panel_Animation() : PanelContent() constructor {
draw_set_alpha(1); draw_set_alpha(1);
} }
for( var k = 0; k < ds_list_size(key_list); k++ ) { //draw easing for( var k = 0, n = array_length(key_list); k < n; k++ ) { //draw easing
var key = key_list[| k]; var key = key_list[k];
var t = key.dopesheet_x; var t = key.dopesheet_x;
if(key.ease_in_type == CURVE_TYPE.bezier) { if(key.ease_in_type == CURVE_TYPE.bezier) {

View file

@ -1,3 +1,25 @@
#region funtion calls
function __fnInit_Collection() {
registerFunction("Collection", "Replace", "", MOD_KEY.none, panel_collection_replace);
registerFunction("Collection", "Edit Meta", "", MOD_KEY.none, panel_collection_edit_meta);
registerFunction("Collection", "Update Thumbnail", "", MOD_KEY.none, panel_collection_update_thumbnail);
registerFunction("Collection", "Delete Collection", "", MOD_KEY.none, panel_collection_delete_collection);
registerFunction("Collection", "Upload To Steam", "", MOD_KEY.none, panel_collection_steam_file_upload);
registerFunction("Collection", "Update Steam", "", MOD_KEY.none, panel_collection_steam_file_update);
registerFunction("Collection", "Unsubscribe", "", MOD_KEY.none, panel_collection_steam_unsubscribe);
}
function panel_collection_replace() { CALL("collection_replace"); PANEL_COLLECTION.replace(); }
function panel_collection_edit_meta() { CALL("collection_edit_meta"); PANEL_COLLECTION.edit_meta(); }
function panel_collection_update_thumbnail() { CALL("collection_update_thumbnail"); PANEL_COLLECTION.update_thumbnail(); }
function panel_collection_delete_collection() { CALL("collection_delete_collection"); PANEL_COLLECTION.delete_collection(); }
function panel_collection_steam_file_upload() { CALL("collection_steam_file_upload"); PANEL_COLLECTION.steam_file_upload(); }
function panel_collection_steam_file_update() { CALL("collection_steam_file_update"); PANEL_COLLECTION.steam_file_update(); }
function panel_collection_steam_unsubscribe() { CALL("collection_steam_unsubscribe"); PANEL_COLLECTION.steam_unsubscribe(); }
#endregion
function Panel_Collection() : PanelContent() constructor { function Panel_Collection() : PanelContent() constructor {
title = __txt("Collections"); title = __txt("Collections");
expandable = false; expandable = false;
@ -36,6 +58,103 @@ function Panel_Collection() : PanelContent() constructor {
PANEL_COLLECTION = self; PANEL_COLLECTION = self;
#region ++++++++++++ Actions ++++++++++++
function replace() {
if(_menu_node == noone) return;
var _path = filename_dir(_menu_node.path);
var _name = filename_name(_menu_node.path);
saveCollection(PANEL_INSPECTOR.getInspecting(), _path, _name, false, _menu_node.meta);
}
function edit_meta() {
if(_menu_node == noone) 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)
dia.meta = meta;
dia.node = PANEL_INSPECTOR.getInspecting();
dia.data_path = data_path;
dia.updating = _menu_node;
dia.doExpand();
}
function update_thumbnail() {
if(_menu_node == noone) return;
var _path = _menu_node.path;
var preview_surface = PANEL_PREVIEW.getNodePreviewSurface();
if(!is_surface(preview_surface)) {
noti_warning("Please send any node to preview panel to use as a thumbnail.")
return;
}
var icon_path = string_replace(_path, filename_ext(_path), ".png");
surface_save_safe(preview_surface, icon_path);
refreshContext();
}
function delete_collection() {
if(_menu_node == noone) return;
file_delete(_menu_node.path);
refreshContext();
}
function steam_file_upload() {
if(_menu_node == noone) 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)
dia.meta = meta;
dia.data_path = data_path;
dia.ugc = 1;
dia.updating = _menu_node;
dia.doExpand();
}
function steam_file_update() {
if(_menu_node == noone) return;
var _node = PANEL_INSPECTOR.getInspecting();
if(_node == noone) {
noti_warning("No node selected. Select a node in graph panel to update workshop content.");
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)
dia.meta = meta;
dia.node = _node;
dia.data_path = data_path;
dia.ugc = 2;
dia.updating = _menu_node;
dia.doExpand();
}
function steam_unsubscribe() {
if(_menu_node == noone) return;
var meta = _menu_node.getMetadata();
var del_id = meta.file_id;
for( var i = 0; i < ds_list_size(STEAM_COLLECTION); i++ ) {
if(STEAM_COLLECTION[| i].getMetadata().file_id == del_id) {
ds_list_delete(STEAM_COLLECTION, i);
break;
}
}
steam_ugc_unsubscribe_item(del_id);
}
#endregion
static initMenu = function() { static initMenu = function() {
if(_menu_node == noone) return; if(_menu_node == noone) return;
var meta = _menu_node.getMetadata(); var meta = _menu_node.getMetadata();
@ -44,41 +163,11 @@ function Panel_Collection() : PanelContent() constructor {
if(meta == noone || !meta.steam) { if(meta == noone || !meta.steam) {
contentMenu = [ contentMenu = [
menuItem(__txtx("panel_collection_replace", "Replace with selected"), function() { menuItemAction(__txtx("panel_collection_replace", "Replace with selected"), panel_collection_replace),
var _path = filename_dir(_menu_node.path); menuItemAction(__txtx("panel_collection_edit_meta", "Edit metadata") + "...", panel_collection_edit_meta),
var _name = filename_name(_menu_node.path); menuItemAction(__txtx("panel_collection_update_thumbnail", "Update thumbnail"), panel_collection_update_thumbnail),
saveCollection(PANEL_INSPECTOR.getInspecting(), _path, _name, false, _menu_node.meta);
}),
menuItem(__txtx("panel_collection_edit_meta", "Edit metadata") + "...", function() {
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)
dia.meta = meta;
dia.node = PANEL_INSPECTOR.getInspecting();
dia.data_path = data_path;
dia.updating = _menu_node;
dia.doExpand();
}),
menuItem(__txtx("panel_collection_update_thumbnail", "Update thumbnail"), function() {
var _path = _menu_node.path;
var preview_surface = PANEL_PREVIEW.getNodePreviewSurface();
if(!is_surface(preview_surface)) {
noti_warning("Please send any node to preview panel to use as a thumbnail.")
return;
}
var icon_path = string_replace(_path, filename_ext(_path), ".png");
surface_save_safe(preview_surface, icon_path);
refreshContext();
}),
-1, -1,
menuItem(__txt("Delete"), function() { menuItemAction(__txt("Delete"), panel_collection_delete_collection)
file_delete(_menu_node.path);
refreshContext();
})
]; ];
if(STEAM_ENABLED) if(STEAM_ENABLED)
@ -87,50 +176,11 @@ function Panel_Collection() : PanelContent() constructor {
if(STEAM_ENABLED) { if(STEAM_ENABLED) {
if(meta.steam == FILE_STEAM_TYPE.local) { if(meta.steam == FILE_STEAM_TYPE.local) {
array_push(contentMenu, menuItem(__txtx("panel_collection_workshop_upload", "Upload to Steam Workshop") + "...", function() { array_push(contentMenu, menuItemAction(__txtx("panel_collection_workshop_upload", "Upload to Steam Workshop") + "...", panel_collection_steam_file_upload));
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)
dia.meta = meta;
dia.data_path = data_path;
dia.ugc = 1;
dia.updating = _menu_node;
dia.doExpand();
}));
} else { } else {
if(meta.author_steam_id == STEAM_USER_ID && meta.file_id != 0) { if(meta.author_steam_id == STEAM_USER_ID && meta.file_id != 0)
array_push(contentMenu, menuItem(__txtx("panel_collection_workshop_update", "Update Steam Workshop content") + "...", function() { array_push(contentMenu, menuItemAction(__txtx("panel_collection_workshop_update", "Update Steam Workshop content") + "...", panel_collection_steam_file_update));
var _node = PANEL_INSPECTOR.getInspecting(); array_push(contentMenu, menuItemAction(__txt("Unsubscribe"), panel_collection_steam_unsubscribe));
if(_node == noone) {
noti_warning("No node selected. Select a node in graph panel to update workshop content.");
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)
dia.meta = meta;
dia.node = _node;
dia.data_path = data_path;
dia.ugc = 2;
dia.updating = _menu_node;
dia.doExpand();
}));
}
array_push(contentMenu, menuItem(__txt("Unsubscribe"), function() {
var meta = _menu_node.getMetadata();
var del_id = meta.file_id;
for( var i = 0; i < ds_list_size(STEAM_COLLECTION); i++ ) {
if(STEAM_COLLECTION[| i].getMetadata().file_id == del_id) {
ds_list_delete(STEAM_COLLECTION, i);
break;
}
}
steam_ugc_unsubscribe_item(del_id);
}));
} }
} }
} }

View file

@ -327,15 +327,15 @@ function Panel_Color() : PanelContent() constructor {
if(mouse_press(mb_right, pFOCUS)) { if(mouse_press(mb_right, pFOCUS)) {
menuCall("color_window_menu",,, [ menuCall("color_window_menu",,, [
menuItem(__txt("Hue"), function() { mode = 0; } ), menuItemAction(__txt("Hue"), function() { mode = 0; } ),
menuItem(__txt("Value"), function() { mode = 1; } ), menuItemAction(__txt("Value"), function() { mode = 1; } ),
menuItem(__txt("Saturation"), function() { mode = 2; } ), menuItemAction(__txt("Saturation"), function() { mode = 2; } ),
-1, -1,
menuItem(__txt("Toggle Alpha"), function() { show_alpha = !show_alpha; }, noone, noone, function() /*=>*/ {return show_alpha} ), menuItemAction(__txt("Toggle Alpha"), function() { show_alpha = !show_alpha; }, noone, noone, function() /*=>*/ {return show_alpha} ),
menuItem(__txt("Toggle Palette"), function() { show_palette = !show_palette; }, noone, noone, function() /*=>*/ {return show_palette} ), menuItemAction(__txt("Toggle Palette"), function() { show_palette = !show_palette; }, noone, noone, function() /*=>*/ {return show_palette} ),
menuItem(__txt("Toggle Hex"), function() { show_hex = !show_hex; }, noone, noone, function() /*=>*/ {return show_hex} ), menuItemAction(__txt("Toggle Hex"), function() { show_hex = !show_hex; }, noone, noone, function() /*=>*/ {return show_hex} ),
-1, -1,
menuItem(__txt("Discretize"), function() { discretize_pal = !discretize_pal; }, noone, noone, function() /*=>*/ {return discretize_pal} ), menuItemAction(__txt("Discretize"), function() { discretize_pal = !discretize_pal; }, noone, noone, function() /*=>*/ {return discretize_pal} ),
]); ]);
} }

View file

@ -53,18 +53,18 @@ function Panel(_parent, _x, _y, _w, _h) constructor {
draw_droppable = false; draw_droppable = false;
border_rb_close = menuItem(__txt("Close"), function() { border_rb_close = menuItemAction(__txt("Close"), function() {
var con = getContent(); var con = getContent();
if(con == noone) return; if(con == noone) return;
con.close(); con.close();
}, THEME.cross); }, THEME.cross);
border_rb_menu = [ border_rb_menu = [
menuItem(__txt("Move"), function() { menuItemAction(__txt("Move"), function() {
extract(); extract();
panel_mouse = 1; panel_mouse = 1;
}), }),
menuItem(__txtx("panel_pop_out", "Pop out"), function() { popWindow(); }, THEME.node_goto), menuItemAction(__txtx("panel_pop_out", "Pop out"), function() { popWindow(); }, THEME.node_goto),
border_rb_close border_rb_close
]; ];
@ -954,8 +954,10 @@ function PanelContent() constructor {
if(o_main.panel_dragging == noone) { if(o_main.panel_dragging == noone) {
pFOCUS = FOCUS == panel/* && panel.mouse_active*/; pFOCUS = FOCUS == panel/* && panel.mouse_active*/;
pHOVER = !CURSOR_IS_LOCK && HOVER == panel && panel.mouse_active; pHOVER = !CURSOR_IS_LOCK && HOVER == panel && panel.mouse_active;
if(pFOCUS) FOCUS_CONTENT = self;
} }
drawContent(panel); drawContent(panel);
} }

View file

@ -207,29 +207,29 @@ function Panel_File_Explorer() : PanelContent() constructor {
__menu_cnxt_selecting = noone; __menu_cnxt_selecting = noone;
menu_file_image = [ menu_file_image = [
menuItem("Add as node", function() { menuItemAction("Add as node", function() {
var node = Node_create_Image_path(PANEL_GRAPH.graph_cx, PANEL_GRAPH.graph_cy, __menu_file_selecting.path); var node = Node_create_Image_path(PANEL_GRAPH.graph_cx, PANEL_GRAPH.graph_cy, __menu_file_selecting.path);
PANEL_PREVIEW.setNodePreview(node); PANEL_PREVIEW.setNodePreview(node);
PANEL_INSPECTOR.inspecting = node; PANEL_INSPECTOR.inspecting = node;
}), }),
menuItem("Add as canvas", function() { menuItemAction("Add as canvas", function() {
var node = nodeBuild("Node_Canvas", PANEL_GRAPH.graph_cx, PANEL_GRAPH.graph_cy).loadImagePath(__menu_file_selecting.path); var node = nodeBuild("Node_Canvas", PANEL_GRAPH.graph_cx, PANEL_GRAPH.graph_cy).loadImagePath(__menu_file_selecting.path);
PANEL_PREVIEW.setNodePreview(node); PANEL_PREVIEW.setNodePreview(node);
PANEL_INSPECTOR.inspecting = node; PANEL_INSPECTOR.inspecting = node;
}), }),
menuItem("Copy path", function() { clipboard_set_text(__menu_file_selecting.path); }, THEME.copy), menuItemAction("Copy path", function() { clipboard_set_text(__menu_file_selecting.path); }, THEME.copy),
]; ];
menu_file_project = [ menu_file_project = [
menuItem("Open", function() { LOAD_AT(__menu_file_selecting.path); }), menuItemAction("Open", function() { LOAD_AT(__menu_file_selecting.path); }),
menuItem("Copy path", function() { clipboard_set_text(__menu_file_selecting.path); }, THEME.copy), menuItemAction("Copy path", function() { clipboard_set_text(__menu_file_selecting.path); }, THEME.copy),
]; ];
menu_general = [ menu_general = [
menuItem("New Canvas", function() { menuItemAction("New Canvas", function() {
var dia = dialogCall(o_dialog_file_name, mouse_mx + 8, mouse_my + 8); var dia = dialogCall(o_dialog_file_name, mouse_mx + 8, mouse_my + 8);
dia.onModify = function (txt) { dia.onModify = function (txt) {
var _s = surface_create(DEF_SURF_W, DEF_SURF_H); var _s = surface_create(DEF_SURF_W, DEF_SURF_H);
@ -246,7 +246,7 @@ function Panel_File_Explorer() : PanelContent() constructor {
dia.path = __menu_cnxt_selecting.path + "/"; dia.path = __menu_cnxt_selecting.path + "/";
}, THEME.new_file), }, THEME.new_file),
menuItem("New Folder", function() { menuItemAction("New Folder", function() {
var dia = dialogCall(o_dialog_file_name, mouse_mx + 8, mouse_my + 8); var dia = dialogCall(o_dialog_file_name, mouse_mx + 8, mouse_my + 8);
dia.name = "New Folder"; dia.name = "New Folder";
dia.onModify = function (txt) { dia.onModify = function (txt) {
@ -257,7 +257,7 @@ function Panel_File_Explorer() : PanelContent() constructor {
}, THEME.folder), }, THEME.folder),
-1, -1,
menuItem("Refresh", function() { if(rootFile) rootFile.getContent() }), menuItemAction("Refresh", function() { if(rootFile) rootFile.getContent() }),
]; ];
#endregion #endregion
@ -447,8 +447,6 @@ function Panel_File_Explorer() : PanelContent() constructor {
_dir.open = !_dir.open; _dir.open = !_dir.open;
} }
// if(mouse_press(mb_right)) menuCall("",,, [ menuItem("Delete", function() {}) ]);
} }
draw_sprite_stretched(THEME.ui_panel_bg, _ind, _px, _py, _ppw, _ph); draw_sprite_stretched(THEME.ui_panel_bg, _ind, _px, _py, _ppw, _ph);

View file

@ -445,36 +445,74 @@
#endregion #endregion
#region hotkey #region hotkey
function call_dialog_preference() { dialogCall(o_dialog_preference); }
function call_dialog_splash() { dialogCall(o_dialog_splash); }
function call_dialog_release_note() { dialogCall(o_dialog_release_note); }
function open_autosave_folder() { shellOpenExplorer(DIRECTORY + "autosave"); }
function call_panel_addon() { dialogPanelCall(new Panel_Addon()); }
function call_panel_history() { dialogPanelCall(new Panel_History()); }
function call_panel_Notification() { panelAdd("Panel_Notification", true); }
function call_panel_Collection() { panelAdd("Panel_Collection", true); }
function call_panel_Graph() { panelAdd("Panel_Graph", true); }
function call_panel_Preview() { panelAdd("Panel_Preview", true); }
function call_panel_Preview_Histogram() { panelAdd("Panel_Preview_Histogram", true); }
function call_panel_Inspector() { panelAdd("Panel_Inspector", true); }
function call_panel_Workspace() { panelAdd("Panel_Workspace", true); }
function call_panel_Animation() { panelAdd("Panel_Animation", true); }
function call_panel_Node_Align() { panelAdd("Panel_Node_Align", true); }
function call_panel_Nodes() { panelAdd("Panel_Nodes", true); }
function call_panel_Tunnels() { panelAdd("Panel_Tunnels", true); }
function call_panel_Color() { panelAdd("Panel_Color", true); }
function call_panel_Palette() { panelAdd("Panel_Palette", true); }
function call_panel_Palette_Mixer() { panelAdd("Panel_Palette_Mixer", true); }
function call_panel_Gradient() { panelAdd("Panel_Gradient", true); }
function call_panel_Console() { panelAdd("Panel_Console", true); }
function call_panel_Globalvar() { panelAdd("Panel_Globalvar", true); }
function call_panel_File_Explorer() { panelAdd("Panel_File_Explorer", true); }
function __initPanelHotkeys() { function __initPanelHotkeys() {
addHotkey("", "Preference", "", MOD_KEY.none, function() /*=>*/ {return dialogCall(o_dialog_preference)}); registerFunction("", "Preference", "", MOD_KEY.none, call_dialog_preference);
addHotkey("", "Splash screen", "", MOD_KEY.none, function() /*=>*/ {return dialogCall(o_dialog_splash)}); registerFunction("", "Splash screen", "", MOD_KEY.none, call_dialog_splash);
addHotkey("", "Release note", "", MOD_KEY.none, function() /*=>*/ {return dialogCall(o_dialog_release_note)}); registerFunction("", "Release note", "", MOD_KEY.none, call_dialog_release_note);
addHotkey("", "Autosave folder", "", MOD_KEY.none, function() /*=>*/ {return shellOpenExplorer(DIRECTORY + "autosave")}); registerFunction("", "Autosave folder", "", MOD_KEY.none, open_autosave_folder);
addHotkey("", "Recent files", "R", MOD_KEY.ctrl | MOD_KEY.shift, function() /*=>*/ { registerFunction("", "Recent files", "R", MOD_KEY.ctrl | MOD_KEY.shift, function() /*=>*/ {
var arr = []; var arr = [];
for(var i = 0; i < min(10, ds_list_size(RECENT_FILES)); i++) for(var i = 0; i < min(10, ds_list_size(RECENT_FILES)); i++)
array_push(arr, menuItem(RECENT_FILES[| i], function(_dat) { LOAD_PATH(_dat.name); })); array_push(arr, menuItemAction(RECENT_FILES[| i], function(_dat) { LOAD_PATH(_dat.name); }));
return menuCall("Recent files",,, arr); return menuCall("Recent files",,, arr);
}); });
addHotkey("", "Addons", "", MOD_KEY.none, function() /*=>*/ {return dialogPanelCall(new Panel_Addon())}); registerFunction("", "Addons", "", MOD_KEY.none, call_panel_addon);
addHotkey("", "History", "", MOD_KEY.none, function() /*=>*/ {return dialogPanelCall(new Panel_History())}); registerFunction("", "History", "", MOD_KEY.none, call_panel_history);
addHotkey("", "Notification Panel", "", MOD_KEY.none, function() /*=>*/ {return panelAdd("Panel_Notification", true)}); registerFunction("", "Notification Panel", "", MOD_KEY.none, call_panel_Notification );
addHotkey("", "Collections Panel", "", MOD_KEY.none, function() /*=>*/ {return panelAdd("Panel_Collection", true)}); registerFunction("", "Collections Panel", "", MOD_KEY.none, call_panel_Collection );
addHotkey("", "Graph Panel", "", MOD_KEY.none, function() /*=>*/ {return panelAdd("Panel_Graph", true)}); registerFunction("", "Graph Panel", "", MOD_KEY.none, call_panel_Graph );
addHotkey("", "Preview Panel", "", MOD_KEY.none, function() /*=>*/ {return panelAdd("Panel_Preview", true)}); registerFunction("", "Preview Panel", "", MOD_KEY.none, call_panel_Preview );
addHotkey("", "Inspector Panel", "", MOD_KEY.none, function() /*=>*/ {return panelAdd("Panel_Inspector", true)}); registerFunction("", "Preview Histogram", "", MOD_KEY.none, call_panel_Preview_Histogram );
addHotkey("", "Workspace Panel", "", MOD_KEY.none, function() /*=>*/ {return panelAdd("Panel_Workspace", true)}); registerFunction("", "Inspector Panel", "", MOD_KEY.none, call_panel_Inspector );
addHotkey("", "Animation Panel", "", MOD_KEY.none, function() /*=>*/ {return panelAdd("Panel_Animation", true)}); registerFunction("", "Workspace Panel", "", MOD_KEY.none, call_panel_Workspace );
addHotkey("", "Align Panel", "", MOD_KEY.none, function() /*=>*/ {return panelAdd("Panel_Node_Align", true)}); registerFunction("", "Animation Panel", "", MOD_KEY.none, call_panel_Animation );
addHotkey("", "Nodes Panel", "", MOD_KEY.none, function() /*=>*/ {return panelAdd("Panel_Nodes", true)});
addHotkey("", "Tunnels Panel", "", MOD_KEY.none, function() /*=>*/ {return panelAdd("Panel_Tunnels", true)}); registerFunction("", "Align Panel", "", MOD_KEY.none, call_panel_Node_Align );
addHotkey("", "Color Panel", "", MOD_KEY.none, function() /*=>*/ {return panelAdd("Panel_Color", true)}); registerFunction("", "Nodes Panel", "", MOD_KEY.none, call_panel_Nodes );
addHotkey("", "Palettes Panel", "", MOD_KEY.none, function() /*=>*/ {return panelAdd("Panel_Palette", true)}); registerFunction("", "Tunnels Panel", "", MOD_KEY.none, call_panel_Tunnels );
addHotkey("", "Gradients Panel", "", MOD_KEY.none, function() /*=>*/ {return panelAdd("Panel_Gradient", true)});
addHotkey("", "Console Panel", "", MOD_KEY.none, function() /*=>*/ {return panelAdd("Panel_Console", true)}); registerFunction("", "Color Panel", "", MOD_KEY.none, call_panel_Color );
registerFunction("", "Palettes Panel", "", MOD_KEY.none, call_panel_Palette );
registerFunction("", "Palettes Mixer Panel","", MOD_KEY.none, call_panel_Palette_Mixer );
registerFunction("", "Gradients Panel", "", MOD_KEY.none, call_panel_Gradient );
registerFunction("", "Console Panel", "", MOD_KEY.none, call_panel_Console );
registerFunction("", "Globalvar Panel", "", MOD_KEY.none, call_panel_Globalvar );
registerFunction("", "File Explorer Panel", "", MOD_KEY.none, call_panel_File_Explorer );
} }
#endregion #endregion

View file

@ -1,108 +1,128 @@
// function calls #region // function calls
function panel_graph_add_node() { CALL("graph_add_node"); PANEL_GRAPH.callAddDialog(); }
function panel_graph_focus_content() { CALL("graph_focus_content"); PANEL_GRAPH.fullView(); }
function panel_graph_preview_focus() { CALL("graph_preview_focus"); PANEL_GRAPH.setCurrentPreview(); }
function panel_graph_import_image() { CALL("graph_import_image"); PANEL_GRAPH.createNodeHotkey("Node_Image"); }
function panel_graph_import_image_array() { CALL("graph_import_image_array"); PANEL_GRAPH.createNodeHotkey("Node_Image_Sequence"); }
function panel_graph_add_number() { CALL("graph_add_number"); PANEL_GRAPH.createNodeHotkey("Node_Number"); }
function panel_graph_add_vec2() { CALL("graph_add_vec2"); PANEL_GRAPH.createNodeHotkey("Node_Vector2"); }
function panel_graph_add_vec3() { CALL("graph_add_vec3"); PANEL_GRAPH.createNodeHotkey("Node_Vector3"); }
function panel_graph_add_vec4() { CALL("graph_add_vec4"); PANEL_GRAPH.createNodeHotkey("Node_Vector4"); }
function panel_graph_add_display() { CALL("graph_add_disp"); PANEL_GRAPH.createNodeHotkey("Node_Display_Text"); }
function panel_graph_add_math_add() { CALL("graph_add_math_add"); PANEL_GRAPH.createNodeHotkey(Node_create_Math, { query: "add" }); }
function panel_graph_select_all() { CALL("graph_select_all"); PANEL_GRAPH.nodes_selecting = PANEL_GRAPH.nodes_list; }
function panel_graph_toggle_grid() { CALL("graph_toggle_grid"); PANEL_GRAPH.display_parameter.show_grid = !PANEL_GRAPH.display_parameter.show_grid; }
function panel_graph_export() { CALL("graph_export"); PANEL_GRAPH.setCurrentExport(); }
function panel_graph_add_transform() { CALL("graph_add_transform"); PANEL_GRAPH.doTransform(); }
function panel_graph_blend() { CALL("graph_blend"); PANEL_GRAPH.doBlend(); }
function panel_graph_compose() { CALL("graph_compose"); PANEL_GRAPH.doCompose(); }
function panel_graph_array() { CALL("graph_array"); PANEL_GRAPH.doArray(); }
function panel_graph_group() { CALL("graph_group"); PANEL_GRAPH.doGroup(); }
function panel_graph_ungroup() { CALL("graph_ungroup"); PANEL_GRAPH.doUngroup(); }
function panel_graph_canvas() { CALL("graph_canvas"); PANEL_GRAPH.setCurrentCanvas(); }
function panel_graph_canvas_blend() { CALL("graph_canvas_blend"); PANEL_GRAPH.setCurrentCanvasBlend(); }
function panel_graph_frame() { CALL("graph_frame"); PANEL_GRAPH.doFrame(); }
function panel_graph_delete_break() { CALL("graph_delete_break"); PANEL_GRAPH.doDelete(false); }
function panel_graph_delete_merge() { CALL("graph_delete_merge"); PANEL_GRAPH.doDelete(true); }
function panel_graph_duplicate() { CALL("graph_duplicate"); PANEL_GRAPH.doDuplicate(); }
function panel_graph_copy() { CALL("graph_copy"); PANEL_GRAPH.doCopy(); }
function panel_graph_paste() { CALL("graph_paste"); PANEL_GRAPH.doPaste(); }
function panel_graph_auto_align() { CALL("graph_auto_align"); node_auto_align(PANEL_GRAPH.nodes_selecting); }
function panel_graph_search() { CALL("graph_search"); PANEL_GRAPH.toggleSearch(); }
function panel_graph_toggle_minimap() { CALL("graph_toggle_minimap"); PANEL_GRAPH.minimap_show = !PANEL_GRAPH.minimap_show; }
function panel_graph_pan() { CALL("graph_pan"); if(PANEL_GRAPH.node_hovering || PANEL_GRAPH.value_focus) return; PANEL_GRAPH.graph_dragging_key = true; }
function panel_graph_zoom() { CALL("graph_zoom"); if(PANEL_GRAPH.node_hovering || PANEL_GRAPH.value_focus) return; PANEL_GRAPH.graph_zooming_key = true; }
function panel_graph_send_to_preview() { CALL("graph_send_to_preview"); PANEL_GRAPH.send_to_preview(); }
function panel_graph_preview_window() { CALL("graph_preview_window"); create_preview_window(PANEL_GRAPH.getFocusingNode()); }
function panel_graph_inspector_panel() { CALL("graph_inspector_panel"); PANEL_GRAPH.inspector_panel(); }
function panel_graph_send_to_export() { CALL("graph_send_to_export"); PANEL_GRAPH.send_to_export(); }
function panel_graph_toggle_preview() { CALL("graph_toggle_preview"); PANEL_GRAPH.setTriggerPreview(); }
function panel_graph_toggle_render() { CALL("graph_toggle_render"); PANEL_GRAPH.setTriggerRender(); }
function panel_graph_toggle_parameter() { CALL("graph_toggle_parameter"); PANEL_GRAPH.setTriggerParameter(); }
function panel_graph_enter_group() { CALL("graph_enter_group"); PANEL_GRAPH.enter_group(); }
function panel_graph_hide_disconnected() { CALL("graph_hide_disconnected"); PANEL_GRAPH.hide_disconnected(); }
function panel_graph_open_group_tab() { CALL("graph_open_group_tab"); PANEL_GRAPH.open_group_tab(); }
function panel_graph_set_as_tool() { CALL("graph_open_set_as_tool"); PANEL_GRAPH.set_as_tool(); }
function panel_graph_doCopyProp() { CALL("graph_doCopyProp"); PANEL_GRAPH.doCopyProp(); }
function panel_graph_doPasteProp() { CALL("graph_doPasteProp"); PANEL_GRAPH.doPasteProp(); }
function panel_graph_createTunnel() { CALL("graph_createTunnel"); PANEL_GRAPH.createTunnel(); }
function __fnInit_Graph() { function __fnInit_Graph() {
__registerFunction("graph_add_node", panel_graph_add_node); registerFunction("Graph", "Add Node", "A", MOD_KEY.none, panel_graph_add_node);
__registerFunction("graph_focus_content", panel_graph_focus_content); registerFunction("Graph", "Focus Content", "F", MOD_KEY.none, panel_graph_focus_content);
__registerFunction("graph_preview_focus", panel_graph_preview_focus); registerFunction("Graph", "Preview Focusing Node", "P", MOD_KEY.none, panel_graph_preview_focus);
__registerFunction("graph_preview_window", panel_graph_preview_window);
registerFunction("Graph", "Import Image", "I", MOD_KEY.none, panel_graph_import_image);
registerFunction("Graph", "Import Image Array", "I", MOD_KEY.shift, panel_graph_import_image_array);
registerFunction("Graph", "Add Number", "1", MOD_KEY.none, panel_graph_add_number);
registerFunction("Graph", "Add Vector2", "2", MOD_KEY.none, panel_graph_add_vec2);
registerFunction("Graph", "Add Vector3", "3", MOD_KEY.none, panel_graph_add_vec3);
registerFunction("Graph", "Add Vector4", "4", MOD_KEY.none, panel_graph_add_vec4);
registerFunction("Graph", "Add Display", "D", MOD_KEY.none, panel_graph_add_display);
registerFunction("Graph", "Transform Node", "T", MOD_KEY.ctrl, panel_graph_add_transform);
registerFunction("Graph", "Select All", "A", MOD_KEY.ctrl, panel_graph_select_all);
registerFunction("Graph", "Toggle Grid", "G", MOD_KEY.none, panel_graph_toggle_grid);
if(!DEMO) registerFunction("Graph", "Export", "E", MOD_KEY.ctrl, panel_graph_export);
registerFunction("Graph", "Blend", "B", MOD_KEY.ctrl, panel_graph_blend);
registerFunction("Graph", "Compose", "B", MOD_KEY.ctrl | MOD_KEY.shift, panel_graph_compose);
registerFunction("Graph", "Array", "A", MOD_KEY.ctrl | MOD_KEY.shift, panel_graph_array);
registerFunction("Graph", "Group", "G", MOD_KEY.ctrl, panel_graph_group);
registerFunction("Graph", "Ungroup", "G", MOD_KEY.ctrl | MOD_KEY.shift, panel_graph_ungroup);
registerFunction("Graph", "Frame", "F", MOD_KEY.shift, panel_graph_frame);
registerFunction("Graph", "Canvas", "C", MOD_KEY.ctrl | MOD_KEY.shift, panel_graph_canvas);
registerFunction("Graph", "Canvas Blend", "C", MOD_KEY.ctrl | MOD_KEY.alt, panel_graph_canvas_blend);
registerFunction("Graph", "Delete (break)", vk_delete, MOD_KEY.shift, panel_graph_delete_break);
registerFunction("Graph", "Delete (merge)", vk_delete, MOD_KEY.none, panel_graph_delete_merge);
registerFunction("Graph", "Duplicate", "D", MOD_KEY.ctrl, panel_graph_duplicate);
registerFunction("Graph", "Copy", "C", MOD_KEY.ctrl, panel_graph_copy);
registerFunction("Graph", "Paste", "V", MOD_KEY.ctrl, panel_graph_paste);
__registerFunction("graph_import_image", panel_graph_import_image); registerFunction("Graph", "Pan", "", MOD_KEY.ctrl, panel_graph_pan);
__registerFunction("graph_import_image_array", panel_graph_import_image_array); registerFunction("Graph", "Zoom", "", MOD_KEY.alt | MOD_KEY.ctrl, panel_graph_zoom);
__registerFunction("graph_add_number", panel_graph_add_number);
__registerFunction("graph_add_vec2", panel_graph_add_vec2);
__registerFunction("graph_add_vec3", panel_graph_add_vec3);
__registerFunction("graph_add_vec4", panel_graph_add_vec4);
__registerFunction("graph_add_display", panel_graph_add_display);
__registerFunction("graph_add_transform", panel_graph_add_transform);
__registerFunction("graph_select_all", panel_graph_select_all); registerFunction("Graph", "Auto Align", "L", MOD_KEY.none, panel_graph_auto_align);
__registerFunction("graph_toggle_grid", panel_graph_toggle_grid); registerFunction("Graph", "Search", "F", MOD_KEY.ctrl, panel_graph_search);
__registerFunction("graph_toggle_preview", panel_graph_toggle_preview); registerFunction("Graph", "Toggle Minimap", "M", MOD_KEY.ctrl, panel_graph_toggle_minimap);
__registerFunction("graph_toggle_render", panel_graph_toggle_render);
__registerFunction("graph_export", panel_graph_export); registerFunction("Graph", "Preview Hovering Node", "", MOD_KEY.none, panel_graph_send_to_preview);
registerFunction("Graph", "Preview Window", "P", MOD_KEY.ctrl, panel_graph_preview_window);
registerFunction("Graph", "Inspect", "", MOD_KEY.none, panel_graph_inspector_panel);
if(!DEMO) registerFunction("Graph", "Export", "", MOD_KEY.none, panel_graph_send_to_export);
registerFunction("Graph", "Toggle Preview", "H", MOD_KEY.none, panel_graph_toggle_preview);
registerFunction("Graph", "Toggle Render", "R", MOD_KEY.none, panel_graph_toggle_render);
registerFunction("Graph", "Toggle Parameters", "M", MOD_KEY.none, panel_graph_toggle_parameter);
registerFunction("Graph", "Enter Group", "", MOD_KEY.none, panel_graph_enter_group);
registerFunction("Graph", "Hide Disconnected", "", MOD_KEY.none, panel_graph_hide_disconnected);
__registerFunction("graph_blend", panel_graph_blend); registerFunction("Graph", "Open In New Tab", "", MOD_KEY.none, panel_graph_open_group_tab);
__registerFunction("graph_compose", panel_graph_compose); registerFunction("Graph", "Set As Tool", "", MOD_KEY.none, panel_graph_set_as_tool);
__registerFunction("graph_array", panel_graph_array);
__registerFunction("graph_group", panel_graph_group); registerFunction("Graph", "Copy Value", "", MOD_KEY.none, panel_graph_doCopyProp);
__registerFunction("graph_ungroup", panel_graph_ungroup); registerFunction("Graph", "Paste Value", "", MOD_KEY.none, panel_graph_doPasteProp);
registerFunction("Graph", "Create Tunnel", "", MOD_KEY.none, panel_graph_createTunnel);
__registerFunction("graph_canvas", panel_graph_canvas);
__registerFunction("graph_canvas_blend", panel_graph_canvas_blend);
__registerFunction("graph_frame", panel_graph_frame);
__registerFunction("graph_delete_break", panel_graph_delete_break);
__registerFunction("graph_delete_merge", panel_graph_delete_merge);
__registerFunction("graph_duplicate", panel_graph_duplicate);
__registerFunction("graph_copy", panel_graph_copy);
__registerFunction("graph_paste", panel_graph_paste);
__registerFunction("graph_pan", panel_graph_pan);
__registerFunction("graph_zoom", panel_graph_zoom);
}
function panel_graph_add_node() { CALL("graph_add_node"); PANEL_GRAPH.callAddDialog(); }
function panel_graph_focus_content() { CALL("graph_focus_content"); PANEL_GRAPH.fullView(); }
function panel_graph_preview_focus() { CALL("graph_preview_focus"); PANEL_GRAPH.setCurrentPreview(); }
function panel_graph_preview_window() { CALL("graph_preview_window"); PANEL_GRAPH.create_preview_window(PANEL_GRAPH.getFocusingNode()); }
function panel_graph_import_image() { CALL("graph_import_image"); PANEL_GRAPH.createNodeHotkey("Node_Image"); }
function panel_graph_import_image_array() { CALL("graph_import_image_array"); PANEL_GRAPH.createNodeHotkey("Node_Image_Sequence"); }
function panel_graph_add_number() { CALL("graph_add_number"); PANEL_GRAPH.createNodeHotkey("Node_Number"); }
function panel_graph_add_vec2() { CALL("graph_add_vec2"); PANEL_GRAPH.createNodeHotkey("Node_Vector2"); }
function panel_graph_add_vec3() { CALL("graph_add_vec3"); PANEL_GRAPH.createNodeHotkey("Node_Vector3"); }
function panel_graph_add_vec4() { CALL("graph_add_vec4"); PANEL_GRAPH.createNodeHotkey("Node_Vector4"); }
function panel_graph_add_display() { CALL("graph_add_disp"); PANEL_GRAPH.createNodeHotkey("Node_Display_Text"); }
function panel_graph_add_math_add() { CALL("graph_add_math_add"); PANEL_GRAPH.createNodeHotkey(Node_create_Math, { query: "add" }); }
function panel_graph_select_all() { CALL("graph_select_all"); PANEL_GRAPH.nodes_selecting = PANEL_GRAPH.nodes_list; }
function panel_graph_toggle_grid() { CALL("graph_toggle_grid"); PANEL_GRAPH.display_parameter.show_grid = !PANEL_GRAPH.display_parameter.show_grid; }
function panel_graph_toggle_preview() { CALL("graph_toggle_preview"); PANEL_GRAPH.setTriggerPreview(); }
function panel_graph_toggle_parameter() { CALL("graph_toggle_parameter"); PANEL_GRAPH.setTriggerParameter(); }
function panel_graph_toggle_render() { CALL("graph_toggle_render"); PANEL_GRAPH.setTriggerRender(); }
function panel_graph_export() { CALL("graph_export"); PANEL_GRAPH.setCurrentExport(); }
function panel_graph_add_transform() { CALL("graph_add_transform"); PANEL_GRAPH.doTransform(); }
function panel_graph_blend() { CALL("graph_blend"); PANEL_GRAPH.doBlend(); }
function panel_graph_compose() { CALL("graph_compose"); PANEL_GRAPH.doCompose(); }
function panel_graph_array() { CALL("graph_array"); PANEL_GRAPH.doArray(); }
function panel_graph_group() { CALL("graph_group"); PANEL_GRAPH.doGroup(); }
function panel_graph_ungroup() { CALL("graph_ungroup"); PANEL_GRAPH.doUngroup(); }
function panel_graph_canvas() { CALL("graph_canvas"); PANEL_GRAPH.setCurrentCanvas(); }
function panel_graph_canvas_blend() { CALL("graph_canvas_blend"); PANEL_GRAPH.setCurrentCanvasBlend(); }
function panel_graph_frame() { CALL("graph_frame"); PANEL_GRAPH.doFrame(); }
function panel_graph_delete_break() { CALL("graph_delete_break"); PANEL_GRAPH.doDelete(false); }
function panel_graph_delete_merge() { CALL("graph_delete_merge"); PANEL_GRAPH.doDelete(true); }
function panel_graph_duplicate() { CALL("graph_duplicate"); PANEL_GRAPH.doDuplicate(); }
function panel_graph_copy() { CALL("graph_copy"); PANEL_GRAPH.doCopy(); }
function panel_graph_paste() { CALL("graph_paste"); PANEL_GRAPH.doPaste(); }
function panel_graph_auto_align() { CALL("graph_auto_align"); node_auto_align(PANEL_GRAPH.nodes_selecting); }
function panel_graph_search() { CALL("graph_search"); PANEL_GRAPH.toggleSearch(); }
function panel_graph_toggle_minimap() { CALL("graph_toggle_minimap"); PANEL_GRAPH.minimap_show = !PANEL_GRAPH.minimap_show; }
function panel_graph_pan() {
CALL("graph_pan");
if(PANEL_GRAPH.node_hovering) return;
if(PANEL_GRAPH.value_focus) return;
PANEL_GRAPH.graph_dragging_key = true;
}
function panel_graph_zoom() {
CALL("graph_zoom");
if(PANEL_GRAPH.node_hovering) return;
if(PANEL_GRAPH.value_focus) return;
PANEL_GRAPH.graph_zooming_key = true;
} }
#endregion
function connectionParameter() constructor {
function connectionParameter() constructor { //
log = false; log = false;
active = true; active = true;
@ -167,7 +187,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
resetContext(); resetContext();
} }
// ---- display ---- #region // ---- display ----
display_parameter = { display_parameter = {
show_grid : true, show_grid : true,
show_dimension : true, show_dimension : true,
@ -186,9 +206,9 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
bg_color = c_black; bg_color = c_black;
slider_width = 0; slider_width = 0;
#endregion
#region // ---- position ----
// ---- position ----
graph_x = 0; graph_x = 0;
graph_y = 0; graph_y = 0;
graph_cx = 0; graph_cx = 0;
@ -224,9 +244,9 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
drag_key = PREFERENCES.pan_mouse_key; drag_key = PREFERENCES.pan_mouse_key;
drag_locking = false; drag_locking = false;
#endregion
#region // ---- mouse ----
// ---- mouse ----
mouse_graph_x = 0; mouse_graph_x = 0;
mouse_graph_y = 0; mouse_graph_y = 0;
mouse_grid_x = 0; mouse_grid_x = 0;
@ -239,9 +259,9 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
mouse_on_graph = false; mouse_on_graph = false;
node_bg_hovering = false; node_bg_hovering = false;
#endregion
#region // ---- nodes ----
// ---- nodes ----
node_context = []; node_context = [];
nodes_list = []; nodes_list = [];
@ -291,9 +311,9 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
frame_hovering = noone; frame_hovering = noone;
_frame_hovering = noone; _frame_hovering = noone;
#endregion
#region // ---- minimap ----
// ---- minimap ----
minimap_show = false; minimap_show = false;
minimap_w = ui(160); minimap_w = ui(160);
minimap_h = ui(160); minimap_h = ui(160);
@ -305,17 +325,17 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
minimap_drag_sy = 0; minimap_drag_sy = 0;
minimap_drag_mx = 0; minimap_drag_mx = 0;
minimap_drag_my = 0; minimap_drag_my = 0;
#endregion
#region // ---- context frame ----
// ---- context frame ----
context_framing = false; context_framing = false;
context_frame_progress = 0; context_frame_progress = 0;
context_frame_direct = 0; context_frame_direct = 0;
context_frame_sx = 0; context_frame_ex = 0; context_frame_sx = 0; context_frame_ex = 0;
context_frame_sy = 0; context_frame_ey = 0; context_frame_sy = 0; context_frame_ey = 0;
#endregion
#region // ---- search ----
// ---- search ----
is_searching = false; is_searching = false;
search_string = ""; search_string = "";
search_index = 0; search_index = 0;
@ -324,7 +344,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
tb_search = new textBox(TEXTBOX_INPUT.text, function(str) /*=>*/ { search_string = string(str); searchNodes(); }); tb_search = new textBox(TEXTBOX_INPUT.text, function(str) /*=>*/ { search_string = string(str); searchNodes(); });
tb_search.align = fa_left; tb_search.align = fa_left;
tb_search.auto_update = true; tb_search.auto_update = true;
#endregion
toolbar_height = ui(40); toolbar_height = ui(40);
@ -374,56 +394,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
function initSize() { toCenterNode(); } function initSize() { toCenterNode(); }
// ++++ hotkeys ++++ #region // ++++ toolbars ++++
addHotkey("Graph", "Add node", "A", MOD_KEY.none, panel_graph_add_node);
addHotkey("Graph", "Focus content", "F", MOD_KEY.none, panel_graph_focus_content);
addHotkey("Graph", "Preview focusing node", "P", MOD_KEY.none, panel_graph_preview_focus);
addHotkey("Graph", "Preview window", "P", MOD_KEY.ctrl, panel_graph_preview_window);
addHotkey("Graph", "Import image", "I", MOD_KEY.none, panel_graph_import_image);
addHotkey("Graph", "Import image array", "I", MOD_KEY.shift, panel_graph_import_image_array);
addHotkey("Graph", "Add Number", "1", MOD_KEY.none, panel_graph_add_number);
addHotkey("Graph", "Add Vector2", "2", MOD_KEY.none, panel_graph_add_vec2);
addHotkey("Graph", "Add Vector3", "3", MOD_KEY.none, panel_graph_add_vec3);
addHotkey("Graph", "Add Vector4", "4", MOD_KEY.none, panel_graph_add_vec4);
addHotkey("Graph", "Add Display", "D", MOD_KEY.none, panel_graph_add_display);
addHotkey("Graph", "Transform node", "T", MOD_KEY.ctrl, panel_graph_add_transform);
addHotkey("Graph", "Select all", "A", MOD_KEY.ctrl, panel_graph_select_all);
addHotkey("Graph", "Toggle grid", "G", MOD_KEY.none, panel_graph_toggle_grid);
addHotkey("Graph", "Toggle preview", "H", MOD_KEY.none, panel_graph_toggle_preview);
addHotkey("Graph", "Toggle render", "R", MOD_KEY.none, panel_graph_toggle_render);
addHotkey("Graph", "Toggle parameters", "M", MOD_KEY.none, panel_graph_toggle_parameter);
if(!DEMO) addHotkey("Graph", "Export", "E", MOD_KEY.ctrl, panel_graph_export);
addHotkey("Graph", "Blend", "B", MOD_KEY.ctrl, panel_graph_blend);
addHotkey("Graph", "Compose", "B", MOD_KEY.ctrl | MOD_KEY.shift, panel_graph_compose);
addHotkey("Graph", "Array", "A", MOD_KEY.ctrl | MOD_KEY.shift, panel_graph_array);
addHotkey("Graph", "Group", "G", MOD_KEY.ctrl, panel_graph_group);
addHotkey("Graph", "Ungroup", "G", MOD_KEY.ctrl | MOD_KEY.shift, panel_graph_ungroup);
addHotkey("Graph", "Canvas", "C", MOD_KEY.ctrl | MOD_KEY.shift, panel_graph_canvas);
addHotkey("Graph", "Canvas blend", "C", MOD_KEY.ctrl | MOD_KEY.alt, panel_graph_canvas_blend);
addHotkey("Graph", "Frame", "F", MOD_KEY.shift, panel_graph_frame);
addHotkey("Graph", "Delete (break)", vk_delete, MOD_KEY.shift, panel_graph_delete_break);
addHotkey("Graph", "Delete (merge)", vk_delete, MOD_KEY.none, panel_graph_delete_merge);
addHotkey("Graph", "Duplicate", "D", MOD_KEY.ctrl, panel_graph_duplicate);
addHotkey("Graph", "Copy", "C", MOD_KEY.ctrl, panel_graph_copy);
addHotkey("Graph", "Paste", "V", MOD_KEY.ctrl, panel_graph_paste);
addHotkey("Graph", "Pan", "", MOD_KEY.ctrl, panel_graph_pan);
addHotkey("Graph", "Zoom", "", MOD_KEY.alt | MOD_KEY.ctrl, panel_graph_zoom);
addHotkey("Graph", "Auto Align", "L", MOD_KEY.none, panel_graph_auto_align);
addHotkey("Graph", "Search", "F", MOD_KEY.ctrl, panel_graph_search);
addHotkey("Graph", "Toggle Minimap", "M", MOD_KEY.ctrl, panel_graph_toggle_minimap);
// ++++ toolbars ++++
tooltip_center = new tooltipHotkey(__txtx("panel_graph_center_to_nodes", "Center to nodes"), "Graph", "Focus content"); tooltip_center = new tooltipHotkey(__txtx("panel_graph_center_to_nodes", "Center to nodes"), "Graph", "Focus content");
tooltip_search = new tooltipHotkey(__txt("Search"), "Graph", "Search"); tooltip_search = new tooltipHotkey(__txt("Search"), "Graph", "Search");
tooltip_minimap = new tooltipHotkey(__txtx("panel_graph_toggle_minimap", "Toggle minimap"), "Graph", "Toggle Minimap"); tooltip_minimap = new tooltipHotkey(__txtx("panel_graph_toggle_minimap", "Toggle minimap"), "Graph", "Toggle Minimap");
@ -491,7 +462,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
]; ];
toolbars = [ toolbars_general ]; toolbars = [ toolbars_general ];
#endregion
//// =========== Get Set =========== //// =========== Get Set ===========
@ -612,74 +583,91 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
//// =========== Menus =========== //// =========== Menus ===========
menu_sent_to_preview = menuItem(__txtx("panel_graph_send_to_preview", "Send to preview"), function() /*=>*/ { setCurrentPreview(node_hover); }); #region ++++++++++++ Actions ++++++++++++
menu_send_to_window = menuItem(__txtx("panel_graph_preview_window", "Send to preview window"), function() /*=>*/ { create_preview_window(node_hover); }, noone, ["Graph", "Preview window"]); function send_to_preview() { setCurrentPreview(node_hover); }
menu_sent_to_inspector = menuItem(__txtx("panel_graph_inspector_panel", "Send to new inspector"), function() /*=>*/ {
var pan = panelAdd("Panel_Inspector", true);
pan.destroy_on_click_out = false;
pan.content.setInspecting(node_hover);
pan.content.locked = true;
});
menu_send_export = menuItem(__txtx("panel_graph_send_to_export", "Send to export"), function() /*=>*/ { setCurrentExport(node_hover); }, noone, ["Graph", "Export"]);
menu_toggle_preview = menuItem(__txtx("panel_graph_toggle_preview", "Toggle node preview"), function() /*=>*/ { setTriggerPreview(); }, noone, ["Graph", "Toggle preview"]);
menu_toggle_render = menuItem(__txtx("panel_graph_toggle_render", "Toggle node render"), function() /*=>*/ { setTriggerRender(); }, noone, ["Graph", "Toggle render"]);
menu_toggle_param = menuItem(__txtx("panel_graph_toggle_parameter", "Toggle node parameters"), function() /*=>*/ { setTriggerParameter(); }, noone, ["Graph", "Toggle parameters"]);
menu_open_group = menuItem(__txtx("panel_graph_enter_group", "Open group"), function() /*=>*/ { PANEL_GRAPH.addContext(node_hover); }, THEME.group);
menu_hide_disconnect = menuItem(__txtx("panel_graph_hide_disconnected", "Hide stray junctions"), function() /*=>*/ { hideDisconnected(); });
function openGroupTab(group) {
var graph = new Panel_Graph(project);
panel.setContent(graph, true);
for( var i = 0; i < array_length(node_context); i++ )
graph.addContext(node_context[i]);
graph.addContext(group);
setFocus(panel); function inspector_panel() {
} var pan = panelAdd("Panel_Inspector", true);
pan.destroy_on_click_out = false;
pan.content.setInspecting(node_hover);
pan.content.locked = true;
}
function send_to_export() { setCurrentExport(node_hover); }
function enter_group() { PANEL_GRAPH.addContext(node_hover); }
function hide_disconnected() { hideDisconnected(); }
function open_group_tab(group = node_hover) {
if(group == noone) return;
var graph = new Panel_Graph(project);
panel.setContent(graph, true);
for( var i = 0; i < array_length(node_context); i++ )
graph.addContext(node_context[i]);
graph.addContext(group);
setFocus(panel);
}
function set_as_tool() {
if(node_hover == noone) return;
node_hover.setTool(!node_hover.isTool);
}
#endregion
menu_open_group_tab = menuItem(__txtx("panel_graph_enter_group_new_tab", "Open group in new tab"), function() /*=>*/ { openGroupTab(node_hover); }, THEME.group); menu_sent_to_preview = menuItemAction(__txtx("panel_graph_send_to_preview", "Send to preview"), panel_graph_send_to_preview);
menu_group_group = menuItem(__txt("Group"), function() /*=>*/ { doGroup(); }, THEME.group, ["Graph", "group"]); menu_send_to_window = menuItemAction(__txtx("panel_graph_preview_window", "Send to preview window"), panel_graph_preview_window);
menu_group_ungroup = menuItem(__txt("Ungroup"), function() /*=>*/ { doUngroup(); }, THEME.group, ["Graph", "Ungroup"]); menu_sent_to_inspector = menuItemAction(__txtx("panel_graph_inspector_panel", "Send to new inspector"), panel_graph_inspector_panel);
menu_group_tool = menuItem(__txt("Set as group tool"), function() /*=>*/ { node_hover.setTool(!node_hover.isTool); }); menu_send_export = menuItemAction(__txtx("panel_graph_send_to_export", "Send to export"), panel_graph_send_to_export);
menu_toggle_preview = menuItemAction(__txtx("panel_graph_toggle_preview", "Toggle node preview"), panel_graph_toggle_preview);
menu_toggle_render = menuItemAction(__txtx("panel_graph_toggle_render", "Toggle node render"), panel_graph_toggle_render);
menu_toggle_param = menuItemAction(__txtx("panel_graph_toggle_parameter", "Toggle node parameters"), panel_graph_toggle_parameter);
menu_open_group = menuItemAction(__txtx("panel_graph_enter_group", "Open group"), panel_graph_enter_group, THEME.group);
menu_hide_disconnect = menuItemAction(__txtx("panel_graph_hide_disconnected", "Hide stray junctions"), panel_graph_hide_disconnected);
menu_open_group_tab = menuItemAction(__txtx("panel_graph_enter_group_new_tab", "Open group in new tab"), panel_graph_open_group_tab, THEME.group);
menu_group_group = menuItemAction(__txt("Group"), panel_graph_group, THEME.group);
menu_group_ungroup = menuItemAction(__txt("Ungroup"), panel_graph_ungroup, THEME.group);
menu_group_tool = menuItemAction(__txt("Set as group tool"), panel_graph_set_as_tool);
menu_node_delete_merge = menuItem(__txtx("panel_graph_delete_and_merge_connection", "Delete and merge connection"), function() /*=>*/ { doDelete(true); }, THEME.cross, ["Graph", "Delete (merge)"]); menu_node_delete_cut = menuItemAction(__txtx("panel_graph_delete_and_cut_connection", "Delete and cut connection"), panel_graph_delete_break, THEME.cross);
menu_node_delete_cut = menuItem(__txtx("panel_graph_delete_and_cut_connection", "Delete and cut connection"), function() /*=>*/ { doDelete(false); }, THEME.cross, ["Graph", "Delete (break)"]); menu_node_delete_merge = menuItemAction(__txtx("panel_graph_delete_and_merge_connection", "Delete and merge connection"), panel_graph_delete_merge, THEME.cross);
menu_node_duplicate = menuItem(__txt("Duplicate"), function() /*=>*/ { doDuplicate(); }, THEME.duplicate, ["Graph", "Duplicate"]); menu_node_duplicate = menuItemAction(__txt("Duplicate"), panel_graph_duplicate, THEME.duplicate);
menu_node_copy = menuItem(__txt("Copy"), function() /*=>*/ { doCopy(); }, THEME.copy, ["Graph", "Copy"]); menu_node_copy = menuItemAction(__txt("Copy"), panel_graph_copy, THEME.copy);
menu_node_transform = menuItem(__txtx("panel_graph_add_transform", "Add transform"), function() /*=>*/ { doTransform(); }, noone, ["Graph", "Transform node"]); menu_node_transform = menuItemAction(__txtx("panel_graph_add_transform", "Add transform"), panel_graph_add_transform);
menu_node_canvas = menuItem(__txtx("panel_graph_canvas", "Canvas"), menu_node_canvas = menuItemAction(__txtx("panel_graph_canvas", "Canvas"),
function(_dat) { function(_dat) {
return submenuCall(_dat, [ return submenuCall(_dat, [
menuItem(__txtx("panel_graph_copy_to_canvas", "Copy to canvas"), function() /*=>*/ { setCurrentCanvas(node_hover); }, noone, ["Graph", "Canvas"]), menuItemAction(__txtx("panel_graph_copy_to_canvas", "Copy to canvas"), panel_graph_canvas),
menuItem(__txtx("panel_graph_overlay_canvas", "Overlay canvas"), function() /*=>*/ { setCurrentCanvasBlend(node_hover); }, noone, ["Graph", "Canvas blend"]) menuItemAction(__txtx("panel_graph_overlay_canvas", "Overlay canvas"), panel_graph_canvas_blend)
]); ]);
}).setIsShelf(); }).setIsShelf();
menu_nodes_align = menuItemGroup(__txtx("panel_graph_align_nodes", "Align"), [ menu_nodes_align = menuItemGroup(__txtx("panel_graph_align_nodes", "Align"), [
[ [THEME.inspector_surface_halign, 0], function() /*=>*/ { node_halign(nodes_selecting, fa_left); } ], [ [THEME.inspector_surface_halign, 0], function() { node_halign(nodes_selecting, fa_left); } ],
[ [THEME.inspector_surface_halign, 1], function() /*=>*/ { node_halign(nodes_selecting, fa_center); } ], [ [THEME.inspector_surface_halign, 1], function() { node_halign(nodes_selecting, fa_center); } ],
[ [THEME.inspector_surface_halign, 2], function() /*=>*/ { node_halign(nodes_selecting, fa_right); } ], [ [THEME.inspector_surface_halign, 2], function() { node_halign(nodes_selecting, fa_right); } ],
[ [THEME.inspector_surface_valign, 0], function() /*=>*/ { node_valign(nodes_selecting, fa_top); } ], [ [THEME.inspector_surface_valign, 0], function() { node_valign(nodes_selecting, fa_top); } ],
[ [THEME.inspector_surface_valign, 1], function() /*=>*/ { node_valign(nodes_selecting, fa_middle); } ], [ [THEME.inspector_surface_valign, 1], function() { node_valign(nodes_selecting, fa_middle); } ],
[ [THEME.inspector_surface_valign, 2], function() /*=>*/ { node_valign(nodes_selecting, fa_bottom); } ], [ [THEME.inspector_surface_valign, 2], function() { node_valign(nodes_selecting, fa_bottom); } ],
[ [THEME.obj_distribute_h, 0], function() /*=>*/ { node_hdistribute(nodes_selecting); } ], [ [THEME.obj_distribute_h, 0], function() { node_hdistribute(nodes_selecting); } ],
[ [THEME.obj_distribute_v, 0], function() /*=>*/ { node_vdistribute(nodes_selecting); } ], [ [THEME.obj_distribute_v, 0], function() { node_vdistribute(nodes_selecting); } ],
]); ]);
menu_nodes_blend = menuItem(__txtx("panel_graph_blend_nodes", "Blend nodes"), function() /*=>*/ { doBlend(); }, noone, ["Graph", "Blend"]); menu_nodes_blend = menuItemAction(__txtx("panel_graph_blend_nodes", "Blend nodes"), panel_graph_blend);
menu_nodes_compose = menuItem(__txtx("panel_graph_compose_nodes", "Compose nodes"), function() /*=>*/ { doCompose(); }, noone, ["Graph", "Compose"]); menu_nodes_compose = menuItemAction(__txtx("panel_graph_compose_nodes", "Compose nodes"), panel_graph_compose);
menu_nodes_array = menuItem(__txtx("panel_graph_array_from_nodes", "Array from nodes"), function() /*=>*/ { doArray(); }, noone, ["Graph", "Array"]); menu_nodes_array = menuItemAction(__txtx("panel_graph_array_from_nodes", "Array from nodes"), panel_graph_array);
menu_nodes_group = menuItem(__txtx("panel_graph_group_nodes", "Group nodes"), function() /*=>*/ { doGroup(); }, THEME.group, ["Graph", "Group"]); menu_nodes_group = menuItemAction(__txtx("panel_graph_group_nodes", "Group nodes"), panel_graph_group);
menu_nodes_frame = menuItem(__txtx("panel_graph_frame_nodes", "Frame nodes"), function() /*=>*/ { doFrame(); }, noone, ["Graph", "Frame"]); menu_nodes_frame = menuItemAction(__txtx("panel_graph_frame_nodes", "Frame nodes"), panel_graph_frame);
menu_node_copy_prop = menuItem(__txtx("panel_graph_copy_prop", "Copy all properties"), function() /*=>*/ { doCopyProp(); }); menu_node_copy_prop = menuItemAction(__txtx("panel_graph_copy_prop", "Copy all properties"), panel_graph_doCopyProp);
menu_node_paste_prop = menuItem(__txtx("panel_graph_paste_prop", "Paste all properties"), function() /*=>*/ { doPasteProp(); }); menu_node_paste_prop = menuItemAction(__txtx("panel_graph_paste_prop", "Paste all properties"), panel_graph_doPasteProp);
menu_connection_tunnel = menuItem(__txtx("panel_graph_tunnel", "Create tunnels"), function() /*=>*/ { createTunnel(); }); menu_connection_tunnel = menuItemAction(__txtx("panel_graph_tunnel", "Create tunnels"), panel_graph_createTunnel);
// node color // node color
function setSelectingNodeColor(color) { function setSelectingNodeColor(color) {
@ -1337,7 +1325,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
var _to = value_focus.value_to[i]; var _to = value_focus.value_to[i];
var _lb = $"[{_to.node.display_name}] {_to.getName()}"; var _lb = $"[{_to.node.display_name}] {_to.getName()}";
array_push(menu, menuItem(_lb, function(data) /*=>*/ { data.params.juncTo.removeFrom(); }, THEME.cross, noone, noone, { juncTo: _to })); array_push(menu, menuItemAction(_lb, function(data) /*=>*/ { data.params.juncTo.removeFrom(); }, THEME.cross, noone, noone, { juncTo: _to }));
} }
for( var i = 0, n = array_length(value_focus.value_to_loop); i < n; i++ ) { for( var i = 0, n = array_length(value_focus.value_to_loop); i < n; i++ ) {
@ -1345,7 +1333,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
var _to = value_focus.value_to_loop[i]; var _to = value_focus.value_to_loop[i];
var _lb = $"[{_to.junc_in.node.display_name}] {_to.junc_in.getName()}"; var _lb = $"[{_to.junc_in.node.display_name}] {_to.junc_in.getName()}";
array_push(menu, menuItem(_lb, function(data) /*=>*/ { data.params.juncTo.destroy(); }, _to.icon_24, noone, noone, { juncTo: _to })); array_push(menu, menuItemAction(_lb, function(data) /*=>*/ { data.params.juncTo.destroy(); }, _to.icon_24, noone, noone, { juncTo: _to }));
} }
} else { } else {
var sep = false; var sep = false;
@ -1355,7 +1343,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
var _jun = value_focus.value_from; var _jun = value_focus.value_from;
var _lb = $"[{_jun.node.display_name}] {_jun.getName()}"; var _lb = $"[{_jun.node.display_name}] {_jun.getName()}";
array_push(menu, menuItem(_lb, function(data) /*=>*/ { __junction_hovering.removeFrom(); }, THEME.cross)); array_push(menu, menuItemAction(_lb, function(data) /*=>*/ { __junction_hovering.removeFrom(); }, THEME.cross));
} }
if(value_focus.value_from_loop) { if(value_focus.value_from_loop) {
@ -1363,7 +1351,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
var _jun = value_focus.value_from_loop.junc_out; var _jun = value_focus.value_from_loop.junc_out;
var _lb = $"[{_jun.node.display_name}] {_jun.getName()}"; var _lb = $"[{_jun.node.display_name}] {_jun.getName()}";
array_push(menu, menuItem(_lb, function(data) /*=>*/ { __junction_hovering.removeFromLoop(); }, value_focus.value_from_loop.icon_24)); array_push(menu, menuItemAction(_lb, function(data) /*=>*/ { __junction_hovering.removeFromLoop(); }, value_focus.value_from_loop.icon_24));
} }
} }
@ -1405,19 +1393,19 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(junction_hovering != noone) if(junction_hovering != noone)
array_push(menu, menu_junc_color, menu_connection_tunnel, -1); array_push(menu, menu_junc_color, menu_connection_tunnel, -1);
array_push(menu, menuItem(__txt("Copy"), function() { doCopy(); }, THEME.copy, ["Graph", "Copy"]).setActive(array_length(nodes_selecting))); array_push(menu, menuItemAction(__txt("Copy"), panel_graph_copy, THEME.copy).setActive(array_length(nodes_selecting)));
array_push(menu, menuItem(__txt("Paste"), function() { doPaste(); }, THEME.paste, ["Graph", "Paste"]).setActive(clipboard_get_text() != "")); array_push(menu, menuItemAction(__txt("Paste"), panel_graph_paste, THEME.paste).setActive(clipboard_get_text() != ""));
if(junction_hovering != noone) { if(junction_hovering != noone) {
array_push(menu, -1); array_push(menu, -1);
if(is_instanceof(junction_hovering, Node_Feedback_Inline)) { if(is_instanceof(junction_hovering, Node_Feedback_Inline)) {
var _jun = junction_hovering.junc_out; var _jun = junction_hovering.junc_out;
array_push(menu, menuItem($"[{_jun.node.display_name}] {_jun.getName()}", function(data) /*=>*/ { __junction_hovering.destroy(); }, THEME.feedback)); array_push(menu, menuItemAction($"[{_jun.node.display_name}] {_jun.getName()}", function(data) /*=>*/ { __junction_hovering.destroy(); }, THEME.feedback));
} else { } else {
var _jun = junction_hovering.value_from; var _jun = junction_hovering.value_from;
array_push(menu, menuItem($"[{_jun.node.display_name}] {_jun.getName()}", function(data) /*=>*/ { __junction_hovering.removeFrom(); }, THEME.cross)); array_push(menu, menuItemAction($"[{_jun.node.display_name}] {_jun.getName()}", function(data) /*=>*/ { __junction_hovering.removeFrom(); }, THEME.cross));
} }
} }
@ -1806,7 +1794,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
_connect[1].value_from_loop.destroy(); _connect[1].value_from_loop.destroy();
var menu = [ var menu = [
menuItem("Feedback", function(data) { menuItemAction("Feedback", function(data) {
var junc_in = data.params.junc_in; var junc_in = data.params.junc_in;
var junc_out = data.params.junc_out; var junc_out = data.params.junc_out;
@ -1818,7 +1806,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
}, THEME.feedback_24,,, { junc_in : _connect[1], junc_out : _connect[2] }), }, THEME.feedback_24,,, { junc_in : _connect[1], junc_out : _connect[2] }),
menuItem("Loop", function(data) { menuItemAction("Loop", function(data) {
var junc_in = data.params.junc_in; var junc_in = data.params.junc_in;
var junc_out = data.params.junc_out; var junc_out = data.params.junc_out;

View file

@ -1,17 +1,42 @@
#region funtion calls #region funtion calls
function __fnInit_Inspector() { function __fnInit_Inspector() {
__registerFunction("inspector_copy_prop", panel_inspector_copy_prop); registerFunction("Inspector", "Copy property", "C", MOD_KEY.ctrl, panel_inspector_copy_prop);
__registerFunction("inspector_paste_prop", panel_inspector_paste_prop); registerFunction("Inspector", "Paste property", "V", MOD_KEY.ctrl, panel_inspector_paste_prop);
__registerFunction("inspector_toggle_animation", panel_inspector_toggle_animation); registerFunction("Inspector", "Toggle animation", "I", MOD_KEY.none, panel_inspector_toggle_animation);
__registerFunction("inspector_color_pick", panel_inspector_color_pick); registerFunction("", "Color picker", "", MOD_KEY.alt, panel_inspector_color_pick);
registerFunction("Inspector", "Expand All Sections", "", MOD_KEY.none, panel_inspector_section_expand_all);
registerFunction("Inspector", "Collapse All Sections", "", MOD_KEY.none, panel_inspector_section_collapse_all);
registerFunction("Inspector", "Reset", "", MOD_KEY.none, panel_inspector_reset);
registerFunction("Inspector", "Add", "", MOD_KEY.none, panel_inspector_add);
registerFunction("Inspector", "Remove", "", MOD_KEY.none, panel_inspector_remove);
registerFunction("Inspector", "Combine Axis", "", MOD_KEY.none, panel_inspector_axis_combine);
registerFunction("Inspector", "Separate Axis", "", MOD_KEY.none, panel_inspector_axis_separate);
registerFunction("Inspector", "Use Expression", "", MOD_KEY.none, panel_inspector_use_expression);
registerFunction("Inspector", "Disable Expression", "", MOD_KEY.none, panel_inspector_disable_expression);
registerFunction("Inspector", "Extract Value", "", MOD_KEY.none, panel_inspector_extract_single);
} }
function panel_inspector_copy_prop() { CALL("inspector_copy_prop"); PANEL_INSPECTOR.propSelectCopy(); } function panel_inspector_copy_prop() { CALL("inspector_copy_property"); PANEL_INSPECTOR.propSelectCopy(); }
function panel_inspector_paste_prop() { CALL("inspector_paste_prop"); PANEL_INSPECTOR.propSelectPaste(); } function panel_inspector_paste_prop() { CALL("inspector_paste_property"); PANEL_INSPECTOR.propSelectPaste(); }
function panel_inspector_toggle_animation() { CALL("inspector_toggle_animation"); PANEL_INSPECTOR.anim_toggling = true; } function panel_inspector_toggle_animation() { CALL("inspector_toggle_animation"); PANEL_INSPECTOR.anim_toggling = true; }
function panel_inspector_color_pick() { CALL("inspector_color_pick"); if(!PREFERENCES.alt_picker&& !MOUSE_BLOCK) return; PANEL_INSPECTOR.color_picking = true; } function panel_inspector_color_pick() { CALL("color_picker"); if(!PREFERENCES.alt_picker&& !MOUSE_BLOCK) return; PANEL_INSPECTOR.color_picking = true; }
function panel_inspector_section_expand_all() { CALL("inspector_section_expand_all"); PANEL_INSPECTOR.section_expand_all(); }
function panel_inspector_section_collapse_all() { CALL("inspector_section_collapse_all"); PANEL_INSPECTOR.section_collapse_all(); }
function panel_inspector_reset() { CALL("inspector_reset"); PANEL_INSPECTOR.junction_reset(); }
function panel_inspector_add() { CALL("inspector_add"); PANEL_INSPECTOR.junction_add(); }
function panel_inspector_remove() { CALL("inspector_remove"); PANEL_INSPECTOR.junction_remove(); }
function panel_inspector_axis_combine() { CALL("inspector_axis_combine"); PANEL_INSPECTOR.junction_axis_combine(); }
function panel_inspector_axis_separate() { CALL("inspector_axis_separate"); PANEL_INSPECTOR.junction_axis_separate(); }
function panel_inspector_use_expression() { CALL("inspector_use_expression"); PANEL_INSPECTOR.junction_use_expression(); }
function panel_inspector_disable_expression() { CALL("inspector_disable_expression"); PANEL_INSPECTOR.junction_disable_expression(); }
function panel_inspector_extract_single() { CALL("inspector_extract_single"); PANEL_INSPECTOR.junction_extract_single(); }
#endregion #endregion
function Inspector_Custom_Renderer(drawFn, registerFn = noone) : widget() constructor { function Inspector_Custom_Renderer(drawFn, registerFn = noone) : widget() constructor {
@ -128,14 +153,6 @@ function Panel_Inspector() : PanelContent() constructor {
workshop_uploading = false; workshop_uploading = false;
#endregion #endregion
#region ++++ hotkeys ++++
addHotkey("Inspector", "Copy property", "C", MOD_KEY.ctrl, panel_inspector_copy_prop);
addHotkey("Inspector", "Paste property", "V", MOD_KEY.ctrl, panel_inspector_paste_prop);
addHotkey("Inspector", "Toggle animation", "I", MOD_KEY.none, panel_inspector_toggle_animation);
addHotkey("", "Color picker", "", MOD_KEY.alt, panel_inspector_color_pick);
#endregion
#region ++++ menus ++++ #region ++++ menus ++++
static nodeExpandAll = function(node) { static nodeExpandAll = function(node) {
if(node.input_display_list == -1) return; if(node.input_display_list == -1) return;
@ -157,31 +174,44 @@ function Panel_Inspector() : PanelContent() constructor {
} }
} }
function section_expand_all() {
if(inspecting != noone) nodeExpandAll(inspecting);
for( var i = 0, n = array_length(inspectings); i < n; i++ )
nodeExpandAll(inspectings[i]);
}
function section_collapse_all() {
if(inspecting != noone) nodeCollapseAll(inspecting);
for( var i = 0, n = array_length(inspectings); i < n; i++ )
nodeCollapseAll(inspectings[i]);
}
function junction_reset() { if(__dialog_junction == noone) return; __dialog_junction.resetValue(); }
function junction_add() { if(__dialog_junction == noone) return; __dialog_junction.setAnim(true); }
function junction_remove() { if(__dialog_junction == noone) return; __dialog_junction.setAnim(false); }
function junction_axis_combine() { if(__dialog_junction == noone) return; __dialog_junction.sep_axis = false; }
function junction_axis_separate() { if(__dialog_junction == noone) return; __dialog_junction.sep_axis = true; }
function junction_use_expression() { if(__dialog_junction == noone) return; __dialog_junction.expUse = true; }
function junction_disable_expression() { if(__dialog_junction == noone) return; __dialog_junction.expUse = false; }
function junction_extract_single() { if(__dialog_junction == noone) return; __dialog_junction.extractNode(); }
group_menu = [ group_menu = [
menuItem(__txt("Expand all"), function() { menuItemAction(__txt("Expand all"), panel_inspector_section_expand_all),
if(inspecting != noone) nodeExpandAll(inspecting); menuItemAction(__txt("Collapse all"), panel_inspector_section_collapse_all),
for( var i = 0, n = array_length(inspectings); i < n; i++ )
nodeExpandAll(inspectings[i]);
}),
menuItem(__txt("Collapse all"), function() {
if(inspecting != noone) nodeCollapseAll(inspecting);
for( var i = 0, n = array_length(inspectings); i < n; i++ )
nodeCollapseAll(inspectings[i]);
}),
] ]
__dialog_junction = noone; __dialog_junction = noone;
menu_junc_reset_value = menuItem(__txtx("panel_inspector_reset", "Reset value"), function() { __dialog_junction.resetValue(); }); menu_junc_reset_value = menuItemAction(__txtx("panel_inspector_reset", "Reset value"), panel_inspector_reset);
menu_junc_add_anim = menuItem(__txtx("panel_inspector_add", "Add animation"), function() { __dialog_junction.setAnim(true); }); menu_junc_add_anim = menuItemAction(__txtx("panel_inspector_add", "Add animation"), panel_inspector_add);
menu_junc_rem_anim = menuItem(__txtx("panel_inspector_remove", "Remove animation"), function() { __dialog_junction.setAnim(false); }); menu_junc_rem_anim = menuItemAction(__txtx("panel_inspector_remove", "Remove animation"), panel_inspector_remove);
menu_junc_combine_axis = menuItem(__txtx("panel_inspector_axis_combine", "Combine axis"), function() { __dialog_junction.sep_axis = false; }); menu_junc_combine_axis = menuItemAction(__txtx("panel_inspector_axis_combine", "Combine axis"), panel_inspector_axis_combine);
menu_junc_separate_axis = menuItem(__txtx("panel_inspector_axis_separate", "Separate axis"), function() { __dialog_junction.sep_axis = true; }); menu_junc_separate_axis = menuItemAction(__txtx("panel_inspector_axis_separate", "Separate axis"), panel_inspector_axis_separate);
menu_junc_expression_ena = menuItem(__txtx("panel_inspector_use_expression", "Use expression"), function() { __dialog_junction.expUse = true; }); menu_junc_expression_ena = menuItemAction(__txtx("panel_inspector_use_expression", "Use expression"), panel_inspector_use_expression);
menu_junc_expression_dis = menuItem(__txtx("panel_inspector_disable_expression", "Disable expression"), function() { __dialog_junction.expUse = false; }); menu_junc_expression_dis = menuItemAction(__txtx("panel_inspector_disable_expression", "Disable expression"), panel_inspector_disable_expression);
menu_junc_extract = menuItem(__txtx("panel_inspector_extract_single", "Extract to node"), function() { __dialog_junction.extractNode(); }); menu_junc_extract = menuItemAction(__txtx("panel_inspector_extract_single", "Extract to node"), panel_inspector_extract_single);
menu_junc_copy = menuItem(__txt("Copy"), function() { clipboard_set_text(__dialog_junction.getString()); }, THEME.copy, ["Inspector", "Copy property"]); menu_junc_copy = menuItemAction(__txt("Copy"), panel_inspector_copy_prop, THEME.copy);
menu_junc_paste = menuItem(__txt("Paste"), function() { __dialog_junction.setString(clipboard_get_text()); }, THEME.paste, ["Inspector", "Paste property"]); menu_junc_paste = menuItemAction(__txt("Paste"), panel_inspector_paste_prop, THEME.paste);
function setSelectingItemColor(color) { function setSelectingItemColor(color) {
if(__dialog_junction == noone) return; if(__dialog_junction == noone) return;
@ -870,11 +900,11 @@ function Panel_Inspector() : PanelContent() constructor {
if(jun.connect_type == JUNCTION_CONNECT.input && jun.extract_node != "") { if(jun.connect_type == JUNCTION_CONNECT.input && jun.extract_node != "") {
if(is_array(jun.extract_node)) { if(is_array(jun.extract_node)) {
var ext = menuItem(__txtx("panel_inspector_extract_multiple", "Extract to..."), function(_dat) { var ext = menuItemAction(__txtx("panel_inspector_extract_multiple", "Extract to..."), function(_dat) {
var arr = []; var arr = [];
for(var i = 0; i < array_length(__dialog_junction.extract_node); i++) { for(var i = 0; i < array_length(__dialog_junction.extract_node); i++) {
var _rec = __dialog_junction.extract_node[i]; var _rec = __dialog_junction.extract_node[i];
array_push(arr, menuItem(_rec, function(_dat) { __dialog_junction.extractNode(_dat.name); })); array_push(arr, menuItemAction(_rec, function(_dat) { __dialog_junction.extractNode(_dat.name); }));
} }
return submenuCall(_dat, arr); return submenuCall(_dat, arr);

View file

@ -17,47 +17,43 @@ function Panel_Menu() : PanelContent() constructor {
#region file #region file
menu_file_nondemo = [ menu_file_nondemo = [
menuItem(__txt("New"), function() { NEW(); }, THEME.new_file, ["", "New file"]), menuItemAction(__txt("New"), NEW, THEME.new_file),
menuItem(__txt("Open") + "...", function() { LOAD(); }, THEME.noti_icon_file_load, ["", "Open"]) menuItemAction(__txt("Open") + "...", LOAD, THEME.noti_icon_file_load)
.setShiftMenu(menuItem(__txt("Open in safe mode") + "...", function() { LOAD(true); }, THEME.noti_icon_file_load)), .setShiftMenu(menuItemAction(__txt("Open in safe mode") + "...", LOAD_SAFE, THEME.noti_icon_file_load)),
menuItem(__txt("Save"), function() { SAVE(); }, THEME.save, ["", "Save"]),
menuItem(__txt("Save as") + "...", function() { SAVE_AS(); }, THEME.save, ["", "Save as"]), menuItemAction(__txt("Save"), SAVE, THEME.save),
menuItem(__txt("Save all"), function() { SAVE_ALL(); }, THEME.icon_save_all, ["", "Save all"]), menuItemAction(__txt("Save as") + "...", SAVE_AS, THEME.save),
menuItem(__txt("Recent files"), function(_dat) { menuItemAction(__txt("Save all"), SAVE_ALL, THEME.icon_save_all),
menuItemAction(__txt("Recent files"), function(_dat) {
var arr = []; var arr = [];
for(var i = 0; i < min(10, ds_list_size(RECENT_FILES)); i++) { for(var i = 0; i < min(10, ds_list_size(RECENT_FILES)); i++) {
var _rec = RECENT_FILES[| i]; var _rec = RECENT_FILES[| i];
array_push(arr, menuItem(_rec, function(_dat) { LOAD_PATH(_dat.name); })); array_push(arr, menuItemAction(_rec, function(_dat) { LOAD_PATH(_dat.name); }));
} }
return submenuCall(_dat, arr); return submenuCall(_dat, arr);
}).setIsShelf(), }).setIsShelf(),
menuItem(__txtx("panel_menu_auto_save_folder", "Open autosave folder"), function() { shellOpenExplorer(DIRECTORY + "autosave"); }, THEME.save_auto, ["", "Autosave folder"]), menuItemAction(__txtx("panel_menu_auto_save_folder", "Open autosave folder"), open_autosave_folder, THEME.save_auto),
menuItem(__txt("Import"), function(_dat) { menuItemAction(__txt("Import"), function(_dat) {
var arr = [ var arr = [ menuItemAction(__txt("Portable project (.zip)") + "...", __IMPORT_ZIP), ];
menuItem(__txt("Portable project (.zip)") + "...", function() { __IMPORT_ZIP(); }),
];
return submenuCall(_dat, arr); return submenuCall(_dat, arr);
}).setIsShelf(), }).setIsShelf(),
menuItem(__txt("Export"), function(_dat) {
var arr = [ menuItemAction(__txt("Export"), function(_dat) {
menuItem(__txt("Portable project (.zip)") + "...", function() { exportPortable(PROJECT); }), var arr = [ menuItemAction(__txt("Portable project (.zip)") + "...", __EXPORT_ZIP), ];
];
return submenuCall(_dat, arr); return submenuCall(_dat, arr);
}).setIsShelf(), }).setIsShelf(),
-1, -1,
]; ];
menu_file = [ menu_file = [
menuItem(__txt("Preferences") + "...", function() { dialogCall(o_dialog_preference); }, THEME.gear, ["", "Preference"]), menuItemAction(__txt("Preferences") + "...", call_dialog_preference, THEME.gear),
menuItem(__txt("Splash screen"), function() { dialogCall(o_dialog_splash); }, noone, ["", "Splash Screen"]), menuItemAction(__txt("Splash screen"), call_dialog_splash),
-1, -1,
menuItem(__txt("Addons"), function(_dat) { menuItemAction(__txt("Addons"), function(_dat) {
var arr = [ var arr = [
menuItem(__txt("Addons") + "...", function() { dialogPanelCall(new Panel_Addon()); }, noone, ["", "Addons"]), menuItemAction(__txt("Addons") + "...", call_panel_addon),
menuItem(__txtx("panel_menu_addons_key", "Key displayer"), function() { menuItemAction(__txtx("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);
return; return;
@ -70,16 +66,16 @@ function Panel_Menu() : PanelContent() constructor {
for( var i = 0, n = array_length(ADDONS); i < n; i++ ) { for( var i = 0, n = array_length(ADDONS); i < n; i++ ) {
var _dir = ADDONS[i].name; var _dir = ADDONS[i].name;
array_push(arr, menuItem(_dir, function(_dat) { addonTrigger(_dat.name); } )); array_push(arr, menuItemAction(_dir, function(_dat) { addonTrigger(_dat.name); } ));
} }
return submenuCall(_dat, arr); return submenuCall(_dat, arr);
}, THEME.addon_icon ).setIsShelf(), }, THEME.addon_icon ).setIsShelf(),
-1, -1,
menuItem(__txt("Fullscreen"), function() { winMan_setFullscreen(!window_is_fullscreen); }, noone, ["", "Fullscreen"]), menuItemAction(__txt("Fullscreen"), global_fullscreen),
menuItem(__txt("Close current project"), function() { PANEL_GRAPH.close(); }, noone, [ "", "Close file" ]), menuItemAction(__txt("Close current project"), global_project_close),
menuItem(__txt("Close all projects"), function() { for( var i = array_length(PROJECTS) - 1; i >= 0; i-- ) closeProject(PROJECTS[i]); }, noone, [ "", "Close all" ]), menuItemAction(__txt("Close all projects"), global_project_close_all),
menuItem(__txt("Close program"), function() { window_close(); }, noone, [ "", "Close program" ]), menuItemAction(__txt("Close program"), window_close),
]; ];
if(!DEMO) menu_file = array_append(menu_file_nondemo, menu_file); if(!DEMO) menu_file = array_append(menu_file_nondemo, menu_file);
@ -87,33 +83,23 @@ function Panel_Menu() : PanelContent() constructor {
#region help #region help
menu_help = [ menu_help = [
menuItem(__txtx("panel_menu_help_video", "Tutorial videos"), function() { menuItemAction(__txtx("panel_menu_help_video", "Tutorial videos"), function() { url_open("https://www.youtube.com/@makhamdev"); }, THEME.youtube),
url_open("https://www.youtube.com/@makhamdev"); menuItemAction(__txtx("panel_menu_help_wiki", "Community Wiki"), function() { url_open("https://pixel-composer.fandom.com/wiki/Pixel_Composer_Wiki"); }, THEME.wiki),
}, THEME.youtube),
menuItem(__txtx("panel_menu_help_wiki", "Community Wiki"), function() {
url_open("https://pixel-composer.fandom.com/wiki/Pixel_Composer_Wiki");
}, THEME.wiki),
-1, -1,
menuItem(__txtx("panel_menu_local_directory", "Open local directory"), function() { menuItemAction(__txtx("panel_menu_local_directory", "Open local directory"), function() { shellOpenExplorer(DIRECTORY); }, THEME.folder),
shellOpenExplorer(DIRECTORY); menuItemAction(__txtx("panel_menu_autosave_directory", "Open autosave directory"), function() { shellOpenExplorer(DIRECTORY + "autosave/"); }, THEME.folder),
}, THEME.folder), menuItemAction(__txtx("panel_menu_reset_default", "Reset default collection, assets"), function() {
menuItem(__txtx("panel_menu_autosave_directory", "Open autosave directory"), function() {
shellOpenExplorer(DIRECTORY + "autosave/");
}, THEME.folder),
menuItem(__txtx("panel_menu_reset_default", "Reset default collection, assets"), function() {
zip_unzip("data/Collections.zip", DIRECTORY + "Collections"); zip_unzip("data/Collections.zip", DIRECTORY + "Collections");
zip_unzip("data/Assets.zip", DIRECTORY + "Assets"); zip_unzip("data/Assets.zip", DIRECTORY + "Assets");
}), }),
-1, -1,
menuItem(__txtx("panel_menu_connect_patreon", "Connect to Patreon"), function() { menuItemAction(__txtx("panel_menu_connect_patreon", "Connect to Patreon"), function() { dialogPanelCall(new Panel_Patreon()); }, THEME.patreon),
dialogPanelCall(new Panel_Patreon());
}, THEME.patreon),
]; ];
#endregion #endregion
#region //////// MENU //////// #region //////// MENU ////////
menuItem_undo = menuItem(__txt("Undo"), function() { UNDO(); }, THEME.undo, ["", "Undo"]); menuItem_undo = menuItemAction(__txt("Undo"), UNDO, THEME.undo);
menuItem_redo = menuItem(__txt("Redo"), function() { REDO(); }, THEME.redo, ["", "Redo"]); menuItem_redo = menuItemAction(__txt("Redo"), REDO, THEME.redo);
menus = [ menus = [
[ __txt("File"), menu_file ], [ __txt("File"), menu_file ],
@ -121,12 +107,12 @@ function Panel_Menu() : PanelContent() constructor {
[ __txt("Edit"), [ [ __txt("Edit"), [
menuItem_undo, menuItem_undo,
menuItem_redo, menuItem_redo,
menuItem(__txt("History"), function() { dialogPanelCall(new Panel_History()); }, noone, ["", "History"]), menuItemAction(__txt("History"), call_panel_history),
]], ]],
[ __txt("Preview"), [ [ __txt("Preview"), [
menuItem(__txtx("panel_menu_center_preview", "Center preview"), function() { PANEL_PREVIEW.do_fullView = true; }, THEME.icon_center_canvas, ["Preview", "Focus content"]), menuItemAction(__txtx("panel_menu_center_preview", "Center preview"), panel_preview_focus_content, THEME.icon_center_canvas),
menuItem(__txtx("panel_menu_save_current_preview_as", "Save current preview as..."), function() { PANEL_PREVIEW.saveCurrentFrame(); }, noone, ["Preview", "Save current frame"]), menuItemAction(__txtx("panel_menu_save_current_preview_as", "Save current preview as..."), panel_preview_save_current_frame),
menuItemGroup(__txtx("panel_menu_preview_background", "Preview background"), [ menuItemGroup(__txtx("panel_menu_preview_background", "Preview background"), [
[ s_preview_transparent, function() { PANEL_PREVIEW.canvas_bg = -1; } ], [ s_preview_transparent, function() { PANEL_PREVIEW.canvas_bg = -1; } ],
[ s_preview_white, function() { PANEL_PREVIEW.canvas_bg = c_white; } ], [ s_preview_white, function() { PANEL_PREVIEW.canvas_bg = c_white; } ],
@ -135,38 +121,21 @@ function Panel_Menu() : PanelContent() constructor {
]], ]],
[ __txt("Animation"), [ [ __txt("Animation"), [
menuItem(__txtx("panel_menu_animation_setting", "Animation Settings..."), function() { menuItemAction(__txtx("panel_menu_animation_setting", "Animation Settings..."), panel_animation_settings, THEME.animation_setting),
var dia = dialogPanelCall(new Panel_Animation_Setting());
dia.anchor = ANCHOR.none;
}, THEME.animation_setting, ["Animation", "Settings"]),
-1, -1,
menuItem(__txtx("panel_menu_animation_scaler", "Animation Scaler..."), function() { menuItemAction(__txtx("panel_menu_animation_scaler", "Animation Scaler..."), panel_animation_scale, THEME.animation_timing),
dialogPanelCall(new Panel_Animation_Scaler());
}, THEME.animation_timing),
]], ]],
[ __txt("Rendering"), [ [ __txt("Rendering"), [
menuItem(__txtx("panel_menu_render_all_nodes", "Render all nodes"), function() { menuItemAction(__txtx("panel_menu_render_all_nodes", "Render all nodes"), global_render_all, [ THEME.sequence_control, 1 ]),
RENDER_ALL_REORDER menuItemAction(__txtx("panel_menu_execute_exports", "Execute all export nodes"), global_export_all),
}, [ THEME.sequence_control, 1 ], ["", "Render all"]), menuItemAction(__txtx("panel_menu_export_render_all", "Render disabled node when export"),
function() { PREFERENCES.render_all_export = !PREFERENCES.render_all_export; },,,
menuItem(__txtx("panel_menu_execute_exports", "Execute all export nodes"), function() { function() { return PREFERENCES.render_all_export; }),
for (var i = 0, n = array_length(PROJECT.allNodes); i < n; i++) {
var node = PROJECT.allNodes[i];
if(!node.active) continue;
if(instanceof(node) != "Node_Export") continue;
node.doInspectorAction();
}
}),
menuItem(__txtx("panel_menu_export_render_all", "Render disabled node when export"),
function() { PREFERENCES.render_all_export = !PREFERENCES.render_all_export; },,,
function() { return PREFERENCES.render_all_export; } ),
]], ]],
[ __txt("Panels"), [ [ __txt("Panels"), [
menuItem(__txt("Workspace"), function(_dat) { menuItemAction(__txt("Workspace"), function(_dat) {
var arr = [], lays = []; var arr = [], lays = [];
var f = file_find_first(DIRECTORY + "layouts/*", 0); var f = file_find_first(DIRECTORY + "layouts/*", 0);
while(f != "") { while(f != "") {
@ -174,7 +143,7 @@ function Panel_Menu() : PanelContent() constructor {
f = file_find_next(); f = file_find_next();
} }
array_push(arr, menuItem(__txtx("panel_menu_save_layout", "Save layout"), function() { array_push(arr, menuItemAction(__txtx("panel_menu_save_layout", "Save layout"), function() {
var dia = dialogCall(o_dialog_file_name, mouse_mx + ui(8), mouse_my + ui(8)); var dia = dialogCall(o_dialog_file_name, mouse_mx + ui(8), mouse_my + ui(8));
dia.name = PREFERENCES.panel_layout_file; dia.name = PREFERENCES.panel_layout_file;
dia.onModify = function(name) { dia.onModify = function(name) {
@ -183,13 +152,11 @@ function Panel_Menu() : PanelContent() constructor {
}; };
})); }));
array_push(arr, menuItem(__txtx("panel_menu_reset_layout", "Reset layout"), function() { array_push(arr, menuItemAction(__txtx("panel_menu_reset_layout", "Reset layout"), resetPanel));
resetPanel();
},, [ "", "Reset layout" ]));
array_push(arr, -1); array_push(arr, -1);
for(var i = 0; i < array_length(lays); i++) { for(var i = 0; i < array_length(lays); i++) {
array_push(arr, menuItem(lays[i], array_push(arr, menuItemAction(lays[i],
function(_dat) { function(_dat) {
PREFERENCES.panel_layout_file = _dat.name; PREFERENCES.panel_layout_file = _dat.name;
PREF_SAVE(); PREF_SAVE();
@ -200,81 +167,79 @@ function Panel_Menu() : PanelContent() constructor {
return submenuCall(_dat, arr); return submenuCall(_dat, arr);
}).setIsShelf(), }).setIsShelf(),
-1, -1,
menuItem(__txt("Collections"), function() { panelAdd("Panel_Collection", true) }, noone, ["", "Collections Panel"], function() { return findPanel("Panel_Collection") != noone; } ), menuItemAction(__txt("Collections"), call_panel_Collection, noone, function() /*=>*/ { return findPanel("Panel_Collection") != noone; } ),
menuItem(__txt("Graph"), function() { panelAdd("Panel_Graph", true) }, noone, ["", "Graph Panel"], function() { return findPanel("Panel_Graph") != noone; } ), menuItemAction(__txt("Graph"), call_panel_Graph, noone, function() /*=>*/ { return findPanel("Panel_Graph") != noone; } ),
menuItem(__txt("Preview"), function() { panelAdd("Panel_Preview", true) }, noone, ["", "Preview Panel"], function() { return findPanel("Panel_Preview") != noone; } ), menuItemAction(__txt("Preview"), call_panel_Preview, noone, function() /*=>*/ { return findPanel("Panel_Preview") != noone; } ),
menuItem(__txt("Inspector"), function() { panelAdd("Panel_Inspector", true) }, noone, ["", "Inspector Panel"], function() { return findPanel("Panel_Inspector") != noone; } ), menuItemAction(__txt("Inspector"), call_panel_Inspector, noone, function() /*=>*/ { return findPanel("Panel_Inspector") != noone; } ),
menuItem(__txt("Workspace"), function() { panelAdd("Panel_Workspace", true) }, noone, ["", "Workspace Panel"], function() { return findPanel("Panel_Workspace") != noone; } ), menuItemAction(__txt("Workspace"), call_panel_Workspace, noone, function() /*=>*/ { return findPanel("Panel_Workspace") != noone; } ),
menuItem(__txt("Animation"), function() { panelAdd("Panel_Animation", true) }, noone, ["", "Animation Panel"], function() { return findPanel("Panel_Animation") != noone; } ), menuItemAction(__txt("Animation"), call_panel_Animation, noone, function() /*=>*/ { return findPanel("Panel_Animation") != noone; } ),
menuItem(__txt("Notifications"), function() { panelAdd("Panel_Notification", true) }, noone, ["", "Notification Panel"], function() { return findPanel("Panel_Notification") != noone; } ), menuItemAction(__txt("Notifications"), call_panel_Notification, noone, function() /*=>*/ { return findPanel("Panel_Notification") != noone; } ),
menuItem(__txt("Global Variables"), function() { panelAdd("Panel_Globalvar", true) }, noone, noone, function() { return findPanel("Panel_Globalvar") != noone; } ), menuItemAction(__txt("Global Variables"), call_panel_Globalvar, noone, function() /*=>*/ { return findPanel("Panel_Globalvar") != noone; } ),
menuItem(__txt("File Explorer"), function() { panelAdd("Panel_File_Explorer", true) },noone, noone, function() { return findPanel("Panel_File_Explorer") != noone; } ), menuItemAction(__txt("File Explorer"), call_panel_File_Explorer, noone, function() /*=>*/ { return findPanel("Panel_File_Explorer") != noone; } ),
menuItem(__txt("Nodes"), function(_dat) { menuItemAction(__txt("Nodes"), function(_dat) {
return submenuCall(_dat, [ return submenuCall(_dat, [
menuItem(__txt("Align"), function() { panelAdd("Panel_Node_Align", true) }, noone, ["", "Align Panel"], function() { return findPanel("Panel_Node_Align") != noone; } ), menuItemAction(__txt("Align"), call_panel_Node_Align, noone, function() /*=>*/ { return findPanel("Panel_Node_Align") != noone; } ),
menuItem(__txt("Nodes"), function() { panelAdd("Panel_Nodes", true) }, noone, ["", "Nodes Panel"], function() { return findPanel("Panel_Nodes") != noone; } ), menuItemAction(__txt("Nodes"), call_panel_Nodes, noone, function() /*=>*/ { return findPanel("Panel_Nodes") != noone; } ),
menuItem(__txt("Tunnels"), function() { panelAdd("Panel_Tunnels", true) }, noone, ["", "Tunnels Panel"], function() { return findPanel("Panel_Tunnels") != noone; } ), menuItemAction(__txt("Tunnels"), call_panel_Tunnels, noone, function() /*=>*/ { return findPanel("Panel_Tunnels") != noone; } ),
]); ]);
} ).setIsShelf(), } ).setIsShelf(),
menuItem(__txt("Color"), function(_dat) { menuItemAction(__txt("Color"), function(_dat) {
return submenuCall(_dat, [ return submenuCall(_dat, [
menuItem(__txt("Color"), function() { panelAdd("Panel_Color", true) }, noone, ["", "Color Panel"], function() { return findPanel("Panel_Color") != noone; } ), menuItemAction(__txt("Color"), call_panel_Color, noone, function() /*=>*/ { return findPanel("Panel_Color") != noone; } ),
menuItem(__txt("Palettes"), function() { panelAdd("Panel_Palette", true) }, noone, ["", "Palettes Panel"], function() { return findPanel("Panel_Palette") != noone; } ), menuItemAction(__txt("Palettes"), call_panel_Palette, noone, function() /*=>*/ { return findPanel("Panel_Palette") != noone; } ),
menuItem(__txt("Gradients"), function() { panelAdd("Panel_Gradient", true) }, noone, ["", "Gradients Panel"], function() { return findPanel("Panel_Gradient") != noone; } ), menuItemAction(__txt("Gradients"), call_panel_Gradient, noone, function() /*=>*/ { return findPanel("Panel_Gradient") != noone; } ),
-1, -1,
menuItem(__txt("Palette Mixer"), function() { panelAdd("Panel_Palette_Mixer", true) }, noone, ["", "Palette Mixer Panel"], function() { return findPanel("Panel_Palette_Mixer") != noone; } ), menuItemAction(__txt("Palette Mixer"), call_panel_Palette_Mixer, noone, function() /*=>*/ { return findPanel("Panel_Palette_Mixer") != noone; } ),
]); ]);
} ).setIsShelf(), } ).setIsShelf(),
menuItem(__txt("Histogram"), function() { panelAdd("Panel_Preview_Histogram", true) }, noone, noone, function() { return findPanel("Panel_Preview_Histogram") != noone; } ), menuItemAction(__txt("Histogram"), call_panel_Preview_Histogram, noone, function() /*=>*/ { return findPanel("Panel_Preview_Histogram") != noone; } ),
]], ]],
[ __txt("Help"), menu_help ], [ __txt("Help"), menu_help ],
]; ];
#endregion #endregion
if(TESTING) { #region if(TESTING) {
array_push(menus, [ __txt("Dev"), [ array_push(menus, [ __txt("Dev"), [
menuItem(__txtx("panel_debug_console", "Console"), function() /*=>*/ { panelAdd("Panel_Console", true) }, noone, ["", "Console Panel"]), menuItemAction(__txtx("panel_debug_console", "Console"), call_panel_Console),
menuItem(__txtx("panel_debug_overlay", "Debug overlay"), function() /*=>*/ { show_debug_overlay(true); }), menuItemAction(__txtx("panel_debug_overlay", "Debug overlay"), function() /*=>*/ { show_debug_overlay(true); }),
menuItem(__txtx("panel_menu_tester", "Tester"), function() /*=>*/ { var dia = dialogPanelCall(new Panel_Test()); dia.destroy_on_click_out = false; }), menuItemAction(__txtx("panel_menu_tester", "Tester"), function() /*=>*/ { var dia = dialogPanelCall(new Panel_Test()); dia.destroy_on_click_out = false; }),
-1, -1,
menuItem(__txtx("panel_menu_test_load_all", "Load all current collections"), function() /*=>*/ { __test_load_current_collections(); }), menuItemAction(__txtx("panel_menu_test_load_all", "Load all current collections"), function() /*=>*/ { __test_load_current_collections(); }),
menuItem(__txtx("panel_menu_test_update_all", "Update all current collections"), function() /*=>*/ { __test_update_current_collections(); }), menuItemAction(__txtx("panel_menu_test_update_all", "Update all current collections"), function() /*=>*/ { __test_update_current_collections(); }),
menuItem(__txtx("panel_menu_test_add_meta", "Add metadata to current collections"), function() /*=>*/ { __test_metadata_current_collections(); }), menuItemAction(__txtx("panel_menu_test_add_meta", "Add metadata to current collections"), function() /*=>*/ { __test_metadata_current_collections(); }),
menuItem(__txtx("panel_menu_test_update_sam", "Update sample projects"), function() /*=>*/ { __test_update_sample_projects(); }), menuItemAction(__txtx("panel_menu_test_update_sam", "Update sample projects"), function() /*=>*/ { __test_update_sample_projects(); }),
-1, -1,
menuItem(__txtx("panel_menu_test_load_nodes", "Load all nodes"), function() /*=>*/ { __test_load_all_nodes(); }), menuItemAction(__txtx("panel_menu_test_load_nodes", "Load all nodes"), function() /*=>*/ { __test_load_all_nodes(); }),
menuItem(__txtx("panel_menu_test_gen_guide", "Generate node guide"), function() /*=>*/ { var dia = dialogPanelCall(new Panel_Node_Data_Gen()); dia.destroy_on_click_out = false; }), menuItemAction(__txtx("panel_menu_test_gen_guide", "Generate node guide"), function() /*=>*/ { var dia = dialogPanelCall(new Panel_Node_Data_Gen()); dia.destroy_on_click_out = false; }),
menuItem(__txtx("panel_menu_test_gen_theme", "Generate theme object"), function() /*=>*/ { __test_generate_theme(); }), menuItemAction(__txtx("panel_menu_test_gen_theme", "Generate theme object"), function() /*=>*/ { __test_generate_theme(); }),
-1, -1,
menuItem(__txtx("panel_menu_test_warning", "Display Warning"), function() /*=>*/ { noti_warning("Error message") }), menuItemAction(__txtx("panel_menu_test_warning", "Display Warning"), function() /*=>*/ { noti_warning("Error message") }),
menuItem(__txtx("panel_menu_test_error", "Display Error"), function() /*=>*/ { noti_error("Error message") }), menuItemAction(__txtx("panel_menu_test_error", "Display Error"), function() /*=>*/ { noti_error("Error message") }),
menuItem(__txtx("panel_menu_test_crash", "Force crash"), function() /*=>*/ { print(1 + "a"); }), menuItemAction(__txtx("panel_menu_test_crash", "Force crash"), function() /*=>*/ { print(1 + "a"); }),
-1, -1,
menuItem(__txt("Misc."), function(_dat) { menuItemAction(__txt("Misc."), function(_dat) {
return submenuCall(_dat, [ return submenuCall(_dat, [ menuItemAction(__txtx("panel_menu_node_credit", "Node credit dialog"), function() /*=>*/ { var dia = dialogPanelCall(new Panel_Node_Cost()); }), ]);
menuItem(__txtx("panel_menu_node_credit", "Node credit dialog"), function() /*=>*/ { var dia = dialogPanelCall(new Panel_Node_Cost()); }),
]);
} ).setIsShelf(), } ).setIsShelf(),
]]); ]]);
} #endregion }
menu_help_steam = array_clone(menu_help); menu_help_steam = array_clone(menu_help);
array_push(menu_help_steam, -1, array_push(menu_help_steam, -1,
menuItem(__txtx("panel_menu_steam_workshop", "Steam Workshop"), function() /*=>*/ { steam_activate_overlay_browser("https://steamcommunity.com/app/2299510/workshop/"); }, THEME.steam) ); menuItemAction(__txtx("panel_menu_steam_workshop", "Steam Workshop"), function() /*=>*/ { steam_activate_overlay_browser("https://steamcommunity.com/app/2299510/workshop/"); }, THEME.steam) );
function onFocusBegin() { PANEL_MENU = self; } function onFocusBegin() { PANEL_MENU = self; }
function setNotiIcon(icon) { #region function setNotiIcon(icon) {
noti_icon = icon; noti_icon = icon;
noti_icon_time = 90; noti_icon_time = 90;
} #endregion }
function undoUpdate() { #region function undoUpdate() {
var txt; var txt;
if(ds_stack_empty(UNDO_STACK)) { if(ds_stack_empty(UNDO_STACK)) {
@ -302,9 +267,9 @@ function Panel_Menu() : PanelContent() constructor {
menuItem_redo.active = !ds_stack_empty(REDO_STACK); menuItem_redo.active = !ds_stack_empty(REDO_STACK);
menuItem_redo.name = txt; menuItem_redo.name = txt;
} #endregion }
function drawContent(panel) { #region function drawContent(panel) {
var _right = PREFERENCES.panel_menu_right_control; var _right = PREFERENCES.panel_menu_right_control;
var _draggable = pFOCUS; var _draggable = pFOCUS;
@ -707,7 +672,7 @@ function Panel_Menu() : PanelContent() constructor {
for(var i = 0; i < min(10, ds_list_size(RECENT_FILES)); i++) { for(var i = 0; i < min(10, ds_list_size(RECENT_FILES)); i++) {
var _rec = RECENT_FILES[| i]; var _rec = RECENT_FILES[| i];
var _dat = RECENT_FILE_DATA[| i]; var _dat = RECENT_FILE_DATA[| i];
array_push(arr, menuItem(_rec, function(_dat) { LOAD_PATH(_dat.name); })); array_push(arr, menuItemAction(_rec, function(_dat) { LOAD_PATH(_dat.name); }));
array_push(tip, [ method(_dat, _dat.getThumbnail), VALUE_TYPE.surface ]); array_push(tip, [ method(_dat, _dat.getThumbnail), VALUE_TYPE.surface ]);
} }
@ -755,5 +720,5 @@ function Panel_Menu() : PanelContent() constructor {
if(mouse_press(mb_left, _draggable)) if(mouse_press(mb_left, _draggable))
winMan_initDrag(0b10000); winMan_initDrag(0b10000);
#endregion #endregion
} #endregion }
} }

View file

@ -11,24 +11,24 @@ function Panel_Notification() : PanelContent() constructor {
showHeader = false; showHeader = false;
rightClickMenu = [ rightClickMenu = [
menuItem(__txtx("noti_clear_log", "Clear log messages"), function() { menuItemAction(__txtx("noti_clear_log", "Clear log messages"), function() {
for( var i = ds_list_size(STATUSES) - 1; i >= 0; i-- ) { for( var i = ds_list_size(STATUSES) - 1; i >= 0; i-- ) {
if(STATUSES[| i].type == NOTI_TYPE.log) if(STATUSES[| i].type == NOTI_TYPE.log)
ds_list_delete(STATUSES, i); ds_list_delete(STATUSES, i);
} }
}), }),
menuItem(__txtx("noti_clear_warn", "Clear warning messages"), function() { menuItemAction(__txtx("noti_clear_warn", "Clear warning messages"), function() {
for( var i = ds_list_size(STATUSES) - 1; i >= 0; i-- ) { for( var i = ds_list_size(STATUSES) - 1; i >= 0; i-- ) {
if(STATUSES[| i].type == NOTI_TYPE.warning) if(STATUSES[| i].type == NOTI_TYPE.warning)
ds_list_delete(STATUSES, i); ds_list_delete(STATUSES, i);
} }
}), }),
-1, -1,
menuItem(__txtx("noti_clear_all", "Clear all notifications"), function() { menuItemAction(__txtx("noti_clear_all", "Clear all notifications"), function() {
ds_list_clear(STATUSES); ds_list_clear(STATUSES);
}), }),
-1, -1,
menuItem(__txtx("noti_open_log", "Open log file"), function() { menuItemAction(__txtx("noti_open_log", "Open log file"), function() {
shellOpenExplorer(DIRECTORY + "log/log.txt"); shellOpenExplorer(DIRECTORY + "log/log.txt");
}), }),
]; ];
@ -77,10 +77,10 @@ function Panel_Notification() : PanelContent() constructor {
if(mouse_press(mb_right, pFOCUS)) { if(mouse_press(mb_right, pFOCUS)) {
var dia = menuCall("notification_menu",,, [ var dia = menuCall("notification_menu",,, [
menuItem(__txtx("noti_copy_message", "Copy notification message"), function() { menuItemAction(__txtx("noti_copy_message", "Copy notification message"), function() {
clipboard_set_text(o_dialog_menubox.noti.txt); clipboard_set_text(o_dialog_menubox.noti.txt);
}), }),
menuItem(__txtx("noti_delete_message", "Delete notification"), function() { menuItemAction(__txtx("noti_delete_message", "Delete notification"), function() {
ds_list_remove(STATUSES, o_dialog_menubox.noti); ds_list_remove(STATUSES, o_dialog_menubox.noti);
}), }),
],, noti); ],, noti);

View file

@ -14,17 +14,17 @@ function Panel_Palette() : PanelContent() constructor {
__save_palette_data = []; __save_palette_data = [];
view_label = true; view_label = true;
menu_refresh = menuItem(__txt("Refresh"), function() { __initPalette(); }); menu_refresh = menuItemAction(__txt("Refresh"), function() { __initPalette(); });
menu_add = menuItem(__txt("Add"), function(_dat) { menu_add = menuItemAction(__txt("Add"), function(_dat) {
return submenuCall(_dat, [ return submenuCall(_dat, [
menuItem(__txt("File..."), function() { menuItemAction(__txt("File..."), function() {
var _p = get_open_filename("hex|*.hex|gpl|*.gpl|Image|.png", "palette"); var _p = get_open_filename("hex|*.hex|gpl|*.gpl|Image|.png", "palette");
if(!file_exists_empty(_p)) return; if(!file_exists_empty(_p)) return;
file_copy(_p, $"{DIRECTORY}Palettes/{filename_name(_p)}"); file_copy(_p, $"{DIRECTORY}Palettes/{filename_name(_p)}");
__initPalette(); __initPalette();
}), }),
menuItem(__txt("Lospec..."), function() { menuItemAction(__txt("Lospec..."), function() {
fileNameCall("", function(txt) { fileNameCall("", function(txt) {
if(txt == "") return; if(txt == "") return;
txt = string_lower(txt); txt = string_lower(txt);
@ -37,8 +37,8 @@ function Panel_Palette() : PanelContent() constructor {
]); ]);
}).setIsShelf(); }).setIsShelf();
menu_stretch = menuItem(__txt("Stretch"), function() { PREFERENCES.palette_stretch = !PREFERENCES.palette_stretch; }, noone, noone, function() /*=>*/ {return PREFERENCES.palette_stretch}); menu_stretch = menuItemAction(__txt("Stretch"), function() { PREFERENCES.palette_stretch = !PREFERENCES.palette_stretch; }, noone, noone, function() /*=>*/ {return PREFERENCES.palette_stretch});
menu_mini = menuItem(__txt("Label"), function() { view_label = !view_label; }, noone, noone, function() /*=>*/ {return view_label}); menu_mini = menuItemAction(__txt("Label"), function() { view_label = !view_label; }, noone, noone, function() /*=>*/ {return view_label});
function onResize() { function onResize() {
sp_palettes.resize(w - ui(padding + padding), h - ui(padding + padding)); sp_palettes.resize(w - ui(padding + padding), h - ui(padding + padding));
@ -164,10 +164,10 @@ function Panel_Palette() : PanelContent() constructor {
menu_add, menu_add,
menu_refresh, menu_refresh,
-1, -1,
menuItem(__txtx("palette_editor_set_default", "Set as default"), function() { menuItemAction(__txtx("palette_editor_set_default", "Set as default"), function() {
PROJECT.setPalette(array_clone(hovering.palette)); PROJECT.setPalette(array_clone(hovering.palette));
}), }),
menuItem(__txtx("palette_editor_delete", "Delete palette"), function() { menuItemAction(__txtx("palette_editor_delete", "Delete palette"), function() {
file_delete(hovering.path); file_delete(hovering.path);
__initPalette(); __initPalette();
}), }),

View file

@ -188,7 +188,7 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
var _b = buttonInstant(THEME.button_hide, _bx, _by, _bs, pal_h, [ mx, my ], pFOCUS, pHOVER, "", THEME.hamburger_s); var _b = buttonInstant(THEME.button_hide, _bx, _by, _bs, pal_h, [ mx, my ], pFOCUS, pHOVER, "", THEME.hamburger_s);
if(_b == 2) { if(_b == 2) {
menuCall("",,, [ menuCall("",,, [
menuItem("Save palette as...", function() { menuItemAction("Save palette as...", function() {
var _path = get_save_filename_pxc("Hex paleete|*.hex", "Palette"); var _path = get_save_filename_pxc("Hex paleete|*.hex", "Palette");
if(_path != "") { if(_path != "") {
var _str = palette_string_hex(palette, false); var _str = palette_string_hex(palette, false);
@ -392,7 +392,7 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
conn_menu_ctx = [ blnd_hovering ]; conn_menu_ctx = [ blnd_hovering ];
menuCall(,,, [ menuCall(,,, [
menuItem("Delete Blend point", function() { array_delete(palette_data.blends, conn_menu_ctx[0], 1); } ), menuItemAction("Delete Blend point", function() { array_delete(palette_data.blends, conn_menu_ctx[0], 1); } ),
]); ]);
} }
@ -443,7 +443,7 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
conn_menu_ctx = [ conn[0], conn[1], _con_rat ]; conn_menu_ctx = [ conn[0], conn[1], _con_rat ];
menuCall(,,, [ menuCall(,,, [
menuItem("New Blend point", function() { array_push(palette_data.blends, { from : conn_menu_ctx[0], to : conn_menu_ctx[1], amount : conn_menu_ctx[2] }) } ), menuItemAction("New Blend point", function() { array_push(palette_data.blends, { from : conn_menu_ctx[0], to : conn_menu_ctx[1], amount : conn_menu_ctx[2] }) } ),
]); ]);
} }
@ -467,18 +467,18 @@ function Panel_Palette_Mixer() : PanelContent() constructor {
if(mouse_press(mb_right)) { if(mouse_press(mb_right)) {
menuCall(,,, [ menuCall(,,, [
menuItem("Center view", function() { centerView(); } ), menuItemAction("Center view", function() { centerView(); } ),
-1, -1,
menuItem("Save mixed...", function() { menuItemAction("Save mixed...", function() {
var _path = get_save_filename_pxc("JSON|*.json", "New mixed"); var _path = get_save_filename_pxc("JSON|*.json", "New mixed");
if(_path != "") save_palette_mixer(palette_data, _path); if(_path != "") save_palette_mixer(palette_data, _path);
}, THEME.save), }, THEME.save),
menuItem("Load mixed...", function() { menuItemAction("Load mixed...", function() {
var _path = get_open_filename_pxc("JSON|*.json", ""); var _path = get_open_filename_pxc("JSON|*.json", "");
if(_path != "") palette_data = load_palette_mixer(_path); if(_path != "") palette_data = load_palette_mixer(_path);
}, THEME.noti_icon_file_load), }, THEME.noti_icon_file_load),
-1, -1,
menuItem("Clear palette", function() { palette_data = { nodes: [], connections: [], blends: [], } }, THEME.cross), menuItemAction("Clear palette", function() { palette_data = { nodes: [], connections: [], blends: [], } }, THEME.cross),
]); ]);
} }
} }

View file

@ -1,3 +1,9 @@
#macro CHECK_PANEL_PRESETS if(!is_instanceof(FOCUS_CONTENT, Panel_Presets)) return;
function panel_preset_replace() { CHECK_PANEL_PRESETS CALL("panel_preset_replace"); FOCUS_CONTENT.replacePreset(FOCUS_CONTENT.selecting_preset.path); }
function panel_preset_delete() { CHECK_PANEL_PRESETS CALL("panel_preset_delete"); file_delete(FOCUS_CONTENT.selecting_preset.path); FOCUS_CONTENT.__initPresets(); }
function panel_preset_reset() { CHECK_PANEL_PRESETS CALL("panel_preset_reset"); FOCUS_CONTENT.newPresetFromNode("_default"); }
function Panel_Presets(_node) : PanelContent() constructor { function Panel_Presets(_node) : PanelContent() constructor {
title = __txt("Presets"); title = __txt("Presets");
padding = 8; padding = 8;
@ -22,14 +28,18 @@ function Panel_Presets(_node) : PanelContent() constructor {
directory_verify($"{DIRECTORY}Presets/{instanceof(node)}/"); directory_verify($"{DIRECTORY}Presets/{instanceof(node)}/");
__initPresets(); __initPresets();
registerFunction("Presets", "Replace", "", MOD_KEY.none, panel_preset_replace);
registerFunction("Presets", "Delete", "", MOD_KEY.none, panel_preset_delete);
registerFunction("Presets", "Reset To Default", "", MOD_KEY.none, panel_preset_reset);
context_menu = [ context_menu = [
menuItem(__txt("Replace preset"), function() { replacePreset(selecting_preset.path); }), menuItemAction(__txt("Replace preset"), panel_preset_replace),
menuItem(__txt("Delete"), function() { file_delete(selecting_preset.path); __initPresets(); }, THEME.cross), menuItemAction(__txt("Delete"), panel_preset_delete, THEME.cross),
]; ];
context_def = [ context_def = [
menuItem(__txt("Set to default"), function() { newPresetFromNode("_default"); }), menuItemAction(__txt("Set to default"), panel_preset_reset),
]; ];
thumbnail_mask = surface_create(1, 1); thumbnail_mask = surface_create(1, 1);

View file

@ -1,19 +1,44 @@
#region funtion calls #region funtion calls
function __fnInit_Preview() { function __fnInit_Preview() {
__registerFunction("preview_focus_content", panel_preview_focus_content); registerFunction("Preview", "Focus content", "F", MOD_KEY.none, panel_preview_focus_content);
__registerFunction("preview_save_current_frame", panel_preview_save_current_frame); registerFunction("Preview", "Save current frame", "S", MOD_KEY.shift, panel_preview_save_current_frame);
__registerFunction("preview_saveCurrentFrameToFocus", panel_preview_saveCurrentFrameToFocus); registerFunction("Preview", "Save to focused file", "", MOD_KEY.none, panel_preview_saveCurrentFrameToFocus);
__registerFunction("preview_save_all_current_frame", panel_preview_save_all_current_frame); registerFunction("Preview", "Save all current frame", "", MOD_KEY.none, panel_preview_save_all_current_frame);
__registerFunction("preview_preview_window", panel_preview_preview_window); registerFunction("Preview", "Preview window", "P", MOD_KEY.ctrl, panel_preview_preview_window);
__registerFunction("preview_toggle_grid", panel_preview_toggle_grid); registerFunction("Preview", "Toggle grid", "G", MOD_KEY.ctrl, panel_preview_toggle_grid);
registerFunction("Preview", "Pan", "", MOD_KEY.ctrl, panel_preview_pan);
registerFunction("Preview", "Zoom", "", MOD_KEY.alt | MOD_KEY.ctrl, panel_preview_zoom);
__registerFunction("preview_pan", panel_preview_pan); registerFunction("Preview", "3D Front view", vk_numpad1, MOD_KEY.none, panel_preview_3d_view_front);
__registerFunction("preview_zoom", panel_preview_zoom); registerFunction("Preview", "3D Back view", vk_numpad1, MOD_KEY.alt, panel_preview_3d_view_back);
registerFunction("Preview", "3D Right view ", vk_numpad3, MOD_KEY.none, panel_preview_3d_view_right);
registerFunction("Preview", "3D Left view ", vk_numpad3, MOD_KEY.alt, panel_preview_3d_view_left);
registerFunction("Preview", "3D Top view", vk_numpad7, MOD_KEY.none, panel_preview_3d_view_top);
registerFunction("Preview", "3D Bottom view", vk_numpad7, MOD_KEY.alt, panel_preview_3d_view_bottom);
registerFunction("Preview", "Scale x1", "1", MOD_KEY.none, function() /*=>*/ { panel_preview_set_zoom(1); });
registerFunction("Preview", "Scale x2", "2", MOD_KEY.none, function() /*=>*/ { panel_preview_set_zoom(2); });
registerFunction("Preview", "Scale x4", "3", MOD_KEY.none, function() /*=>*/ { panel_preview_set_zoom(4); });
registerFunction("Preview", "Scale x8", "4", MOD_KEY.none, function() /*=>*/ { panel_preview_set_zoom(8); });
registerFunction("Preview", "Set Tile Off", "", MOD_KEY.none, panel_preview_set_tile_off);
registerFunction("Preview", "Set Tile Horizontal", "", MOD_KEY.none, panel_preview_set_tile_horizontal);
registerFunction("Preview", "Set Tile Vertical", "", MOD_KEY.none, panel_preview_set_tile_vertical);
registerFunction("Preview", "Set Tile Both", "", MOD_KEY.none, panel_preview_set_tile_both);
registerFunction("Preview", "Toggle Tile", "", MOD_KEY.none, panel_preview_set_tile_toggle);
registerFunction("Preview", "New Preview Window", "", MOD_KEY.none, panel_preview_new_preview_window);
registerFunction("Preview", "Save Current Frame", "", MOD_KEY.none, panel_preview_saveCurrentFrame);
registerFunction("Preview", "Save All Current Frames", "", MOD_KEY.none, panel_preview_saveAllCurrentFrames);
registerFunction("Preview", "Copy Current Frame", "", MOD_KEY.none, panel_preview_copyCurrentFrame);
registerFunction("Preview", "Copy Color", "", MOD_KEY.none, panel_preview_copy_color);
registerFunction("Preview", "Copy Color Hex", "", MOD_KEY.none, panel_preview_copy_color_hex);
} }
function panel_preview_focus_content() { CALL("preview_focus_content"); PANEL_PREVIEW.fullView(); } function panel_preview_focus_content() { CALL("preview_focus_content"); PANEL_PREVIEW.fullView(); }
function panel_preview_save_current_frame() { CALL("preview_save_current_frame"); PANEL_PREVIEW.saveCurrentFrame(); } function panel_preview_save_current_frame() { CALL("preview_save_current_frame"); PANEL_PREVIEW.saveCurrentFrame(); }
function panel_preview_saveCurrentFrameToFocus() { CALL("preview_saveCurrentFrameToFocus"); PANEL_PREVIEW.saveCurrentFrameToFocus(); } function panel_preview_saveCurrentFrameToFocus() { CALL("preview_save_to_focused_file"); PANEL_PREVIEW.saveCurrentFrameToFocus(); }
function panel_preview_save_all_current_frame() { CALL("preview_save_all_current_frame"); PANEL_PREVIEW.saveAllCurrentFrames(); } function panel_preview_save_all_current_frame() { CALL("preview_save_all_current_frame"); PANEL_PREVIEW.saveAllCurrentFrames(); }
function panel_preview_preview_window() { CALL("preview_preview_window"); PANEL_PREVIEW.create_preview_window(PANEL_PREVIEW.getNodePreview()); } function panel_preview_preview_window() { CALL("preview_preview_window"); PANEL_PREVIEW.create_preview_window(PANEL_PREVIEW.getNodePreview()); }
function panel_preview_toggle_grid() { CALL("preview_toggle_grid"); PROJECT.previewGrid.show = !PROJECT.previewGrid.show; } function panel_preview_toggle_grid() { CALL("preview_toggle_grid"); PROJECT.previewGrid.show = !PROJECT.previewGrid.show; }
@ -21,14 +46,28 @@
function panel_preview_pan() { CALL("preview_pan"); PANEL_PREVIEW.canvas_dragging_key = true; } function panel_preview_pan() { CALL("preview_pan"); PANEL_PREVIEW.canvas_dragging_key = true; }
function panel_preview_zoom() { CALL("preview_zoom"); PANEL_PREVIEW.canvas_zooming_key = true; } function panel_preview_zoom() { CALL("preview_zoom"); PANEL_PREVIEW.canvas_zooming_key = true; }
function panel_preview_3d_view_front() { CALL("preview_3d_view_front"); PANEL_PREVIEW.d3_view_action_front(); } function panel_preview_3d_view_front() { CALL("preview_3d_front_view"); PANEL_PREVIEW.d3_view_action_front(); }
function panel_preview_3d_view_back() { CALL("preview_3d_view_back"); PANEL_PREVIEW.d3_view_action_back(); } function panel_preview_3d_view_back() { CALL("preview_3d_back_view"); PANEL_PREVIEW.d3_view_action_back(); }
function panel_preview_3d_view_right() { CALL("preview_3d_view_right"); PANEL_PREVIEW.d3_view_action_right(); } function panel_preview_3d_view_right() { CALL("preview_3d_right_view"); PANEL_PREVIEW.d3_view_action_right(); }
function panel_preview_3d_view_left() { CALL("preview_3d_view_left"); PANEL_PREVIEW.d3_view_action_left(); } function panel_preview_3d_view_left() { CALL("preview_3d_left_view"); PANEL_PREVIEW.d3_view_action_left(); }
function panel_preview_3d_view_top() { CALL("preview_3d_view_top"); PANEL_PREVIEW.d3_view_action_top(); } function panel_preview_3d_view_top() { CALL("preview_3d_top_view"); PANEL_PREVIEW.d3_view_action_top(); }
function panel_preview_3d_view_bottom() { CALL("preview_3d_view_bottom"); PANEL_PREVIEW.d3_view_action_bottom(); } function panel_preview_3d_view_bottom() { CALL("preview_3d_bottom_view"); PANEL_PREVIEW.d3_view_action_bottom(); }
function panel_preview_set_zoom(zoom) { CALL("preview_preview_set_zoom"); PANEL_PREVIEW.fullView(zoom); }
function panel_preview_set_tile_off() { CALL("preview_set_tile_off"); PANEL_PREVIEW.set_tile_off(); }
function panel_preview_set_tile_horizontal() { CALL("preview_set_tile_horizontal"); PANEL_PREVIEW.set_tile_horizontal(); }
function panel_preview_set_tile_vertical() { CALL("preview_set_tile_vertical"); PANEL_PREVIEW.set_tile_vertical(); }
function panel_preview_set_tile_both() { CALL("preview_set_tile_both"); PANEL_PREVIEW.set_tile_both(); }
function panel_preview_set_tile_toggle() { CALL("preview_set_tile_toggle"); PANEL_PREVIEW.set_tile_toggle(); }
function panel_preview_new_preview_window() { CALL("preview_new_preview_window"); PANEL_PREVIEW.new_preview_window(); }
function panel_preview_saveCurrentFrame() { CALL("preview_saveCurrentFrame"); PANEL_PREVIEW.saveCurrentFrame(); }
function panel_preview_saveAllCurrentFrames() { CALL("preview_saveAllCurrentFrames"); PANEL_PREVIEW.saveAllCurrentFrames(); }
function panel_preview_copyCurrentFrame() { CALL("preview_copyCurrentFrame"); PANEL_PREVIEW.copyCurrentFrame(); }
function panel_preview_copy_color() { CALL("preview_copy_color"); PANEL_PREVIEW.copy_color(); }
function panel_preview_copy_color_hex() { CALL("preview_copy_color_hex"); PANEL_PREVIEW.copy_color_hex(); }
function panel_preview_set_zoom(zoom) { CALL("preview_preview_set_zoom"); PANEL_PREVIEW.fullView(zoom); }
#endregion #endregion
function Panel_Preview() : PanelContent() constructor { function Panel_Preview() : PanelContent() constructor {
@ -221,31 +260,17 @@ function Panel_Preview() : PanelContent() constructor {
tb_framerate = new textBox(TEXTBOX_INPUT.number, function(val) { preview_rate = real(val); }); tb_framerate = new textBox(TEXTBOX_INPUT.number, function(val) { preview_rate = real(val); });
#region ++++ hotkey ++++
addHotkey("Preview", "Focus content", "F", MOD_KEY.none, panel_preview_focus_content);
addHotkey("Preview", "Save current frame", "S", MOD_KEY.shift, panel_preview_save_current_frame);
addHotkey("Preview", "Save to focused file", "", MOD_KEY.none, panel_preview_saveCurrentFrameToFocus);
addHotkey("Preview", "Save all current frame", "", MOD_KEY.none, panel_preview_save_all_current_frame);
addHotkey("Preview", "Preview window", "P", MOD_KEY.ctrl, panel_preview_preview_window);
addHotkey("Preview", "Toggle grid", "G", MOD_KEY.ctrl, panel_preview_toggle_grid);
addHotkey("Preview", "Pan", "", MOD_KEY.ctrl, panel_preview_pan);
addHotkey("Preview", "Zoom", "", MOD_KEY.alt | MOD_KEY.ctrl, panel_preview_zoom);
addHotkey("Preview", "3D Front view", vk_numpad1, MOD_KEY.none, panel_preview_3d_view_front);
addHotkey("Preview", "3D Back view", vk_numpad1, MOD_KEY.alt, panel_preview_3d_view_back);
addHotkey("Preview", "3D Right view ", vk_numpad3, MOD_KEY.none, panel_preview_3d_view_right);
addHotkey("Preview", "3D Left view ", vk_numpad3, MOD_KEY.alt, panel_preview_3d_view_left);
addHotkey("Preview", "3D Top view", vk_numpad7, MOD_KEY.none, panel_preview_3d_view_top);
addHotkey("Preview", "3D Bottom view", vk_numpad7, MOD_KEY.alt, panel_preview_3d_view_bottom);
addHotkey("Preview", "Scale x1", "1", MOD_KEY.none, function() /*=>*/ { panel_preview_set_zoom(1); });
addHotkey("Preview", "Scale x2", "2", MOD_KEY.none, function() /*=>*/ { panel_preview_set_zoom(2); });
addHotkey("Preview", "Scale x4", "3", MOD_KEY.none, function() /*=>*/ { panel_preview_set_zoom(4); });
addHotkey("Preview", "Scale x8", "4", MOD_KEY.none, function() /*=>*/ { panel_preview_set_zoom(8); });
#endregion
#region ++++ toolbars & actions ++++ #region ++++ toolbars & actions ++++
function set_tile_off() { tileMode = 0; }
function set_tile_horizontal() { tileMode = 1; }
function set_tile_vertical() { tileMode = 2; }
function set_tile_both() { tileMode = 3; }
function set_tile_toggle() { tileMode = (tileMode + 1) % 4; }
function new_preview_window() { create_preview_window(getNodePreview()); }
function copy_color() { clipboard_set_text(sample_color); }
function copy_color_hex() { clipboard_set_text(color_get_hex(sample_color)); }
topbar_height = ui(32); topbar_height = ui(32);
toolbar_height = ui(40); toolbar_height = ui(40);
toolbars = [ toolbars = [
@ -261,9 +286,9 @@ function Panel_Preview() : PanelContent() constructor {
function() { return splitView; }, function() { return splitView; },
function() { function() {
switch(splitView) { switch(splitView) {
case 0 : return __txtx("panel_preview_split_view_off", "Split view off"); case 0 : return __txtx("panel_preview_split_view_off", "Split view off");
case 1 : return __txtx("panel_preview_horizontal_split_view", "Horizontal split view"); case 1 : return __txtx("panel_preview_horizontal_split_view", "Horizontal split view");
case 2 : return __txtx("panel_preview_vertical_split_view", "Vertical split view"); case 2 : return __txtx("panel_preview_vertical_split_view", "Vertical split view");
} }
return __txtx("panel_preview_split_view", "Split view"); return __txtx("panel_preview_split_view", "Split view");
}, },
@ -274,19 +299,19 @@ function Panel_Preview() : PanelContent() constructor {
function() { var t = [3, 0, 1, 2]; return array_safe_get_fast(t, tileMode); }, function() { var t = [3, 0, 1, 2]; return array_safe_get_fast(t, tileMode); },
function() { function() {
switch(tileMode) { switch(tileMode) {
case 0 : return __txtx("panel_preview_tile_off", "Tile off"); case 0 : return __txtx("panel_preview_tile_off", "Tile off");
case 1 : return __txtx("panel_preview_tile_horizontal", "Tile horizontal"); case 1 : return __txtx("panel_preview_tile_horizontal", "Tile horizontal");
case 2 : return __txtx("panel_preview_tile_vertical", "Tile vertical"); case 2 : return __txtx("panel_preview_tile_vertical", "Tile vertical");
case 3 : return __txtx("panel_preview_tile_both", "Tile both"); case 3 : return __txtx("panel_preview_tile_both", "Tile both");
} }
return __txtx("panel_preview_tile_mode", "Tile mode"); return __txtx("panel_preview_tile_mode", "Tile mode");
}, },
function(data) { function(data) {
menuCall("preview_tile_menu", data.x + ui(28), data.y + ui(28), [ menuCall("preview_tile_menu", data.x + ui(28), data.y + ui(28), [
menuItem(__txtx("panel_preview_tile_off", "Tile off"), function() { tileMode = 0; }), menuItemAction(__txtx("panel_preview_tile_off", "Tile off"), panel_preview_set_tile_off),
menuItem(__txtx("panel_preview_tile_horizontal", "Tile horizontal"), function() { tileMode = 1; }), menuItemAction(__txtx("panel_preview_tile_horizontal", "Tile horizontal"), panel_preview_set_tile_horizontal),
menuItem(__txtx("panel_preview_tile_vertical", "Tile vertical"), function() { tileMode = 2; }), menuItemAction(__txtx("panel_preview_tile_vertical", "Tile vertical"), panel_preview_set_tile_vertical),
menuItem(__txtx("panel_preview_tile_both", "Tile both"), function() { tileMode = 3; }), menuItemAction(__txtx("panel_preview_tile_both", "Tile both"), panel_preview_set_tile_both),
]); ]);
} }
], ],
@ -2099,14 +2124,14 @@ function Panel_Preview() : PanelContent() constructor {
if(mouse_on_preview && mouse_press(mb_right, pFOCUS) && !key_mod_press(SHIFT)) { if(mouse_on_preview && mouse_press(mb_right, pFOCUS) && !key_mod_press(SHIFT)) {
menuCall("preview_context_menu",,, [ menuCall("preview_context_menu",,, [
menuItem(__txtx("panel_graph_preview_window", "Send to preview window"), function() { create_preview_window(getNodePreview()); }, noone, ["Preview", "Preview window"]), menuItemAction(__txtx("panel_graph_preview_window", "Send to preview window"), panel_preview_new_preview_window),
-1, -1,
menuItem(__txtx("panel_preview_save", "Save current preview as") + "...", function() { saveCurrentFrame(); }, noone, ["Preview", "Save current frame"]), menuItemAction(__txtx("panel_preview_save", "Save current preview as") + "...", panel_preview_saveCurrentFrame),
menuItem(__txtx("panel_preview_save_all", "Save all current previews as") + "...", function() { saveAllCurrentFrames(); }, noone, ["Preview", "Save all current frame"]), menuItemAction(__txtx("panel_preview_save_all", "Save all current previews as") + "...", panel_preview_saveAllCurrentFrames),
-1, -1,
menuItem($"{__txtx("panel_preview_copy_image", "Copy image")}", function() { copyCurrentFrame(); }, THEME.copy), menuItemAction($"{__txtx("panel_preview_copy_image", "Copy image")}", panel_preview_copyCurrentFrame, THEME.copy),
menuItem($"{__txtx("panel_preview_copy_color", "Copy color")} [{sample_color}]", function() { clipboard_set_text(sample_color); }), menuItemAction($"{__txtx("panel_preview_copy_color", "Copy color")} [{sample_color}]", panel_preview_copy_color),
menuItem($"{__txtx("panel_preview_copy_hex", "Copy hex")} [{color_get_hex(sample_color)}]", function() { clipboard_set_text(color_get_hex(sample_color)); }), menuItemAction($"{__txtx("panel_preview_copy_hex", "Copy hex")} [{color_get_hex(sample_color)}]", panel_preview_copy_color_hex),
],, getNodePreview()); ],, getNodePreview());
} }

View file

@ -1,6 +1,12 @@
#macro CHECK_PANEL_PREVIEW_WINDOW if(!is_instanceof(FOCUS_CONTENT, Panel_Preview_Window)) return;
function panel_preview_window_reset() { CHECK_PANEL_PREVIEW_WINDOW CALL("preview_window_reset"); FOCUS_CONTENT.reset(); }
function panel_preview_window_inspect() { CHECK_PANEL_PREVIEW_WINDOW CALL("preview_window_inspect"); PANEL_GRAPH.nodes_selecting = [ FOCUS_CONTENT.node_target ]; }
function panel_preview_window_preview() { CHECK_PANEL_PREVIEW_WINDOW CALL("preview_window_preview"); PANEL_PREVIEW.setNodePreview(FOCUS_CONTENT.node_target); }
function Panel_Preview_Window() : PanelContent() constructor { function Panel_Preview_Window() : PanelContent() constructor {
min_w = ui(64); min_w = ui(64);
min_h = ui(64); min_h = ui(64);
padding = 8; padding = 8;
title_height = 24; title_height = 24;
@ -48,11 +54,15 @@ function Panel_Preview_Window() : PanelContent() constructor {
content_surface = noone; content_surface = noone;
surfaceCheck(); surfaceCheck();
registerFunction("Preview Window", "Reset view", "", MOD_KEY.none, panel_preview_window_reset);
registerFunction("Preview Window", "Inspect", "", MOD_KEY.none, panel_preview_window_inspect);
registerFunction("Preview Window", "Preview", "", MOD_KEY.none, panel_preview_window_preview);
menu = [ menu = [
menuItem(__txtx("reset_view", "Reset view"), function() { reset(); }), menuItemAction(__txtx("reset_view", "Reset view"), panel_preview_window_reset),
-1, -1,
menuItem(__txt("Inspect"), function() { PANEL_GRAPH.nodes_selecting = [ node_target ]; }), menuItemAction(__txt("Inspect"), panel_preview_window_inspect),
menuItem(__txtx("panel_graph_send_to_preview", "Send to preview"), function() { PANEL_PREVIEW.setNodePreview(node_target); }), menuItemAction(__txtx("panel_graph_send_to_preview", "Send to preview"), panel_preview_window_preview),
-1, -1,
] ]
@ -151,7 +161,7 @@ function Panel_Preview_Window() : PanelContent() constructor {
var o = node_target.outputs[i]; var o = node_target.outputs[i];
if(o.type != VALUE_TYPE.surface) continue; if(o.type != VALUE_TYPE.surface) continue;
array_push(_menu, menuItem(o.name, function(_dat) { changeChannel(_dat.index); })); array_push(_menu, menuItemAction(o.name, function(_dat) { changeChannel(_dat.index); }));
} }
menuCall("preview_window_menu",,, _menu,, node_target); menuCall("preview_window_menu",,, _menu,, node_target);
} }

View file

@ -1,5 +1,11 @@
#macro CHECK_PANEL_WORKSPACE if(!is_instanceof(FOCUS_CONTENT, Panel_Workspace)) return;
function panel_workspace_apply() { CHECK_PANEL_WORKSPACE CALL("panel_workspace_apply"); FOCUS_CONTENT.apply_space(); }
function panel_workspace_replace() { CHECK_PANEL_WORKSPACE CALL("panel_workspace_replace"); FOCUS_CONTENT.replace_space(); }
function panel_workspace_delete() { CHECK_PANEL_WORKSPACE CALL("panel_workspace_delete"); FOCUS_CONTENT.delete_space(); }
function Panel_Workspace() : PanelContent() constructor { function Panel_Workspace() : PanelContent() constructor {
title = "Workspace"; title = "Workspace";
workspaces = []; workspaces = [];
w = ui(480); w = ui(480);
h = ui(40); h = ui(40);
@ -7,10 +13,33 @@ function Panel_Workspace() : PanelContent() constructor {
scroll = 0; scroll = 0;
scroll_to = 0; scroll_to = 0;
scroll_max = 0; scroll_max = 0;
hori = false; hori = false;
layout_selecting = ""; layout_selecting = "";
registerFunction("Workspace", "Apply", "", MOD_KEY.none, panel_workspace_apply);
registerFunction("Workspace", "Replace", "", MOD_KEY.none, panel_workspace_replace);
registerFunction("Workspace", "Delete", "", MOD_KEY.none, panel_workspace_delete);
function apply_space() {
if(layout_selecting == "") return;
PREFERENCES.panel_layout_file = layout_selecting;
PREF_SAVE();
setPanel();
}
function replace_space() {
if(layout_selecting == "") return;
var cont = panelSerialize();
json_save_struct(DIRECTORY + "layouts/" + layout_selecting + ".json", cont);
}
function delete_space() {
if(layout_selecting == "") return;
file_delete(DIRECTORY + "layouts/" + layout_selecting + ".json");
refreshContent();
}
function refreshContent() { function refreshContent() {
workspaces = []; workspaces = [];
@ -20,8 +49,8 @@ function Panel_Workspace() : PanelContent() constructor {
array_push(workspaces, filename_name_only(f)); array_push(workspaces, filename_name_only(f));
f = file_find_next(); f = file_find_next();
} }
}
refreshContent(); } refreshContent();
function onFocusBegin() { refreshContent(); } function onFocusBegin() { refreshContent(); }
@ -74,20 +103,9 @@ function Panel_Workspace() : PanelContent() constructor {
if(mouse_press(mb_right, pFOCUS)) { if(mouse_press(mb_right, pFOCUS)) {
layout_selecting = str; layout_selecting = str;
menuCall("workspace_menu",,, [ menuCall("workspace_menu",,, [
menuItem(__txt("Select"), function() { menuItemAction(__txt("Select"), apply_space),
PREFERENCES.panel_layout_file = layout_selecting; menuItemAction(__txtx("workspace_replace_current", "Replace with current"), replace_space),
PREF_SAVE(); menuItemAction(__txt("Delete"), delete_space, THEME.cross),
setPanel();
}),
menuItem(__txtx("workspace_replace_current", "Replace with current"), function() {
var cont = panelSerialize();
json_save_struct(DIRECTORY + "layouts/" + layout_selecting + ".json", cont);
}),
menuItem(__txt("Delete"), function() {
file_delete(DIRECTORY + "layouts/" + layout_selecting + ".json");
refreshContent();
}, THEME.cross),
]); ]);
} }
} }

View file

@ -40,7 +40,7 @@ function filename_name_only(name) {
return string_replace(name, filename_ext(name), "") return string_replace(name, filename_ext(name), "")
} }
function string_to_var(str) { INLINE return string_replace_all(string_lower(str), " ", "_"); } function string_to_var(str) { INLINE return string_replace_all(string_replace_all(string_lower(str), " ", "_"), "/", "_"); }
function string_quote(str) { INLINE return $"\"{str}\""; } function string_quote(str) { INLINE return $"\"{str}\""; }
function array_to_string(arr) { function array_to_string(arr) {