Implement UnhandledExceptionFilter and revert "set intro scene background to white"

Also use g_iScreenWidth and g_iScreenHeight in RMLManager
This commit is contained in:
GabsPuNs
2026-06-20 15:35:42 -04:00
parent 82d80943b7
commit d3af93969a
11 changed files with 96 additions and 91 deletions

View File

@@ -17,6 +17,9 @@ extern ID3D11Device* g_pd3dDevice;
extern ID3D11DeviceContext* g_pImmediateContext;
extern ID3D11RenderTargetView* g_pRenderTargetView;
extern int g_iScreenWidth;
extern int g_iScreenHeight;
RmlManager& RmlManager::Get()
{
static RmlManager instance;
@@ -26,8 +29,6 @@ RmlManager& RmlManager::Get()
RmlManager::RmlManager()
: m_initialised(false)
, m_context(nullptr)
, m_viewport_width(0)
, m_viewport_height(0)
{
}
@@ -36,7 +37,7 @@ RmlManager::~RmlManager()
Shutdown();
}
bool RmlManager::Init(int viewport_width, int viewport_height)
bool RmlManager::Init()
{
if (m_initialised)
return true;
@@ -65,22 +66,13 @@ bool RmlManager::Init(int viewport_width, int viewport_height)
return false;
}
// GabsPuN: Hardcoded. Is this really needed?
/*
// Load default fonts
Rml::LoadFontFace("C:/Windows/Fonts/segoeui.ttf", false);
Rml::LoadFontFace("C:/Windows/Fonts/segoeuib.ttf", false);
Rml::LoadFontFace("C:/Windows/Fonts/segoeuii.ttf", false);
Rml::LoadFontFace("C:/Windows/Fonts/segoeuiz.ttf", false);
*/
// Minecraft's UI fonts (from tryashtar/minecraft-ttf)
if (!Rml::LoadFontFace(assetPath + "/fonts/Mojangles.ttf", "Minecraft Default", Rml::Style::FontStyle::Normal, Rml::Style::FontWeight::Normal, false))
app.DebugPrintf("[RmlManager] FAILED loading Mojangles.ttf\n");
if (!Rml::LoadFontFace(assetPath + "/fonts/MinecraftTen.ttf", "Minecraft Default", Rml::Style::FontStyle::Normal, Rml::Style::FontWeight::Bold, true))
app.DebugPrintf("[RmlManager] FAILED loading MinecraftTen.ttf\n");
m_context = Rml::CreateContext("main", Rml::Vector2i(viewport_width, viewport_height));
m_context = Rml::CreateContext("main", Rml::Vector2i(g_iScreenWidth, g_iScreenHeight));
if (!m_context)
{
app.DebugPrintf("[RmlManager] Failed to create RmlUi context\n");
@@ -88,17 +80,14 @@ bool RmlManager::Init(int viewport_width, int viewport_height)
return false;
}
app.DebugPrintf("[RmlManager] Context created (%dx%d)\n", viewport_width, viewport_height);
app.DebugPrintf("[RmlManager] Context created (%dx%d)\n", g_iScreenWidth, g_iScreenHeight);
m_viewport_width = viewport_width;
m_viewport_height = viewport_height;
m_renderer->SetViewport(viewport_width, viewport_height);
m_renderer->SetViewport(g_iScreenWidth, g_iScreenHeight);
m_initialised = true;
app.DebugPrintf("[RmlManager] Initialised (%dx%d)\n", viewport_width, viewport_height);
app.DebugPrintf("[RmlManager] Initialised (%dx%d)\n", g_iScreenWidth, g_iScreenHeight);
UpdateDpRatio(m_viewport_width, m_viewport_height);
UpdateDpRatio();
return true;
}
@@ -175,24 +164,22 @@ void RmlManager::OnResize(int width, int height)
{
if (!m_initialised || !m_context)
return;
m_viewport_width = width;
m_viewport_height = height;
m_context->SetDimensions(Rml::Vector2i(width, height));
m_renderer->SetViewport(width, height);
UpdateDpRatio(width, height);
}
void RmlManager::UpdateDpRatio(int viewport_width, int viewport_height)
void RmlManager::UpdateDpRatio()
{
if (!m_context)
return;
float scale_x = static_cast<float>(viewport_width) / 1920;
float scale_y = static_cast<float>(viewport_height) / 1080;
float scale_x = static_cast<float>(g_iScreenWidth) / 1920;
float scale_y = static_cast<float>(g_iScreenHeight) / 1080;
float base_ratio = (scale_x < scale_y) ? scale_x : scale_y;
float auto_dp = base_ratio;
float viewport_cap = 0.88f * static_cast<float>(viewport_height) / 850.0f;
float viewport_cap = 0.88f * static_cast<float>(g_iScreenHeight) / 850.0f;
if (auto_dp > viewport_cap)
auto_dp = viewport_cap;