diff --git a/scenes/JoypadMonitor6Btn.gd b/scenes/JoypadMonitor6Btn.gd index a35c7ef..b0e8a2c 100644 --- a/scenes/JoypadMonitor6Btn.gd +++ b/scenes/JoypadMonitor6Btn.gd @@ -27,12 +27,13 @@ func _process(delta: float) -> void: var right = Input.get_joy_axis(joypad_index, id_right) var start = Input.get_joy_axis(joypad_index, id_start) var back = Input.get_joy_axis(joypad_index, id_back) - $Grid/left/Label.text = "%.03f" % left - $Grid/down/Label.text = "%.03f" % down - $Grid/up/Label.text = "%.03f" % up - $Grid/right/Label.text = "%.03f" % right - $TopRow/lbl_start.text = "start\n%.03f" % start - $TopRow/lbl_back.text = "back\n%.03f" % back + var precision = "%.05f" + $Grid/left/Label.text = precision % left + $Grid/down/Label.text = precision % down + $Grid/up/Label.text = precision % up + $Grid/right/Label.text = precision % right + $TopRow/lbl_start.text = "start\n" + precision % start + $TopRow/lbl_back.text = "back\n" + precision % back $Grid/left/t.modulate = color_on if Input.is_joy_button_pressed(joypad_index, id_left) else color_off $Grid/down/t.modulate = color_on if Input.is_joy_button_pressed(joypad_index, id_down) else color_off diff --git a/scenes/MainMenu.tscn b/scenes/MainMenu.tscn index 4539267..afb8a77 100644 --- a/scenes/MainMenu.tscn +++ b/scenes/MainMenu.tscn @@ -29,7 +29,6 @@ margin_top = 464.0 margin_right = 614.0 margin_bottom = 532.0 size_flags_horizontal = 4 -disabled = true text = "Step" [node name="btn_settings" type="Button" parent="VBoxContainer"] diff --git a/scenes/StepGame.tscn b/scenes/StepGame.tscn index 81a7ed9..07581cc 100644 --- a/scenes/StepGame.tscn +++ b/scenes/StepGame.tscn @@ -116,15 +116,19 @@ script = ExtResource( 1 ) [node name="Center" type="Node2D" parent="noteHandler/viewport"] position = Vector2( 540, 540 ) -[node name="SlideTrailHandler" type="Node2D" parent="noteHandler/viewport/Center"] +[node name="slideTrailHandler" type="Node2D" parent="noteHandler/viewport/Center"] +unique_name_in_owner = true -[node name="JudgeText" type="MeshInstance2D" parent="noteHandler/viewport/Center"] +[node name="judgeText" type="MeshInstance2D" parent="noteHandler/viewport/Center"] +unique_name_in_owner = true texture = ExtResource( 2 ) [node name="meshinstance" type="MeshInstance2D" parent="noteHandler/viewport/Center"] +unique_name_in_owner = true material = SubResource( 2 ) [node name="notelines" type="MeshInstance2D" parent="noteHandler/viewport/Center"] +unique_name_in_owner = true material = SubResource( 3 ) [node name="lbl_combo" type="Label" parent="noteHandler"] @@ -165,6 +169,11 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="square" type="Control" parent="."] +unique_name_in_owner = true +anchor_right = 1.0 +anchor_bottom = 1.0 + [connection signal="combo_changed" from="noteHandler" to="noteHandler/lbl_combo" method="_on_NoteHandler_combo_changed"] [connection signal="finished_song" from="noteHandler" to="noteHandler/lbl_combo" method="_on_NoteHandler_finished_song"] [connection signal="column_pressed" from="InputHandler" to="noteHandler" method="_on_InputHandler_column_pressed"] diff --git a/scripts/MainMenu.gd b/scripts/MainMenu.gd index 8b51aa6..1a7389b 100644 --- a/scripts/MainMenu.gd +++ b/scripts/MainMenu.gd @@ -2,8 +2,12 @@ extends Control signal start_touchgame signal start_stepgame +func update_libraries_text() -> void: + $lbl_settingspath.text = 'Data directories:\n' + '\n'.join(Settings.get_library_paths()) + func _ready() -> void: - $lbl_settingspath.text = "Data directory is\n" + FileLoader.userroot + update_libraries_text() + Settings.connect('config_loaded', self, 'update_libraries_text') func quit() -> void: get_tree().quit() diff --git a/scripts/StepMenu.gd b/scripts/StepMenu.gd index f681c81..dd2ba74 100644 --- a/scripts/StepMenu.gd +++ b/scripts/StepMenu.gd @@ -222,7 +222,7 @@ func _draw_song_select(center: Vector2) -> Array: if len(genres) <= 0: draw_string_centered(genreFont, Vector2(center.x, center.y-440*f_scale), 'No Songs in Library!', Color.aqua) - draw_string_centered(diffNumFont, Vector2(center.x, center.y-390*f_scale), FileLoader.userroot, Color.lightgreen) + draw_string_centered(diffNumFont, Vector2(center.x, center.y-390*f_scale), Settings.user_data_dir, Color.lightgreen) return touchrects var ssid = self.selected_song_idx diff --git a/scripts/TouchMenu.gd b/scripts/TouchMenu.gd index 661f057..38d81d7 100644 --- a/scripts/TouchMenu.gd +++ b/scripts/TouchMenu.gd @@ -217,7 +217,7 @@ func _draw_song_select(center: Vector2) -> Array: if len(genres) <= 0: draw_string_centered(genreFont, Vector2(center.x, center.y-440*f_scale), 'No Songs in Library!', Color.aqua) - draw_string_centered(diffNumFont, Vector2(center.x, center.y-390*f_scale), FileLoader.userroot, Color.lightgreen) + draw_string_centered(diffNumFont, Vector2(center.x, center.y-390*f_scale), Settings.user_data_dir, Color.lightgreen) return touchrects var ssid = self.selected_song_idx diff --git a/singletons/FileLoader.gd b/singletons/FileLoader.gd index f8bf78c..c8c2fcf 100644 --- a/singletons/FileLoader.gd +++ b/singletons/FileLoader.gd @@ -10,13 +10,14 @@ const NOT_FOUND := '' const default_difficulty_keys = ['Z', 'B', 'A', 'E', 'M', 'R'] -var userroot := OS.get_user_data_dir().rstrip('/')+'/' if OS.get_name() != 'Android' else '/storage/emulated/0/RhythmGame/' -var PATHS := PoolStringArray([userroot]) # Temporary hardcoded testing -# The following would probably work. One huge caveat is that permission needs to be manually granted by the user in app settings as we can't use OS.request_permission('WRITE_EXTERNAL_STORAGE') -# '/storage/emulated/0/Android/data/au.ufeff.rhythmgame/' -# '/sdcard/Android/data/au.ufeff.rhythmgame/' +var PATHS : PoolStringArray +func update_library_paths() -> void: + PATHS = Settings.get_library_paths() + func _ready() -> void: + update_library_paths() print('Library paths: ', PATHS) + Settings.connect('config_loaded', self, 'update_library_paths') func find_file(name: String, print_notfound:=false) -> String: @@ -175,7 +176,7 @@ func load_filelist(filelist: Array, directory=''): func save_json(filename: String, data: Dictionary): - filename = userroot + filename + filename = Settings.user_data_dir + filename var dir = filename.rsplit('/', true, 1)[0] match FileHelpers.init_directory(dir): OK: diff --git a/singletons/Settings.gd b/singletons/Settings.gd index 9c5de6c..f0b345f 100644 --- a/singletons/Settings.gd +++ b/singletons/Settings.gd @@ -2,8 +2,17 @@ # This is mostly used so that signals can be used to respond to settings changes extends Node +signal config_loaded signal subsampling_changed(xy) +const ANDROID_USERDIR := '/storage/emulated/0/RhythmGame/' +# The following would probably work. One huge caveat is that permission needs to be manually granted by the user in app settings as we can't use OS.request_permission('WRITE_EXTERNAL_STORAGE') +# '/storage/emulated/0/Android/data/au.ufeff.rhythmgame/' +# '/sdcard/Android/data/au.ufeff.rhythmgame/' +var user_data_dir := OS.get_user_data_dir().rstrip('/')+'/' if OS.get_name() != 'Android' else ANDROID_USERDIR +var SETTINGS_FILENAME = user_data_dir + 'settings.cfg' +var config : ConfigFile + var subsampling: Vector2 setget SSXY_set, SSXY_get var subsampling_x: float setget SSX_set, SSX_get var subsampling_y: float setget SSY_set, SSY_get @@ -26,17 +35,32 @@ func SSY_get() -> float: func SSXY_get() -> Vector2: return Vector2(self.subsampling_x, self.subsampling_y) - - -const SETTINGS_FILENAME = 'user://settings.conf' +func get_library_paths() -> PoolStringArray: + var paths = [user_data_dir] + var additional_paths = config.get_value('libraries', 'additional_paths', []) + # Ensure paths are valid and have trailing slash + for p in additional_paths: + if p is String: + paths.append(p.rstrip('/')+'/') + return PoolStringArray(paths) func load_settings(): - var config := ConfigFile.new() + config = ConfigFile.new() + config.set_value('libraries', 'additional_paths', []) match config.load(SETTINGS_FILENAME): OK: - pass + SSXY_set(Vector2( + config.get_value('rendering', 'subsampling_x', subsampling_x), + config.get_value('rendering', 'subsampling_y', subsampling_y) + )) + emit_signal('config_loaded') ERR_FILE_NOT_FOUND: save_settings() + print('Loaded settings from ' + SETTINGS_FILENAME) func save_settings(): - pass + config.save(SETTINGS_FILENAME) + print('Saved settings to ' + SETTINGS_FILENAME) + +func _ready(): + load_settings()