From 90ac30dd891cfca779c5126333f19c9051768fc9 Mon Sep 17 00:00:00 2001 From: Nordup Date: Fri, 25 Oct 2024 05:27:49 +0400 Subject: [PATCH] windowed mode, initial screen settings --- app/assets/textures/minimize.svg | 39 +++++++ app/assets/textures/minimize.svg.import | 37 ++++++ app/project.godot | 6 +- app/scenes/app.tscn | 23 ---- app/scenes/menu.tscn | 146 ++++++++++++++++++------ app/scenes/menu_body/world.tscn | 1 + app/scripts/ui/menu/exit_app.gd | 5 - app/scripts/ui/menu/menu.gd | 14 +++ app/scripts/ui/menu/window_buttons.gd | 17 +++ app/scripts/ui/world/splash_screen.gd | 6 + app/scripts/ui/world/world_canvas.gd | 2 +- godot | 2 +- 12 files changed, 233 insertions(+), 65 deletions(-) create mode 100644 app/assets/textures/minimize.svg create mode 100644 app/assets/textures/minimize.svg.import delete mode 100644 app/scripts/ui/menu/exit_app.gd create mode 100644 app/scripts/ui/menu/window_buttons.gd diff --git a/app/assets/textures/minimize.svg b/app/assets/textures/minimize.svg new file mode 100644 index 0000000..d3fb980 --- /dev/null +++ b/app/assets/textures/minimize.svg @@ -0,0 +1,39 @@ + + + + + + diff --git a/app/assets/textures/minimize.svg.import b/app/assets/textures/minimize.svg.import new file mode 100644 index 0000000..5398e77 --- /dev/null +++ b/app/assets/textures/minimize.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ba0x5hoq2ihbh" +path="res://.godot/imported/minimize.svg-da0875c5f49c7e85702b1ddd89b760c9.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/textures/minimize.svg" +dest_files=["res://.godot/imported/minimize.svg-da0875c5f49c7e85702b1ddd89b760c9.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=7.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/app/project.godot b/app/project.godot index cb938d8..eb126f3 100644 --- a/app/project.godot +++ b/app/project.godot @@ -16,7 +16,7 @@ config/tags=PackedStringArray("thegates") run/main_scene="res://scenes/app.tscn" config/features=PackedStringArray("4.3") run/max_fps=144 -boot_splash/bg_color=Color(0.156863, 0.156863, 0.156863, 1) +boot_splash/bg_color=Color(0, 0, 0, 0) boot_splash/show_image=false config/icon="res://app_icon/icon.svg" config/windows_native_icon="res://app_icon/toolbar_icon.ico" @@ -41,10 +41,12 @@ gdscript/warnings/integer_division=0 window/size/viewport_width=1920 window/size/viewport_height=1080 -window/size/mode=4 +window/size/mode=2 window/size/borderless=true +window/size/transparent=true window/stretch/mode="canvas_items" window/stretch/aspect="expand" +window/per_pixel_transparency/allowed=true window/vsync/vsync_mode=3 [gui] diff --git a/app/scenes/app.tscn b/app/scenes/app.tscn index 2b4b141..6a840af 100644 --- a/app/scenes/app.tscn +++ b/app/scenes/app.tscn @@ -69,28 +69,5 @@ bookmarks = ExtResource("6_rupvx") [node name="Menu" parent="." instance=ExtResource("3_o1f7b")] -[node name="GoBack" parent="Menu/VBoxContainer/Top/MenuNavigation" index="0"] -physics_interpolation_mode = 2 -auto_translate_mode = 1 - -[node name="GoForward" parent="Menu/VBoxContainer/Top/MenuNavigation" index="1"] -physics_interpolation_mode = 2 -auto_translate_mode = 1 - -[node name="Reload" parent="Menu/VBoxContainer/Top/MenuNavigation" index="2"] -physics_interpolation_mode = 2 -auto_translate_mode = 1 - -[node name="Search" parent="Menu/VBoxContainer/Top/MenuNavigation" index="3"] -auto_translate_mode = 2 - -[node name="Home" parent="Menu/VBoxContainer/Top/MenuNavigation" index="4"] -physics_interpolation_mode = 2 -auto_translate_mode = 1 - -[node name="Exit" parent="Menu/VBoxContainer/Top" index="2"] -physics_interpolation_mode = 2 -auto_translate_mode = 1 - [editable path="Debug"] [editable path="Menu"] diff --git a/app/scenes/menu.tscn b/app/scenes/menu.tscn index 275a131..4eeaf08 100644 --- a/app/scenes/menu.tscn +++ b/app/scenes/menu.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=19 format=3 uid="uid://5btb7nvgmfhl"] +[gd_scene load_steps=20 format=3 uid="uid://5btb7nvgmfhl"] [ext_resource type="Script" path="res://scripts/ui/menu/menu_navigation.gd" id="1_7anvm"] [ext_resource type="Texture2D" uid="uid://8wvea7j0v0rx" path="res://assets/textures/Reload.svg" id="1_d6dhb"] @@ -8,10 +8,11 @@ [ext_resource type="Resource" uid="uid://b1xvdym0qh6td" path="res://resources/gate_events.res" id="3_m632k"] [ext_resource type="Resource" uid="uid://bqgikyax6jfqa" path="res://resources/history.tres" id="3_wi554"] [ext_resource type="Texture2D" uid="uid://bmju020v33vrv" path="res://assets/textures/home.svg" id="4_5npup"] -[ext_resource type="Script" path="res://scripts/ui/menu/exit_app.gd" id="4_2065t"] [ext_resource type="PackedScene" uid="uid://ctam0fxigbefk" path="res://scenes/components/search.tscn" id="5_li2do"] [ext_resource type="Script" path="res://scripts/ui/fullscreen_animation.gd" id="7_1hi62"] [ext_resource type="Resource" uid="uid://crjhix0osmtnf" path="res://resources/ui_events.res" id="8_8dnbq"] +[ext_resource type="Script" path="res://scripts/ui/menu/window_buttons.gd" id="10_0d0if"] +[ext_resource type="Texture2D" uid="uid://ba0x5hoq2ihbh" path="res://assets/textures/minimize.svg" id="11_36jpg"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_pveoh"] bg_color = Color(0.156863, 0.156863, 0.156863, 1) @@ -48,7 +49,7 @@ tracks/1/keys = { tracks/2/type = "value" tracks/2/imported = false tracks/2/enabled = true -tracks/2/path = NodePath("VBoxContainer/Top/Exit:modulate") +tracks/2/path = NodePath("VBoxContainer/Top/WindowButtons:modulate") tracks/2/interp = 1 tracks/2/loop_wrap = true tracks/2/keys = { @@ -89,7 +90,7 @@ tracks/1/keys = { tracks/2/type = "value" tracks/2/imported = false tracks/2/enabled = true -tracks/2/path = NodePath("VBoxContainer/Top/Exit:modulate") +tracks/2/path = NodePath("VBoxContainer/Top/WindowButtons:modulate") tracks/2/interp = 1 tracks/2/loop_wrap = true tracks/2/keys = { @@ -130,7 +131,7 @@ tracks/1/keys = { tracks/2/type = "value" tracks/2/imported = false tracks/2/enabled = true -tracks/2/path = NodePath("VBoxContainer/Top/Exit:modulate") +tracks/2/path = NodePath("VBoxContainer/Top/WindowButtons:modulate") tracks/2/interp = 1 tracks/2/loop_wrap = true tracks/2/keys = { @@ -214,6 +215,8 @@ process_mode = 0 process_priority = 0 process_physics_priority = 0 process_thread_group = 0 +physics_interpolation_mode = 2 +auto_translate_mode = 1 editor_description = "" visible = true modulate = Color(1, 1, 1, 1) @@ -237,7 +240,6 @@ layout_mode = 2 size_flags_horizontal = 8 size_flags_vertical = 4 size_flags_stretch_ratio = 1.0 -auto_translate = true localize_numeral_system = true tooltip_text = "" focus_neighbor_left = NodePath("") @@ -285,6 +287,8 @@ process_mode = 0 process_priority = 0 process_physics_priority = 0 process_thread_group = 0 +physics_interpolation_mode = 2 +auto_translate_mode = 1 editor_description = "" visible = true modulate = Color(1, 1, 1, 1) @@ -308,7 +312,6 @@ layout_mode = 2 size_flags_horizontal = 8 size_flags_vertical = 4 size_flags_stretch_ratio = 1.0 -auto_translate = true localize_numeral_system = true tooltip_text = "" focus_neighbor_left = NodePath("") @@ -354,6 +357,8 @@ process_mode = 0 process_priority = 0 process_physics_priority = 0 process_thread_group = 0 +physics_interpolation_mode = 2 +auto_translate_mode = 1 editor_description = "" visible = true modulate = Color(1, 1, 1, 1) @@ -377,7 +382,6 @@ layout_mode = 2 size_flags_horizontal = 8 size_flags_vertical = 4 size_flags_stretch_ratio = 1.0 -auto_translate = true localize_numeral_system = true tooltip_text = "" focus_neighbor_left = NodePath("") @@ -417,6 +421,7 @@ texture = ExtResource("1_d6dhb") expand_mode = 1 [node name="Search" parent="VBoxContainer/Top/MenuNavigation" instance=ExtResource("5_li2do")] +auto_translate_mode = 2 layout_mode = 2 size_flags_horizontal = 4 size_flags_vertical = 4 @@ -428,6 +433,8 @@ process_mode = 0 process_priority = 0 process_physics_priority = 0 process_thread_group = 0 +physics_interpolation_mode = 2 +auto_translate_mode = 1 editor_description = "" visible = true modulate = Color(1, 1, 1, 1) @@ -451,7 +458,6 @@ layout_mode = 2 size_flags_horizontal = 8 size_flags_vertical = 4 size_flags_stretch_ratio = 1.0 -auto_translate = true localize_numeral_system = true tooltip_text = "" focus_neighbor_left = NodePath("") @@ -490,15 +496,36 @@ size_flags_vertical = 4 texture = ExtResource("4_5npup") expand_mode = 1 -[node name="Exit" type="BaseButton" parent="VBoxContainer/Top"] +[node name="WindowButtons" type="HBoxContainer" parent="VBoxContainer/Top" node_paths=PackedStringArray("minimize", "exit")] +layout_mode = 1 +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -40.0 +offset_top = -10.0 +offset_right = -20.0 +offset_bottom = 10.0 +grow_horizontal = 0 +grow_vertical = 2 +theme_override_constants/separation = 20 +alignment = 2 +script = ExtResource("10_0d0if") +minimize = NodePath("Minimize") +exit = NodePath("Exit") + +[node name="Minimize" type="BaseButton" parent="VBoxContainer/Top/WindowButtons"] _import_path = NodePath("") unique_name_in_owner = false process_mode = 0 process_priority = 0 process_physics_priority = 0 process_thread_group = 0 +physics_interpolation_mode = 2 +auto_translate_mode = 1 editor_description = "" -visible = true +visible = false modulate = Color(1, 1, 1, 1) self_modulate = Color(1, 1, 1, 1) show_behind_parent = false @@ -514,27 +541,12 @@ texture_repeat = 0 material = null use_parent_material = false clip_contents = false -custom_minimum_size = Vector2(0, 0) +custom_minimum_size = Vector2(20, 20) layout_direction = 0 -layout_mode = 1 -anchors_preset = 6 -anchor_left = 1.0 -anchor_top = 0.5 -anchor_right = 1.0 -anchor_bottom = 0.5 -offset_left = -40.0 -offset_top = -10.0 -offset_right = -20.0 -offset_bottom = 10.0 -grow_horizontal = 0 -grow_vertical = 2 -rotation = 0.0 -scale = Vector2(1, 1) -pivot_offset = Vector2(0, 0) -size_flags_horizontal = 1 +layout_mode = 2 +size_flags_horizontal = 3 size_flags_vertical = 1 size_flags_stretch_ratio = 1.0 -auto_translate = true localize_numeral_system = true tooltip_text = "" focus_neighbor_left = NodePath("") @@ -559,9 +571,79 @@ button_group = null shortcut = null shortcut_feedback = true shortcut_in_tooltip = true -script = ExtResource("4_2065t") +script = null -[node name="TextureRect" type="TextureRect" parent="VBoxContainer/Top/Exit"] +[node name="TextureRect" type="TextureRect" parent="VBoxContainer/Top/WindowButtons/Minimize"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 4 +size_flags_vertical = 4 +texture = ExtResource("11_36jpg") +expand_mode = 1 + +[node name="Exit" type="BaseButton" parent="VBoxContainer/Top/WindowButtons"] +_import_path = NodePath("") +unique_name_in_owner = false +process_mode = 0 +process_priority = 0 +process_physics_priority = 0 +process_thread_group = 0 +physics_interpolation_mode = 2 +auto_translate_mode = 1 +editor_description = "" +visible = true +modulate = Color(1, 1, 1, 1) +self_modulate = Color(1, 1, 1, 1) +show_behind_parent = false +top_level = false +clip_children = 0 +light_mask = 1 +visibility_layer = 1 +z_index = 0 +z_as_relative = true +y_sort_enabled = false +texture_filter = 0 +texture_repeat = 0 +material = null +use_parent_material = false +clip_contents = false +custom_minimum_size = Vector2(20, 20) +layout_direction = 0 +layout_mode = 2 +size_flags_horizontal = 1 +size_flags_vertical = 1 +size_flags_stretch_ratio = 1.0 +localize_numeral_system = true +tooltip_text = "" +focus_neighbor_left = NodePath("") +focus_neighbor_top = NodePath("") +focus_neighbor_right = NodePath("") +focus_neighbor_bottom = NodePath("") +focus_next = NodePath("") +focus_previous = NodePath("") +focus_mode = 0 +mouse_filter = 0 +mouse_force_pass_scroll_events = true +mouse_default_cursor_shape = 2 +theme = null +theme_type_variation = &"" +disabled = false +toggle_mode = false +button_pressed = false +action_mode = 1 +button_mask = 1 +keep_pressed_outside = false +button_group = null +shortcut = null +shortcut_feedback = true +shortcut_in_tooltip = true +script = null + +[node name="TextureRect" type="TextureRect" parent="VBoxContainer/Top/WindowButtons/Exit"] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -584,5 +666,3 @@ libraries = { script = ExtResource("7_1hi62") ui_events = ExtResource("8_8dnbq") gate_events = ExtResource("3_m632k") - -[connection signal="pressed" from="VBoxContainer/Top/Exit" to="VBoxContainer/Top/Exit" method="_on_pressed"] diff --git a/app/scenes/menu_body/world.tscn b/app/scenes/menu_body/world.tscn index d9c0e4f..cecca50 100644 --- a/app/scenes/menu_body/world.tscn +++ b/app/scenes/menu_body/world.tscn @@ -335,6 +335,7 @@ expand_mode = 5 stretch_mode = 5 script = ExtResource("13_3b6nd") gate_events = ExtResource("2_q7cvi") +command_events = ExtResource("6_18mgg") ui_events = ExtResource("9_ir58h") splash_screen = ExtResource("10_23bjc") diff --git a/app/scripts/ui/menu/exit_app.gd b/app/scripts/ui/menu/exit_app.gd deleted file mode 100644 index 5d4632a..0000000 --- a/app/scripts/ui/menu/exit_app.gd +++ /dev/null @@ -1,5 +0,0 @@ -extends BaseButton - - -func _on_pressed() -> void: - get_tree().quit() diff --git a/app/scripts/ui/menu/menu.gd b/app/scripts/ui/menu/menu.gd index 95f6897..e5b540f 100644 --- a/app/scripts/ui/menu/menu.gd +++ b/app/scripts/ui/menu/menu.gd @@ -5,9 +5,23 @@ extends Control func _ready() -> void: resized.connect(on_resized) + set_initial_screen() on_resized() func on_resized() -> void: Debug.logclr("Ui resized: %dx%d" % [size.x, size.y], Debug.SILENT_CLR) ui_events.ui_size_changed_emit(size) + + +func set_initial_screen() -> void: + var last_screen = DataSaver.get_value("settings", "last_screen") + if last_screen == null: last_screen = 0 + + DisplayServer.window_set_current_screen(last_screen) + Debug.logclr("Initial screen: %d" % [last_screen], Debug.SILENT_CLR) + + +func _exit_tree() -> void: + var last_screen = DisplayServer.window_get_current_screen() + DataSaver.set_value("settings", "last_screen", last_screen) diff --git a/app/scripts/ui/menu/window_buttons.gd b/app/scripts/ui/menu/window_buttons.gd new file mode 100644 index 0000000..a2e6696 --- /dev/null +++ b/app/scripts/ui/menu/window_buttons.gd @@ -0,0 +1,17 @@ +extends Control + +@export var minimize: BaseButton +@export var exit: BaseButton + + +func _ready() -> void: + minimize.pressed.connect(on_minimize) + exit.pressed.connect(on_exit) + + +func on_minimize() -> void: + DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_MINIMIZED) + + +func on_exit() -> void: + get_tree().quit() diff --git a/app/scripts/ui/world/splash_screen.gd b/app/scripts/ui/world/splash_screen.gd index 8edbccc..212714d 100644 --- a/app/scripts/ui/world/splash_screen.gd +++ b/app/scripts/ui/world/splash_screen.gd @@ -2,6 +2,7 @@ extends TextureRect class_name SplashScreen @export var gate_events: GateEvents +@export var command_events: CommandEvents @export var ui_events: UiEvents @export var splash_screen: Texture2D @@ -12,6 +13,7 @@ class_name SplashScreen func _ready(): gate_events.gate_info_loaded.connect(show_thumbnail) gate_events.gate_entered.connect(show_splash_screen) + command_events.first_frame_drawn.connect(first_frame_drawn) # Change size show_splash_screen() @@ -34,6 +36,10 @@ func show_splash_screen() -> void: self.texture = ImageTexture.create_from_image(image) +func first_frame_drawn() -> void: + hide() + + func resize_and_convert(image: Image, format: Image.Format) -> Image: image.resize(width, height) image.convert(format) diff --git a/app/scripts/ui/world/world_canvas.gd b/app/scripts/ui/world/world_canvas.gd index 5de1fd3..0a7d9b1 100644 --- a/app/scripts/ui/world/world_canvas.gd +++ b/app/scripts/ui/world/world_canvas.gd @@ -21,4 +21,4 @@ func _ready() -> void: func animate(value: float) -> void: - custom_minimum_size.x = lerp(initial, full_screen, value) + custom_minimum_size.x = lerp(initial, full_screen + 1, value) diff --git a/godot b/godot index ed89c45..f51caa6 160000 --- a/godot +++ b/godot @@ -1 +1 @@ -Subproject commit ed89c45ea8dd91167e7c2351e6326983e5a46d06 +Subproject commit f51caa6d0deba8abd21e7ccaf09ad1edbca604c1