Skip to content

Commit 673f119

Browse files
kphoenix137Yggdrasill
authored andcommitted
Menu text revision (diasurgical#3902)
1 parent 204f4ed commit 673f119

File tree

9 files changed

+98
-27
lines changed

9 files changed

+98
-27
lines changed

CMake/Assets.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ set(devilutionx_assets
9999
fonts/30-03.clx
100100
fonts/30-04.clx
101101
fonts/30-20.clx
102+
fonts/30-e0.clx
102103
fonts/42-00.clx
103104
fonts/42-01.clx
104105
fonts/42-02.clx

Source/control.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "panels/spell_book.hpp"
4545
#include "panels/spell_icons.hpp"
4646
#include "panels/spell_list.hpp"
47+
#include "pfile.h"
4748
#include "playerdat.hpp"
4849
#include "qol/stash.h"
4950
#include "qol/xpbar.h"
@@ -1180,6 +1181,19 @@ void CheckMainPanelButtonUp()
11801181
DoAutoMap();
11811182
break;
11821183
case PanelButtonMainmenu:
1184+
if (MyPlayerIsDead) {
1185+
if (!gbIsMultiplayer) {
1186+
if (gbValidSaveFile)
1187+
gamemenu_load_game(false);
1188+
else
1189+
gamemenu_exit_game(false);
1190+
} else {
1191+
NetSendCmd(true, CMD_RETOWN);
1192+
}
1193+
break;
1194+
} else if (MyPlayer->_pHitPoints == 0) {
1195+
break;
1196+
}
11831197
qtextflag = false;
11841198
gamemenu_handle_previous();
11851199
gamemenuOff = false;
@@ -1414,6 +1428,50 @@ void RedBack(const Surface &out)
14141428
}
14151429
}
14161430

1431+
void DrawDeathText(const Surface &out)
1432+
{
1433+
const TextRenderOptions largeTextOptions {
1434+
.flags = UiFlags::FontSize42 | UiFlags::ColorGold | UiFlags::AlignCenter | UiFlags::VerticalCenter,
1435+
.spacing = 2
1436+
};
1437+
const TextRenderOptions smallTextOptions {
1438+
.flags = UiFlags::FontSize30 | UiFlags::ColorGold | UiFlags::AlignCenter | UiFlags::VerticalCenter,
1439+
.spacing = 2
1440+
};
1441+
std::string text;
1442+
int verticalPadding = 42;
1443+
Point linePosition { 0, gnScreenHeight / 2 - (verticalPadding * 2) };
1444+
1445+
text = _("You have died");
1446+
DrawString(out, text, linePosition, largeTextOptions);
1447+
linePosition.y += verticalPadding;
1448+
1449+
std::string buttonText;
1450+
1451+
switch (ControlMode) {
1452+
case ControlTypes::KeyboardAndMouse:
1453+
buttonText = _("ESC");
1454+
break;
1455+
case ControlTypes::Gamepad:
1456+
buttonText = ToString(GamepadType, ControllerButton_BUTTON_START);
1457+
break;
1458+
case ControlTypes::VirtualGamepad:
1459+
buttonText = _("Menu Button");
1460+
break;
1461+
}
1462+
1463+
if (!gbIsMultiplayer) {
1464+
if (gbValidSaveFile)
1465+
text = fmt::format(fmt::runtime(_("Press {} to load last save.")), buttonText);
1466+
else
1467+
text = fmt::format(fmt::runtime(_("Press {} to return to Main Menu.")), buttonText);
1468+
1469+
} else {
1470+
text = fmt::format(fmt::runtime(_("Press {} to restart in town.")), buttonText);
1471+
}
1472+
DrawString(out, text, linePosition, smallTextOptions);
1473+
}
1474+
14171475
void DrawGoldSplit(const Surface &out)
14181476
{
14191477
const int dialogX = 30;

Source/control.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ void CheckChrBtns();
175175
void ReleaseChrBtns(bool addAllStatPoints);
176176
void DrawDurIcon(const Surface &out);
177177
void RedBack(const Surface &out);
178+
void DrawDeathText(const Surface &out);
178179
void DrawSpellBook(const Surface &out);
179180
void DrawGoldSplit(const Surface &out);
180181
void control_drop_gold(SDL_Keycode vkey);

Source/diablo.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,17 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
490490
}
491491

492492
if (MyPlayerIsDead) {
493+
if (vkey == SDLK_ESCAPE) {
494+
if (!gbIsMultiplayer) {
495+
if (gbValidSaveFile)
496+
gamemenu_load_game(false);
497+
else
498+
gamemenu_exit_game(false);
499+
} else {
500+
NetSendCmd(true, CMD_RETOWN);
501+
}
502+
return;
503+
}
493504
if (sgnTimeoutCurs != CURSOR_NONE) {
494505
return;
495506
}
@@ -506,7 +517,8 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
506517
return;
507518
}
508519
}
509-
if (vkey == SDLK_ESCAPE) {
520+
// Disallow player from accessing escape menu during the frames before the death message appears
521+
if (vkey == SDLK_ESCAPE && MyPlayer->_pHitPoints > 0) {
510522
if (!PressEscKey()) {
511523
LastMouseButtonAction = MouseActionType::None;
512524
gamemenu_on();

Source/engine/render/scrollrt.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,14 +1286,15 @@ void DrawView(const Surface &out, Point startPosition)
12861286
if (ChatLogFlag) {
12871287
DrawChatLog(out);
12881288
}
1289-
if (IsDiabloMsgAvailable()) {
1290-
DrawDiabloMsg(out.subregionY(0, out.h() - GetMainPanel().size.height));
1291-
}
12921289
if (MyPlayerIsDead) {
12931290
RedBack(out);
1291+
DrawDeathText(out);
12941292
} else if (PauseMode != 0) {
12951293
gmenu_draw_pause(out);
12961294
}
1295+
if (IsDiabloMsgAvailable()) {
1296+
DrawDiabloMsg(out.subregionY(0, out.h() - GetMainPanel().size.height));
1297+
}
12971298

12981299
DrawControllerModifierHints(out);
12991300
DrawPlrMsg(out);

Source/gamemenu.cpp

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,23 @@ void GamemenuSpeed(bool bActivate);
4444
/** Contains the game menu items of the single player menu. */
4545
TMenuItem sgSingleMenu[] = {
4646
// clang-format off
47-
// dwFlags, pszStr, fnMenu
48-
{ GMENU_ENABLED, N_("Save Game"), &gamemenu_save_game },
49-
{ GMENU_ENABLED, N_("Options"), &GamemenuOptions },
50-
{ GMENU_ENABLED, N_("New Game"), &GamemenuNewGame },
51-
{ GMENU_ENABLED, N_("Load Game"), &gamemenu_load_game },
52-
{ GMENU_ENABLED, N_("Quit Game"), &gamemenu_quit_game },
53-
{ GMENU_ENABLED, nullptr, nullptr }
47+
// dwFlags, pszStr, fnMenu
48+
{ GMENU_ENABLED, N_("Options"), &GamemenuOptions },
49+
{ GMENU_ENABLED, N_("Save Game"), &gamemenu_save_game },
50+
{ GMENU_ENABLED, N_("Load Game"), &gamemenu_load_game },
51+
{ GMENU_ENABLED, N_("Exit to Main Menu"), &GamemenuNewGame },
52+
{ GMENU_ENABLED, N_("Quit Game"), &gamemenu_quit_game },
53+
{ GMENU_ENABLED, nullptr, nullptr },
5454
// clang-format on
5555
};
5656
/** Contains the game menu items of the multi player menu. */
5757
TMenuItem sgMultiMenu[] = {
5858
// clang-format off
59-
// dwFlags, pszStr, fnMenu
60-
{ GMENU_ENABLED, N_("Options"), &GamemenuOptions },
61-
{ GMENU_ENABLED, N_("New Game"), &GamemenuNewGame },
62-
{ GMENU_ENABLED, N_("Restart In Town"), &GamemenuRestartTown },
63-
{ GMENU_ENABLED, N_("Quit Game"), &gamemenu_quit_game },
64-
{ GMENU_ENABLED, nullptr, nullptr },
59+
// dwFlags, pszStr, fnMenu
60+
{ GMENU_ENABLED, N_("Options"), &GamemenuOptions },
61+
{ GMENU_ENABLED, N_("Exit to Main Menu"), &GamemenuNewGame },
62+
{ GMENU_ENABLED, N_("Quit Game"), &gamemenu_quit_game },
63+
{ GMENU_ENABLED, nullptr, nullptr },
6564
// clang-format on
6665
};
6766
TMenuItem sgOptionsMenu[] = {
@@ -88,18 +87,13 @@ const char *const SoundToggleNames[] = {
8887

8988
void GamemenuUpdateSingle()
9089
{
91-
sgSingleMenu[3].setEnabled(gbValidSaveFile);
90+
sgSingleMenu[2].setEnabled(gbValidSaveFile);
9291

9392
bool enable = MyPlayer->_pmode != PM_DEATH && !MyPlayerIsDead;
9493

9594
sgSingleMenu[0].setEnabled(enable);
9695
}
9796

98-
void GamemenuUpdateMulti()
99-
{
100-
sgMultiMenu[2].setEnabled(MyPlayerIsDead);
101-
}
102-
10397
void GamemenuPrevious(bool /*bActivate*/)
10498
{
10599
gamemenu_on();
@@ -286,6 +280,11 @@ void GamemenuSpeed(bool bActivate)
286280

287281
} // namespace
288282

283+
void gamemenu_exit_game(bool bActivate)
284+
{
285+
GamemenuNewGame(bActivate);
286+
}
287+
289288
void gamemenu_quit_game(bool bActivate)
290289
{
291290
GamemenuNewGame(bActivate);
@@ -368,7 +367,7 @@ void gamemenu_on()
368367
if (!gbIsMultiplayer) {
369368
gmenu_set_items(sgSingleMenu, GamemenuUpdateSingle);
370369
} else {
371-
gmenu_set_items(sgMultiMenu, GamemenuUpdateMulti);
370+
gmenu_set_items(sgMultiMenu, nullptr);
372371
}
373372
PressEscKey();
374373
}

Source/gamemenu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace devilution {
1010
void gamemenu_on();
1111
void gamemenu_off();
1212
void gamemenu_handle_previous();
13+
void gamemenu_exit_game(bool bActivate);
1314
void gamemenu_quit_game(bool bActivate);
1415
void gamemenu_load_game(bool bActivate);
1516
void gamemenu_save_game(bool bActivate);

Source/player.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,9 +1034,6 @@ bool DoDeath(Player &player)
10341034
dFlags[player.position.tile.x][player.position.tile.y] |= DungeonFlag::DeadPlayer;
10351035
} else if (&player == MyPlayer && player.AnimInfo.tickCounterOfCurrentFrame == 30) {
10361036
MyPlayerIsDead = true;
1037-
if (!gbIsMultiplayer) {
1038-
gamemenu_on();
1039-
}
10401037
}
10411038
}
10421039

@@ -2616,6 +2613,7 @@ StartPlayerKill(Player &player, DeathReason deathReason)
26162613

26172614
if (&player == MyPlayer) {
26182615
NetSendCmdParam1(true, CMD_PLRDEAD, static_cast<uint16_t>(deathReason));
2616+
gamemenu_off();
26192617
}
26202618

26212619
const bool dropGold = !gbIsMultiplayer || !(player.isOnLevel(16) || player.isOnArenaLevel());

assets/fonts/30-e0.clx

29.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)