From 06e885f4cb43116797c83844d56aafce9aaaa120 Mon Sep 17 00:00:00 2001 From: To Live Is To Die Date: Sun, 3 Apr 2022 12:10:31 -0600 Subject: [PATCH 1/2] Created a cfg file for the settings menu --- .../SettingsMenuConfig.gd | 24 +++++++++++++++++++ .../SettingsMenuControl.tscn | 16 ++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 Phase2/Godot ===(Game Code)===/MainMenu/GodotUserInterface_Luke_Settings/bcirpg_settingsMenuLuke/SettingsMenuConfig.gd diff --git a/Phase2/Godot ===(Game Code)===/MainMenu/GodotUserInterface_Luke_Settings/bcirpg_settingsMenuLuke/SettingsMenuConfig.gd b/Phase2/Godot ===(Game Code)===/MainMenu/GodotUserInterface_Luke_Settings/bcirpg_settingsMenuLuke/SettingsMenuConfig.gd new file mode 100644 index 0000000..7a495be --- /dev/null +++ b/Phase2/Godot ===(Game Code)===/MainMenu/GodotUserInterface_Luke_Settings/bcirpg_settingsMenuLuke/SettingsMenuConfig.gd @@ -0,0 +1,24 @@ +extends Control + + +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(): + iniFile.save("user://PlayerPreferences.cfg") + +func loadFile(): + pass + +func _ready(): + initFile() diff --git a/Phase2/Godot ===(Game Code)===/MainMenu/GodotUserInterface_Luke_Settings/bcirpg_settingsMenuLuke/SettingsMenuControl.tscn b/Phase2/Godot ===(Game Code)===/MainMenu/GodotUserInterface_Luke_Settings/bcirpg_settingsMenuLuke/SettingsMenuControl.tscn index e0dc656..5199c07 100644 --- a/Phase2/Godot ===(Game Code)===/MainMenu/GodotUserInterface_Luke_Settings/bcirpg_settingsMenuLuke/SettingsMenuControl.tscn +++ b/Phase2/Godot ===(Game Code)===/MainMenu/GodotUserInterface_Luke_Settings/bcirpg_settingsMenuLuke/SettingsMenuControl.tscn @@ -1,8 +1,13 @@ -[gd_scene format=2] +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://SettingsMenuConfig.gd" type="Script" id=1] + +[sub_resource type="StyleBoxFlat" id=1] [node name="Control" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 +script = ExtResource( 1 ) __meta__ = { "_edit_use_anchors_": false } @@ -14,6 +19,7 @@ margin_left = -12.9719 margin_top = -2.0755 margin_right = -12.9719 margin_bottom = -2.0755 +custom_styles/panel = SubResource( 1 ) __meta__ = { "_edit_use_anchors_": false } @@ -107,7 +113,9 @@ text = "Font Size:" margin_top = 18.0 margin_right = 155.0 margin_bottom = 34.0 -max_value = 10.0 +min_value = 1.0 +max_value = 5.0 +value = 5.0 tick_count = 10 ticks_on_borders = true @@ -121,7 +129,9 @@ text = "Brightness:" margin_top = 56.0 margin_right = 155.0 margin_bottom = 72.0 -max_value = 10.0 +min_value = 1.0 +max_value = 5.0 +value = 5.0 tick_count = 10 ticks_on_borders = true From 33ce915df29bb0acbc214c3224d76b631fe64d20 Mon Sep 17 00:00:00 2001 From: To Live Is To Die Date: Sun, 3 Apr 2022 12:57:24 -0600 Subject: [PATCH 2/2] Made a working cfg file --- .../SettingsMenuConfig.gd | 33 +++++++++++++++++-- .../SettingsMenuControl.tscn | 24 +++++++++++--- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/Phase2/Godot ===(Game Code)===/MainMenu/GodotUserInterface_Luke_Settings/bcirpg_settingsMenuLuke/SettingsMenuConfig.gd b/Phase2/Godot ===(Game Code)===/MainMenu/GodotUserInterface_Luke_Settings/bcirpg_settingsMenuLuke/SettingsMenuConfig.gd index 7a495be..25e7514 100644 --- a/Phase2/Godot ===(Game Code)===/MainMenu/GodotUserInterface_Luke_Settings/bcirpg_settingsMenuLuke/SettingsMenuConfig.gd +++ b/Phase2/Godot ===(Game Code)===/MainMenu/GodotUserInterface_Luke_Settings/bcirpg_settingsMenuLuke/SettingsMenuConfig.gd @@ -1,10 +1,27 @@ extends Control +onready var NameVar = get_node('Panel/Label/VBoxContainer/HBoxDisplayName/LineEdit') + +onready var NRiskVar = get_node('Panel/Label/VBoxContainer/HBoxRiskFactor/LineEdit') + +onready var FontVar = get_node('Panel/Label2/VBoxContainer/HSlider2') + +onready var BrightnessVar = get_node('Panel/Label2/VBoxContainer/HSlider3') + +onready var VolumeVar = get_node('Panel/Label3/VBoxContainer/HSlider2') + +onready var ConsoleCommandVar = get_node('Panel/Label3/VBoxContainer/HBoxDevConsole/CheckBox') + +onready var ClosedCaptionsVar = get_node('Panel/Label3/VBoxContainer/HBoxClosedCaptions/CheckBox') + +onready var saveButton = get_node("Panel/SaveButton") + var iniFile = ConfigFile.new() + func initFile(): iniFile.set_value("player_preferences", "player_name", "Cliff") iniFile.set_value("player_preferences", "risk_threshold", 2) @@ -15,10 +32,22 @@ func initFile(): iniFile.set_value("general_settings", "dev_console", 3) iniFile.save("user://PlayerPreferences.cfg") func saveFile(): + iniFile.set_value("player_preferences", "player_name", NameVar.text) + iniFile.set_value("player_preferences", "risk_threshold", NRiskVar.text) + iniFile.set_value("visual_controls", "font_size", FontVar.value) + iniFile.set_value("visual_controls", "brightness", BrightnessVar.value) + iniFile.set_value("general_settings", "volume", VolumeVar.value) + iniFile.set_value("general_settings", "closed_captions", ClosedCaptionsVar.is_pressed()) + iniFile.set_value("general_settings", "dev_console", ConsoleCommandVar.is_pressed()) iniFile.save("user://PlayerPreferences.cfg") func loadFile(): pass - + +func _process(delta): + if saveButton.pressed == true: + saveFile() + print('saveFileRan') + func _ready(): - initFile() + pass diff --git a/Phase2/Godot ===(Game Code)===/MainMenu/GodotUserInterface_Luke_Settings/bcirpg_settingsMenuLuke/SettingsMenuControl.tscn b/Phase2/Godot ===(Game Code)===/MainMenu/GodotUserInterface_Luke_Settings/bcirpg_settingsMenuLuke/SettingsMenuControl.tscn index 5199c07..794ffdc 100644 --- a/Phase2/Godot ===(Game Code)===/MainMenu/GodotUserInterface_Luke_Settings/bcirpg_settingsMenuLuke/SettingsMenuControl.tscn +++ b/Phase2/Godot ===(Game Code)===/MainMenu/GodotUserInterface_Luke_Settings/bcirpg_settingsMenuLuke/SettingsMenuControl.tscn @@ -13,12 +13,13 @@ __meta__ = { } [node name="Panel" type="Panel" parent="."] -anchor_right = 1.0 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 anchor_bottom = 1.0 -margin_left = -12.9719 -margin_top = -2.0755 -margin_right = -12.9719 -margin_bottom = -2.0755 +margin_left = -512.0 +margin_top = -600.0 +margin_right = 512.0 custom_styles/panel = SubResource( 1 ) __meta__ = { "_edit_use_anchors_": false @@ -202,3 +203,16 @@ text = "Developer Console:" margin_left = 129.0 margin_right = 153.0 margin_bottom = 24.0 + +[node name="SaveButton" type="Button" parent="Panel"] +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +margin_left = -146.0 +margin_top = -20.0 +margin_right = 193.0 +text = "Save Settings" +__meta__ = { +"_edit_use_anchors_": false +}