Skip to content

Commit

Permalink
Grid Size: ability for user to change (mbrlabs#199)
Browse files Browse the repository at this point in the history
* add default grid size and grid size settings in settings dialog

* get rid of default grid size setting and just use grid size

* set value in different place

* remove unused code

* remove unused variable

* add settings string for grid size in en.txt
  • Loading branch information
johnblat authored Aug 7, 2023
1 parent a9c3d46 commit 30e3752
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 28 deletions.
1 change: 1 addition & 0 deletions lorien/Assets/I18n/en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ SETTINGS_PRESSURE_SENSITIVITY Pressure Sensitivity
SETTINGS_BRUSH_SIZE Default Brush Size
SETTINGS_CANVAS_COLOR Default Canvas Color
SETTINGS_PROJECT_FOLDER Default Project Folder
SETTINGS_GRID_SIZE Grid Size
SETTINGS_LANGUAGE Language
SETTINGS_THEME Theme
SETTINGS_UI_SCALE UI Scale
Expand Down
7 changes: 6 additions & 1 deletion lorien/InfiniteCanvas/InfiniteCanvasGrid.gd
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ func _on_zoom_changed(zoom: float) -> void: update()
func _on_position_changed(pos: Vector2) -> void: update()
func _on_viewport_size_changed() -> void: update()

# -------------------------------------------------------------------------------------------------
func set_grid_size(size: int) -> void:
_grid_size = size
update()

# -------------------------------------------------------------------------------------------------
func set_canvas_color(c: Color) -> void:
_grid_color = c * 1.25

# -------------------------------------------------------------------------------------------------
func set_grid_scale(size: float):
_grid_size = Config.DEFAULT_GRID_SIZE * size
_grid_size *= size
update()

# -------------------------------------------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions lorien/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extends Control

# -------------------------------------------------------------------------------------------------
onready var _canvas: InfiniteCanvas = $InfiniteCanvas
onready var _canvas_grid: InfiniteCanvasGrid = $InfiniteCanvas/Viewport/Grid
onready var _statusbar: Statusbar = $Statusbar
onready var _menubar: Menubar = $Topbar/Menubar
onready var _toolbar: Toolbar = $Topbar/Toolbar
Expand Down Expand Up @@ -70,6 +71,8 @@ func _ready():
_export_dialog.connect("file_selected", self, "_on_export_confirmed")

_settings_dialog.connect("ui_scale_changed", self, "_on_scale_changed")
_settings_dialog.connect("grid_size_changed", self, "_on_grid_size_changed")


# Initialize scale
_on_scale_changed()
Expand Down Expand Up @@ -329,6 +332,10 @@ func _on_brush_color_changed(color: Color) -> void:
func _on_brush_size_changed(size: int) -> void:
_canvas.set_brush_size(size)

# -------------------------------------------------------------------------------------------------
func _on_grid_size_changed(size: int) -> void:
_canvas_grid.set_grid_size(size)

# -------------------------------------------------------------------------------------------------
func _on_clear_canvas() -> void:
_canvas.clear()
Expand Down
9 changes: 4 additions & 5 deletions lorien/Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ margin_bottom = 202.0
custom_styles/panel = SubResource( 1 )

[node name="ColorPicker" type="ColorPicker" parent="BackgroundColorPickerPopup/PanelContainer"]
margin_left = 28.0
margin_top = 28.0
margin_right = 337.0
margin_bottom = 432.0
margin_left = 52.0
margin_top = 52.0
margin_right = 361.0
margin_bottom = 456.0
edit_alpha = false
presets_enabled = false
presets_visible = false
Expand Down Expand Up @@ -218,7 +218,6 @@ margin_right = 225.0
margin_bottom = 102.5

[node name="SettingsDialog" parent="." instance=ExtResource( 10 )]
visible = false
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
Expand Down
9 changes: 9 additions & 0 deletions lorien/UI/Dialogs/SettingsDialog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const UI_SCALE_CUSTOM_INDEX := 1

# -------------------------------------------------------------------------------------------------
signal ui_scale_changed
signal grid_size_changed(size)

# -------------------------------------------------------------------------------------------------
onready var _tab_container: TabContainer = $MarginContainer/TabContainer
Expand All @@ -34,6 +35,7 @@ onready var _language_options: OptionButton = $MarginContainer/TabContainer/Gene
onready var _brush_rounding_options: OptionButton = $MarginContainer/TabContainer/Rendering/VBoxContainer/BrushRounding/OptionButton
onready var _ui_scale_options: OptionButton = $MarginContainer/TabContainer/Appearance/VBoxContainer/UIScale/HBoxContainer/UIScaleOptions
onready var _ui_scale: SpinBox = $MarginContainer/TabContainer/Appearance/VBoxContainer/UIScale/HBoxContainer/UIScale
onready var _grid_size: SpinBox = $MarginContainer/TabContainer/Appearance/VBoxContainer/GridSize/GridSize

# -------------------------------------------------------------------------------------------------
func _ready():
Expand All @@ -52,6 +54,7 @@ func _apply_language() -> void:
func _set_values() -> void:
var brush_size = Settings.get_value(Settings.GENERAL_DEFAULT_BRUSH_SIZE, Config.DEFAULT_BRUSH_SIZE)
var canvas_color = Settings.get_value(Settings.GENERAL_DEFAULT_CANVAS_COLOR, Config.DEFAULT_CANVAS_COLOR)
var grid_size = Config.DEFAULT_GRID_SIZE
var project_dir = Settings.get_value(Settings.GENERAL_DEFAULT_PROJECT_DIR, "")
var theme = Settings.get_value(Settings.APPEARANCE_THEME, Types.UITheme.DARK)
var aa_mode = Settings.get_value(Settings.RENDERING_AA_MODE, Config.DEFAULT_AA_MODE)
Expand Down Expand Up @@ -82,6 +85,7 @@ func _set_values() -> void:
_pressure_sensitivity.value = pressure_sensitivity
_brush_size.value = brush_size
_canvas_color.color = canvas_color
_grid_size.value = grid_size
_project_dir.text = project_dir
_foreground_fps.value = foreground_fps
_background_fps.value = background_fps
Expand Down Expand Up @@ -133,7 +137,12 @@ func _on_DefaultBrushSize_value_changed(value: int) -> void:
# -------------------------------------------------------------------------------------------------
func _on_DefaultCanvasColor_color_changed(color: Color) -> void:
Settings.set_value(Settings.GENERAL_DEFAULT_CANVAS_COLOR, color)


# -------------------------------------------------------------------------------------------------
func _on_GridSize_value_changed(value: int) -> void:
emit_signal("grid_size_changed", int(value))

# -------------------------------------------------------------------------------------------------
func _on_PressureSensitivity_value_changed(value: float):
Settings.set_value(Settings.GENERAL_PRESSURE_SENSITIVITY, value)
Expand Down
52 changes: 39 additions & 13 deletions lorien/UI/Dialogs/SettingsDialog.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ color = Color( 0.12549, 0.129412, 0.141176, 1 )
edit_alpha = false

[node name="DefaultSaveDir" type="HBoxContainer" parent="MarginContainer/TabContainer/General/VBoxContainer"]
margin_top = 87.0
margin_top = 112.0
margin_right = 496.0
margin_bottom = 108.0
margin_bottom = 133.0
size_flags_horizontal = 3

[node name="Label" type="Label" parent="MarginContainer/TabContainer/General/VBoxContainer/DefaultSaveDir"]
Expand All @@ -162,15 +162,15 @@ placeholder_text = "e.g. C:/Users/me/Lorien"
placeholder_alpha = 0.5

[node name="HSeparator4" type="HSeparator" parent="MarginContainer/TabContainer/General/VBoxContainer"]
margin_top = 112.0
margin_top = 137.0
margin_right = 496.0
margin_bottom = 136.0
margin_bottom = 161.0
custom_constants/separation = 24

[node name="Language" type="HBoxContainer" parent="MarginContainer/TabContainer/General/VBoxContainer"]
margin_top = 140.0
margin_top = 165.0
margin_right = 496.0
margin_bottom = 165.0
margin_bottom = 190.0
size_flags_horizontal = 3

[node name="Label" type="Label" parent="MarginContainer/TabContainer/General/VBoxContainer/Language"]
Expand All @@ -189,9 +189,9 @@ size_flags_horizontal = 3
text = "English"

[node name="HSeparator" type="HSeparator" parent="MarginContainer/TabContainer/General/VBoxContainer"]
margin_top = 169.0
margin_top = 194.0
margin_right = 496.0
margin_bottom = 181.0
margin_bottom = 206.0
custom_constants/separation = 12
custom_styles/separator = SubResource( 3 )

Expand Down Expand Up @@ -254,21 +254,21 @@ margin_bottom = 70.0

[node name="Label" type="Label" parent="MarginContainer/TabContainer/Appearance/VBoxContainer/UIScale"]
margin_top = 4.0
margin_right = 246.0
margin_right = 218.0
margin_bottom = 21.0
size_flags_horizontal = 3
size_flags_vertical = 6
text = "SETTINGS_UI_SCALE"

[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/TabContainer/Appearance/VBoxContainer/UIScale"]
margin_left = 250.0
margin_left = 222.0
margin_right = 496.0
margin_bottom = 25.0
size_flags_horizontal = 3
size_flags_vertical = 3

[node name="UIScaleOptions" type="OptionButton" parent="MarginContainer/TabContainer/Appearance/VBoxContainer/UIScale/HBoxContainer"]
margin_right = 121.0
margin_right = 198.0
margin_bottom = 25.0
size_flags_horizontal = 3
size_flags_vertical = 3
Expand All @@ -277,8 +277,8 @@ items = [ "SETTINGS_UI_SCALE_AUTO", null, false, 0, null, "SETTINGS_UI_SCALE_CUS
selected = 0

[node name="UIScale" type="SpinBox" parent="MarginContainer/TabContainer/Appearance/VBoxContainer/UIScale/HBoxContainer"]
margin_left = 125.0
margin_right = 246.0
margin_left = 202.0
margin_right = 274.0
margin_bottom = 25.0
size_flags_horizontal = 3
size_flags_vertical = 3
Expand All @@ -304,6 +304,31 @@ custom_colors/font_color = Color( 1, 0.470588, 0.470588, 1 )
text = "SETTINGS_RESTART_NOTICE"
align = 1

[node name="GridSize" type="HBoxContainer" parent="MarginContainer/TabContainer/Appearance/VBoxContainer"]
margin_top = 90.0
margin_right = 496.0
margin_bottom = 111.0
size_flags_horizontal = 3

[node name="Label" type="Label" parent="MarginContainer/TabContainer/Appearance/VBoxContainer/GridSize"]
margin_top = 2.0
margin_right = 246.0
margin_bottom = 19.0
size_flags_horizontal = 3
size_flags_vertical = 6
text = "SETTINGS_GRID_SIZE"

[node name="GridSize" type="SpinBox" parent="MarginContainer/TabContainer/Appearance/VBoxContainer/GridSize"]
margin_left = 250.0
margin_right = 496.0
margin_bottom = 21.0
size_flags_horizontal = 3
size_flags_vertical = 3
min_value = 8.0
max_value = 256.0
value = 12.0
allow_greater = true

[node name="Rendering" type="Control" parent="MarginContainer/TabContainer"]
visible = false
anchor_right = 1.0
Expand Down Expand Up @@ -467,6 +492,7 @@ dialog_autowrap = true
[connection signal="item_selected" from="MarginContainer/TabContainer/Appearance/VBoxContainer/UIScale/HBoxContainer/UIScaleOptions" to="." method="_on_UIScaleOptions_item_selected"]
[connection signal="gui_input" from="MarginContainer/TabContainer/Appearance/VBoxContainer/UIScale/HBoxContainer/UIScale" to="MarginContainer/TabContainer/Appearance/VBoxContainer/UIScale/HBoxContainer/UIScale" method="_on_UIScale_gui_input"]
[connection signal="value_changed" from="MarginContainer/TabContainer/Appearance/VBoxContainer/UIScale/HBoxContainer/UIScale" to="." method="_on_UIScale_value_changed"]
[connection signal="value_changed" from="MarginContainer/TabContainer/Appearance/VBoxContainer/GridSize/GridSize" to="." method="_on_GridSize_value_changed"]
[connection signal="item_selected" from="MarginContainer/TabContainer/Rendering/VBoxContainer/AntiAliasing/AntiAliasing" to="." method="_on_AntiAliasing_item_selected"]
[connection signal="item_selected" from="MarginContainer/TabContainer/Rendering/VBoxContainer/BrushRounding/OptionButton" to="." method="_on_Brush_rounding_item_selected"]
[connection signal="value_changed" from="MarginContainer/TabContainer/Rendering/VBoxContainer/TargetFramerate/TargetFramerate" to="." method="_on_Target_Fps_Foreground_changed"]
Expand Down
10 changes: 2 additions & 8 deletions lorien/UI/Menubar.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,21 @@ margin_bottom = 38.0
rect_min_size = Vector2( 0, 38 )
theme = ExtResource( 1 )
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Left" type="HBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/separation = 4
__meta__ = {
"_edit_use_anchors_": false
}

[node name="VSeparator3" type="VSeparator" parent="Left"]
margin_right = 12.0
margin_bottom = 38.0
mouse_filter = 2
size_flags_horizontal = 4
custom_styles/separator = SubResource( 1 )
custom_constants/separation = 12
custom_styles/separator = SubResource( 1 )

[node name="MenuButton" type="TextureButton" parent="Left"]
modulate = Color( 0.776471, 0.776471, 0.776471, 1 )
Expand All @@ -58,8 +52,8 @@ margin_right = 50.0
margin_bottom = 38.0
mouse_filter = 2
size_flags_horizontal = 4
custom_styles/separator = SubResource( 2 )
custom_constants/separation = 12
custom_styles/separator = SubResource( 2 )

[node name="Tabs" type="HBoxContainer" parent="Left"]
margin_left = 54.0
Expand Down
2 changes: 1 addition & 1 deletion lorien/UI/Toolbar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func _on_window_resized() -> void:
# -------------------------------------------------------------------------------------------------
func _on_GridButton_toggled(toggled: bool):
emit_signal("grid_enabled", toggled)

# -------------------------------------------------------------------------------------------------
func _on_FullscreenButton_toggled(button_pressed):
OS.set_window_fullscreen(button_pressed)
Expand Down

0 comments on commit 30e3752

Please sign in to comment.