Preserve data across the Straywild transition
This commit is contained in:
parent
737d1cf2e0
commit
98a27e2f53
28 changed files with 577 additions and 94 deletions
19
main/main.gd
19
main/main.gd
|
|
@ -277,6 +277,7 @@ var _rain_ambience: RainAmbienceType
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
_data_root.prepare_legacy_user_data()
|
||||
_performance_profile = RuntimePerformanceProfileType.from_environment()
|
||||
_dedicated_runtime = _is_dedicated_server_runtime()
|
||||
if _dedicated_runtime:
|
||||
|
|
@ -471,10 +472,7 @@ func _start_dedicated_server() -> void:
|
|||
_fail_dedicated_server(config.error_message)
|
||||
return
|
||||
var data_path: String = config.data_directory
|
||||
var manifest_path: String = data_path.path_join(
|
||||
PlayerDataRoot.MANIFEST_FILENAME
|
||||
)
|
||||
if not FileAccess.file_exists(manifest_path):
|
||||
if not _data_root.has_data_manifest(data_path):
|
||||
var created: Dictionary = _data_root.create_unbound_root(data_path)
|
||||
if not bool(created.get("ok", false)):
|
||||
_fail_dedicated_server(str(created.get(
|
||||
|
|
@ -973,6 +971,7 @@ func _initialize_application(dedicated: bool) -> void:
|
|||
_network_session,
|
||||
_interface_fonts,
|
||||
)
|
||||
_game_ui.data_root_changed.connect(_on_data_root_changed)
|
||||
_game_ui.setup_controller_mapping(_controller_mapping_manager)
|
||||
_ui_pixelation.setup_controller_mapping(_controller_mapping_manager)
|
||||
_game_ui.setup_keyboard_mouse_mapping(_keyboard_mouse_mapping_manager)
|
||||
|
|
@ -1344,6 +1343,18 @@ func _on_data_root_status(message: String) -> void:
|
|||
_configure_popup_dialog.call_deferred(dialog, dialog.get_ok_button())
|
||||
|
||||
|
||||
func _on_data_root_changed() -> void:
|
||||
_save_manager.set_autosave_enabled(false)
|
||||
_save_manager.cancel_pending_autosave()
|
||||
_configure_portable_stores()
|
||||
if not _network_profile_service.reload_persisted_profile():
|
||||
push_warning("The selected data folder's player profile could not be loaded.")
|
||||
_network_session.set_local_appearance_snapshot(
|
||||
_appearance_store.get_snapshot()
|
||||
)
|
||||
_game_ui.get_title_screen().refresh_after_data_root_change()
|
||||
|
||||
|
||||
func _on_server_trust_required(
|
||||
endpoint: String,
|
||||
expected_fingerprint: String,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@ const PROFILE_ENVIRONMENT_VARIABLE: String = (
|
|||
"straywild_PERFORMANCE_PROFILE"
|
||||
)
|
||||
const LEGACY_LIGHT_ENVIRONMENT_VARIABLE: String = "straywild_LOW_END"
|
||||
const NETFISHING_PROFILE_ENVIRONMENT_VARIABLE := (
|
||||
"NETFISHING_PERFORMANCE_PROFILE"
|
||||
)
|
||||
const NETFISHING_LIGHT_ENVIRONMENT_VARIABLE := "NETFISHING_LOW_END"
|
||||
const NORMAL_PROFILE: StringName = &"normal"
|
||||
const LIGHT_PROFILE: StringName = &"light"
|
||||
const NORMAL_WORLD_RENDER_SCALE: float = 1.0
|
||||
|
|
@ -14,9 +18,19 @@ var _profile_name: StringName = NORMAL_PROFILE
|
|||
|
||||
|
||||
static func from_environment() -> RuntimePerformanceProfile:
|
||||
var profile_name: String = OS.get_environment(
|
||||
PROFILE_ENVIRONMENT_VARIABLE
|
||||
)
|
||||
if profile_name.is_empty():
|
||||
profile_name = OS.get_environment(
|
||||
NETFISHING_PROFILE_ENVIRONMENT_VARIABLE
|
||||
)
|
||||
return from_name(
|
||||
StringName(OS.get_environment(PROFILE_ENVIRONMENT_VARIABLE)),
|
||||
OS.get_environment(LEGACY_LIGHT_ENVIRONMENT_VARIABLE) == "1",
|
||||
StringName(profile_name),
|
||||
(
|
||||
OS.get_environment(LEGACY_LIGHT_ENVIRONMENT_VARIABLE) == "1"
|
||||
or OS.get_environment(NETFISHING_LIGHT_ENVIRONMENT_VARIABLE) == "1"
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue