Cleaned and improved some event stuff
This commit is contained in:
@@ -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()
|
@@ -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
|
||||
|
@@ -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("_")
|
||||
|
||||
|
@@ -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
|
Reference in New Issue
Block a user