From aa97e2a11b9bd8048533098b7e695e6b2a5539e9 Mon Sep 17 00:00:00 2001 From: Death Killer <884052+deathkiller@users.noreply.github.com> Date: Wed, 22 May 2024 09:37:03 +0200 Subject: [PATCH] Better menus and HUD for low-res (part 2) (#57) --- Sources/Jazz2/UI/HUD.cpp | 6 ++++-- Sources/Jazz2/UI/Menu/AboutSection.cpp | 16 +++++++++------- Sources/Jazz2/UI/Menu/BeginSection.cpp | 4 ++++ Sources/Jazz2/UI/Menu/InGameMenu.cpp | 11 ++++++----- Sources/Jazz2/UI/Menu/MainMenu.cpp | 13 +++++++------ 5 files changed, 30 insertions(+), 20 deletions(-) diff --git a/Sources/Jazz2/UI/HUD.cpp b/Sources/Jazz2/UI/HUD.cpp index 6ec198d4..c153171c 100644 --- a/Sources/Jazz2/UI/HUD.cpp +++ b/Sources/Jazz2/UI/HUD.cpp @@ -726,12 +726,14 @@ namespace Jazz2::UI offset = 0; } + float textScale = (ViewSize.X >= 360 ? 1.0f : 0.8f); + int32_t charOffsetShadow = charOffset; _smallFont->DrawString(this, _levelText, charOffsetShadow, ViewSize.X * 0.5f + offset, ViewSize.Y * 0.04f + 2.5f, FontShadowLayer, - Alignment::Top, Colorf(0.0f, 0.0f, 0.0f, 0.3f), 1.0f, 0.72f, 0.8f, 0.8f); + Alignment::Top, Colorf(0.0f, 0.0f, 0.0f, 0.3f), textScale, 0.72f, 0.8f, 0.8f); _smallFont->DrawString(this, _levelText, charOffset, ViewSize.X * 0.5f + offset, ViewSize.Y * 0.04f, FontLayer, - Alignment::Top, Font::DefaultColor, 1.0f, 0.72f, 0.8f, 0.8f); + Alignment::Top, Font::DefaultColor, textScale, 0.72f, 0.8f, 0.8f); if (_levelTextTime > TotalTime) { _levelTextTime = -1.0f; diff --git a/Sources/Jazz2/UI/Menu/AboutSection.cpp b/Sources/Jazz2/UI/Menu/AboutSection.cpp index 15647e67..a082a252 100644 --- a/Sources/Jazz2/UI/Menu/AboutSection.cpp +++ b/Sources/Jazz2/UI/Menu/AboutSection.cpp @@ -128,7 +128,7 @@ namespace Jazz2::UI::Menu Vector2i viewSize = canvas->ViewSize; Vector2f pos = Vector2f(viewSize.X * 0.5f, viewSize.Y * 0.5f); - pos.Y = std::round(std::max(150.0f, pos.Y * 0.86f)); + pos.Y = (viewSize.Y >= 300 ? std::round(std::max(150.0f, pos.Y * 0.86f)) : 30.0f); _root->DrawElement(MenuDim, pos.X, pos.Y + 24.0f - 2.0f, IMenuContainer::BackgroundLayer, Alignment::Top, Colorf::Black, Vector2f(680.0f, 200.0f), Vector4f(1.0f, 0.0f, -0.7f, 0.7f)); @@ -137,10 +137,12 @@ namespace Jazz2::UI::Menu int32_t charOffset = 0; - // TRANSLATORS: Main information in About section - _root->DrawStringShadow(_f("Reimplementation of the game \f[c:0x9e7056]Jazz Jackrabbit 2\f[c] released in 1998. Supports various\nversions of the game (Shareware Demo, Holiday Hare '98, The Secret Files and\nChristmas Chronicles). Also, it partially supports some features of JJ2+ extension.\nFor more information, visit the official website: %s", "\f[c:0x707070]https://deat.tk/jazz2/\f[c]"), - charOffset, viewSize.X * 0.5f, pos.Y - 22.0f, IMenuContainer::FontLayer, - Alignment::Center, Font::DefaultColor, 0.7f, 0.4f, 0.0f, 0.0f, 0.0f, 0.9f, 1.2f); + if (viewSize.Y >= 300) { + // TRANSLATORS: Main information in About section + _root->DrawStringShadow(_f("Reimplementation of the game \f[c:0x9e7056]Jazz Jackrabbit 2\f[c] released in 1998. Supports various\nversions of the game (Shareware Demo, Holiday Hare '98, The Secret Files and\nChristmas Chronicles). Also, it partially supports some features of JJ2+ extension.\nFor more information, visit the official website: %s", "\f[c:0x707070]https://deat.tk/jazz2/\f[c]"), + charOffset, viewSize.X * 0.5f, pos.Y - 22.0f, IMenuContainer::FontLayer, + Alignment::Center, Font::DefaultColor, 0.7f, 0.4f, 0.0f, 0.0f, 0.0f, 0.9f, 1.2f); + } // TRANSLATORS: Header in About section _root->DrawStringShadow(_("Created By"), charOffset, pos.X, pos.Y + 42.0f, IMenuContainer::FontLayer, @@ -156,12 +158,12 @@ namespace Jazz2::UI::Menu Alignment::Left, Font::DefaultColor, 0.74f, 0.4f, 0.6f, 0.6f, 0.6f, 0.9f, 1.2f); // TRANSLATORS: Bottom information in About section - _root->DrawStringShadow(_f("This project uses modified \f[c:0x9e7056]nCine\f[c] game engine and following libraries:\n%s", ADDITIONAL_INFO), charOffset, viewSize.X * 0.5f, pos.Y + 54.0f + pos.Y * 0.4f, IMenuContainer::FontLayer, + _root->DrawStringShadow(_f("This project uses modified \f[c:0x9e7056]nCine\f[c] game engine and following libraries:\n%s", ADDITIONAL_INFO), charOffset, viewSize.X * 0.5f, pos.Y + 54.0f + std::max(60.0f, pos.Y * 0.4f), IMenuContainer::FontLayer, Alignment::Top, Font::DefaultColor, 0.76f, 0.4f, 0.6f, 0.6f, 0.6f, 0.9f, 1.2f); _root->DrawElement(MenuLine, 0, viewSize.X * 0.5f, pos.Y + 24.0f, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); - pos.Y = viewSize.Y - 100.0f; + //pos.Y = viewSize.Y - 100.0f; } void AboutSection::OnTouchEvent(const nCine::TouchEvent& event, const Vector2i& viewSize) diff --git a/Sources/Jazz2/UI/Menu/BeginSection.cpp b/Sources/Jazz2/UI/Menu/BeginSection.cpp index 23278306..166f950d 100644 --- a/Sources/Jazz2/UI/Menu/BeginSection.cpp +++ b/Sources/Jazz2/UI/Menu/BeginSection.cpp @@ -169,6 +169,10 @@ namespace Jazz2::UI::Menu { Recti contentBounds = _root->GetContentBounds(); Vector2f center = Vector2f(contentBounds.X + contentBounds.W * 0.5f, contentBounds.Y + contentBounds.H * 0.2f * (1.0f - 0.048f * (int32_t)_items.size())); + if (contentBounds.H < 230) { + center.Y *= 0.85f; + } + int32_t charOffset = 0; #if !defined(DEATH_TARGET_EMSCRIPTEN) diff --git a/Sources/Jazz2/UI/Menu/InGameMenu.cpp b/Sources/Jazz2/UI/Menu/InGameMenu.cpp index 971a0aa2..e76fddb1 100644 --- a/Sources/Jazz2/UI/Menu/InGameMenu.cpp +++ b/Sources/Jazz2/UI/Menu/InGameMenu.cpp @@ -110,11 +110,12 @@ namespace Jazz2::UI::Menu int32_t charOffsetShadow = 0; float titleY = _owner->_contentBounds.Y - (ViewSize.Y >= 300 ? 30.0f : 12.0f); - constexpr float logoScale = 1.0f; - constexpr float logoTextScale = 1.0f; - constexpr float logoTranslateX = 1.0f; - constexpr float logoTranslateY = 0.0f; - constexpr float logoTextTranslate = 0.0f; + float logoBaseScale = (ViewSize.Y >= 300 ? 1.0f : 0.85f); + float logoScale = logoBaseScale; + float logoTextScale = logoBaseScale; + float logoTranslateX = logoBaseScale; + float logoTranslateY = 0.0f; + float logoTextTranslate = 0.0f; // Show blurred viewport behind DrawTexture(*_owner->_root->_blurPass4.GetTarget(), Vector2f::Zero, 500, Vector2f(static_cast(ViewSize.X), static_cast(ViewSize.Y)), Vector4f(1.0f, 0.0f, 1.0f, 0.0f), Colorf(0.5f, 0.5f, 0.5f, std::min(AnimTime * 8.0f, 1.0f))); diff --git a/Sources/Jazz2/UI/Menu/MainMenu.cpp b/Sources/Jazz2/UI/Menu/MainMenu.cpp index 55c87704..161149a4 100644 --- a/Sources/Jazz2/UI/Menu/MainMenu.cpp +++ b/Sources/Jazz2/UI/Menu/MainMenu.cpp @@ -210,9 +210,10 @@ namespace Jazz2::UI::Menu int32_t charOffsetShadow = 0; float titleY = _owner->_contentBounds.Y - (ViewSize.Y >= 300 ? 30.0f : 12.0f); - float logoScale = 1.0f + (1.0f - _owner->_logoTransition) * 7.0f; - float logoTextScale = 1.0f + (1.0f - _owner->_logoTransition) * 2.0f; - float logoTranslateX = 1.0f + (1.0f - _owner->_logoTransition) * 1.2f; + float logoBaseScale = (ViewSize.Y >= 300 ? 1.0f : 0.85f); + float logoScale = logoBaseScale + (1.0f - _owner->_logoTransition) * 7.0f; + float logoTextScale = logoBaseScale + (1.0f - _owner->_logoTransition) * 2.0f; + float logoTranslateX = logoBaseScale + (1.0f - _owner->_logoTransition) * 1.2f; float logoTranslateY = (1.0f - _owner->_logoTransition) * 120.0f; float logoTextTranslate = (1.0f - _owner->_logoTransition) * 60.0f; @@ -224,11 +225,11 @@ namespace Jazz2::UI::Menu _owner->DrawElement(MenuCarrot, -1, center.X - 76.0f * logoTranslateX, titleY - 6.0f + logoTranslateY + 2.0f, ShadowLayer + 200, Alignment::Center, Colorf(0.0f, 0.0f, 0.0f, 0.3f), 0.8f * logoScale, 0.8f * logoScale); _owner->DrawElement(MenuCarrot, -1, center.X - 76.0f * logoTranslateX, titleY - 6.0f + logoTranslateY, MainLayer + 200, Alignment::Center, Colorf::White, 0.8f * logoScale, 0.8f * logoScale); - _owner->_mediumFont->DrawString(this, "Jazz"_s, charOffsetShadow, center.X - 63.0f, titleY + logoTranslateY + 2.0f, FontShadowLayer + 200, + _owner->_mediumFont->DrawString(this, "Jazz"_s, charOffsetShadow, center.X - 63.0f * logoTranslateX + logoTextTranslate, titleY + logoTranslateY + 2.0f, FontShadowLayer + 200, Alignment::Left, Colorf(0.0f, 0.0f, 0.0f, 0.32f), 0.75f * logoTextScale, 1.65f, 3.0f, 3.0f, 0.0f, 0.92f); - _owner->_mediumFont->DrawString(this, "2"_s, charOffsetShadow, center.X - 19.0f, titleY - 8.0f + logoTranslateY + 2.0f, FontShadowLayer + 200, + _owner->_mediumFont->DrawString(this, "2"_s, charOffsetShadow, center.X - 19.0f * logoTranslateX + logoTextTranslate, titleY - 8.0f + logoTranslateY + 2.0f, FontShadowLayer + 200, Alignment::Left, Colorf(0.0f, 0.0f, 0.0f, 0.32f), 0.5f * logoTextScale, 0.0f, 0.0f, 0.0f, 0.0f); - _owner->_mediumFont->DrawString(this, "Resurrection"_s, charOffsetShadow, center.X - 10.0f, titleY + 4.0f + logoTranslateY + 2.5f, FontShadowLayer + 200, + _owner->_mediumFont->DrawString(this, "Resurrection"_s, charOffsetShadow, center.X - 10.0f * logoTranslateX + logoTextTranslate, titleY + 4.0f + logoTranslateY + 2.5f, FontShadowLayer + 200, Alignment::Left, Colorf(0.0f, 0.0f, 0.0f, 0.3f), 0.5f * logoTextScale, 0.4f, 1.2f, 1.2f, 0.46f, 0.8f); _owner->_mediumFont->DrawString(this, "Jazz"_s, charOffset, center.X - 63.0f * logoTranslateX + logoTextTranslate, titleY + logoTranslateY, FontLayer + 200,