2024-04-16 10:10:18 +08:00
|
|
|
extends Node
|
|
|
|
|
2024-05-20 10:28:59 +08:00
|
|
|
class_name SceneLoader
|
|
|
|
|
|
|
|
var ConfigParams = preload("res://config_params.gd")
|
|
|
|
|
2024-04-16 10:10:18 +08:00
|
|
|
func _ready():
|
|
|
|
# 监听JavaScript发送的场景名称
|
|
|
|
var training_name = JavaScriptBridge.eval("""
|
|
|
|
var urlParams = new URLSearchParams(window.location.search);
|
2024-05-27 14:38:30 +08:00
|
|
|
urlParams.get('name');
|
2024-04-16 10:10:18 +08:00
|
|
|
""")
|
2024-05-20 10:28:59 +08:00
|
|
|
var token = JavaScriptBridge.eval("""
|
|
|
|
var urlParams = new URLSearchParams(window.location.search);
|
|
|
|
urlParams.get('token');
|
|
|
|
""")
|
|
|
|
print(training_name, ", token=", token)
|
|
|
|
ConfigParams.Token = token
|
2024-04-16 10:10:18 +08:00
|
|
|
if not training_name:
|
|
|
|
$ErrMsg.text = "未指定实训"
|
|
|
|
else:
|
|
|
|
_on_scene_name_received(training_name)
|
|
|
|
|
|
|
|
func _on_scene_name_received(training_name):
|
|
|
|
print("load training: ", training_name)
|
|
|
|
var scene = load("res://trainings/" + training_name + ".tscn")
|
|
|
|
if not scene:
|
|
|
|
$ErrMsg.text = "未找到实训: %s" % training_name
|
|
|
|
if scene:
|
|
|
|
get_tree().change_scene_to_packed(scene)
|