Skip to content

Commit

Permalink
fix: More scaling stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
Force67 committed Feb 12, 2022
1 parent 27a5542 commit d3d6053
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
9 changes: 3 additions & 6 deletions Code/client/Services/Debug/TestService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,12 @@
extern thread_local bool g_overrideFormId;

constexpr char kBuildTag[] = "Build: " BUILD_COMMIT " " BUILD_BRANCH " EVO\nBuilt: " __TIMESTAMP__;

// TODO: this doesnt account for the stupid title bar....
static void DrawBuildTag()
{
auto* pWindow = BSGraphics::GetMainWindow();
const ImVec2 coord{static_cast<float>(pWindow->iWindowX + 50),
static_cast<float>(pWindow->iWindowY + (pWindow->uiWindowHeight - 100))};

ImGui::GetBackgroundDrawList()->AddText(ImGui::GetFont(), 35.f, coord, ImColor::ImColor(255.f, 0.f, 0.f),
const ImVec2 coord{50.f, static_cast<float>((pWindow->uiWindowHeight + 25) - 100)};
ImGui::GetBackgroundDrawList()->AddText(ImGui::GetFont(), ImGui::GetFontSize(), coord,
ImColor::ImColor(255.f, 0.f, 0.f),
kBuildTag);
}

Expand Down
3 changes: 2 additions & 1 deletion Code/components/imgui/ImGuiClipboard_Win32.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (C) 2022 TiltedPhoques SRL.
// For licensing information see LICENSE at the root of this distribution.
// Taken from https://github.com/xposure/ImGuiSharp/blob/58860d38a9ec066f492c983c9c63393d6e00a442/ImGuiSharp.Shared/ImGui.h/Helpers.cpp
// Taken from
// https://github.com/xposure/ImGuiSharp/blob/58860d38a9ec066f492c983c9c63393d6e00a442/ImGuiSharp.Shared/ImGui.h/Helpers.cpp

#include "imgui.h"
#include <Windows.h>
Expand Down
22 changes: 7 additions & 15 deletions Code/components/imgui/ImGuiDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// For licensing information see LICENSE at the root of this distribution.

#include "imgui.h"
#include <imgui/ImGuiDriver.h>
#include <imgui/imgui_impl_win32.h>
#include <imgui/ImGuiClipboard_Win32.h>
#include <imgui/ImGuiDriver.h>
#include <imgui/ImguiFont.inl>
#include <imgui/imgui_impl_win32.h>

namespace ImGuiImpl
{
Expand Down Expand Up @@ -79,7 +79,7 @@ void SetTiltedImStyle()
style.FrameBorderSize = 0.0f;
style.WindowBorderSize = 1.0f;
}
}
} // namespace

ImGuiDriver::ImGuiDriver()
{
Expand Down Expand Up @@ -118,21 +118,13 @@ ImGuiDriver::~ImGuiDriver()
void ImGuiDriver::Initialize(void* apHandle)
{
float scaleFactor = ImGui_ImplWin32_GetDpiScaleForHwnd(apHandle);

// https://docs.microsoft.com/en-us/windows/win32/learnwin32/dpi-and-device-independent-pixels
// 45.f / 1.5 = 30
// 45.f / 1.0 = 40

// 1440P = 2560 x 1440
// 1080P = 1920 x 1080
// 3840P = 3480 x 2160
// https://github.com/ocornut/imgui/blob/master/docs/FAQ.md#q-how-should-i-handle-dpi-in-my-application

// 3260 = 3x
// 1920 =
// 1920 =
// https://github.com/ocornut/imgui/blob/master/docs/FAQ.md#q-how-should-i-handle-dpi-in-my-application
auto& io = ImGui::GetIO();
io.Fonts->AddFontFromMemoryCompressedBase85TTF(Roboto_compressed_data_base85,
20.f * scaleFactor); //->Scale = scaleFactor;

ImGui::GetStyle().ScaleAllSizes(scaleFactor);
}
}
} // namespace ImGuiImpl
1 change: 1 addition & 0 deletions Code/components/imgui/ImGuiDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ImGuiDriver
~ImGuiDriver();

void Initialize(void* apNativeHandle);

private:
// No user data yet. TBD later
};
Expand Down

0 comments on commit d3d6053

Please sign in to comment.