godot_experiments/experiments/psd_panel_ui.gd

38 lines
1.2 KiB
GDScript

@tool
extends Node2D
var stationLabelNode: PackedScene = preload("res://experiments/station_label.tscn")
class StationLable:
var name: String
var enName: String
var current: bool
func _init(n, en, cur):
name = n
enName = en
current = cur
var stations = [
StationLable.new("会展中心", "Exhibition Center", false),
StationLable.new("世纪大道", "Century Avenue", false),
StationLable.new("交通大学", "JiaoTong Univercity", true),
StationLable.new("市图书馆", "City Library", false),
StationLable.new("中心医院", "Central Hospital", false),
StationLable.new("未来路", "Wei lai lu", false),
StationLable.new("火车站", "train station", false),
StationLable.new("人民广场", "People's Square", false),
StationLable.new("体育中心", "sports center", false),
]
func _ready():
for i in stations.size():
var slable = stations[i]
print(slable.name, slable.enName, slable.current)
if slable.current:
$VBoxContainer/CurrentStationName.text = slable.name
$VBoxContainer/EnName.text = slable.enName
var slScene = stationLabelNode.instantiate()
slScene._init_station_name_and_position(slable.name, slable.enName, i)
$Container.add_child(slScene)