# atlas_test —— Atlas 大地图窗口的无资源 headless 自检。 # godot --headless --path project --script atlas_test.gd extends SceneTree const AtlasUI = preload("res://ui/atlas_ui.gd") const UiManager = preload("res://ui/ui_manager.gd") class FakeWorld extends Node: func get_map_size_tiles() -> Vector2i: return Vector2i(2, 2) func chunk_dir(_x: int, _y: int) -> String: return "/no-such-chunk" func load_dds(_path: String): return null class FakeClient extends Node: var entities := {9: {"vid": 9, "pos": Vector3(2, 0, -2)}} func get_party() -> Array: return [{"vid": 9, "leader": true}] func get_entity(vid: int) -> Dictionary: return entities.get(vid, {}) func get_land_areas() -> Array: return [{"x": 0, "y": 0, "width": 5000, "height": 5000, "guild_id": 7}] func get_observers() -> Array: return [{"vid": 9, "pos": Vector3(2, 0, -2)}] func get_world_markers() -> Array: return [{"pos": Vector3(-2, 0, 2)}] var _fail := 0 func _ck(ok: bool, msg: String) -> void: if not ok: _fail += 1 printerr("FAIL: " + msg) func _init() -> void: await _run() if _fail == 0: print("PASS: atlas_test (window + drag + coordinate query)") quit(0) else: printerr("%d check(s) failed" % _fail) quit(1) func _run() -> void: var world := FakeWorld.new() get_root().add_child(world) var ui: CanvasLayer = UiManager.new() get_root().add_child(ui) await process_frame var player := Node3D.new() player.position = Vector3(128, 0, 256) get_root().add_child(player) var client := FakeClient.new() get_root().add_child(client) var atlas: Node = AtlasUI.new() get_root().add_child(atlas) atlas.setup(world, ui, func() -> Node3D: return player, "test_map", client) atlas.open() _ck(atlas.is_open(), "atlas opens") _ck(atlas._map != null and atlas._map.size == Vector2(256, 256), "atlas builds map texture") _ck(String(atlas._coord.text).contains("X 12800") and String(atlas._coord.text).contains("Y 25600"), "atlas reports player server-centimetre coordinates") atlas._overlay.queue_redraw() _ck(atlas._overlay.is_inside_tree(), "atlas world marker overlay is live") var old_pos: Vector2 = atlas._map.position var down := InputEventMouseButton.new() down.button_index = MOUSE_BUTTON_LEFT down.pressed = true down.position = Vector2(100, 100) atlas._on_map_input(down) var drag := InputEventMouseMotion.new() drag.position = Vector2(140, 120) atlas._on_map_input(drag) _ck(atlas._map.position != old_pos, "atlas left drag moves map") var reset := InputEventMouseButton.new() reset.button_index = MOUSE_BUTTON_RIGHT reset.pressed = true atlas._on_map_input(reset) _ck(atlas._map.position == atlas._map_origin, "atlas right click recenters map") atlas.close() _ck(not atlas.is_open(), "atlas closes")