fix: Splash screen texture scaling
This commit is contained in:
parent
f4403ff480
commit
6e6c5bbc67
@ -31,6 +31,8 @@
|
|||||||
using namespace std::literals::chrono_literals;
|
using namespace std::literals::chrono_literals;
|
||||||
|
|
||||||
namespace hex::init {
|
namespace hex::init {
|
||||||
|
|
||||||
|
constexpr static auto WindowSize = ImVec2(640, 400);
|
||||||
|
|
||||||
struct GlfwError {
|
struct GlfwError {
|
||||||
int errorCode = 0;
|
int errorCode = 0;
|
||||||
@ -258,7 +260,7 @@ namespace hex::init {
|
|||||||
|
|
||||||
|
|
||||||
FrameResult WindowSplash::fullFrame() {
|
FrameResult WindowSplash::fullFrame() {
|
||||||
glfwSetWindowSize(m_window, 640, 400);
|
glfwSetWindowSize(m_window, WindowSize.x, WindowSize.y);
|
||||||
centerWindow(m_window);
|
centerWindow(m_window);
|
||||||
|
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
@ -273,7 +275,7 @@ namespace hex::init {
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Draw the splash screen background
|
// Draw the splash screen background
|
||||||
drawList->AddImage(this->m_splashBackgroundTexture, ImVec2(0, 0), this->m_splashBackgroundTexture.getSize());
|
drawList->AddImage(this->m_splashBackgroundTexture, ImVec2(0, 0), WindowSize);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -330,7 +332,7 @@ namespace hex::init {
|
|||||||
this->m_progressLerp += (m_progress - this->m_progressLerp) * 0.1F;
|
this->m_progressLerp += (m_progress - this->m_progressLerp) * 0.1F;
|
||||||
|
|
||||||
// Draw the splash screen foreground
|
// Draw the splash screen foreground
|
||||||
drawList->AddImage(this->m_splashTextTexture, ImVec2(0, 0), this->m_splashTextTexture.getSize());
|
drawList->AddImage(this->m_splashTextTexture, ImVec2(0, 0), WindowSize);
|
||||||
|
|
||||||
// Draw the "copyright" notice
|
// Draw the "copyright" notice
|
||||||
drawList->AddText(ImVec2(35, 85), ImColor(0xFF, 0xFF, 0xFF, 0xFF), hex::format("WerWolv\n2020 - {0}", &__DATE__[7]).c_str());
|
drawList->AddText(ImVec2(35, 85), ImColor(0xFF, 0xFF, 0xFF, 0xFF), hex::format("WerWolv\n2020 - {0}", &__DATE__[7]).c_str());
|
||||||
@ -343,7 +345,7 @@ namespace hex::init {
|
|||||||
const static auto VersionInfo = hex::format("{0}", ImHexApi::System::getImHexVersion().get());
|
const static auto VersionInfo = hex::format("{0}", ImHexApi::System::getImHexVersion().get());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
drawList->AddText(ImVec2((this->m_splashBackgroundTexture.getSize().x - ImGui::CalcTextSize(VersionInfo.c_str()).x) / 2, 105), ImColor(0xFF, 0xFF, 0xFF, 0xFF), VersionInfo.c_str());
|
drawList->AddText(ImVec2((WindowSize.x - ImGui::CalcTextSize(VersionInfo.c_str()).x) / 2, 105), ImColor(0xFF, 0xFF, 0xFF, 0xFF), VersionInfo.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the task progress bar
|
// Draw the task progress bar
|
||||||
@ -553,8 +555,8 @@ namespace hex::init {
|
|||||||
|
|
||||||
// Load splash screen image from romfs
|
// Load splash screen image from romfs
|
||||||
const auto backingScale = ImHexApi::System::getNativeScale() * ImHexApi::System::getBackingScaleFactor();
|
const auto backingScale = ImHexApi::System::getNativeScale() * ImHexApi::System::getBackingScaleFactor();
|
||||||
this->m_splashBackgroundTexture = ImGuiExt::Texture::fromSVG(romfs::get("splash_background.svg").span(), 640 * backingScale, 400 * backingScale, ImGuiExt::Texture::Filter::Linear);
|
this->m_splashBackgroundTexture = ImGuiExt::Texture::fromSVG(romfs::get("splash_background.svg").span(), WindowSize.x * backingScale, WindowSize.y * backingScale, ImGuiExt::Texture::Filter::Linear);
|
||||||
this->m_splashTextTexture = ImGuiExt::Texture::fromSVG(romfs::get("splash_text.svg").span(), 640 * backingScale, 400 * backingScale, ImGuiExt::Texture::Filter::Linear);
|
this->m_splashTextTexture = ImGuiExt::Texture::fromSVG(romfs::get("splash_text.svg").span(), WindowSize.x * backingScale, WindowSize.y * backingScale, ImGuiExt::Texture::Filter::Linear);
|
||||||
|
|
||||||
// If the image couldn't be loaded correctly, something went wrong during the build process
|
// If the image couldn't be loaded correctly, something went wrong during the build process
|
||||||
// Close the application since this would lead to errors later on anyway.
|
// Close the application since this would lead to errors later on anyway.
|
||||||
@ -589,6 +591,7 @@ namespace hex::init {
|
|||||||
|
|
||||||
void WindowSplash::exitGLFW() const {
|
void WindowSplash::exitGLFW() const {
|
||||||
glfwDestroyWindow(m_window);
|
glfwDestroyWindow(m_window);
|
||||||
|
glfwTerminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowSplash::exitImGui() const {
|
void WindowSplash::exitImGui() const {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user