PneumaticPlaything/Scripts/Configs/GlobalVariables.gd
2025-08-14 17:10:00 -07:00

72 lines
1.9 KiB
GDScript

extends Node
var FOV = 80
var config = ConfigFile.new()
var msaa = 1
var ssaa = 1
var scaling = 0
var theme = 0
var shadows = 1
var theme_index = [
"res://UI/Themes/Dark.tres",
"res://UI/Themes/Light.tres",
"res://UI/Themes/AppleII.tres",
"res://UI/Themes/HotDogStand.tres"
]
var background_index = [
"res://UI/MenuBG/1StageBG.png",
"res://UI/MenuBG/BalconyBG.png",
"res://UI/MenuBG/CStageBG.png",
"res://UI/MenuBG/ProtoRoadBG.png",
"res://UI/MenuBG/2StageBG.png",
"res://UI/MenuBG/12StageBG.png",
"res://UI/MenuBG/Mini1StageBG.png",
"res://UI/MenuBG/Cyber3StageBG.png",
]
func _ready() -> void:
msaa = get_viewport().msaa_3d
ssaa = get_viewport().screen_space_aa
loadConfig()
func updateConfig():
msaa = get_viewport().msaa_3d
ssaa = get_viewport().screen_space_aa
config.set_value("GRAPHICS", "fov", FOV)
config.set_value("GRAPHICS", "msaa", msaa)
config.set_value("GRAPHICS", "ssaa", ssaa)
config.set_value("GRAPHICS", "shadows", shadows)
config.set_value("INTERFACE", "scaling", scaling)
config.set_value("INTERFACE", "theme", theme)
config.save("user://settings.cfg")
func loadConfig():
var err = config.load("user://settings.cfg")
print("loading config...")
if err != OK:
print("Couldn't load config!")
return
FOV = config.get_value("GRAPHICS", "fov")
msaa = config.get_value("GRAPHICS", "msaa")
ssaa = config.get_value("GRAPHICS", "ssaa")
shadows = config.get_value("GRAPHICS", "shadows")
scaling = config.get_value("INTERFACE", "scaling")
theme = config.get_value("INTERFACE", "theme")
print("config loaded.")
# set msaa
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