diff --git a/Translations/Translations.pot b/Translations/Translations.pot index fc263d62a..93c38cd4a 100644 --- a/Translations/Translations.pot +++ b/Translations/Translations.pot @@ -1233,40 +1233,20 @@ msgstr "" msgid "All" msgstr "" -msgid "Rectangular grid width:" +#. Found in the Preferences, in the Canvas tab. +msgid "Rectangular grid size:" msgstr "" -msgid "Sets how far apart are vertical lines of the rectangular grid" +#. Found in the Preferences, in the Canvas tab. +msgid "Isometric grid size:" msgstr "" -msgid "Rectangular grid height:" +#. Found in the Preferences, in the Canvas tab. +msgid "Grid offset:" msgstr "" -msgid "Sets how far apart are horizontal lines of the rectangular grid" -msgstr "" - -msgid "Isometric cell bounds width:" -msgstr "" - -msgid "Sets the width of the isometric cell's axis aligned bounding box" -msgstr "" - -msgid "Isometric cell bounds height:" -msgstr "" - -msgid "Sets the height of the isometric cell's axis aligned bounding box" -msgstr "" - -msgid "Grid offset x:" -msgstr "" - -msgid "Sets grid's x offset from the canvas origin (top left corner of the image)" -msgstr "" - -msgid "Grid offset y:" -msgstr "" - -msgid "Sets grid's y offset from the canvas origin (top left corner of the image)" +#. Found in the Preferences, in the Canvas tab. Hint tooltip of the grid offset value sliders. +msgid "Sets grid's offset from the canvas origin (top left corner of the image)" msgstr "" msgid "Draw over Tile Mode:" @@ -2384,6 +2364,7 @@ msgstr "" msgid "Ambient color energy:" msgstr "" +#. An option that toggles the visibility of something on or off. Found in the format of "Visible: on/off" msgid "Visible:" msgstr "" diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index 87a13b59c..d3c494e3f 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -92,12 +92,9 @@ var default_width := 64 var default_height := 64 var default_fill_color := Color(0, 0, 0, 0) var grid_type = GridTypes.CARTESIAN -var grid_width := 2 -var grid_height := 2 -var grid_isometric_cell_bounds_width := 16 -var grid_isometric_cell_bounds_height := 8 -var grid_offset_x := 0 -var grid_offset_y := 0 +var grid_size := Vector2(2, 2) +var isometric_grid_size := Vector2(16, 8) +var grid_offset := Vector2.ZERO var grid_draw_over_tile_mode := false var grid_color := Color.black var pixel_grid_show_at_zoom := 1500.0 # percentage diff --git a/src/Preferences/PreferencesDialog.gd b/src/Preferences/PreferencesDialog.gd index d0736d7e4..c01509d3c 100644 --- a/src/Preferences/PreferencesDialog.gd +++ b/src/Preferences/PreferencesDialog.gd @@ -36,20 +36,9 @@ var preferences := [ Preference.new("default_fill_color", "Image/ImageOptions/DefaultFillColor", "color"), Preference.new("smooth_zoom", "Canvas/ZoomOptions/SmoothZoom", "pressed"), Preference.new("grid_type", "Canvas/GridOptions/GridType", "selected"), - Preference.new("grid_width", "Canvas/GridOptions/GridWidthValue", "value"), - Preference.new("grid_height", "Canvas/GridOptions/GridHeightValue", "value"), - Preference.new( - "grid_isometric_cell_bounds_width", - "Canvas/GridOptions/IsometricCellBoundsWidthValue", - "value" - ), - Preference.new( - "grid_isometric_cell_bounds_height", - "Canvas/GridOptions/IsometricCellBoundsHeightValue", - "value" - ), - Preference.new("grid_offset_x", "Canvas/GridOptions/GridOffsetXValue", "value"), - Preference.new("grid_offset_y", "Canvas/GridOptions/GridOffsetYValue", "value"), + Preference.new("grid_size", "Canvas/GridOptions/GridSizeValue", "value"), + Preference.new("isometric_grid_size", "Canvas/GridOptions/IsometricGridSizeValue", "value"), + Preference.new("grid_offset", "Canvas/GridOptions/GridOffsetValue", "value"), Preference.new( "grid_draw_over_tile_mode", "Canvas/GridOptions/GridDrawOverTileMode", "pressed" ), @@ -201,7 +190,7 @@ func _ready() -> void: global_value = Global.get(pref.prop_name) # This is needed because color_changed doesn't fire if the color changes in code - if pref.value_type == "color": + if typeof(value) == TYPE_VECTOR2 or typeof(value) == TYPE_COLOR: preference_update(pref.prop_name, pref.require_restart) disable_restore_default_button( restore_default_button, global_value.is_equal_approx(pref.default_value) diff --git a/src/Preferences/PreferencesDialog.tscn b/src/Preferences/PreferencesDialog.tscn index 10cf63476..71c185fee 100644 --- a/src/Preferences/PreferencesDialog.tscn +++ b/src/Preferences/PreferencesDialog.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=2] +[gd_scene load_steps=9 format=2] [ext_resource path="res://src/Preferences/PreferencesDialog.gd" type="Script" id=1] [ext_resource path="res://src/Preferences/HandleExtensions.gd" type="Script" id=2] @@ -6,6 +6,7 @@ [ext_resource path="res://src/Preferences/HandleLanguages.gd" type="Script" id=4] [ext_resource path="res://src/Preferences/HandleThemes.gd" type="Script" id=5] [ext_resource path="res://src/UI/Nodes/ValueSlider.tscn" type="PackedScene" id=6] +[ext_resource path="res://src/UI/Nodes/ValueSliderV2.tscn" type="PackedScene" id=7] [sub_resource type="ButtonGroup" id=1] @@ -370,12 +371,12 @@ color = Color( 0.992157, 0.427451, 0.0784314, 1 ) [node name="Canvas" type="VBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide"] visible = false -margin_top = 56.0 -margin_right = 529.0 -margin_bottom = 584.0 +margin_top = 74.0 +margin_right = 486.0 +margin_bottom = 602.0 [node name="ZoomHeader" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas"] -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 14.0 custom_constants/separation = 0 @@ -387,26 +388,26 @@ text = "Zoom" [node name="HSeparator" type="HSeparator" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/ZoomHeader"] margin_left = 37.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 14.0 size_flags_horizontal = 3 [node name="ZoomOptions" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas"] margin_top = 18.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 42.0 [node name="Label" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/ZoomOptions"] margin_top = 5.0 -margin_right = 262.0 +margin_right = 241.0 margin_bottom = 19.0 rect_min_size = Vector2( 110, 0 ) size_flags_horizontal = 3 text = "Smooth Zoom" [node name="SmoothZoom" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/ZoomOptions"] -margin_left = 266.0 -margin_right = 529.0 +margin_left = 245.0 +margin_right = 486.0 margin_bottom = 24.0 hint_tooltip = "Adds a smoother transition when zooming in or out" mouse_default_cursor_shape = 2 @@ -416,7 +417,7 @@ text = "On" [node name="GuideHeader" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas"] margin_top = 46.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 60.0 custom_constants/separation = 0 @@ -428,13 +429,13 @@ text = "Guides" [node name="HSeparator" type="HSeparator" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GuideHeader"] margin_left = 45.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 14.0 size_flags_horizontal = 3 [node name="GuideOptions" type="GridContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas"] margin_top = 64.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 84.0 custom_constants/vseparation = 4 custom_constants/hseparation = 4 @@ -442,7 +443,7 @@ columns = 3 [node name="GuideColorLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GuideOptions"] margin_top = 3.0 -margin_right = 175.0 +margin_right = 161.0 margin_bottom = 17.0 rect_min_size = Vector2( 110, 0 ) hint_tooltip = "A color of ruler guides displayed on the canvas" @@ -451,8 +452,8 @@ size_flags_horizontal = 3 text = "Guides color:" [node name="GuideColor" type="ColorPickerButton" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GuideOptions"] -margin_left = 179.0 -margin_right = 354.0 +margin_left = 165.0 +margin_right = 326.0 margin_bottom = 20.0 rect_min_size = Vector2( 64, 20 ) hint_tooltip = "A color of ruler guides displayed on the canvas" @@ -462,7 +463,7 @@ color = Color( 0.63, 0.13, 0.94, 1 ) [node name="GridHeader" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas"] margin_top = 88.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 102.0 custom_constants/separation = 0 @@ -474,13 +475,13 @@ text = "Grid" [node name="HSeparator" type="HSeparator" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridHeader"] margin_left = 27.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 14.0 size_flags_horizontal = 3 [node name="GridOptions" type="GridContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas"] margin_top = 106.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 266.0 custom_constants/vseparation = 4 custom_constants/hseparation = 4 @@ -488,7 +489,7 @@ columns = 3 [node name="GridTypeLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] margin_top = 3.0 -margin_right = 183.0 +margin_right = 171.0 margin_bottom = 17.0 hint_tooltip = "Sets the type of the grid between rectangular, isometric or both" mouse_filter = 0 @@ -499,8 +500,8 @@ __meta__ = { } [node name="GridType" type="OptionButton" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] -margin_left = 187.0 -margin_right = 337.0 +margin_left = 175.0 +margin_right = 346.0 margin_bottom = 20.0 hint_tooltip = "Sets the type of the grid between rectangular, isometric or both" mouse_default_cursor_shape = 2 @@ -509,144 +510,76 @@ text = "Rectangular" items = [ "Rectangular", null, false, 0, null, "Isometric", null, false, 1, null, "All", null, false, 2, null ] selected = 0 -[node name="GridWidthLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] -margin_left = 341.0 -margin_top = 3.0 -margin_right = 529.0 -margin_bottom = 17.0 +[node name="GridSizeLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] +margin_left = 350.0 +margin_right = 486.0 +margin_bottom = 20.0 rect_min_size = Vector2( 110, 0 ) -hint_tooltip = "Sets how far apart are vertical lines of the rectangular grid" mouse_filter = 0 -text = "Rectangular grid width:" +size_flags_vertical = 1 +text = "Rectangular grid size:" -[node name="GridWidthValue" type="SpinBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] +[node name="GridSizeValue" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions" instance=ExtResource( 7 )] margin_top = 24.0 -margin_right = 183.0 -margin_bottom = 48.0 -hint_tooltip = "Sets how far apart are vertical lines of the rectangular grid" -mouse_default_cursor_shape = 2 -min_value = 1.0 -max_value = 16384.0 -value = 2.0 -rounded = true -align = 2 -suffix = "px" - -[node name="GridHeightLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] -margin_left = 187.0 -margin_top = 29.0 -margin_right = 337.0 -margin_bottom = 43.0 -hint_tooltip = "Sets how far apart are horizontal lines of the rectangular grid" -mouse_filter = 0 -text = "Rectangular grid height:" - -[node name="GridHeightValue" type="SpinBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] -margin_left = 341.0 -margin_top = 24.0 -margin_right = 529.0 -margin_bottom = 48.0 -hint_tooltip = "Sets how far apart are horizontal lines of the rectangular grid" -mouse_default_cursor_shape = 2 -min_value = 1.0 -max_value = 16384.0 -value = 2.0 -rounded = true -align = 2 -suffix = "px" - -[node name="IsometricCellBoundsWidthLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] -margin_top = 57.0 -margin_right = 183.0 -margin_bottom = 71.0 -hint_tooltip = "Sets the width of the isometric cell's axis aligned bounding box" -mouse_filter = 0 -text = "Isometric cell bounds width:" - -[node name="IsometricCellBoundsWidthValue" type="SpinBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] -margin_left = 187.0 -margin_top = 52.0 -margin_right = 337.0 +margin_right = 171.0 margin_bottom = 76.0 -hint_tooltip = "Sets the width of the isometric cell's axis aligned bounding box" -mouse_default_cursor_shape = 2 -min_value = 2.0 -max_value = 16384.0 -value = 16.0 -rounded = true -align = 2 -suffix = "px" +value = Vector2( 2, 2 ) +min_value = Vector2( 1, 1 ) +allow_greater = true +show_ratio = true +prefix_x = "Width:" +prefix_y = "Height:" +suffix_x = "px" +suffix_y = "px" -[node name="IsometricCellBoundsHeightLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] -margin_left = 341.0 -margin_top = 57.0 -margin_right = 529.0 -margin_bottom = 71.0 -hint_tooltip = "Sets the height of the isometric cell's axis aligned bounding box" +[node name="IsometricGridSizeLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] +margin_left = 175.0 +margin_top = 24.0 +margin_right = 346.0 +margin_bottom = 76.0 mouse_filter = 0 -text = "Isometric cell bounds height:" +size_flags_vertical = 1 +text = "Isometric grid size:" -[node name="IsometricCellBoundsHeightValue" type="SpinBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] +[node name="IsometricGridSizeValue" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions" instance=ExtResource( 7 )] +margin_left = 350.0 +margin_top = 24.0 +margin_right = 486.0 +margin_bottom = 76.0 +value = Vector2( 16, 8 ) +min_value = Vector2( 2, 2 ) +allow_greater = true +show_ratio = true +prefix_x = "Width:" +prefix_y = "Height:" +suffix_x = "px" +suffix_y = "px" + +[node name="GridOffsetLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] +margin_top = 99.0 +margin_right = 171.0 +margin_bottom = 113.0 +hint_tooltip = "Sets grid's offset from the canvas origin (top left corner of the image)" +mouse_filter = 0 +size_flags_vertical = 1 +text = "Grid offset:" + +[node name="GridOffsetValue" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions" instance=ExtResource( 7 )] +margin_left = 175.0 margin_top = 80.0 -margin_right = 183.0 -margin_bottom = 104.0 -hint_tooltip = "Sets the height of the isometric cell's axis aligned bounding box" -mouse_default_cursor_shape = 2 -min_value = 2.0 -max_value = 16384.0 -value = 8.0 -rounded = true -align = 2 -suffix = "px" - -[node name="GridOffsetXLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] -margin_left = 187.0 -margin_top = 85.0 -margin_right = 337.0 -margin_bottom = 99.0 -hint_tooltip = "Sets grid's x offset from the canvas origin (top left corner of the image)" -mouse_filter = 0 -text = "Grid offset x:" - -[node name="GridOffsetXValue" type="SpinBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] -margin_left = 341.0 -margin_top = 80.0 -margin_right = 529.0 -margin_bottom = 104.0 -hint_tooltip = "Sets grid's x offset from the canvas origin (top left corner of the image)" -mouse_default_cursor_shape = 2 -min_value = -16384.0 -max_value = 16384.0 -rounded = true -align = 2 -suffix = "px" - -[node name="GridOffsetYLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] -margin_top = 113.0 -margin_right = 183.0 -margin_bottom = 127.0 -hint_tooltip = "Sets grid's y offset from the canvas origin (top left corner of the image)" -mouse_filter = 0 -text = "Grid offset y:" - -[node name="GridOffsetYValue" type="SpinBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] -margin_left = 187.0 -margin_top = 108.0 -margin_right = 337.0 +margin_right = 346.0 margin_bottom = 132.0 -hint_tooltip = "Sets grid's y offset from the canvas origin (top left corner of the image)" -mouse_default_cursor_shape = 2 -min_value = -16384.0 -max_value = 16384.0 -rounded = true -align = 2 -suffix = "px" +hint_tooltip = "Sets grid's offset from the canvas origin (top left corner of the image)" +allow_greater = true +allow_lesser = true +suffix_x = "px" +suffix_y = "px" [node name="GridDrawOverTileModeLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] -margin_left = 341.0 -margin_top = 113.0 -margin_right = 529.0 -margin_bottom = 127.0 +margin_left = 350.0 +margin_top = 99.0 +margin_right = 486.0 +margin_bottom = 113.0 rect_min_size = Vector2( 110, 0 ) hint_tooltip = "If disabled, the grid will be drawn only over the original image" mouse_filter = 0 @@ -654,25 +587,25 @@ text = "Draw over Tile Mode:" [node name="GridDrawOverTileMode" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] margin_top = 136.0 -margin_right = 183.0 +margin_right = 171.0 margin_bottom = 160.0 hint_tooltip = "If disabled, the grid will be drawn only over the original image" mouse_default_cursor_shape = 2 text = "On" [node name="GridColorLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] -margin_left = 187.0 +margin_left = 175.0 margin_top = 141.0 -margin_right = 337.0 +margin_right = 346.0 margin_bottom = 155.0 hint_tooltip = "A color of the grid" mouse_filter = 0 text = "Grid color:" [node name="GridColor" type="ColorPickerButton" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/GridOptions"] -margin_left = 341.0 +margin_left = 350.0 margin_top = 136.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 160.0 rect_min_size = Vector2( 64, 20 ) hint_tooltip = "A color of the grid" @@ -680,7 +613,7 @@ mouse_default_cursor_shape = 2 [node name="PixelGridHeader" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas"] margin_top = 270.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 284.0 custom_constants/separation = 0 @@ -692,13 +625,13 @@ text = "Pixel Grid" [node name="HSeparator" type="HSeparator" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/PixelGridHeader"] margin_left = 62.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 14.0 size_flags_horizontal = 3 [node name="PixelGridOptions" type="GridContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas"] margin_top = 288.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 336.0 custom_constants/vseparation = 4 custom_constants/hseparation = 4 @@ -706,7 +639,7 @@ columns = 3 [node name="ShowAtZoomLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/PixelGridOptions"] margin_top = 5.0 -margin_right = 211.0 +margin_right = 190.0 margin_bottom = 19.0 rect_min_size = Vector2( 110, 0 ) hint_tooltip = "Sets the minimal zoom at which pixel grid will be shown" @@ -715,8 +648,8 @@ size_flags_horizontal = 3 text = "Show at zoom:" [node name="ShowAtZoom" type="SpinBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/PixelGridOptions"] -margin_left = 215.0 -margin_right = 426.0 +margin_left = 194.0 +margin_right = 383.0 margin_bottom = 24.0 rect_min_size = Vector2( 80, 0 ) hint_tooltip = "Sets the minimal zoom at which pixel grid will be shown" @@ -731,9 +664,9 @@ align = 2 suffix = "%" [node name="GridColorLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/PixelGridOptions"] -margin_left = 430.0 +margin_left = 387.0 margin_top = 5.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 19.0 hint_tooltip = "A color of the pixel grid" mouse_filter = 0 @@ -741,7 +674,7 @@ text = "Pixel grid color:" [node name="GridColor" type="ColorPickerButton" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/PixelGridOptions"] margin_top = 28.0 -margin_right = 211.0 +margin_right = 190.0 margin_bottom = 48.0 rect_min_size = Vector2( 64, 20 ) hint_tooltip = "A color of the pixel grid" @@ -749,7 +682,7 @@ mouse_default_cursor_shape = 2 [node name="TransparencyHeader" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas"] margin_top = 340.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 354.0 custom_constants/separation = 0 @@ -761,13 +694,13 @@ text = "Transparency" [node name="HSeparator" type="HSeparator" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/TransparencyHeader"] margin_left = 84.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 14.0 size_flags_horizontal = 3 [node name="CheckerOptions" type="GridContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas"] margin_top = 358.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 462.0 custom_constants/vseparation = 4 custom_constants/hseparation = 4 @@ -775,7 +708,7 @@ columns = 3 [node name="SizeLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/CheckerOptions"] margin_top = 5.0 -margin_right = 177.0 +margin_right = 162.0 margin_bottom = 19.0 rect_min_size = Vector2( 110, 0 ) hint_tooltip = "Size of the transparent checker background" @@ -784,8 +717,8 @@ size_flags_horizontal = 3 text = "Checker size:" [node name="CheckerSizeValue" type="SpinBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/CheckerOptions"] -margin_left = 181.0 -margin_right = 357.0 +margin_left = 166.0 +margin_right = 314.0 margin_bottom = 24.0 hint_tooltip = "Size of the transparent checker background" mouse_default_cursor_shape = 2 @@ -798,9 +731,9 @@ align = 2 suffix = "px" [node name="CheckerColor1Label" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/CheckerOptions"] -margin_left = 361.0 +margin_left = 318.0 margin_top = 5.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 19.0 hint_tooltip = "First color of the transparent checker background" mouse_filter = 0 @@ -808,7 +741,7 @@ text = "Checker color 1:" [node name="CheckerColor1" type="ColorPickerButton" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/CheckerOptions"] margin_top = 28.0 -margin_right = 177.0 +margin_right = 162.0 margin_bottom = 48.0 rect_min_size = Vector2( 64, 20 ) hint_tooltip = "First color of the transparent checker background" @@ -816,18 +749,18 @@ mouse_default_cursor_shape = 2 color = Color( 0.470588, 0.470588, 0.470588, 1 ) [node name="CheckerColor2Label" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/CheckerOptions"] -margin_left = 181.0 +margin_left = 166.0 margin_top = 31.0 -margin_right = 357.0 +margin_right = 314.0 margin_bottom = 45.0 hint_tooltip = "Second color of the transparent checker background" mouse_filter = 0 text = "Checker color 2:" [node name="CheckerColor2" type="ColorPickerButton" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/CheckerOptions"] -margin_left = 361.0 +margin_left = 318.0 margin_top = 28.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 48.0 rect_min_size = Vector2( 64, 20 ) hint_tooltip = "Second color of the transparent checker background" @@ -836,49 +769,49 @@ color = Color( 0.341176, 0.34902, 0.341176, 1 ) [node name="Label" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/CheckerOptions"] margin_top = 57.0 -margin_right = 177.0 +margin_right = 162.0 margin_bottom = 71.0 rect_min_size = Vector2( 110, 0 ) text = "Follow Canvas Movement" [node name="CheckerFollowMovement" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/CheckerOptions"] -margin_left = 181.0 +margin_left = 166.0 margin_top = 52.0 -margin_right = 357.0 +margin_right = 314.0 margin_bottom = 76.0 hint_tooltip = "The transparent checker follow the movement of canvas" mouse_default_cursor_shape = 2 text = "On" [node name="Label2" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/CheckerOptions"] -margin_left = 361.0 +margin_left = 318.0 margin_top = 57.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 71.0 rect_min_size = Vector2( 110, 0 ) text = "Follow Canvas Zoom Level" [node name="CheckerFollowScale" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/CheckerOptions"] margin_top = 80.0 -margin_right = 177.0 +margin_right = 162.0 margin_bottom = 104.0 hint_tooltip = "The transparent checker follow the zoom level of canvas" mouse_default_cursor_shape = 2 text = "On" [node name="Label3" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/CheckerOptions"] -margin_left = 181.0 +margin_left = 166.0 margin_top = 85.0 -margin_right = 357.0 +margin_right = 314.0 margin_bottom = 99.0 rect_min_size = Vector2( 110, 0 ) mouse_filter = 0 text = "Tile mode opacity:" [node name="TileModeOpacity" type="SpinBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/CheckerOptions"] -margin_left = 361.0 +margin_left = 318.0 margin_top = 80.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 104.0 mouse_default_cursor_shape = 2 max_value = 1.0 @@ -888,7 +821,7 @@ align = 2 [node name="BackgroundHeader" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas"] margin_top = 466.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 480.0 custom_constants/separation = 0 @@ -900,13 +833,13 @@ text = "Background" [node name="HSeparator" type="HSeparator" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/BackgroundHeader"] margin_left = 74.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 14.0 size_flags_horizontal = 3 [node name="BackgroundOptions" type="GridContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas"] margin_top = 484.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 528.0 custom_constants/vseparation = 4 custom_constants/hseparation = 4 @@ -914,7 +847,7 @@ columns = 3 [node name="ColorFromLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/BackgroundOptions"] margin_top = 3.0 -margin_right = 204.0 +margin_right = 182.0 margin_bottom = 17.0 rect_min_size = Vector2( 110, 0 ) mouse_filter = 0 @@ -922,8 +855,8 @@ size_flags_horizontal = 3 text = "Background color from:" [node name="ColorOptionButton" type="OptionButton" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/BackgroundOptions"] -margin_left = 208.0 -margin_right = 411.0 +margin_left = 186.0 +margin_right = 368.0 margin_bottom = 20.0 mouse_default_cursor_shape = 2 size_flags_horizontal = 3 @@ -932,16 +865,16 @@ items = [ "Theme", null, false, 0, null, "Custom", null, false, 1, null ] selected = 0 [node name="ColorLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/BackgroundOptions"] -margin_left = 415.0 +margin_left = 372.0 margin_top = 3.0 -margin_right = 529.0 +margin_right = 486.0 margin_bottom = 17.0 mouse_filter = 0 text = "Background color:" [node name="BackgroundColor" type="ColorPickerButton" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Canvas/BackgroundOptions"] margin_top = 24.0 -margin_right = 204.0 +margin_right = 182.0 margin_bottom = 44.0 rect_min_size = Vector2( 64, 20 ) mouse_default_cursor_shape = 2 diff --git a/src/Tools/BaseTool.gd b/src/Tools/BaseTool.gd index 12d48bc6f..cb2f454ab 100644 --- a/src/Tools/BaseTool.gd +++ b/src/Tools/BaseTool.gd @@ -124,21 +124,19 @@ func draw_preview() -> void: func snap_position(position: Vector2) -> Vector2: var snapping_distance := Global.snapping_distance * Global.camera.zoom.x if Global.snap_to_rectangular_grid: - var grid_size := Vector2(Global.grid_width, Global.grid_height) - var grid_offset := Vector2(Global.grid_offset_x, Global.grid_offset_y) - var grid_pos := position.snapped(grid_size) - grid_pos += grid_offset + var grid_pos := position.snapped(Global.grid_size) + grid_pos += Global.grid_offset # keeping grid_pos as is would have been fine but this adds extra accuracy as to # which snap point (from the list below) is closest to mouse and occupy THAT point - var t_l := grid_pos + Vector2(-grid_size.x, -grid_size.y) - var t_c := grid_pos + Vector2(0, -grid_size.y) # t_c is for "top centre" and so on - var t_r := grid_pos + Vector2(grid_size.x, -grid_size.y) - var m_l := grid_pos + Vector2(-grid_size.x, 0) + var t_l := grid_pos + Vector2(-Global.grid_size.x, -Global.grid_size.y) + var t_c := grid_pos + Vector2(0, -Global.grid_size.y) # t_c is for "top centre" and so on + var t_r := grid_pos + Vector2(Global.grid_size.x, -Global.grid_size.y) + var m_l := grid_pos + Vector2(-Global.grid_size.x, 0) var m_c := grid_pos - var m_r := grid_pos + Vector2(grid_size.x, 0) - var b_l := grid_pos + Vector2(-grid_size.x, grid_size.y) - var b_c := grid_pos + Vector2(0, grid_size.y) - var b_r := grid_pos + Vector2(grid_size.x, grid_size.y) + var m_r := grid_pos + Vector2(Global.grid_size.x, 0) + var b_l := grid_pos + Vector2(-Global.grid_size.x, Global.grid_size.y) + var b_c := grid_pos + Vector2(0, Global.grid_size.y) + var b_r := grid_pos + Global.grid_size var vec_arr := [t_l, t_c, t_r, m_l, m_c, m_r, b_l, b_c, b_r] for vec in vec_arr: if vec.distance_to(position) < grid_pos.distance_to(position): diff --git a/src/Tools/Move.gd b/src/Tools/Move.gd index ff9521582..32b60d128 100644 --- a/src/Tools/Move.gd +++ b/src/Tools/Move.gd @@ -13,28 +13,27 @@ onready var selection_node: Node2D = Global.canvas.selection func _input(event: InputEvent) -> void: - if _start_pos != Vector2.INF: - if event.is_action_pressed("transform_snap_grid"): - _snap_to_grid = true - var grid_size := Vector2(Global.grid_width, Global.grid_height) - _offset = _offset.snapped(grid_size) - if Global.current_project.has_selection: - if selection_node.is_moving_content: - var prev_pos: Vector2 = selection_node.big_bounding_rectangle.position - selection_node.big_bounding_rectangle.position = prev_pos.snapped(grid_size) - # The first time transform_snap_grid is enabled then _snap_position() is not called - # and the selection had wrong offset, so do selection offsetting here - var grid_offset := Vector2(Global.grid_offset_x, Global.grid_offset_y) - grid_offset = Vector2( - fmod(grid_offset.x, grid_size.x), fmod(grid_offset.y, grid_size.y) - ) - selection_node.big_bounding_rectangle.position += grid_offset - selection_node.marching_ants_outline.offset += ( - selection_node.big_bounding_rectangle.position - - prev_pos - ) - elif event.is_action_released("transform_snap_grid"): - _snap_to_grid = false + if _start_pos == Vector2.INF: + return + if event.is_action_pressed("transform_snap_grid"): + _snap_to_grid = true + _offset = _offset.snapped(Global.grid_size) + if Global.current_project.has_selection and selection_node.is_moving_content: + var prev_pos: Vector2 = selection_node.big_bounding_rectangle.position + selection_node.big_bounding_rectangle.position = prev_pos.snapped(Global.grid_size) + # The first time transform_snap_grid is enabled then _snap_position() is not called + # and the selection had wrong offset, so do selection offsetting here + var grid_offset := Global.grid_offset + grid_offset = Vector2( + fmod(grid_offset.x, Global.grid_size.x), fmod(grid_offset.y, Global.grid_size.y) + ) + selection_node.big_bounding_rectangle.position += grid_offset + selection_node.marching_ants_outline.offset += ( + selection_node.big_bounding_rectangle.position + - prev_pos + ) + elif event.is_action_released("transform_snap_grid"): + _snap_to_grid = false func draw_start(position: Vector2) -> void: @@ -103,19 +102,18 @@ func _snap_position(position: Vector2) -> Vector2: else: position.x = _start_pos.x if _snap_to_grid: # Snap to grid - var grid_size := Vector2(Global.grid_width, Global.grid_height) - position = position.snapped(grid_size) + position = position.snapped(Global.grid_size) # The part below only corrects the offset for situations when there is no selection # Offsets when there is selection is controlled in _input() function if !Global.current_project.has_selection: var move_offset := Vector2.ZERO move_offset.x = ( _start_pos.x - - int(_start_pos.x / Global.grid_width) * Global.grid_width + - int(_start_pos.x / Global.grid_size.x) * Global.grid_size.x ) move_offset.y = ( _start_pos.y - - int(_start_pos.y / Global.grid_height) * Global.grid_height + - int(_start_pos.y / Global.grid_size.y) * Global.grid_size.y ) position += move_offset diff --git a/src/Tools/SelectionTools/SelectionTool.gd b/src/Tools/SelectionTools/SelectionTool.gd index 148524b72..d3f125592 100644 --- a/src/Tools/SelectionTools/SelectionTool.gd +++ b/src/Tools/SelectionTools/SelectionTool.gd @@ -165,17 +165,18 @@ func draw_move(position: Vector2) -> void: else: position.x = _start_pos.x if Input.is_action_pressed("transform_snap_grid"): - var grid_size := Vector2(Global.grid_width, Global.grid_height) - _offset = _offset.snapped(grid_size) - var prev_pos = selection_node.big_bounding_rectangle.position - selection_node.big_bounding_rectangle.position = prev_pos.snapped(grid_size) + _offset = _offset.snapped(Global.grid_size) + var prev_pos: Vector2 = selection_node.big_bounding_rectangle.position + selection_node.big_bounding_rectangle.position = prev_pos.snapped(Global.grid_size) selection_node.marching_ants_outline.offset += ( selection_node.big_bounding_rectangle.position - prev_pos ) - position = position.snapped(grid_size) - var grid_offset := Vector2(Global.grid_offset_x, Global.grid_offset_y) - grid_offset = Vector2(fmod(grid_offset.x, grid_size.x), fmod(grid_offset.y, grid_size.y)) + position = position.snapped(Global.grid_size) + var grid_offset := Global.grid_offset + grid_offset = Vector2( + fmod(grid_offset.x, Global.grid_size.x), fmod(grid_offset.y, Global.grid_size.y) + ) position += grid_offset if _move_content: diff --git a/src/UI/Canvas/Grid.gd b/src/UI/Canvas/Grid.gd index a5e9f13e7..e1c518a67 100644 --- a/src/UI/Canvas/Grid.gd +++ b/src/UI/Canvas/Grid.gd @@ -30,21 +30,21 @@ func _draw_cartesian_grid(target_rect: Rect2) -> void: var x: float = ( target_rect.position.x - + fposmod(Global.grid_offset_x - target_rect.position.x, Global.grid_width) + + fposmod(Global.grid_offset.x - target_rect.position.x, Global.grid_size.x) ) while x <= target_rect.end.x: grid_multiline_points.push_back(Vector2(x, target_rect.position.y)) grid_multiline_points.push_back(Vector2(x, target_rect.end.y)) - x += Global.grid_width + x += Global.grid_size.x var y: float = ( target_rect.position.y - + fposmod(Global.grid_offset_y - target_rect.position.y, Global.grid_height) + + fposmod(Global.grid_offset.y - target_rect.position.y, Global.grid_size.y) ) while y <= target_rect.end.y: grid_multiline_points.push_back(Vector2(target_rect.position.x, y)) grid_multiline_points.push_back(Vector2(target_rect.end.x, y)) - y += Global.grid_height + y += Global.grid_size.y if not grid_multiline_points.empty(): draw_multiline(grid_multiline_points, Global.grid_color) @@ -57,13 +57,9 @@ func _draw_isometric_grid(target_rect: Rect2) -> void: # It will be converted to PoolVector2Array before being sent to be rendered. var grid_multiline_points := [] - var cell_size := Vector2( - Global.grid_isometric_cell_bounds_width, Global.grid_isometric_cell_bounds_height - ) + var cell_size := Global.isometric_grid_size var max_cell_count: Vector2 = target_rect.size / cell_size - - var origin := Vector2(Global.grid_offset_x, Global.grid_offset_y) - var origin_offset: Vector2 = (origin - target_rect.position).posmodv(cell_size) + var origin_offset: Vector2 = (Global.grid_offset - target_rect.position).posmodv(cell_size) # lines ↗↗↗ (from bottom-left to top-right) var per_cell_offset := cell_size * Vector2(1, -1) diff --git a/src/UI/Canvas/Selection.gd b/src/UI/Canvas/Selection.gd index 5fa2074d4..234ae0bdf 100644 --- a/src/UI/Canvas/Selection.gd +++ b/src/UI/Canvas/Selection.gd @@ -192,7 +192,7 @@ func _move_with_arrow_keys(event: InputEvent) -> void: if _is_action_direction(event) and arrow_key_move: var step := Vector2.ONE if Input.is_key_pressed(KEY_CONTROL): - step = Vector2(Global.grid_width, Global.grid_height) + step = Global.grid_size var input := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down") var move := input.rotated(stepify(Global.camera.rotation, PI / 2)) # These checks are needed to fix a bug where the selection got stuck