#pragma once // Metin2PythonHost — the 40250 script layer inside the Godot process (docs/PORT-PLAN.md 批次 2P step 4). // // Metin2Pack.initialize(AssetRoot.client_path()) # the packs system.py is read from // if Metin2PythonHost.start() == "": // var err := Metin2PythonHost.run_main_script("") // // Both calls answer with "" on success and with the reason otherwise, so GDScript never has to guess // from a bool. 2V0-e reaches prototype.RunApp(); until 2V0-f implements the application adapter, // app.Create reports CREATE_DEVICE and the original script displays its error popup. // // This is the only unit that knows both godot-cpp and the port tree: the sequence itself lives in // platform/ScriptLib/PythonBoot.h, which stays godot-free. #include #include #include #include #include namespace mtgodot { class Metin2PythonHost : public godot::Object { GDCLASS(Metin2PythonHost, godot::Object) public: // Stages the standard library (Metin2Python::stdlib_path) when `stdlib_path` is empty, then starts // the interpreter. "" on success, including when it was already running. static godot::String start(const godot::String &stdlib_path); static bool is_running(); // __DEBUG__, __COMMAND_LINE__ and system.py out of the packs. "" when system.py ran to the end. static godot::String run_main_script(const godot::String &command_line); // One line of Python in the same __main__ dictionary. "" when it ran. static godot::String run_line(const godot::String &source); static godot::String evaluate(const godot::String &expression); // True while system.py is inside app.Loop(); ui_update() then runs one CPythonApplication::Process(). static bool is_app_looping(); static void set_ui_size(int width, int height); static void ui_mouse_move(int x, int y); static void ui_mouse_button(int button, bool pressed, int x, int y); static void ui_key(int key, bool pressed); // WM_CHAR (Unicode code point) and WM_KEYDOWN (Win32 VK code) for the 40250 IME. static void ui_char(int codepoint); static void ui_ime_key(int vkey); static void ui_update(); static godot::Array ui_render_commands(); // The pixels of a "mem:@" image command (the CGraphicFontTexture glyph pages) as an // RGBA8 Image; null when the texture is gone or its revision is still `known_revision`. static godot::Ref memory_texture(const godot::String &name, int64_t known_revision); // The 3D draw calls of the last ui_update() (RenderCommands3D.h), one Dictionary each: "world", // "view", "proj" (PackedFloat32Array, D3D row-vector layout), vertex arrays, "indices", "texture0" // and the blend/depth/cull/lighting state. static godot::Array render3d_draws(); static godot::String current_map_name(); static void stop(); protected: static void _bind_methods(); }; } // namespace mtgodot