Allow custom status bars to override notifications, centered prints and chat prompt.

This commit is contained in:
Mari the Deer 2019-08-16 15:45:49 +02:00
commit 14dc288f22
4 changed files with 75 additions and 11 deletions

View file

@ -773,6 +773,19 @@ void FNotifyBuffer::AddString(int printlevel, FString source)
con_notifylines == 0)
return;
// [MK] allow the status bar to take over notify printing
if (StatusBar != nullptr)
{
IFVIRTUALPTR(StatusBar, DBaseStatusBar, ProcessNotify)
{
VMValue params[] = { (DObject*)StatusBar, printlevel, &source };
int rv;
VMReturn ret(&rv);
VMCall(func, params, countof(params), &ret, 1);
if (!!rv) return;
}
}
width = DisplayWidth / active_con_scaletext(generic_ui);
FFont *font = generic_ui ? NewSmallFont : AlternativeSmallFont;
@ -960,6 +973,12 @@ int DPrintf (int level, const char *format, ...)
void C_FlushDisplay ()
{
NotifyStrings.Clear();
if (StatusBar == nullptr) return;
IFVIRTUALPTR(StatusBar, DBaseStatusBar, FlushNotify)
{
VMValue params[] = { (DObject*)StatusBar };
VMCall(func, params, countof(params), nullptr, 1);
}
}
void C_AdjustBottom ()
@ -1740,6 +1759,17 @@ void C_MidPrint (FFont *font, const char *msg, bool bold)
if (StatusBar == nullptr || screen == nullptr)
return;
// [MK] allow the status bar to take over MidPrint
IFVIRTUALPTR(StatusBar, DBaseStatusBar, ProcessMidPrint)
{
FString msgstr = msg;
VMValue params[] = { (DObject*)StatusBar, font, &msg, bold };
int rv;
VMReturn ret(&rv);
VMCall(func, params, countof(params), &ret, 1);
if (!!rv) return;
}
if (msg != nullptr)
{
auto color = (EColorRange)PrintColors[bold? PRINTLEVELS+1 : PRINTLEVELS];