mirror of
https://github.com/GabsPuNs/Project-Zenith-Main.git
synced 2026-07-09 18:38:09 +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;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class RmlManager
|
||||
public:
|
||||
static RmlManager& Get();
|
||||
|
||||
bool Init();
|
||||
bool Init(int width, int height);
|
||||
void Shutdown();
|
||||
|
||||
void Update();
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
RenderInterface_D3D11* GetRenderInterface() const { return m_renderer.get(); }
|
||||
|
||||
void OnResize(int width, int height);
|
||||
void UpdateDpRatio();
|
||||
void UpdateDpRatio(int width, int height);
|
||||
|
||||
void OnLanguageChanged();
|
||||
|
||||
|
||||
@@ -915,6 +915,8 @@ static bool ResizeD3D(int newW, int newH)
|
||||
ui.updateRenderTargets(g_pRenderTargetView, g_pDepthStencilView);
|
||||
ui.updateScreenSize(bbW, bbH);
|
||||
|
||||
RmlManager::Get().OnResize(bbW, bbH);
|
||||
|
||||
// Track actual backbuffer dimensions for the rest of the engine
|
||||
g_iScreenWidth = bbW;
|
||||
g_iScreenHeight = bbH;
|
||||
@@ -969,6 +971,7 @@ postReset:
|
||||
g_iScreenWidth = recW;
|
||||
g_iScreenHeight = recH;
|
||||
ui.updateScreenSize(recW, recH);
|
||||
RmlManager::Get().OnResize(recW, recH);
|
||||
}
|
||||
|
||||
app.DebugPrintf("[RESIZE] FAILED but recovered views at %dx%d\n", g_iScreenWidth, g_iScreenHeight);
|
||||
@@ -1069,8 +1072,11 @@ static Minecraft* InitialiseMinecraftRuntime()
|
||||
RenderManager.Initialise(g_pd3dDevice, g_pSwapChain);
|
||||
|
||||
app.loadStringTable();
|
||||
|
||||
ui.init(g_pd3dDevice, g_pImmediateContext, g_pRenderTargetView, g_pDepthStencilView, g_iScreenWidth, g_iScreenHeight);
|
||||
|
||||
RmlManager::Get().Init(g_iScreenWidth, g_iScreenHeight);
|
||||
|
||||
InputManager.Initialise(1, 3, MINECRAFT_ACTION_MAX, ACTION_MAX_MENU);
|
||||
g_KBMInput.Init();
|
||||
DefineActions();
|
||||
@@ -1504,9 +1510,10 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
|
||||
}
|
||||
#endif
|
||||
ui.tick();
|
||||
RmlManager::Get().Update();
|
||||
ui.render();
|
||||
|
||||
RmlManager::Get().Render();
|
||||
|
||||
g_DiscordPresence.Tick();
|
||||
|
||||
pMinecraft->gameRenderer->ApplyGammaPostProcess();
|
||||
|
||||
@@ -61,10 +61,6 @@ void ConsoleUIController::init(ID3D11Device *dev, ID3D11DeviceContext *ctx, ID3D
|
||||
|
||||
// Shared init
|
||||
postInit();
|
||||
|
||||
// Initialise RmlUi (menus)
|
||||
if (!RmlManager::Get().Init())
|
||||
app.DebugPrintf("ConsoleUIController::init - RmlManager::Init failed\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -88,9 +84,6 @@ void ConsoleUIController::render()
|
||||
|
||||
renderScenes();
|
||||
|
||||
// Render RmlUi menus on top of the Iggy scenes
|
||||
RmlManager::Get().Render();
|
||||
|
||||
/* Finally we're ready to display the frame. We call GDraw to
|
||||
let it know we're done rendering, so it can do any finalization
|
||||
it needs to do. */
|
||||
|
||||
@@ -9,7 +9,7 @@ RmlManager& RmlManager::Get()
|
||||
RmlManager::RmlManager() : m_initialised(false), m_context(nullptr) {}
|
||||
RmlManager::~RmlManager() {}
|
||||
|
||||
bool RmlManager::Init(int viewport_width, int viewport_height)
|
||||
bool RmlManager::Init(int width, int height)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -17,6 +17,6 @@ bool RmlManager::Init(int viewport_width, int viewport_height)
|
||||
void RmlManager::Shutdown() {}
|
||||
void RmlManager::Update() {}
|
||||
void RmlManager::Render() {}
|
||||
void RmlManager::OnResize() {}
|
||||
void RmlManager::UpdateDpRatio() {}
|
||||
void RmlManager::OnResize(int width, int height) {}
|
||||
void RmlManager::UpdateDpRatio(int width, int height) {}
|
||||
void RmlManager::OnLanguageChanged() {}
|
||||
Reference in New Issue
Block a user