Add a button in Settings that opens the config folder
Shows the folder with config.ini, the saved settings and the cached characters and songs in the system's file manager. Closes #45
This commit is contained in:
1 parent
222d231b1b
commit
06f457b027
4 files changed
+56
-1
No files matched your search
@@ -158,6 +158,21 @@ focus_mode = 0
|
||||
action_mode = 0
|
||||
text = "Count plays in statistics"
|
||||
|
||||
[node name="ConfigFolderRow" type="HBoxContainer" parent="SettingsPanel/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Title" type="Label" parent="SettingsPanel/VBoxContainer/ConfigFolderRow"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_type_variation = &"SettingsRowLabel"
|
||||
text = "Settings and cached files"
|
||||
|
||||
[node name="OpenConfigFolderButton" type="Button" parent="SettingsPanel/VBoxContainer/ConfigFolderRow"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
focus_mode = 0
|
||||
text = "Open folder"
|
||||
|
||||
[node name="FolderDialog" type="FileDialog" parent="."]
|
||||
unique_name_in_owner = true
|
||||
title = "Choose a music folder"
|
||||
|
||||
@@ -2,7 +2,8 @@ class_name SettingsPopup
|
||||
extends BasePopup
|
||||
## The application settings: which MusicServer or music folder to play from, fullscreen,
|
||||
## how many songs to download ahead, whether to prefer less played soundtracks and whether
|
||||
## plays count in the statistics. Opened from the Settings button in the top bar.
|
||||
## plays count in the statistics, and a button that opens the folder the settings are
|
||||
## kept in. Opened from the Settings button in the top bar.
|
||||
##
|
||||
## A music folder (see [MusicFolder]) is used instead of the server until Use server is
|
||||
## pressed or the game is closed. The settings that need the server are off meanwhile.
|
||||
@@ -32,6 +33,11 @@ const PADDING: Vector2 = Vector2(20, 12)
|
||||
@onready var play_order_row: HBoxContainer = %PlayOrderRow
|
||||
@onready var play_order_button: OptionButton = %PlayOrderButton
|
||||
@onready var folder_dialog: FileDialog = %FolderDialog
|
||||
@onready var open_config_folder_button: Button = %OpenConfigFolderButton
|
||||
|
||||
## Shows a folder in the system's file manager. The tests replace it, so no file manager
|
||||
## opens while they run.
|
||||
var show_folder: Callable = _show_in_file_manager
|
||||
|
||||
# Where the panel's middle is, so it stays centred when rows are shown or hidden
|
||||
var _panel_middle_y: float = 0.0
|
||||
@@ -48,6 +54,8 @@ func _ready() -> void:
|
||||
choose_folder_button.pressed.connect(folder_dialog.popup_centered)
|
||||
folder_dialog.dir_selected.connect(use_music_folder)
|
||||
use_server_button.pressed.connect(use_server)
|
||||
open_config_folder_button.pressed.connect(open_config_folder)
|
||||
open_config_folder_button.tooltip_text = Settings.config_dir()
|
||||
play_order_button.item_selected.connect(_on_play_order_selected)
|
||||
lower_cache_button.pressed.connect(lower_cache)
|
||||
increase_cache_button.pressed.connect(increase_cache)
|
||||
@@ -88,6 +96,14 @@ func use_server() -> void:
|
||||
server_changed.emit()
|
||||
|
||||
|
||||
## Shows the folder with the config file, the saved settings and the cached characters
|
||||
## and songs in the system's file manager.
|
||||
func open_config_folder() -> void:
|
||||
var dir: String = Settings.config_dir()
|
||||
DirAccess.make_dir_recursive_absolute(dir)
|
||||
show_folder.call(dir)
|
||||
|
||||
|
||||
func lower_cache() -> void:
|
||||
Playlist.number_of_tracks_to_preload = maxi(Playlist.number_of_tracks_to_preload - 1, 1)
|
||||
cache_label.text = str(Playlist.number_of_tracks_to_preload)
|
||||
@@ -160,5 +176,14 @@ func _fit_to_rows() -> void:
|
||||
rows.size = Vector2(settings_panel.size.x - PADDING.x * 2, height - PADDING.y * 2)
|
||||
|
||||
|
||||
func _show_in_file_manager(dir: String) -> void:
|
||||
var error: Error = OS.shell_show_in_file_manager(dir)
|
||||
if error != OK:
|
||||
# Not every platform has a file manager to show a folder in; open it instead
|
||||
error = OS.shell_open(dir)
|
||||
if error != OK:
|
||||
GameLog.warning("Could not open %s: %s" % [dir, error_string(error)])
|
||||
|
||||
|
||||
func _update_fullscreen_button() -> void:
|
||||
fullscreen_button.set_pressed_no_signal(Settings.fullscreen)
|
||||
Reference in new issue
Block a user