f2111a376a
- Introduced `life_evolution.gd` to manage life evolution processes. - Implemented `manual_production.gd` for handling production mechanics, including resource management and production steps. - Created `object_batches.gd` to manage batches of objects, including scaling and appending batches. - Developed `object_ledger.gd` for tracking physical amounts, available resources, and binding ownerships. - Added `simulation_module.gd` as a base class for simulation modules, providing a weak reference to the world. - Established `stellar_rules.gd` for managing stellar evolution and destruction mechanics. - Introduced `universe_environment.gd` to calculate environmental parameters based on the current state of the universe.
61 lines
2.9 KiB
GDScript
61 lines
2.9 KiB
GDScript
extends SceneTree
|
|
|
|
var checks: int = 0
|
|
var failures: int = 0
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("run")
|
|
|
|
func check(value: bool, message: String) -> void:
|
|
checks += 1
|
|
if not value:
|
|
failures += 1
|
|
push_error(message)
|
|
|
|
func run() -> void:
|
|
var scene = load("res://world/world.tscn").instantiate()
|
|
var stage = scene.get_node("Stage")
|
|
stage.owniverse.free()
|
|
stage.set_script(load("res://tests/fixtures/ui_stage.gd"))
|
|
root.add_child(scene)
|
|
await process_frame
|
|
await process_frame
|
|
stage.stage_page_scroller.scroll_horizontal = stage.PAGE_WIDTH
|
|
await process_frame
|
|
stage.owniverse.state.amount.H = 1000.0
|
|
stage.owniverse.state.amount.RD = 2.0
|
|
stage.owniverse.presentation.refresh(stage.owniverse.state, stage.owniverse.catalog)
|
|
stage.set_owniverse_item_value()
|
|
var hydrogen = stage.owniverse_items.H
|
|
var dwarf = stage.owniverse_items.RD
|
|
check(hydrogen.description.text == "1 000", "Pending quantities reach controls")
|
|
check(dwarf.description.text == "2", "Other page receives its current quantity")
|
|
check(stage.owniverse.presentation.pending_amounts.is_empty(), "Published queue is consumed by Stage")
|
|
stage.owniverse.presentation.deferred_updates = true
|
|
stage.owniverse.state.amount.H = 2000.0
|
|
stage.owniverse.presentation.refresh(stage.owniverse.state, stage.owniverse.catalog)
|
|
check(stage.owniverse.presentation.dirty and stage.owniverse.presentation.pending_amounts.is_empty(), "Deferred refresh marks dirty without republishing")
|
|
stage.set_owniverse_item_value()
|
|
check(hydrogen.description.text == "1 000", "Labels retain last published quantity")
|
|
stage.owniverse.presentation.refresh(stage.owniverse.state, stage.owniverse.catalog, true)
|
|
stage.set_owniverse_item_value()
|
|
check(hydrogen.description.text == "2 000" and not stage.owniverse.presentation.dirty, "Forced refresh publishes latest state")
|
|
stage.owniverse.presentation.deferred_updates = false
|
|
stage.item_activated(hydrogen)
|
|
stage.set_owniverse_item_value()
|
|
check(hydrogen.description.text == root.get_node("Global").format_number(stage.owniverse.state.amount.H), "Player production publishes the new quantity")
|
|
check(stage.owniverse.state.amount.H > 2000.0, "Production action actually executed")
|
|
dwarf.visible = true
|
|
stage.stage_page_scroller.scroll_horizontal = 2 * stage.PAGE_WIDTH
|
|
await process_frame
|
|
stage._refresh_universe_ui()
|
|
check(dwarf.description.text == "2", "Newly visible page receives cached latest values")
|
|
stage.owniverse.state.time.year = 1234.5
|
|
stage._refresh_universe_ui()
|
|
check(stage.date_time.text == "1 234.5", "Time displays tenths with thousands separator")
|
|
for entity in stage.owniverse.catalog.entities.values(): entity.free()
|
|
stage.owniverse.free()
|
|
scene.free()
|
|
print("UI updates: %d checks, %d failures" % [checks, failures])
|
|
quit(0 if failures == 0 else 1)
|