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

@ -139,6 +139,10 @@ func set_transport_enabled(enabled: bool):
transport_enabled = enabled
func _ready() -> void:
$SubViewport.msaa_3d = Globalvariables.msaa
$SubViewport.screen_space_aa = Globalvariables.ssaa
get_window().set_theme(load(Globalvariables.theme_index[Globalvariables.theme]))
$ColorRect.color = get_window().theme.get_color("color", "EditorBG")
get_tree().get_root().size_changed.connect(_on_size_changed)
erase_all.connect(_erase_all)
$MenuBar/MenuButton.get_popup().id_pressed.connect(_showtape_menu_button_pressed)

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

View file

@ -3,27 +3,26 @@ extends Panel
@export var thisTab = 0
func _ready() -> void:
$AAOption.selected = get_viewport().msaa_3d
$SSAAOption.selected = get_viewport().screen_space_aa
$AAOption.select(get_viewport().msaa_3d)
$SSAAOption.select(get_viewport().screen_space_aa)
$FOVSlider.value = Globalvariables.FOV
$FOVSlider/CurrentLabel.text = str(int(Globalvariables.FOV))
func _on_tab_bar_tab_changed(tab: int) -> void:
if (thisTab == tab):
self.show()
visible = true
else:
self.hide()
func updateconfig():
Globalvariables.updateConfig()
visible = false
func _on_fov_slider_value_changed(value: float) -> void:
Globalvariables.FOV = value
$FOVSlider/CurrentLabel.text = str(int(value))
Globalvariables.updateConfig()
func _on_option_aa_ss_item_selected(index: int) -> void:
get_viewport().screen_space_aa = int(index == 1) as Viewport.ScreenSpaceAA
Globalvariables.updateConfig()
func _on_option_aa_msaa_item_selected(index: int) -> void:
@ -35,4 +34,4 @@ func _on_option_aa_msaa_item_selected(index: int) -> void:
get_viewport().msaa_3d = Viewport.MSAA_4X
elif index == 3: # 8×
get_viewport().msaa_3d = Viewport.MSAA_8X
Globalvariables.updateConfig()

View file

@ -18,6 +18,8 @@ var stage
func _ready() -> void:
stage = FreeRoamMaps.MapIndex[get_node("../").current_map]["stage"]
set_theme(load(Globalvariables.theme_index[Globalvariables.theme]))
var cosmetics_offset = 0
var cosmetics_count = 0
for cosmetic_subtable in stage["cosmetics"]:

View file

@ -0,0 +1,23 @@
extends Panel
@export var thisTab = 1
func _ready() -> void:
$ScalingOption.select(Globalvariables.scaling)
$ThemeOption.select(Globalvariables.theme)
func _on_tab_bar_tab_changed(tab: int) -> void:
if (thisTab == tab):
visible = true
else:
visible = false
func _on_scaling_option_item_selected(index: int) -> void:
Globalvariables.scaling = index
get_window().content_scale_mode = index as Window.ContentScaleMode
Globalvariables.updateConfig()
func _on_theme_option_item_selected(index: int) -> void:
Globalvariables.theme = index
get_window().set_theme(load(Globalvariables.theme_index[Globalvariables.theme]))
Globalvariables.updateConfig()

View file

@ -0,0 +1 @@
uid://bmqi57p5yipll

View file

@ -8,12 +8,12 @@ func _ready():
$Buttons/EditorButton.grab_focus()
Globalvariables.loadConfig()
print(Globalvariables.FOV)
print(Globalvariables.msaa)
$SettingsScreen/DialogPanel/GraphicsPanel/FOVSlider.value = Globalvariables.FOV
$SettingsScreen/DialogPanel/GraphicsPanel/AAOption.selected = Globalvariables.msaa
$SettingsScreen/DialogPanel/GraphicsPanel/SSAAOption.selected = Globalvariables.ssaa
get_window().set_theme(load(Globalvariables.theme_index[Globalvariables.theme]))
var moddir = DirAccess.open("user://Mods")
if moddir == null:
print("Mod folder was not found. Creating.")

View file

@ -1,6 +1,8 @@
extends Control
@export var x_offset : int = 0
@export var color : String
func _ready() -> void:
self.size.x += x_offset
$ColorRect.color = get_window().theme.get_color("color", color)

View file

@ -108,6 +108,7 @@ func _update_out_flow(new_value: float, _internalid: int) -> void:
out_flow = new_value
func _ready() -> void:
$MovementsBG.color = get_window().theme.get_color("color", "MovementOff")
if (flow_path != "None"):
var flow_control = get_node(flow_path + str(movement_bit) + animatronic + movement_name + current_stage)
flow_control.in_value_updated.connect(self._update_in_flow)