aboutsummaryrefslogtreecommitdiff
path: root/client/settings.gd
diff options
context:
space:
mode:
Diffstat (limited to 'client/settings.gd')
-rw-r--r--client/settings.gd114
1 files changed, 41 insertions, 73 deletions
diff --git a/client/settings.gd b/client/settings.gd
index cb8f9cf0..ade51262 100644
--- a/client/settings.gd
+++ b/client/settings.gd
@@ -30,36 +30,9 @@ static func get_root():
]),
SettingsCategory.new("graphics", [
PresetRow.new("preset", {
- "low": {
- "ui_blur": true,
- "aa": 0,
- "ssao": false,
- "taa": false,
- "shadows": false,
- "glow": false,
- "grass_amount": 0,
- "lq_trees": true
- },
- "medium": {
- "ui_blur": true,
- "aa": 1,
- "ssao": false,
- "taa": false,
- "shadows": true,
- "glow": false,
- "grass_amount": 0,
- "lq_trees": false
- },
- "high": {
- "ui_blur": true,
- "aa": 2,
- "ssao": true,
- "taa": false,
- "shadows": true,
- "glow": true,
- "grass_amount": 16,
- "lq_trees": false
- }
+ "low": {"ui_blur": true, "aa": "disabled", "ssao": false, "taa": false, "shadows": false, "glow": false, "grass_amount": 0, "lq_trees": true},
+ "medium": {"ui_blur": true, "aa": "fx", "ssao": false, "taa": false, "shadows": true, "glow": false, "grass_amount": 0, "lq_trees": false},
+ "high": {"ui_blur": true, "aa": "ms2x", "ssao": true, "taa": false, "shadows": true, "glow": true, "grass_amount": 16, "lq_trees": false}
}),
DropdownSetting.new("fullscreen", "keep", ["keep", "always", "never"]),
DropdownSetting.new("aa", "ms2x" if Global.on_high_end() else "disabled", ["disabled", "fx", "ms2x", "ms4x"]),
@@ -80,7 +53,7 @@ static func get_root():
]),
SettingsCategory.new("ui", [
DropdownSetting.new("touch_controls", 0, ["automatic", "enabled", "disabled"]),
- DropdownSetting.new("language", "system", Global.languages.map(func(e): return e[1])),
+ DropdownSetting.new("language", "system", Global.language_list()),
DropdownSetting.new("scale_mode", "resize", ["resize", "disabled"]),
RangeSetting.new("scale_factor", 1. if not Global.on_mobile() else 1.5, 0.5, 1.5, 3),
]),
@@ -94,16 +67,23 @@ static func get_root():
])
static func hook_changed(key: String, callable: Callable):
- change_hooks[key] = callable
+ change_hooks_display[key] = callable
static func hook_changed_init(key: String, callable: Callable):
hook_changed(key, callable)
callable.call(Global.get_setting(key))
-static var change_hooks = {
+static var change_hooks_display = {}
+static var change_hooks_apply = {
"graphics.aa": h_aa,
"graphics.taa": h_taa,
+ "graphics.fullscreen": h_fullscreen,
"ui.scale_mode": h_scale_mode,
+ "ui.scale_factor": h_scale_factor,
+ "ui.language": h_language,
+ "audio.master_volume": h_volume_master,
+ "audio.music_volume": h_volume_music,
+ "audio.sfx_volume": h_volume_sfx,
}
static func h_aa(mode):
@@ -128,52 +108,40 @@ static func h_aa(mode):
static func h_taa(enabled):
Global.get_viewport().use_taa = enabled
-static func h_scale_mode(mode: int):
+static func h_scale_mode(mode: String):
match mode:
- 0:
- Global.get_tree().root.content_scale_mode = Window.CONTENT_SCALE_MODE_CANVAS_ITEMS
- 1:
- Global.get_tree().root.content_scale_mode = Window.CONTENT_SCALE_MODE_DISABLED
+ "scale": Global.get_tree().root.content_scale_mode = Window.CONTENT_SCALE_MODE_CANVAS_ITEMS
+ "disabled": Global.get_tree().root.content_scale_mode = Window.CONTENT_SCALE_MODE_DISABLED
-# func apply_settings():
-# update_fullscreen()
-# update_language()
+static func h_scale_factor(value: float):
+ Global.get_tree().root.content_scale_factor = value
-# # UI scale factor
-# get_tree().root.content_scale_factor = get_setting("ui_scale_factor")
+static func h_volume_master(value: float): Sound.set_volume(0, value)
+static func h_volume_music(value: float): Sound.set_volume(1, value)
+static func h_volume_sfx(value: float): Sound.set_volume(2, value)
-# # Hints
+static func h_touch(mode: String):
+ match mode:
+ "enabled": Global.using_touch = true
+ "disabled": Global.using_touch = false
+ Global.using_touch_change.emit()
+
+static func h_language(language: String):
+ print("STELANG ", language)
+ if language == "system": language = OS.get_locale_language()
+ TranslationServer.set_locale(language)
+
+static func h_fullscreen(mode: String):
+ match mode:
+ "keep": pass
+ "always": DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
+ "never": if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
+ DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
+
+# TODO whatever this does
# if not get_setting("tutorial_started"):
# for k in profile["hints"].keys():
# set_hint(k, false)
-# # Sets all volumes
-# Sound.set_volume(0, get_setting("master_volume"))
-# Sound.set_volume(1, get_setting("music_volume"))
-# Sound.set_volume(2, get_setting("sfx_volume"))
-
-# # Touch controls
-# match get_setting("touch_controls"):
-# # 0: Automatically adjusted
-# 1: # Enabled
-# using_touch = true
-# 2: # Disabled
-# using_touch = false
-# using_touch_change.emit()
-
-# # Input settings
+# TODO update input map for *all* input with a single hook
# InputManager.apply_input_map(InputManager.settings_dictionary_to_input_map(get_category_settings("input")))
-
-# settings_changed.emit()
-
-# func update_language():
-# var language = languages[get_setting("language")][0]
-# if language == "system": language = OS.get_locale_language()
-# TranslationServer.set_locale(language)
-
-# func update_fullscreen():
-# match get_setting("fullscreen"):
-# 0: pass
-# 1: DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
-# 2: if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
-# DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)