Skip to content

Commit

Permalink
Better menus and HUD for low-res (part 2) (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
deathkiller committed May 22, 2024
1 parent 4837952 commit aa97e2a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
6 changes: 4 additions & 2 deletions Sources/Jazz2/UI/HUD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 9 additions & 7 deletions Sources/Jazz2/UI/Menu/AboutSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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,
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions Sources/Jazz2/UI/Menu/BeginSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 6 additions & 5 deletions Sources/Jazz2/UI/Menu/InGameMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(ViewSize.X), static_cast<float>(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)));
Expand Down
13 changes: 7 additions & 6 deletions Sources/Jazz2/UI/Menu/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
Expand Down

0 comments on commit aa97e2a

Please sign in to comment.