add theming support, fix ui issues, add ui scaling option

This commit is contained in:
Persephone Bubblegum-Holiday 2025-08-13 00:21:27 -07:00
parent 61806723ba
commit 1ced41d096
18 changed files with 259 additions and 49 deletions

View file

@ -4,10 +4,20 @@ var FOV = 80
var config = ConfigFile.new()
var msaa = 1
var ssaa = 1
var scaling = 0
var theme = 0
var theme_index = [
"res://UI/Themes/Dark.tres",
"res://UI/Themes/Light.tres",
"res://UI/Themes/AppleII.tres",
"res://UI/Themes/HotDogStand.tres"
]
func _ready() -> void:
msaa = get_viewport().msaa_3d
ssaa = get_viewport().screen_space_aa
loadConfig()
func updateConfig():
msaa = get_viewport().msaa_3d
@ -15,6 +25,8 @@ func updateConfig():
config.set_value("GRAPHICS", "fov", FOV)
config.set_value("GRAPHICS", "msaa", msaa)
config.set_value("GRAPHICS", "ssaa", ssaa)
config.set_value("INTERFACE", "scaling", scaling)
config.set_value("INTERFACE", "theme", theme)
config.save("user://settings.cfg")
func loadConfig():
@ -27,18 +39,20 @@ func loadConfig():
FOV = config.get_value("GRAPHICS", "fov")
msaa = config.get_value("GRAPHICS", "msaa")
ssaa = config.get_value("GRAPHICS", "ssaa")
scaling = config.get_value("INTERFACE", "scaling")
theme = config.get_value("INTERFACE", "theme")
print("config loaded.")
# set msaa
var index = msaa
if index == 0: # Disabled
get_viewport().msaa_3d = Viewport.MSAA_DISABLED
elif index == 1: # 2×
get_viewport().msaa_3d = Viewport.MSAA_2X
elif index == 2: # 4×
get_viewport().msaa_3d = Viewport.MSAA_4X
elif index == 3: # 8×
get_viewport().msaa_3d = Viewport.MSAA_8X
# set ssaa
get_viewport().screen_space_aa = int(index == 1) as Viewport.ScreenSpaceAA
match (msaa):
0:
get_viewport().msaa_3d = Viewport.MSAA_DISABLED
1:
get_viewport().msaa_3d = Viewport.MSAA_2X
2:
get_viewport().msaa_3d = Viewport.MSAA_4X
3:
get_viewport().msaa_3d = Viewport.MSAA_8X
get_viewport().screen_space_aa = ssaa as Viewport.ScreenSpaceAA
get_window().content_scale_mode = scaling as Window.ContentScaleMode