Config setting reset

- Add reset button for most config dialog.
This commit is contained in:
Tanasart 2023-10-31 21:24:54 +07:00
parent eb977680b9
commit cc527b55a6
13 changed files with 323 additions and 240 deletions

View file

@ -1,7 +1,43 @@
function __Panel_Linear_Setting_Item(name, editWidget, data, onEdit = noone, getDefault = noone) constructor { #region
self.name = name;
self.editWidget = editWidget;
self.data = data;
self.onEdit = onEdit;
self.getDefault = getDefault;
} #endregion
function __Panel_Linear_Setting_Item_Preference(name, key, editWidget, _data = noone) : __Panel_Linear_Setting_Item(name, editWidget, _data) constructor { #region
self.key = key;
data = function() {
gml_pragma("forceinline");
return PREFERENCES[$ key];
}
onEdit = function(val) {
gml_pragma("forceinline");
PREFERENCES[$ key] = val;
PREF_SAVE();
}
getDefault = function() {
gml_pragma("forceinline");
return PREFERENCES_DEF[$ key];
}
} #endregion
function __Panel_Linear_Setting_Label(name, sprite, s_index = 0, s_color = c_white) constructor { #region
self.name = name;
self.sprite = sprite;
self.s_index = s_index;
self.s_color = s_color;
} #endregion
function Panel_Linear_Setting() : PanelContent() constructor { function Panel_Linear_Setting() : PanelContent() constructor {
title = __txtx("preview_3d_settings", "3D Preview Settings"); title = __txtx("preview_3d_settings", "3D Preview Settings");
w = ui(380); w = ui(400);
bg_y = -1; bg_y = -1;
bg_y_to = -1; bg_y_to = -1;
@ -22,13 +58,11 @@ function Panel_Linear_Setting() : PanelContent() constructor {
for( var i = 0, n = array_length(properties); i < n; i++ ) { for( var i = 0, n = array_length(properties); i < n; i++ ) {
var _prop = properties[i]; var _prop = properties[i];
var _widg = _prop[0]; if(is_instanceof(_prop, __Panel_Linear_Setting_Label)) {
var _text = _prop.name;
if(is_string(_widg)) { var _spr = _prop.sprite;
var _text = _prop[0]; var _ind = _prop.s_index;
var _spr = _prop[1]; var _colr = _prop.s_color;
var _ind = _prop[2];
var _colr = _prop[3];
draw_sprite_stretched_ext(THEME.group_label, 0, ui(4), yy - th / 2 + ui(2), w - ui(8), th - ui(4), _colr, 1); draw_sprite_stretched_ext(THEME.group_label, 0, ui(4), yy - th / 2 + ui(2), w - ui(8), th - ui(4), _colr, 1);
draw_sprite_ui(_spr, _ind, ui(4) + th / 2, yy); draw_sprite_ui(_spr, _ind, ui(4) + th / 2, yy);
@ -40,8 +74,11 @@ function Panel_Linear_Setting() : PanelContent() constructor {
continue; continue;
} }
var _text = _prop[1]; if(is_instanceof(_prop, __Panel_Linear_Setting_Item)) {
var _data = _prop[2](); var _text = _prop.name;
var _data = _prop.data;
var _widg = _prop.editWidget;
if(is_callable(_data)) _data = _data();
_widg.setFocusHover(pFOCUS, pHOVER); _widg.setFocusHover(pFOCUS, pHOVER);
_widg.register(); _widg.register();
@ -54,7 +91,13 @@ function Panel_Linear_Setting() : PanelContent() constructor {
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text); draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
draw_text_add(ui(16), yy, _text); draw_text_add(ui(16), yy, _text);
var params = new widgetParam(w - ui(8) - ww, yy - wh / 2, ww, wh, _data, {}, [ mx, my ], x, y); var _x1 = w - ui(8);
var _wdw = ww;
if(_prop.getDefault != noone)
_wdw -= ui(32 + 8);
var params = new widgetParam(_x1 - ww, yy - wh / 2, _wdw, wh, _data, {}, [ mx, my ], x, y);
if(is_instanceof(_widg, checkBox)) { if(is_instanceof(_widg, checkBox)) {
params.halign = fa_center; params.halign = fa_center;
params.valign = fa_center; params.valign = fa_center;
@ -62,7 +105,23 @@ function Panel_Linear_Setting() : PanelContent() constructor {
_widg.drawParam(params); _widg.drawParam(params);
if(_prop.getDefault != noone) {
var _defVal = is_method(_prop.getDefault)? _prop.getDefault() : _prop.getDefault;
var _bs = ui(32);
var _bx = _x1 - _bs;
var _by = yy - _bs / 2;
if(isEqual(_data, _defVal))
draw_sprite_ext(THEME.refresh_s, 0, _bx + _bs / 2, _by + _bs / 2, 1, 1, 0, COLORS._main_icon, 0.6);
else {
if(buttonInstant(THEME.button_hide, _bx, _by, _bs, _bs, [ mx, my ], pFOCUS, pHOVER, __txt("Reset"), THEME.refresh_s) == 2)
_prop.onEdit(_defVal);
}
}
yy += th; yy += th;
continue;
}
} }
bg_a = lerp_float(bg_a, _hov, 2); bg_a = lerp_float(bg_a, _hov, 2);

View file

@ -36,7 +36,8 @@
[ "__textBox_draw", function(wd, _x, _y, _w, _h, _text, _m) { [ "__textBox_draw", function(wd, _x, _y, _w, _h, _text, _m) {
if(!ds_map_exists(global.ADDON_WIDGET, wd)) return; if(!ds_map_exists(global.ADDON_WIDGET, wd)) return;
global.ADDON_WIDGET[? wd].draw(_x, _y, _w, _h, _text, _m); var _param = new widgetParam(_x, _y, _w, _h, _text, {}, _m)
global.ADDON_WIDGET[? wd].drawParam(_param);
} ], } ],
@" @"
TextBox = {} TextBox = {}
@ -72,7 +73,8 @@ end",
[ "__vectorBox_draw", function(wd, _x, _y, _w, _h, _vector, _m) { [ "__vectorBox_draw", function(wd, _x, _y, _w, _h, _vector, _m) {
if(!ds_map_exists(global.ADDON_WIDGET, wd)) return; if(!ds_map_exists(global.ADDON_WIDGET, wd)) return;
global.ADDON_WIDGET[? wd].draw(_x, _y, _w, _h, _vector, _m); var _param = new widgetParam(_x, _y, _w, _h, _vector, {}, _m)
global.ADDON_WIDGET[? wd].drawParam(_param);
} ], } ],
@" @"
@ -109,7 +111,8 @@ end",
[ "__checkBox_draw", function(wd, _x, _y, _value, _m) { [ "__checkBox_draw", function(wd, _x, _y, _value, _m) {
if(!ds_map_exists(global.ADDON_WIDGET, wd)) return; if(!ds_map_exists(global.ADDON_WIDGET, wd)) return;
global.ADDON_WIDGET[? wd].draw(_x, _y, _value); var _param = new widgetParam(_x, _y, ui(24), ui(24), _value, {}, _m)
global.ADDON_WIDGET[? wd].drawParam(_param);
} ], } ],
@" @"
@ -147,7 +150,8 @@ end",
if(!ds_map_exists(global.ADDON_WIDGET, wd)) return; if(!ds_map_exists(global.ADDON_WIDGET, wd)) return;
var _button = global.ADDON_WIDGET[? wd]; var _button = global.ADDON_WIDGET[? wd];
_button.draw(_x, _y, _w, _h); var _param = new widgetParam(_x, _y, _w, _h, 0, {}, _m)
_button.drawParam(_param);
} ], } ],
@" @"
@ -170,10 +174,8 @@ end",
for( var i = 0, n = array_length(global.__lua_widget_functions); i < n; i++ ) { for( var i = 0, n = array_length(global.__lua_widget_functions); i < n; i++ ) {
var _func = global.__lua_widget_functions[i]; var _func = global.__lua_widget_functions[i];
if(is_string(_func)) if(is_string(_func)) lua_add_code(lua, _func);
lua_add_code(lua, _func); else if(is_array(_func)) lua_add_function(lua, _func[0], _func[1]);
else if(is_array(_func))
lua_add_function(lua, _func[0], _func[1]);
} }
} }
#endregion #endregion

View file

@ -67,7 +67,7 @@ function buttonGroup(_data, _onClick) : widget() constructor {
if(display_button) { if(display_button) {
var bx = _x; var bx = _x;
var draw_sel = []; var draw_sel = noone;
for(var i = 0; i < amo; i++) { for(var i = 0; i < amo; i++) {
buttons[i].setFocusHover(active, hover); buttons[i].setFocusHover(active, hover);
@ -92,6 +92,7 @@ function buttonGroup(_data, _onClick) : widget() constructor {
bx += ww; bx += ww;
} }
if(draw_sel != noone)
draw_sprite_stretched_ext(draw_sel[0], 3, draw_sel[1], _y, ww, _h, COLORS._main_accent, 1); draw_sprite_stretched_ext(draw_sel[0], 3, draw_sel[1], _y, ww, _h, COLORS._main_accent, 1);
if(point_in_rectangle(_m[0], _m[1], _x, _y, _x + w, _y + _h)) { if(point_in_rectangle(_m[0], _m[1], _x, _y, _x + w, _y + _h)) {

View file

@ -6,14 +6,11 @@ function Panel_Animation_Scaler() : Panel_Linear_Setting() constructor {
#region data #region data
properties = [ properties = [
[ new __Panel_Linear_Setting_Item(
new textBox(TEXTBOX_INPUT.number, function(to) {
to = toNumber(to);
scale_to = to;
}),
__txtx("anim_scale_target_frame_length", "Target frame length"), __txtx("anim_scale_target_frame_length", "Target frame length"),
new textBox(TEXTBOX_INPUT.number, function(to) { scale_to = toNumber(to); }),
function() { return scale_to; }, function() { return scale_to; },
] )
]; ];
setHeight(); setHeight();

View file

@ -5,27 +5,21 @@ function Panel_Animation_Setting() : Panel_Linear_Setting() constructor {
#region data #region data
properties = [ properties = [
[ new __Panel_Linear_Setting_Item(
new textBox(TEXTBOX_INPUT.number, function(str) {
TOTAL_FRAMES = real(str);
}),
__txtx("anim_length", "Animation length"), __txtx("anim_length", "Animation length"),
new textBox(TEXTBOX_INPUT.number, function(str) { TOTAL_FRAMES = real(str); }),
function() { return TOTAL_FRAMES; } function() { return TOTAL_FRAMES; }
], ),
[ new __Panel_Linear_Setting_Item(
new textBox(TEXTBOX_INPUT.number, function(str) {
PROJECT.animator.framerate = real(str);
}),
__txtx("anim_frame_rate", "Preview frame rate"), __txtx("anim_frame_rate", "Preview frame rate"),
new textBox(TEXTBOX_INPUT.number, function(str) { PROJECT.animator.framerate = real(str); }),
function() { return PROJECT.animator.framerate; } function() { return PROJECT.animator.framerate; }
], ),
[ new __Panel_Linear_Setting_Item(
new buttonGroup([__txt("Loop"), __txt("Stop")], function(b) {
PROJECT.animator.playback = b;
}),
__txtx("anim_on_end", "On end"), __txtx("anim_on_end", "On end"),
new buttonGroup([__txt("Loop"), __txt("Stop")], function(b) { PROJECT.animator.playback = b; }),
function() { return PROJECT.animator.playback; } function() { return PROJECT.animator.playback; }
] ),
]; ];
setHeight(); setHeight();

View file

@ -5,54 +5,42 @@ function Panel_Graph_Connection_Setting() : Panel_Linear_Setting() constructor {
#region data #region data
properties = [ properties = [
[ new __Panel_Linear_Setting_Item_Preference(
__txt("Type"),
"curve_connection_line",
new buttonGroup([ THEME.icon_curve_connection, THEME.icon_curve_connection, THEME.icon_curve_connection, THEME.icon_curve_connection ], new buttonGroup([ THEME.icon_curve_connection, THEME.icon_curve_connection, THEME.icon_curve_connection, THEME.icon_curve_connection ],
function(val) { PREFERENCES.curve_connection_line = val; }), function(val) { PREFERENCES.curve_connection_line = val; }),
__txt("Type"), ),
function() { return PREFERENCES.curve_connection_line; } new __Panel_Linear_Setting_Item_Preference(
],
[
new textBox(TEXTBOX_INPUT.number, function(str) {
PREFERENCES.connection_line_width = max(0.5, real(str));
}),
__txtx("dialog_connection_thickness", "Line thickness"), __txtx("dialog_connection_thickness", "Line thickness"),
function() { return PREFERENCES.connection_line_width; } "connection_line_width",
], new textBox(TEXTBOX_INPUT.number, function(str) { PREFERENCES.connection_line_width = max(0.5, real(str)); }),
[ ),
new textBox(TEXTBOX_INPUT.number, function(str) { new __Panel_Linear_Setting_Item_Preference(
PREFERENCES.connection_line_corner = max(0, real(str));
}).setSlidable(),
__txtx("dialog_connection_radius", "Corner radius"), __txtx("dialog_connection_radius", "Corner radius"),
function() { return PREFERENCES.connection_line_corner; } "connection_line_corner",
], new textBox(TEXTBOX_INPUT.number, function(str) { PREFERENCES.connection_line_corner = max(0, real(str)); }).setSlidable(),
[ ),
new textBox(TEXTBOX_INPUT.number, function(str) { new __Panel_Linear_Setting_Item_Preference(
PREFERENCES.connection_line_aa = clamp(real(str), 1, 4);
}),
__txtx("pref_connection_quality", "Render quality"), __txtx("pref_connection_quality", "Render quality"),
function() { return PREFERENCES.connection_line_aa; } "connection_line_aa",
], new textBox(TEXTBOX_INPUT.number, function(str) { PREFERENCES.connection_line_aa = clamp(real(str), 1, 4); }),
[ ),
new buttonGroup([ "None", "ALT", "Always" ], function(val) { new __Panel_Linear_Setting_Item_Preference(
PREFERENCES.connection_line_highlight = val;
}),
__txtx("pref_connection_highlight", "Highlight connection"), __txtx("pref_connection_highlight", "Highlight connection"),
function() { return PREFERENCES.connection_line_highlight; } "connection_line_highlight",
], new buttonGroup([ "None", "ALT", "Always" ], function(val) { PREFERENCES.connection_line_highlight = val; }),
[ ),
new slider(0, 1, 0.05, function(val) { new __Panel_Linear_Setting_Item_Preference(
PREFERENCES.connection_line_highlight_fade = val;
}),
__txtx("pref_connection_highlight_fade", "Fade connection"), __txtx("pref_connection_highlight_fade", "Fade connection"),
function() { return PREFERENCES.connection_line_highlight_fade }, "connection_line_highlight_fade",
], new slider(0, 1, 0.05, function(val) { PREFERENCES.connection_line_highlight_fade = val; }),
[ ),
new checkBox(function() { new __Panel_Linear_Setting_Item_Preference(
PREFERENCES.connection_line_highlight_all = !PREFERENCES.connection_line_highlight_all;
}),
__txtx("pref_connection_highlight_all", "Highlight all"), __txtx("pref_connection_highlight_all", "Highlight all"),
function() { return PREFERENCES.connection_line_highlight_all }, "connection_line_highlight_all",
], new checkBox(function() { PREFERENCES.connection_line_highlight_all = !PREFERENCES.connection_line_highlight_all; }),
),
]; ];
setHeight(); setHeight();

View file

@ -5,54 +5,66 @@ function Panel_Graph_Grid_Setting() : Panel_Linear_Setting() constructor {
#region data #region data
properties = [ properties = [
[ new __Panel_Linear_Setting_Item(
__txtx("grid_snap", "Snap to grid"),
new checkBox(function() { new checkBox(function() {
if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return; if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return;
PANEL_GRAPH.project.graphGrid.snap = !PANEL_GRAPH.project.graphGrid.snap; PANEL_GRAPH.project.graphGrid.snap = !PANEL_GRAPH.project.graphGrid.snap;
}), }),
__txtx("grid_snap", "Snap to grid"), function() { return PANEL_GRAPH.project.graphGrid.snap; },
function() { return PANEL_GRAPH.project.graphGrid.snap; } function(val) { PANEL_GRAPH.project.graphGrid.snap = val; },
], true,
[ ),
new __Panel_Linear_Setting_Item(
__txtx("grid_size", "Grid size"),
new textBox(TEXTBOX_INPUT.number, function(str) { new textBox(TEXTBOX_INPUT.number, function(str) {
if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return; if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return;
PANEL_GRAPH.project.graphGrid.size = max(1, real(str)); PANEL_GRAPH.project.graphGrid.size = max(1, real(str));
}), }),
__txtx("grid_size", "Grid size"), function() { return PANEL_GRAPH.project.graphGrid.size; },
function() { return PANEL_GRAPH.project.graphGrid.size; } function(val) { PANEL_GRAPH.project.graphGrid.size = val; },
], 16,
[ ),
new __Panel_Linear_Setting_Item(
__txtx("project_graphGrid_opacity", "Grid opacity"),
new slider(0, 1, .05, function(str) { new slider(0, 1, .05, function(str) {
if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return; if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return;
PANEL_GRAPH.project.graphGrid.opacity = clamp(real(str), 0, 1); PANEL_GRAPH.project.graphGrid.opacity = clamp(real(str), 0, 1);
}), }),
__txtx("project_graphGrid_opacity", "Grid opacity"), function() { return PANEL_GRAPH.project.graphGrid.opacity; },
function() { return PANEL_GRAPH.project.graphGrid.opacity; } function(val) { PANEL_GRAPH.project.graphGrid.opacity = val; },
], 0.05,
[ ),
new __Panel_Linear_Setting_Item(
__txtx("project_graphGrid_color", "Grid color"),
new buttonColor(function(color) { new buttonColor(function(color) {
if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return; if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return;
PANEL_GRAPH.project.graphGrid.color = color; PANEL_GRAPH.project.graphGrid.color = color;
}, self), }, self),
__txtx("project_graphGrid_color", "Grid color"), function() { return PANEL_GRAPH.project.graphGrid.color; },
function() { return PANEL_GRAPH.project.graphGrid.color; } function(val) { PANEL_GRAPH.project.graphGrid.color = val; },
], c_white,
[ ),
new __Panel_Linear_Setting_Item(
__txtx("grid_show_origin", "Show origin"),
new checkBox(function() { new checkBox(function() {
if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return; if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return;
PANEL_GRAPH.project.graphGrid.show_origin = !PANEL_GRAPH.project.graphGrid.show_origin; PANEL_GRAPH.project.graphGrid.show_origin = !PANEL_GRAPH.project.graphGrid.show_origin;
}), }),
__txtx("grid_show_origin", "Show origin"), function() { return PANEL_GRAPH.project.graphGrid.show_origin; },
function() { return PANEL_GRAPH.project.graphGrid.show_origin; } function(val) { PANEL_GRAPH.project.graphGrid.show_origin = val; },
], false,
[ ),
new __Panel_Linear_Setting_Item(
__txtx("grid_highlight_every", "Highlight period"),
new textBox(TEXTBOX_INPUT.number, function(str) { new textBox(TEXTBOX_INPUT.number, function(str) {
if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return; if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return;
PANEL_GRAPH.project.graphGrid.highlight = max(1, round(real(str))); PANEL_GRAPH.project.graphGrid.highlight = max(1, round(real(str)));
}), }),
__txtx("grid_highlight_every", "Highlight period"), function() { return PANEL_GRAPH.project.graphGrid.highlight; },
function() { return PANEL_GRAPH.project.graphGrid.highlight; } function(val) { PANEL_GRAPH.project.graphGrid.highlight = val; },
], 12,
),
]; ];

View file

@ -6,31 +6,41 @@ function Panel_Graph_View_Setting(display) : Panel_Linear_Setting() constructor
#region data #region data
properties = [ properties = [
[ new __Panel_Linear_Setting_Item(
new checkBox(function() { display_parameter.show_grid = !display_parameter.show_grid; }),
__txt("Grid"), __txt("Grid"),
new checkBox(function() { display_parameter.show_grid = !display_parameter.show_grid; }),
function() { return display_parameter.show_grid }, function() { return display_parameter.show_grid },
], function(val) { display_parameter.show_grid = val; },
[ true,
new checkBox(function() { display_parameter.show_dimension = !display_parameter.show_dimension; }), ),
new __Panel_Linear_Setting_Item(
__txtx("graph_visibility_dim", "Dimension"), __txtx("graph_visibility_dim", "Dimension"),
new checkBox(function() { display_parameter.show_dimension = !display_parameter.show_dimension; }),
function() { return display_parameter.show_dimension }, function() { return display_parameter.show_dimension },
], function(val) { display_parameter.show_dimension = val; },
[ true,
new checkBox(function() { display_parameter.show_compute = !display_parameter.show_compute; }), ),
new __Panel_Linear_Setting_Item(
__txtx("graph_visibility_compute", "Compute time"), __txtx("graph_visibility_compute", "Compute time"),
new checkBox(function() { display_parameter.show_compute = !display_parameter.show_compute; }),
function() { return display_parameter.show_compute }, function() { return display_parameter.show_compute },
], function(val) { display_parameter.show_compute = val; },
[ true,
new checkBox(function() { display_parameter.avoid_label = !display_parameter.avoid_label; }), ),
new __Panel_Linear_Setting_Item(
__txtx("graph_visibility_avoid_label", "Avoid Label"), __txtx("graph_visibility_avoid_label", "Avoid Label"),
new checkBox(function() { display_parameter.avoid_label = !display_parameter.avoid_label; }),
function() { return display_parameter.avoid_label }, function() { return display_parameter.avoid_label },
], function(val) { display_parameter.avoid_label = val; },
[ true,
new slider(50, 100, 1, function(val) { display_parameter.preview_scale = val; }), ),
new __Panel_Linear_Setting_Item(
__txtx("graph_visibility_preview_scale", "Preview Scale"), __txtx("graph_visibility_preview_scale", "Preview Scale"),
new slider(50, 100, 1, function(val) { display_parameter.preview_scale = val; }),
function() { return display_parameter.preview_scale }, function() { return display_parameter.preview_scale },
], function(val) { display_parameter.preview_scale = val; },
100,
),
]; ];
setHeight(); setHeight();

View file

@ -6,55 +6,65 @@ function Panel_Preview_3D_Setting(panel) : Panel_Linear_Setting() constructor {
#region data #region data
properties_default = [ properties_default = [
[ new __Panel_Linear_Setting_Item(
new checkBox(function() { preview_panel.d3_scene_light_enabled = !preview_panel.d3_scene_light_enabled; }),
__txt("Preview Light"), __txt("Preview Light"),
new checkBox(function() { preview_panel.d3_scene_light_enabled = !preview_panel.d3_scene_light_enabled; }),
function() { return preview_panel.d3_scene_light_enabled }, function() { return preview_panel.d3_scene_light_enabled },
], function(val) { preview_panel.d3_scene_light_enabled = val; },
[ true,
new buttonColor(function(col) { ),
preview_panel.d3_scene.lightAmbient = col; }), new __Panel_Linear_Setting_Item(
__txt("Ambient Color"), __txt("Ambient Color"),
new buttonColor(function(col) { preview_panel.d3_scene.lightAmbient = col; }),
function() { return preview_panel.d3_scene.lightAmbient }, function() { return preview_panel.d3_scene.lightAmbient },
], function(val) { preview_panel.d3_scene.lightAmbient = val; },
[ $404040,
),
new __Panel_Linear_Setting_Item(
__txt("Light Intensity"),
new slider(0, 1, 0.01, function(val) { new slider(0, 1, 0.01, function(val) {
preview_panel.d3_scene_light0.intensity = val; preview_panel.d3_scene_light0.intensity = val;
preview_panel.d3_scene_light1.intensity = val; preview_panel.d3_scene_light1.intensity = val;
}), }),
__txt("Light Intensity"),
function() { return preview_panel.d3_scene_light0.intensity }, function() { return preview_panel.d3_scene_light0.intensity },
], function(val) { preview_panel.d3_scene_light0.intensity = val; },
[ 1,
new checkBox(function() { ),
preview_panel.d3_scene_light0.shadow_active = !preview_panel.d3_scene_light0.shadow_active; }), new __Panel_Linear_Setting_Item(
__txt("Shadow"), __txt("Shadow"),
new checkBox(function() { preview_panel.d3_scene_light0.shadow_active = !preview_panel.d3_scene_light0.shadow_active; }),
function() { return preview_panel.d3_scene_light0.shadow_active }, function() { return preview_panel.d3_scene_light0.shadow_active },
], function(val) { preview_panel.d3_scene_light0.shadow_active = val; },
[ false,
),
new __Panel_Linear_Setting_Item(
__txt("View Plane"),
new vectorBox(2, function(index, value) { new vectorBox(2, function(index, value) {
if(index == 0) preview_panel.d3_view_camera.view_near = value; if(index == 0) preview_panel.d3_view_camera.view_near = value;
else if(index == 1) preview_panel.d3_view_camera.view_far = value; else if(index == 1) preview_panel.d3_view_camera.view_far = value;
}), }),
__txt("View Plane"),
function() { return [ preview_panel.d3_view_camera.view_near, preview_panel.d3_view_camera.view_far ] }, function() { return [ preview_panel.d3_view_camera.view_near, preview_panel.d3_view_camera.view_far ] },
], function(val) { preview_panel.d3_view_camera.view_near = val[0]; preview_panel.d3_view_camera.view_far = val[1] },
[ [ 0.01, 50 ],
new checkBox(function() { ),
preview_panel.d3_scene.gammaCorrection = !preview_panel.d3_scene.gammaCorrection; }), new __Panel_Linear_Setting_Item(
__txt("Gamma Correct"), __txt("Gamma Correct"),
new checkBox(function() { preview_panel.d3_scene.gammaCorrection = !preview_panel.d3_scene.gammaCorrection; }),
function() { return preview_panel.d3_scene.gammaCorrection }, function() { return preview_panel.d3_scene.gammaCorrection },
], function(val) { preview_panel.d3_scene.gammaCorrection = val; },
[ true,
new checkBox(function() { ),
preview_panel.d3_scene.show_normal = !preview_panel.d3_scene.show_normal; }), new __Panel_Linear_Setting_Item(
__txt("Normal"), __txt("Normal"),
new checkBox(function() { preview_panel.d3_scene.show_normal = !preview_panel.d3_scene.show_normal; }),
function() { return preview_panel.d3_scene.show_normal }, function() { return preview_panel.d3_scene.show_normal },
], function(val) { preview_panel.d3_scene.show_normal = val; },
false,
),
] ]
var scene_camera = [ var scene_camera = [
[ "Currently using camera node settings", THEME.noti_icon_warning, 1, COLORS._main_accent ], new __Panel_Linear_Setting_Label( "Currently using camera node settings", THEME.noti_icon_warning, 1, COLORS._main_accent ),
]; ];
properties_camera = array_append(scene_camera, properties_default); properties_camera = array_append(scene_camera, properties_default);

View file

@ -5,44 +5,46 @@ function Panel_Preview_Grid_Setting() : Panel_Linear_Setting() constructor {
#region data #region data
properties = [ properties = [
[ new __Panel_Linear_Setting_Item(
new checkBox(function() {
PROJECT.previewGrid.show = !PROJECT.previewGrid.show;
}),
__txt("Enabled"), __txt("Enabled"),
function() { return PROJECT.previewGrid.show; } new checkBox(function() { PROJECT.previewGrid.show = !PROJECT.previewGrid.show; }),
], function() { return PROJECT.previewGrid.show; },
[ function(val) { PROJECT.previewGrid.show = val; },
new checkBox(function() { false,
PROJECT.previewGrid.snap = !PROJECT.previewGrid.snap; ),
}), new __Panel_Linear_Setting_Item(
__txtx("grid_snap", "Snap to grid"), __txtx("grid_snap", "Snap to grid"),
function() { return PROJECT.previewGrid.snap; } new checkBox(function() { PROJECT.previewGrid.snap = !PROJECT.previewGrid.snap; }),
], function() { return PROJECT.previewGrid.snap; },
[ function(val) { PROJECT.previewGrid.snap = val; },
false,
),
new __Panel_Linear_Setting_Item(
__txt("Grid size"),
new vectorBox(2, function(index, value) { new vectorBox(2, function(index, value) {
var _v = PROJECT.previewGrid.size[index]; var _v = PROJECT.previewGrid.size[index];
PROJECT.previewGrid.size[index] = max(1, value); PROJECT.previewGrid.size[index] = max(1, value);
return _v != max(1, value); return _v != max(1, value);
}).setLinkInactiveColor(COLORS._main_icon_light), }).setLinkInactiveColor(COLORS._main_icon_light),
__txt("Grid size"), function() { return PROJECT.previewGrid.size; },
function() { return PROJECT.previewGrid.size; } function(val) { PROJECT.previewGrid.size = val; },
], [ 16, 16 ],
[ ),
new slider(0, 1, .05, function(str) { new __Panel_Linear_Setting_Item(
PROJECT.previewGrid.opacity = clamp(real(str), 0, 1);
}),
__txt("Grid opacity"), __txt("Grid opacity"),
function() { return PROJECT.previewGrid.opacity; } new slider(0, 1, .05, function(str) { PROJECT.previewGrid.opacity = clamp(real(str), 0, 1); }),
], function() { return PROJECT.previewGrid.opacity; },
[ function(val) { PROJECT.previewGrid.opacity = val; },
new buttonColor(function(color) { 0.5,
PROJECT.previewGrid.color = color; ),
}, self), new __Panel_Linear_Setting_Item(
__txt("Grid color"), __txt("Grid color"),
function() { return PROJECT.previewGrid.color; } new buttonColor(function(color) { PROJECT.previewGrid.color = color; }, self),
] function() { return PROJECT.previewGrid.color; },
function(val) { PROJECT.previewGrid.color = val; },
COLORS.panel_preview_grid,
),
]; ];
setHeight(); setHeight();

View file

@ -5,48 +5,48 @@ function Panel_Preview_Onion_Setting() : Panel_Linear_Setting() constructor {
#region data #region data
properties = [ properties = [
[ new __Panel_Linear_Setting_Item(
new checkBox(function() {
PROJECT.onion_skin.enabled = !PROJECT.onion_skin.enabled;
}),
__txt("Enabled"), __txt("Enabled"),
function() { return PROJECT.onion_skin.enabled; } new checkBox(function() { PROJECT.onion_skin.enabled = !PROJECT.onion_skin.enabled; }),
], function() { return PROJECT.onion_skin.enabled; },
[ function(val) { PROJECT.onion_skin.enabled = val; },
new checkBox(function() { false
PROJECT.onion_skin.on_top = !PROJECT.onion_skin.on_top; ),
}), new __Panel_Linear_Setting_Item(
__txtx("onion_skin_top", "Draw on top"), __txtx("onion_skin_top", "Draw on top"),
function() { return PROJECT.onion_skin.on_top; } new checkBox(function() { PROJECT.onion_skin.on_top = !PROJECT.onion_skin.on_top; }),
], function() { return PROJECT.onion_skin.on_top; },
[ function(val) { PROJECT.onion_skin.on_top = val; },
new textBox(TEXTBOX_INPUT.number, function(str) { true
PROJECT.onion_skin.step = max(1, round(real(str))); ),
}), new __Panel_Linear_Setting_Item(
__txtx("onion_skin_frame_step", "Frame step"), __txtx("onion_skin_frame_step", "Frame step"),
function() { return PROJECT.onion_skin.step; } new textBox(TEXTBOX_INPUT.number, function(str) { PROJECT.onion_skin.step = max(1, round(real(str))); }),
], function() { return PROJECT.onion_skin.step; },
[ function(val) { PROJECT.onion_skin.step = val; },
new buttonColor(function(color) { 1
PROJECT.onion_skin.color[0] = color; ),
}, self), new __Panel_Linear_Setting_Item(
__txtx("onion_skin_pre_color", "Pre Color"), __txtx("onion_skin_pre_color", "Pre Color"),
function() { return PROJECT.onion_skin.color[0]; } new buttonColor(function(color) { PROJECT.onion_skin.color[0] = color; }, self),
], function() { return PROJECT.onion_skin.color[0]; },
[ function(val) { PROJECT.onion_skin.color[0] = val; },
new buttonColor(function(color) { c_red
PROJECT.onion_skin.color[1] = color; ),
}, self), new __Panel_Linear_Setting_Item(
__txtx("onion_skin_post_color", "Post Color"), __txtx("onion_skin_post_color", "Post Color"),
function() { return PROJECT.onion_skin.color[1]; } new buttonColor(function(color) { PROJECT.onion_skin.color[1] = color; }, self),
], function() { return PROJECT.onion_skin.color[1]; },
[ function(val) { PROJECT.onion_skin.color[1] = val; },
new slider(0, 1, .05, function(str) { c_blue
PROJECT.onion_skin.alpha = clamp(real(str), 0, 1); ),
}), new __Panel_Linear_Setting_Item(
__txt("Opacity"), __txt("Opacity"),
function() { return PROJECT.onion_skin.alpha; } new slider(0, 1, .05, function(str) { PROJECT.onion_skin.alpha = clamp(real(str), 0, 1); }),
] function() { return PROJECT.onion_skin.alpha; },
function(val) { PROJECT.onion_skin.alpha = val; },
0.5
),
]; ];
setHeight(); setHeight();

View file

@ -6,21 +6,27 @@ function Panel_Preview_Snap_Setting(panel) : Panel_Linear_Setting() constructor
#region data #region data
properties = [ properties = [
[ new __Panel_Linear_Setting_Item(
new checkBox(function() { preview_panel.d3_tool_snap = !preview_panel.d3_tool_snap; }),
__txt("Snap"), __txt("Snap"),
new checkBox(function() { preview_panel.d3_tool_snap = !preview_panel.d3_tool_snap; }),
function() { return preview_panel.d3_tool_snap }, function() { return preview_panel.d3_tool_snap },
], function(val) { preview_panel.d3_tool_snap = val; },
[ false,
new textBox(TEXTBOX_INPUT.number, function(val) { preview_panel.d3_tool_snap_position = val; }), ),
new __Panel_Linear_Setting_Item(
__txt("Linear"), __txt("Linear"),
new textBox(TEXTBOX_INPUT.number, function(val) { preview_panel.d3_tool_snap_position = val; }),
function() { return preview_panel.d3_tool_snap_position }, function() { return preview_panel.d3_tool_snap_position },
], function(val) { preview_panel.d3_tool_snap_position = val; },
[ 1,
new textBox(TEXTBOX_INPUT.number, function(val) { preview_panel.d3_tool_snap_rotation = val; }), ),
new __Panel_Linear_Setting_Item(
__txt("Rotation"), __txt("Rotation"),
new textBox(TEXTBOX_INPUT.number, function(val) { preview_panel.d3_tool_snap_rotation = val; }),
function() { return preview_panel.d3_tool_snap_rotation }, function() { return preview_panel.d3_tool_snap_rotation },
], function(val) { preview_panel.d3_tool_snap_rotation = val; },
15,
),
] ]
setHeight(); setHeight();

View file

@ -1,5 +1,5 @@
#region preference #region preference
globalvar PREFERENCES; globalvar PREFERENCES, PREFERENCES_DEF;
PREFERENCES = {}; PREFERENCES = {};
PREFERENCES.ui_framerate = 60; PREFERENCES.ui_framerate = 60;
@ -72,6 +72,8 @@
PREFERENCES.alt_picker = true; PREFERENCES.alt_picker = true;
PREFERENCES.clear_temp_on_close = true; PREFERENCES.clear_temp_on_close = true;
PREFERENCES.pan_mouse_key = mb_middle; PREFERENCES.pan_mouse_key = mb_middle;
PREFERENCES_DEF = variable_clone(PREFERENCES);
#endregion #endregion
#region recent files #region recent files