- Added skill selection for user maps.

This commit is contained in:
Christoph Oelckers 2021-12-27 09:26:56 +01:00
parent 85e0198b65
commit eaac9de1a4
3 changed files with 29 additions and 18 deletions

View file

@ -16,6 +16,7 @@ struct spritetype;
struct sectortype;
struct tspritetype;
class DCoreActor;
struct MapRecord;
struct GameStats
{
@ -27,6 +28,7 @@ struct GameStats
struct FNewGameStartup
{
MapRecord* Map;
int Episode;
int Level;
int Skill;

View file

@ -90,17 +90,24 @@ FNewGameStartup NewGameStartupInfo;
static bool DoStartGame(FNewGameStartup& gs)
{
auto vol = FindVolume(gs.Episode);
if (!vol) return false;
if (isShareware() && (vol->flags & VF_SHAREWARELOCK))
MapRecord* map;
if (gs.Map == nullptr)
{
M_StartMessage(GStrings("SHAREWARELOCK"), 1, NAME_None);
return false;
}
auto vol = FindVolume(gs.Episode);
if (!vol) return false;
if (isShareware() && (vol->flags & VF_SHAREWARELOCK))
{
M_StartMessage(GStrings("SHAREWARELOCK"), 1, NAME_None);
return false;
}
map = FindMapByName(vol->startmap);
if (!map) return false;
}
else
map = gs.Map;
auto map = FindMapByName(vol->startmap);
if (!map) return false;
soundEngine->StopAllChannels();
gi->StartGame(gs); // play game specific effects (like Duke/RR/SW's voice lines when starting a game.)
@ -132,9 +139,13 @@ bool M_SetSpecialMenu(FName& menu, int param)
break;
case NAME_Skillmenu:
// sent from the episode menu
NewGameStartupInfo.Episode = param;
NewGameStartupInfo.Level = 0;
// sent from the episode or user map menu
if (param != INT_MAX)
{
NewGameStartupInfo.Map = nullptr;
NewGameStartupInfo.Episode = param;
NewGameStartupInfo.Level = 0;
}
NewGameStartupInfo.Skill = gDefaultSkill;
return true;

View file

@ -253,8 +253,6 @@ DEFINE_ACTION_FUNCTION(_UserMapMenu, DrawPreview)
return 0;
}
void DoStartMap(FString mapname);
DEFINE_ACTION_FUNCTION(_UsermapMenu, StartMap)
{
PARAM_PROLOGUE;
@ -264,9 +262,9 @@ DEFINE_ACTION_FUNCTION(_UsermapMenu, StartMap)
{
ThrowAbortException(X_OTHER, "Attempt to start user map outside of menu code");
}
DoStartMap(entry->filename);
M_ClearMenus();
UnloadMapPreviews(&root);
NewGameStartupInfo.Episode = -1;
NewGameStartupInfo.Level = -1;
NewGameStartupInfo.Map = SetupUserMap(entry->filename, g_gameType & GAMEFLAG_DUKE ? "dethtoll.mid" : nullptr);
M_SetMenu(NAME_Skillmenu, INT_MAX);
return 0;
}