small fixes

This commit is contained in:
Tanasart 2024-04-05 10:50:03 +07:00
parent 8e4c70ced3
commit 31d3fc31c8
9 changed files with 277 additions and 230 deletions

View file

@ -5,6 +5,7 @@ if(winMan_isMinimized()) exit;
if(is_struct(TOOLTIP)) { if(is_struct(TOOLTIP)) {
if(struct_has(TOOLTIP, "drawTooltip")) if(struct_has(TOOLTIP, "drawTooltip"))
TOOLTIP.drawTooltip(); TOOLTIP.drawTooltip();
} else if(is_array(TOOLTIP)) { } else if(is_array(TOOLTIP)) {
var content = TOOLTIP[0]; var content = TOOLTIP[0];
var type = TOOLTIP[1]; var type = TOOLTIP[1];

View file

@ -121,14 +121,12 @@
else ds_list_add(HOTKEYS[? _context], key); else ds_list_add(HOTKEYS[? _context], key);
} }
function getHotkey(context, name) { function find_hotkey(_context, _name) { #region
if(!ds_map_exists(HOTKEYS, context)) return noone; if(!ds_map_exists(HOTKEYS, _context)) return noone;
for(var i = 0; i < ds_list_size(HOTKEYS[? context]); i++) { for(var j = 0; j < ds_list_size(HOTKEYS[? _context]); j++) {
var hotkey = HOTKEYS[? _context][| i]; if(HOTKEYS[? _context][| j].name == _name)
if(hotkey.name == name) return hotkey; return HOTKEYS[? _context][| j];
} }
} #endregion
return noone;
}
#endregion #endregion

View file

@ -51,17 +51,17 @@ function Node_Collection_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) c
static getNodeBorder = function(_ind, _vertex, _node) { #region static getNodeBorder = function(_ind, _vertex, _node) { #region
var _rad = 6; var _rad = 6;
var _stp = 15; var _stp = 30;
var _nx0 = is_instanceof(_node, input_node_type)? _node.x + _node.w / 2 : _node.x - 32 + _rad; var _nx0 = is_instanceof(_node, input_node_type)? _node.x + _node.w / 2 : _node.x - 32 + _rad;
var _ny0 = _node.y - 32 + _rad; var _ny0 = _node.y - 32 + _rad;
var _nx1 = is_instanceof(_node, output_node_type)? _node.x + _node.w / 2 : _node.x + _node.w + 32 - _rad; var _nx1 = is_instanceof(_node, output_node_type)? _node.x + _node.w / 2 : _node.x + _node.w + 32 - _rad;
var _ny1 = _node.y + _node.h + 32 - _rad; var _ny1 = _node.y + _node.h + 32 - _rad;
for( var i = 0; i < 90; i += _stp ) _vertex[_ind++] = [ _nx1 + lengthdir_x(_rad, i), _ny0 + lengthdir_y(_rad, i) ]; for( var i = 0; i <= 90; i += _stp ) _vertex[_ind++] = [ _nx1 + lengthdir_x(_rad, i), _ny0 + lengthdir_y(_rad, i) ];
for( var i = 90; i < 180; i += _stp ) _vertex[_ind++] = [ _nx0 + lengthdir_x(_rad, i), _ny0 + lengthdir_y(_rad, i) ]; for( var i = 90; i <= 180; i += _stp ) _vertex[_ind++] = [ _nx0 + lengthdir_x(_rad, i), _ny0 + lengthdir_y(_rad, i) ];
for( var i = 180; i < 270; i += _stp ) _vertex[_ind++] = [ _nx0 + lengthdir_x(_rad, i), _ny1 + lengthdir_y(_rad, i) ]; for( var i = 180; i <= 270; i += _stp ) _vertex[_ind++] = [ _nx0 + lengthdir_x(_rad, i), _ny1 + lengthdir_y(_rad, i) ];
for( var i = 270; i < 360; i += _stp ) _vertex[_ind++] = [ _nx1 + lengthdir_x(_rad, i), _ny1 + lengthdir_y(_rad, i) ]; for( var i = 270; i <= 360; i += _stp ) _vertex[_ind++] = [ _nx1 + lengthdir_x(_rad, i), _ny1 + lengthdir_y(_rad, i) ];
return _ind; return _ind;
} #endregion } #endregion
@ -101,7 +101,7 @@ function Node_Collection_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) c
group_vertex = []; group_vertex = [];
if(_ind == 0) return; if(_ind == 0) return;
var _vtrx = array_create(_ind * 4 * 6); var _vtrx = array_create(_ind * 4 * (90 / 30 + 1));
var _ind = 0; var _ind = 0;
for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) { for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) {
@ -137,7 +137,7 @@ function Node_Collection_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) c
array_delete(_vtrx, 1, _linS - 1); array_delete(_vtrx, 1, _linS - 1);
group_vertex = [ _vtrx[0], _vtrx[1] ]; group_vertex = [ _vtrx[0], _vtrx[1] ];
for( var i = 2, n = array_length(_vtrx); i < n; i++ ) { for( var i = 2, n = array_length(_vtrx); i < n; i++ ) {
var _v = _vtrx[i]; var _v = _vtrx[i];
@ -145,6 +145,22 @@ function Node_Collection_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) c
array_pop(group_vertex); array_pop(group_vertex);
array_push(group_vertex, _v); array_push(group_vertex, _v);
} }
for( var i = array_length(group_vertex) - 1; i >= 0; i-- ) {
var n = array_length(group_vertex);
if(n < 4) break;
var v0 = group_vertex[(i - 1 + n) % n];
var v1 = group_vertex[i];
var v2 = group_vertex[(i + 1) % n];
var a0 = point_direction(v1[0], v1[1], v0[0], v0[1]);
var a1 = point_direction(v1[0], v1[1], v2[0], v2[1]);
var d = angle_difference(a0, a1);
if(min(abs(d), abs(d - 180)) <= 2)
array_delete(group_vertex, i, 1);
}
#endregion #endregion
} #endregion } #endregion
@ -263,7 +279,7 @@ function Node_Collection_Inline(_x, _y, _group = noone) : Node(_x, _y, _group) c
// var _vx = _x + a[0] * _s; // var _vx = _x + a[0] * _s;
// var _vy = _y + a[1] * _s; // var _vy = _y + a[1] * _s;
// draw_circle(_vx, _vy, 3, false); // draw_circle(_vx, _vy, 1, false);
//} //}
return _hov; return _hov;

View file

@ -9,9 +9,9 @@ function readObj_init() {
_VBT = []; _VBT = [];
_VBN = []; _VBN = [];
mats = []; mats = [];
matIndex = []; matIndex = [];
tris = []; tris = [];
mtlPath = ""; mtlPath = "";
use_normal = true; use_normal = true;
v = ds_list_create(); v = ds_list_create();
vt = ds_list_create(); vt = ds_list_create();
@ -36,6 +36,7 @@ function readObj_file() {
case "v" : case "v" :
ds_list_add(v, [ toNumber(sep[1]), toNumber(sep[2]), toNumber(sep[3]) ]); ds_list_add(v, [ toNumber(sep[1]), toNumber(sep[2]), toNumber(sep[3]) ]);
break; break;
case "vt" : case "vt" :
var _u = toNumber(sep[1]); var _u = toNumber(sep[1]);
var _v = toNumber(sep[2]); var _v = toNumber(sep[2]);
@ -54,6 +55,7 @@ function readObj_file() {
ds_list_add(vn, [ _nx, _ny, _nz ]); ds_list_add(vn, [ _nx, _ny, _nz ]);
break; break;
case "f" : case "f" :
var _len = array_length(sep); var _len = array_length(sep);
var _f = array_create(_len - 1); var _f = array_create(_len - 1);
@ -62,13 +64,13 @@ function readObj_file() {
for( var i = 1; i < _len; i++ ) { for( var i = 1; i < _len; i++ ) {
var _sp = string_split(sep[i], "/"); var _sp = string_split(sep[i], "/");
if(array_length(_sp) < 2) continue; if(array_length(_sp) < 3) continue;
_f[i - 1] = toNumber(_sp[0]); _f[i - 1] = toNumber(_sp[0]);
_ft[i - 1] = toNumber(_sp[1]); _ft[i - 1] = toNumber(_sp[1]);
_fn[i - 1] = toNumber(_sp[2]); _fn[i - 1] = toNumber(_sp[2]);
if(array_length(_sp) < 3) use_normal = false; use_normal = array_length(_sp) >= 4;
} }
tri += _len - 2; tri += _len - 2;
@ -76,6 +78,7 @@ function readObj_file() {
ds_list_add(ft, _ft); //get texture map ds_list_add(ft, _ft); //get texture map
ds_list_add(fn, _fn); //get normal ds_list_add(fn, _fn); //get normal
break; break;
case "usemtl" : case "usemtl" :
var mname = ""; var mname = "";
for( var i = 1; i < array_length(sep); i++ ) for( var i = 1; i < array_length(sep); i++ )
@ -97,12 +100,14 @@ function readObj_file() {
tri = 0; tri = 0;
break; break;
case "mtllib" : case "mtllib" :
mtlPath = ""; mtlPath = "";
for( var i = 1; i < array_length(sep); i++ ) for( var i = 1; i < array_length(sep); i++ )
mtlPath += (i == 1? "" : " ") + sep[i]; mtlPath += (i == 1? "" : " ") + sep[i];
mtlPath = string_trim(mtlPath); mtlPath = string_trim(mtlPath);
break; break;
case "o" : case "o" :
//print("Reading vertex group: " + sep[1]) //print("Reading vertex group: " + sep[1])
break; break;

View file

@ -165,47 +165,6 @@ function Panel_Animation() : PanelContent() constructor {
copy_clipboard = ds_list_create(); copy_clipboard = ds_list_create();
#region ++++ control_buttons ++++
control_buttons = [
[
function() { return __txt("Stop"); },
function() { return 4; },
function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; },
function() { PROJECT.animator.stop(); }
],
[
function() { return PROJECT.animator.is_playing? __txt("Pause") : __txt("Play from current (Shift + Space)"); },
function() { return !PROJECT.animator.is_playing; },
function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; },
function() { if(PROJECT.animator.is_playing) PROJECT.animator.pause(); else PROJECT.animator.resume(); }
],
[
function() { return __txtx("panel_animation_go_to_first_frame", "Go to first frame"); },
function() { return 3; },
function() { return COLORS._main_icon; },
function() { PROJECT.animator.firstFrame(); }
],
[
function() { return __txtx("panel_animation_go_to_last_frame", "Go to last frame"); },
function() { return 2; },
function() { return COLORS._main_icon; },
function() { PROJECT.animator.lastFrame(); }
],
[
function() { return __txtx("panel_animation_previous_frame", "Previous frame"); },
function() { return 5; },
function() { return COLORS._main_icon; },
function() { PROJECT.animator.setFrame(PROJECT.animator.real_frame - 1); }
],
[
function() { return __txtx("panel_animation_next_frame", "Next frame"); },
function() { return 6; },
function() { return COLORS._main_icon; },
function() { PROJECT.animator.setFrame(PROJECT.animator.real_frame + 1); }
],
];
#endregion
#region ++++ hotkeys ++++ #region ++++ hotkeys ++++
__collapse = false; __collapse = false;
@ -230,6 +189,56 @@ function Panel_Animation() : PanelContent() constructor {
addHotkey("Animation", "Paste", "V", MOD_KEY.ctrl, panel_animation_paste); addHotkey("Animation", "Paste", "V", MOD_KEY.ctrl, panel_animation_paste);
addHotkey("Animation", "Collapse Toggle", "C", MOD_KEY.none, collapseToggle); addHotkey("Animation", "Collapse Toggle", "C", MOD_KEY.none, collapseToggle);
addHotkey("Animation", "Toggle nodes", "H", MOD_KEY.none, panel_animation_show_nodes); addHotkey("Animation", "Toggle nodes", "H", MOD_KEY.none, panel_animation_show_nodes);
tooltip_toggle_nodes = new tooltipHotkey(__txtx("panel_animation_show_node", "Toggle node label"), "Animation", "Toggle nodes");
#endregion
#region ++++ control_buttons ++++
tooltip_resume = new tooltipHotkey(__txt("Resume"), "", "Resume/Pause");
tooltip_pause = new tooltipHotkey(__txt("Pause"), "", "Resume/Pause");
tooltip_fr_first = new tooltipHotkey(__txtx("panel_animation_go_to_first_frame", "Go to first frame"), "", "First frame");
tooltip_fr_last = new tooltipHotkey(__txtx("panel_animation_go_to_last_frame", "Go to last frame"), "", "Last 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 = [
[
function() { return __txt("Stop"); },
function() { return 4; },
function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; },
function() { PROJECT.animator.stop(); }
],
[
function() { return PROJECT.animator.is_playing? tooltip_pause : tooltip_resume; },
function() { return !PROJECT.animator.is_playing; },
function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; },
function() { if(PROJECT.animator.is_playing) PROJECT.animator.pause(); else PROJECT.animator.resume(); }
],
[
function() { return tooltip_fr_first; },
function() { return 3; },
function() { return COLORS._main_icon; },
function() { PROJECT.animator.firstFrame(); }
],
[
function() { return tooltip_fr_last; },
function() { return 2; },
function() { return COLORS._main_icon; },
function() { PROJECT.animator.lastFrame(); }
],
[
function() { return tooltip_fr_prev; },
function() { return 5; },
function() { return COLORS._main_icon; },
function() { PROJECT.animator.setFrame(PROJECT.animator.real_frame - 1); }
],
[
function() { return tooltip_fr_next; },
function() { return 6; },
function() { return COLORS._main_icon; },
function() { PROJECT.animator.setFrame(PROJECT.animator.real_frame + 1); }
],
];
#endregion #endregion
#region ++++ context menu ++++ #region ++++ context menu ++++
@ -2125,8 +2134,7 @@ function Panel_Animation() : PanelContent() constructor {
node_name_type = (node_name_type + 1) % 3; node_name_type = (node_name_type + 1) % 3;
by += ui(32); if(by > max_y) return; by += ui(32); if(by > max_y) return;
txt = __txtx("panel_animation_show_node", "Toggle node label"); if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(28), [mx, my], pFOCUS, pHOVER, tooltip_toggle_nodes, THEME.junc_visible, show_nodes) == 2)
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(28), [mx, my], pFOCUS, pHOVER, txt, THEME.junc_visible, show_nodes) == 2)
show_nodes = !show_nodes; show_nodes = !show_nodes;
by += ui(32); if(by > max_y) return; by += ui(32); if(by > max_y) return;

View file

@ -299,52 +299,6 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
function initSize() { toCenterNode(); } initSize(); function initSize() { toCenterNode(); } initSize();
#region ++++ toolbars ++++
toolbars = [
[
THEME.icon_preview_export,
function() { return 0; },
function() { return __txtx("panel_graph_export_image", "Export graph as image"); },
function() { dialogPanelCall(new Panel_Graph_Export_Image(self)); }
],
[
THEME.icon_center_canvas,
function() { return 0; },
function() { return __txtx("panel_graph_center_to_nodes", "Center to nodes"); },
function() { toCenterNode(); }
],
[
THEME.icon_minimap,
function() { return minimap_show; },
function() { return minimap_show? __txtx("panel_graph_minimap_enabled", "Minimap enabled") : __txtx("panel_graph_minimap_disabled", "Minimap disabled"); },
function() { minimap_show = !minimap_show; }
],
[
THEME.icon_curve_connection,
function() { return PREFERENCES.curve_connection_line; },
function() { return __txtx("panel_graph_connection_line", "Connection render settings"); },
function(param) {
dialogPanelCall(new Panel_Graph_Connection_Setting(), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
}
],
[
THEME.icon_grid_setting,
function() { return 0; },
function() { return __txtx("grid_title", "Grid settings"); },
function(param) {
dialogPanelCall(new Panel_Graph_Grid_Setting(), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
}
],
[
THEME.icon_visibility,
function() { return 0; },
function() { return __txtx("graph_visibility_title", "Visibility settings"); },
function(param) {
dialogPanelCall(new Panel_Graph_View_Setting(display_parameter), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
}
],
]; #endregion
#region ++++ hotkeys ++++ #region ++++ hotkeys ++++
addHotkey("Graph", "Add node", "A", MOD_KEY.none, panel_graph_add_node); 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", "Focus content", "F", MOD_KEY.none, panel_graph_focus_content);
@ -389,6 +343,55 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
addHotkey("Graph", "Zoom", "", MOD_KEY.alt | MOD_KEY.ctrl, panel_graph_zoom); addHotkey("Graph", "Zoom", "", MOD_KEY.alt | MOD_KEY.ctrl, panel_graph_zoom);
#endregion #endregion
#region ++++ toolbars ++++
tooltip_center = new tooltipHotkey(__txtx("panel_graph_center_to_nodes", "Center to nodes"), "Graph", "Focus content");
toolbars = [
[
THEME.icon_preview_export,
function() { return 0; },
function() { return __txtx("panel_graph_export_image", "Export graph as image"); },
function() { dialogPanelCall(new Panel_Graph_Export_Image(self)); }
],
[
THEME.icon_center_canvas,
function() { return 0; },
function() { return tooltip_center; },
function() { toCenterNode(); }
],
[
THEME.icon_minimap,
function() { return minimap_show; },
function() { return minimap_show? __txtx("panel_graph_minimap_enabled", "Minimap enabled") : __txtx("panel_graph_minimap_disabled", "Minimap disabled"); },
function() { minimap_show = !minimap_show; }
],
[
THEME.icon_curve_connection,
function() { return PREFERENCES.curve_connection_line; },
function() { return __txtx("panel_graph_connection_line", "Connection render settings"); },
function(param) {
dialogPanelCall(new Panel_Graph_Connection_Setting(), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
}
],
[
THEME.icon_grid_setting,
function() { return 0; },
function() { return __txtx("grid_title", "Grid settings"); },
function(param) {
dialogPanelCall(new Panel_Graph_Grid_Setting(), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
}
],
[
THEME.icon_visibility,
function() { return 0; },
function() { return __txtx("graph_visibility_title", "Visibility settings"); },
function(param) {
dialogPanelCall(new Panel_Graph_View_Setting(display_parameter), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
}
],
];
#endregion
#region ++++ node setters ++++ #region ++++ node setters ++++
function setCurrentPreview(_node = getFocusingNode()) { #region function setCurrentPreview(_node = getFocusingNode()) { #region
if(!_node) return; if(!_node) return;
@ -514,10 +517,11 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
pan.content.setInspecting(node_hover); pan.content.setInspecting(node_hover);
pan.content.locked = true; 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_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_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_render = menuItem(__txtx("panel_graph_toggle_render", "Toggle node render"), function() { setTriggerRender(); }, noone, ["Graph", "Toggle render"]);
menu_open_group = menuItem(__txtx("panel_graph_enter_group", "Open group"), function() { PANEL_GRAPH.addContext(node_hover); }, THEME.group); 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);
function openGroupTab(group) { function openGroupTab(group) {
var graph = new Panel_Graph(project); var graph = new Panel_Graph(project);
@ -1052,7 +1056,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
array_push(menu, menu_node_color, -1, menu_sent_to_preview, menu_send_to_window, menu_sent_to_inspector); array_push(menu, menu_node_color, -1, menu_sent_to_preview, menu_send_to_window, menu_sent_to_inspector);
if(!DEMO) if(!DEMO)
array_push(menu, menu_send_export); array_push(menu, menu_send_export);
array_push(menu, -1, menu_toggle_preview, menu_toggle_render); array_push(menu, -1, menu_toggle_preview, menu_toggle_render, menu_toggle_param);
if(is_instanceof(node_hover, Node_Collection)) if(is_instanceof(node_hover, Node_Collection))
array_push(menu, -1, menu_open_group, menu_open_group_tab, menu_group_ungroup); array_push(menu, -1, menu_open_group, menu_open_group_tab, menu_group_ungroup);

View file

@ -199,111 +199,6 @@ 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 ++++ toolbars & actions ++++
topbar_height = ui(32);
toolbar_height = ui(40);
toolbars = [
[
THEME.icon_reset_when_preview,
function() { return resetViewOnDoubleClick; },
function() { return resetViewOnDoubleClick? __txtx("panel_preview_center_canvas_on_preview", "Center canvas on preview") :
__txtx("panel_preview_keep_canvas_on_preview", "Keep canvas on preview"); },
function() { resetViewOnDoubleClick = !resetViewOnDoubleClick; }
],
[
THEME.icon_split_view,
function() { return splitView; },
function() {
switch(splitView) {
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 2 : return __txtx("panel_preview_vertical_split_view", "Vertical split view");
}
return __txtx("panel_preview_split_view", "Split view");
},
function() { splitView = (splitView + 1) % 3; }
],
[
THEME.icon_tile_view,
function() { var t = [3, 0, 1, 2]; return array_safe_get_fast(t, tileMode); },
function() {
switch(tileMode) {
case 0 : return __txtx("panel_preview_tile_off", "Tile off");
case 1 : return __txtx("panel_preview_tile_horizontal", "Tile horizontal");
case 2 : return __txtx("panel_preview_tile_vertical", "Tile vertical");
case 3 : return __txtx("panel_preview_tile_both", "Tile both");
}
return __txtx("panel_preview_tile_mode", "Tile mode");
},
function(data) {
menuCall("preview_tile_menu", data.x + ui(28), data.y + ui(28), [
menuItem(__txtx("panel_preview_tile_off", "Tile off"), function() { tileMode = 0; }),
menuItem(__txtx("panel_preview_tile_horizontal", "Tile horizontal"), function() { tileMode = 1; }),
menuItem(__txtx("panel_preview_tile_vertical", "Tile vertical"), function() { tileMode = 2; }),
menuItem(__txtx("panel_preview_tile_both", "Tile both"), function() { tileMode = 3; }),
]);
}
],
[
THEME.icon_grid_setting,
function() { return 0; },
function() { return __txtx("grid_title", "Grid setting") },
function(param) {
var dia = dialogPanelCall(new Panel_Preview_Grid_Setting(), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
}
],
[
THEME.onion_skin,
function() { return 0; },
function() { return __txt("Onion Skin") },
function(param) {
var dia = dialogPanelCall(new Panel_Preview_Onion_Setting(), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
}
],
];
toolbars_3d = [
[
THEME.d3d_preview_settings,
function() { return 0; },
function() { return __txt("3D Preview Settings") },
function(param) {
var dia = dialogPanelCall(new Panel_Preview_3D_Setting(self), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
}
],
[
THEME.d3d_snap_settings,
function() { return 0; },
function() { return __txt("3D Snap Settings") },
function(param) {
var dia = dialogPanelCall(new Panel_Preview_Snap_Setting(self), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
}
],
];
actions = [
[
THEME.lock,
__txtx("panel_preview_lock_preview", "Lock previewing node"),
function() { locked = !locked; },
function() { return !locked; },
],
[
THEME.icon_preview_export,
__txtx("panel_preview_export_canvas", "Export canvas"),
function() { saveCurrentFrame(); },
function() { return 0; },
],
[
THEME.icon_center_canvas,
__txtx("panel_preview_center_canvas", "Center canvas"),
function() { fullView(); },
function() { return 0; },
],
]
#endregion
#region ++++ hotkey ++++ #region ++++ hotkey ++++
addHotkey("Preview", "Focus content", "F", MOD_KEY.none, panel_preview_focus_content); 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 current frame", "S", MOD_KEY.shift, panel_preview_save_current_frame);
@ -315,6 +210,113 @@ function Panel_Preview() : PanelContent() constructor {
addHotkey("Preview", "Zoom", "", MOD_KEY.alt | MOD_KEY.ctrl, panel_preview_zoom); addHotkey("Preview", "Zoom", "", MOD_KEY.alt | MOD_KEY.ctrl, panel_preview_zoom);
#endregion #endregion
#region ++++ toolbars & actions ++++
topbar_height = ui(32);
toolbar_height = ui(40);
toolbars = [
[
THEME.icon_reset_when_preview,
function() { return resetViewOnDoubleClick; },
function() { return resetViewOnDoubleClick? __txtx("panel_preview_center_canvas_on_preview", "Center canvas on preview") :
__txtx("panel_preview_keep_canvas_on_preview", "Keep canvas on preview"); },
function() { resetViewOnDoubleClick = !resetViewOnDoubleClick; }
],
[
THEME.icon_split_view,
function() { return splitView; },
function() {
switch(splitView) {
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 2 : return __txtx("panel_preview_vertical_split_view", "Vertical split view");
}
return __txtx("panel_preview_split_view", "Split view");
},
function() { splitView = (splitView + 1) % 3; }
],
[
THEME.icon_tile_view,
function() { var t = [3, 0, 1, 2]; return array_safe_get_fast(t, tileMode); },
function() {
switch(tileMode) {
case 0 : return __txtx("panel_preview_tile_off", "Tile off");
case 1 : return __txtx("panel_preview_tile_horizontal", "Tile horizontal");
case 2 : return __txtx("panel_preview_tile_vertical", "Tile vertical");
case 3 : return __txtx("panel_preview_tile_both", "Tile both");
}
return __txtx("panel_preview_tile_mode", "Tile mode");
},
function(data) {
menuCall("preview_tile_menu", data.x + ui(28), data.y + ui(28), [
menuItem(__txtx("panel_preview_tile_off", "Tile off"), function() { tileMode = 0; }),
menuItem(__txtx("panel_preview_tile_horizontal", "Tile horizontal"), function() { tileMode = 1; }),
menuItem(__txtx("panel_preview_tile_vertical", "Tile vertical"), function() { tileMode = 2; }),
menuItem(__txtx("panel_preview_tile_both", "Tile both"), function() { tileMode = 3; }),
]);
}
],
[
THEME.icon_grid_setting,
function() { return 0; },
function() { return __txtx("grid_title", "Grid setting") },
function(param) {
var dia = dialogPanelCall(new Panel_Preview_Grid_Setting(), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
}
],
[
THEME.onion_skin,
function() { return 0; },
function() { return __txt("Onion Skin") },
function(param) {
var dia = dialogPanelCall(new Panel_Preview_Onion_Setting(), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
}
],
];
toolbars_3d = [
[
THEME.d3d_preview_settings,
function() { return 0; },
function() { return __txt("3D Preview Settings") },
function(param) {
var dia = dialogPanelCall(new Panel_Preview_3D_Setting(self), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
}
],
[
THEME.d3d_snap_settings,
function() { return 0; },
function() { return __txt("3D Snap Settings") },
function(param) {
var dia = dialogPanelCall(new Panel_Preview_Snap_Setting(self), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left });
}
],
];
tooltip_center = new tooltipHotkey(__txtx("panel_preview_center_canvas", "Center canvas"), "Preview", "Focus content");
actions = [
[
THEME.lock,
__txtx("panel_preview_lock_preview", "Lock previewing node"),
function() { locked = !locked; },
function() { return !locked; },
],
[
THEME.icon_preview_export,
__txtx("panel_preview_export_canvas", "Export canvas"),
function() { saveCurrentFrame(); },
function() { return 0; },
],
[
THEME.icon_center_canvas,
tooltip_center,
function() { fullView(); },
function() { return 0; },
],
];
#endregion
function setNodePreview(node) { #region function setNodePreview(node) { #region
if(locked) return; if(locked) return;

View file

@ -292,13 +292,4 @@
var grav = struct_try_get(PREFERENCES, "physics_gravity", [ 0, 10 ]); var grav = struct_try_get(PREFERENCES, "physics_gravity", [ 0, 10 ]);
physics_world_gravity(array_safe_get_fast(grav, 0, 0), array_safe_get_fast(grav, 1, 10)); physics_world_gravity(array_safe_get_fast(grav, 0, 0), array_safe_get_fast(grav, 1, 10));
} #endregion } #endregion
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 #endregion

View file

@ -1,8 +1,30 @@
function tooltipHotkey(text, context, name) constructor { function tooltipHotkey(text, context, name) constructor {
self.text = text; self.text = text;
self.hotkey = getHotkey(context, name); self.hotkey = find_hotkey(context, name);
keyStr = hotkey? key_get_name(hotkey.key, hotkey.modi) : "";
static drawTooltip = function() { static drawTooltip = function() {
draw_set_font(f_p0);
var _w1 = string_width(text);
draw_set_font(f_p1);
var _w2 = string_width(keyStr);
var tw = min(WIN_W - ui(32), _w1 + ui(16) + _w2);
var th = string_height_ext(text, -1, tw);
var mx = min(mouse_mx + ui(16), WIN_W - (tw + ui(16)));
var my = min(mouse_my + ui(16), WIN_H - (th + ui(16)));
draw_sprite_stretched(THEME.textbox, 3, mx, my, tw + ui(16), th + ui(16));
draw_sprite_stretched(THEME.textbox, 0, mx, my, tw + ui(16), th + ui(16));
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
draw_set_color(COLORS._main_text);
draw_text_line(mx + ui(8), my + ui(8), text, -1, tw);
draw_set_text(f_p1, fa_right, fa_center, COLORS._main_text_sub);
draw_text_line(mx + tw + ui(8), my + th / 2 + ui(10), keyStr, -1, tw);
} }
} }