40 lines
1.1 KiB
GDScript
40 lines
1.1 KiB
GDScript
|
|
extends Control
|
||
|
|
class_name OwniverseEntity
|
||
|
|
|
||
|
|
signal entity_activated(entity)
|
||
|
|
|
||
|
|
const ENTITY_WIDTH = 216
|
||
|
|
const ENTITY_HEIGHT = 256
|
||
|
|
|
||
|
|
@onready var texture_button: TextureButton = $TextureButton
|
||
|
|
@onready var description: Label = $Description
|
||
|
|
@onready var selection: TextureRect = $Selection
|
||
|
|
|
||
|
|
@export var entity_name: String = ""
|
||
|
|
@export var entity_id: String = ""
|
||
|
|
@export var entity_page: int = -1
|
||
|
|
@export var sub_page: int = -1
|
||
|
|
|
||
|
|
|
||
|
|
func set_selection(flag: bool) -> void:
|
||
|
|
selection.visible = flag
|
||
|
|
|
||
|
|
|
||
|
|
func init_button(properties: Dictionary):
|
||
|
|
var image_path = "res://" + properties.image + properties.name + ".png"
|
||
|
|
texture_button.texture_normal = load(image_path)
|
||
|
|
position = Vector2i(int(properties.col) * ENTITY_WIDTH, int(properties.row) * ENTITY_HEIGHT)
|
||
|
|
entity_id = properties.id
|
||
|
|
entity_name = properties.name
|
||
|
|
entity_page = int(properties.page)
|
||
|
|
sub_page = int(properties.sub_page)
|
||
|
|
name = properties.id
|
||
|
|
set_selection(false)
|
||
|
|
#print(properties)
|
||
|
|
|
||
|
|
|
||
|
|
func _on_button_up() -> void:
|
||
|
|
set_selection(true)
|
||
|
|
entity_activated.emit(self)
|
||
|
|
#Texture_button.texture_normal = load("res://UI/0-Forces/Inflatin.png")
|