History Display and Pager from More Options

Adds back saving to the history array, and the history page accessible from Game-->More Options. Includes history paging, which iterates through history.

Does not yet display the current history page.
This commit is contained in:
MacDugRPG 2022-05-15 15:11:27 -04:00
parent 7464b851e0
commit 8836f4686e
8 changed files with 146 additions and 5 deletions

View File

@ -3,3 +3,6 @@
[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}

View File

@ -69,10 +69,10 @@ func add_response_to_game(response: Control):
func add_response_to_history(response: Control) -> void:
#DKM TEMP: so here we
#1. var response_history = response.duplicate()
#2. get the history array from the singleton,
var response_for_history = response.duplicate()
#2. get the history array from the singleton,
#3. Add this to the history array
#
pass
history_source.output_history_array.append(response_for_history)
func _on_option1_button_down() -> void:

View File

@ -19,7 +19,7 @@ func _ready() -> void:
#DKM temp:
print("Loaded history array size is: " + str(historyScreensSingleton.output_history_array.size()))
#DKM TEMP: tres format:
#DKM TEMP: load using tres format:
func load_history_file() -> HistoryScreensTemplateSingleton:
if ResourceLoader.exists(history_file):
var history = ResourceLoader.load(history_file)

View File

@ -0,0 +1,17 @@
#BUT_HISTORYPAGER:
# Simply moves through array page -- should call the HistoryViewer script to display
# stored page and response fro the history array
#
extends Button
onready var historyViewerScript = get_node("/root/HistoryViewer")
func _on_But_HistoryPager_button_up() -> void:
if(historyViewerScript.current_history_page_no < historyViewerScript.history_source.output_history_array.size()):
historyViewerScript.current_history_page_no = historyViewerScript.current_history_page_no +1
else:
historyViewerScript.current_history_page_no = 0
print("Current page: " + str(historyViewerScript.current_history_page_no))

View File

@ -0,0 +1,40 @@
#HISTORY_VIEWER:
# Controls output space -- will display the appropriate history array page.
# DKM TEMP: 5/15/22: what's here is replicated from the Game script for starting
# purposes. I have this working in experimental version -- will add this back
# next.
extends Control
onready var history_source = get_node("/root/History").historyScreensSingleton
onready var current_history = $Background/MarginContainer/Rows/GameInfo/CurrentHistory
onready var current_history_page_no = 0
#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")
func _ready() -> void:
#DKM TEMP: for testing only -- this will be set in settings
theme=load("res://assets/ui_controlNode_dark_theme.tres")
#DKM_TEMP: display size of current history:
print("Loaded history array size is: " + str(history_source.output_history_array.size()))
#Handles input text
func create_response(response_text: String):
var response = TextOutput.instance()
response.text = response_text
add_response_to_game(response)
#Copies the response output to add to both current game output, and the
# history array.
func add_response_to_game(response: Control):
if(current_history.get_child_count() > 0):
current_history.remove_child(current_history.get_child(0))
current_history.add_child(response)

View File

@ -0,0 +1,80 @@
[gd_scene load_steps=5 format=2]
[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/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
theme = ExtResource( 3 )
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Background" type="PanelContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_right = -274.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="Background"]
margin_left = 1.0
margin_top = 1.0
margin_right = 749.0
margin_bottom = 599.0
custom_constants/margin_right = 20
custom_constants/margin_top = 10
custom_constants/margin_left = 20
custom_constants/margin_bottom = 20
[node name="Rows" type="VBoxContainer" parent="Background/MarginContainer"]
margin_left = 20.0
margin_top = 10.0
margin_right = 728.0
margin_bottom = 578.0
custom_constants/separation = 10
[node name="ItemList" type="ItemList" parent="Background/MarginContainer/Rows"]
margin_right = 708.0
margin_bottom = 40.0
rect_min_size = Vector2( 0, 40 )
[node name="But_ChangeScene" parent="Background/MarginContainer/Rows/ItemList" instance=ExtResource( 2 )]
text = "More Options"
next_scene_path = "res://screens/MoreOptions.tscn"
[node name="But_HistoryPager" type="Button" parent="Background/MarginContainer/Rows/ItemList"]
anchor_left = 1.0
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
margin_left = -168.0
margin_top = -18.0
margin_bottom = 18.0
text = "History Pager"
script = ExtResource( 4 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="GameInfo" type="PanelContainer" parent="Background/MarginContainer/Rows"]
margin_top = 50.0
margin_right = 708.0
margin_bottom = 568.0
size_flags_vertical = 3
[node name="CurrentText" type="VBoxContainer" parent="Background/MarginContainer/Rows/GameInfo"]
margin_left = 1.0
margin_top = 1.0
margin_right = 707.0
margin_bottom = 517.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/separation = 20
[connection signal="button_up" from="Background/MarginContainer/Rows/ItemList/But_HistoryPager" to="Background/MarginContainer/Rows/ItemList/But_HistoryPager" method="_on_But_HistoryPager_button_up"]

View File

@ -49,7 +49,7 @@ margin_top = 40.0
margin_right = 238.0
margin_bottom = 125.0
text = "Show History"
next_scene_path = "res://screens/MenuScreen.tscn"
next_scene_path = "res://screens/HistoryViewer.tscn"
[node name="But_Chat" parent="VBoxContainer" instance=ExtResource( 1 )]
margin_top = 129.0

View File

@ -8,6 +8,7 @@ func _on_But_ResumeGame_button_up():
var gameSingleton = get_node("/root/GameCurrent")
var gameScene = gameSingleton.gameCurrent_scene
root.remove_child(thisScene)
#DKM TEMP: cleanup this scene!
thisScene.queue_free()
root.add_child(gameScene)