godot_experiments/station_info_panel/style1/current_station_panel.gd

92 lines
2.0 KiB
GDScript

@tool
extends Node3D
## 面板宽度,单位(m)
@export_range(1, 10) var panelWidth: float = 3:
get:
return panelWidth
set(v):
panelWidth = v
update()
## 面板高度,单位(m)
@export_range(0.1, 5) var panelHeight: float = 1:
get:
return panelHeight
set(v):
panelHeight = v
update()
## 面板背景色
@export var bgColor: Color = Color.DARK_GRAY:
get:
return bgColor
set(v):
bgColor = v
update()
## 装饰条颜色
@export var stripColor: Color = Color.DARK_GREEN:
get:
return stripColor
set(v):
stripColor = v
update()
## 是否显示线路信息
@export var lineInfoShow: bool = true:
get:
return lineInfoShow
set(v):
lineInfoShow = v
update()
## 线路信息背景色
@export var lineInfoBgColor: Color = Color.DARK_GREEN:
get:
return lineInfoBgColor
set(v):
lineInfoBgColor = v
update()
## 线路号
@export_range(1, 40) var lineNumber: int = 1:
get:
return lineNumber
set(v):
lineNumber = v
update()
## 车站名称
@export var stationName: String = "车站一":
get:
return stationName
set(v):
stationName = v
update()
## 车站英文/拼音名称
@export var stationEnName: String = "CHEZHANYI":
get:
return stationEnName
set(v):
stationEnName = v
update()
var isReady: bool = false
func update():
if not isReady:
return
$SubViewport/CurrentStationPanelContent.bgColor = bgColor
$SubViewport/CurrentStationPanelContent.stripColor = stripColor
$SubViewport/CurrentStationPanelContent.lineInfoShow = lineInfoShow
$SubViewport/CurrentStationPanelContent.lineInfoBgColor = lineInfoBgColor
$SubViewport/CurrentStationPanelContent.lineNumber = lineNumber
$SubViewport/CurrentStationPanelContent.stationName = stationName
$SubViewport/CurrentStationPanelContent.stationEnName = stationEnName
var vp = $SubViewport
$Plane.mesh.size.x = panelWidth
$Plane.mesh.size.y = panelHeight
$Plane.material_override.albedo_texture = vp.get_texture()
func _ready():
isReady = true
print("csPanel ready")
update()