Files
GabsPuNs-Project_Zenith_Main/Minecraft.Client/Windows64/RmlUi_SystemInterface_Win64.cpp
GabsPuNs 3ee643962d Fix compilation for MSVC, also moved some folders.
1. Added again the libraries for MSVC. If you need MinGW libraries version tell me
2. Removed "#include stdafx.h". Is not needed.
3. Renamed "RmlUIAssets" to "UI" and "Menus" to "Iggy"
2026-06-10 21:22:41 -04:00

114 lines
3.0 KiB
C++

#include "RmlUi_SystemInterface_Win64.h"
SystemInterface_Win64::SystemInterface_Win64()
{
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
m_frequency = static_cast<double>(freq.QuadPart);
QueryPerformanceCounter(&m_startup);
}
SystemInterface_Win64::~SystemInterface_Win64()
{
}
double SystemInterface_Win64::GetElapsedTime()
{
LARGE_INTEGER now;
QueryPerformanceCounter(&now);
return static_cast<double>(now.QuadPart - m_startup.QuadPart) / m_frequency;
}
int SystemInterface_Win64::TranslateString(Rml::String& translated, const Rml::String& input)
{
translated = input;
return 0;
}
void SystemInterface_Win64::JoinPath(Rml::String& translated_path, const Rml::String& document_path, const Rml::String& path)
{
Rml::SystemInterface::JoinPath(translated_path, document_path, path);
}
bool SystemInterface_Win64::LogMessage(Rml::Log::Type type, const Rml::String& message)
{
app.DebugPrintf("[RmlUi] %s\n", message.c_str());
return true;
}
void SystemInterface_Win64::SetMouseCursor(const Rml::String& cursor_name)
{
static HCURSOR cursor_default = LoadCursor(nullptr, IDC_ARROW);
static HCURSOR cursor_move = LoadCursor(nullptr, IDC_SIZEALL);
static HCURSOR cursor_pointer = LoadCursor(nullptr, IDC_HAND);
static HCURSOR cursor_resize = LoadCursor(nullptr, IDC_SIZEWE);
static HCURSOR cursor_cross = LoadCursor(nullptr, IDC_CROSS);
static HCURSOR cursor_text = LoadCursor(nullptr, IDC_IBEAM);
static HCURSOR cursor_unavailable = LoadCursor(nullptr, IDC_NO);
extern HWND g_hWnd;
HCURSOR cursor_handle = nullptr;
if (cursor_name.empty() || cursor_name == "arrow")
cursor_handle = cursor_default;
else if (cursor_name == "pointer")
cursor_handle = cursor_pointer;
else if (cursor_name == "move")
cursor_handle = cursor_move;
else if (cursor_name == "resize")
cursor_handle = cursor_resize;
else if (cursor_name == "cross")
cursor_handle = cursor_cross;
else if (cursor_name == "text")
cursor_handle = cursor_text;
else if (cursor_name == "unavailable" || cursor_name == "not-allowed")
cursor_handle = cursor_unavailable;
if (cursor_handle && g_hWnd)
{
SetCursor(cursor_handle);
SetClassLongPtrA(g_hWnd, GCLP_HCURSOR, (LONG_PTR)cursor_handle);
}
}
void SystemInterface_Win64::SetClipboardText(const Rml::String& text)
{
if (!OpenClipboard(nullptr))
return;
EmptyClipboard();
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, text.size() + 1);
if (hGlobal)
{
memcpy(GlobalLock(hGlobal), text.c_str(), text.size() + 1);
GlobalUnlock(hGlobal);
SetClipboardData(CF_TEXT, hGlobal);
}
CloseClipboard();
}
void SystemInterface_Win64::GetClipboardText(Rml::String& text)
{
text.clear();
if (!OpenClipboard(nullptr))
return;
HANDLE hData = GetClipboardData(CF_TEXT);
if (hData)
{
char* pszText = static_cast<char*>(GlobalLock(hData));
if (pszText)
{
text = pszText;
GlobalUnlock(hData);
}
}
CloseClipboard();
}
void SystemInterface_Win64::ActivateKeyboard(Rml::Vector2f /*caret_position*/, float /*line_height*/)
{
}
void SystemInterface_Win64::DeactivateKeyboard()
{
}