Browse Source

Menu text revision (#3902)

pull/7424/merge
Eric Robinson 1 year ago committed by GitHub
parent
commit
aca06e898a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CMake/Assets.cmake
  2. 58
      Source/control.cpp
  3. 1
      Source/control.h
  4. 14
      Source/diablo.cpp
  5. 7
      Source/engine/render/scrollrt.cpp
  6. 39
      Source/gamemenu.cpp
  7. 1
      Source/gamemenu.h
  8. 4
      Source/player.cpp
  9. BIN
      assets/fonts/30-e0.clx

1
CMake/Assets.cmake

@ -99,6 +99,7 @@ set(devilutionx_assets
fonts/30-03.clx fonts/30-03.clx
fonts/30-04.clx fonts/30-04.clx
fonts/30-20.clx fonts/30-20.clx
fonts/30-e0.clx
fonts/42-00.clx fonts/42-00.clx
fonts/42-01.clx fonts/42-01.clx
fonts/42-02.clx fonts/42-02.clx

58
Source/control.cpp

@ -44,6 +44,7 @@
#include "panels/spell_book.hpp" #include "panels/spell_book.hpp"
#include "panels/spell_icons.hpp" #include "panels/spell_icons.hpp"
#include "panels/spell_list.hpp" #include "panels/spell_list.hpp"
#include "pfile.h"
#include "playerdat.hpp" #include "playerdat.hpp"
#include "qol/stash.h" #include "qol/stash.h"
#include "qol/xpbar.h" #include "qol/xpbar.h"
@ -1180,6 +1181,19 @@ void CheckMainPanelButtonUp()
DoAutoMap(); DoAutoMap();
break; break;
case PanelButtonMainmenu: case PanelButtonMainmenu:
if (MyPlayerIsDead) {
if (!gbIsMultiplayer) {
if (gbValidSaveFile)
gamemenu_load_game(false);
else
gamemenu_exit_game(false);
} else {
NetSendCmd(true, CMD_RETOWN);
}
break;
} else if (MyPlayer->_pHitPoints == 0) {
break;
}
qtextflag = false; qtextflag = false;
gamemenu_handle_previous(); gamemenu_handle_previous();
gamemenuOff = false; gamemenuOff = false;
@ -1414,6 +1428,50 @@ void RedBack(const Surface &out)
} }
} }
void DrawDeathText(const Surface &out)
{
const TextRenderOptions largeTextOptions {
.flags = UiFlags::FontSize42 | UiFlags::ColorGold | UiFlags::AlignCenter | UiFlags::VerticalCenter,
.spacing = 2
};
const TextRenderOptions smallTextOptions {
.flags = UiFlags::FontSize30 | UiFlags::ColorGold | UiFlags::AlignCenter | UiFlags::VerticalCenter,
.spacing = 2
};
std::string text;
int verticalPadding = 42;
Point linePosition { 0, gnScreenHeight / 2 - (verticalPadding * 2) };
text = _("You have died");
DrawString(out, text, linePosition, largeTextOptions);
linePosition.y += verticalPadding;
std::string buttonText;
switch (ControlMode) {
case ControlTypes::KeyboardAndMouse:
buttonText = _("ESC");
break;
case ControlTypes::Gamepad:
buttonText = ToString(GamepadType, ControllerButton_BUTTON_START);
break;
case ControlTypes::VirtualGamepad:
buttonText = _("Menu Button");
break;
}
if (!gbIsMultiplayer) {
if (gbValidSaveFile)
text = fmt::format(fmt::runtime(_("Press {} to load last save.")), buttonText);
else
text = fmt::format(fmt::runtime(_("Press {} to return to Main Menu.")), buttonText);
} else {
text = fmt::format(fmt::runtime(_("Press {} to restart in town.")), buttonText);
}
DrawString(out, text, linePosition, smallTextOptions);
}
void DrawGoldSplit(const Surface &out) void DrawGoldSplit(const Surface &out)
{ {
const int dialogX = 30; const int dialogX = 30;

1
Source/control.h

@ -175,6 +175,7 @@ void CheckChrBtns();
void ReleaseChrBtns(bool addAllStatPoints); void ReleaseChrBtns(bool addAllStatPoints);
void DrawDurIcon(const Surface &out); void DrawDurIcon(const Surface &out);
void RedBack(const Surface &out); void RedBack(const Surface &out);
void DrawDeathText(const Surface &out);
void DrawSpellBook(const Surface &out); void DrawSpellBook(const Surface &out);
void DrawGoldSplit(const Surface &out); void DrawGoldSplit(const Surface &out);
void control_drop_gold(SDL_Keycode vkey); void control_drop_gold(SDL_Keycode vkey);

14
Source/diablo.cpp

@ -490,6 +490,17 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
} }
if (MyPlayerIsDead) { if (MyPlayerIsDead) {
if (vkey == SDLK_ESCAPE) {
if (!gbIsMultiplayer) {
if (gbValidSaveFile)
gamemenu_load_game(false);
else
gamemenu_exit_game(false);
} else {
NetSendCmd(true, CMD_RETOWN);
}
return;
}
if (sgnTimeoutCurs != CURSOR_NONE) { if (sgnTimeoutCurs != CURSOR_NONE) {
return; return;
} }
@ -506,7 +517,8 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
return; return;
} }
} }
if (vkey == SDLK_ESCAPE) { // Disallow player from accessing escape menu during the frames before the death message appears
if (vkey == SDLK_ESCAPE && MyPlayer->_pHitPoints > 0) {
if (!PressEscKey()) { if (!PressEscKey()) {
LastMouseButtonAction = MouseActionType::None; LastMouseButtonAction = MouseActionType::None;
gamemenu_on(); gamemenu_on();

7
Source/engine/render/scrollrt.cpp

@ -1286,14 +1286,15 @@ void DrawView(const Surface &out, Point startPosition)
if (ChatLogFlag) { if (ChatLogFlag) {
DrawChatLog(out); DrawChatLog(out);
} }
if (IsDiabloMsgAvailable()) {
DrawDiabloMsg(out.subregionY(0, out.h() - GetMainPanel().size.height));
}
if (MyPlayerIsDead) { if (MyPlayerIsDead) {
RedBack(out); RedBack(out);
DrawDeathText(out);
} else if (PauseMode != 0) { } else if (PauseMode != 0) {
gmenu_draw_pause(out); gmenu_draw_pause(out);
} }
if (IsDiabloMsgAvailable()) {
DrawDiabloMsg(out.subregionY(0, out.h() - GetMainPanel().size.height));
}
DrawControllerModifierHints(out); DrawControllerModifierHints(out);
DrawPlrMsg(out); DrawPlrMsg(out);

39
Source/gamemenu.cpp

@ -44,24 +44,23 @@ void GamemenuSpeed(bool bActivate);
/** Contains the game menu items of the single player menu. */ /** Contains the game menu items of the single player menu. */
TMenuItem sgSingleMenu[] = { TMenuItem sgSingleMenu[] = {
// clang-format off // clang-format off
// dwFlags, pszStr, fnMenu // dwFlags, pszStr, fnMenu
{ GMENU_ENABLED, N_("Save Game"), &gamemenu_save_game }, { GMENU_ENABLED, N_("Options"), &GamemenuOptions },
{ GMENU_ENABLED, N_("Options"), &GamemenuOptions }, { GMENU_ENABLED, N_("Save Game"), &gamemenu_save_game },
{ GMENU_ENABLED, N_("New Game"), &GamemenuNewGame }, { GMENU_ENABLED, N_("Load Game"), &gamemenu_load_game },
{ GMENU_ENABLED, N_("Load Game"), &gamemenu_load_game }, { GMENU_ENABLED, N_("Exit to Main Menu"), &GamemenuNewGame },
{ GMENU_ENABLED, N_("Quit Game"), &gamemenu_quit_game }, { GMENU_ENABLED, N_("Quit Game"), &gamemenu_quit_game },
{ GMENU_ENABLED, nullptr, nullptr } { GMENU_ENABLED, nullptr, nullptr },
// clang-format on // clang-format on
}; };
/** Contains the game menu items of the multi player menu. */ /** Contains the game menu items of the multi player menu. */
TMenuItem sgMultiMenu[] = { TMenuItem sgMultiMenu[] = {
// clang-format off // clang-format off
// dwFlags, pszStr, fnMenu // dwFlags, pszStr, fnMenu
{ GMENU_ENABLED, N_("Options"), &GamemenuOptions }, { GMENU_ENABLED, N_("Options"), &GamemenuOptions },
{ GMENU_ENABLED, N_("New Game"), &GamemenuNewGame }, { GMENU_ENABLED, N_("Exit to Main Menu"), &GamemenuNewGame },
{ GMENU_ENABLED, N_("Restart In Town"), &GamemenuRestartTown }, { GMENU_ENABLED, N_("Quit Game"), &gamemenu_quit_game },
{ GMENU_ENABLED, N_("Quit Game"), &gamemenu_quit_game }, { GMENU_ENABLED, nullptr, nullptr },
{ GMENU_ENABLED, nullptr, nullptr },
// clang-format on // clang-format on
}; };
TMenuItem sgOptionsMenu[] = { TMenuItem sgOptionsMenu[] = {
@ -88,18 +87,13 @@ const char *const SoundToggleNames[] = {
void GamemenuUpdateSingle() void GamemenuUpdateSingle()
{ {
sgSingleMenu[3].setEnabled(gbValidSaveFile); sgSingleMenu[2].setEnabled(gbValidSaveFile);
bool enable = MyPlayer->_pmode != PM_DEATH && !MyPlayerIsDead; bool enable = MyPlayer->_pmode != PM_DEATH && !MyPlayerIsDead;
sgSingleMenu[0].setEnabled(enable); sgSingleMenu[0].setEnabled(enable);
} }
void GamemenuUpdateMulti()
{
sgMultiMenu[2].setEnabled(MyPlayerIsDead);
}
void GamemenuPrevious(bool /*bActivate*/) void GamemenuPrevious(bool /*bActivate*/)
{ {
gamemenu_on(); gamemenu_on();
@ -286,6 +280,11 @@ void GamemenuSpeed(bool bActivate)
} // namespace } // namespace
void gamemenu_exit_game(bool bActivate)
{
GamemenuNewGame(bActivate);
}
void gamemenu_quit_game(bool bActivate) void gamemenu_quit_game(bool bActivate)
{ {
GamemenuNewGame(bActivate); GamemenuNewGame(bActivate);
@ -368,7 +367,7 @@ void gamemenu_on()
if (!gbIsMultiplayer) { if (!gbIsMultiplayer) {
gmenu_set_items(sgSingleMenu, GamemenuUpdateSingle); gmenu_set_items(sgSingleMenu, GamemenuUpdateSingle);
} else { } else {
gmenu_set_items(sgMultiMenu, GamemenuUpdateMulti); gmenu_set_items(sgMultiMenu, nullptr);
} }
PressEscKey(); PressEscKey();
} }

1
Source/gamemenu.h

@ -10,6 +10,7 @@ namespace devilution {
void gamemenu_on(); void gamemenu_on();
void gamemenu_off(); void gamemenu_off();
void gamemenu_handle_previous(); void gamemenu_handle_previous();
void gamemenu_exit_game(bool bActivate);
void gamemenu_quit_game(bool bActivate); void gamemenu_quit_game(bool bActivate);
void gamemenu_load_game(bool bActivate); void gamemenu_load_game(bool bActivate);
void gamemenu_save_game(bool bActivate); void gamemenu_save_game(bool bActivate);

4
Source/player.cpp

@ -1037,9 +1037,6 @@ bool DoDeath(Player &player)
dFlags[player.position.tile.x][player.position.tile.y] |= DungeonFlag::DeadPlayer; dFlags[player.position.tile.x][player.position.tile.y] |= DungeonFlag::DeadPlayer;
} else if (&player == MyPlayer && player.AnimInfo.tickCounterOfCurrentFrame == 30) { } else if (&player == MyPlayer && player.AnimInfo.tickCounterOfCurrentFrame == 30) {
MyPlayerIsDead = true; MyPlayerIsDead = true;
if (!gbIsMultiplayer) {
gamemenu_on();
}
} }
} }
@ -2619,6 +2616,7 @@ StartPlayerKill(Player &player, DeathReason deathReason)
if (&player == MyPlayer) { if (&player == MyPlayer) {
NetSendCmdParam1(true, CMD_PLRDEAD, static_cast<uint16_t>(deathReason)); NetSendCmdParam1(true, CMD_PLRDEAD, static_cast<uint16_t>(deathReason));
gamemenu_off();
} }
const bool dropGold = !gbIsMultiplayer || !(player.isOnLevel(16) || player.isOnArenaLevel()); const bool dropGold = !gbIsMultiplayer || !(player.isOnLevel(16) || player.isOnArenaLevel());

BIN
assets/fonts/30-e0.clx

Binary file not shown.
Loading…
Cancel
Save