Skip to content

CraftMaterialIconUI ​

Inherits: HBoxContainer

Enhanced material icon UI with visual feedback for material availability

Variables ​

boolhas_sufficient_materialstrue
intrequired_quantity1
intavailable_quantity0
ItemDefinitionitem_definitionnull
Colornormal_modulateColor.WHITE
Colorinsufficient_modulateColor(0.5, 0.5, 0.5, 0.8)
Colornormal_label_colorColor.WHITE
Colorinsufficient_label_colorColor.RED
Colorsufficient_label_colorColor.GREEN

Methods ​

voidsetup_material_icon( item_def: ItemDefinition, required_qty: int, available_qty: int )
voidupdate_availability( new_available_qty: int )
Stringget_availability_text()
boolis_sufficient()
intget_shortage()
voidapply_hover_effect()
voidremove_hover_effect()

Variable descriptions ​

bool has_sufficient_materials = true ​

Material availability state

int required_quantity = 1 ​

How many the recipe needs.

int available_quantity = 0 ​

How many the player has.

ItemDefinition item_definition = null ​

The material.

Color normal_modulate = Color.WHITE ​

Visual states

Color insufficient_modulate = Color(0.5, 0.5, 0.5, 0.8) ​

Greyed out

Color normal_label_color = Color.WHITE ​

The color of the label before it is checked.

Color insufficient_label_color = Color.RED ​

The color of the label when the player has too few.

Color sufficient_label_color = Color.GREEN ​

The color of the label when the player has enough.

Method descriptions ​

void setup_material_icon( item_def: ItemDefinition, required_qty: int, available_qty: int ) ​

Setup the material icon with item data and availability info

void update_availability( new_available_qty: int ) ​

Update availability without changing the item

String get_availability_text() ​

Get formatted display text for tooltips or other UI elements

bool is_sufficient() ​

Check if this material icon represents sufficient materials

int get_shortage() ​

Get the shortage amount if insufficient

void apply_hover_effect() ​

Apply hover effects (optional - can be used with mouse events)

void remove_hover_effect() ​

Remove hover effects