client_main: default route switches to port (MT_PORT_PATH)
Without MT_PORT_PATH the app runs 40250 system.py on the Python UI and 3D surfaces; MT_PORT_PATH=legacy keeps the GDScript AppFlow. The smoke/playable live tests stay on legacy, MT_TEST_MODE=python_ui remains a port alias, and an unset switch falls back to legacy (with a warning) when the Python host or the 40250 pack is missing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
2ead95756e
commit
a49942a1a1
+43
-19
@@ -1,6 +1,9 @@
|
||||
# client_main —— 打包客户端的入口场景根(main_scene = res://client_main.tscn)。
|
||||
#
|
||||
# 只做一件事:起 AppFlow(登录 → 选人 → 进游戏 串场控制器)。
|
||||
# 默认走 port 路由(PORT-PLAN §2 总开关):40250 system.py 在内嵌解释器里跑,界面画在
|
||||
# python_ui_surface.gd、RenderGame 的 3D 绘制画在 python_3d_surface.gd。
|
||||
# MT_PORT_PATH=legacy 回到旧的 GDScript AppFlow(登录 → 选人 → 进游戏 串场控制器);
|
||||
# MT_TEST_MODE=smoke/playable 是 AppFlow 的真服测试,固定走 legacy。
|
||||
# 资源目录由 AssetRoot 决定:默认 res://../assets(开发树),打包后设环境变量
|
||||
# MT_ASSETS 指向真实资源目录即可(见 project/asset_root.gd)。
|
||||
extends Node
|
||||
@@ -35,29 +38,50 @@ func _ready() -> void:
|
||||
printerr("%d check(s) failed" % fail)
|
||||
get_tree().quit(1 if fail else 0)
|
||||
return
|
||||
# MT_TEST_MODE=python_ui:40250 system.py 的界面直接画在 Godot Canvas 上(PORT-PLAN 2V0-f),
|
||||
# Logo → 登录 → 选人 → 进游戏,RenderGame 的 3D 绘制由 python_3d_surface.gd 画出(2V2-e),
|
||||
# 方向键/鼠标点地走动走 40250 原路径(2V3);app.Exit() 退出进程。
|
||||
if OS.get_environment("MT_TEST_MODE") == "python_ui":
|
||||
AssetPack.ensure()
|
||||
var surface: Control = preload("res://python_ui_surface.gd").new()
|
||||
surface.name = "PythonUISurface"
|
||||
add_child(surface)
|
||||
# The UI surface runs CPythonApplication::Process in its _process; the 3D surface reads that
|
||||
# frame's draws after it, so it comes second in the tree.
|
||||
var world: Node3D = preload("res://python_3d_surface.gd").new()
|
||||
world.name = "Python3DSurface"
|
||||
add_child(world)
|
||||
var err: String = surface.run_app()
|
||||
if err != "":
|
||||
printerr("python_ui: " + err)
|
||||
get_tree().quit(1)
|
||||
return
|
||||
if OS.get_environment("MT_TEST_MODE") == "forest_render":
|
||||
var forest := ForestMapRenderTest.new()
|
||||
forest.name = "ForestMapRenderTest"
|
||||
add_child(forest)
|
||||
return
|
||||
# port 路由:40250 system.py 的界面直接画在 Godot Canvas 上(PORT-PLAN 2V0-f),
|
||||
# Logo → 登录 → 选人 → 进游戏,RenderGame 的 3D 绘制由 python_3d_surface.gd 画出(2V2-e),
|
||||
# 方向键/鼠标点地走动走 40250 原路径(2V3);app.Exit() 退出进程。
|
||||
# MT_TEST_MODE=python_ui 是切换默认值之前的入口,保留为 MT_PORT_PATH=port 的别名。
|
||||
var mode := OS.get_environment("MT_TEST_MODE")
|
||||
var route := OS.get_environment("MT_PORT_PATH")
|
||||
if mode == "python_ui":
|
||||
route = "port"
|
||||
elif mode == "smoke" or mode == "playable":
|
||||
route = "legacy"
|
||||
if route != "legacy":
|
||||
if route != "" and route != "port":
|
||||
push_warning("[client] 未知的 MT_PORT_PATH=%s,按 port 处理" % route)
|
||||
if _start_port_route(route != ""):
|
||||
return
|
||||
_start_legacy_route()
|
||||
|
||||
# Returns false when the port route cannot start and the default (unset MT_PORT_PATH) should fall
|
||||
# back to legacy; an explicit MT_PORT_PATH=port quits with the error instead.
|
||||
func _start_port_route(explicit: bool) -> bool:
|
||||
AssetPack.ensure()
|
||||
if not explicit and not (ClassDB.class_exists("Metin2PythonHost") and AssetRoot.pack_ready()):
|
||||
push_warning("[client] port 路由缺 Metin2PythonHost 或 40250 Client/pack(%s),退回 legacy AppFlow" % AssetRoot.client_path())
|
||||
return false
|
||||
var surface: Control = preload("res://python_ui_surface.gd").new()
|
||||
surface.name = "PythonUISurface"
|
||||
add_child(surface)
|
||||
# The UI surface runs CPythonApplication::Process in its _process; the 3D surface reads that
|
||||
# frame's draws after it, so it comes second in the tree.
|
||||
var world: Node3D = preload("res://python_3d_surface.gd").new()
|
||||
world.name = "Python3DSurface"
|
||||
add_child(world)
|
||||
var err: String = surface.run_app()
|
||||
if err != "":
|
||||
printerr("port: " + err)
|
||||
get_tree().quit(1)
|
||||
return true
|
||||
|
||||
func _start_legacy_route() -> void:
|
||||
# 打包 app 从 Finder/open 启动时没有 shell 环境;40250 服务器使用 classic
|
||||
# DH2/CTR 协议,因此默认固定到 classic,同时保留 MT_PROTOCOL 覆盖能力。
|
||||
if OS.get_environment("MT_PROTOCOL").is_empty():
|
||||
|
||||
Reference in New Issue
Block a user