Files
mtgodot-poc/project/client_main.gd
T
2026-09-07 14:53:36 +08:00

30 lines
1.3 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# client_main —— 打包客户端的入口场景根(main_scene = res://client_main.tscn)。
#
# 只做一件事:起 AppFlow(登录 → 选人 → 进游戏 串场控制器)。
# 资源目录由 AssetRoot 决定:默认 res://../assets(开发树),打包后设环境变量
# MT_ASSETS 指向真实资源目录即可(见 project/asset_root.gd)。
extends Node
const AppFlow = preload("res://app_flow.gd")
const LiveSmokeTest = preload("res://live_smoke_test.gd")
func _ready() -> void:
# 打包 app 从 Finder/open 启动时没有 shell 环境;40250 服务器使用 classic
# DH2/CTR 协议,因此默认固定到 classic,同时保留 MT_PROTOCOL 覆盖能力。
if OS.get_environment("MT_PROTOCOL").is_empty():
OS.set_environment("MT_PROTOCOL", "classic")
# 移动端:APK/IPA 里没有资源 —— 挂载外部的 assets.zipadb push / ios-deploy 上传)。
AssetPack.ensure()
var root := AssetRoot.path()
if not AssetRoot.available():
push_warning("[client] 资源目录不存在:%s —— MT_ASSETS 环境变量 / assets.zipadb push 到 files/" % root)
var af := AppFlow.new()
af.name = "AppFlow"
add_child(af)
af.start(root)
if OS.get_environment("MT_TEST_MODE") == "smoke":
var smoke := LiveSmokeTest.new()
smoke.name = "LiveSmokeTest"
add_child(smoke)
smoke.setup(af, af.client)