Files
owniverse/ui/owniverse_item/owniverse_item.gd
T
Kirill c4e7302567 Add new tests and implement frame budget management
- Introduced `civilization_benchmark.gd` and `legacy_quantity_math.gd` for benchmarking and legacy quantity calculations.
- Created `test_dynamic_math.gd`, `test_frame_evolution.gd`, and `test_sparse_batches.gd` to validate mathematical operations and frame evolution logic.
- Implemented `frame_budget.gd` to manage cooperative work on the main thread, ensuring no partially calculated state is published.
- Added UID files for all new scripts to maintain unique identifiers.
2026-10-01 23:43:34 +03:00

48 lines
1.3 KiB
GDScript

extends Control
class_name OwniverseItem
const E = preload("res://world/owniverse/math/exact.gd")
signal item_activated(item)
const ENTITY_WIDTH = 216
const ENTITY_HEIGHT = 256
@onready var texture_button: TextureButton = $TextureButton
@onready var description: Label = $Description
@onready var selection: TextureRect = $Selection
var item_id: String = ""
var item_name: String = ""
var item_page: int = -1
var item_sub_page: int = -1
var item_type = ""
func set_label(value) -> void:
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 "")
if description.text != text:
description.text = text
#description.text = str(value)
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)
item_id = properties.id
item_name = properties.name
item_page = int(properties.page)
item_sub_page = int(properties.sub_page)
name = properties.id
func _on_button_up() -> void:
set_selection(true)
item_activated.emit(self)