- fixed: The skill menu did not remember its last selection.

This commit is contained in:
Christoph Oelckers 2022-04-12 00:04:45 +02:00
parent 36245ae598
commit f3d557bcf5

View file

@ -81,6 +81,7 @@ void I_WaitVBL(int count);
FNewGameStartup NewGameStartupInfo; FNewGameStartup NewGameStartupInfo;
int LastSkill = -1;
bool M_SetSpecialMenu(FName& menu, int param) bool M_SetSpecialMenu(FName& menu, int param)
@ -147,6 +148,7 @@ bool M_SetSpecialMenu(FName& menu, int param)
{ {
// sent from the skill menu for a skill that needs to be confirmed // sent from the skill menu for a skill that needs to be confirmed
NewGameStartupInfo.Skill = param; NewGameStartupInfo.Skill = param;
LastSkill = param;
const char *msg = AllSkills[param].MustConfirmText; const char *msg = AllSkills[param].MustConfirmText;
if (*msg==0) msg = GStrings("NIGHTMARE"); if (*msg==0) msg = GStrings("NIGHTMARE");
@ -157,6 +159,7 @@ bool M_SetSpecialMenu(FName& menu, int param)
case NAME_Startgame: case NAME_Startgame:
// sent either from skill menu or confirmation screen. Skill gets only set if sent from skill menu // sent either from skill menu or confirmation screen. Skill gets only set if sent from skill menu
// Now we can finally start the game. Ugh... // Now we can finally start the game. Ugh...
LastSkill = param;
NewGameStartupInfo.Skill = param; NewGameStartupInfo.Skill = param;
[[fallthrough]]; [[fallthrough]];
case NAME_StartgameConfirmed: case NAME_StartgameConfirmed:
@ -1048,7 +1051,7 @@ void M_StartupSkillMenu(FNewGameStartup *gs)
} }
if (MenuSkills.Size() == 0) I_Error("No valid skills for menu found. At least one must be defined."); if (MenuSkills.Size() == 0) I_Error("No valid skills for menu found. At least one must be defined.");
int defskill = DefaultSkill; int defskill = LastSkill > -1? LastSkill : DefaultSkill; // use the last selected skill, if available.
if ((unsigned int)defskill >= MenuSkills.Size()) if ((unsigned int)defskill >= MenuSkills.Size())
{ {
defskill = SkillIndices[(MenuSkills.Size() - 1) / 2]; defskill = SkillIndices[(MenuSkills.Size() - 1) / 2];