@@ -7,6 +7,7 @@ var _config_changed := false
7
7
var _old_config : Dictionary
8
8
9
9
# Games directory
10
+ var config_version : int = 1
10
11
var is_first_time : bool = true : set = _set_is_first_time
11
12
var games_dir : String = FileUtils .get_home_dir () + "/ROMS" : set = _set_games_dir
12
13
var current_theme : String = "default" : set = _set_current_theme
@@ -35,6 +36,7 @@ var virtual_keyboard_show_on_controller : bool = true: set = _set_virtual_keyboa
35
36
var virtual_keyboard_show_on_mouse : bool = false : set = _set_virtual_keyboard_show_on_mouse
36
37
var accessibility_screen_reader_enabled : bool = true : set = _set_accessibility_screen_reader_enabled
37
38
39
+ const KEY_CONFIG_VERSION = "config_version"
38
40
const KEY_IS_FIRST_TIME = "is_first_time"
39
41
const KEY_GAMES_DIR = "games_dir"
40
42
const KEY_CURRENT_THEME = "current_theme"
@@ -65,6 +67,7 @@ const KEY_ACCESSIBILITY_SCREEN_READER_ENABLED = "accessibility_screen_reader_ena
65
67
66
68
67
69
const _keys = [
70
+ KEY_CONFIG_VERSION ,
68
71
KEY_IS_FIRST_TIME ,
69
72
KEY_GAMES_DIR ,
70
73
KEY_CURRENT_THEME ,
@@ -162,6 +165,12 @@ static func default_virtual_keyboard_type() -> String:
162
165
else :
163
166
return "builtin"
164
167
168
+ func _get_stored_version (config : Dictionary ) -> int :
169
+ if config .has (KEY_CONFIG_VERSION ):
170
+ return int (config [KEY_CONFIG_VERSION ])
171
+ else :
172
+ return 0
173
+
165
174
func _set_is_first_time (_is_first_time ):
166
175
mark_for_saving ()
167
176
is_first_time = _is_first_time
@@ -338,7 +347,7 @@ func save_config_to_path(path: String, force_save: bool = false) -> int:
338
347
dict [key ] = get (key )
339
348
340
349
# Save JSON to file
341
- var json_output := JSON .stringify (dict , "\t " )
350
+ var json_output := JSON .stringify (dict , "\t " , false )
342
351
file .store_string (json_output )
343
352
file .close ()
344
353
_config_changed = false
@@ -363,6 +372,7 @@ func process_new_change(key: String):
363
372
accessibility_screen_reader_enabled = is_first_time
364
373
365
374
func process_raw_config_changes (config : Dictionary ):
375
+ ## Before config version was introduced
366
376
# Scraper credentials were moved to a dedicated file
367
377
var creds := [
368
378
"scraper_ss_username" ,
@@ -424,3 +434,18 @@ func process_raw_config_changes(config: Dictionary):
424
434
config [KEY_INPUT_CONTROLLER_ICON_TYPE ] = "ouya"
425
435
0 , _ :
426
436
config [KEY_INPUT_CONTROLLER_ICON_TYPE ] = "auto"
437
+
438
+ var version := _get_stored_version (config )
439
+ while version < config_version :
440
+ _should_save = true
441
+ _handle_config_update (config , version )
442
+ version += 1
443
+
444
+ func _handle_config_update (config : Dictionary , version : int ):
445
+ match version :
446
+ 0 :
447
+ # First config version; RetroHub port from Godot 3 to Godot 4
448
+ # Input remaps have to be reset
449
+ config [KEY_INPUT_KEY_MAP ] = input_key_map
450
+ config [KEY_CUSTOM_INPUT_REMAP ] = custom_input_remap
451
+ RetroHubUI .call_deferred ("show_warning" , "The following settings had to be reset due to incompatible changes in RetroHub:\n \n - Keyboard remaps\n -Controller custom layout\n \n Please reconfigure these in the Settings menu if desired." )
0 commit comments