mirror of
https://github.com/RPG-Research/bcirpg.git
synced 2024-04-16 14:23:01 +00:00
Merge branch 'master' of https://github.com/RPG-Research/bcirpg
This commit is contained in:
commit
6c9d371734
@ -0,0 +1,34 @@
|
||||
tool
|
||||
extends Button
|
||||
|
||||
onready var game_history_array = get_node("../../../../../").history_array
|
||||
|
||||
var is_history = false
|
||||
|
||||
|
||||
func _on_But_History_button_up():
|
||||
var history_pager_button = get_node("../../ItemList/But_History_Page")
|
||||
var history_rows_node = get_node("../../GameInfo/HistoryRows")
|
||||
var current_text_node = get_node("../../GameInfo/CurrentText")
|
||||
var option_one = get_node("../../InputArea/VBoxContainer/option1")
|
||||
var option_two = get_node("../../InputArea/VBoxContainer/option2")
|
||||
var option_three = get_node("../../InputArea/VBoxContainer/option3")
|
||||
|
||||
if(!is_history):
|
||||
history_rows_node.add_child(game_history_array[0])
|
||||
history_pager_button.show()
|
||||
history_rows_node.show()
|
||||
current_text_node.hide()
|
||||
option_one.hide()
|
||||
option_two.hide()
|
||||
option_three.hide()
|
||||
is_history = true
|
||||
else:
|
||||
history_pager_button.hide()
|
||||
history_rows_node.hide()
|
||||
current_text_node.show()
|
||||
option_one.show()
|
||||
option_two.show()
|
||||
option_three.show()
|
||||
is_history = false
|
||||
|
@ -0,0 +1,12 @@
|
||||
extends Button
|
||||
|
||||
onready var game_history_array = get_node("../../../../../").history_array
|
||||
|
||||
var current_page = 0
|
||||
|
||||
func _on_But_History_Page_button_up():
|
||||
var history_rows_node = get_node("../../GameInfo/HistoryRows")
|
||||
current_page += 1
|
||||
history_rows_node.remove_child(history_rows_node.get_child(0))
|
||||
history_rows_node.add_child(game_history_array[current_page])
|
||||
|
@ -11,6 +11,8 @@ func initialize(starting_locale) -> String:
|
||||
current_opt1 = get_node("../Background/MarginContainer/Rows/InputArea/VBoxContainer/option1")
|
||||
current_opt2 = get_node("../Background/MarginContainer/Rows/InputArea/VBoxContainer/option2")
|
||||
current_opt3 = get_node("../Background/MarginContainer/Rows/InputArea/VBoxContainer/option3")
|
||||
|
||||
current_opt1.grab_focus()
|
||||
return change_room(starting_locale)
|
||||
|
||||
#Function that loads response from the option string chosen
|
||||
|
@ -3,30 +3,37 @@ extends Control
|
||||
#Abstract class we instance when wanted in game as child of HistoryReference
|
||||
const TextOutput = preload("res://UserInterface/Response.tscn")
|
||||
const InputResponse = preload("res://UserInterface/InputResponse.tscn")
|
||||
#Limit the length of our history:
|
||||
var max_scroll_length := 0
|
||||
|
||||
#TODO: offload this to file
|
||||
#For storing history selections
|
||||
var output_history_singleton = OutputHistory.new()
|
||||
var history_array = output_history_singleton.output_history_array
|
||||
|
||||
#TODO: change 'HistoryRows' to better name for current use
|
||||
var history_screens_array = Array()
|
||||
|
||||
onready var command_processor = $CommandProcessor
|
||||
onready var history_rows = $Background/MarginContainer/Rows/GameInfo/ScrollContainer/HistoryRows
|
||||
onready var scroll = $Background/MarginContainer/Rows/GameInfo/ScrollContainer
|
||||
onready var scrollbar = scroll.get_v_scrollbar()
|
||||
onready var current_text = $Background/MarginContainer/Rows/GameInfo/CurrentText
|
||||
onready var history_rows = $Background/MarginContainer/Rows/GameInfo/HistoryRows
|
||||
onready var history_pager = $Background/MarginContainer/Rows/ItemList/But_History_Page
|
||||
onready var locale_manager = $LocaleManager
|
||||
onready var option_one = $Background/MarginContainer/Rows/InputArea/VBoxContainer/option1
|
||||
onready var option_two= $Background/MarginContainer/Rows/InputArea/VBoxContainer/option2
|
||||
onready var option_three = $Background/MarginContainer/Rows/InputArea/VBoxContainer/option3
|
||||
|
||||
|
||||
#Ensure that the latest added input is in focus on scroll
|
||||
func _ready() -> void:
|
||||
scrollbar.connect("changed", self, "handle_scrollbar_changed")
|
||||
max_scroll_length = scrollbar.max_value
|
||||
|
||||
history_pager.hide()
|
||||
history_rows.hide()
|
||||
current_text.show()
|
||||
option_one.show()
|
||||
option_two.show()
|
||||
option_three.show()
|
||||
|
||||
create_response("The game has begun! You can select from the available options below.")
|
||||
|
||||
var starting_locale_response = command_processor.initialize(locale_manager.get_child(0))
|
||||
create_response(starting_locale_response)
|
||||
|
||||
|
||||
func handle_scrollbar_changed():
|
||||
if max_scroll_length != scrollbar.max_value:
|
||||
max_scroll_length = scrollbar.max_value
|
||||
scroll.scroll_vertical = max_scroll_length
|
||||
create_response(starting_locale_response)
|
||||
|
||||
#Below temporarily takes user selection and appends it to responses; adding new isntances
|
||||
# of our input row with an input and response pair for each
|
||||
@ -45,7 +52,10 @@ func create_response(response_text: String):
|
||||
|
||||
|
||||
func add_response_to_game(response: Control):
|
||||
history_rows.add_child(response)
|
||||
var response_history = response.duplicate()
|
||||
history_array.append(response_history)
|
||||
current_text.remove_child(current_text.get_child(0))
|
||||
current_text.add_child(response)
|
||||
|
||||
|
||||
func _on_option1_button_down() -> void:
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=10 format=2]
|
||||
[gd_scene load_steps=12 format=2]
|
||||
|
||||
[ext_resource path="res://UserInterface/But_ChangeScene.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Game.gd" type="Script" id=2]
|
||||
@ -6,6 +6,8 @@
|
||||
[ext_resource path="res://CommandProcessor.gd" type="Script" id=4]
|
||||
[ext_resource path="res://Locale.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://LocaleManager.gd" type="Script" id=6]
|
||||
[ext_resource path="res://But_History.gd" type="Script" id=7]
|
||||
[ext_resource path="res://But_History_Page.gd" type="Script" id=8]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 0.117647, 0.117647, 0.117647, 1 )
|
||||
@ -86,27 +88,50 @@ margin_bottom = 30.0
|
||||
text = "Menu"
|
||||
next_scene_path = "res://Screens/MenuScreen.tscn"
|
||||
|
||||
[node name="But_History" type="Button" parent="Background/MarginContainer/Rows/ItemList"]
|
||||
margin_left = 96.0
|
||||
margin_right = 167.0
|
||||
margin_bottom = 33.0
|
||||
text = "Toggle History"
|
||||
script = ExtResource( 7 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="But_History_Page" type="Button" parent="Background/MarginContainer/Rows/ItemList"]
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
margin_left = -103.0
|
||||
margin_bottom = 33.0
|
||||
text = "History Page"
|
||||
script = ExtResource( 8 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="GameInfo" type="PanelContainer" parent="Background/MarginContainer/Rows"]
|
||||
margin_top = 50.0
|
||||
margin_right = 984.0
|
||||
margin_bottom = 436.0
|
||||
margin_bottom = 418.0
|
||||
size_flags_vertical = 3
|
||||
custom_styles/panel = SubResource( 2 )
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="Background/MarginContainer/Rows/GameInfo"]
|
||||
[node name="CurrentText" type="VBoxContainer" parent="Background/MarginContainer/Rows/GameInfo"]
|
||||
margin_right = 984.0
|
||||
margin_bottom = 386.0
|
||||
scroll_horizontal_enabled = false
|
||||
margin_bottom = 368.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
custom_constants/separation = 20
|
||||
|
||||
[node name="HistoryRows" type="VBoxContainer" parent="Background/MarginContainer/Rows/GameInfo/ScrollContainer"]
|
||||
[node name="HistoryRows" type="VBoxContainer" parent="Background/MarginContainer/Rows/GameInfo"]
|
||||
margin_right = 984.0
|
||||
margin_bottom = 386.0
|
||||
margin_bottom = 368.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
custom_constants/separation = 20
|
||||
|
||||
[node name="InputArea" type="PanelContainer" parent="Background/MarginContainer/Rows"]
|
||||
margin_top = 446.0
|
||||
margin_top = 428.0
|
||||
margin_right = 984.0
|
||||
margin_bottom = 570.0
|
||||
rect_min_size = Vector2( 0, 120 )
|
||||
@ -114,31 +139,34 @@ custom_styles/panel = SubResource( 3 )
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Background/MarginContainer/Rows/InputArea"]
|
||||
margin_right = 984.0
|
||||
margin_bottom = 124.0
|
||||
margin_bottom = 142.0
|
||||
custom_constants/separation = 5
|
||||
|
||||
[node name="option1" type="LinkButton" parent="Background/MarginContainer/Rows/InputArea/VBoxContainer"]
|
||||
[node name="option1" type="Button" parent="Background/MarginContainer/Rows/InputArea/VBoxContainer"]
|
||||
margin_right = 984.0
|
||||
margin_bottom = 38.0
|
||||
margin_bottom = 44.0
|
||||
custom_fonts/font = ExtResource( 3 )
|
||||
text = "Option 1"
|
||||
align = 0
|
||||
|
||||
[node name="option2" type="LinkButton" parent="Background/MarginContainer/Rows/InputArea/VBoxContainer"]
|
||||
margin_top = 43.0
|
||||
[node name="option2" type="Button" parent="Background/MarginContainer/Rows/InputArea/VBoxContainer"]
|
||||
margin_top = 49.0
|
||||
margin_right = 984.0
|
||||
margin_bottom = 81.0
|
||||
focus_mode = 2
|
||||
margin_bottom = 93.0
|
||||
custom_fonts/font = ExtResource( 3 )
|
||||
text = "Option 2"
|
||||
align = 0
|
||||
|
||||
[node name="option3" type="LinkButton" parent="Background/MarginContainer/Rows/InputArea/VBoxContainer"]
|
||||
margin_top = 86.0
|
||||
[node name="option3" type="Button" parent="Background/MarginContainer/Rows/InputArea/VBoxContainer"]
|
||||
margin_top = 98.0
|
||||
margin_right = 984.0
|
||||
margin_bottom = 124.0
|
||||
focus_mode = 2
|
||||
margin_bottom = 142.0
|
||||
custom_fonts/font = ExtResource( 3 )
|
||||
text = "Option 3"
|
||||
align = 0
|
||||
|
||||
[connection signal="button_up" from="Background/MarginContainer/Rows/ItemList/But_History" to="Background/MarginContainer/Rows/ItemList/But_History" method="_on_But_History_button_up"]
|
||||
[connection signal="button_up" from="Background/MarginContainer/Rows/ItemList/But_History_Page" to="Background/MarginContainer/Rows/ItemList/But_History_Page" method="_on_But_History_Page_button_up"]
|
||||
[connection signal="button_down" from="Background/MarginContainer/Rows/InputArea/VBoxContainer/option1" to="." method="_on_option1_button_down"]
|
||||
[connection signal="button_down" from="Background/MarginContainer/Rows/InputArea/VBoxContainer/option2" to="." method="_on_option2_button_down"]
|
||||
[connection signal="button_down" from="Background/MarginContainer/Rows/InputArea/VBoxContainer/option3" to="." method="_on_option3_button_down"]
|
||||
|
@ -0,0 +1,6 @@
|
||||
extends Control
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
$VBoxContainer/But_NewGame.grab_focus()
|
@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=7 format=2]
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://UserInterface/But_ChangeScene.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Screens/MenuScreen.gd" type="Script" id=2]
|
||||
[ext_resource path="res://UserInterface/Title.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://assets/background_demo.png" type="Texture" id=7]
|
||||
[ext_resource path="res://assets/ui_theme.tres" type="Theme" id=8]
|
||||
@ -11,6 +12,7 @@
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
theme = ExtResource( 8 )
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
@ -19,26 +19,39 @@ func _get_configuration_warning() -> String:
|
||||
return "next_scene_path must be set for this button to work" if next_scene_path == "" else ""
|
||||
|
||||
|
||||
func _saveSettings(inputSettings : String, riskFactor : String) -> void:
|
||||
#CONFIG/INI SAVE:
|
||||
func _saveSettings(inputSettings : String, riskFactor : String) -> void:
|
||||
var player_settings = get_node("/root/PlayerSettings")
|
||||
player_settings.playerSettingsSingleton.inputName = inputSettings
|
||||
player_settings.playerSettingsSingleton.riskFactor = riskFactor
|
||||
#Temp:
|
||||
var temp_manual_JSON = {
|
||||
"playerSettingsTemplate": {
|
||||
"inputName": inputSettings,
|
||||
"riskFactor": riskFactor
|
||||
}
|
||||
}
|
||||
var config = ConfigFile.new()
|
||||
|
||||
#Save to file (JSON for now)
|
||||
var settings_file = "user://testPlayerSettings.sav"
|
||||
var file = File.new()
|
||||
if file.open(settings_file, File.WRITE) != 0:
|
||||
print("Cannot write temporary file to: " + settings_file)
|
||||
else:
|
||||
file.store_line(to_json(temp_manual_JSON))
|
||||
file.close()
|
||||
config.set_value("Temp player","InputSettings", inputSettings)
|
||||
config.set_value("Temp player","RiskFactor", riskFactor)
|
||||
|
||||
config.save("user://settings.cfg")
|
||||
|
||||
#JSON SAVE:
|
||||
#func _saveSettings(inputSettings : String, riskFactor : String) -> void:
|
||||
# var player_settings = get_node("/root/PlayerSettings")
|
||||
# player_settings.playerSettingsSingleton.inputName = inputSettings
|
||||
# player_settings.playerSettingsSingleton.riskFactor = riskFactor
|
||||
# #Temp:
|
||||
# var temp_manual_JSON = {
|
||||
# "playerSettingsTemplate": {
|
||||
# "inputName": inputSettings,
|
||||
# "riskFactor": riskFactor
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# #Save to file (JSON for now)
|
||||
# var settings_file = "user://testPlayerSettings.sav"
|
||||
# var file = File.new()
|
||||
# if file.open(settings_file, File.WRITE) != 0:
|
||||
# print("Cannot write temporary file to: " + settings_file)
|
||||
# else:
|
||||
# file.store_line(to_json(temp_manual_JSON))
|
||||
# file.close()
|
||||
|
||||
|
||||
#****This save Settings functions as designed; but modified to work with alternate approach of loading
|
||||
|
@ -0,0 +1,9 @@
|
||||
tool
|
||||
extends Button
|
||||
|
||||
onready var history_rows = $Background/MarginContainer/Rows/GameInfo/ScrollContainer/HistoryRows
|
||||
onready var current_text = $Background/MarginContainer/Rows/GameInfo/CurrentText
|
||||
|
||||
func _on_But_History_button_up():
|
||||
print("History button pressed - temp")
|
||||
|
@ -0,0 +1,4 @@
|
||||
extends Node
|
||||
class_name OutputHistory
|
||||
|
||||
var output_history_array = Array()
|
@ -4,27 +4,49 @@
|
||||
|
||||
extends Node
|
||||
|
||||
var settings_file = "user://testPlayerSettings.sav"
|
||||
#DKM TEMP: JSON:
|
||||
#var settings_file = "user://testPlayerSettings.sav"
|
||||
|
||||
#DKM TEMP: TO DO: constant:
|
||||
var settings_file = "user://settings.cfg"
|
||||
var playerSettingsSingleton = PlayerSettingsTemplate.new()
|
||||
|
||||
func _ready() -> void:
|
||||
load_settings_file()
|
||||
|
||||
|
||||
#Config/ini:
|
||||
func load_settings_file():
|
||||
var config = ConfigFile.new()
|
||||
# Load data from a file.
|
||||
var err = config.load(settings_file)
|
||||
# If the file didn't load, ignore it.
|
||||
if err != OK:
|
||||
return
|
||||
for player in config.get_sections():
|
||||
var inputName = config.get_value(player, "InputSettings")
|
||||
var riskFactor = config.get_value(player, "RiskFactor")
|
||||
|
||||
print("Input name loaded as: " + inputName)
|
||||
|
||||
playerSettingsSingleton.inputName = inputName
|
||||
playerSettingsSingleton.riskFactor = riskFactor
|
||||
|
||||
#Using JSON:
|
||||
#DKM TEMP: manual JSON parsing is most certainly not the way to go -- temp testing these
|
||||
# are saved and loaded correctly.
|
||||
func load_settings_file():
|
||||
var file = File.new()
|
||||
file.open(settings_file, file.READ)
|
||||
var text = file.get_as_text()
|
||||
var parsedText = parse_json(text)
|
||||
if(parsedText != null):
|
||||
print("Input name loaded as: " + parsedText.playerSettingsTemplate.inputName)
|
||||
playerSettingsSingleton.inputName = parsedText.playerSettingsTemplate.inputName
|
||||
playerSettingsSingleton.riskFactor = parsedText.playerSettingsTemplate.riskFactor
|
||||
else:
|
||||
print("No previously existing player settings file found")
|
||||
|
||||
#func load_settings_file():
|
||||
# var file = File.new()
|
||||
# file.open(settings_file, file.READ)
|
||||
# var text = file.get_as_text()
|
||||
# var parsedText = parse_json(text)
|
||||
# if(parsedText != null):
|
||||
# print("Input name loaded as: " + parsedText.playerSettingsTemplate.inputName)
|
||||
# playerSettingsSingleton.inputName = parsedText.playerSettingsTemplate.inputName
|
||||
# playerSettingsSingleton.riskFactor = parsedText.playerSettingsTemplate.riskFactor
|
||||
# else:
|
||||
# print("No previously existing player settings file found")
|
||||
#
|
||||
#DKM TEMP:
|
||||
#****THIS LOADS a string successfully, but not objects
|
||||
#func _loadSettings() -> void:
|
||||
|
@ -15,12 +15,18 @@ _global_script_classes=[ {
|
||||
"path": "res://Locale.gd"
|
||||
}, {
|
||||
"base": "Node",
|
||||
"class": "OutputHistory",
|
||||
"language": "GDScript",
|
||||
"path": "res://globalScripts/outputHistory.gd"
|
||||
}, {
|
||||
"base": "Node",
|
||||
"class": "PlayerSettingsTemplate",
|
||||
"language": "GDScript",
|
||||
"path": "res://globalScripts/playerSettingsTemplate.gd"
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
"Locale": "",
|
||||
"OutputHistory": "",
|
||||
"PlayerSettingsTemplate": ""
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user