From 654391a278106e4b74473c44ba527297d36c26de Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 25 Jul 2020 15:41:11 +0200 Subject: [PATCH] - fixed layout for classic Duke fullscreen HUD. --- source/core/screenjob.cpp | 1 - source/core/statusbar.cpp | 1 + source/games/duke/src/2d_d.cpp | 4 ++++ source/games/duke/src/input.cpp | 26 +++++++++++++------------- source/games/duke/src/sbar.cpp | 7 +++++-- source/games/duke/src/sbar_d.cpp | 5 ++--- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/source/core/screenjob.cpp b/source/core/screenjob.cpp index ef1fa876a..e080941b8 100644 --- a/source/core/screenjob.cpp +++ b/source/core/screenjob.cpp @@ -124,7 +124,6 @@ public: if (totalclock < ototalclock - 1) { - Printf("\n"); twod->ClearScreen(); DrawTexture(twod, animtex.GetFrame(), 0, 0, DTA_FullscreenEx, 3, DTA_Masked, false, TAG_DONE); return skiprequest? -1 : 1; diff --git a/source/core/statusbar.cpp b/source/core/statusbar.cpp index 7a72e49dc..f4af3efa1 100644 --- a/source/core/statusbar.cpp +++ b/source/core/statusbar.cpp @@ -627,6 +627,7 @@ void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, d { continue; } + width += font->GetDefaultKerning(); if (!monospaced) //If we are monospaced lets use the offset x += (c->GetDisplayLeftOffset() + 1); //ignore x offsets since we adapt to character size diff --git a/source/games/duke/src/2d_d.cpp b/source/games/duke/src/2d_d.cpp index 9f3012403..b13bb255a 100644 --- a/source/games/duke/src/2d_d.cpp +++ b/source/games/duke/src/2d_d.cpp @@ -111,6 +111,8 @@ void InitFonts_d() fontdata.Insert('/', tileGetTexture(THREEBYFIVE + 11)); fontdata.Insert('%', tileGetTexture(MINIFONT + '%' - '!')); fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation. + GlyphSet::Iterator iti(fontdata); + while (iti.NextPair(pair)) pair->Value->SetOffsetsNotForFont(); IndexFont = new ::FFont("IndexFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata); fontdata.Clear(); @@ -118,6 +120,8 @@ void InitFonts_d() // digital font for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(DIGITALNUM + i)); fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation. + GlyphSet::Iterator itd(fontdata); + while (itd.NextPair(pair)) pair->Value->SetOffsetsNotForFont(); DigiFont = new ::FFont("DigiFont", nullptr, nullptr, 0, 0, 0, -1, -1, false, false, false, &fontdata); } diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 6f136537e..bc2630acc 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -1297,19 +1297,19 @@ void registerinputcommands() C_RegisterFunction("slot", "slot : select a weapon from the given slot (1-10)", ccmd_slot); C_RegisterFunction("weapprev", nullptr, [](CCmdFuncPtr)->int { WeaponToSend = 11; return CCMD_OK; }); C_RegisterFunction("weapnext", nullptr, [](CCmdFuncPtr)->int { WeaponToSend = 12; return CCMD_OK; }); - C_RegisterFunction("pause", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_PAUSE; return CCMD_OK; }); - C_RegisterFunction("steroids", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_STEROIDS; return CCMD_OK; }); - C_RegisterFunction("nightvision", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_NIGHTVISION; return CCMD_OK; }); - C_RegisterFunction("medkit", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_MEDKIT; return CCMD_OK; }); - C_RegisterFunction("centerview", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_CENTER_VIEW; return CCMD_OK; }); - C_RegisterFunction("holsterweapon", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_HOLSTER; return CCMD_OK; }); - C_RegisterFunction("invprev", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_INV_LEFT; return CCMD_OK; }); - C_RegisterFunction("invnext", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_INV_RIGHT; return CCMD_OK; }); - C_RegisterFunction("holoduke", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_HOLODUKE; return CCMD_OK; }); - C_RegisterFunction("jetpack", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_JETPACK; return CCMD_OK; }); - C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_TURNAROUND; return CCMD_OK; }); - C_RegisterFunction("invuse", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_INVENTORY; return CCMD_OK; }); - C_RegisterFunction("backoff", nullptr, [](CCmdFuncPtr)->int { BitsToSend = SKB_ESCAPE; return CCMD_OK; }); + C_RegisterFunction("pause", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_PAUSE; return CCMD_OK; }); + C_RegisterFunction("steroids", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_STEROIDS; return CCMD_OK; }); + C_RegisterFunction("nightvision", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_NIGHTVISION; return CCMD_OK; }); + C_RegisterFunction("medkit", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_MEDKIT; return CCMD_OK; }); + C_RegisterFunction("centerview", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_CENTER_VIEW; return CCMD_OK; }); + C_RegisterFunction("holsterweapon", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_HOLSTER; return CCMD_OK; }); + C_RegisterFunction("invprev", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_INV_LEFT; return CCMD_OK; }); + C_RegisterFunction("invnext", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_INV_RIGHT; return CCMD_OK; }); + C_RegisterFunction("holoduke", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_HOLODUKE; return CCMD_OK; }); + C_RegisterFunction("jetpack", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_JETPACK; return CCMD_OK; }); + C_RegisterFunction("turnaround", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_TURNAROUND; return CCMD_OK; }); + C_RegisterFunction("invuse", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_INVENTORY; return CCMD_OK; }); + C_RegisterFunction("backoff", nullptr, [](CCmdFuncPtr)->int { BitsToSend |= SKB_ESCAPE; return CCMD_OK; }); } // This is called from ImputState::ClearAllInput and resets all static state being used here. diff --git a/source/games/duke/src/sbar.cpp b/source/games/duke/src/sbar.cpp index 5e0b41e26..1f47e6347 100644 --- a/source/games/duke/src/sbar.cpp +++ b/source/games/duke/src/sbar.cpp @@ -49,9 +49,9 @@ BEGIN_DUKE_NS //========================================================================== DDukeCommonStatusBar::DDukeCommonStatusBar() - : numberFont(BigFont, 1, Off, 1, 1), + : numberFont(BigFont, 0, Off, 1, 1), indexFont(IndexFont, 4, CellRight, 1, 1), - miniFont(SmallFont2, 1, Off, 1, 1), + miniFont(SmallFont2, 0, Off, 1, 1), digiFont(DigiFont, 1 , Off, 1, 1) { drawOffset.Y = 0; @@ -100,10 +100,13 @@ std::pair DDukeCommonStatusBar::ontext(struct player_s { case ICON_HOLODUKE: onstate = p->holoduke_on; + break; case ICON_JETPACK: onstate = p->jetpack_on; + break; case ICON_HEATS: onstate = p->heat_on; + break; } // Texts are intentionally not translated because the font is too small for making localization work and the translated words are too long. diff --git a/source/games/duke/src/sbar_d.cpp b/source/games/duke/src/sbar_d.cpp index dabca3685..59ca63e99 100644 --- a/source/games/duke/src/sbar_d.cpp +++ b/source/games/duke/src/sbar_d.cpp @@ -201,7 +201,7 @@ public: DrawGraphic(tileGetTexture(HEALTHBOX), 5, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); int health = (sprite[p->i].pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; FStringf format("%d", health); - SBar_DrawString(this, &digiFont, format, 19, -digiFont.mFont->GetHeight() * scale - 7, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + SBar_DrawString(this, &digiFont, format, 19, -digiFont.mFont->GetHeight() * scale - 3, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); // // ammo @@ -209,7 +209,7 @@ public: DrawGraphic(tileGetTexture(AMMOBOX), 37, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); int wp = (p->curr_weapon == HANDREMOTE_WEAPON) ? HANDBOMB_WEAPON : p->curr_weapon; format.Format("%d", p->ammo_amount[wp]); - SBar_DrawString(this, &digiFont, format, 53, -digiFont.mFont->GetHeight() * scale - 7, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); + SBar_DrawString(this, &digiFont, format, 53, -digiFont.mFont->GetHeight() * scale - 3, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); // // inventory @@ -229,7 +229,6 @@ public: auto text = ontext(p); if (text.first) SBar_DrawString(this, &miniFont, text.first, x + 34, -miniFont.mFont->GetHeight() - 14.5, DI_TEXT_ALIGN_RIGHT, text.second, 1, 0, 0, 1, 1); - } }