mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 14:51:40 +00:00
Extended MENUDEF Functionality
*Added Font and TextureID types to Option and Image Scroller items (List items already have these) *Added "Class" instruction for Image Scrollers *Added ability for Option items to read in their OptionMenuDescriptor (List and Image Scroller items already have this) *Added "ForceList" instruction for Lists so that skill, playerclass, and episode menus don't get overridden
This commit is contained in:
parent
63c2d93033
commit
599b00f2ea
3 changed files with 65 additions and 7 deletions
|
@ -94,6 +94,7 @@ public:
|
|||
int mVirtWidth;
|
||||
int mVirtHeight;
|
||||
bool mCustomSizeSet;
|
||||
bool mForceList;
|
||||
|
||||
void Reset();
|
||||
};
|
||||
|
|
|
@ -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<VMValue> 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<FString> 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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue