- quote cleanup.

This commit is contained in:
Christoph Oelckers 2020-06-30 22:53:15 +02:00
parent 8aaadfad1b
commit 2e98b2f8da
23 changed files with 50 additions and 296 deletions

View file

@ -156,7 +156,6 @@ struct GameInterface : ::GameInterface
void DrawMenuCaption(const DVector2& origin, const char* text) override;
bool SaveGame(FSaveGameNode*) override;
bool LoadGame(FSaveGameNode*) override;
void DoPrintMessage(int prio, const char*) override;
void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool bg) override;
void QuitToTitle() override;
FString GetCoordString() override;

View file

@ -2877,12 +2877,6 @@ void viewSetMessage(const char *pMessage, const int pal, const MESSAGE_PRIORITY
gGameMessageMgr.Add(pMessage, 15, pal, priority);
}
void GameInterface::DoPrintMessage(int prio, const char*msg)
{
viewSetMessage(msg, 0, prio == PRINT_LOW ? MESSAGE_PRIORITY_PICKUP : prio == PRINT_MEDIUM ? MESSAGE_PRIORITY_NORMAL : MESSAGE_PRIORITY_SYSTEM);
}
void viewDisplayMessage(void)
{
gGameMessageMgr.Display();

View file

@ -134,6 +134,7 @@ CUSTOM_CVAR(Int, con_scaletext, 2, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // Scale not
{
if (self < 0) self = 0;
}
CVAR(Bool, con_pulseText, true, CVAR_ARCHIVE)
CUSTOM_CVAR(Int, con_scale, 0, CVAR_ARCHIVE)
{
@ -1097,6 +1098,10 @@ void FNotifyBuffer::Draw()
if (j > 0)
{
double alpha = (j < NOTIFYFADETIME) ? 1. * j / NOTIFYFADETIME : 1;
if (con_pulseText)
{
alpha *= 0.7 + 0.3 * sin(I_msTime() / 100.);
}
if (notify.PrintLevel >= PRINTLEVELS)
color = CR_UNTRANSLATED;

View file

@ -1076,7 +1076,7 @@ CCMD (togglemsg)
const char *statestr = argv.argc() <= 2? "*" : argv[2];
if (*statestr == '*')
{
gi->PrintMessage(PRINT_MEDIUM, "\"%s\" = \"%s\"\n", var->GetName(), val.Bool ? "true" : "false");
Printf(PRINT_MEDIUM|PRINT_NOTIFY, "\"%s\" = \"%s\"\n", var->GetName(), val.Bool ? "true" : "false");
}
else
{
@ -1087,7 +1087,7 @@ CCMD (togglemsg)
// Positive means Off/On, negative means On/Off
int quote = state > 0? state + val.Bool : -(state + val.Bool);
auto text = quoteMgr.GetQuote(quote);
if (text) gi->PrintMessage(PRINT_MEDIUM, "%s\n", text);
if (text) Printf(PRINT_MEDIUM|PRINT_NOTIFY, "%s\n", text);
}
}
}

View file

@ -233,22 +233,16 @@ CCMD (togglemessages)
{
if (hud_messages)
{
gi->PrintMessage(PRINT_MEDIUM, "%s\n", quoteMgr.GetQuote(24));
Printf(PRINT_MEDIUM | PRINT_NOTIFY, "%s\n", quoteMgr.GetQuote(24));
hud_messages = false;
}
else
{
hud_messages = true;
gi->PrintMessage(PRINT_MEDIUM, "%s\n", quoteMgr.GetQuote(23));
Printf(PRINT_MEDIUM | PRINT_NOTIFY, "%s\n", quoteMgr.GetQuote(23));
}
}
//{
//Blood::gGameMessageMgr.SetState(self); // this is for terminaing an active message. Cannot be done like this because CVARs are global.
//}
CVARD_NAMED(Int, hud_numbertile, althud_numbertile, 2930, CVAR_ARCHIVE|CVAR_FRONTEND_DUKELIKE, "first tile in alt hud number set")
CVARD_NAMED(Int, hud_numberpal, althud_numberpal, 0, CVAR_ARCHIVE|CVAR_FRONTEND_DUKELIKE, "pal for alt hud numbers")
CVARD_NAMED(Int, hud_shadows, althud_shadows, true, CVAR_ARCHIVE|CVAR_FRONTEND_DUKELIKE, "enable/disable althud shadows")
@ -284,7 +278,7 @@ CCMD(togglemouseaim)
in_mousemode = !in_mousemode;
if (!silentmouseaimtoggle)
{
gi->DoPrintMessage(PRINT_MEDIUM, in_mousemode? GStrings("TXT_MOUSEAIMON") : GStrings("TXT_MOUSEAIMOFF"));
Printf(PRINT_MEDIUM|PRINT_NOTIFY, in_mousemode? GStrings("TXT_MOUSEAIMON") : GStrings("TXT_MOUSEAIMOFF"));
}
}

View file

@ -76,15 +76,6 @@ struct GameInterface
virtual bool SaveGame(FSaveGameNode*) { return false; }
virtual bool LoadGame(FSaveGameNode*) { return false; }
virtual bool CleanupForLoad() { return true; }
virtual void DoPrintMessage(int prio, const char*) {}
void PrintMessage(int prio, const char*fmt, ...)
{
va_list ap;
va_start(ap, fmt);
FString f;
f.VFormat(fmt, ap);
DoPrintMessage(prio, f);
}
virtual void DrawPlayerSprite(const DVector2& origin, bool onteam) {}
virtual void QuitToTitle() {}
virtual void SetAmbience(bool on) {}

View file

@ -240,7 +240,6 @@ struct GameInterface : ::GameInterface
void DrawMenuCaption(const DVector2& origin, const char* text) override;
bool SaveGame(FSaveGameNode*) override;
bool LoadGame(FSaveGameNode*) override;
void DoPrintMessage(int prio, const char*) override;
void DrawPlayerSprite(const DVector2& origin, bool onteam) override;
void QuitToTitle() override;
FString GetCoordString() override;

View file

@ -343,30 +343,4 @@ void P_DoQuote(int32_t q, DukePlayer_t *p)
}
}
void GameInterface::DoPrintMessage(int prio, const char* t)
{
auto p = g_player[myconnectindex].ps; // text quotes always belong to the local player.
int32_t cq = 0;
if (hud_messages == 0 || !(p->gm & MODE_GAME))
return;
if (p->fta > 0)
if (p->ftq == QUOTE_RESERVED || p->ftq == QUOTE_RESERVED2) return;
if (p == g_player[screenpeek].ps)
Printf(prio | PRINT_NOTIFY, cq ? TEXTCOLOR_TAN "%s\n" : "%s\n", t);
if (hud_messages == 1)
{
p->fta = 100;
p->ftq = -32768;
text_quote = t;
pub = NUMPAGES;
pus = NUMPAGES;
}
}
END_EDUKE_NS

View file

@ -221,7 +221,6 @@ struct GameInterface : ::GameInterface
void DrawMenuCaption(const DVector2& origin, const char* text) override;
bool SaveGame(FSaveGameNode*) override;
bool LoadGame(FSaveGameNode*) override;
void DoPrintMessage(int prio, const char* text) override;
void DrawPlayerSprite(const DVector2& origin, bool onteam) override;
void QuitToTitle() override;
FString GetCoordString() override;

View file

@ -251,14 +251,11 @@ void G_GameExit(const char *msg) ATTRIBUTE((noreturn));
void G_GameQuit(void);
void G_HandleLocalKeys(void);
void G_HandleSpecialKeys(void);
void G_PrintGameQuotes(int32_t snum);
//void G_SE40(int32_t smoothratio);
void G_UpdatePlayerFromMenu(void);
void P_DoQuote(int32_t q,DukePlayer_t *p);
inline void FTA(int q, DukePlayer_t* p)
{
P_DoQuote(q, p);
}
void FTA(int q, struct player_struct* p);
void P_SetGamePalette(DukePlayer_t* player, uint32_t palid, ESetPalFlags flags);
void OnMotorcycle(DukePlayer_t *pPlayer, int spriteNum);
void OffMotorcycle(DukePlayer_t *pPlayer);

View file

@ -168,6 +168,36 @@ void genspriteremaps(void)
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void FTA(int q, struct player_struct* p)
{
if (hud_messages == 0 || q < 0 || !(p->gm & MODE_GAME))
return;
if (p->ftq != q)
{
if (q == 13) p->ftq = q;
auto qu = quoteMgr.GetQuote(q);
if (p == g_player[screenpeek].ps && qu[0] != '\0')
{
if (q >= 70 && q <= 72 && hud_messages == 2)
{
// Todo: redirect this to a centered message (these are "need a key" messages)
}
else
{
int printlevel = hud_messages == 1 ? PRINT_MEDIUM : PRINT_MEDIUM | PRINT_NOTIFY;
Printf(printlevel, "%s\n", qu);
}
}
}
}
END_DUKE_NS

View file

@ -979,7 +979,6 @@ int parse(void)
ps[g_p].pals.f = 0;
ps[g_p].footprintcount = 0;
ps[g_p].weapreccnt = 0;
ps[g_p].fta = 0;
ps[g_p].ftq = 0;
ps[g_p].posxv = ps[g_p].posyv = 0;
if (!isRR()) ps[g_p].rotscrnang = 0;

View file

@ -214,7 +214,7 @@ typedef struct player_struct {
int16_t wackedbyactor, pyoff, opyoff;
int16_t newowner, jumping_counter, airleft;
int16_t fta, ftq, access_wallnum, access_spritenum;
int16_t /*fta,*/ ftq, access_wallnum, access_spritenum;
int16_t got_access, weapon_ang, visibility;
int16_t somethingonplayer, on_crane, i, one_parallax_sectnum;
int16_t random_club_frame, one_eighty_count;

View file

@ -79,7 +79,6 @@ void resetplayerstats(int snum)
p->subweapon = 0;
p->last_full_weapon = 0;
p->ftq = 0;
p->fta = 0;
p->tipincs = 0;
p->buttonpalette = 0;
p->actorsqu =-1;

View file

@ -137,8 +137,6 @@ RECHECK:
}
}
G_PrintGameQuotes(screenpeek);
if (ud.last_camsprite != ud.camerasprite)
ud.last_camsprite = ud.camerasprite;

View file

@ -1950,7 +1950,7 @@ MAIN_LOOP_RESTART:
ototalclock = 0;
lockclock = 0;
g_player[myconnectindex].ps->fta = 0;
g_player[myconnectindex].ps->ftq = 0;
if (ud.warp_on == 1)
{
@ -2176,15 +2176,7 @@ int G_DoMoveThings(void)
if (playerNum != screenpeek && g_player[playerNum].ps->dead_flag == 0)
{
if (pPlayer->fta == 0 || pPlayer->ftq == QUOTE_RESERVED3)
{
if (ldist(&sprite[pPlayer->i], &sprite[hitData.sprite]) < 9216)
{
quoteMgr.FormatQuote(QUOTE_RESERVED3, "%s", &g_player[playerNum].user_name[0]);
pPlayer->fta = 12, pPlayer->ftq = QUOTE_RESERVED3;
}
}
else if (pPlayer->fta > 2) pPlayer->fta -= 3;
Printf(PRINT_HIGH|PRINT_NOTIFY, "%s\n", &g_player[playerNum].user_name[0]);
}
}
}
@ -2238,19 +2230,10 @@ int G_DoMoveThings(void)
if (ud.pause_on == 0)
{
// todo: take HUD timer stuff out of the main game loop
auto p = &ps[i];
if (p->pals.f > 0)
p->pals.f--;
if (p->fta > 0)
{
p->fta--;
if (p->fta == 0)
{
p->ftq = 0;
}
}
if (g_levelTextTime > 0)
g_levelTextTime--;

View file

@ -142,9 +142,9 @@ int32_t G_LoadPlayer(const char *path)
if (status < 0 || h.numplayers != ud.multimode)
{
if (status == -4 || status == -3 || status == 1)
P_DoQuote(QUOTE_SAVE_BAD_VERSION, g_player[myconnectindex].ps);
FTA(QUOTE_SAVE_BAD_VERSION, g_player[myconnectindex].ps);
else if (h.numplayers != ud.multimode)
P_DoQuote(QUOTE_SAVE_BAD_PLAYERS, g_player[myconnectindex].ps);
FTA(QUOTE_SAVE_BAD_PLAYERS, g_player[myconnectindex].ps);
ototalclock = totalclock;
ready2send = 1;
@ -261,7 +261,7 @@ bool G_SavePlayer(FSaveGameNode *sv)
{
Printf("Saved: %s\n", fn.GetChars());
quoteMgr.InitializeQuote(QUOTE_RESERVED4, "Game Saved");
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
FTA(QUOTE_RESERVED4, g_player[myconnectindex].ps);
}
ready2send = 1;
@ -279,7 +279,7 @@ bool GameInterface::LoadGame(FSaveGameNode* sv)
if (g_netServer || ud.multimode > 1)
{
quoteMgr.InitializeQuote(QUOTE_RESERVED4, "Multiplayer Loading Not Yet Supported");
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
FTA(QUOTE_RESERVED4, g_player[myconnectindex].ps);
// g_player[myconnectindex].ps->gm = MODE_GAME;
return false;
@ -298,7 +298,7 @@ bool GameInterface::SaveGame(FSaveGameNode* sv)
if (g_netServer || ud.multimode > 1)
{
quoteMgr.InitializeQuote(QUOTE_RESERVED4, "Multiplayer Saving Not Yet Supported");
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
FTA(QUOTE_RESERVED4, g_player[myconnectindex].ps);
return false;
}
else

View file

@ -814,8 +814,6 @@ void G_DisplayRest(int32_t smoothratio)
G_DrawStatusBar(screenpeek);
G_PrintGameQuotes(screenpeek);
if (ud.show_level_text && hud_showmapname && g_levelTextTime > 1 && !M_Active())
{
int32_t o = 10|16;

View file

@ -193,174 +193,4 @@ int32_t textsc(int32_t sc)
return scale(sc, hud_textscale, 400);
}
#define FTAOPAQUETIME 30
// alpha increments of 8 --> 256 / 8 = 32 --> round up to power of 2 --> 32 --> divide by 2 --> 16 alphatabs required
static inline int32_t textsh(uint32_t t)
{
return (hud_glowingquotes && ((videoGetRenderMode() == REND_CLASSIC && numalphatabs < 15) || t >= FTAOPAQUETIME))
? sintable[(t << 7) & 2047] >> 11
: (sintable[(FTAOPAQUETIME << 7) & 2047] >> 11);
}
// orientation flags depending on time that a quote has still to be displayed
static inline int32_t texto(int32_t t)
{
if (videoGetRenderMode() != REND_CLASSIC || numalphatabs >= 15 || t > 4)
return 0;
if (t > 2)
return 1;
return 1|32;
}
static inline int32_t texta(int32_t t)
{
return 255 - clamp(t<<3, 0, 255);
}
static FORCE_INLINE int32_t text_ypos(void)
{
if (hud_position == 1 && ud.screen_size == 4 && ud.althud == 1)
return 32<<16;
#ifdef GEKKO
return 16<<16;
#elif defined EDUKE32_TOUCH_DEVICES
return 24<<16;
#else
return 1<<16;
#endif
}
static FString text_quote; // To put text into the quote display that does not come from the quote array. (Is it really necessary to implement everything as a hack??? :( )
// this handles both multiplayer and item pickup message type text
// both are passed on to gametext
void G_PrintGameQuotes(int32_t snum)
{
const DukePlayer_t *const ps = g_player[snum].ps;
const int32_t reserved_quote = (ps->ftq >= QUOTE_RESERVED && ps->ftq <= QUOTE_RESERVED3);
// NOTE: QUOTE_RESERVED4 is not included.
int32_t const ybase = (fragbarheight()<<16) + text_ypos();
int32_t height = 0;
int32_t k = ps->fta;
// primary quote
do
{
if (k <= 1)
break;
int32_t y = ybase;
if (reserved_quote)
{
#ifdef SPLITSCREEN_MOD_HACKS
if (!g_fakeMultiMode)
y = 140<<16;
else
y = 70<<16;
#else
y = 140<<16;
#endif
}
int32_t pal = 0;
int32_t x = 160<<16;
#ifdef SPLITSCREEN_MOD_HACKS
if (g_fakeMultiMode)
{
pal = g_player[snum].pcolor;
const int32_t sidebyside = ud.screen_size != 0;
if (sidebyside)
x = snum == 1 ? 240<<16 : 80<<16;
else if (snum == 1)
y += 100<<16;
}
#endif
if (text_quote.IsNotEmpty() && ps->ftq == -32768) height = gametext_(x, y, text_quote, textsh(k), pal, texto(k), texta(k), TEXT_XCENTER).y + (1 << 16);
else height = gametext_(x, y, quoteMgr.GetQuote(ps->ftq), textsh(k), pal, texto(k), texta(k), TEXT_XCENTER).y + (1 << 16);
}
while (0);
// userquotes
int32_t y = ybase;
if (k > 1 && !reserved_quote)
y += k <= 8 ? (height * (k-1))>>3 : height;
}
void P_DoQuote(int32_t q, DukePlayer_t *p)
{
int32_t cq = 0;
if (hud_messages == 0 || q < 0 || !(p->gm & MODE_GAME))
return;
if (q & MAXQUOTES)
{
cq = 1;
q &= ~MAXQUOTES;
}
if (p->fta > 0 && q != QUOTE_RESERVED && q != QUOTE_RESERVED2)
if (p->ftq == QUOTE_RESERVED || p->ftq == QUOTE_RESERVED2) return;
if (p->ftq != q)
{
auto qu = quoteMgr.GetQuote(q);
if (p == g_player[screenpeek].ps && qu[0] != '\0')
{
int printlevel = hud_messages == 1 ? PRINT_MEDIUM : PRINT_MEDIUM | PRINT_NOTIFY;
Printf(printlevel, "%s\n", qu);
}
}
if (hud_messages == 1)
{
p->ftq = q;
p->fta = 100;
pub = NUMPAGES;
pus = NUMPAGES;
}
}
void GameInterface::DoPrintMessage(int prio, const char* t)
{
auto p = g_player[myconnectindex].ps; // text quotes always belong to the local player.
int32_t cq = 0;
if (hud_messages == 0 || !(p->gm & MODE_GAME))
return;
if (p->fta > 0)
if (p->ftq == QUOTE_RESERVED || p->ftq == QUOTE_RESERVED2) return;
if (p == g_player[screenpeek].ps)
{
if (hud_messages == 2) prio |= PRINT_NOTIFY;
Printf(prio, cq ? TEXTCOLOR_TAN "%s\n" : "%s\n", t);
}
if (hud_messages == 1)
{
p->fta = 100;
p->ftq = -32768;
text_quote = t;
pub = NUMPAGES;
pus = NUMPAGES;
}
}
END_DUKE_NS

View file

@ -230,7 +230,6 @@ struct GameInterface : ::GameInterface
void DrawMenuCaption(const DVector2& origin, const char* text) override;
bool SaveGame(FSaveGameNode*) override;
bool LoadGame(FSaveGameNode*) override;
void DoPrintMessage(int prio, const char* text) override;
void DrawPlayerSprite(const DVector2& origin, bool onteam) override;
void QuitToTitle() override;
FString GetCoordString() override;

View file

@ -347,28 +347,4 @@ void P_DoQuote(int32_t q, DukePlayer_t *p)
}
}
void GameInterface::DoPrintMessage(int prio, const char* t)
{
auto p = g_player[myconnectindex].ps; // text quotes always belong to the local player.
int32_t cq = 0;
if (hud_messages == 0 || !(p->gm & MODE_GAME))
return;
if (p->fta > 0)
if (p->ftq == QUOTE_RESERVED || p->ftq == QUOTE_RESERVED2) return;
if (p == g_player[screenpeek].ps)
Printf(prio|PRINT_NOTIFY, cq ? TEXTCOLOR_TAN "%s\n" : "%s\n", t);
if (hud_messages == 1)
{
p->fta = 100;
p->ftq = -32768;
text_quote = t;
pub = NUMPAGES;
pus = NUMPAGES;
}
}
END_RR_NS

View file

@ -2551,7 +2551,6 @@ struct GameInterface : ::GameInterface
bool CleanupForLoad() override;
bool LoadGame(FSaveGameNode* sv) override;
bool SaveGame(FSaveGameNode* sv) override;
void DoPrintMessage(int prio, const char* text) override;
void SetAmbience(bool on) override { if (on) StartAmbientSound(); else StopAmbientSound(); }
FString GetCoordString() override;

View file

@ -435,15 +435,6 @@ void PutStringInfo(PLAYERp pp, const char *string)
if (hud_messages == 1) PutStringInfoLine(pp, string);
}
void GameInterface::DoPrintMessage(int prio, const char* string)
{
if (!hud_messages)
return;
Printf(prio | PRINT_NOTIFY, "%s", string); // Put it in the console too
if (hud_messages == 1) PutStringInfoLine(&Player[myconnectindex], string);
}
void PutStringInfoLine(PLAYERp pp, const char *string)
{
short x,y;