- removed Blood's message display.

We'll use the common one in c_console from now on.
This commit is contained in:
Christoph Oelckers 2020-07-31 21:06:56 +02:00
parent a12cdf849e
commit 2f94ae8160
6 changed files with 3 additions and 278 deletions

View file

@ -345,7 +345,6 @@ void PreloadCache(void)
void EndLevel(void)
{
gViewPos = VIEWPOS_0;
gGameMessageMgr.Clear();
sndKillAllSounds();
sfxKillAllSounds();
ambKillAll();
@ -545,8 +544,6 @@ void StartLevel(GAMEOPTIONS *gameOptions)
// viewSetMessage("");
viewSetErrorMessage("");
viewResizeView(gViewSize);
if (gGameOptions.nGameType == 3)
gGameMessageMgr.SetCoordinates(gViewX0S+1,gViewY0S+15);
netWaitForEveryone(0);
totalclock = 0;
paused = 0;

View file

@ -520,11 +520,7 @@ bool GameInterface::LoadGame(FSaveGameNode* node)
bOutOfSync = 0;
for (int i = 0; i < gNetPlayers; i++)
playerSetRace(&gPlayer[i], gPlayer[i].lifeMode);
if (VanillaMode())
viewSetMessage("");
else
gGameMessageMgr.Clear();
viewSetErrorMessage("");
viewSetErrorMessage("");
if (gamestate != GS_LEVEL)
{
netWaitForEveryone(0);

View file

@ -279,218 +279,6 @@ void LevelWarp(int nEpisode, int nLevel)
viewResizeView(gViewSize);
}
CGameMessageMgr::CGameMessageMgr()
{
if (!VanillaMode())
Clear();
x = 1;
y = 0;
at9 = 0;
atd = 0;
nFont = 0;
fontHeight = 8;
maxNumberOfMessagesToDisplay = 4;
visibilityDurationInSecs = 5;
messageFlags = 15;
numberOfDisplayedMessages = 0;
nextMessagesIndex = messagesIndex = 0;
}
void CGameMessageMgr::SetState(char state)
{
if (this->state && !state)
{
this->state = 0;
Clear();
}
else if (!this->state && state)
this->state = 1;
}
void CGameMessageMgr::Add(const char *pText, char a2, const int pal, const MESSAGE_PRIORITY priority)
{
if (a2 && messageFlags && hud_messages == 1) // add only if messages are enabled and in native format
{
messageStruct *pMessage = &messages[nextMessagesIndex];
strncpy(pMessage->text, pText, kMaxMessageTextLength-1);
pMessage->text[kMaxMessageTextLength-1] = 0;
pMessage->lastTickWhenVisible = gFrameClock + visibilityDurationInSecs*kTicRate;
pMessage->pal = pal;
pMessage->priority = priority;
pMessage->deleted = false;
nextMessagesIndex = (nextMessagesIndex+1)%kMessageLogSize;
if (VanillaMode())
{
numberOfDisplayedMessages++;
if (numberOfDisplayedMessages > maxNumberOfMessagesToDisplay)
{
messagesIndex = (messagesIndex+1)%kMessageLogSize;
atd = 0;
numberOfDisplayedMessages = maxNumberOfMessagesToDisplay;
at9 = fontHeight;
}
}
}
}
void CGameMessageMgr::Display(void)
{
if (VanillaMode())
{
if (numberOfDisplayedMessages && this->state)
{
int initialNrOfDisplayedMsgs = numberOfDisplayedMessages;
int initialMessagesIndex = messagesIndex;
int shade = ClipHigh(initialNrOfDisplayedMsgs*8, 48);
int x = gViewMode == 3 ? gViewX0S : 0;
int y = (gViewMode == 3 ? this->y : 0) + (int)at9;
for (int i = 0; i < initialNrOfDisplayedMsgs; i++)
{
messageStruct* pMessage = &messages[(initialMessagesIndex+i)%kMessageLogSize];
if (pMessage->lastTickWhenVisible < gFrameClock)
{
messagesIndex = (messagesIndex+1)%kMessageLogSize;
numberOfDisplayedMessages--;
continue;
}
viewDrawText(nFont, pMessage->text, x, y, shade, pMessage->pal, 0, false, 256);
if (gViewMode == 3)
{
int height;
viewGetFontInfo(nFont, pMessage->text, &height, NULL);
if (x+height > gViewX1S)
viewUpdatePages();
}
y += fontHeight;
shade = ClipLow(shade-64/initialNrOfDisplayedMsgs, -128);
}
}
}
else
{
if (this->state)
{
messageStruct* currentMessages[kMessageLogSize];
int currentMessagesCount = 0;
for (int i = 0; i < kMessageLogSize; i++)
{
messageStruct* pMessage = &messages[i];
if (gFrameClock < pMessage->lastTickWhenVisible && !pMessage->deleted)
{
currentMessages[currentMessagesCount++] = pMessage;
}
}
SortMessagesByPriority(currentMessages, currentMessagesCount);
messageStruct* messagesToDisplay[kMessageLogSize];
int messagesToDisplayCount = 0;
for (int i = 0; i < currentMessagesCount && messagesToDisplayCount < maxNumberOfMessagesToDisplay; i++)
{
messagesToDisplay[messagesToDisplayCount++] = currentMessages[i];
}
SortMessagesByTime(messagesToDisplay, messagesToDisplayCount);
int shade = ClipHigh(messagesToDisplayCount*8, 48);
int x = gViewMode == 3 ? gViewX0S : 0;
int y = (gViewMode == 3 ? this->y : 0) + (int)at9;
for (int i = 0; i < messagesToDisplayCount; i++)
{
messageStruct* pMessage = messagesToDisplay[i];
viewDrawText(nFont, pMessage->text, x, y, shade, pMessage->pal, 0, false, 256);
if (gViewMode == 3)
{
int height;
viewGetFontInfo(nFont, pMessage->text, &height, NULL);
if (x+height > gViewX1S)
viewUpdatePages();
}
y += fontHeight;
shade = ClipLow(shade-64/messagesToDisplayCount, -128);
}
}
}
if (at9 != 0)
{
at9 = fontHeight*at9/kTicRate;
atd += gFrameTicks;
}
}
void CGameMessageMgr::Clear(void)
{
if (VanillaMode())
{
messagesIndex = nextMessagesIndex = numberOfDisplayedMessages = 0;
}
else
{
for (int i = 0; i < kMessageLogSize; i++)
{
messageStruct* pMessage = &messages[i];
pMessage->deleted = true;
}
}
}
void CGameMessageMgr::SetMaxMessages(int nMessages)
{
maxNumberOfMessagesToDisplay = ClipRange(nMessages, 1, 16);
}
void CGameMessageMgr::SetFont(int nFont)
{
this->nFont = nFont;
fontHeight = gFont[nFont]->GetHeight();
}
void CGameMessageMgr::SetCoordinates(int x, int y)
{
this->x = ClipRange(x, 0, gViewX1S);
this->y = ClipRange(y, 0, gViewY1S);
}
void CGameMessageMgr::SetMessageTime(int nTime)
{
visibilityDurationInSecs = ClipRange(nTime, 1, 8);
}
void CGameMessageMgr::SetMessageFlags(unsigned int nFlags)
{
messageFlags = nFlags&0xf;
}
void CGameMessageMgr::SortMessagesByPriority(messageStruct** messages, int count) {
for (int i = 1; i < count; i++)
{
for (int j = 0; j < count - i; j++)
{
if (messages[j]->priority != messages[j + 1]->priority ? messages[j]->priority < messages[j + 1]->priority : messages[j]->lastTickWhenVisible < messages[j + 1]->lastTickWhenVisible)
{
messageStruct* temp = messages[j];
messages[j] = messages[j + 1];
messages[j + 1] = temp;
}
}
}
}
void CGameMessageMgr::SortMessagesByTime(messageStruct** messages, int count) {
for (int i = 1; i < count; i++)
{
for (int j = 0; j < count - i; j++)
{
if (messages[j]->lastTickWhenVisible > messages[j + 1]->lastTickWhenVisible)
{
messageStruct* temp = messages[j];
messages[j] = messages[j + 1];
messages[j + 1] = temp;
}
}
}
}
void CPlayerMsg::Clear(void)
{
text[0] = 0;

View file

@ -39,47 +39,6 @@ enum MESSAGE_PRIORITY {
MESSAGE_PRIORITY_SYSTEM = 100
};
class CGameMessageMgr
{
public:
struct messageStruct
{
ClockTicks lastTickWhenVisible;
char text[kMaxMessageTextLength];
int pal;
MESSAGE_PRIORITY priority;
bool deleted = false;
};
char state;
int x;
int y;
ClockTicks at9;
ClockTicks atd;
int nFont;
int fontHeight;
int maxNumberOfMessagesToDisplay;
int visibilityDurationInSecs;
char messageFlags;
int numberOfDisplayedMessages;
int messagesIndex;
int nextMessagesIndex;
messageStruct messages[kMessageLogSize];
CGameMessageMgr();
void SetState(char state);
void Add(const char *pText, char a2, const int pal = 0, const MESSAGE_PRIORITY priority = MESSAGE_PRIORITY_NORMAL);
void Display(void);
void Clear();
void SetMaxMessages(int nMessages);
void SetFont(int nFont);
void SetCoordinates(int x, int y);
void SetMessageTime(int nTime);
void SetMessageFlags(unsigned int nFlags);
private:
void SortMessagesByPriority(messageStruct** messages, int count);
void SortMessagesByTime(messageStruct** messages, int count);
};
class CPlayerMsg
{
public:

View file

@ -129,7 +129,6 @@ int xscale, xscalecorrect, yscale, xstep, ystep;
int gScreenTilt;
CGameMessageMgr gGameMessageMgr;
bool bLoadScreenCrcMatch = false;
@ -1817,12 +1816,6 @@ void viewInit(void)
#endif
uint8_t *data = tileAllocTile(4077, kLensSize, kLensSize);
memset(data, TRANSPARENT_INDEX, kLensSize*kLensSize);
gGameMessageMgr.SetState(hud_messages);
gGameMessageMgr.SetCoordinates(1, 1);
gGameMessageMgr.SetFont(3);
gGameMessageMgr.SetMaxMessages(4);
gGameMessageMgr.SetMessageTime(5);
for (int i = 0; i < 16; i++)
{
@ -1882,7 +1875,6 @@ void viewResizeView(int size)
gViewY1S = divscale16(gViewY1, yscale);
}
videoSetViewableArea(gViewX0, gViewY0, gViewX1, gViewY1);
gGameMessageMgr.SetCoordinates(gViewX0S + 1, gViewY0S + 1);
viewUpdatePages();
}
@ -2853,20 +2845,14 @@ void viewSetSystemMessage(const char* pMessage, ...) {
vsprintf(buffer, pMessage, args);
Printf(PRINT_HIGH | PRINT_NOTIFY, "%s\n", buffer); // print it also in console
gGameMessageMgr.Add(buffer, 15, 7, MESSAGE_PRIORITY_NORMAL);
}
void viewSetMessage(const char *pMessage, const int pal, const MESSAGE_PRIORITY priority)
{
int printlevel = priority < 0 ? PRINT_LOW : priority < MESSAGE_PRIORITY_SYSTEM ? PRINT_MEDIUM : PRINT_HIGH;
Printf(printlevel|PRINT_NOTIFY, "%s\n", pMessage);
gGameMessageMgr.Add(pMessage, 15, pal, priority);
}
void viewDisplayMessage(void)
{
gGameMessageMgr.Display();
}
char errMsg[256];
@ -3528,7 +3514,6 @@ void viewDrawScreen(bool sceneonly)
{
DrawStatSprite(2048, xdim-15, 20);
}
viewDisplayMessage();
CalcFrameRate();
viewDrawMapTitle();

View file

@ -89,7 +89,6 @@ extern char gInterpolateWall[];
extern char gInterpolateSector[];
extern LOCATION gPrevSpriteLoc[kMaxSprites];
extern int gViewSize;
extern CGameMessageMgr gGameMessageMgr;
extern int gViewXCenter, gViewYCenter;
extern int gViewX0, gViewY0, gViewX1, gViewY1;
extern int gViewX0S, gViewY0S, gViewX1S, gViewY1S;
@ -133,7 +132,8 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, int zm);
void CalcPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, int zm);
void viewSetMessage(const char *pMessage, const int pal = 0, const MESSAGE_PRIORITY priority = MESSAGE_PRIORITY_NORMAL);
void viewDisplayMessage(void);
void viewSetErrorMessage(const char *pMessage);
void DoLensEffect(void);
void UpdateDacs(int nPalette, bool bNoTint = false);