mirror of
https://github.com/RPG-Research/bcirpg.git
synced 2024-04-16 14:23:01 +00:00
Settings implementation updates
Finishes merging of current settings to load all from file, update for display, save to singleton. Also adds currently hard-coded (in the GlobalSaveInstance) file name based on themes choice for use in all control nodes. Applies that theme load to all current control nodes.
This commit is contained in:
parent
2c48b0a433
commit
baa4ee34d4
@ -5,6 +5,7 @@
|
||||
extends Control
|
||||
|
||||
onready var history_source = get_node("/root/History").historyScreensSingleton
|
||||
onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance
|
||||
|
||||
#Abstract class we instance when wanted in game as child of HistoryReference
|
||||
const TextOutput = preload("res://UserInterface/Response.tscn")
|
||||
@ -26,9 +27,8 @@ onready var charSheet = $Con_charSheet/MarginContainer/VBoxContainer/CharacterSh
|
||||
onready var module_map = "user://temp_map.save"
|
||||
|
||||
func _ready() -> void:
|
||||
#DKM TEMP: for testing only -- this will be set in settings
|
||||
save_module()
|
||||
theme=load("res://assets/ui_controlNode_dark_theme.tres")
|
||||
theme=load(settings.themeFile)
|
||||
current_text.show()
|
||||
option_one.show()
|
||||
option_two.show()
|
||||
|
@ -4,8 +4,7 @@ extends Node
|
||||
var settingsInstance = PlayerSettingsTemplate.new()
|
||||
var settings_file = "user://PlayerPreferences.cfg"
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
func _ready() -> void:
|
||||
load_settings_file()
|
||||
|
||||
#Config/ini:
|
||||
@ -16,9 +15,30 @@ func load_settings_file():
|
||||
# If the file didn't load, ignore it.
|
||||
if err != OK:
|
||||
return
|
||||
#Preferences:
|
||||
settingsInstance.inputName = config.get_value("player_preferences", "player_name")
|
||||
settingsInstance.riskFactor = config.get_value("player_preferences", "risk_threshold")
|
||||
#Controls:
|
||||
settingsInstance.fontSize = config.get_value("visual_controls", "font_size")
|
||||
settingsInstance.brightness = config.get_value("visual_controls", "brightness")
|
||||
#General Settings:
|
||||
settingsInstance.volume = config.get_value("general_settings", "volume")
|
||||
settingsInstance.bClosedCaptions = config.get_value("general_settings", "closed_captions")
|
||||
settingsInstance.bdevConsole = config.get_value("general_settings", "dev_console")
|
||||
#Keyboard:
|
||||
settingsInstance.visualKeyboardLayout = config.get_value("virtual_keyboard", "keyboard_layout")
|
||||
#Theme:
|
||||
settingsInstance.themeChoiceInt = config.get_value("theme", "theme_selection")
|
||||
|
||||
load_themeFile()
|
||||
|
||||
#DKM TEMP: working
|
||||
print("Input name loaded as: " + str(settingsInstance.inputName))
|
||||
print("Risk loaded as: " + str(settingsInstance.riskFactor))
|
||||
print("Theme loaded as: " + str(settingsInstance.themeFile))
|
||||
|
||||
func load_themeFile() -> void:
|
||||
#DKM TEMP: this shouldn't be hard-coded:
|
||||
if(settingsInstance.themeChoiceInt == 1):
|
||||
settingsInstance.themeFile = "res://assets/ui_controlNode_light_theme.tres"
|
||||
else:
|
||||
settingsInstance.themeFile = "res://assets/ui_controlNode_dark_theme.tres"
|
||||
|
@ -15,9 +15,9 @@ var bVirtualKeyboard = false
|
||||
# Setting of 0 is Qwerty, Setting of 1 is Davorak, Setting of 2 is Alphabetical
|
||||
var visualKeyboardLayout = 0
|
||||
|
||||
|
||||
# Setting of 0 is dark, setting of 1 is light, and so on
|
||||
var themeChoice = 0
|
||||
var themeChoiceInt = 0
|
||||
var themeFile = "res://assets/ui_controlNode_dark_theme.tres"
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
@ -4,8 +4,10 @@
|
||||
|
||||
extends Control
|
||||
|
||||
onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance
|
||||
|
||||
func _ready() -> void:
|
||||
theme=load(settings.themeFile)
|
||||
$Title/But_SaveChar.grab_focus()
|
||||
|
||||
|
||||
|
@ -3,8 +3,10 @@
|
||||
|
||||
extends Control
|
||||
|
||||
onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance
|
||||
|
||||
func _ready() -> void:
|
||||
theme=load(settings.themeFile)
|
||||
$Title/But_loadCharacter.grab_focus()
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
extends Control
|
||||
|
||||
onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance
|
||||
onready var history_source = get_node("/root/History").historyScreensSingleton
|
||||
onready var current_history = $Background/MarginContainer/Rows/GameInfo/CurrentHistory
|
||||
#For zero-indexed array position:
|
||||
@ -18,8 +19,7 @@ const InputResponse = preload("res://UserInterface/InputResponse.tscn")
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
#DKM TEMP: for testing only -- this will be set in settings
|
||||
theme=load("res://assets/ui_controlNode_dark_theme.tres")
|
||||
theme=load(settings.themeFile)
|
||||
|
||||
print("Loaded history array size is: " + str(history_source.output_history_array.size()))
|
||||
update_pager()
|
||||
|
@ -2,15 +2,15 @@
|
||||
# Expanded for Import Character option
|
||||
|
||||
extends Control
|
||||
|
||||
onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance
|
||||
|
||||
var charFilePath
|
||||
var a
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
#DKM TEMP TODO: replace with settings Singleton theme value
|
||||
#theme=load("res://assets/ui_controlNode_dark_theme.tres")
|
||||
$But_ChangeScene.grab_focus()
|
||||
|
||||
theme=load(settings.themeFile)
|
||||
|
||||
func _on_Button_pressed():
|
||||
$VBoxContainer2/VBoxContainer/FileDialog.popup()
|
||||
|
@ -3,10 +3,9 @@
|
||||
|
||||
extends Control
|
||||
|
||||
var settings_file = "user://PlayerPreferences.cfg"
|
||||
onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
#DKM TEMP: for testing only -- this will be set for all scenes in settings
|
||||
theme=load("res://assets/ui_controlNode_dark_theme.tres")
|
||||
theme=load(settings.themeFile)
|
||||
$VBoxContainer/But_NewGame.grab_focus()
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
extends Control
|
||||
|
||||
onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
#DKM TEMP: for testing only -- this will be set in settings
|
||||
theme=load("res://assets/ui_controlNode_dark_theme.tres")
|
||||
theme=load(settings.themeFile)
|
||||
$VBoxContainer/But_ResumeGame.grab_focus()
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
extends Control
|
||||
|
||||
onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
#DKM TEMP: for testing only -- this will be set in settings
|
||||
theme=load("res://assets/ui_controlNode_dark_theme.tres")
|
||||
theme=load(settings.themeFile)
|
||||
$VBoxContainer/But_ChoosePlayer.grab_focus()
|
||||
|
@ -41,7 +41,6 @@ onready var themeChoiceList = get_node('Panel/HBoxContainer/RootVboxVisualContro
|
||||
var iniFile = ConfigFile.new()
|
||||
|
||||
func saveToInstance():
|
||||
|
||||
#Save to Singleton, so saveFile does not need to be constantly read
|
||||
saveObject.settingsInstance.inputName = NameVar.text
|
||||
saveObject.settingsInstance.riskFactor = NRiskVar.value
|
||||
@ -50,9 +49,15 @@ func saveToInstance():
|
||||
saveObject.settingsInstance.bClosedCaptions = ClosedCaptionsVar.is_pressed()
|
||||
saveObject.settingsInstance.bdevConsole = ConsoleCommandVar.is_pressed()
|
||||
saveObject.settingsInstance.bVirtualKeyboard = bKeyboardEnabled.is_pressed()
|
||||
saveObject.settingsInstance.visualKeyboardLayout = keyboardLayoutList.get_selected_items()
|
||||
saveObject.settingsInstance.themeChoice = themeChoiceList.get_selected_items()
|
||||
|
||||
var savedKeyboardItems = keyboardLayoutList.get_selected_items()
|
||||
var keyboardSelection = savedKeyboardItems[0]
|
||||
saveObject.settingsInstance.visualKeyboardLayout = keyboardSelection
|
||||
var savedThemeItems = themeChoiceList.get_selected_items()
|
||||
var themeSelection = savedThemeItems[0]
|
||||
saveObject.settingsInstance.themeChoiceInt = themeSelection
|
||||
#Trigger re-load of the file name
|
||||
saveObject.load_settings_file()
|
||||
theme=load(saveObject.settingsInstance.themeFile)
|
||||
|
||||
|
||||
func saveFile():
|
||||
@ -71,7 +76,7 @@ func saveFile():
|
||||
|
||||
var keyboardSelection = savedKeyboardItems[0]
|
||||
|
||||
var savedThemeItems = keyboardLayoutList.get_selected_items()
|
||||
var savedThemeItems = themeChoiceList.get_selected_items()
|
||||
|
||||
var themeSelection = savedThemeItems[0]
|
||||
|
||||
@ -100,12 +105,13 @@ func _process(delta):
|
||||
print('saveFileRan')
|
||||
|
||||
func _ready():
|
||||
#DKM TEMP: we need to set these to values from the file
|
||||
#Get the singleton's values for initial settings:
|
||||
NameVar.text = saveObject.settingsInstance.inputName
|
||||
NRiskVar.value = saveObject.settingsInstance.riskFactor
|
||||
#themeChoiceList
|
||||
|
||||
theme=load("res://assets/ui_controlNode_dark_theme.tres")
|
||||
FontVar.value = saveObject.settingsInstance.fontSize
|
||||
ClosedCaptionsVar.pressed = saveObject.settingsInstance.bClosedCaptions
|
||||
ConsoleCommandVar.pressed = saveObject.settingsInstance.bdevConsole
|
||||
bKeyboardEnabled.pressed = saveObject.settingsInstance.bVirtualKeyboard
|
||||
|
||||
print(NameVar.get_path())
|
||||
|
||||
@ -120,6 +126,9 @@ func _ready():
|
||||
for i in range(2):
|
||||
themeChoiceList.add_item(themeContents[i],null,true)
|
||||
|
||||
keyboardLayoutList.select(0,true)
|
||||
keyboardLayoutList.select(saveObject.settingsInstance.visualKeyboardLayout,true)
|
||||
|
||||
themeChoiceList.select(0,true)
|
||||
themeChoiceList.select(saveObject.settingsInstance.themeChoiceInt,true)
|
||||
|
||||
#Load selected theme:
|
||||
theme=load(saveObject.settingsInstance.themeFile)
|
||||
|
@ -177,6 +177,9 @@ margin_left = -77.5
|
||||
margin_top = 30.0
|
||||
margin_right = 77.5
|
||||
margin_bottom = 120.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="Panel/HBoxContainer/RootVboxGeneralSettings/GeneralSettingsLabel/VBoxContainer"]
|
||||
margin_right = 155.0
|
||||
@ -294,24 +297,26 @@ margin_bottom = 99.0
|
||||
auto_height = true
|
||||
|
||||
[node name="HBoxBottomRow" type="HBoxContainer" parent="Panel"]
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_left = 0.500488
|
||||
anchor_right = 0.595215
|
||||
margin_left = -48.5
|
||||
margin_top = 200.0
|
||||
margin_right = 48.5
|
||||
margin_bottom = 225.0
|
||||
alignment = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="SaveButton" type="Button" parent="Panel/HBoxBottomRow"]
|
||||
margin_right = 97.0
|
||||
margin_left = 24.0
|
||||
margin_right = 121.0
|
||||
margin_bottom = 25.0
|
||||
text = "Save Settings"
|
||||
|
||||
[node name="But_ChangeScene" parent="Panel/HBoxBottomRow" instance=ExtResource( 3 )]
|
||||
margin_left = 101.0
|
||||
margin_right = 146.0
|
||||
margin_left = 125.0
|
||||
margin_right = 170.0
|
||||
margin_bottom = 25.0
|
||||
text = "Back"
|
||||
next_scene_path = "res://screens/MenuScreen.tscn"
|
||||
|
Loading…
Reference in New Issue
Block a user