Files
metin2-client/extension/src/platform/EterLib/GrpImageInstance.cpp
T
shenleiandClaude Opus 5.5 141206cb69 2V0-f: run the real system.py app loop in Godot
- 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>
2026-09-23 13:38:13 +09:00

168 lines
4.3 KiB
C++

// Platform skeleton for EterLib/GrpImageInstance.h (40250 EterLib/GrpImageInstance.cpp), generated by platform_stub.py.
// Every MT_PLATFORM_STUB() body is unimplemented: replace it with the platform implementation.
#include "EterLib/StdAfx.h"
#include "EterLib/GrpImageInstance.h"
#include "../PlatformStub.h"
#include "UIRenderCommands.h"
#include "EterBase/CRC32.h"
auto CGraphicImageInstance::Type() -> DWORD
{
static DWORD type = GetCRC32("CGraphicImageInstance", sizeof("CGraphicImageInstance") - 1);
return type;
}
auto CGraphicImageInstance::IsType(DWORD type) -> BOOL
{
return OnIsType(type);
}
CGraphicImageInstance::CGraphicImageInstance()
{
m_DiffuseColor = D3DXCOLOR(1, 1, 1, 1);
m_v2Position = D3DXVECTOR2(0, 0);
}
CGraphicImageInstance::~CGraphicImageInstance()
{
Destroy();
}
// 40250 Destroy(): drop the image reference, then Initialize() (white, at the origin).
auto CGraphicImageInstance::Destroy() -> void
{
m_roImage.Clear();
m_DiffuseColor = D3DXCOLOR(1, 1, 1, 1);
m_v2Position = D3DXVECTOR2(0, 0);
}
auto CGraphicImageInstance::Render() -> void
{
if (!IsEmpty()) OnRender();
}
auto CGraphicImageInstance::SetDiffuseColor(float r, float g, float b, float a) -> void
{
m_DiffuseColor = D3DXCOLOR(r, g, b, a);
}
auto CGraphicImageInstance::SetPosition(float x, float y) -> void
{
m_v2Position = D3DXVECTOR2(x, y);
}
auto CGraphicImageInstance::SetImagePointer(CGraphicImage *image) -> void
{
m_roImage.SetPointer(image);
OnSetImagePointer();
}
auto CGraphicImageInstance::ReloadImagePointer(CGraphicImage *) -> void
{
MT_PLATFORM_STUB();
}
auto CGraphicImageInstance::IsEmpty() const -> bool
{
return m_roImage.IsNull() || m_roImage->IsEmpty();
}
auto CGraphicImageInstance::GetWidth() -> int
{
return IsEmpty() ? 0 : m_roImage->GetWidth();
}
auto CGraphicImageInstance::GetHeight() -> int
{
return IsEmpty() ? 0 : m_roImage->GetHeight();
}
auto CGraphicImageInstance::GetTexturePointer() -> CGraphicTexture *
{
CGraphicImage* pkImage = m_roImage.GetPointer();
return pkImage ? pkImage->GetTexturePointer() : NULL;
}
auto CGraphicImageInstance::GetTextureReference() const -> const CGraphicTexture &
{
return m_roImage->GetTextureReference();
}
auto CGraphicImageInstance::GetGraphicImagePointer() -> CGraphicImage *
{
return m_roImage.GetPointer();
}
auto CGraphicImageInstance::operator==(const CGraphicImageInstance &) const -> bool
{
MT_PLATFORM_STUB();
return mt_platform_stub_return<bool>();
}
auto CGraphicImageInstance::Initialize() -> void
{
MT_PLATFORM_STUB();
}
// 40250 GrpImageInstance.cpp:44-96: the image's rect inside its texture (a .sub shares its parent's)
// becomes the texture coordinates of one quad.
auto CGraphicImageInstance::OnRender() -> void
{
CGraphicImage * pImage = m_roImage.GetPointer();
CGraphicTexture * pTexture = pImage->GetTexturePointer();
if (pTexture->GetWidth() <= 0 || pTexture->GetHeight() <= 0)
return;
float fimgWidth = pImage->GetWidth();
float fimgHeight = pImage->GetHeight();
const RECT& c_rRect = pImage->GetRectReference();
float texReverseWidth = 1.0f / float(pTexture->GetWidth());
float texReverseHeight = 1.0f / float(pTexture->GetHeight());
float su = c_rRect.left * texReverseWidth;
float sv = c_rRect.top * texReverseHeight;
float eu = (c_rRect.left + (c_rRect.right-c_rRect.left)) * texReverseWidth;
float ev = (c_rRect.top + (c_rRect.bottom-c_rRect.top)) * texReverseHeight;
const float x[4] = {m_v2Position.x-0.5f, m_v2Position.x + fimgWidth-0.5f,
m_v2Position.x-0.5f, m_v2Position.x + fimgWidth-0.5f};
const float y[4] = {m_v2Position.y-0.5f, m_v2Position.y-0.5f,
m_v2Position.y + fimgHeight-0.5f, m_v2Position.y + fimgHeight-0.5f};
UIRenderAddImage(pTexture, x, y, su, sv, eu, ev, UIRenderColor(m_DiffuseColor));
}
auto CGraphicImageInstance::OnSetImagePointer() -> void
{
MT_PLATFORM_STUB();
}
auto CGraphicImageInstance::OnIsType(DWORD type) -> BOOL
{
return type == Type();
}
auto CGraphicImageInstance::CreateSystem(UINT) -> void
{
MT_PLATFORM_STUB();
}
auto CGraphicImageInstance::DestroySystem() -> void
{
MT_PLATFORM_STUB();
}
auto CGraphicImageInstance::New() -> CGraphicImageInstance *
{
return new CGraphicImageInstance();
}
auto CGraphicImageInstance::Delete(CGraphicImageInstance *instance) -> void
{
if (!instance) return;
instance->Destroy();
delete instance;
}
decltype(CGraphicImageInstance::ms_kPool) CGraphicImageInstance::ms_kPool{};