Fix Escape
This commit is contained in:
+16
-6
@@ -1,8 +1,8 @@
|
||||
extends CanvasLayer
|
||||
|
||||
@onready var chat_log = $Control/ChatLog
|
||||
@onready var chat_messages_container = $Control/ChatLog/ChatMessages
|
||||
@onready var chat_input = $Control/InputContainer/ChatInput
|
||||
@onready var chat_log = $Control/VBoxContainer/ChatLog
|
||||
@onready var chat_messages_container = $Control/VBoxContainer/ChatLog/ChatMessages
|
||||
@onready var chat_input = $Control/VBoxContainer/InputContainer/ChatInput
|
||||
|
||||
const MAX_MESSAGES = 50
|
||||
const TYPE_COLORS = {
|
||||
@@ -13,6 +13,7 @@ const TYPE_COLORS = {
|
||||
}
|
||||
|
||||
func _ready():
|
||||
print("[ChatUI] _ready called")
|
||||
chat_input.text_submitted.connect(_on_message_submitted)
|
||||
|
||||
visible = false
|
||||
@@ -21,13 +22,20 @@ func _ready():
|
||||
call_deferred("_connect_gamestate")
|
||||
|
||||
func _connect_gamestate():
|
||||
print("[ChatUI] _connect_gamestate called")
|
||||
if GameState:
|
||||
print("[ChatUI] Connecting to GameState.chat_message_received signal")
|
||||
GameState.chat_message_received.connect(_on_chat_message)
|
||||
print("[ChatUI] Signal connected successfully")
|
||||
else:
|
||||
print("[ChatUI] ERROR: GameState not found!")
|
||||
|
||||
func _on_chat_message(sender: String, message: String, type: String):
|
||||
print("[ChatUI] _on_chat_message received - Sender: '%s', Message: '%s', Type: '%s'" % [sender, message, type])
|
||||
_add_message(sender, message, type)
|
||||
|
||||
func _add_message(sender: String, message: String, type: String = "normal"):
|
||||
print("[ChatUI] Adding message to chat log")
|
||||
var label = RichTextLabel.new()
|
||||
label.bbcode_enabled = true
|
||||
label.fit_content = true
|
||||
@@ -35,13 +43,14 @@ func _add_message(sender: String, message: String, type: String = "normal"):
|
||||
|
||||
var color = TYPE_COLORS.get(type, Color.WHITE)
|
||||
var color_hex = color.to_html(false)
|
||||
|
||||
print("[ChatUI] set type")
|
||||
if type == "system":
|
||||
label.text = "[color=#%s][System] %s[/color]" % [color_hex, message]
|
||||
else:
|
||||
label.text = "[color=#ffd700]%s:[/color] [color=#%s]%s[/color]" % [sender, color_hex, message]
|
||||
|
||||
print("[ChatUI] Bout to add")
|
||||
chat_messages_container.add_child(label)
|
||||
print("[ChatUI] Message added: %s" % label.text)
|
||||
|
||||
# Limit messages
|
||||
while chat_messages_container.get_child_count() > MAX_MESSAGES:
|
||||
@@ -58,7 +67,8 @@ func _on_message_submitted(text: String):
|
||||
if text.strip_edges().is_empty():
|
||||
_close()
|
||||
return
|
||||
|
||||
_add_message(GameState.character.get("name"),text,"normal")
|
||||
print("[ChatUI] Sending chat message: %s" % text)
|
||||
GameState.send_chat(text)
|
||||
chat_input.text = ""
|
||||
_close()
|
||||
|
||||
@@ -12,6 +12,7 @@ extends CanvasLayer
|
||||
|
||||
@onready var minimap_container = $TopRight/Minimap
|
||||
@onready var minimap_texture = $TopRight/Minimap/MinimapTexture
|
||||
@onready var event_log = $TopRight/EventLog
|
||||
|
||||
@onready var hotbar_container = $BottomCenter/Hotbar
|
||||
|
||||
@@ -35,6 +36,7 @@ func _connect_gamestate():
|
||||
GameState.dungeon_state_updated.connect(_update_resources)
|
||||
GameState.inventory_updated.connect(_update_hotbar)
|
||||
GameState.dungeon_entered.connect(_on_dungeon_entered)
|
||||
GameState.loot_received.connect(_on_loot_received)
|
||||
|
||||
func _on_dungeon_entered():
|
||||
_generate_minimap()
|
||||
@@ -212,3 +214,31 @@ func _update_escape_indicator():
|
||||
var remaining = max(0, 5 - elapsed)
|
||||
if escape_countdown:
|
||||
escape_countdown.text = "%.1f" % remaining
|
||||
|
||||
func _on_loot_received(items: Array):
|
||||
print("[HUD] Loot received! %d items" % items.size())
|
||||
for item in items:
|
||||
var item_name = item.get("name", item.get("Name", "Unknown"))
|
||||
var rarity = item.get("rarity", item.get("Rarity", "Common"))
|
||||
var quantity = item.get("quantity", item.get("Quantity", 1))
|
||||
|
||||
var color = _get_rarity_color(rarity)
|
||||
var text = "+%d %s" % [quantity, item_name] if quantity > 1 else "+ %s" % item_name
|
||||
add_log_entry(text, color)
|
||||
|
||||
func _get_rarity_color(rarity: String) -> Color:
|
||||
match rarity.to_lower():
|
||||
"common": return Color(0.7, 0.7, 0.7)
|
||||
"uncommon": return Color(0.18, 0.8, 0.44)
|
||||
"rare": return Color(0.2, 0.6, 0.86)
|
||||
"epic": return Color(0.61, 0.35, 0.71)
|
||||
"legendary": return Color(0.95, 0.61, 0.07)
|
||||
_: return Color.WHITE
|
||||
|
||||
func add_log_entry(test: String, color: Color):
|
||||
var label = RichTextLabel.new()
|
||||
label.bbcode_enabled = true
|
||||
label.fit_content = true
|
||||
label.scroll_active = false
|
||||
event_log.add_child(label)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user