mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-10-30 07:11:05 +00:00
Dpi fixes (#449)
* Potential fix for DPI scaling. * Show window size in pixels while in Fullscreen mode.
This commit is contained in:
parent
c90d1fcb7b
commit
03ef34ffe8
5 changed files with 38 additions and 18 deletions
|
|
@ -2344,7 +2344,7 @@ namespace plume {
|
|||
dstWidth = rect.right - rect.left;
|
||||
dstHeight = rect.bottom - rect.top;
|
||||
# elif defined(SDL_VULKAN_ENABLED)
|
||||
SDL_GetWindowSize(renderWindow, (int *)(&dstWidth), (int *)(&dstHeight));
|
||||
SDL_GetWindowSizeInPixels(renderWindow, (int *)(&dstWidth), (int *)(&dstHeight));
|
||||
# elif defined(__ANDROID__)
|
||||
dstWidth = ANativeWindow_getWidth(renderWindow);
|
||||
dstHeight = ANativeWindow_getHeight(renderWindow);
|
||||
|
|
|
|||
|
|
@ -2415,19 +2415,25 @@ static void DrawImGui()
|
|||
// we can adjust the mouse events before ImGui processes them.
|
||||
uint32_t width = g_swapChain->getWidth();
|
||||
uint32_t height = g_swapChain->getHeight();
|
||||
|
||||
if (width != Video::s_viewportWidth || height != Video::s_viewportHeight)
|
||||
float mousePosScaleX = float(width) / float(GameWindow::s_width);
|
||||
float mousePosScaleY = float(height) / float(GameWindow::s_height);
|
||||
float mousePosOffsetX = (width - Video::s_viewportWidth) / 2.0f;
|
||||
float mousePosOffsetY = (height - Video::s_viewportHeight) / 2.0f;
|
||||
for (int i = 0; i < io.Ctx->InputEventsQueue.Size; i++)
|
||||
{
|
||||
float mousePosOffsetX = (width - Video::s_viewportWidth) / 2.0f;
|
||||
float mousePosOffsetY = (height - Video::s_viewportHeight) / 2.0f;
|
||||
|
||||
for (int i = 0; i < io.Ctx->InputEventsQueue.Size; i++)
|
||||
auto& e = io.Ctx->InputEventsQueue[i];
|
||||
if (e.Type == ImGuiInputEventType_MousePos)
|
||||
{
|
||||
auto& e = io.Ctx->InputEventsQueue[i];
|
||||
if (e.Type == ImGuiInputEventType_MousePos)
|
||||
if (e.MousePos.PosX != -FLT_MAX)
|
||||
{
|
||||
if (e.MousePos.PosX != -FLT_MAX) e.MousePos.PosX -= mousePosOffsetX;
|
||||
if (e.MousePos.PosY != -FLT_MAX) e.MousePos.PosY -= mousePosOffsetY;
|
||||
e.MousePos.PosX *= mousePosScaleX;
|
||||
e.MousePos.PosX -= mousePosOffsetX;
|
||||
}
|
||||
|
||||
if (e.MousePos.PosY != -FLT_MAX)
|
||||
{
|
||||
e.MousePos.PosY *= mousePosScaleY;
|
||||
e.MousePos.PosY -= mousePosOffsetY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -378,6 +378,11 @@ SDL_Rect GameWindow::GetDimensions()
|
|||
return rect;
|
||||
}
|
||||
|
||||
void GameWindow::GetSizeInPixels(int *w, int *h)
|
||||
{
|
||||
SDL_GetWindowSizeInPixels(s_pWindow, w, h);
|
||||
}
|
||||
|
||||
void GameWindow::SetDimensions(int w, int h, int x, int y)
|
||||
{
|
||||
s_width = w;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public:
|
|||
static bool IsMaximised();
|
||||
static EWindowState SetMaximised(bool isEnabled);
|
||||
static SDL_Rect GetDimensions();
|
||||
static void GetSizeInPixels(int *w, int *h);
|
||||
static void SetDimensions(int w, int h, int x = SDL_WINDOWPOS_CENTERED, int y = SDL_WINDOWPOS_CENTERED);
|
||||
static void ResetDimensions();
|
||||
static uint32_t GetWindowFlags();
|
||||
|
|
|
|||
|
|
@ -1121,17 +1121,25 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf
|
|||
{
|
||||
if (config == &Config::WindowSize)
|
||||
{
|
||||
auto displayModes = GameWindow::GetDisplayModes();
|
||||
|
||||
if (config->Value >= 0 && config->Value < displayModes.size())
|
||||
if (Config::Fullscreen)
|
||||
{
|
||||
auto& displayMode = displayModes[config->Value];
|
||||
|
||||
valueText = fmt::format("{}x{}", displayMode.w, displayMode.h);
|
||||
int displayW, displayH;
|
||||
GameWindow::GetSizeInPixels(&displayW, &displayH);
|
||||
valueText = fmt::format("{}x{}", displayW, displayH);
|
||||
}
|
||||
else
|
||||
{
|
||||
valueText = fmt::format("{}x{}", GameWindow::s_width, GameWindow::s_height);
|
||||
auto displayModes = GameWindow::GetDisplayModes();
|
||||
if (config->Value >= 0 && config->Value < displayModes.size())
|
||||
{
|
||||
auto& displayMode = displayModes[config->Value];
|
||||
|
||||
valueText = fmt::format("{}x{}", displayMode.w, displayMode.h);
|
||||
}
|
||||
else
|
||||
{
|
||||
valueText = fmt::format("{}x{}", GameWindow::s_width, GameWindow::s_height);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (config == &Config::Monitor)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue