aboutsummaryrefslogtreecommitdiff
path: root/client/global.gd
diff options
context:
space:
mode:
Diffstat (limited to 'client/global.gd')
-rw-r--r--client/global.gd88
1 files changed, 4 insertions, 84 deletions
diff --git a/client/global.gd b/client/global.gd
index c7ee555e..d9d714aa 100644
--- a/client/global.gd
+++ b/client/global.gd
@@ -24,37 +24,9 @@ signal using_touch_change(using: bool)
@warning_ignore("UNUSED_SIGNAL")
signal hand_count_change(count: bool)
-var default_profile := {
- "username": "",
- "character_style": {
- "color": 0,
- "headwear": 0,
- "hairstyle": 0
- },
- "last_server_url": "",
- "tutorial_ingredients_played": [],
- "registry_asked": false,
- "hints": {
- "has_moved": false,
- "has_boosted": false,
- "has_interacted": false,
- "has_rotated": false,
- "has_reset": false,
- "has_zoomed": false,
- "has_seen_performance": false,
- "has_seen_join_while_running": false
- }
-}
-
var using_joypad := false
var using_touch := false
-# profile and settings are stored in a Dictionary[String, Any]
-var profile: Dictionary
-var settings: Dictionary
-
-var settings_tree: GameSetting
-
var game_paused := false
var hand_count := 0
@@ -68,7 +40,7 @@ var focused_node: Control
var focused_menu: Menu # only use this as a last resort, currently exists to open setup menu from settings
func _ready():
- profile = load_dict("user://profile", default_profile)
+ Profile.load("user://profile")
Settings.load("user://settings.json")
get_viewport().gui_focus_changed.connect(Sound.play_hover_maybe)
get_viewport().gui_focus_changed.connect(func(node): focused_node = node)
@@ -105,27 +77,6 @@ func _input(event):
using_touch = false
using_touch_change.emit(using_touch)
-func save_profile():
- save_dict("user://profile", profile)
-
-func save_dict(path: String, dict: Dictionary):
- var f = FileAccess.open(path, FileAccess.WRITE)
- var to_save = dict.duplicate(true)
- f.store_var(to_save, true)
-
-func load_dict(path: String, default: Dictionary) -> Dictionary:
- # TOCTOU here. Godot docs says its fine.
- if not FileAccess.file_exists(path):
- print("Skip profile load")
- return default
- var f = FileAccess.open(path, FileAccess.READ)
- var saved_dict = f.get_var(true)
-
- if saved_dict != null and saved_dict is Dictionary:
- add_missing_keys(saved_dict, default)
-
- return saved_dict
-
func on_mobile() -> bool:
var os_name := OS.get_name()
return os_name == "Android" or os_name == "iOS"
@@ -138,37 +89,6 @@ func on_high_end() -> bool:
func on_vulkan() -> bool:
return ProjectSettings.get_setting("rendering/rendering_device/driver") == "vulkan"
-func get_profile(key: String):
- if profile.has(key):
- return profile[key]
- else:
- push_error("Tried to access profile setting \"%s\", which does not exist (missing key)" % key)
- return null
-
-func set_profile(key: String, value):
- if !profile.has(key):
- push_error("Tried to set profile setting \"%s\", which does not yet exist (missing key)" % key)
- return
- if profile[key] != value:
- profile[key] = value
-
-func set_hint(key: String, value: bool):
- if !profile["hints"].has(key):
- push_error("Tried to set hint \"%s\", which does not yet exist (missing key)" % key)
- if profile["hints"][key] != value:
- if value:
- Settings.write("gameplay.hints_started", true)
- Settings.save()
- profile["hints"][key] = value
- save_profile() # TODO avoid this call when bulk-unsetting hints
-
-func get_hint(key: String):
- if profile["hints"].has(key):
- return profile["hints"][key]
- else:
- push_error("Tried to access hint \"%s\", which does not exist (missing key)" % key)
- return null
-
static func interpolate(current, target, dt):
return target + (current - target) * exp(-dt)
@@ -206,7 +126,7 @@ func language_list():
func array_eq(a, b):
return a.all(func(e): return a.count(e) == b.count(e))
-func add_missing_keys(dict: Dictionary, reference: Dictionary):
+static func add_missing_keys(dict: Dictionary, reference: Dictionary):
for k in reference.keys():
if !dict.has(k) or typeof(dict[k]) != typeof(reference[k]):
dict[k] = reference[k]
@@ -220,8 +140,8 @@ func array_has_all(parent: Array, children: Array) -> bool:
return false
return true
-func configure_viewport_aa(vp: Viewport, aa: String) -> void:
- match aa:
+func configure_viewport_aa(vp: Viewport) -> void:
+ match Settings.read("graphics.aa"):
"disabled":
vp.msaa_3d = Viewport.MSAA_DISABLED
vp.screen_space_aa = Viewport.SCREEN_SPACE_AA_DISABLED