From 8836f4686e7596cb833d96160539839750678dc0 Mon Sep 17 00:00:00 2001 From: MacDugRPG <57243055+MacDugRPG@users.noreply.github.com> Date: Sun, 15 May 2022 15:11:27 -0400 Subject: [PATCH] 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. --- .../bcirpg_newGame_20220227A/Control.tscn | 3 + .../bcirpg_newGame_20220227A/gamePlay/Game.gd | 6 +- .../globalScripts/history.gd | 2 +- .../screens/But_HistoryPager.gd | 17 ++++ .../screens/HistoryViewer.gd | 40 ++++++++++ .../screens/HistoryViewer.tscn | 80 +++++++++++++++++++ .../screens/MoreOptions.tscn | 2 +- .../userInterface/But_ResumeGame.gd | 1 + 8 files changed, 146 insertions(+), 5 deletions(-) create mode 100644 Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/But_HistoryPager.gd create mode 100644 Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/HistoryViewer.gd create mode 100644 Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/HistoryViewer.tscn diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/Control.tscn b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/Control.tscn index 00a6290..bd41ee5 100644 --- a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/Control.tscn +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/Control.tscn @@ -3,3 +3,6 @@ [node name="Control" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/gamePlay/Game.gd b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/gamePlay/Game.gd index 46f0037..1743714 100644 --- a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/gamePlay/Game.gd +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/gamePlay/Game.gd @@ -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: diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/globalScripts/history.gd b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/globalScripts/history.gd index 0fe7e5a..e36f485 100644 --- a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/globalScripts/history.gd +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/globalScripts/history.gd @@ -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) diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/But_HistoryPager.gd b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/But_HistoryPager.gd new file mode 100644 index 0000000..6c5cdb6 --- /dev/null +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/But_HistoryPager.gd @@ -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)) diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/HistoryViewer.gd b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/HistoryViewer.gd new file mode 100644 index 0000000..f1da0ce --- /dev/null +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/HistoryViewer.gd @@ -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) + + + + diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/HistoryViewer.tscn b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/HistoryViewer.tscn new file mode 100644 index 0000000..805ed5f --- /dev/null +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/HistoryViewer.tscn @@ -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"] diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/MoreOptions.tscn b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/MoreOptions.tscn index 5d8d51b..27b7471 100644 --- a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/MoreOptions.tscn +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/screens/MoreOptions.tscn @@ -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 diff --git a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/userInterface/But_ResumeGame.gd b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/userInterface/But_ResumeGame.gd index 9d21fcd..ee37c4f 100644 --- a/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/userInterface/But_ResumeGame.gd +++ b/Phase2/Godot ===(Game Code)===/NewGame/Doug/bcirpg_newGame_20220227A/userInterface/But_ResumeGame.gd @@ -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)