diff --git a/scripts/__panel_linear_setting/__panel_linear_setting.gml b/scripts/__panel_linear_setting/__panel_linear_setting.gml index ea5cd93e6..d0d626b1e 100644 --- a/scripts/__panel_linear_setting/__panel_linear_setting.gml +++ b/scripts/__panel_linear_setting/__panel_linear_setting.gml @@ -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 { title = __txtx("preview_3d_settings", "3D Preview Settings"); - w = ui(380); + w = ui(400); bg_y = -1; bg_y_to = -1; @@ -21,14 +57,12 @@ function Panel_Linear_Setting() : PanelContent() constructor { for( var i = 0, n = array_length(properties); i < n; i++ ) { var _prop = properties[i]; - - var _widg = _prop[0]; - if(is_string(_widg)) { - var _text = _prop[0]; - var _spr = _prop[1]; - var _ind = _prop[2]; - var _colr = _prop[3]; + if(is_instanceof(_prop, __Panel_Linear_Setting_Label)) { + var _text = _prop.name; + var _spr = _prop.sprite; + var _ind = _prop.s_index; + var _colr = _prop.s_color; 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); @@ -40,29 +74,54 @@ function Panel_Linear_Setting() : PanelContent() constructor { continue; } - var _text = _prop[1]; - var _data = _prop[2](); - - _widg.setFocusHover(pFOCUS, pHOVER); - _widg.register(); - - if(pHOVER && point_in_rectangle(mx, my, 0, yy - th / 2, w, yy + th / 2)) { - bg_y_to = yy - th / 2; - _hov = true; - } + if(is_instanceof(_prop, __Panel_Linear_Setting_Item)) { + var _text = _prop.name; + var _data = _prop.data; + var _widg = _prop.editWidget; + if(is_callable(_data)) _data = _data(); - draw_set_text(f_p1, fa_left, fa_center, COLORS._main_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); - if(is_instanceof(_widg, checkBox)) { - params.halign = fa_center; - params.valign = fa_center; - } + _widg.setFocusHover(pFOCUS, pHOVER); + _widg.register(); - _widg.drawParam(params); - - yy += th; + if(pHOVER && point_in_rectangle(mx, my, 0, yy - th / 2, w, yy + th / 2)) { + bg_y_to = yy - th / 2; + _hov = true; + } + + draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text); + draw_text_add(ui(16), yy, _text); + + 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)) { + params.halign = fa_center; + params.valign = fa_center; + } + + _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; + continue; + } } bg_a = lerp_float(bg_a, _hov, 2); diff --git a/scripts/addon_lua_widget/addon_lua_widget.gml b/scripts/addon_lua_widget/addon_lua_widget.gml index cf5914c1a..cee82b00a 100644 --- a/scripts/addon_lua_widget/addon_lua_widget.gml +++ b/scripts/addon_lua_widget/addon_lua_widget.gml @@ -36,7 +36,8 @@ [ "__textBox_draw", function(wd, _x, _y, _w, _h, _text, _m) { 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 = {} @@ -72,7 +73,8 @@ end", [ "__vectorBox_draw", function(wd, _x, _y, _w, _h, _vector, _m) { 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) { 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; 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++ ) { var _func = global.__lua_widget_functions[i]; - if(is_string(_func)) - lua_add_code(lua, _func); - else if(is_array(_func)) - lua_add_function(lua, _func[0], _func[1]); + if(is_string(_func)) lua_add_code(lua, _func); + else if(is_array(_func)) lua_add_function(lua, _func[0], _func[1]); } } #endregion \ No newline at end of file diff --git a/scripts/buttonGroup/buttonGroup.gml b/scripts/buttonGroup/buttonGroup.gml index dc1823eb2..3a634a080 100644 --- a/scripts/buttonGroup/buttonGroup.gml +++ b/scripts/buttonGroup/buttonGroup.gml @@ -67,7 +67,7 @@ function buttonGroup(_data, _onClick) : widget() constructor { if(display_button) { var bx = _x; - var draw_sel = []; + var draw_sel = noone; for(var i = 0; i < amo; i++) { buttons[i].setFocusHover(active, hover); @@ -92,7 +92,8 @@ function buttonGroup(_data, _onClick) : widget() constructor { bx += ww; } - draw_sprite_stretched_ext(draw_sel[0], 3, draw_sel[1], _y, ww, _h, COLORS._main_accent, 1); + if(draw_sel != noone) + 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(is_array(data) && key_mod_press(SHIFT)) { diff --git a/scripts/panel_animation_scaler/panel_animation_scaler.gml b/scripts/panel_animation_scaler/panel_animation_scaler.gml index 1ebfafb15..8510a127d 100644 --- a/scripts/panel_animation_scaler/panel_animation_scaler.gml +++ b/scripts/panel_animation_scaler/panel_animation_scaler.gml @@ -6,14 +6,11 @@ function Panel_Animation_Scaler() : Panel_Linear_Setting() constructor { #region data properties = [ - [ - new textBox(TEXTBOX_INPUT.number, function(to) { - to = toNumber(to); - scale_to = to; - }), + new __Panel_Linear_Setting_Item( __txtx("anim_scale_target_frame_length", "Target frame length"), + new textBox(TEXTBOX_INPUT.number, function(to) { scale_to = toNumber(to); }), function() { return scale_to; }, - ] + ) ]; setHeight(); diff --git a/scripts/panel_animation_settings/panel_animation_settings.gml b/scripts/panel_animation_settings/panel_animation_settings.gml index 2619c7942..cc1ee53a2 100644 --- a/scripts/panel_animation_settings/panel_animation_settings.gml +++ b/scripts/panel_animation_settings/panel_animation_settings.gml @@ -5,27 +5,21 @@ function Panel_Animation_Setting() : Panel_Linear_Setting() constructor { #region data properties = [ - [ - new textBox(TEXTBOX_INPUT.number, function(str) { - TOTAL_FRAMES = real(str); - }), + new __Panel_Linear_Setting_Item( __txtx("anim_length", "Animation length"), + new textBox(TEXTBOX_INPUT.number, function(str) { TOTAL_FRAMES = real(str); }), function() { return TOTAL_FRAMES; } - ], - [ - new textBox(TEXTBOX_INPUT.number, function(str) { - PROJECT.animator.framerate = real(str); - }), + ), + new __Panel_Linear_Setting_Item( __txtx("anim_frame_rate", "Preview frame rate"), + new textBox(TEXTBOX_INPUT.number, function(str) { PROJECT.animator.framerate = real(str); }), function() { return PROJECT.animator.framerate; } - ], - [ - new buttonGroup([__txt("Loop"), __txt("Stop")], function(b) { - PROJECT.animator.playback = b; - }), + ), + new __Panel_Linear_Setting_Item( __txtx("anim_on_end", "On end"), + new buttonGroup([__txt("Loop"), __txt("Stop")], function(b) { PROJECT.animator.playback = b; }), function() { return PROJECT.animator.playback; } - ] + ), ]; setHeight(); diff --git a/scripts/panel_graph_connection_settings/panel_graph_connection_settings.gml b/scripts/panel_graph_connection_settings/panel_graph_connection_settings.gml index 80054fab5..e4f274f18 100644 --- a/scripts/panel_graph_connection_settings/panel_graph_connection_settings.gml +++ b/scripts/panel_graph_connection_settings/panel_graph_connection_settings.gml @@ -5,54 +5,42 @@ function Panel_Graph_Connection_Setting() : Panel_Linear_Setting() constructor { #region data 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 ], - function(val) { PREFERENCES.curve_connection_line = val; }), - __txt("Type"), - function() { return PREFERENCES.curve_connection_line; } - ], - [ - new textBox(TEXTBOX_INPUT.number, function(str) { - PREFERENCES.connection_line_width = max(0.5, real(str)); - }), + function(val) { PREFERENCES.curve_connection_line = val; }), + ), + new __Panel_Linear_Setting_Item_Preference( __txtx("dialog_connection_thickness", "Line thickness"), - function() { return PREFERENCES.connection_line_width; } - ], - [ - new textBox(TEXTBOX_INPUT.number, function(str) { - PREFERENCES.connection_line_corner = max(0, real(str)); - }).setSlidable(), + "connection_line_width", + new textBox(TEXTBOX_INPUT.number, function(str) { PREFERENCES.connection_line_width = max(0.5, real(str)); }), + ), + new __Panel_Linear_Setting_Item_Preference( __txtx("dialog_connection_radius", "Corner radius"), - function() { return PREFERENCES.connection_line_corner; } - ], - [ - new textBox(TEXTBOX_INPUT.number, function(str) { - PREFERENCES.connection_line_aa = clamp(real(str), 1, 4); - }), + "connection_line_corner", + new textBox(TEXTBOX_INPUT.number, function(str) { PREFERENCES.connection_line_corner = max(0, real(str)); }).setSlidable(), + ), + new __Panel_Linear_Setting_Item_Preference( __txtx("pref_connection_quality", "Render quality"), - function() { return PREFERENCES.connection_line_aa; } - ], - [ - new buttonGroup([ "None", "ALT", "Always" ], function(val) { - PREFERENCES.connection_line_highlight = val; - }), + "connection_line_aa", + new textBox(TEXTBOX_INPUT.number, function(str) { PREFERENCES.connection_line_aa = clamp(real(str), 1, 4); }), + ), + new __Panel_Linear_Setting_Item_Preference( __txtx("pref_connection_highlight", "Highlight connection"), - function() { return PREFERENCES.connection_line_highlight; } - ], - [ - new slider(0, 1, 0.05, function(val) { - PREFERENCES.connection_line_highlight_fade = val; - }), + "connection_line_highlight", + new buttonGroup([ "None", "ALT", "Always" ], function(val) { PREFERENCES.connection_line_highlight = val; }), + ), + new __Panel_Linear_Setting_Item_Preference( __txtx("pref_connection_highlight_fade", "Fade connection"), - function() { return PREFERENCES.connection_line_highlight_fade }, - ], - [ - new checkBox(function() { - PREFERENCES.connection_line_highlight_all = !PREFERENCES.connection_line_highlight_all; - }), + "connection_line_highlight_fade", + new slider(0, 1, 0.05, function(val) { PREFERENCES.connection_line_highlight_fade = val; }), + ), + new __Panel_Linear_Setting_Item_Preference( __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(); diff --git a/scripts/panel_graph_grid_settings/panel_graph_grid_settings.gml b/scripts/panel_graph_grid_settings/panel_graph_grid_settings.gml index 00cc41359..bc58f179d 100644 --- a/scripts/panel_graph_grid_settings/panel_graph_grid_settings.gml +++ b/scripts/panel_graph_grid_settings/panel_graph_grid_settings.gml @@ -5,54 +5,66 @@ function Panel_Graph_Grid_Setting() : Panel_Linear_Setting() constructor { #region data properties = [ - [ + new __Panel_Linear_Setting_Item( + __txtx("grid_snap", "Snap to grid"), new checkBox(function() { if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return; 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) { if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return; 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) { if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return; 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) { if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return; PANEL_GRAPH.project.graphGrid.color = color; }, 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() { if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return; 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) { if(PANEL_GRAPH.project == noone || !PANEL_GRAPH.project.active) return; 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, + ), ]; diff --git a/scripts/panel_graph_view_settings/panel_graph_view_settings.gml b/scripts/panel_graph_view_settings/panel_graph_view_settings.gml index 4f6d3fa11..dce25b4e4 100644 --- a/scripts/panel_graph_view_settings/panel_graph_view_settings.gml +++ b/scripts/panel_graph_view_settings/panel_graph_view_settings.gml @@ -6,31 +6,41 @@ function Panel_Graph_View_Setting(display) : Panel_Linear_Setting() constructor #region data properties = [ - [ - new checkBox(function() { display_parameter.show_grid = !display_parameter.show_grid; }), + new __Panel_Linear_Setting_Item( __txt("Grid"), + new checkBox(function() { display_parameter.show_grid = !display_parameter.show_grid; }), function() { return display_parameter.show_grid }, - ], - [ - new checkBox(function() { display_parameter.show_dimension = !display_parameter.show_dimension; }), + function(val) { display_parameter.show_grid = val; }, + true, + ), + new __Panel_Linear_Setting_Item( __txtx("graph_visibility_dim", "Dimension"), + new checkBox(function() { display_parameter.show_dimension = !display_parameter.show_dimension; }), function() { return display_parameter.show_dimension }, - ], - [ - new checkBox(function() { display_parameter.show_compute = !display_parameter.show_compute; }), + function(val) { display_parameter.show_dimension = val; }, + true, + ), + new __Panel_Linear_Setting_Item( __txtx("graph_visibility_compute", "Compute time"), + new checkBox(function() { display_parameter.show_compute = !display_parameter.show_compute; }), function() { return display_parameter.show_compute }, - ], - [ - new checkBox(function() { display_parameter.avoid_label = !display_parameter.avoid_label; }), + function(val) { display_parameter.show_compute = val; }, + true, + ), + new __Panel_Linear_Setting_Item( __txtx("graph_visibility_avoid_label", "Avoid Label"), + new checkBox(function() { display_parameter.avoid_label = !display_parameter.avoid_label; }), function() { return display_parameter.avoid_label }, - ], - [ - new slider(50, 100, 1, function(val) { display_parameter.preview_scale = val; }), + function(val) { display_parameter.avoid_label = val; }, + true, + ), + new __Panel_Linear_Setting_Item( __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(val) { display_parameter.preview_scale = val; }, + 100, + ), ]; setHeight(); diff --git a/scripts/panel_preview_3d_setting/panel_preview_3d_setting.gml b/scripts/panel_preview_3d_setting/panel_preview_3d_setting.gml index 07a25b594..09716bf25 100644 --- a/scripts/panel_preview_3d_setting/panel_preview_3d_setting.gml +++ b/scripts/panel_preview_3d_setting/panel_preview_3d_setting.gml @@ -6,55 +6,65 @@ function Panel_Preview_3D_Setting(panel) : Panel_Linear_Setting() constructor { #region data properties_default = [ - [ - new checkBox(function() { preview_panel.d3_scene_light_enabled = !preview_panel.d3_scene_light_enabled; }), + new __Panel_Linear_Setting_Item( __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 }, - ], - [ - new buttonColor(function(col) { - preview_panel.d3_scene.lightAmbient = col; }), + function(val) { preview_panel.d3_scene_light_enabled = val; }, + true, + ), + new __Panel_Linear_Setting_Item( __txt("Ambient Color"), + new buttonColor(function(col) { preview_panel.d3_scene.lightAmbient = col; }), 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) { preview_panel.d3_scene_light0.intensity = val; preview_panel.d3_scene_light1.intensity = val; }), - __txt("Light Intensity"), function() { return preview_panel.d3_scene_light0.intensity }, - ], - [ - new checkBox(function() { - preview_panel.d3_scene_light0.shadow_active = !preview_panel.d3_scene_light0.shadow_active; }), + function(val) { preview_panel.d3_scene_light0.intensity = val; }, + 1, + ), + new __Panel_Linear_Setting_Item( __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(val) { preview_panel.d3_scene_light0.shadow_active = val; }, + false, + ), + new __Panel_Linear_Setting_Item( + __txt("View Plane"), new vectorBox(2, function(index, value) { if(index == 0) preview_panel.d3_view_camera.view_near = 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 ] }, - ], - [ - new checkBox(function() { - preview_panel.d3_scene.gammaCorrection = !preview_panel.d3_scene.gammaCorrection; }), + function(val) { preview_panel.d3_view_camera.view_near = val[0]; preview_panel.d3_view_camera.view_far = val[1] }, + [ 0.01, 50 ], + ), + new __Panel_Linear_Setting_Item( __txt("Gamma Correct"), + new checkBox(function() { preview_panel.d3_scene.gammaCorrection = !preview_panel.d3_scene.gammaCorrection; }), function() { return preview_panel.d3_scene.gammaCorrection }, - ], - [ - new checkBox(function() { - preview_panel.d3_scene.show_normal = !preview_panel.d3_scene.show_normal; }), + function(val) { preview_panel.d3_scene.gammaCorrection = val; }, + true, + ), + new __Panel_Linear_Setting_Item( __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(val) { preview_panel.d3_scene.show_normal = val; }, + false, + ), ] 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); diff --git a/scripts/panel_preview_grid_setting/panel_preview_grid_setting.gml b/scripts/panel_preview_grid_setting/panel_preview_grid_setting.gml index d32e5602c..ff932dc4e 100644 --- a/scripts/panel_preview_grid_setting/panel_preview_grid_setting.gml +++ b/scripts/panel_preview_grid_setting/panel_preview_grid_setting.gml @@ -5,44 +5,46 @@ function Panel_Preview_Grid_Setting() : Panel_Linear_Setting() constructor { #region data properties = [ - [ - new checkBox(function() { - PROJECT.previewGrid.show = !PROJECT.previewGrid.show; - }), + new __Panel_Linear_Setting_Item( __txt("Enabled"), - function() { return PROJECT.previewGrid.show; } - ], - [ - new checkBox(function() { - PROJECT.previewGrid.snap = !PROJECT.previewGrid.snap; - }), + new checkBox(function() { PROJECT.previewGrid.show = !PROJECT.previewGrid.show; }), + function() { return PROJECT.previewGrid.show; }, + function(val) { PROJECT.previewGrid.show = val; }, + false, + ), + new __Panel_Linear_Setting_Item( __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) { var _v = PROJECT.previewGrid.size[index]; PROJECT.previewGrid.size[index] = max(1, value); return _v != max(1, value); }).setLinkInactiveColor(COLORS._main_icon_light), - __txt("Grid size"), - function() { return PROJECT.previewGrid.size; } - ], - [ - new slider(0, 1, .05, function(str) { - PROJECT.previewGrid.opacity = clamp(real(str), 0, 1); - }), + function() { return PROJECT.previewGrid.size; }, + function(val) { PROJECT.previewGrid.size = val; }, + [ 16, 16 ], + ), + new __Panel_Linear_Setting_Item( __txt("Grid opacity"), - function() { return PROJECT.previewGrid.opacity; } - ], - [ - new buttonColor(function(color) { - PROJECT.previewGrid.color = color; - }, self), + 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; }, + 0.5, + ), + new __Panel_Linear_Setting_Item( __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(); diff --git a/scripts/panel_preview_onion_setting/panel_preview_onion_setting.gml b/scripts/panel_preview_onion_setting/panel_preview_onion_setting.gml index 58dd7de0e..02ab53dba 100644 --- a/scripts/panel_preview_onion_setting/panel_preview_onion_setting.gml +++ b/scripts/panel_preview_onion_setting/panel_preview_onion_setting.gml @@ -5,48 +5,48 @@ function Panel_Preview_Onion_Setting() : Panel_Linear_Setting() constructor { #region data properties = [ - [ - new checkBox(function() { - PROJECT.onion_skin.enabled = !PROJECT.onion_skin.enabled; - }), + new __Panel_Linear_Setting_Item( __txt("Enabled"), - function() { return PROJECT.onion_skin.enabled; } - ], - [ - new checkBox(function() { - PROJECT.onion_skin.on_top = !PROJECT.onion_skin.on_top; - }), + new checkBox(function() { PROJECT.onion_skin.enabled = !PROJECT.onion_skin.enabled; }), + function() { return PROJECT.onion_skin.enabled; }, + function(val) { PROJECT.onion_skin.enabled = val; }, + false + ), + new __Panel_Linear_Setting_Item( __txtx("onion_skin_top", "Draw on top"), - function() { return PROJECT.onion_skin.on_top; } - ], - [ - new textBox(TEXTBOX_INPUT.number, function(str) { - PROJECT.onion_skin.step = max(1, round(real(str))); - }), + 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; }, + true + ), + new __Panel_Linear_Setting_Item( __txtx("onion_skin_frame_step", "Frame step"), - function() { return PROJECT.onion_skin.step; } - ], - [ - new buttonColor(function(color) { - PROJECT.onion_skin.color[0] = color; - }, self), + 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; }, + 1 + ), + new __Panel_Linear_Setting_Item( __txtx("onion_skin_pre_color", "Pre Color"), - function() { return PROJECT.onion_skin.color[0]; } - ], - [ - new buttonColor(function(color) { - PROJECT.onion_skin.color[1] = color; - }, self), + 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; }, + c_red + ), + new __Panel_Linear_Setting_Item( __txtx("onion_skin_post_color", "Post Color"), - function() { return PROJECT.onion_skin.color[1]; } - ], - [ - new slider(0, 1, .05, function(str) { - PROJECT.onion_skin.alpha = clamp(real(str), 0, 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; }, + c_blue + ), + new __Panel_Linear_Setting_Item( __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(); diff --git a/scripts/panel_preview_snap_setting/panel_preview_snap_setting.gml b/scripts/panel_preview_snap_setting/panel_preview_snap_setting.gml index 6b6c4d805..64dc9680d 100644 --- a/scripts/panel_preview_snap_setting/panel_preview_snap_setting.gml +++ b/scripts/panel_preview_snap_setting/panel_preview_snap_setting.gml @@ -6,21 +6,27 @@ function Panel_Preview_Snap_Setting(panel) : Panel_Linear_Setting() constructor #region data properties = [ - [ - new checkBox(function() { preview_panel.d3_tool_snap = !preview_panel.d3_tool_snap; }), + new __Panel_Linear_Setting_Item( __txt("Snap"), + new checkBox(function() { preview_panel.d3_tool_snap = !preview_panel.d3_tool_snap; }), function() { return preview_panel.d3_tool_snap }, - ], - [ - new textBox(TEXTBOX_INPUT.number, function(val) { preview_panel.d3_tool_snap_position = val; }), + function(val) { preview_panel.d3_tool_snap = val; }, + false, + ), + new __Panel_Linear_Setting_Item( __txt("Linear"), + new textBox(TEXTBOX_INPUT.number, function(val) { preview_panel.d3_tool_snap_position = val; }), function() { return preview_panel.d3_tool_snap_position }, - ], - [ - new textBox(TEXTBOX_INPUT.number, function(val) { preview_panel.d3_tool_snap_rotation = val; }), + function(val) { preview_panel.d3_tool_snap_position = val; }, + 1, + ), + new __Panel_Linear_Setting_Item( __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(val) { preview_panel.d3_tool_snap_rotation = val; }, + 15, + ), ] setHeight(); diff --git a/scripts/preferences/preferences.gml b/scripts/preferences/preferences.gml index 3b6d2855e..7b4154232 100644 --- a/scripts/preferences/preferences.gml +++ b/scripts/preferences/preferences.gml @@ -1,5 +1,5 @@ #region preference - globalvar PREFERENCES; + globalvar PREFERENCES, PREFERENCES_DEF; PREFERENCES = {}; PREFERENCES.ui_framerate = 60; @@ -72,6 +72,8 @@ PREFERENCES.alt_picker = true; PREFERENCES.clear_temp_on_close = true; PREFERENCES.pan_mouse_key = mb_middle; + + PREFERENCES_DEF = variable_clone(PREFERENCES); #endregion #region recent files