- system.py runs app.Loop() on the script fiber; each UIUpdate is one CPythonApplication::Process(). Logo -> Login, popup ESC/click and app.Exit teardown (launcher cleared first, as in 40250 Main) work. - Image commands are base-texture quads with UVs (a .sub shares its parent texture); ImageInstance/ExpandedImageInstance OnRender and SetRenderingRect ported verbatim, so scale/rotation/rendering rect are drawn. - CGraphicBase::GetColor / grp.GenerateColor ported (ThinBoard background). - port.app_loop test, python_host_test app-loop checks, MT_TEST_MODE=python_ui. - TODO: .fnt/CGraphicText font pipeline, ExpandedImage blend modes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
2.0 KiB
C++
48 lines
2.0 KiB
C++
#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 <godot_cpp/classes/object.hpp>
|
|
#include <godot_cpp/variant/string.hpp>
|
|
#include <godot_cpp/variant/array.hpp>
|
|
|
|
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);
|
|
// 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);
|
|
static void ui_update();
|
|
static godot::Array ui_render_commands();
|
|
static void stop();
|
|
|
|
protected:
|
|
static void _bind_methods();
|
|
};
|
|
|
|
} // namespace mtgodot
|