- backend update

This commit is contained in:
Christoph Oelckers 2020-10-25 09:20:26 +01:00
parent 570897005c
commit 273ad5e133
8 changed files with 81 additions and 71 deletions

View file

@ -77,9 +77,6 @@ void C_HideConsole (void);
void C_AdjustBottom (void); void C_AdjustBottom (void);
void C_FlushDisplay (void); void C_FlushDisplay (void);
class FFont;
void C_MidPrint (FFont *font, const char *message, bool bold = false);
bool C_Responder (event_t *ev); bool C_Responder (event_t *ev);
void C_SetNotifyFontScale(double scale); void C_SetNotifyFontScale(double scale);

View file

@ -26,6 +26,7 @@ struct SystemCallbacks
int (*GetGender)(); int (*GetGender)();
void (*MenuClosed)(); void (*MenuClosed)();
bool (*CheckMenudefOption)(const char* opt); bool (*CheckMenudefOption)(const char* opt);
void (*ConsoleToggled)(int state);
}; };
extern SystemCallbacks sysCallbacks; extern SystemCallbacks sysCallbacks;

View file

@ -637,18 +637,6 @@ DEFINE_ACTION_FUNCTION(DOptionMenuItemCommand, DoCommand)
return 0; return 0;
} }
DEFINE_ACTION_FUNCTION(_Console, MidPrint)
{
PARAM_PROLOGUE;
PARAM_POINTER(fnt, FFont);
PARAM_STRING(text);
PARAM_BOOL(bold);
const char* txt = text[0] == '$' ? GStrings(&text[1]) : text.GetChars();
C_MidPrint(fnt, txt, bold);
return 0;
}
DEFINE_ACTION_FUNCTION(_Console, HideConsole) DEFINE_ACTION_FUNCTION(_Console, HideConsole)
{ {
C_HideConsole(); C_HideConsole();

View file

@ -1012,37 +1012,25 @@ void C_DrawConsole ()
void C_FullConsole () void C_FullConsole ()
{ {
/*
if (hud_toggled)
D_ToggleHud();
if (demoplayback)
G_CheckDemoStatus ();
D_QuitNetGame ();
advancedemo = false;
*/
ConsoleState = c_down; ConsoleState = c_down;
HistPos = NULL; HistPos = NULL;
TabbedLast = false; TabbedLast = false;
TabbedList = false; TabbedList = false;
if (gamestate != GS_STARTUP) gamestate = GS_FULLCONSOLE;
{
gamestate = GS_FULLCONSOLE;
Mus_Stop();
}
C_AdjustBottom (); C_AdjustBottom ();
} }
void C_ToggleConsole () void C_ToggleConsole ()
{ {
int togglestate;
if (gamestate == GS_INTRO) // blocked if (gamestate == GS_INTRO) // blocked
{ {
return; return;
} }
if (gamestate == GS_MENUSCREEN) if (gamestate == GS_MENUSCREEN)
{ {
gamestate = GS_FULLCONSOLE; gameaction = ga_fullconsole;
C_FullConsole(); togglestate = c_down;
} }
else if (!chatmodeon && (ConsoleState == c_up || ConsoleState == c_rising) && menuactive == MENU_Off) else if (!chatmodeon && (ConsoleState == c_up || ConsoleState == c_rising) && menuactive == MENU_Off)
{ {
@ -1050,13 +1038,17 @@ void C_ToggleConsole ()
HistPos = NULL; HistPos = NULL;
TabbedLast = false; TabbedLast = false;
TabbedList = false; TabbedList = false;
togglestate = c_falling;
} }
else if (gamestate != GS_FULLCONSOLE && gamestate != GS_STARTUP) else if (gamestate != GS_FULLCONSOLE && gamestate != GS_STARTUP)
{ {
ConsoleState = c_rising; ConsoleState = c_rising;
C_FlushDisplay (); C_FlushDisplay();
togglestate = c_rising;
} }
else return;
// This must be done as an event callback because the client code does not control the console toggling.
if (sysCallbacks.ConsoleToggled) sysCallbacks.ConsoleToggled(togglestate);
} }
void C_HideConsole () void C_HideConsole ()
@ -1500,40 +1492,3 @@ CCMD(toggleconsole)
C_ToggleConsole(); C_ToggleConsole();
} }
/* Printing in the middle of the screen */
CVAR(Float, con_midtime, 3.f, CVAR_ARCHIVE)
const char *console_bar = "----------------------------------------";
void C_MidPrint (FFont *font, const char *msg, bool bold)
{
#if 0 // The Build engine cannot do this at the moment. Q: Implement and redirect some messages here?
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, &msgstr, 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];
Printf(PRINT_HIGH|PRINT_NONOTIFY, TEXTCOLOR_ESCAPESTR "%c%s\n%s\n%s\n", color, console_bar, msg, console_bar);
StatusBar->AttachMessage (Create<DHUDMessage>(font, msg, 1.5f, 0.375f, 0, 0, color, con_midtime), MAKE_ID('C','N','T','R'));
}
else
{
StatusBar->DetachMessage (MAKE_ID('C','N','T','R'));
}
#endif
}

View file

@ -43,6 +43,8 @@ enum gameaction_t : int
ga_nextlevel, // Actually start the next level. ga_nextlevel, // Actually start the next level.
ga_loadgamehidecon, ga_loadgamehidecon,
ga_newgamenostopsound, // start a new game ga_newgamenostopsound, // start a new game
ga_fullconsole,
}; };
extern gamestate_t gamestate; extern gamestate_t gamestate;
extern gameaction_t gameaction; extern gameaction_t gameaction;

View file

@ -244,6 +244,12 @@ static void GameTicker()
gamestate = GS_INTERMISSION; gamestate = GS_INTERMISSION;
break; break;
case ga_fullconsole:
C_FullConsole();
Mus_Stop();
gameaction = ga_nothing;
break;
// for later // for later
// case ga_recordgame, // start a new demo recording (later) // case ga_recordgame, // start a new demo recording (later)
// case ga_loadgameplaydemo, // load a savegame and play a demo. // case ga_loadgameplaydemo, // load a savegame and play a demo.

View file

@ -493,7 +493,6 @@ struct Font native
struct Console native struct Console native
{ {
native static void HideConsole(); native static void HideConsole();
native static void MidPrint(Font fontname, string textlabel, bool bold = false);
native static vararg void Printf(string fmt, ...); native static vararg void Printf(string fmt, ...);
} }

View file

@ -1234,3 +1234,65 @@ class OptionMenuItemScaleSlider : OptionMenuItemSlider
} }
//=============================================================================
//
// Flag option by Accensus
//
//=============================================================================
class OptionMenuItemFlagOption : OptionMenuItemOption
{
int mBitShift;
OptionMenuItemFlagOption Init(String label, Name command, Name values, int bitShift, CVar greycheck = null, int center = 0)
{
Super.Init(label, command, values, greycheck, center);
mBitShift = bitShift;
return self;
}
override int GetSelection()
{
int Selection = 0;
int cnt = OptionValues.GetCount(mValues);
if (cnt > 0 && mCVar != null)
{
if (OptionValues.GetTextValue(mValues, 0).Length() == 0)
{
int CurrentFlags = mCVar.GetInt();
for (int i = 0; i < cnt; i++)
{
int OptionValue = int(OptionValues.GetValue(mValues, i));
if (CurrentFlags & (OptionValue << mBitShift))
{
Selection = i;
break;
}
}
}
}
return Selection;
}
override void SetSelection(int Selection)
{
int cnt = OptionValues.GetCount(mValues);
if (cnt > 0 && mCVar != null)
{
if (OptionValues.GetTextValue(mValues, 0).Length() == 0)
{
int OptionValue = int(OptionValues.GetValue(mValues, Selection));
int CurrentFlags = mCVar.GetInt();
switch (OptionValue)
{
case 0: CurrentFlags &= ~(1 << mBitShift); break;
case 1: CurrentFlags |= (1 << mBitShift); break;
}
mCVar.SetInt(CurrentFlags);
}
}
}
}