Inventory context
This commit is contained in:
parent
d413c211b5
commit
fed57e38df
17 changed files with 128 additions and 108 deletions
|
@ -1,9 +1,13 @@
|
|||
extends Button
|
||||
|
||||
@export var constructible : Prototype
|
||||
class_name ConstructionButton
|
||||
|
||||
func _ready() -> void:
|
||||
icon = constructible.preview
|
||||
var prototype : Prototype:
|
||||
set(value):
|
||||
prototype = value
|
||||
icon = prototype.preview
|
||||
get:
|
||||
return prototype
|
||||
|
||||
func _pressed() -> void:
|
||||
GuiEventBus.construction_selected.emit(constructible)
|
||||
GuiEventBus.construction_selected.emit(prototype)
|
||||
|
|
11
scripts/gui/construction_buttons_generator.gd
Normal file
11
scripts/gui/construction_buttons_generator.gd
Normal file
|
@ -0,0 +1,11 @@
|
|||
extends Node
|
||||
|
||||
const button = preload("res://scenes/gui/construction_button.tscn")
|
||||
|
||||
func _ready() -> void:
|
||||
for file in ResourceLoader.list_directory("res://generic/prototypes/"):
|
||||
var btn = button.instantiate()
|
||||
var loaded_prototype : Prototype = ResourceLoader.load("res://generic/prototypes/"+file)
|
||||
|
||||
btn.get_node("Button").prototype = loaded_prototype
|
||||
add_child(btn)
|
1
scripts/gui/construction_buttons_generator.gd.uid
Normal file
1
scripts/gui/construction_buttons_generator.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://bnjwg4rlcfd8k
|
|
@ -2,5 +2,5 @@ extends Node
|
|||
|
||||
@warning_ignore_start("unused_signal")
|
||||
|
||||
signal construction_selected(constructible : Prototype)
|
||||
signal construction_placed(constructible : Prototype)
|
||||
signal construction_selected(prototype : Prototype)
|
||||
signal construction_placed(prototype : Prototype)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue