Work on item display windows and variant coloring for portraits and sprites.

This commit is contained in:
2025-08-30 08:01:48 -04:00
parent b93889e914
commit 149ee993dc
84 changed files with 1526 additions and 43 deletions

View File

@@ -24,7 +24,7 @@ var weapon : Weapon
var armor : Armor
var accessory : Accessory
var inventory : Dictionary[Vector2, Item] = {}
var inventory_size : Vector2i = Vector2i(6,1)
var inventory_size : Vector2i = Vector2i(3,2)
var inventory_count : int = 0
var quest_sprite : QuestSprite

View File

@@ -0,0 +1 @@
extends Control

View File

@@ -0,0 +1 @@
uid://m86jmtwv1a22

View File

@@ -17,6 +17,8 @@ var data : Adventurer
var item_slots : Array[ItemSlot]
var item_display_window_template = preload("res://templates/item_display_window.tscn")
func setup(adv : Adventurer) -> void:
data = adv
data.changed.connect(_on_data_changed)
@@ -24,6 +26,7 @@ func setup(adv : Adventurer) -> void:
item_slots = []
for child : ItemSlot in %InventoryGrid.get_children():
item_slots.append(child)
child.display_item.connect(_on_display_item)
#TODO: Show equipment
update_items()
@@ -61,3 +64,11 @@ func update_items() -> void:
func _on_data_changed() -> void:
update_stats()
update_items()
func _on_display_item(item : Item) -> void:
var wnd : Popup = item_display_window_template.instantiate()
adding_subwindow = true
add_child(wnd)
wnd.setup(item)
wnd.popup_centered()
adding_subwindow = false

1
scripts/color_variant.gd Normal file
View File

@@ -0,0 +1 @@
extends TextureRect

View File

@@ -0,0 +1 @@
uid://cdi0oxcug1hup

View File

@@ -1 +1,32 @@
extends Window
extends Popup
var dragging : bool = false
var item : Item
@onready var image : TextureRect = %Image
@onready var item_name : Label = %ItemName
@onready var item_type : Label = %ItemType
@onready var item_grade : Label = %ItemGrade
@onready var primary_stat : Label = %PrimaryStat
@onready var secondary_stats : Label = %SecondaryStats
@onready var brief : Label = %Brief
func setup(itm : Item) -> void:
item = itm
title = item.name + " Information"
image.texture = item.image
item_name.text = item.name
item_type.text = item.item_type_name()
item_grade.text = item.grade
primary_stat.text = item.primary_stat()
#TODO: Implement item secondary stats meaningfully
brief.text = item.brief
func _on_drag_region_gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT:
dragging = event.pressed
elif dragging and event is InputEventMouseMotion:
position += Vector2i(event.screen_relative)

View File

@@ -1,11 +1,13 @@
class_name ItemSlot extends Control
#var item_display_window_template = preload("res://templates/item_display_window.tscn")
@onready var item_sprite : TextureRect = $Item
var dragging : bool = false
var last_click : int = 0
var item : Item
@onready var item_sprite : TextureRect = $Item
signal display_item(itm)
func assign(itm : Item) -> void:
item = itm
if item.image != null:
@@ -29,6 +31,9 @@ func clear() -> void:
func _on_gui_input(event: InputEvent) -> void:
var mmevt = event as InputEventMouseMotion
var mbevt = event as InputEventMouseButton
if mbevt != null:
if mbevt.pressed and mbevt.button_index == MOUSE_BUTTON_LEFT and item != null:
display_item.emit(item)
#if mbevt and mbevt.button_index == MOUSE_BUTTON_MASK_LEFT:
#if !mbevt.pressed:
#if dragging and

View File

@@ -1,7 +1,14 @@
class_name ProfileWindow extends Window
var dragging : bool = false
var adding_subwindow : bool = false
func _on_focus_exited() -> void:
var focused_node = get_viewport().gui_get_focus_owner()
if is_ancestor_of(focused_node) or adding_subwindow:
return
else:
_on_close_requested()
func _on_close_requested() -> void:
queue_free()