33 lines
1.2 KiB
GDScript
33 lines
1.2 KiB
GDScript
extends Control
|
|
const EVENT_CHOICE_BUTTON = preload("res://scene/event_choice_button.tscn")
|
|
@onready var choice_add_pos: VBoxContainer = $MarginContainer/NinePatchRect/VBoxContainer/VBoxContainer/choice_add_pos
|
|
@onready var event_texture: TextureRect = $MarginContainer/HBoxContainer/event_texture
|
|
@onready var event_intro: Label = $MarginContainer/NinePatchRect/VBoxContainer/event_intro
|
|
@onready var event_name: Label = $MarginContainer/NinePatchRect/TextureRect/event_name
|
|
|
|
var data:Dictionary
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
set_event_data("event_01")
|
|
pass # Replace with function body.
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
pass
|
|
#通过事件ID初始化界面
|
|
func set_event_data(id:String):
|
|
data=Global.get_event_data(id)
|
|
for i in choice_add_pos.get_children():
|
|
i.queue_free()
|
|
event_texture.texture=Global.get_texture(data["texture"])
|
|
event_intro.text=data["text"]
|
|
event_name.text=data["name"]
|
|
var choice_data=data["choice"]
|
|
for i in choice_data:
|
|
var new_btn=EVENT_CHOICE_BUTTON.instantiate()
|
|
choice_add_pos.add_child(new_btn)
|
|
new_btn.set_data(i)
|
|
|
|
|