2022-01-30 20:43:22 +00:00
|
|
|
#GAME:
|
|
|
|
# Controls output space, loading descriptions and options for each locale and
|
|
|
|
# appending to the history array.
|
|
|
|
|
2022-01-02 20:52:54 +00:00
|
|
|
extends Control
|
|
|
|
|
2022-02-06 21:27:54 +00:00
|
|
|
onready var history_source = get_node("/root/History").historyScreensSingleton
|
2022-01-30 20:43:22 +00:00
|
|
|
|
2022-01-02 20:52:54 +00:00
|
|
|
#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")
|
2022-01-23 20:18:08 +00:00
|
|
|
|
2022-01-02 20:52:54 +00:00
|
|
|
|
|
|
|
onready var command_processor = $CommandProcessor
|
2022-01-23 20:18:08 +00:00
|
|
|
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
|
2022-01-02 20:52:54 +00:00
|
|
|
onready var locale_manager = $LocaleManager
|
2022-01-23 20:18:08 +00:00
|
|
|
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
|
|
|
|
|
2022-01-02 20:52:54 +00:00
|
|
|
|
|
|
|
func _ready() -> void:
|
2022-01-23 20:18:08 +00:00
|
|
|
history_pager.hide()
|
|
|
|
history_rows.hide()
|
|
|
|
current_text.show()
|
|
|
|
option_one.show()
|
|
|
|
option_two.show()
|
|
|
|
option_three.show()
|
|
|
|
|
2022-02-06 21:27:54 +00:00
|
|
|
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.")
|
2022-01-02 20:52:54 +00:00
|
|
|
|
|
|
|
var starting_locale_response = command_processor.initialize(locale_manager.get_child(0))
|
2022-02-06 21:27:54 +00:00
|
|
|
create_response(opening_text + " " + starting_locale_response)
|
2022-01-02 20:52:54 +00:00
|
|
|
|
2022-01-30 20:43:22 +00:00
|
|
|
#Below temporarily takes user selection and appends it to responses; adding new instances
|
2022-01-02 20:52:54 +00:00
|
|
|
# of our input row with an input and response pair for each
|
|
|
|
func handleUserInput(user_choice: String) -> void:
|
|
|
|
var input_response = InputResponse.instance()
|
|
|
|
var inputText = "User selected: " + user_choice
|
|
|
|
var response = command_processor.process_command(user_choice)
|
|
|
|
input_response.set_text(inputText, response)
|
|
|
|
add_response_to_game(input_response)
|
|
|
|
|
2022-01-30 20:43:22 +00:00
|
|
|
#Handles input text
|
2022-01-02 20:52:54 +00:00
|
|
|
func create_response(response_text: String):
|
|
|
|
var response = TextOutput.instance()
|
|
|
|
response.text = response_text
|
|
|
|
add_response_to_game(response)
|
|
|
|
|
2022-01-30 20:43:22 +00:00
|
|
|
#Copies the response output to add to both current game output, and the
|
|
|
|
# history array.
|
2022-01-02 20:52:54 +00:00
|
|
|
func add_response_to_game(response: Control):
|
2022-01-23 20:18:08 +00:00
|
|
|
var response_history = response.duplicate()
|
2022-02-06 21:27:54 +00:00
|
|
|
|
2022-01-30 20:43:22 +00:00
|
|
|
#DKM TEMP: stopped here, trying to add page number to history text
|
2022-02-06 21:27:54 +00:00
|
|
|
#var history_page_number = HISTORY_SOURCE.output_history_array.size() + 1
|
2022-01-30 20:43:22 +00:00
|
|
|
#var history_string = "Page " + str(history_page_number) + "; "
|
2022-02-06 21:27:54 +00:00
|
|
|
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))
|
2022-01-23 20:18:08 +00:00
|
|
|
current_text.add_child(response)
|
2022-01-02 20:52:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_option1_button_down() -> void:
|
|
|
|
var option1 = get_node("Background/MarginContainer/Rows/InputArea/VBoxContainer/option1")
|
|
|
|
handleUserInput(option1.get_text())
|
|
|
|
|
|
|
|
|
|
|
|
func _on_option2_button_down() -> void:
|
|
|
|
var option2 = get_node("Background/MarginContainer/Rows/InputArea/VBoxContainer/option2")
|
|
|
|
handleUserInput(option2.get_text())
|
|
|
|
|
|
|
|
|
|
|
|
func _on_option3_button_down() -> void:
|
|
|
|
var option3 = get_node("Background/MarginContainer/Rows/InputArea/VBoxContainer/option3")
|
|
|
|
handleUserInput(option3.get_text())
|