- allow specifying a custom class for message box display.

This commit is contained in:
Christoph Oelckers 2017-04-14 23:28:54 +02:00
commit edebea4f8d
11 changed files with 19 additions and 6 deletions

View file

@ -371,6 +371,7 @@ void FMapInfoParser::ParseGameInfo()
GAMEINFOKEY_STRING_STAMPED(statusbarclass, "statusbarclass", statusbarclassfile)
GAMEINFOKEY_MUSIC(intermissionMusic, intermissionOrder, "intermissionMusic")
GAMEINFOKEY_STRING(CursorPic, "CursorPic")
GAMEINFOKEY_STRING(MessageBoxClass, "MessageBoxClass")
GAMEINFOKEY_BOOL(noloopfinalemusic, "noloopfinalemusic")
GAMEINFOKEY_BOOL(drawreadthis, "drawreadthis")
GAMEINFOKEY_BOOL(swapmenu, "swapmenu")

View file

@ -152,6 +152,7 @@ struct gameinfo_t
int statusbarfile = -1;
FName statusbarclass;
int statusbarclassfile = -1;
FName MessageBoxClass;
FName backpacktype;
FString intermissionMusic;
int intermissionOrder;

View file

@ -66,14 +66,18 @@ DEFINE_ACTION_FUNCTION(DMessageBoxMenu, CallHandler)
DMenu *CreateMessageBoxMenu(DMenu *parent, const char *message, int messagemode, bool playsound, FName action = NAME_None, hfunc handler = nullptr)
{
auto c = PClass::FindClass("MessageBoxMenu");
auto c = PClass::FindClass(gameinfo.MessageBoxClass);
if (!c->IsDescendantOf(NAME_MessageBoxMenu)) c = PClass::FindClass(NAME_MessageBoxMenu);
auto p = c->CreateNew();
FString namestr = message;
VMValue params[] = { p, parent, &namestr, messagemode, playsound, action.GetIndex(), reinterpret_cast<void*>(handler) };
auto f = dyn_cast<PFunction>(c->FindSymbol("Init", false));
VMCall(f->Variants[0].Implementation, params, countof(params), nullptr, 0);
return (DMenu*)p;
IFVIRTUALPTRNAME(p, NAME_MessageBoxMenu, Init)
{
VMValue params[] = { p, parent, &namestr, messagemode, playsound, action.GetIndex(), reinterpret_cast<void*>(handler) };
VMCall(func, params, countof(params), nullptr, 0);
return (DMenu*)p;
}
return nullptr;
}
//=============================================================================

View file

@ -912,3 +912,4 @@ xx(StaticArray)
xx(DynArray)
xx(Struct)
xx(ReflectType)
xx(MessageBoxMenu)