Port 2V0-f window input and UI render command bridge
This commit is contained in:
@@ -4,22 +4,25 @@
|
||||
#include "EterLib/GrpImageInstance.h"
|
||||
|
||||
#include "../PlatformStub.h"
|
||||
#include "UIRenderCommands.h"
|
||||
#include "EterBase/CRC32.h"
|
||||
#include <algorithm>
|
||||
|
||||
auto CGraphicImageInstance::Type() -> DWORD
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<DWORD>();
|
||||
static DWORD type = GetCRC32("CGraphicImageInstance", sizeof("CGraphicImageInstance") - 1);
|
||||
return type;
|
||||
}
|
||||
|
||||
auto CGraphicImageInstance::IsType(DWORD) -> BOOL
|
||||
auto CGraphicImageInstance::IsType(DWORD type) -> BOOL
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<BOOL>();
|
||||
return OnIsType(type);
|
||||
}
|
||||
|
||||
CGraphicImageInstance::CGraphicImageInstance()
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
m_DiffuseColor = D3DXCOLOR(1, 1, 1, 1);
|
||||
m_v2Position = D3DXVECTOR2(0, 0);
|
||||
}
|
||||
|
||||
CGraphicImageInstance::~CGraphicImageInstance()
|
||||
@@ -29,27 +32,28 @@ CGraphicImageInstance::~CGraphicImageInstance()
|
||||
|
||||
auto CGraphicImageInstance::Destroy() -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
m_roImage.Clear();
|
||||
}
|
||||
|
||||
auto CGraphicImageInstance::Render() -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
if (!IsEmpty()) OnRender();
|
||||
}
|
||||
|
||||
auto CGraphicImageInstance::SetDiffuseColor(float, float, float, float) -> void
|
||||
auto CGraphicImageInstance::SetDiffuseColor(float r, float g, float b, float a) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
m_DiffuseColor = D3DXCOLOR(r, g, b, a);
|
||||
}
|
||||
|
||||
auto CGraphicImageInstance::SetPosition(float, float) -> void
|
||||
auto CGraphicImageInstance::SetPosition(float x, float y) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
m_v2Position = D3DXVECTOR2(x, y);
|
||||
}
|
||||
|
||||
auto CGraphicImageInstance::SetImagePointer(CGraphicImage *) -> void
|
||||
auto CGraphicImageInstance::SetImagePointer(CGraphicImage *image) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
m_roImage.SetPointer(image);
|
||||
OnSetImagePointer();
|
||||
}
|
||||
|
||||
auto CGraphicImageInstance::ReloadImagePointer(CGraphicImage *) -> void
|
||||
@@ -59,20 +63,17 @@ auto CGraphicImageInstance::ReloadImagePointer(CGraphicImage *) -> void
|
||||
|
||||
auto CGraphicImageInstance::IsEmpty() const -> bool
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<bool>();
|
||||
return m_roImage.IsNull() || m_roImage->IsEmpty();
|
||||
}
|
||||
|
||||
auto CGraphicImageInstance::GetWidth() -> int
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<int>();
|
||||
return IsEmpty() ? 0 : m_roImage->GetWidth();
|
||||
}
|
||||
|
||||
auto CGraphicImageInstance::GetHeight() -> int
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<int>();
|
||||
return IsEmpty() ? 0 : m_roImage->GetHeight();
|
||||
}
|
||||
|
||||
auto CGraphicImageInstance::GetTexturePointer() -> CGraphicTexture *
|
||||
@@ -89,8 +90,7 @@ auto CGraphicImageInstance::GetTextureReference() const -> const CGraphicTexture
|
||||
|
||||
auto CGraphicImageInstance::GetGraphicImagePointer() -> CGraphicImage *
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<CGraphicImage *>();
|
||||
return m_roImage.GetPointer();
|
||||
}
|
||||
|
||||
auto CGraphicImageInstance::operator==(const CGraphicImageInstance &) const -> bool
|
||||
@@ -106,7 +106,18 @@ auto CGraphicImageInstance::Initialize() -> void
|
||||
|
||||
auto CGraphicImageInstance::OnRender() -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
CGraphicImage* image = m_roImage.GetPointer();
|
||||
if (!image) return;
|
||||
auto channel = [](float value) -> std::uint32_t {
|
||||
return static_cast<std::uint32_t>(std::clamp(value, 0.0f, 1.0f) * 255.0f + 0.5f);
|
||||
};
|
||||
const std::uint32_t color = (channel(m_DiffuseColor.a) << 24) |
|
||||
(channel(m_DiffuseColor.r) << 16) | (channel(m_DiffuseColor.g) << 8) |
|
||||
channel(m_DiffuseColor.b);
|
||||
UIRenderCommand command{UIRenderCommand::Image, m_v2Position.x, m_v2Position.y,
|
||||
m_v2Position.x + image->GetWidth(), m_v2Position.y + image->GetHeight(), color};
|
||||
command.text = image->GetFileName();
|
||||
UIRenderAdd(std::move(command));
|
||||
}
|
||||
|
||||
auto CGraphicImageInstance::OnSetImagePointer() -> void
|
||||
@@ -114,10 +125,9 @@ auto CGraphicImageInstance::OnSetImagePointer() -> void
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CGraphicImageInstance::OnIsType(DWORD) -> BOOL
|
||||
auto CGraphicImageInstance::OnIsType(DWORD type) -> BOOL
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<BOOL>();
|
||||
return type == Type();
|
||||
}
|
||||
|
||||
auto CGraphicImageInstance::CreateSystem(UINT) -> void
|
||||
@@ -132,13 +142,14 @@ auto CGraphicImageInstance::DestroySystem() -> void
|
||||
|
||||
auto CGraphicImageInstance::New() -> CGraphicImageInstance *
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<CGraphicImageInstance *>();
|
||||
return new CGraphicImageInstance();
|
||||
}
|
||||
|
||||
auto CGraphicImageInstance::Delete(CGraphicImageInstance *) -> void
|
||||
auto CGraphicImageInstance::Delete(CGraphicImageInstance *instance) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
if (!instance) return;
|
||||
instance->Destroy();
|
||||
delete instance;
|
||||
}
|
||||
|
||||
decltype(CGraphicImageInstance::ms_kPool) CGraphicImageInstance::ms_kPool{};
|
||||
|
||||
Reference in New Issue
Block a user