diff --git a/src/common/menu/menu.h b/src/common/menu/menu.h index bad3406e94..aaeecbcd44 100644 --- a/src/common/menu/menu.h +++ b/src/common/menu/menu.h @@ -94,6 +94,7 @@ public: int mVirtWidth; int mVirtHeight; bool mCustomSizeSet; + bool mForceList; void Reset(); }; diff --git a/src/common/menu/menudef.cpp b/src/common/menu/menudef.cpp index 0ef4e4fe17..1b25fcdad1 100644 --- a/src/common/menu/menudef.cpp +++ b/src/common/menu/menudef.cpp @@ -419,6 +419,10 @@ static void DoParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc, bool &s } } } + else if (sc.Compare("ForceList")) + { + desc->mForceList = true; + } else { // all item classes from which we know that they support sized scaling. @@ -759,6 +763,7 @@ static void ParseListMenu(FScanner &sc) desc->mFromEngine = fileSystem.GetFileContainer(sc.LumpNum) == 0; // flags menu if the definition is from the IWAD. desc->mVirtWidth = -2; desc->mCustomSizeSet = false; + desc->mForceList = false; if (DefaultListMenuSettings->mCustomSizeSet) { desc->mVirtHeight = DefaultListMenuSettings->mVirtHeight; @@ -1028,13 +1033,19 @@ static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc, int i { auto &args = func->Variants[0].Proto->ArgumentTypes; TArray params; + int start = 1; params.Push(0); + if (args.Size() > 1 && args[1] == NewPointer(PClass::FindClass("OptionMenuDescriptor"))) + { + params.Push(desc); + start = 2; + } auto TypeCVar = NewPointer(NewStruct("CVar", nullptr, true)); // Note that this array may not be reallocated so its initial size must be the maximum possible elements. TArray strings(args.Size()); - for (unsigned i = 1; i < args.Size(); i++) + for (unsigned i = start; i < args.Size(); i++) { sc.MustGetString(); if (args[i] == TypeString) @@ -1050,6 +1061,24 @@ static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc, int i { params.Push(V_GetColor(sc)); } + else if (args[i] == TypeFont) + { + auto f = V_GetFont(sc.String); + if (f == nullptr) + { + sc.ScriptError("Unknown font %s", sc.String); + } + params.Push(f); + } + else if (args[i] == TypeTextureID) + { + auto f = TexMan.CheckForTexture(sc.String, ETextureType::MiscPatch); + if (!f.Exists()) + { + sc.ScriptMessage("Unknown texture %s", sc.String); + } + params.Push(f.GetIndex()); + } else if (args[i]->isIntCompatible()) { char *endp; @@ -1228,6 +1257,16 @@ static void ParseImageScrollerBody(FScanner& sc, DImageScrollerDescriptor* desc) ParseImageScrollerBody(sc, desc); } } + else if (sc.Compare("Class")) + { + sc.MustGetString(); + PClass* cls = PClass::FindClass(sc.String); + if (cls == nullptr || !cls->IsDescendantOf("ImageScrollerMenu")) + { + sc.ScriptError("Unknown menu class '%s'", sc.String); + } + desc->mClass = cls; + } else if (sc.Compare("animatedtransition")) { desc->mAnimatedTransition = true; @@ -1300,6 +1339,24 @@ static void ParseImageScrollerBody(FScanner& sc, DImageScrollerDescriptor* desc) { params.Push(V_GetColor(sc)); } + else if (args[i] == TypeFont) + { + auto f = V_GetFont(sc.String); + if (f == nullptr) + { + sc.ScriptError("Unknown font %s", sc.String); + } + params.Push(f); + } + else if (args[i] == TypeTextureID) + { + auto f = TexMan.CheckForTexture(sc.String, ETextureType::MiscPatch); + if (!f.Exists()) + { + sc.ScriptMessage("Unknown texture %s", sc.String); + } + params.Push(f.GetIndex()); + } else if (args[i]->isIntCompatible()) { char* endp; diff --git a/src/menu/doommenu.cpp b/src/menu/doommenu.cpp index d7b57c84ab..82f4ac94bf 100644 --- a/src/menu/doommenu.cpp +++ b/src/menu/doommenu.cpp @@ -616,9 +616,9 @@ void M_StartupEpisodeMenu(FNewGameStartup *gs) // center the menu on the screen if the top space is larger than the bottom space int totalheight = posy + AllEpisodes.Size() * spacing - topy; - if (totalheight < 190 || AllEpisodes.Size() == 1) + if (ld->mForceList || totalheight < 190 || AllEpisodes.Size() == 1) { - int newtop = (200 - totalheight) / 2; + int newtop = max(10, 200 - totalheight) / 2; int topdelta = newtop - topy; if (topdelta < 0) { @@ -760,9 +760,9 @@ static void BuildPlayerclassMenu() ld->mAutoselect = ld->mItems.Push(it); success = true; } - else if (totalheight <= 190) + else if (ld->mForceList || totalheight <= 190) { - int newtop = (200 - totalheight + topy) / 2; + int newtop = (max(10, 200 - totalheight) + topy) / 2; int topdelta = newtop - topy; if (topdelta < 0) { @@ -1146,9 +1146,9 @@ void M_StartupSkillMenu(FNewGameStartup *gs) // center the menu on the screen if the top space is larger than the bottom space int totalheight = posy + MenuSkills.Size() * spacing - topy; - if (totalheight < 190 || MenuSkills.Size() == 1) + if (ld->mForceList || totalheight < 190 || MenuSkills.Size() == 1) { - int newtop = (200 - totalheight) / 2; + int newtop = max(10, 200 - totalheight) / 2; int topdelta = newtop - topy; if (topdelta < 0) {