57 lines
1.1 KiB
GDScript3
57 lines
1.1 KiB
GDScript3
|
@tool
|
||
|
extends Node2D
|
||
|
|
||
|
## 从左到右/从右到左
|
||
|
@export var leftToRight: bool = true:
|
||
|
get:
|
||
|
return leftToRight
|
||
|
set(v):
|
||
|
leftToRight = v
|
||
|
update()
|
||
|
## 车站列表
|
||
|
@export var stations: Array[String] = ["车站一|CHEZHANYI"]:
|
||
|
get:
|
||
|
return stations
|
||
|
set(v):
|
||
|
stations = v
|
||
|
assert(stations.size() > 0, "车站列表不能为空")
|
||
|
for s in stations:
|
||
|
assert(s.split("|").size() == 2, "车站名格式:'车站名|车站英文名'")
|
||
|
update()
|
||
|
## 当前车站索引
|
||
|
@export var currentStationIndex: int = 0:
|
||
|
get:
|
||
|
return currentStationIndex
|
||
|
set(v):
|
||
|
currentStationIndex = v
|
||
|
update()
|
||
|
|
||
|
|
||
|
@onready var siteInfoScene: PackedScene = preload("res://station_info_panel/style1/site_info.tscn")
|
||
|
|
||
|
var isReady = false
|
||
|
func update():
|
||
|
if not isReady:
|
||
|
|
||
|
return
|
||
|
for c in $Sites.get_children():
|
||
|
c.free()
|
||
|
var size = stations.size()
|
||
|
var s = stations[0]
|
||
|
var sns = s.split("|")
|
||
|
var sis = siteInfoScene.instantiate()
|
||
|
sis.stationName = sns[0]
|
||
|
sis.stationEnName = sns[1]
|
||
|
sis.stripColor = Color.AQUA
|
||
|
sis.nameColor = Color.BLUE
|
||
|
$Sites.add_child(sis)
|
||
|
|
||
|
var w = sis.calculateWidth()
|
||
|
print(w)
|
||
|
#for i in stations.size():
|
||
|
|
||
|
|
||
|
func _ready():
|
||
|
isReady = true
|
||
|
update()
|