From 6c940973c6b2be929d287098cd7f2a7821357cf0 Mon Sep 17 00:00:00 2001 From: qrrk <19731636+qrrk@users.noreply.github.com> Date: Sun, 12 Sep 2021 23:31:53 +0300 Subject: [PATCH] Add button to open game dir --- icons/folder.svg | 16 ++++++++++++++++ icons/folder.svg.import | 34 ++++++++++++++++++++++++++++++++++ icons/placeholder.svg | 16 ++++++++++++++++ icons/placeholder.svg.import | 34 ++++++++++++++++++++++++++++++++++ scenes/Catapult.tscn | 26 ++++++++++++++++++++++---- scenes/InlineIconButton.tscn | 20 ++++++++++++++++++++ scripts/Catapult.gd | 12 +++++++++++- scripts/InlineIconButton.gd | 20 ++++++++++++++++++++ 8 files changed, 173 insertions(+), 5 deletions(-) create mode 100644 icons/folder.svg create mode 100644 icons/folder.svg.import create mode 100644 icons/placeholder.svg create mode 100644 icons/placeholder.svg.import create mode 100644 scenes/InlineIconButton.tscn create mode 100644 scripts/InlineIconButton.gd diff --git a/icons/folder.svg b/icons/folder.svg new file mode 100644 index 00000000..e1dbcbe0 --- /dev/null +++ b/icons/folder.svg @@ -0,0 +1,16 @@ + + + + + diff --git a/icons/folder.svg.import b/icons/folder.svg.import new file mode 100644 index 00000000..60b9d471 --- /dev/null +++ b/icons/folder.svg.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/folder.svg-e1871ca68b6ee04f205d48c1bf08149e.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icons/folder.svg" +dest_files=[ "res://.import/folder.svg-e1871ca68b6ee04f205d48c1bf08149e.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/icons/placeholder.svg b/icons/placeholder.svg new file mode 100644 index 00000000..82438a87 --- /dev/null +++ b/icons/placeholder.svg @@ -0,0 +1,16 @@ + + + + + diff --git a/icons/placeholder.svg.import b/icons/placeholder.svg.import new file mode 100644 index 00000000..498b5526 --- /dev/null +++ b/icons/placeholder.svg.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/placeholder.svg-6fcf5bc9686c035a74d6211bc2e89751.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icons/placeholder.svg" +dest_files=[ "res://.import/placeholder.svg-6fcf5bc9686c035a74d6211bc2e89751.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/scenes/Catapult.tscn b/scenes/Catapult.tscn index fe774c96..a5ef93e5 100644 --- a/scenes/Catapult.tscn +++ b/scenes/Catapult.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=26 format=2] +[gd_scene load_steps=28 format=2] [ext_resource path="res://icons/info.svg" type="Texture" id=1] [ext_resource path="res://icons/download.svg" type="Texture" id=2] @@ -24,6 +24,8 @@ [ext_resource path="res://fonts/OpenSans-Semibold.tres" type="DynamicFont" id=22] [ext_resource path="res://fonts/OpenSans-Italic.tres" type="DynamicFont" id=23] [ext_resource path="res://fonts/OpenSans-SemiboldItalic.tres" type="DynamicFont" id=24] +[ext_resource path="res://icons/folder.svg" type="Texture" id=25] +[ext_resource path="res://scenes/InlineIconButton.tscn" type="PackedScene" id=26] [sub_resource type="ButtonGroup" id=1] @@ -231,13 +233,28 @@ margin_bottom = 29.0 text = "Currently installed:" align = 1 -[node name="Build" type="Label" parent="Main/Tabs/Game/CurrentInstall"] +[node name="Build" type="HBoxContainer" parent="Main/Tabs/Game/CurrentInstall"] +margin_left = 347.0 margin_top = 35.0 -margin_right = 769.0 +margin_right = 422.0 margin_bottom = 64.0 +size_flags_horizontal = 4 +custom_constants/separation = 4 + +[node name="Name" type="Label" parent="Main/Tabs/Game/CurrentInstall/Build"] +margin_right = 53.0 +margin_bottom = 29.0 text = "None" align = 1 +[node name="GameDir" parent="Main/Tabs/Game/CurrentInstall/Build" instance=ExtResource( 26 )] +margin_left = 57.0 +margin_top = 5.0 +margin_right = 75.0 +margin_bottom = 23.0 +hint_tooltip = "Open game directory." +texture_normal = ExtResource( 25 ) + [node name="BtnPlay" type="Button" parent="Main/Tabs/Game/CurrentInstall" groups=[ "disable_while_installing_game", ]] @@ -898,11 +915,12 @@ __meta__ = { [connection signal="meta_clicked" from="Main/GameInfo/Description" to="." method="_on_Description_meta_clicked"] [connection signal="tab_changed" from="Main/Tabs" to="." method="_on_Tabs_tab_changed"] -[connection signal="tab_changed" from="Main/Tabs" to="Main/Tabs/Mods" method="_on_Tabs_tab_changed"] [connection signal="tab_changed" from="Main/Tabs" to="Main/Tabs/Soundpacks" method="_on_Tabs_tab_changed"] +[connection signal="tab_changed" from="Main/Tabs" to="Main/Tabs/Mods" method="_on_Tabs_tab_changed"] [connection signal="item_selected" from="Main/Tabs/Game/Builds/BuildsList" to="." method="_on_BuildsList_item_selected"] [connection signal="pressed" from="Main/Tabs/Game/Builds/BtnRefresh" to="." method="_on_BtnRefresh_pressed"] [connection signal="pressed" from="Main/Tabs/Game/BtnInstall" to="." method="_on_BtnInstall_pressed"] +[connection signal="pressed" from="Main/Tabs/Game/CurrentInstall/Build/GameDir" to="." method="_on_GameDir_pressed"] [connection signal="pressed" from="Main/Tabs/Game/CurrentInstall/BtnPlay" to="." method="_on_BtnPlay_pressed"] [connection signal="status_message" from="Main/Tabs/Mods" to="." method="_on_status_message"] [connection signal="item_selected" from="Main/Tabs/Mods/HBox/Installed/InstalledList" to="Main/Tabs/Mods" method="_on_InstalledList_item_selected"] diff --git a/scenes/InlineIconButton.tscn b/scenes/InlineIconButton.tscn new file mode 100644 index 00000000..3dd45951 --- /dev/null +++ b/scenes/InlineIconButton.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://icons/placeholder.svg" type="Texture" id=1] +[ext_resource path="res://scripts/InlineIconButton.gd" type="Script" id=2] + +[node name="InlineIconButton" type="TextureButton"] +margin_right = 20.0 +margin_bottom = 20.0 +rect_min_size = Vector2( 18, 18 ) +size_flags_horizontal = 4 +size_flags_vertical = 4 +texture_normal = ExtResource( 1 ) +expand = true +script = ExtResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"] +[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"] diff --git a/scripts/Catapult.gd b/scripts/Catapult.gd index c7ad5c0a..67411161 100644 --- a/scripts/Catapult.gd +++ b/scripts/Catapult.gd @@ -25,12 +25,13 @@ onready var _fshelper = $FSHelper onready var _installer = $ReleaseInstaller onready var _btn_install = $Main/Tabs/Game/BtnInstall onready var _btn_refresh = $Main/Tabs/Game/Builds/BtnRefresh +onready var _btn_game_dir = $Main/Tabs/Game/CurrentInstall/Build/GameDir onready var _btn_play = $Main/Tabs/Game/CurrentInstall/BtnPlay onready var _lst_builds = $Main/Tabs/Game/Builds/BuildsList onready var _lst_games = $Main/GameChoice/GamesList onready var _rbtn_stable = $Main/Tabs/Game/Channel/Group/RBtnStable onready var _rbtn_exper = $Main/Tabs/Game/Channel/Group/RBtnExperimental -onready var _lbl_build = $Main/Tabs/Game/CurrentInstall/Build +onready var _lbl_build = $Main/Tabs/Game/CurrentInstall/Build/Name var _disable_savestate = {} @@ -319,6 +320,13 @@ func _get_release_key() -> String: return key +func _on_GameDir_pressed() -> void: + + var gamedir = _fshelper.get_own_dir().plus_file(_settings.read("game")).plus_file("current") + if Directory.new().dir_exists(gamedir): + OS.shell_open(gamedir) + + func setup_ui() -> void: _game_info.visible = _settings.read("show_game_desc") @@ -396,6 +404,7 @@ func _refresh_currently_installed() -> void: _lbl_build.text = info[game]["name"] _btn_install.text = "Update to Selected" _btn_play.disabled = false + _btn_game_dir.visible = true if (_lst_builds.selected != -1) and (_lst_builds.selected < len(releases)): if not _settings.read("update_to_same_build_allowed"): _btn_install.disabled = (releases[_lst_builds.selected]["name"] == info[game]["name"]) @@ -407,6 +416,7 @@ func _refresh_currently_installed() -> void: _btn_install.text = "Install Selected" _btn_install.disabled = false _btn_play.disabled = true + _btn_game_dir.visible = false for i in [1, 2]: _tabs.set_tab_disabled(i, not _is_selected_game_installed()) diff --git a/scripts/InlineIconButton.gd b/scripts/InlineIconButton.gd new file mode 100644 index 00000000..6f5f723a --- /dev/null +++ b/scripts/InlineIconButton.gd @@ -0,0 +1,20 @@ +extends TextureButton + + +export(float, 1.0, 1.5) var _scale_when_hovered = 1.1 + +var _normal_position := Vector2() + + +func _on_mouse_entered() -> void: + + _normal_position = rect_position + rect_size = rect_min_size * _scale_when_hovered + var offset := (rect_size - rect_min_size) / 2.0 + rect_position -= offset + + +func _on_mouse_exited() -> void: + + rect_size = rect_min_size + rect_position = _normal_position