Cleaned and improved some event stuff

This commit is contained in:
2025-05-26 13:11:27 -05:00
parent c1d8dd46d8
commit d6a2f4b567
27 changed files with 296 additions and 108 deletions

View File

@@ -62,13 +62,13 @@ msgstr[1] "Received {quantity} {item.title}."
# QUESTS
#
msgid "quest.test_quest.title"
msgstr "Test Quest"
msgstr "Learn to cook!"
msgid "quest.test_quest.onion.title"
msgstr "Scavenge Onions"
msgid "quest.test_quest.sweet_potato.title"
msgstr "Scavenge Sweet Potatoes"
msgid "quest.test_quest.onion.description"
msgstr "Find and collect {quantity} {item.title} and bring them back to {npc}."
msgid "quest.test_quest.sweet_potato.description"
msgstr "Find and collect {quantity} {item.title} so you can learn to cook!"
#
# ITEMS
@@ -120,7 +120,24 @@ msgstr ""
"\n"
"Press [input action=debug][/input] to open the debug menu"
# ==============================================================================
#
# MAPS
#
# ==============================================================================
# TEST
msgid "test"
msgstr "Test {item.title} String"
#
# Test Map
#
msgid "map.test_map.title"
msgstr "Test Map"
# Events
msgid "map.test_map.event.gather_onion.text0"
msgstr "I am giving you a quest to gather some ingredients."
msgid "map.test_map.event.gather_onion.text1"
msgstr "Take this to help you on your way."
msgid "map.test_map.event.gather_onion.text2"
msgstr "How goes the quest? Have you gathered the ingredients?"

View File

@@ -27,10 +27,15 @@ SCENE_MANAGER="*res://scripts/Singleton/SceneSystem.gd"
UI="*res://scenes/Singletons/UI.tscn"
VN="*res://scripts/Singleton/VNSystem.gd"
LOAD="*res://scenes/Singletons/Load.tscn"
EVENT="*res://scripts/Singleton/EventSystem.gd"
RECIPE="*res://scenes/Singletons/Recipe.tscn"
LOCALE="*res://scripts/Singleton/LocaleSystem.gd"
ControllerIcons="*res://addons/controller_icons/ControllerIcons.gd"
EVENT="*res://scenes/Singletons/Event.tscn"
[debug]
gdscript/warnings/unused_variable=0
gdscript/warnings/shadowed_variable=0
[display]

View File

@@ -29,7 +29,7 @@ ambient_light_source = 1
[node name="TestMap" type="Node3D"]
script = ExtResource("1_ru75d")
mapName = "My cool map"
title = "map.test_map.title"
[node name="Entities" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.19857, 0.684572, 0.968477)
@@ -44,11 +44,33 @@ interactEvent = NodePath("../../Events/TestConversation")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.56382, -0.547748, 1.61289)
interactEvent = NodePath("../../Events/TestConversation")
[node name="ItemOnGround" parent="Entities" instance=ExtResource("4_ejcqv")]
[node name="Onion0" parent="Entities" instance=ExtResource("4_ejcqv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.546944, -0.547748, -3.46628)
itemType = 2
quantity = 2
[node name="Onion1" parent="Entities" instance=ExtResource("4_ejcqv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.25922, -0.547748, -4.61426)
itemType = 2
quantity = 2
[node name="Onion2" parent="Entities" instance=ExtResource("4_ejcqv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.83853, -0.547748, -3.29584)
itemType = 2
quantity = 2
[node name="SweetPotato0" parent="Entities" instance=ExtResource("4_ejcqv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.31019, -0.547748, 3.74619)
itemType = 3
[node name="SweetPotato1" parent="Entities" instance=ExtResource("4_ejcqv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0143311, -0.547748, 4.4158)
itemType = 3
[node name="SweetPotato2" parent="Entities" instance=ExtResource("4_ejcqv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.05915, -0.547748, 5.04958)
itemType = 3
[node name="Map" type="Node3D" parent="."]
metadata/_edit_lock_ = true
@@ -85,39 +107,35 @@ event = 1
eventFlag = 1
metadata/_custom_type_script = "uid://ccujhcc446mvh"
[node name="Text 0" type="Node" parent="Events/TestConversation/After Quest Started"]
[node name="Text 2" type="Node" parent="Events/TestConversation/After Quest Started"]
script = ExtResource("6_gxq5o")
text = "Go find those ingredients!"
text = "map.test_map.event.gather_onion.text2"
[node name="Before Quest STarted" type="Node" parent="Events/TestConversation"]
[node name="Before Quest Started" type="Node" parent="Events/TestConversation"]
script = ExtResource("13_60ixl")
event = 1
type = 2
eventFlag = 1
metadata/_custom_type_script = "uid://ccujhcc446mvh"
[node name="Text 0" type="Node" parent="Events/TestConversation/Before Quest STarted"]
[node name="Text 0" type="Node" parent="Events/TestConversation/Before Quest Started"]
script = ExtResource("6_gxq5o")
text = "I am giving you a quest to gather some ingredients."
text = "map.test_map.event.gather_onion.text0"
[node name="Quest" type="Node" parent="Events/TestConversation/Before Quest STarted"]
[node name="Quest" type="Node" parent="Events/TestConversation/Before Quest Started"]
script = ExtResource("7_brp0k")
metadata/_custom_type_script = "uid://c4d7nithqnx5y"
[node name="Text 1" type="Node" parent="Events/TestConversation/Before Quest STarted"]
[node name="Text 1" type="Node" parent="Events/TestConversation/Before Quest Started"]
script = ExtResource("6_gxq5o")
text = "Take this potion to help you on your way."
text = "map.test_map.event.gather_onion.text1"
[node name="Get Item" type="Node" parent="Events/TestConversation/Before Quest STarted"]
[node name="Get Item" type="Node" parent="Events/TestConversation/Before Quest Started"]
script = ExtResource("10_avybc")
getType = 1
metadata/_custom_type_script = "uid://b41umpbgqfuc2"
[node name="Text 2" type="Node" parent="Events/TestConversation/Before Quest STarted"]
script = ExtResource("6_gxq5o")
text = "Thanks for taking that potion."
[node name="EventFlagModify" type="Node" parent="Events/TestConversation/Before Quest STarted"]
[node name="EventFlagModify" type="Node" parent="Events/TestConversation/Before Quest Started"]
script = ExtResource("12_ncdgy")
event = 1
eventFlag = 1

View File

@@ -0,0 +1,9 @@
[gd_scene load_steps=2 format=3 uid="uid://dqde5pj14u71"]
[ext_resource type="Script" uid="uid://dy8gbmwddma3b" path="res://scripts/Singleton/EventSystem.gd" id="1_pu13l"]
[node name="EventSystem" type="Node"]
script = ExtResource("1_pu13l")
metadata/_custom_type_script = "uid://dy8gbmwddma3b"
[node name="StartedEvents" type="Node" parent="."]

View File

@@ -14,10 +14,10 @@ script = ExtResource("2_n4ii1")
title = "quest.test_quest.title"
metadata/_custom_type_script = "uid://dn0kxbe85n40f"
[node name="Find Onion" type="Node" parent="Quests/Test Quest"]
[node name="Find Sweet Potato" type="Node" parent="Quests/Test Quest"]
script = ExtResource("3_l8p7p")
title = "quest.test_quest.onion.title"
description = "quest.test_quest.onion.description"
itemType = 2
title = "quest.test_quest.sweet_potato.title"
description = "quest.test_quest.sweet_potato.description"
itemType = 3
quantity = 2
metadata/_custom_type_script = "uid://de1ao4huhy0hm"

View File

@@ -26,11 +26,11 @@ visible = false
layout_mode = 2
anchors_preset = 0
[node name="VNTextbox" parent="." instance=ExtResource("3_btpxp")]
visible = false
[node name="EventFlagMenu" parent="." instance=ExtResource("5_12prj")]
layout_mode = 1
[node name="EventFlagMenu" parent="." instance=ExtResource("5_12prj")]
[node name="VNTextbox" parent="." instance=ExtResource("3_btpxp")]
visible = false
layout_mode = 1
[node name="DebugMenu" parent="." instance=ExtResource("2_is0g4")]

View File

@@ -2,15 +2,18 @@
[ext_resource type="Script" uid="uid://b4a3ne2vn36mt" path="res://scripts/UI/EventFlagMenu.gd" id="1_nnw5f"]
[node name="EventFlagsMenu" type="Panel" node_paths=PackedStringArray("flagList", "grid")]
[node name="EventFlagsMenu" type="Panel" node_paths=PackedStringArray("flagList", "grid", "btnClose")]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1_nnw5f")
flagList = NodePath("HBoxContainer/FlagList")
grid = NodePath("HBoxContainer/Control")
grid = NodePath("HBoxContainer/VBoxContainer/Control")
btnClose = NodePath("HBoxContainer/VBoxContainer/HBoxContainer/Button")
metadata/_custom_type_script = "uid://b4a3ne2vn36mt"
[node name="HBoxContainer" type="HBoxContainer" parent="."]
@@ -31,43 +34,56 @@ item_count = 2
item_0/text = "Item 0"
item_1/text = "Item 1"
[node name="Control" type="GridContainer" parent="HBoxContainer"]
[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"]
clip_contents = true
layout_mode = 2
size_flags_horizontal = 3
columns = 6
[node name="Flag0" type="CheckBox" parent="HBoxContainer/Control"]
[node name="HBoxContainer" type="HBoxContainer" parent="HBoxContainer/VBoxContainer"]
layout_mode = 2
alignment = 2
[node name="Button" type="Button" parent="HBoxContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
text = "close"
[node name="Control" type="GridContainer" parent="HBoxContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
columns = 5
[node name="Flag0" type="CheckBox" parent="HBoxContainer/VBoxContainer/Control"]
layout_mode = 2
text = "Flag 0"
[node name="Flag1" type="CheckBox" parent="HBoxContainer/Control"]
[node name="Flag1" type="CheckBox" parent="HBoxContainer/VBoxContainer/Control"]
layout_mode = 2
text = "Flag 0"
[node name="Flag2" type="CheckBox" parent="HBoxContainer/Control"]
[node name="Flag2" type="CheckBox" parent="HBoxContainer/VBoxContainer/Control"]
layout_mode = 2
text = "Flag 0"
[node name="Flag3" type="CheckBox" parent="HBoxContainer/Control"]
[node name="Flag3" type="CheckBox" parent="HBoxContainer/VBoxContainer/Control"]
layout_mode = 2
text = "Flag 0"
[node name="Flag4" type="CheckBox" parent="HBoxContainer/Control"]
[node name="Flag4" type="CheckBox" parent="HBoxContainer/VBoxContainer/Control"]
layout_mode = 2
text = "Flag 0"
[node name="Flag5" type="CheckBox" parent="HBoxContainer/Control"]
[node name="Flag5" type="CheckBox" parent="HBoxContainer/VBoxContainer/Control"]
layout_mode = 2
text = "Flag 0"
[node name="Flag6" type="CheckBox" parent="HBoxContainer/Control"]
[node name="Flag6" type="CheckBox" parent="HBoxContainer/VBoxContainer/Control"]
layout_mode = 2
text = "Flag 0"
[node name="Flag7" type="CheckBox" parent="HBoxContainer/Control"]
[node name="Flag7" type="CheckBox" parent="HBoxContainer/VBoxContainer/Control"]
layout_mode = 2
text = "Flag 0"
[node name="Flag8" type="CheckBox" parent="HBoxContainer/Control"]
[node name="Flag8" type="CheckBox" parent="HBoxContainer/VBoxContainer/Control"]
layout_mode = 2
text = "Flag 0"

View File

@@ -1,14 +1,15 @@
[gd_scene load_steps=3 format=3 uid="uid://bkx3l0kckf4a8"]
[gd_scene load_steps=4 format=3 uid="uid://bkx3l0kckf4a8"]
[ext_resource type="Theme" uid="uid://dm7ee4aqjr2dl" path="res://ui/UI Theme.tres" id="1_wx4lp"]
[ext_resource type="Script" uid="uid://ck62jug2gl4wk" path="res://scripts/UI/VNTextbox.gd" id="2_uo1gm"]
[ext_resource type="Script" uid="uid://cq6bvma0kk6tg" path="res://scripts/UI/AdvancedRichText.gd" id="3_j0315"]
[node name="VNTextbox" type="PanelContainer"]
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -50.0
offset_top = -58.0
grow_horizontal = 2
grow_vertical = 0
theme = ExtResource("1_wx4lp")
@@ -17,12 +18,22 @@ script = ExtResource("2_uo1gm")
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 2
theme = ExtResource("1_wx4lp")
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="Label" type="RichTextLabel" parent="MarginContainer"]
layout_mode = 2
theme = ExtResource("1_wx4lp")
bbcode_enabled = true
text = "test
test
test
test"
text = "Text
Text
Text
Text"
script = ExtResource("3_j0315")
advancedText = "Text
Text
Text
Text"
metadata/_custom_type_script = "uid://cq6bvma0kk6tg"

View File

@@ -31,4 +31,9 @@ func make(inventory:Inventory = null) -> void:
for output in outputs:
inventory.addItem(output.type, output.quantity)
timesMade += 1
timesMade += 1
func getTransContext() -> TransContext:
var ctx = TransContext.new()
ctx.addTrans("title", title)
return ctx

View File

@@ -38,6 +38,9 @@ func getRaycastInteractable() -> EntityInteractable:
return interactable
func _process(delta: float) -> void:
if !entity or entity.isPaused():
return
match interactorType:
InteractorType.PLAYER_INPUT:
_processPlayerInput()
@@ -49,6 +52,10 @@ func _process(delta: float) -> void:
func _processPlayerInput() -> void:
if !Input.is_action_just_pressed("interact"):
return
# Conditions where player cannot interact.
if UI.hasInteractionFocus():
return
var interactable:EntityInteractable = getRaycastInteractable()
if interactable:

View File

@@ -22,11 +22,9 @@ func onEntityInteract(
interactor:EntityInteractor,
interactee:EntityInteractable
) -> void:
print("Interact?")
var event = EventGetItem.new()
event.itemType = itemType;
event.quantity = quantity;
event.removeNode = self
EVENT.addEvent(event)
event.onEntityInteract(interactor, interactee)
get_parent().remove_child(self)
self.queue_free()

View File

@@ -2,15 +2,13 @@ class_name Event extends Node
const Entity = preload("res://scripts/Entity/Entity.gd");
var inEventSystemTree:bool = false;
var started:bool = false;
var ended:bool = false;
var interactor:EntityInteractor = null
var interactee:EntityInteractable = null
# Godot Methods
func _init() -> void:
pass
func _process(delta: float) -> void:
if !started || ended:
return
@@ -21,6 +19,11 @@ func _process(delta: float) -> void:
# Event methods (cleaned up)
func start() -> void:
assert(
self.is_inside_tree(),
"Event is trying to start but the node is not part of the scene tree. "+
"Refer to EventSystem.addEvent"
)
assert(started == false)
started = true
@@ -34,6 +37,8 @@ func isDone() -> bool:
func end() -> void:
assert(ended == false)
ended = true
if self.inEventSystemTree:
EVENT.removeEvent(self)
func isEndingEvent() -> bool:
return false

View File

@@ -17,41 +17,46 @@ func start() -> void:
if interactee && interactor:
if turnInteractee && interactee.entityDirection && interactor.characterBody:
var turn = EventEntityTurn.new()
turn.name = "Conversation Turn Interactee"
turn.entity = interactee.entityDirection
turn.direction = turn.entity.getDirectionToFace(interactor.characterBody.global_position)
addExtraEvent(turn, 0)
addChildEvent(turn, 0)
if turnInteractor && interactor.entityDirection && interactee.characterBody:
var turn = EventEntityTurn.new()
turn.name = "Conversation Turn Interactor"
turn.entity = interactor.entityDirection
turn.direction = turn.entity.getDirectionToFace(interactee.characterBody.global_position)
addExtraEvent(turn, 0)
addChildEvent(turn, 0)
# Create start pause event
if (pauseInteractee && interactee.entity) || (pauseInteractor && interactor.entity):
var startPause = EventPause.new()
startPause.name = "Conversation Start Pause"
startPause.pauseType = startPauseType
startPause.entities = entities
if pauseInteractee && interactee.entity:
startPause.includeInteractee = pauseInteractee
if pauseInteractor && interactor.entity:
startPause.includeInteractor = pauseInteractor
addExtraEvent(startPause, 0)
addChildEvent(startPause, 0)
# Create end pause event.
endPauseEvent = EventPause.new()
endPauseEvent.name = "Conversation End Pause"
endPauseEvent.pauseType = endPauseType
endPauseEvent.entities = entities
if pauseInteractee && interactee.entity:
endPauseEvent.includeInteractee = pauseInteractee
if pauseInteractor && interactor.entity:
endPauseEvent.includeInteractor = pauseInteractor
addExtraEvent(endPauseEvent, -1)
addChildEvent(endPauseEvent, -1)
# Pass off to event group
super.start()
func end() -> void:
print("Ending conversation event: ", self)
# Manually end pause
if endPauseEvent != null && !endPauseEvent.started:
endPauseEvent.start()

View File

@@ -1,11 +1,25 @@
class_name EventTextbox extends "res://scripts/Event/Event.gd"
# @export var text:Array[String] = [ "Hello Text" ];
@export_multiline var text:String = "Hello Text"
@export_multiline var text:String = ""
var textPlural:String = ""
var count:int = 1
var transContext:TransContext = null
func start() -> void:
super.start()
VN.getTextbox().setText(self.text);
if text.is_empty() && transContext == null:
push_error("EventTextbox text is empty and no TransContext provided.")
return
if transContext == null:
transContext = TransContext.new()
if textPlural.is_empty():
VN.getTextbox().setText(transContext.trans(text))
else:
VN.getTextbox().setText(transContext.transPlural(text, textPlural, count));
func isDone() -> bool:
return super.isDone() && VN.getTextbox().isClosed;

View File

@@ -80,13 +80,4 @@ func reset() -> void:
for child in childEvents:
child.reset()
# Send to the parent to reset the extra events
super.reset()
func startChild(child:Event) -> void:
# Inherits some properties from this event.
child.interactee = self.interactee
child.interactor = self.interactor
child.start()
if child.isEndingEvent():
self.end()
super.reset()

View File

@@ -1,7 +1,7 @@
class_name EventWithChildren extends "res://scripts/Event/Event.gd"
var childEvents:Array[Event] = []
var extraEvents:Array[Event] = []
var addedEvents:Array[Event] = []
func start():
super.start()
@@ -22,16 +22,29 @@ func _updateChildEvents() -> void:
childEvents.append(child)
func _cleanupExtraEvents():
for event in extraEvents:
for event in addedEvents:
remove_child(event)
event.queue_free()
extraEvents = []
addedEvents = []
_updateChildEvents()
func addExtraEvent(child:Event, position:int) -> void:
func addChildEvent(child:Event, position:int = -1) -> void:
assert(started == false || ended == true)
# Add the child to the extra events list
extraEvents.append(child)
if position < 0:
position = childEvents.size() + position + 1
add_child(child)
move_child(child, position)
_updateChildEvents()
addedEvents.append(child)
_updateChildEvents()
func startChild(child:Event) -> void:
assert(child.get_parent() == self)
# Inherits some properties from this event.
child.interactee = self.interactee
child.interactor = self.interactor
child.start()
if child.isEndingEvent():
self.end()

View File

@@ -1,5 +1,7 @@
class_name EventGetItem extends "res://scripts/Event/Item/EventItem.gd"
const EventConversation = preload("res://scripts/Event/EventConversation.gd")
enum GetType {
FOUND,
GIVEN,
@@ -7,14 +9,20 @@ enum GetType {
@export var showText: bool = true
@export var getType:GetType = GetType.FOUND;
@export var removeNode:Node = null
var conversationEvent:EventConversation = null
var textboxEvent:EventTextbox = null
func start() -> void:
super.start()
getInventory().addItem(itemType, quantity)
# Should show text?
if !showText:
super.start()
return
# What text to show?
var textKey:String
match getType:
GetType.FOUND:
@@ -22,12 +30,29 @@ func start() -> void:
GetType.GIVEN:
textKey = "event.get_item.given"
_:
pass
super.start()
return
# Create translation context
var ctx = TransContext.new()
ctx.addInteger("quantity", quantity)
ctx.addContext("item", ITEM.getItem(itemType).getTransContext())
VN.getTextbox().setText(ctx.transPlural(textKey, textKey + "_plural", quantity));
# Create conversation
conversationEvent = EventConversation.new()
addChildEvent(conversationEvent)
# Create textbox
textboxEvent = EventTextbox.new()
textboxEvent.transContext = ctx
textboxEvent.text = textKey
textboxEvent.textPlural = textKey + "_plural"
textboxEvent.count = quantity
conversationEvent.addChildEvent(textboxEvent)
# Begin processing
super.start()
startChild(conversationEvent)
func isDone() -> bool:
if !super.isDone():
@@ -35,5 +60,13 @@ func isDone() -> bool:
if !showText:
return true
return VN.getTextbox().isClosed;
return conversationEvent.isDone()
func end() -> void:
if removeNode:
var parent = removeNode.get_parent()
if parent:
parent.remove_child(removeNode)
removeNode.queue_free()
removeNode = null
super.end()

View File

@@ -1,4 +1,4 @@
class_name EventItem extends Event
class_name EventItem extends "res://scripts/Event/Flow/EventWithChildren.gd"
const Inventory = preload("res://scripts/Item/Inventory.gd")
@export var itemType:Item.Type = Item.Type.POTION

View File

@@ -1,8 +1,13 @@
class_name Map extends Node
@export var mapName:String = "Map"
@export_multiline var title:String = ""
@export var mapEnterEvent:Event = null
func _ready() -> void:
if mapEnterEvent:
mapEnterEvent.start()
mapEnterEvent.start()
func getTransContext() -> TransContext:
var ctx = TransContext.new()
ctx.set("title", title)
return ctx

View File

@@ -1,4 +1,4 @@
class_name MainMenuScene extends Node
func _enter_tree() -> void:
pass
pass

View File

@@ -47,4 +47,25 @@ func eventAreFlagsOff(event:SpecialEvent, flagsToCheck:int) -> bool:
func eventIsAnyOfFlagsOff(event:SpecialEvent, flagsToCheck:int) -> bool:
if !eventFlags.has(event):
eventFlags[event] = 0;
return (eventFlags[event] & flagsToCheck) != flagsToCheck;
return (eventFlags[event] & flagsToCheck) != flagsToCheck;
# Adds an event that is created by code into the scene tree and lets it be
# managed properly by the event system.
func addEvent(event:Event) -> void:
assert(
!event.is_inside_tree(),
"Event is already inside the scene tree, cannot add it again."
)
$StartedEvents.add_child(event)
event.inEventSystemTree = true
func removeEvent(event:Event) -> void:
assert(
event.inEventSystemTree,
"Event is not inside event system tree."
)
event.inEventSystemTree = false
$StartedEvents.remove_child(event)
event.queue_free()

View File

@@ -32,4 +32,4 @@ func getItem(type:Item.Type) -> Item:
return ITEM_MAP[type]
func isStackable(itemType:Item.Type) -> bool:
return getItem(itemType).stackable
return getItem(itemType).stackable

View File

@@ -39,15 +39,6 @@ func _init() -> void:
var preferred = OS.get_locale()
self.setLocaleFromLocaleString(preferred)
func _enter_tree() -> void:
# Test
print("Hello World!")
var ctx = TransContext.new()
ctx.addInteger("quantity", 2)
ctx.addContext("item", ITEM.getItem(Item.Type.POTION).getTransContext())
print(ctx.trans("test"))
func setLocaleFromLocaleString(localeString:String) -> void:
var parts:PackedStringArray = localeString.split("_")

View File

@@ -4,13 +4,36 @@ var QUEST_MENU:QuestMenu
var DEBUG_MENU:DebugMenu
var INVENTORY_MENU:FullInventoryMenu
var EVENT_FLAG_MENU:EventFlagMenu
var VN_TEXTBOX:VNTextbox
func _ready() -> void:
QUEST_MENU = $QuestMenu
DEBUG_MENU = $DebugMenu
INVENTORY_MENU = $FullInventory
EVENT_FLAG_MENU = $EventFlagMenu
VN_TEXTBOX = $VNTextbox
func _process(delta: float) -> void:
# This needs to always be at the end of the parent node's tree
get_parent().move_child(self, get_parent().get_child_count() - 1)
func hasInteractionFocus() -> bool:
# Returns true if the UI system has focus, basically if any UI menu or
# element is open in a way that prevents interaction with the game world.
if QUEST_MENU.isOpen():
return true
if DEBUG_MENU.isOpen():
return true
if INVENTORY_MENU.isOpen():
return true
if EVENT_FLAG_MENU.isOpen():
return true
if !VN_TEXTBOX.isClosed:
return true
return false

View File

@@ -106,8 +106,6 @@ func build(
# Merge with our dictionary
dict.merge(subDict)
print("Trans context before key prepend: ", dict)
if key != "":
# Now prepend the parent key to all keys in the dictionary
var newDict:Dictionary[String, String] = {}

View File

@@ -2,6 +2,8 @@ class_name EventFlagMenu extends Panel
@export var flagList:ItemList
@export var grid:GridContainer
@export var btnClose:Button
var checkboxes:Array[CheckBox] = []
var selectedEvent:int = -1
@@ -24,6 +26,7 @@ func _ready() -> void:
EVENT.eventFlagUpdated.connect(_on_EventFlagUpdated)
flagList.item_selected.connect(_on_EventSelected)
btnClose.pressed.connect(close)
func _exit_tree() -> void:
EVENT.eventFlagUpdated.disconnect(_on_EventFlagUpdated)

View File

@@ -70,7 +70,7 @@ func getCountOfCharactersToScrollInView() -> int:
func recalculateWrapping():
# Reset label to default.
label.text = text;
label.advancedText = text;
label.visible_characters = -1;
label.fit_content = true;
isMoreViews = false;
@@ -98,7 +98,7 @@ func recalculateWrapping():
wrappedText += "\n";
wrappedText += text[i];
label.text = wrappedText;
label.advancedText = wrappedText;
label.fit_content = false;
label.visible_characters = 0;