2026-03-30 00:48:20 +03:00
|
|
|
extends Control
|
2026-04-08 00:23:22 +03:00
|
|
|
class_name OwniverseItem
|
2026-10-01 23:43:34 +03:00
|
|
|
const E = preload("res://world/owniverse/math/exact.gd")
|
2026-03-30 00:48:20 +03:00
|
|
|
|
2026-04-08 00:23:22 +03:00
|
|
|
signal item_activated(item)
|
2026-03-30 00:48:20 +03:00
|
|
|
|
|
|
|
|
const ENTITY_WIDTH = 216
|
|
|
|
|
const ENTITY_HEIGHT = 256
|
2026-04-05 20:15:07 +03:00
|
|
|
|
|
|
|
|
|
2026-03-30 00:48:20 +03:00
|
|
|
@onready var texture_button: TextureButton = $TextureButton
|
|
|
|
|
@onready var description: Label = $Description
|
|
|
|
|
@onready var selection: TextureRect = $Selection
|
|
|
|
|
|
2026-05-05 23:49:12 +03:00
|
|
|
|
2026-04-08 00:23:22 +03:00
|
|
|
var item_id: String = ""
|
|
|
|
|
var item_name: String = ""
|
|
|
|
|
var item_page: int = -1
|
|
|
|
|
var item_sub_page: int = -1
|
2026-05-05 23:49:12 +03:00
|
|
|
var item_type = ""
|
2026-03-30 00:48:20 +03:00
|
|
|
|
|
|
|
|
|
2026-09-30 08:08:27 +03:00
|
|
|
func set_label(value) -> void:
|
2026-10-01 23:43:34 +03:00
|
|
|
var text: String = E.scientific(value, 5) if E.gt(E.absolute(value), 1000000000) else (E.grouped(value, 0, false) if E.ne(value, 0) else "")
|
2026-09-20 22:14:47 +03:00
|
|
|
if description.text != text:
|
|
|
|
|
description.text = text
|
2026-07-10 20:36:44 +03:00
|
|
|
#description.text = str(value)
|
2026-06-21 17:27:31 +03:00
|
|
|
|
|
|
|
|
|
2026-03-30 00:48:20 +03:00
|
|
|
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)
|
2026-04-08 00:23:22 +03:00
|
|
|
item_id = properties.id
|
|
|
|
|
item_name = properties.name
|
|
|
|
|
item_page = int(properties.page)
|
|
|
|
|
item_sub_page = int(properties.sub_page)
|
2026-03-30 00:48:20 +03:00
|
|
|
name = properties.id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_button_up() -> void:
|
|
|
|
|
set_selection(true)
|
2026-04-08 00:23:22 +03:00
|
|
|
item_activated.emit(self)
|