Skip to content

VendorSlotUI ​

Inherits: MarginContainer

Clean VendorSlotUI that initializes everything in setup_vendor_slot() instead of _ready() Refactored to use system_hub instead of ui_manager

Variables ​

ItemDefinitionitem_definition
VendorInventoryComponentvendor_inventory
Entityplayer_entity
intitem_id
intstock_quantity
intitem_price
CurrencyDefinitioncurrency_definition
boolis_interactabletrue
Colordefault_background_colorColor.WHITE
Colorhover_background_colorColor(1.2, 1.2, 1.2, 1.0)
Colorunavailable_background_colorColor(0.5, 0.5, 0.5, 1.0)
Colorout_of_stock_background_colorColor(0.3, 0.3, 0.3, 1.0)

Methods ​

voidsetup_vendor_slot( item_def: ItemDefinition, vendor_inv: VendorInventoryComponent, player: Entity )
voidrefresh_display()
Stringget_vendor_buy_price()
boolhas_item()
Stringget_price_string()
boolcan_purchase()
voidupdate_stock_display( new_stock: int )
intget_stock_quantity()
intget_item_price()
voidupdate_affordability()

Signals ​

purchase_requested( item_id: int, quantity: int ) ​

Emitted when the player wants to buy: the item and how many.

item_tooltip_requested( item: ItemInstance, definition: ItemDefinition, context: String, additional_data: Dictionary ) ​

Tooltips

hide_tooltip( force_hide: bool ) ​

Asks the interface to hide the tooltip (force hides it at once).

message_requested( message: String ) ​

Messages

warning_message_requested( message: String ) ​

Asks the interface to show a warning.

ui_sfx_request( sound: AudioManager.UISound, volume_modifier: float ) ​

Audio Request

Constants ​

  • int UNLIMITED_STOCK = -1 - Constant for unlimited stock

Variable descriptions ​

ItemDefinition item_definition ​

The item the slot sells.

VendorInventoryComponent vendor_inventory ​

The stock of the vendor.

Entity player_entity ​

The player who buys.

int item_id ​

The id of the item.

int stock_quantity ​

How many are in stock.

int item_price ​

The price of one.

CurrencyDefinition currency_definition ​

The currency of the price.

bool is_interactable = true ​

True when the player can buy from the slot.

Color default_background_color = Color.WHITE ​

The color of the background.

Color hover_background_color = Color(1.2, 1.2, 1.2, 1.0) ​

The color of the background under the mouse.

Color unavailable_background_color = Color(0.5, 0.5, 0.5, 1.0) ​

The color of the background when the player cannot buy.

Color out_of_stock_background_color = Color(0.3, 0.3, 0.3, 1.0) ​

The color of the background when it is out of stock.

Method descriptions ​

void setup_vendor_slot( item_def: ItemDefinition, vendor_inv: VendorInventoryComponent, player: Entity ) ​

Setup this slot with vendor item data - call this after adding as child

void refresh_display() ​

Refresh all display elements

String get_vendor_buy_price() ​

Get vendor's buy-back price for this item type

bool has_item() ​

Does the slot sell something?

String get_price_string() ​

The price as text, with the currency.

bool can_purchase() ​

Can the player buy from the slot (it is in stock)?

void update_stock_display( new_stock: int ) ​

Shows a new stock quantity.

int get_stock_quantity() ​

How many are in stock.

int get_item_price() ​

The price of one.

void update_affordability() ​

Checks whether the player can pay, and updates the slot.