Port 2V0 UI Python bindings and app module link surface

This commit is contained in:
shen
2026-09-22 19:57:35 -07:00
parent a0ad587f78
commit b221a9eaf5
74 changed files with 18320 additions and 9 deletions
@@ -0,0 +1,13 @@
#include <il/il.h>
#include "../PlatformStub.h"
void ilGenImages(unsigned count, ILuint* images)
{
MT_PLATFORM_STUB();
for (unsigned i = 0; i < count; ++i)
images[i] = 0;
}
void ilBindImage(ILuint) { MT_PLATFORM_STUB(); }
bool ilLoad(unsigned, const char*) { MT_PLATFORM_STUB(); return false; }
int ilGetInteger(unsigned) { MT_PLATFORM_STUB(); return 0; }
void ilDeleteImages(unsigned, const ILuint*) { MT_PLATFORM_STUB(); }
@@ -0,0 +1,9 @@
#include "EterLib/StdAfx.h"
#include "EterLib/Camera.h"
#include "../PlatformStub.h"
CCamera* CCameraManager::GetCurrentCamera()
{
MT_PLATFORM_STUB();
return nullptr;
}
@@ -11,6 +11,21 @@
#include "../PlatformStub.h"
void CPythonGraphic::SetViewport(float, float, float, float) { MT_PLATFORM_STUB(); }
void CPythonGraphic::RestoreViewport() { MT_PLATFORM_STUB(); }
void CPythonGraphic::SetOmniLight() { MT_PLATFORM_STUB(); }
long CPythonGraphic::GenerateColor(float, float, float, float) { MT_PLATFORM_STUB(); return 0; }
void CPythonGraphic::RenderUpButton(float, float, float, float) { MT_PLATFORM_STUB(); }
void CPythonGraphic::RenderDownButton(float, float, float, float) { MT_PLATFORM_STUB(); }
bool CPythonGraphic::SaveScreenShot(const char*) { MT_PLATFORM_STUB(); return false; }
void CPythonGraphic::SetCursorPosition(int, int) { MT_PLATFORM_STUB(); }
DWORD CPythonGraphic::GetAvailableMemory() { MT_PLATFORM_STUB(); return 0; }
void CPythonGraphic::SetGameRenderState() { MT_PLATFORM_STUB(); }
void CPythonGraphic::SetInterfaceRenderState() { MT_PLATFORM_STUB(); }
void CPythonGraphic::PushState() { MT_PLATFORM_STUB(); }
void CPythonGraphic::PopState() { MT_PLATFORM_STUB(); }
void CPythonGraphic::SetGamma(float) { MT_PLATFORM_STUB(); }
void CPythonGraphic::RenderCoolTimeBox(float fxCenter, float fyCenter, float fRadius, float fTime)
{
MT_PLATFORM_STUB();
@@ -3,6 +3,7 @@
#include "ScriptLib/StdAfx.h"
#include "ScriptLib/PythonLauncher.h"
#include "UserInterface/StdAfx.h" // initpack and the rest of the module initializer list
#include "EterPythonLib/StdAfx.h"
#include "PythonBoot.h"
#include "PythonHost.h"
#include "../EterBase/LogBox.h"
@@ -13,6 +14,7 @@ namespace
{
// 40250 has this on Main()'s stack. CPythonLauncher is a CSingleton, so there is still only ever one.
std::unique_ptr<CPythonLauncher> g_launcher;
std::unique_ptr<UI::CWindowManager> g_window_manager;
bool fail(std::string* error, const std::string& text)
{
@@ -55,6 +57,7 @@ bool Start(const char* stdlib_path, std::string* error)
Stop();
return fail(error, "InstallStdLib(" + stdlib + "): " + stdlib_error);
}
g_window_manager = std::make_unique<UI::CWindowManager>();
return true;
}
@@ -66,10 +69,14 @@ bool RunMainScript(const char* lpCmdLine, std::string* error)
CPythonLauncher& pyLauncher = *g_launcher;
// The module initializers, in 40250's order. Everything after initpack (initdbg, initime, initgrp,
// initgrpImage, initgrpText, initwndMgr, initudp, initapp, ... initServerStateChecker) is a 2V slice:
// system.py stops at the first import of one of them, today `app`.
// The module initializers follow 40250's order; missing modules arrive in later 2V steps.
initpack();
initdbg();
initgrp();
initgrpImage();
initgrpText();
initwndMgr();
initapp();
ClearLogBoxMessage();
@@ -122,6 +129,10 @@ bool RunMainScript(const char* lpCmdLine, std::string* error)
TraceError("RunMain Error");
return fail(error, "RunMain Error: " + LastLogBoxMessage());
}
// system.py catches failures in prototype.py and calls dbg.LogBox. Its outer
// RunFile then succeeds, so surface that recorded failure to the Godot host.
if (!LastLogBoxMessage().empty())
return fail(error, "RunMain Error: " + LastLogBoxMessage());
}
NANOEND
@@ -143,6 +154,7 @@ void Stop()
{
if (!g_launcher)
return;
g_window_manager.reset();
g_launcher->Clear(); // Main() calls Clear() explicitly before the launcher leaves scope
g_launcher.reset();
}
@@ -0,0 +1,88 @@
#include "UserInterface/StdAfx.h"
#include "UserInterface/PythonApplication.h"
#include "UserInterface/MarkManager.h"
#include "GameLib/GameUtil.h"
#include "EterLib/Camera.h"
#include "../PlatformStub.h"
// 2V0-d link surface. The application event loop and UI rendering are implemented in 2V0-f.
CPythonApplication* CPythonApplication::ms_pInstance = nullptr;
void CPythonApplication::ShowWebPage(const char*, const RECT&) { MT_PLATFORM_STUB(); }
void CPythonApplication::MoveWebPage(const RECT&) { MT_PLATFORM_STUB(); }
void CPythonApplication::HideWebPage() { MT_PLATFORM_STUB(); }
bool CPythonApplication::IsWebPageMode() { MT_PLATFORM_STUB(); return false; }
void CPythonApplication::GetInfo(UINT, std::string* out) { MT_PLATFORM_STUB(); if (out) out->clear(); }
void CPythonApplication::Loop() { MT_PLATFORM_STUB(); }
void CPythonApplication::Exit() { MT_PLATFORM_STUB(); }
void CPythonApplication::Abort() { MT_PLATFORM_STUB(); }
void CPythonApplication::SetMinFog(float) { MT_PLATFORM_STUB(); }
void CPythonApplication::SetFrameSkip(bool) { MT_PLATFORM_STUB(); }
bool CPythonApplication::Create(PyObject*, const char*, int, int, int) { MT_PLATFORM_STUB(); return false; }
void CPythonApplication::UpdateGame() { MT_PLATFORM_STUB(); }
void CPythonApplication::RenderGame() { MT_PLATFORM_STUB(); }
bool CPythonApplication::Process() { MT_PLATFORM_STUB(); return false; }
BOOL CPythonApplication::SetCursorNum(int) { MT_PLATFORM_STUB(); return FALSE; }
void CPythonApplication::SetCursorVisible(BOOL, bool) { MT_PLATFORM_STUB(); }
BOOL CPythonApplication::GetCursorVisible() { MT_PLATFORM_STUB(); return FALSE; }
bool CPythonApplication::GetLiarCursorOn() { MT_PLATFORM_STUB(); return false; }
void CPythonApplication::SetCursorMode(int) { MT_PLATFORM_STUB(); }
void CPythonApplication::SetMouseHandler(PyObject*) { MT_PLATFORM_STUB(); }
void CPythonApplication::SetGlobalCenterPosition(LONG, LONG) { MT_PLATFORM_STUB(); }
void CPythonApplication::SetCamera(float, float, float, float) { MT_PLATFORM_STUB(); }
void CPythonApplication::GetCamera(float* distance, float* pitch, float* rotation, float* height) {
MT_PLATFORM_STUB();
if (distance) *distance = 0;
if (pitch) *pitch = 0;
if (rotation) *rotation = 0;
if (height) *height = 0;
}
void CPythonApplication::RotateCamera(int) { MT_PLATFORM_STUB(); }
void CPythonApplication::PitchCamera(int) { MT_PLATFORM_STUB(); }
void CPythonApplication::ZoomCamera(int) { MT_PLATFORM_STUB(); }
void CPythonApplication::MovieRotateCamera(int) { MT_PLATFORM_STUB(); }
void CPythonApplication::MoviePitchCamera(int) { MT_PLATFORM_STUB(); }
void CPythonApplication::MovieZoomCamera(int) { MT_PLATFORM_STUB(); }
void CPythonApplication::MovieResetCamera() { MT_PLATFORM_STUB(); }
float CPythonApplication::GetRotation() { MT_PLATFORM_STUB(); return 0; }
float CPythonApplication::GetPitch() { MT_PLATFORM_STUB(); return 0; }
void CPythonApplication::SetFPS(int) { MT_PLATFORM_STUB(); }
time_t CPythonApplication::GetServerTime() { MT_PLATFORM_STUB(); return 0; }
time_t CPythonApplication::GetServerTimeStamp() { MT_PLATFORM_STUB(); return 0; }
void CPythonApplication::SetConnectData(const char*, int) { MT_PLATFORM_STUB(); }
void CPythonApplication::GetConnectData(std::string& ip, int& port) { MT_PLATFORM_STUB(); ip.clear(); port = 0; }
void CPythonApplication::EnableSpecialCameraMode() { MT_PLATFORM_STUB(); }
void CPythonApplication::SetCameraSpeed(int) { MT_PLATFORM_STUB(); }
void CPythonApplication::SaveCameraSetting(const char*) { MT_PLATFORM_STUB(); }
bool CPythonApplication::LoadCameraSetting(const char*) { MT_PLATFORM_STUB(); return false; }
void CPythonApplication::SetForceSightRange(int) { MT_PLATFORM_STUB(); }
void CCamera::SetResistance(float) { MT_PLATFORM_STUB(); }
void CCamera::SetCameraMaxDistance(float) { MT_PLATFORM_STUB(); }
void CGuildMarkManager::SetMarkPathPrefix(const char*) { MT_PLATFORM_STUB(); }
void CMovieMan::PlayLogo(const char*) { MT_PLATFORM_STUB(); }
float GetDegreeDifference(float, float) { MT_PLATFORM_STUB(); return 0; }
int GetRotatingDirection(float, float) { MT_PLATFORM_STUB(); return 0; }
BOOL HAIR_COLOR_ENABLE = FALSE;
BOOL PERF_CHECKER_RENDER_GAME = FALSE;
BOOL RIDE_HORSE_ENABLE = FALSE;
BOOL SKILL_EFFECT_UPGRADE_ENABLE = FALSE;
BOOL USE_ARMOR_SPECULAR = FALSE;
BOOL USE_WEAPON_SPECULAR = FALSE;
D3DXCOLOR g_fSpecularColor;
double g_specularSpd = 0;
int g_iAccumulationTime = 0;
bool LoadLocaleData(const char*) { MT_PLATFORM_STUB(); return false; }
void SetGuildSymbolPath(const char*) { MT_PLATFORM_STUB(); }
void DefaultFont_SetName(const char*) { MT_PLATFORM_STUB(); }
void TextTail_SetLivingTime(long) { MT_PLATFORM_STUB(); }
const char* LocaleService_GetName() { MT_PLATFORM_STUB(); return ""; }
bool LocaleService_IsCHEONMA() { MT_PLATFORM_STUB(); return false; }
void LocaleService_SetCHEONMA(bool) { MT_PLATFORM_STUB(); }
unsigned LocaleService_GetCodePage() { MT_PLATFORM_STUB(); return 0; }
const char* LocaleService_GetLocaleName() { MT_PLATFORM_STUB(); return ""; }
const char* LocaleService_GetLocalePath() { MT_PLATFORM_STUB(); return ""; }
void LocaleService_ForceSetLocale(const char*, const char*) { MT_PLATFORM_STUB(); }