Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Cap_New_Button = preload("res://UserInterface/Option.tscn")

func _ready() -> void:
theme=load(settings.themeFile)
$Title/But_SaveChar.call_deferred("grab_focus")
$Title/But_SaveChar.grab_focus()
_populate_output_character_format()

#This function is helper function for name dropdown task and should be added in ImportCharacter.gd file to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ margin_left = 215.0
margin_top = 23.0
margin_right = 997.0
margin_bottom = 447.0
focus_mode = 0

[node name="Title" type="Label" parent="."]
anchor_right = 1.0
Expand Down Expand Up @@ -68,7 +67,6 @@ margin_left = 370.0
margin_top = 31.0
margin_right = 989.0
margin_bottom = 452.0
follow_focus = true

[node name="VBoxContainer" type="VBoxContainer" parent="Title/ScrollContainer"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ func _ready() -> void:

print("Loaded history array size is: " + str(history_source.output_history_array.size()))
update_pager()

$Background/MarginContainer/Rows/ItemList/But_ChangeScene.call_deferred("grab_focus")
#DKM TEMP:
# page_displayer.text = "1"
# if(current_history.get_child_count() > 0):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

[ext_resource path="res://Screens/HistoryViewer.gd" type="Script" id=1]
[ext_resource path="res://userInterface/But_ChangeScene.tscn" type="PackedScene" id=2]
[ext_resource path="res://assets/Themes/Dark Theme/ui_controlNode_dark_theme.tres" type="Theme" id=3]
[ext_resource path="res://assets/ui_controlNode_dark_theme.tres" type="Theme" id=3]
[ext_resource path="res://Screens/But_HistoryPager.gd" type="Script" id=4]


[node name="HistoryViewer" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ func _ready() -> void:
theme=load(settings.themeFile)
_populate_output_character_format()
#Uncomment this if we want to grab focus on the "Open Character File" option by default
#$VBoxContainer2/But_OpenFile.call_deferred("grab_focus")
$But_Play.call_deferred("grab_focus") #This will grab focus on the "Start Game" option by default
#$VBoxContainer2/But_OpenFile.grab_focus()
$But_Play.grab_focus() #This will grab focus on the "Start Game" option by default

func _on_Button_pressed():
$FileDialog.popup()
Expand Down Expand Up @@ -140,9 +140,8 @@ func _populate_preset_character_format(file:File):

# Connect the last LineEdit back to the first button
if previous_control != $VBoxContainer2/Save_Button:
#previous_control.focus_next = $VBoxContainer2/But_OpenFile.get_path()
#$VBoxContainer2/But_OpenFile.focus_previous = previous_control.get_path()
previous_control.focus_next = $But_Play.get_path()
previous_control.focus_next = $VBoxContainer2/But_OpenFile.get_path()
$VBoxContainer2/But_OpenFile.focus_previous = previous_control.get_path()


#FUNCTION clear the character sheet
Expand All @@ -164,7 +163,7 @@ func _on_FileDialog_file_selected(path):
_populate_preset_character_format(file)

file.close()
$VBoxContainer2/But_OpenFile.call_deferred("grab_focus")
$VBoxContainer2/But_OpenFile.grab_focus()

#FUNCTION save data to character singleton
#Params: None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=5 format=2]

[ext_resource path="res://Screens/ImportCharacter.gd" type="Script" id=1]
[ext_resource path="res://UserInterface/But_PlayButton.gd" type="Script" id=2]
[ext_resource path="res://UserInterface/Title.tscn" type="PackedScene" id=3]
[ext_resource path="res://UserInterface/But_ChangeScene.tscn" type="PackedScene" id=4]
[ext_resource path="res://UserInterface/FileDialog_Controls.gd" type="Script" id=5]

[node name="Control" type="Control"]
anchor_right = 1.0
Expand Down Expand Up @@ -36,7 +35,6 @@ rect_min_size = Vector2( 400, 140 )
window_title = "Open a File"
mode = 0
access = 2
script = ExtResource( 5 )
__meta__ = {
"_edit_use_anchors_": false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
theme=load(settings.themeFile)
GlobalSaveInstance.load_fontSize(theme)
$VBoxContainer/But_NewGame.call_deferred("grab_focus")
$VBoxContainer/But_NewGame.grab_focus()
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[ext_resource path="res://Screens/MenuScreen.gd" type="Script" id=2]
[ext_resource path="res://assets/liberation_serif_40pt.tres" type="DynamicFont" id=3]
[ext_resource path="res://UserInterface/Title.tscn" type="PackedScene" id=5]
[ext_resource path="res://assets/Themes/Dark Theme/ui_controlNode_dark_theme.tres" type="Theme" id=6]
[ext_resource path="res://assets/ui_controlNode_dark_theme.tres" type="Theme" id=6]
[ext_resource path="res://UserInterface/But_Quit.tscn" type="PackedScene" id=10]

[node name="MenuScreen" type="Control"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
theme=load(settings.themeFile)
$VBoxContainer/But_Multi_Join.call_deferred("grab_focus")
$VBoxContainer/But_Multi_Join.grab_focus()
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

[ext_resource path="res://UserInterface/But_ChangeScene.tscn" type="PackedScene" id=1]
[ext_resource path="res://Screens/MenuServerOptions.gd" type="Script" id=2]
[ext_resource path="res://assets/Themes/Dark Theme/ui_controlNode_dark_theme.tres" type="Theme" id=6]

[ext_resource path="res://assets/ui_controlNode_dark_theme.tres" type="Theme" id=6]

[node name="MenuServerOptions" type="Control"]
anchor_right = 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
theme=load(settings.themeFile)
$VBoxContainer/But_ResumeGame.call_deferred("grab_focus")
$VBoxContainer/But_ResumeGame.grab_focus()
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
[ext_resource path="res://UserInterface/But_ChangeScene.tscn" type="PackedScene" id=1]
[ext_resource path="res://UserInterface/But_ResumeGame.gd" type="Script" id=2]
[ext_resource path="res://Screens/MoreOptions.gd" type="Script" id=3]
[ext_resource path="res://assets/Themes/Dark Theme/ui_controlNode_dark_theme.tres" type="Theme" id=6]

[ext_resource path="res://assets/ui_controlNode_dark_theme.tres" type="Theme" id=6]

[node name="MoreOptions" type="Control"]
anchor_right = 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ onready var settings = get_node("/root/GlobalSaveInstance").settingsInstance
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
theme=load(settings.themeFile)
$VBoxContainer/But_ChoosePlayer.call_deferred("grab_focus")
$VBoxContainer/But_ChoosePlayer.grab_focus()
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

[ext_resource path="res://UserInterface/But_ChangeScene.tscn" type="PackedScene" id=1]
[ext_resource path="res://Screens/PlayerSelection.gd" type="Script" id=2]
[ext_resource path="res://assets/Themes/Dark Theme/ui_controlNode_dark_theme.tres" type="Theme" id=6]

[ext_resource path="res://assets/ui_controlNode_dark_theme.tres" type="Theme" id=6]

[node name="PlayerSelection" type="Control"]
anchor_right = 1.0
Expand Down
126 changes: 20 additions & 106 deletions Phase2/MVP/Game/bcirpg_game_mvp_2024_0831A/Screens/SettingsMenuConfig.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ extends Control
#Allow us to link to the dropdowns on the UI:
export (NodePath) var genre_dropdown_path
export (NodePath) var game_dropdown_path
export (NodePath) var theme_dropdown_path

#Allows us to set the directory where themes will be looked for
export var theme_directory_path: String = "res://assets/Themes/"

# Items to Fill the dropdown Lists
onready var keyboardContents = ["Qwerty", "Dvorak", "Alphabetical"]
Expand All @@ -21,7 +17,6 @@ onready var saveObject = get_node('/root/GlobalSaveInstance')

onready var genre_dropdown = get_node(genre_dropdown_path)
onready var game_dropdown = get_node(game_dropdown_path)
onready var theme_dropdown = get_node(theme_dropdown_path)

#res://SettingsMenuControl.tscn

Expand All @@ -32,9 +27,6 @@ onready var GAL = Genre_Layer.new()
const Game_Layer := preload("res://globalScripts/GSP_Lookups.gd")
onready var GSP = Game_Layer.new()

#Dictionary to store file paths for themes and their corresponding names, will be a 2D array
var themes_names_paths_dict = {}

# Vars For UI Widgets
onready var NameVar = get_node('SettingsScroll/HBoxContainer/RootVboxPlayerPreferences/Label/VBoxPlayerPreferances/DisplayNameLineEdit')

Expand Down Expand Up @@ -75,21 +67,16 @@ func saveToInstance():
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
# #DKM TEMP: for web version, setting this to the singleton without requiring reprocess of file
# if(saveObject.settingsInstance.themeChoiceInt == 1):
# saveObject.settingsInstance.themeFile = "res://assets/ui_controlNode_light_theme.tres"
# else:
# saveObject.settingsInstance.themeFile = "res://assets/ui_controlNode_dark_theme.tres"

print(theme_dropdown.get_selected_id())
saveObject.settingsInstance.themeFile = themes_names_paths_dict[theme_dropdown.get_item_text(theme_dropdown.get_selected_id())]
var savedThemeItems = themeChoiceList.get_selected_items()
var themeSelection = savedThemeItems[0]
saveObject.settingsInstance.themeChoiceInt = themeSelection
#DKM TEMP: for web version, setting this to the singleton without requiring reprocess of file
if(saveObject.settingsInstance.themeChoiceInt == 1):
saveObject.settingsInstance.themeFile = "res://assets/ui_controlNode_light_theme.tres"
else:
saveObject.settingsInstance.themeFile = "res://assets/ui_controlNode_dark_theme.tres"
#Load selected theme:
theme=load(saveObject.settingsInstance.themeFile)

#Trigger re-load of the file name
#saveObject.load_settings_file()
#theme=load(saveObject.settingsInstance.themeFile)
Expand All @@ -111,12 +98,15 @@ func saveFile():

var keyboardSelection = savedKeyboardItems[0]

var savedThemeItems = themeChoiceList.get_selected_items()

var themeSelection = savedThemeItems[0]

print(typeof(keyboardSelection))

iniFile.set_value("virtual_keyboard", "keyboard_layout", keyboardSelection)

# save the filepath to the theme we're using
iniFile.set_value("theme", "theme_selection", themes_names_paths_dict[theme_dropdown.get_item_text(theme_dropdown.get_selected_id())])
iniFile.set_value("theme", "theme_selection", themeSelection)

iniFile.set_value("player_preferences", "genre_selection", saveObject.settingsInstance.genre_options[genre_dropdown.get_selected_id()])
iniFile.set_value("player_preferences", "game_selection", saveObject.settingsInstance.game_options[game_dropdown.get_selected_id()])
Expand Down Expand Up @@ -162,86 +152,13 @@ func add_game_options():
if(game != "OPEND6_FANTASY"):
saveObject.settingsInstance.game_options.append(game)
game_dropdown.add_item(str(game).to_lower())

#FUNCTION: Add Theme Options (to dropdown and dictionary)
#PARAMS: None
#Returns: None
#Notes: loads themes from theme_directory_path, themes_names_paths_dict is edited
func add_theme_options():
var themeChoices = get_theme_paths_recursive(theme_directory_path)
for theme_path in themeChoices:
var theme_name = get_theme_name(theme_path)
theme_dropdown.add_item(theme_name)
themes_names_paths_dict[theme_name] = theme_path

#FUNCTION: Get Theme Paths Recursive
#PARAMS: None
#Returns: array of valid theme paths from theme_directory_path and subdirectories
#Notes:
func get_theme_paths_recursive(directory_path) -> Array:
var to_return_array = []
var directory = Directory.new()
# open() can return OK, FAILED, or ERR_...
if directory.open(directory_path) == OK:
# start a stream to list files and directories
directory.list_dir_begin(true, true) # "true" leaves out . and .. directories and hidden files
var file_name = directory.get_next()
var file_path = directory_path + file_name
print(file_path)
# I don't know if this is the correct way to check for file existence
# in an ideal world, this finds bundled resources, but I genuinely have no idea if this is the right way to do that
while file_name != "":
# check if the file is actually a directory
if directory.current_is_dir():
file_path = file_path + "/"
to_return_array.append_array(get_theme_paths_recursive(file_path))
elif ResourceLoader.exists(file_path) || directory.file_exists(file_path):
# make sure the file is a theme file
# check for the text "gd_resource type=\"Theme\""
# this should be more efficient than loading the whole resource, then checking its type?
var file = File.new()
file.open(file_path, File.READ)
var file_first_line = file.get_line()
if file_first_line.find("gd_resource type=\"Theme\"") != -1:
#file is a theme file
to_return_array.append(file_path)
file_name = directory.get_next()
file_path = directory_path + file_name
directory.list_dir_end()
return to_return_array
else:
return []

#FUNCTION: Get Theme Name
#PARAMS: path to theme
#Returns: name of theme resource or theme's filename if theme has no name
#Notes:
func get_theme_name(theme_path) -> String:
var regex = RegEx.new()
regex.compile("resource_name = \"(.*)\"")

var theme_file = File.new()
theme_file.open(theme_path, File.READ)
var file_text = theme_file.get_as_text()
# get the first capture group from the regex as the name
var regex_result = regex.search(file_text)

if regex_result != null:
# if the theme has a name
var theme_name = regex_result.get_string(1)
return theme_name

regex.compile(".*\/(.*$)")
return regex.search(theme_path).get_string(1)


func _ready():
#Get our initial genre options for dropdown:
add_genre_options()
#Get our initial game system options for dropdown:
add_game_options()
#Get theme options for dropdown:
add_theme_options()

#Get the singleton's values for initial settings:
NameVar.text = saveObject.settingsInstance.inputName
Expand All @@ -254,14 +171,6 @@ func _ready():
#genre_dropdown.select(saveObject.settingsInstance.genre_selection)
genre_dropdown.select(saveObject.settingsInstance.genre_options.find(saveObject.settingsInstance.genre_selection))
game_dropdown.select(saveObject.settingsInstance.game_options.find(saveObject.settingsInstance.game_selection))

#loop through the theme dropdown ooptions until we find the one that matches the name of the saved theme and select it
for i in range(theme_dropdown.get_item_count()):
#print("theme dropdown i = " + str(i))
#print("theme dropdown text = " + theme_dropdown.get_item_text(i))
if theme_dropdown.get_item_text(i) == get_theme_name(saveObject.settingsInstance.themeFile):
theme_dropdown.select(i)
break

print(NameVar.get_path())

Expand All @@ -271,9 +180,14 @@ func _ready():

keyboardLayoutList.select(0,true)

# Init Theme Choice List

for i in range(2):
themeChoiceList.add_item(themeContents[i],null,true)

keyboardLayoutList.select(saveObject.settingsInstance.visualKeyboardLayout,true)

themeChoiceList.select(saveObject.settingsInstance.themeChoiceInt,true)

#Load selected theme:
theme=load(saveObject.settingsInstance.themeFile)

$HBoxBottomRow/But_ChangeScene.call_deferred("grab_focus")
Loading