From 2318cb38c4572fb365b011f0d117f2d1ab17750c Mon Sep 17 00:00:00 2001 From: Anish Mishra Date: Sat, 17 May 2025 21:13:32 +0530 Subject: [PATCH] Ready for alpha 2 release --- .github/workflows/build.yml | 2 +- src/config_classes/SaveData.gd | 4 ++-- src/ui_parts/handles_manager.gd | 8 +++++--- src/ui_parts/tab_bar.gd | 14 +++++++------- src/ui_widgets/camera.gd | 8 +++++--- src/ui_widgets/points_field.tscn | 6 +++--- src/ui_widgets/zoom_menu.gd | 18 +++++++++++++++--- src/ui_widgets/zoom_menu.tscn | 13 +++++-------- 8 files changed, 43 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8f360b1..f4b8a1a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ env: # Used in the editor config file name. Do not change this for patch releases. GODOT_FEATURE_VERSION: 4.4 # Commit hash - GODOT_COMMIT_HASH: daa4b058ee9272dd4ee9033bb093afb21ad558b7 + GODOT_COMMIT_HASH: 49a5bc7b6 PROJECT_NAME: GodSVG Mobile BUILD_OPTIONS: target=template_release lto=full production=yes deprecated=no minizip=no brotli=no vulkan=no openxr=no use_volk=no disable_3d=yes modules_enabled_by_default=no module_freetype_enabled=yes module_gdscript_enabled=yes module_svg_enabled=yes module_jpg_enabled=yes module_text_server_adv_enabled=yes graphite=no module_webp_enabled=yes module_mbedtls_enabled=yes swappy=no build_profile=../godsvg/.github/disabled_classes.build GODOT_REPO: https://github.com/godotengine/godot.git diff --git a/src/config_classes/SaveData.gd b/src/config_classes/SaveData.gd index 4664f0a..35db893 100644 --- a/src/config_classes/SaveData.gd +++ b/src/config_classes/SaveData.gd @@ -711,7 +711,7 @@ func remove_tab(idx: int) -> void: if idx < _active_tab_index: new_active_tab_index -= 1 - # Clear unnecessary files. + # Clear unnecessary files. This will clear the removed tab too. var used_file_paths := PackedStringArray() for tab in _tabs: used_file_paths.append(tab.get_edited_file_path()) @@ -720,7 +720,7 @@ func remove_tab(idx: int) -> void: for file_name in DirAccess.get_files_at(TabData.EDITED_FILES_DIR): var full_path := TabData.EDITED_FILES_DIR.path_join(file_name) if not full_path in used_file_paths: - DirAccess.remove_absolute(TabData.EDITED_FILES_DIR.path_join(file_name)) + DirAccess.remove_absolute(full_path) if _tabs.is_empty(): _add_new_tab() diff --git a/src/ui_parts/handles_manager.gd b/src/ui_parts/handles_manager.gd index 0b18a26..ddd0ee9 100644 --- a/src/ui_parts/handles_manager.gd +++ b/src/ui_parts/handles_manager.gd @@ -95,13 +95,15 @@ func _ready() -> void: State.hover_changed.connect(queue_redraw) State.zoom_changed.connect(queue_redraw) State.handle_added.connect(_on_handle_added) - State.show_handles_changed.connect(toggle_visibility) State.view_changed.connect(_on_view_changed) queue_update_handles() + + State.show_handles_changed.connect(update_show_handles) + update_show_handles() -func toggle_visibility() -> void: - visible = not visible +func update_show_handles() -> void: + visible = State.show_handles HandlerGUI.throw_mouse_motion_event() func queue_update_handles() -> void: diff --git a/src/ui_parts/tab_bar.gd b/src/ui_parts/tab_bar.gd index 7824fb9..8e9b54a 100644 --- a/src/ui_parts/tab_bar.gd +++ b/src/ui_parts/tab_bar.gd @@ -412,21 +412,21 @@ func _get_tooltip(at_position: Vector2) -> String: return "" - var current_tab := Configs.savedata.get_tab(hovered_tab_idx) + var hovered_tab := Configs.savedata.get_tab(hovered_tab_idx) # We have to pass some metadata to the tooltip. # Since "*" isn't valid in filepaths, we use it as a delimiter. if hovered_tab_idx == Configs.savedata.get_active_tab_index(): - return "%s*active" % current_tab.get_presented_svg_file_path() + return "%s*active" % hovered_tab.get_presented_svg_file_path() - return "%s*%d" % [current_tab.get_presented_svg_file_path(), current_tab.id] + return "%s*%d" % [hovered_tab.get_presented_svg_file_path(), hovered_tab.id] func _make_custom_tooltip(for_text: String) -> Object: var asterisk_pos := for_text.find("*") if asterisk_pos == -1: return null - var current_tab := Configs.savedata.get_tab(get_hovered_index()) - var is_saved := not current_tab.svg_file_path.is_empty() + var hovered_tab := Configs.savedata.get_tab(get_hovered_index()) + var is_saved := not hovered_tab.svg_file_path.is_empty() var path := for_text.left(asterisk_pos) var label := Label.new() @@ -438,9 +438,9 @@ func _make_custom_tooltip(for_text: String) -> Object: Translator.translate("This SVG is not bound to a file location yet.") Utils.set_max_text_width(label, 192.0, 4.0) - # If the tab is active, no need for an SVG preview. + # If the tab is active or empty, no need for an SVG preview. var metadata := for_text.right(-asterisk_pos - 1) - if metadata == "active": + if metadata == "active" or hovered_tab.empty_unsaved: return label var id := metadata.to_int() diff --git a/src/ui_widgets/camera.gd b/src/ui_widgets/camera.gd index 498b1f7..9bc1caf 100644 --- a/src/ui_widgets/camera.gd +++ b/src/ui_widgets/camera.gd @@ -25,7 +25,9 @@ func _ready() -> void: State.svg_resized.connect(queue_redraw) State.zoom_changed.connect(change_zoom) State.zoom_changed.connect(queue_redraw) - State.show_grid_changed.connect(toggle_visibility) + + State.show_grid_changed.connect(update_show_grid) + update_show_grid() func exit_tree() -> void: RenderingServer.free_rid(surface) @@ -33,8 +35,8 @@ func exit_tree() -> void: func change_zoom() -> void: zoom = State.zoom -func toggle_visibility() -> void: - visible = not visible +func update_show_grid() -> void: + visible = State.show_grid func update() -> void: diff --git a/src/ui_widgets/points_field.tscn b/src/ui_widgets/points_field.tscn index 8e254e0..5bf1b2f 100644 --- a/src/ui_widgets/points_field.tscn +++ b/src/ui_widgets/points_field.tscn @@ -4,13 +4,13 @@ [ext_resource type="Script" uid="uid://1hox6gd5pxku" path="res://src/ui_widgets/BetterLineEdit.gd" id="2_4uivs"] [node name="PointsField" type="VBoxContainer"] -offset_right = 358.0 +offset_right = 300.0 offset_bottom = 45.0 theme_override_constants/separation = 2 script = ExtResource("1_pnk5w") [node name="LineEdit" type="LineEdit" parent="."] -custom_minimum_size = Vector2(358, 0) +custom_minimum_size = Vector2(300, 0) layout_mode = 2 size_flags_horizontal = 0 focus_mode = 1 @@ -18,6 +18,6 @@ script = ExtResource("2_4uivs") mono_font_tooltip = true [node name="Points" type="Control" parent="."] -custom_minimum_size = Vector2(344, 0) +custom_minimum_size = Vector2(295, 0) layout_mode = 2 size_flags_horizontal = 8 diff --git a/src/ui_widgets/zoom_menu.gd b/src/ui_widgets/zoom_menu.gd index 5d5a80d..146da5f 100644 --- a/src/ui_widgets/zoom_menu.gd +++ b/src/ui_widgets/zoom_menu.gd @@ -6,9 +6,9 @@ const MAX_ZOOM = 512.0 signal zoom_changed(zoom_level: float, offset: Vector2) signal zoom_reset_pressed -@onready var zoom_out_button: BetterButton = $ZoomOut -@onready var zoom_in_button: BetterButton = $ZoomIn -@onready var zoom_reset_button: BetterButton = $ZoomReset +@onready var zoom_out_button: Button = $ZoomOut +@onready var zoom_in_button: Button = $ZoomIn +@onready var zoom_reset_button: Button = $ZoomReset var _zoom_level: float @@ -71,3 +71,15 @@ func update_buttons_appearance() -> void: zoom_out_button.disabled = is_min_zoom zoom_out_button.mouse_default_cursor_shape = Control.CURSOR_ARROW if\ is_min_zoom else Control.CURSOR_POINTING_HAND + + +func _on_zoom_out_pressed() -> void: + HandlerGUI.throw_action_event("zoom_out") + + +func _on_zoom_reset_pressed() -> void: + HandlerGUI.throw_action_event("zoom_reset") + + +func _on_zoom_in_pressed() -> void: + HandlerGUI.throw_action_event("zoom_in") diff --git a/src/ui_widgets/zoom_menu.tscn b/src/ui_widgets/zoom_menu.tscn index eec4f27..987b8b4 100644 --- a/src/ui_widgets/zoom_menu.tscn +++ b/src/ui_widgets/zoom_menu.tscn @@ -1,9 +1,8 @@ -[gd_scene load_steps=5 format=3 uid="uid://oltvrf01xrxl"] +[gd_scene load_steps=4 format=3 uid="uid://oltvrf01xrxl"] [ext_resource type="Texture2D" uid="uid://c2h5snkvemm4p" path="res://assets/icons/Minus.svg" id="1_8ggy2"] [ext_resource type="Script" uid="uid://dj2q7wnto3uqp" path="res://src/ui_widgets/zoom_menu.gd" id="1_18ab8"] [ext_resource type="Texture2D" uid="uid://eif2ioi0mw17" path="res://assets/icons/Plus.svg" id="2_284x5"] -[ext_resource type="Script" uid="uid://ynx3s1jc6bwq" path="res://src/ui_widgets/BetterButton.gd" id="3_vgfv3"] [node name="ZoomMenu" type="HBoxContainer"] offset_right = 114.0 @@ -18,8 +17,6 @@ mouse_default_cursor_shape = 2 theme_type_variation = &"IconButton" icon = ExtResource("1_8ggy2") icon_alignment = 1 -script = ExtResource("3_vgfv3") -action = "zoom_out" [node name="ZoomReset" type="Button" parent="."] custom_minimum_size = Vector2(58, 0) @@ -27,8 +24,6 @@ layout_mode = 2 focus_mode = 0 mouse_default_cursor_shape = 2 text = "100%" -script = ExtResource("3_vgfv3") -action = "zoom_reset" [node name="ZoomIn" type="Button" parent="."] layout_mode = 2 @@ -37,5 +32,7 @@ mouse_default_cursor_shape = 2 theme_type_variation = &"IconButton" icon = ExtResource("2_284x5") icon_alignment = 1 -script = ExtResource("3_vgfv3") -action = "zoom_in" + +[connection signal="pressed" from="ZoomOut" to="." method="_on_zoom_out_pressed"] +[connection signal="pressed" from="ZoomReset" to="." method="_on_zoom_reset_pressed"] +[connection signal="pressed" from="ZoomIn" to="." method="_on_zoom_in_pressed"]