Files
mtgodot-poc/project/client_main.gd
T
shenandshen 837c830182 port: complete 100% logic layer, eliminate pending dir, and unify client_main on port route
- Completed batch 4-f (Messenger, Guild, GuildMark), 4-g (PythonSystem, systemSetting), 4-h (PythonSoundManagerModule, MilesLib CSoundManager)
- Ported UserInterface/Locale.cpp, EterLocale/Japanese.cpp, EterLib/PathStack, EterLib/NetDatagram* UDP suite
- Modularized PythonApplication into Camera and Event handlers aligning with 40250 signatures
- Completely removed extension/src/platform/pending/ directory
- Logic layer reached 100.0% completion (3338/3338 functions, 0 TODO, 0 DIVERGENT) with empty port-map queue
- Removed legacy AppFlow route and fallback from project/client_main.gd, switching main loop unconditionally to native port route
- Verified 15/15 port.login_flow integration steps and 19/19 port_gate suites passing
2026-09-23 22:17:59 -07:00

68 lines
3.0 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)。
#
# 走 40250 原生 port 路径:40250 system.py 在内嵌解释器里跑,界面画在
# python_ui_surface.gd、RenderGame 的 3D 绘制画在 python_3d_surface.gd。
# 方向键/鼠标点地走动走 40250 原路径(2V3);app.Exit() 退出进程。
# 资源目录由 AssetRoot 决定:40250 Client/pack 资源包。
extends Node
const PackageRenderTest = preload("res://package_render_test.gd")
const ForestMapRenderTest = preload("res://forest_map_render_test.gd")
func _ready() -> void:
if OS.get_environment("MT_TEST_MODE") == "particle_exit":
add_child(preload("res://particle_exit_test.gd").new())
return
# MT_TEST_MODE=render:包内离线渲染自检,不起 CPythonApplication、不连服务器。
# 导出模板不接受 --script,这是导出包里唯一能跑离线渲染回归的入口。
if OS.get_environment("MT_TEST_MODE") == "render":
AssetPack.ensure()
var t := PackageRenderTest.new()
t.name = "PackageRenderTest"
add_child(t)
return
# MT_TEST_MODE=python:在 app 进程里起内嵌解释器跑 system.py(PORT-PLAN 批次 2P step 4)。
# 导出模板不接受 --script,这是在真机 APK/IPA 里跑这条检查的唯一入口。
if OS.get_environment("MT_TEST_MODE") == "python":
AssetPack.ensure()
var fail: int = preload("res://python_host_check.gd").new().run()
if fail == 0:
print("PASS: python_host_check (app 进程内 system.py)")
else:
printerr("%d check(s) failed" % fail)
get_tree().quit(1 if fail else 0)
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() 退出进程。
if OS.has_environment("MT_PORT_PATH") and OS.get_environment("MT_PORT_PATH") == "legacy":
push_warning("[client] MT_PORT_PATH=legacy 已废弃并移除,40250 原生 port 路径已接管主循环")
_start_port_route()
# 启动 40250 原生 port 路径
func _start_port_route() -> void:
AssetPack.ensure()
if not (ClassDB.class_exists("Metin2PythonHost") and AssetRoot.pack_ready()):
printerr("[client] port 路由缺少 Metin2PythonHost 或 40250 Client/pack(%s)" % AssetRoot.client_path())
get_tree().quit(1)
return
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)