Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu text revision #3902

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMake/Assets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ set(devilutionx_assets
fonts/30-03.clx
fonts/30-04.clx
fonts/30-20.clx
fonts/30-e0.clx
fonts/42-00.clx
fonts/42-01.clx
fonts/42-02.clx
Expand Down
58 changes: 58 additions & 0 deletions Source/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "panels/spell_book.hpp"
#include "panels/spell_icons.hpp"
#include "panels/spell_list.hpp"
#include "pfile.h"
#include "playerdat.hpp"
#include "qol/stash.h"
#include "qol/xpbar.h"
Expand Down Expand Up @@ -1180,6 +1181,19 @@ void CheckMainPanelButtonUp()
DoAutoMap();
break;
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;
gamemenu_handle_previous();
gamemenuOff = false;
Expand Down Expand Up @@ -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)
{
const int dialogX = 30;
Expand Down
1 change: 1 addition & 0 deletions Source/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ void CheckChrBtns();
void ReleaseChrBtns(bool addAllStatPoints);
void DrawDurIcon(const Surface &out);
void RedBack(const Surface &out);
void DrawDeathText(const Surface &out);
void DrawSpellBook(const Surface &out);
void DrawGoldSplit(const Surface &out);
void control_drop_gold(SDL_Keycode vkey);
Expand Down
14 changes: 13 additions & 1 deletion Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,17 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
}

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) {
return;
}
Expand All @@ -506,7 +517,8 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
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()) {
LastMouseButtonAction = MouseActionType::None;
gamemenu_on();
Expand Down
7 changes: 4 additions & 3 deletions Source/engine/render/scrollrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,14 +1262,15 @@ void DrawView(const Surface &out, Point startPosition)
if (ChatLogFlag) {
DrawChatLog(out);
}
if (IsDiabloMsgAvailable()) {
DrawDiabloMsg(out.subregionY(0, out.h() - GetMainPanel().size.height));
}
if (MyPlayerIsDead) {
RedBack(out);
DrawDeathText(out);
} else if (PauseMode != 0) {
gmenu_draw_pause(out);
}
if (IsDiabloMsgAvailable()) {
DrawDiabloMsg(out.subregionY(0, out.h() - GetMainPanel().size.height));
}

DrawControllerModifierHints(out);
DrawPlrMsg(out);
Expand Down
39 changes: 19 additions & 20 deletions Source/gamemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,23 @@ void GamemenuSpeed(bool bActivate);
/** Contains the game menu items of the single player menu. */
TMenuItem sgSingleMenu[] = {
// clang-format off
// dwFlags, pszStr, fnMenu
{ GMENU_ENABLED, N_("Save Game"), &gamemenu_save_game },
{ GMENU_ENABLED, N_("Options"), &GamemenuOptions },
{ GMENU_ENABLED, N_("New Game"), &GamemenuNewGame },
{ GMENU_ENABLED, N_("Load Game"), &gamemenu_load_game },
{ GMENU_ENABLED, N_("Quit Game"), &gamemenu_quit_game },
{ GMENU_ENABLED, nullptr, nullptr }
// dwFlags, pszStr, fnMenu
{ GMENU_ENABLED, N_("Options"), &GamemenuOptions },
{ GMENU_ENABLED, N_("Save Game"), &gamemenu_save_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, nullptr, nullptr },
// clang-format on
};
/** Contains the game menu items of the multi player menu. */
TMenuItem sgMultiMenu[] = {
// clang-format off
// dwFlags, pszStr, fnMenu
{ GMENU_ENABLED, N_("Options"), &GamemenuOptions },
{ GMENU_ENABLED, N_("New Game"), &GamemenuNewGame },
{ GMENU_ENABLED, N_("Restart In Town"), &GamemenuRestartTown },
{ GMENU_ENABLED, N_("Quit Game"), &gamemenu_quit_game },
{ GMENU_ENABLED, nullptr, nullptr },
// dwFlags, pszStr, fnMenu
{ GMENU_ENABLED, N_("Options"), &GamemenuOptions },
{ GMENU_ENABLED, N_("Exit to Main Menu"), &GamemenuNewGame },
{ GMENU_ENABLED, N_("Quit Game"), &gamemenu_quit_game },
{ GMENU_ENABLED, nullptr, nullptr },
// clang-format on
};
TMenuItem sgOptionsMenu[] = {
Expand All @@ -88,18 +87,13 @@ const char *const SoundToggleNames[] = {

void GamemenuUpdateSingle()
{
sgSingleMenu[3].setEnabled(gbValidSaveFile);
sgSingleMenu[2].setEnabled(gbValidSaveFile);

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

sgSingleMenu[0].setEnabled(enable);
}

void GamemenuUpdateMulti()
{
sgMultiMenu[2].setEnabled(MyPlayerIsDead);
}

void GamemenuPrevious(bool /*bActivate*/)
{
gamemenu_on();
Expand Down Expand Up @@ -286,6 +280,11 @@ void GamemenuSpeed(bool bActivate)

} // namespace

void gamemenu_exit_game(bool bActivate)
{
GamemenuNewGame(bActivate);
}

void gamemenu_quit_game(bool bActivate)
{
GamemenuNewGame(bActivate);
Expand Down Expand Up @@ -368,7 +367,7 @@ void gamemenu_on()
if (!gbIsMultiplayer) {
gmenu_set_items(sgSingleMenu, GamemenuUpdateSingle);
} else {
gmenu_set_items(sgMultiMenu, GamemenuUpdateMulti);
gmenu_set_items(sgMultiMenu, nullptr);
}
PressEscKey();
}
Expand Down
1 change: 1 addition & 0 deletions Source/gamemenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace devilution {
void gamemenu_on();
void gamemenu_off();
void gamemenu_handle_previous();
void gamemenu_exit_game(bool bActivate);
void gamemenu_quit_game(bool bActivate);
void gamemenu_load_game(bool bActivate);
void gamemenu_save_game(bool bActivate);
Expand Down
4 changes: 1 addition & 3 deletions Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1037,9 +1037,6 @@ bool DoDeath(Player &player)
dFlags[player.position.tile.x][player.position.tile.y] |= DungeonFlag::DeadPlayer;
} else if (&player == MyPlayer && player.AnimInfo.tickCounterOfCurrentFrame == 30) {
MyPlayerIsDead = true;
if (!gbIsMultiplayer) {
gamemenu_on();
}
}
}

Expand Down Expand Up @@ -2619,6 +2616,7 @@ StartPlayerKill(Player &player, DeathReason deathReason)

if (&player == MyPlayer) {
NetSendCmdParam1(true, CMD_PLRDEAD, static_cast<uint16_t>(deathReason));
gamemenu_off();
}

const bool dropGold = !gbIsMultiplayer || !(player.isOnLevel(16) || player.isOnArenaLevel());
Expand Down
Binary file added assets/fonts/30-e0.clx
Binary file not shown.
Loading