mirror of
https://github.com/RPG-Research/bcirpg.git
synced 2024-04-16 14:23:01 +00:00
History improvements; added map points
History improvement for use singleton, with various loading and saving efforts for the history. Added locations and command processing upgrade for some map exploration.
This commit is contained in:
parent
6efdac1d4c
commit
931820e328
@ -7,8 +7,6 @@ tool
|
|||||||
extends Button
|
extends Button
|
||||||
|
|
||||||
onready var game_history_array = get_node("/root/History").historyScreensSingleton.output_history_array
|
onready var game_history_array = get_node("/root/History").historyScreensSingleton.output_history_array
|
||||||
#DKM TEMP: conversion to global -- prior method
|
|
||||||
#onready var game_history_array = get_node("../../../../../").history_array
|
|
||||||
|
|
||||||
var current_page = 0
|
var current_page = 0
|
||||||
|
|
||||||
@ -21,3 +19,4 @@ func _on_But_History_Page_button_up():
|
|||||||
history_rows_node.remove_child(history_rows_node.get_child(0))
|
history_rows_node.remove_child(history_rows_node.get_child(0))
|
||||||
history_rows_node.add_child(game_history_array[current_page])
|
history_rows_node.add_child(game_history_array[current_page])
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,23 +18,44 @@ func initialize(starting_locale) -> String:
|
|||||||
current_opt1.grab_focus()
|
current_opt1.grab_focus()
|
||||||
return change_room(starting_locale)
|
return change_room(starting_locale)
|
||||||
|
|
||||||
|
#DKM TEMP: this must load from files written by toolset
|
||||||
#Function that loads response from the option string chosen
|
#Function that loads response from the option string chosen
|
||||||
func process_command(option: String) -> String:
|
func process_command(option: String) -> String:
|
||||||
var optionArr = option.split(" ", false)
|
var optCmd_Action = option.split(": ", false)
|
||||||
if optionArr.size() < 2:
|
if (optCmd_Action.size() < 2):
|
||||||
return "Error: no valid command in option!"
|
return "Error: no valid command and action in option!"
|
||||||
if(optionArr[0] == "Go"):
|
match optCmd_Action[0]:
|
||||||
return go(optionArr[1])
|
"Go":
|
||||||
else:
|
return go(optCmd_Action[1])
|
||||||
return "Nothing happens! Command word was: " + optionArr[0]
|
"Wait":
|
||||||
|
return "You rest a bit. Now what?"
|
||||||
|
"Talk":
|
||||||
|
return talk(optCmd_Action[1])
|
||||||
|
"Examine":
|
||||||
|
return examine(optCmd_Action[1])
|
||||||
|
"Scream":
|
||||||
|
return "You yell :'" + optCmd_Action[1].to_upper() +"'!!"
|
||||||
|
_:
|
||||||
|
return "Nothing happens! Command word was: " + optCmd_Action[0]
|
||||||
|
|
||||||
func go(destination: String) -> String:
|
|
||||||
|
|
||||||
|
func go(action: String) -> String:
|
||||||
|
var destination = action.split(" ", false)[0]
|
||||||
if current_locale.exits.keys().has(destination):
|
if current_locale.exits.keys().has(destination):
|
||||||
var change_response = change_room(current_locale.exits[destination])
|
var change_response = change_room(current_locale.exits[destination])
|
||||||
return PoolStringArray(["You go %s." % destination, change_response]).join("\n")
|
return PoolStringArray(["You go %s." % destination, change_response]).join("\n")
|
||||||
else:
|
else:
|
||||||
return "That is not a valid place to go!"
|
return "That is not a valid place to go!"
|
||||||
|
|
||||||
|
#DKM TEMP: do an examination dictionary lookup here?
|
||||||
|
func examine(action: String) -> String:
|
||||||
|
return action.to_upper() + " looks about how you'd expect. [Dictionary lookup forthcoming]"
|
||||||
|
|
||||||
|
#DKM TEMP: dialog entry needed -- temp
|
||||||
|
func talk(action: String) -> String:
|
||||||
|
var target = action.split("to ", false)[0].to_upper()
|
||||||
|
return target + " has little to say! [Dialog forthcoming]"
|
||||||
|
|
||||||
#Helper:
|
#Helper:
|
||||||
func change_room(new_room: Locale) -> String:
|
func change_room(new_room: Locale) -> String:
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
onready var HISTORY_SOURCE = get_node("/root/History").historyScreensSingleton
|
onready var history_source = get_node("/root/History").historyScreensSingleton
|
||||||
|
|
||||||
#Abstract class we instance when wanted in game as child of HistoryReference
|
#Abstract class we instance when wanted in game as child of HistoryReference
|
||||||
const TextOutput = preload("res://UserInterface/Response.tscn")
|
const TextOutput = preload("res://UserInterface/Response.tscn")
|
||||||
@ -29,10 +29,11 @@ func _ready() -> void:
|
|||||||
option_two.show()
|
option_two.show()
|
||||||
option_three.show()
|
option_three.show()
|
||||||
|
|
||||||
create_response("The game has begun! You can select from the available options below.")
|
var opening_text = "The game has begun! You can select from the available options below. "
|
||||||
|
#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))
|
var starting_locale_response = command_processor.initialize(locale_manager.get_child(0))
|
||||||
create_response(starting_locale_response)
|
create_response(opening_text + " " + starting_locale_response)
|
||||||
|
|
||||||
#Below temporarily takes user selection and appends it to responses; adding new instances
|
#Below temporarily takes user selection and appends it to responses; adding new instances
|
||||||
# of our input row with an input and response pair for each
|
# of our input row with an input and response pair for each
|
||||||
@ -53,10 +54,13 @@ func create_response(response_text: String):
|
|||||||
# history array.
|
# history array.
|
||||||
func add_response_to_game(response: Control):
|
func add_response_to_game(response: Control):
|
||||||
var response_history = response.duplicate()
|
var response_history = response.duplicate()
|
||||||
var history_page_number = HISTORY_SOURCE.output_history_array.size() + 1
|
|
||||||
#DKM TEMP: stopped here, trying to add page number to history text
|
#DKM TEMP: stopped here, trying to add page number to history text
|
||||||
|
#var history_page_number = HISTORY_SOURCE.output_history_array.size() + 1
|
||||||
#var history_string = "Page " + str(history_page_number) + "; "
|
#var history_string = "Page " + str(history_page_number) + "; "
|
||||||
HISTORY_SOURCE.output_history_array.append(response_history)
|
if(history_source.output_history_array != null):
|
||||||
|
history_source.output_history_array.append(response_history)
|
||||||
|
if(current_text.get_child_count() > 0):
|
||||||
current_text.remove_child(current_text.get_child(0))
|
current_text.remove_child(current_text.get_child(0))
|
||||||
current_text.add_child(response)
|
current_text.add_child(response)
|
||||||
|
|
||||||
|
@ -32,27 +32,71 @@ script = ExtResource( 4 )
|
|||||||
[node name="LocaleManager" type="Node" parent="."]
|
[node name="LocaleManager" type="Node" parent="."]
|
||||||
script = ExtResource( 6 )
|
script = ExtResource( 6 )
|
||||||
|
|
||||||
[node name="HouseLocale" parent="LocaleManager" instance=ExtResource( 5 )]
|
[node name="Loc_Boat" parent="LocaleManager" instance=ExtResource( 5 )]
|
||||||
margin_left = 41.38
|
margin_left = 41.38
|
||||||
margin_top = -513.913
|
margin_top = -513.913
|
||||||
margin_right = 291.381
|
margin_right = 291.381
|
||||||
margin_bottom = -313.913
|
margin_bottom = -313.913
|
||||||
locale_name = "a house."
|
locale_name = "a boat"
|
||||||
locale_description = "The house has no windows, but is illuminated by an odd-looking lamp. There is a staircase descending, and a door made of stone. "
|
locale_description = "You have been shipwrecked."
|
||||||
option1 = "Go east"
|
option1 = "Go: east off the boat"
|
||||||
option2 = "Try to open stone door?"
|
option2 = "Examine: this boat"
|
||||||
option3 = "Descend the stair in the floor?"
|
option3 = "Wait: a while"
|
||||||
|
|
||||||
[node name="HouseOutside" parent="LocaleManager" instance=ExtResource( 5 )]
|
[node name="Loc_Shore" parent="LocaleManager" instance=ExtResource( 5 )]
|
||||||
margin_left = 509.38
|
margin_left = 509.38
|
||||||
margin_top = -512.913
|
margin_top = -512.913
|
||||||
margin_right = 759.381
|
margin_right = 759.381
|
||||||
margin_bottom = -312.913
|
margin_bottom = -312.913
|
||||||
locale_name = "outside a house"
|
locale_name = "the beach outside the wrecked ship"
|
||||||
locale_description = "You are standing outside a house."
|
locale_description = "You are standing on a white sand beach beside the crashing waves. You can go west, back onto the boat, or go north into the woods."
|
||||||
option1 = "Go west"
|
option1 = "Go: west to boat"
|
||||||
option2 = "Try to open stone door?"
|
option2 = "Go: north to woods"
|
||||||
option3 = "Descend the stair in the floor?"
|
option3 = "Talk: to yourself"
|
||||||
|
|
||||||
|
[node name="Loc_WoodsA1" parent="LocaleManager" instance=ExtResource( 5 )]
|
||||||
|
margin_left = 510.439
|
||||||
|
margin_top = -806.384
|
||||||
|
margin_right = 760.44
|
||||||
|
margin_bottom = -606.384
|
||||||
|
locale_name = "the island woods"
|
||||||
|
locale_description = "These woods get thick!"
|
||||||
|
option1 = "Go: south back to the beach"
|
||||||
|
option2 = "Go: north deeper in"
|
||||||
|
option3 = "Scream: for help"
|
||||||
|
|
||||||
|
[node name="Loc_WoodsA2" parent="LocaleManager" instance=ExtResource( 5 )]
|
||||||
|
margin_left = 509.439
|
||||||
|
margin_top = -1083.38
|
||||||
|
margin_right = 759.44
|
||||||
|
margin_bottom = -883.384
|
||||||
|
locale_name = "deeper into the woods"
|
||||||
|
locale_description = "The woods are very thick. You feel like someone -- or something, may be watching you."
|
||||||
|
option1 = "Go: south back in the direction of the beach"
|
||||||
|
option2 = "Go: east into the thicket"
|
||||||
|
option3 = "Examine: the woods"
|
||||||
|
|
||||||
|
[node name="Loc_WoodsA3" parent="LocaleManager" instance=ExtResource( 5 )]
|
||||||
|
margin_left = 882.439
|
||||||
|
margin_top = -1084.38
|
||||||
|
margin_right = 1132.44
|
||||||
|
margin_bottom = -884.38
|
||||||
|
locale_name = "a clearing"
|
||||||
|
locale_description = "There is a clearing here in the woods. You hear strange sounds, and musics. Something skitters north into the woods"
|
||||||
|
option1 = "Go: north after the creature"
|
||||||
|
option2 = "Go: west back into the thicket"
|
||||||
|
option3 = "Listen: to the sounds"
|
||||||
|
|
||||||
|
[node name="Loc_WoodsA4" parent="LocaleManager" instance=ExtResource( 5 )]
|
||||||
|
margin_left = 878.439
|
||||||
|
margin_top = -1361.38
|
||||||
|
margin_right = 1128.44
|
||||||
|
margin_bottom = -1161.38
|
||||||
|
locale_name = "a cliff top"
|
||||||
|
locale_description = "The strange animal darts through and vanishes in front of you. There is a serious drop off here, plunging a long ways to rocks below. A figure moves along the rocks, moaning and cursing, grumpily."
|
||||||
|
option1 = "Go: south back to the clearing "
|
||||||
|
option2 = "Talk: to the grumpy figure"
|
||||||
|
option3 = "Examine: the grumpy figure"
|
||||||
|
|
||||||
[node name="Background" type="PanelContainer" parent="."]
|
[node name="Background" type="PanelContainer" parent="."]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
@ -5,8 +5,13 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
|
#DKM TEMP: must load from toolset
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
$HouseLocale.connect_exit("east", $HouseOutside)
|
$Loc_Boat.connect_exit("east", $Loc_Shore)
|
||||||
|
$Loc_Shore.connect_exit("north", $Loc_WoodsA1)
|
||||||
|
$Loc_WoodsA1.connect_exit("north", $Loc_WoodsA2)
|
||||||
|
$Loc_WoodsA2.connect_exit("east", $Loc_WoodsA3)
|
||||||
|
$Loc_WoodsA3.connect_exit("north", $Loc_WoodsA4)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,20 +4,31 @@
|
|||||||
|
|
||||||
extends Button
|
extends Button
|
||||||
|
|
||||||
|
var history_JSON = "user://history.json"
|
||||||
|
|
||||||
|
|
||||||
#DKM TEMP: save history is only here temporarily -- needs to move upstream.
|
#DKM TEMP: save history is only here temporarily -- needs to move upstream.
|
||||||
func _on_But_Quit_button_up():
|
func _on_But_Quit_button_up():
|
||||||
_saveHistory()
|
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
|
||||||
func _saveHistory() -> void:
|
|
||||||
var history = get_node("/root/History")
|
|
||||||
var config = ConfigFile.new()
|
|
||||||
|
|
||||||
#DKM TEMP: yet to parse out useful values
|
#JSON: requires dictionaries:
|
||||||
var i = 0
|
#func _saveHistory_JSON() -> void:
|
||||||
for page in history.historyScreensSingleton.output_history_array:
|
# var history_screens_arr = get_node("/root/History").historyScreensSingleton.output_history_array
|
||||||
config.set_value("Temp player history",str(i), page)
|
# var file = File.new()
|
||||||
i = i+1
|
# file.open(history_JSON, File.WRITE)
|
||||||
|
# file.store_string(to_json(history_screens_arr))
|
||||||
|
#
|
||||||
|
# file.close()
|
||||||
|
# # #DKM TEMP:
|
||||||
|
# print("Saved history array size should be: " + str(history_screens_arr.size()))
|
||||||
|
|
||||||
|
|
||||||
|
#DKM TEMP:
|
||||||
|
#tres file:
|
||||||
|
#func _saveHistory() -> void:
|
||||||
|
# var history_screens = get_node("/root/History").historyScreensSingleton
|
||||||
|
# assert(ResourceSaver.save("user://history.tres", history_screens)==OK)
|
||||||
|
# #DKM TEMP:
|
||||||
|
# print("Saved history array size: " + str(history_screens.output_history_array.size()))
|
||||||
|
|
||||||
config.save("user://history.cfg")
|
|
||||||
|
@ -6,25 +6,26 @@ extends Node
|
|||||||
|
|
||||||
|
|
||||||
#DKM TEMP: not a cfg?
|
#DKM TEMP: not a cfg?
|
||||||
var history_file = "user://history.cfg"
|
var history_file = "user://history.tres"
|
||||||
var historyScreensSingleton = HistoryScreensTemplateSingleton.new()
|
var historyScreensSingleton
|
||||||
|
var testing = false
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
pass
|
if(testing):
|
||||||
#load_history_file()
|
historyScreensSingleton = load_history_file()
|
||||||
|
if (historyScreensSingleton == null):
|
||||||
|
historyScreensSingleton = HistoryScreensTemplateSingleton.new()
|
||||||
|
|
||||||
#Config/ini:
|
#DKM temp:
|
||||||
func load_history_file():
|
print("Loaded history array size is: " + str(historyScreensSingleton.output_history_array.size()))
|
||||||
var config = ConfigFile.new()
|
|
||||||
# Load data from a file.
|
|
||||||
var err = config.load(history_file)
|
|
||||||
# If the file didn't load, ignore it.
|
|
||||||
if err != OK:
|
|
||||||
return
|
|
||||||
for player in config.get_sections():
|
|
||||||
var history_zero = config.get_value(player, "HistoryArray[0]")
|
|
||||||
|
|
||||||
print("HistoryArray[0] loaded as: " + history_zero)
|
#DKM TEMP: tres format:
|
||||||
|
func load_history_file() -> HistoryScreensTemplateSingleton:
|
||||||
|
if ResourceLoader.exists(history_file):
|
||||||
|
var history = ResourceLoader.load(history_file)
|
||||||
|
if history is HistoryScreensTemplateSingleton:
|
||||||
|
return history
|
||||||
|
else: return null
|
||||||
|
else:
|
||||||
|
return null
|
||||||
|
|
||||||
historyScreensSingleton.output_history_array[0] = history_zero
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#PLAYERSETTINGSTEMPLATE:
|
#PLAYERSETTINGSTEMPLATE:
|
||||||
# Class for holding history screens
|
# Class for holding history screens
|
||||||
|
extends Resource
|
||||||
|
|
||||||
extends Node
|
|
||||||
class_name HistoryScreensTemplateSingleton
|
class_name HistoryScreensTemplateSingleton
|
||||||
|
|
||||||
var output_history_array = Array()
|
var output_history_array = Array()
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
config_version=4
|
config_version=4
|
||||||
|
|
||||||
_global_script_classes=[ {
|
_global_script_classes=[ {
|
||||||
"base": "Node",
|
"base": "Resource",
|
||||||
"class": "HistoryScreensTemplateSingleton",
|
"class": "HistoryScreensTemplateSingleton",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://globalScripts/historyScreensTemplate.gd"
|
"path": "res://globalScripts/historyScreensTemplate.gd"
|
||||||
|
Loading…
Reference in New Issue
Block a user