Files
mtgodot-poc/project/client_main.gd
T
shenandshen 3981cbe5e6 port: purge obsolete GDScript UI, legacy flows, and deprecated controllers
- Purged 66 obsolete GDScript UI components and mobile prototype UI from project/ui/ (retaining ui_assets.gd)
- Purged deprecated GDScript game scene, flow state machines, and local gameplay controllers (app_flow, game_scene, player_controller, net_world, etc.)
- Purged deprecated local system simulation scripts (consumable_system, chest_system, equip_rules, etc.) and project/fx/
- Purged legacy GDScript unit tests targeting obsolete classes
- Unified viewport back buffer sizing in CGraphicBase/CGraphicDevice/PythonBoot
- Cleaned up client_main.gd and python_host_check.gd for pure native port architecture
- Verified all port tests passing: port_map.py check (0 errors), port_gate.sh macos PASS (19/19 suites), python_game_render_test PASS
2026-09-23 22:48:41 -07:00

52 lines
2.4 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
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=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
# 原生 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)