Changes to settings menu, added singleton

This commit is contained in:
To Live Is To Die 2022-04-10 12:27:10 -06:00
parent 8897e5222a
commit 8fd1d3a524
4 changed files with 103 additions and 85 deletions

View File

@ -1,9 +1,8 @@
extends Control extends Control
onready var NameVar = get_node('Panel/Label/VBoxContainer/HBoxDisplayName/LineEdit') onready var NameVar = get_node('Panel/Label/VBoxContainer/HBoxDisplayName/LineEdit')
onready var NRiskVar = get_node('Panel/Label/VBoxContainer/HBoxRiskFactor/LineEdit') onready var NRiskVar = get_node('Panel/Label/VBoxContainer/VBoxContainer/RiskSlider')
onready var FontVar = get_node('Panel/Label2/VBoxContainer/HSlider2') onready var FontVar = get_node('Panel/Label2/VBoxContainer/HSlider2')
@ -15,27 +14,18 @@ onready var ConsoleCommandVar = get_node('Panel/Label3/VBoxContainer/HBoxDevCons
onready var ClosedCaptionsVar = get_node('Panel/Label3/VBoxContainer/HBoxClosedCaptions/CheckBox') onready var ClosedCaptionsVar = get_node('Panel/Label3/VBoxContainer/HBoxClosedCaptions/CheckBox')
onready var saveButton = get_node("Panel/SaveButton") onready var DarkModeVar = get_node("Panel/Label3/VBoxContainer/HBoxDarkMode/CheckBox")
onready var saveButton = get_node("Panel/Label3/VBoxContainer/SaveButton")
var iniFile = ConfigFile.new() var iniFile = ConfigFile.new()
func initFile():
iniFile.set_value("player_preferences", "player_name", "Cliff")
iniFile.set_value("player_preferences", "risk_threshold", 2)
iniFile.set_value("visual_controls", "font_size", 3)
iniFile.set_value("visual_controls", "brightness", 3)
iniFile.set_value("general_settings", "volume", 3)
iniFile.set_value("general_settings", "closed_captions", false)
iniFile.set_value("general_settings", "dev_console", 3)
iniFile.save("user://PlayerPreferences.cfg")
func saveFile(): func saveFile():
iniFile.set_value("player_preferences", "player_name", NameVar.text) iniFile.set_value("player_preferences", "player_name", NameVar.text)
iniFile.set_value("player_preferences", "risk_threshold", NRiskVar.text) iniFile.set_value("player_preferences", "risk_threshold", NRiskVar.value)
iniFile.set_value("visual_controls", "font_size", FontVar.value) iniFile.set_value("visual_controls", "font_size", FontVar.value)
iniFile.set_value("visual_controls", "brightness", BrightnessVar.value) iniFile.set_value("visual_controls", "brightness", BrightnessVar.value)
iniFile.set_value("visual_controls", "dark_mode", DarkModeVar.is_pressed())
iniFile.set_value("general_settings", "volume", VolumeVar.value) iniFile.set_value("general_settings", "volume", VolumeVar.value)
iniFile.set_value("general_settings", "closed_captions", ClosedCaptionsVar.is_pressed()) iniFile.set_value("general_settings", "closed_captions", ClosedCaptionsVar.is_pressed())
iniFile.set_value("general_settings", "dev_console", ConsoleCommandVar.is_pressed()) iniFile.set_value("general_settings", "dev_console", ConsoleCommandVar.is_pressed())

View File

@ -1,12 +1,15 @@
[gd_scene load_steps=3 format=2] [gd_scene load_steps=4 format=2]
[ext_resource path="res://SettingsMenuConfig.gd" type="Script" id=1] [ext_resource path="res://SettingsMenuConfig.gd" type="Script" id=1]
[ext_resource path="res://assets/liberation_serif.tres" type="DynamicFont" id=2]
[sub_resource type="StyleBoxFlat" id=1] [sub_resource type="Theme" id=3]
default_font = ExtResource( 2 )
[node name="Control" type="Control"] [node name="Control" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
theme = SubResource( 3 )
script = ExtResource( 1 ) script = ExtResource( 1 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
@ -14,13 +17,13 @@ __meta__ = {
[node name="Panel" type="Panel" parent="."] [node name="Panel" type="Panel" parent="."]
anchor_left = 0.5 anchor_left = 0.5
anchor_top = 1.0 anchor_top = 0.5
anchor_right = 0.5 anchor_right = 0.5
anchor_bottom = 1.0 anchor_bottom = 0.5
margin_left = -512.0 margin_left = -512.0
margin_top = -600.0 margin_top = -300.0
margin_right = 512.0 margin_right = 512.0
custom_styles/panel = SubResource( 1 ) margin_bottom = 300.0
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
@ -47,36 +50,47 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="HBoxRiskFactor" type="HBoxContainer" parent="Panel/Label/VBoxContainer"]
margin_right = 202.0
margin_bottom = 24.0
[node name="Label" type="Label" parent="Panel/Label/VBoxContainer/HBoxRiskFactor"]
margin_top = 5.0
margin_right = 140.0
margin_bottom = 19.0
text = "Risk Factor Threshold:"
[node name="LineEdit" type="LineEdit" parent="Panel/Label/VBoxContainer/HBoxRiskFactor"]
margin_left = 144.0
margin_right = 202.0
margin_bottom = 24.0
[node name="HBoxDisplayName" type="HBoxContainer" parent="Panel/Label/VBoxContainer"] [node name="HBoxDisplayName" type="HBoxContainer" parent="Panel/Label/VBoxContainer"]
margin_top = 28.0 margin_right = 157.0
margin_right = 202.0 margin_bottom = 29.0
margin_bottom = 52.0
[node name="Label" type="Label" parent="Panel/Label/VBoxContainer/HBoxDisplayName"] [node name="Label" type="Label" parent="Panel/Label/VBoxContainer/HBoxDisplayName"]
margin_top = 5.0 margin_top = 5.0
margin_right = 93.0 margin_right = 95.0
margin_bottom = 19.0 margin_bottom = 24.0
text = "Display Name:" text = "Display Name:"
[node name="LineEdit" type="LineEdit" parent="Panel/Label/VBoxContainer/HBoxDisplayName"] [node name="LineEdit" type="LineEdit" parent="Panel/Label/VBoxContainer/HBoxDisplayName"]
margin_left = 97.0 margin_left = 99.0
margin_right = 155.0 margin_right = 157.0
margin_bottom = 24.0 margin_bottom = 29.0
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/Label/VBoxContainer"]
margin_top = 33.0
margin_right = 157.0
margin_bottom = 72.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HBoxFontSize" type="HBoxContainer" parent="Panel/Label/VBoxContainer/VBoxContainer"]
margin_right = 157.0
margin_bottom = 19.0
[node name="Label" type="Label" parent="Panel/Label/VBoxContainer/VBoxContainer/HBoxFontSize"]
margin_right = 145.0
margin_bottom = 19.0
text = "Risk Factor Threshold:"
[node name="RiskSlider" type="HSlider" parent="Panel/Label/VBoxContainer/VBoxContainer"]
margin_top = 23.0
margin_right = 157.0
margin_bottom = 39.0
min_value = 1.0
max_value = 5.0
value = 5.0
tick_count = 10
ticks_on_borders = true
[node name="Label2" type="Label" parent="Panel"] [node name="Label2" type="Label" parent="Panel"]
anchor_left = 0.5 anchor_left = 0.5
@ -103,17 +117,17 @@ __meta__ = {
[node name="HBoxFontSize" type="HBoxContainer" parent="Panel/Label2/VBoxContainer"] [node name="HBoxFontSize" type="HBoxContainer" parent="Panel/Label2/VBoxContainer"]
margin_right = 155.0 margin_right = 155.0
margin_bottom = 14.0 margin_bottom = 19.0
[node name="Label" type="Label" parent="Panel/Label2/VBoxContainer/HBoxFontSize"] [node name="Label" type="Label" parent="Panel/Label2/VBoxContainer/HBoxFontSize"]
margin_right = 62.0 margin_right = 64.0
margin_bottom = 14.0 margin_bottom = 19.0
text = "Font Size:" text = "Font Size:"
[node name="HSlider2" type="HSlider" parent="Panel/Label2/VBoxContainer"] [node name="HSlider2" type="HSlider" parent="Panel/Label2/VBoxContainer"]
margin_top = 18.0 margin_top = 23.0
margin_right = 155.0 margin_right = 155.0
margin_bottom = 34.0 margin_bottom = 39.0
min_value = 1.0 min_value = 1.0
max_value = 5.0 max_value = 5.0
value = 5.0 value = 5.0
@ -121,15 +135,15 @@ tick_count = 10
ticks_on_borders = true ticks_on_borders = true
[node name="Label" type="Label" parent="Panel/Label2/VBoxContainer"] [node name="Label" type="Label" parent="Panel/Label2/VBoxContainer"]
margin_top = 38.0 margin_top = 43.0
margin_right = 155.0 margin_right = 155.0
margin_bottom = 52.0 margin_bottom = 62.0
text = "Brightness:" text = "Brightness:"
[node name="HSlider3" type="HSlider" parent="Panel/Label2/VBoxContainer"] [node name="HSlider3" type="HSlider" parent="Panel/Label2/VBoxContainer"]
margin_top = 56.0 margin_top = 66.0
margin_right = 155.0 margin_right = 155.0
margin_bottom = 72.0 margin_bottom = 82.0
min_value = 1.0 min_value = 1.0
max_value = 5.0 max_value = 5.0
value = 5.0 value = 5.0
@ -140,7 +154,7 @@ ticks_on_borders = true
anchor_left = 0.5 anchor_left = 0.5
anchor_right = 0.5 anchor_right = 0.5
margin_left = -52.5 margin_left = -52.5
margin_top = 220.0 margin_top = 210.0
margin_right = 52.5 margin_right = 52.5
text = "General Settings" text = "General Settings"
__meta__ = { __meta__ = {
@ -151,67 +165,79 @@ __meta__ = {
anchor_left = 0.5 anchor_left = 0.5
anchor_right = 0.5 anchor_right = 0.5
margin_left = -77.5 margin_left = -77.5
margin_top = 40.0 margin_top = 30.0
margin_right = 77.5 margin_right = 77.5
margin_bottom = 52.0 margin_bottom = 120.0
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="Label" type="Label" parent="Panel/Label3/VBoxContainer"] [node name="Label" type="Label" parent="Panel/Label3/VBoxContainer"]
margin_right = 155.0 margin_right = 155.0
margin_bottom = 14.0 margin_bottom = 19.0
rect_pivot_offset = Vector2( 62, 14 ) rect_pivot_offset = Vector2( 62, 14 )
text = "Volume:" text = "Volume:"
[node name="HSlider2" type="HSlider" parent="Panel/Label3/VBoxContainer"] [node name="HSlider2" type="HSlider" parent="Panel/Label3/VBoxContainer"]
margin_top = 18.0 margin_top = 23.0
margin_right = 155.0 margin_right = 155.0
margin_bottom = 34.0 margin_bottom = 39.0
max_value = 10.0 max_value = 10.0
tick_count = 10 tick_count = 10
ticks_on_borders = true ticks_on_borders = true
[node name="HBoxClosedCaptions" type="HBoxContainer" parent="Panel/Label3/VBoxContainer"] [node name="HBoxClosedCaptions" type="HBoxContainer" parent="Panel/Label3/VBoxContainer"]
margin_top = 38.0 margin_top = 43.0
margin_right = 155.0 margin_right = 155.0
margin_bottom = 62.0 margin_bottom = 70.0
[node name="Label" type="Label" parent="Panel/Label3/VBoxContainer/HBoxClosedCaptions"] [node name="Label" type="Label" parent="Panel/Label3/VBoxContainer/HBoxClosedCaptions"]
margin_top = 5.0 margin_top = 4.0
margin_right = 106.0 margin_right = 108.0
margin_bottom = 19.0 margin_bottom = 23.0
text = "Closed Captions:" text = "Closed Captions:"
[node name="CheckBox" type="CheckBox" parent="Panel/Label3/VBoxContainer/HBoxClosedCaptions"] [node name="CheckBox" type="CheckBox" parent="Panel/Label3/VBoxContainer/HBoxClosedCaptions"]
margin_left = 110.0 margin_left = 112.0
margin_right = 134.0 margin_right = 136.0
margin_bottom = 24.0 margin_bottom = 27.0
[node name="HBoxDevConsole" type="HBoxContainer" parent="Panel/Label3/VBoxContainer"] [node name="HBoxDevConsole" type="HBoxContainer" parent="Panel/Label3/VBoxContainer"]
margin_top = 66.0 margin_top = 74.0
margin_right = 155.0 margin_right = 155.0
margin_bottom = 90.0 margin_bottom = 101.0
[node name="Label" type="Label" parent="Panel/Label3/VBoxContainer/HBoxDevConsole"] [node name="Label" type="Label" parent="Panel/Label3/VBoxContainer/HBoxDevConsole"]
margin_top = 5.0 margin_top = 4.0
margin_right = 125.0 margin_right = 126.0
margin_bottom = 19.0 margin_bottom = 23.0
text = "Developer Console:" text = "Developer Console:"
[node name="CheckBox" type="CheckBox" parent="Panel/Label3/VBoxContainer/HBoxDevConsole"] [node name="CheckBox" type="CheckBox" parent="Panel/Label3/VBoxContainer/HBoxDevConsole"]
margin_left = 129.0 margin_left = 130.0
margin_right = 153.0 margin_right = 154.0
margin_bottom = 24.0 margin_bottom = 27.0
[node name="SaveButton" type="Button" parent="Panel"] [node name="HBoxDarkMode" type="HBoxContainer" parent="Panel/Label3/VBoxContainer"]
anchor_left = 0.5 margin_top = 105.0
anchor_top = 1.0 margin_right = 155.0
anchor_right = 0.5 margin_bottom = 132.0
anchor_bottom = 1.0
margin_left = -146.0 [node name="Label" type="Label" parent="Panel/Label3/VBoxContainer/HBoxDarkMode"]
margin_top = -20.0 margin_top = 4.0
margin_right = 193.0 margin_right = 77.0
margin_bottom = 23.0
text = "Dark Mode:"
[node name="CheckBox" type="CheckBox" parent="Panel/Label3/VBoxContainer/HBoxDarkMode"]
margin_left = 81.0
margin_right = 105.0
margin_bottom = 27.0
[node name="SaveButton" type="Button" parent="Panel/Label3/VBoxContainer"]
margin_top = 136.0
margin_right = 155.0
margin_bottom = 161.0
text = "Save Settings" text = "Save Settings"
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false

View File

@ -3,4 +3,6 @@
[ext_resource path="res://assets/Fonts_source/LiberationSerif-Regular.ttf" type="DynamicFontData" id=1] [ext_resource path="res://assets/Fonts_source/LiberationSerif-Regular.ttf" type="DynamicFontData" id=1]
[resource] [resource]
use_mipmaps = true
use_filter = true
font_data = ExtResource( 1 ) font_data = ExtResource( 1 )

View File

@ -26,7 +26,7 @@ config/icon="res://icon.png"
[autoload] [autoload]
Settings="*res://Settings.gd" SettingsMenuConfig="*res://SettingsMenuConfig.gd"
[physics] [physics]