mirror of
https://github.com/GabsPuNs/Project-Zenith-Main.git
synced 2026-07-10 03:28:05 +00:00
Revert some changes.
This commit is contained in:
@@ -17,9 +17,6 @@ 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;
|
||||
@@ -37,7 +34,7 @@ RmlManager::~RmlManager()
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
bool RmlManager::Init()
|
||||
bool RmlManager::Init(int width, int height)
|
||||
{
|
||||
if (m_initialised)
|
||||
return true;
|
||||
@@ -72,7 +69,7 @@ bool RmlManager::Init()
|
||||
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(g_iScreenWidth, g_iScreenHeight));
|
||||
m_context = Rml::CreateContext("main", Rml::Vector2i(width, height));
|
||||
if (!m_context)
|
||||
{
|
||||
app.DebugPrintf("[RmlManager] Failed to create RmlUi context\n");
|
||||
@@ -80,14 +77,14 @@ bool RmlManager::Init()
|
||||
return false;
|
||||
}
|
||||
|
||||
app.DebugPrintf("[RmlManager] Context created (%dx%d)\n", g_iScreenWidth, g_iScreenHeight);
|
||||
app.DebugPrintf("[RmlManager] Context created (%dx%d)\n", width, height);
|
||||
|
||||
m_renderer->SetViewport(g_iScreenWidth, g_iScreenHeight);
|
||||
m_renderer->SetViewport(width, height);
|
||||
m_initialised = true;
|
||||
|
||||
app.DebugPrintf("[RmlManager] Initialised (%dx%d)\n", g_iScreenWidth, g_iScreenHeight);
|
||||
app.DebugPrintf("[RmlManager] Initialised (%dx%d)\n", width, height);
|
||||
|
||||
UpdateDpRatio();
|
||||
UpdateDpRatio(width, height);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -167,19 +164,20 @@ void RmlManager::OnResize(int width, int height)
|
||||
|
||||
m_context->SetDimensions(Rml::Vector2i(width, height));
|
||||
m_renderer->SetViewport(width, height);
|
||||
UpdateDpRatio(width, height);
|
||||
}
|
||||
|
||||
void RmlManager::UpdateDpRatio()
|
||||
void RmlManager::UpdateDpRatio(int width, int height)
|
||||
{
|
||||
if (!m_context)
|
||||
return;
|
||||
|
||||
float scale_x = static_cast<float>(g_iScreenWidth) / 1920;
|
||||
float scale_y = static_cast<float>(g_iScreenHeight) / 1080;
|
||||
float scale_x = static_cast<float>(width) / 1920;
|
||||
float scale_y = static_cast<float>(height) / 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>(g_iScreenHeight) / 850.0f;
|
||||
float viewport_cap = 0.88f * static_cast<float>(height) / 850.0f;
|
||||
if (auto_dp > viewport_cap)
|
||||
auto_dp = viewport_cap;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user