chat status lines are now deleted on the next screen

origin
patty21 23 years ago
parent ce530cead0
commit e87822fb07

@ -15,27 +15,46 @@ _chat chat;
int int
chat_findfreeline () chat_findfreeline ()
{ {
int i; int i;
i = chat.lastline;
for (i = 0; (i < CHAT_MAX_LINES && chat.lines[i][0] != 0); i++);
if (i >= CHAT_MAX_LINES) { if (i >= CHAT_MAX_LINES) {
memcpy (chat.lines[1], chat.lines[0], 255); memcpy (chat.lines[1], chat.lines[0], 255);
i = 255; i = 255;
} }
else
chat.lastline++;
chat.changed = 1; chat.changed = 1;
return i; return i;
} }
void
chat_cleanup ()
{
int i;
for (i = 0; i < CHAT_MAX_LINES; i++) {
if (chat.linestatus[i] > 0)
chat.linestatus[i] = -1;
}
}
void void
chat_addline (char *text) chat_addline (char *text)
{ {
int l; int l;
l = chat_findfreeline (); l = chat_findfreeline ();
chat.linestatus[l] = 0;
strncpy (chat.lines[l], text, 255);
chat.lineschanged = 1;
}
void
chat_addstatusline (char *text)
{
int l;
l = chat_findfreeline ();
chat.linestatus[l] = 1;
strncpy (chat.lines[l], text, 255); strncpy (chat.lines[l], text, 255);
chat.lineschanged = 1; chat.lineschanged = 1;
} }
@ -75,7 +94,7 @@ chat_drawbox ()
src.h = src.y + font[0].size.y; src.h = src.y + font[0].size.y;
draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_DARK >> 1); draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_DARK >> 1);
gfx_AddUpdateRect (chat.window.x, chat.window.y, chat.window.w, chat.window.h); gfx_AddUpdateRect (chat.window.x, chat.window.y, chat.window.w, chat.window.h);
}; };
void void
@ -116,7 +135,7 @@ chat_show (int x1, int y1, int x2, int y2)
chat.window.h = y2 - y1; chat.window.h = y2 - y1;
chat_drawbox (); chat_drawbox ();
chat.changed = 1; chat.changed = 1;
chat.lineschanged = 1; chat.lineschanged = 1;
} }
}; };
@ -193,19 +212,24 @@ chat_loop (SDL_Event * event)
p1 = p2 = 0; p1 = p2 = 0;
maxchar = (chat.window.w - 4) / font[0].size.x; maxchar = (chat.window.w - 4) / font[0].size.x;
if (chat.lineschanged) { if (chat.lineschanged) {
font_setcolor (255,255,255,0); font_setcolor (255, 255, 255, 0);
y = chat.window.y + 4; y = chat.window.y + 4;
l = chat.startline; l = chat.startline;
while (y < (chat.window.y + chat.window.h - 32) && chat.lines[l][0] != 0) { while (y < (chat.window.y + chat.window.h - 32) && chat.lines[l][0] != 0) {
for (p1 = 0; (p1 < maxchar && chat.lines[l][p2] != 0); p1++) if (chat.linestatus[l] < 0) {
text[p1] = chat.lines[l][p2++];
text[p1] = 0;
font_draw (chat.window.x + 4, y, text, 0);
if (chat.lines[l][p2] == 0) { // the end of the line
l++; l++;
p2 = 0;
} }
y = y + font[0].size.y; else {
for (p1 = 0; (p1 < maxchar && chat.lines[l][p2] != 0); p1++)
text[p1] = chat.lines[l][p2++];
text[p1] = 0;
font_draw (chat.window.x + 4, y, text, 0);
if (chat.lines[l][p2] == 0) { // the end of the line
l++;
p2 = 0;
}
y = y + font[0].size.y;
}
} }
if (chat.lines[l][0] != 0) { if (chat.lines[l][0] != 0) {
chat.startline++; chat.startline++;
@ -227,6 +251,7 @@ chat_loop (SDL_Event * event)
for (p1 = 0; (p1 < maxchar && chat.input.text[p2] != 0); p1++) for (p1 = 0; (p1 < maxchar && chat.input.text[p2] != 0); p1++)
text[p1] = chat.input.text[p2++]; text[p1] = chat.input.text[p2++];
text[p1] = 0; text[p1] = 0;
font_draw (chat.window.x + 4, (chat.window.y + chat.window.h) - 4 - font[0].size.y, text,0); font_draw (chat.window.x + 4, (chat.window.y + chat.window.h) - 4 - font[0].size.y,
text, 0);
} }
}; };

@ -14,7 +14,9 @@ struct __chat {
signed char changed; signed char changed;
SDL_Surface *oldscreen; SDL_Surface *oldscreen;
short int startline; short int startline;
short int lastline;
char lines[CHAT_MAX_LINES][255]; char lines[CHAT_MAX_LINES][255];
short int linestatus[CHAT_MAX_LINES];
signed char lineschanged; signed char lineschanged;
_keybinput input; _keybinput input;
} typedef _chat; } typedef _chat;
@ -23,7 +25,9 @@ extern _chat chat;
extern void chat_show (int x1, int y1, int x2, int y2); extern void chat_show (int x1, int y1, int x2, int y2);
extern void chat_addline (char *text); extern void chat_addline (char *text);
extern void chat_addstatusline (char *text);
extern void chat_loop (SDL_Event *event); extern void chat_loop (SDL_Event *event);
extern void chat_drawbox (); extern void chat_drawbox ();
extern void chat_cleanup ();
#endif #endif

@ -42,8 +42,8 @@ mw_init ()
SDL_FreeSurface (tmp); SDL_FreeSurface (tmp);
network_loop (); network_loop ();
} }
bman.updatestatusbar = 1; bman.updatestatusbar = 1;
}; };
@ -54,9 +54,9 @@ mw_shutdown ()
int i; int i;
chat_show (-1, -1, -1, -1); chat_show (-1, -1, -1, -1);
chat_cleanup();
gfx_free_players (); gfx_free_players ();
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
SDL_FreeSurface (mw_plgfx[i]); SDL_FreeSurface (mw_plgfx[i]);
}; };
@ -87,12 +87,12 @@ mw_draw_status ()
x = (gfx.res.x - px * 320) / 2; x = (gfx.res.x - px * 320) / 2;
for (pnr = 0; pnr < px; pnr++) { for (pnr = 0; pnr < px; pnr++) {
font_setcolor (128,128,128,0); font_setcolor (128, 128, 128, 0);
font_draw (pnr * 320 + x - 2, 22, " Wins Points", 0); font_draw (pnr * 320 + x - 2, 22, " Wins Points", 0);
font_setcolor (192,192,255,0); font_setcolor (192, 192, 255, 0);
font_draw (pnr * 320 + x, 24, " Wins Points", 0); font_draw (pnr * 320 + x, 24, " Wins Points", 0);
} }
/* 2. the names with points */ /* 2. the names with points */
for (x1 = pnr = 0, y = 48; pnr < MAX_PLAYERS; pnr++) { for (x1 = pnr = 0, y = 48; pnr < MAX_PLAYERS; pnr++) {
redraw_logo (x1 * 320, y - 4, 320, 32); redraw_logo (x1 * 320, y - 4, 320, 32);
@ -113,9 +113,9 @@ mw_draw_status ()
if (PS_IS_used (bman.players[pnr].state)) { if (PS_IS_used (bman.players[pnr].state)) {
if (bman.lastwinner == pnr) if (bman.lastwinner == pnr)
font_setcolor (255,255,192,0); font_setcolor (255, 255, 192, 0);
else else
font_setcolor (192,192,192,0); font_setcolor (192, 192, 192, 0);
font_draw (x + x1 * 320, y, text, 0); font_draw (x + x1 * 320, y, text, 0);
} }
x1++; x1++;
@ -221,9 +221,11 @@ mw_draw_chat ()
{ {
if (chat.visible == 0) { if (chat.visible == 0) {
chat_show (16, mw_chat + 16, gfx.res.x - 16, gfx.res.y - 32); chat_show (16, mw_chat + 16, gfx.res.x - 16, gfx.res.y - 32);
chat_addline ("Press [STRG] or [CTRL] - to select a player"); chat_addstatusline ("Press [STRG] or [CTRL] - to select a player");
if (GT_MP_PTPM) if (GT_MP_PTPM) {
chat_addline ("F4 - to start the game"); chat_addstatusline ("F4 - to start the game");
chat_addstatusline ("F5 - to change map settings");
}
} }
}; };
@ -269,11 +271,11 @@ wait_for_players ()
SDL_Flip (gfx.screen); SDL_Flip (gfx.screen);
} }
else { /* we have a connect so draw status */ else { /* we have a connect so draw status */
if (bman.updatestatusbar) { if (bman.updatestatusbar) {
mw_draw_status (); mw_draw_status ();
gfx_AddUpdateRect (0, 0, gfx.res.x, mw_player); gfx_AddUpdateRect (0, 0, gfx.res.x, mw_player);
bman.updatestatusbar = 0; bman.updatestatusbar = 0;
} }
mw_draw_gfxselect (selgfx); mw_draw_gfxselect (selgfx);
gfx_AddUpdateRect (0, mw_player, gfx.res.x, mw_chat); gfx_AddUpdateRect (0, mw_player, gfx.res.x, mw_chat);
mw_draw_chat (); mw_draw_chat ();
@ -343,27 +345,27 @@ wait_for_players ()
bman.players[bman.p_nr].gfx_nr = -1; bman.players[bman.p_nr].gfx_nr = -1;
} }
net_change_playerid (bman.p_nr, 1); net_change_playerid (bman.p_nr, 1);
bman.updatestatusbar = 1; bman.updatestatusbar = 1;
} }
if ((GT_MP_PTPM) && ready && keys[SDLK_F4] && (!keypressed)) { if ((GT_MP_PTPM) && ready && keys[SDLK_F4] && (!keypressed)) {
done = 1; done = 1;
bman.updatestatusbar = 1; bman.updatestatusbar = 1;
} }
if ((GT_MP_PTPM) && keys[SDLK_F5] && (!keypressed)) { if ((GT_MP_PTPM) && keys[SDLK_F5] && (!keypressed)) {
/* Map modification */ /* Map modification */
mapmenu (); mapmenu ();
draw_logo(); draw_logo ();
mw_draw_status (); mw_draw_status ();
mw_draw_gfxselect (selgfx); mw_draw_gfxselect (selgfx);
UpdateRects_nr = 0; UpdateRects_nr = 0;
gfx_AddUpdateRect (0, 0, gfx.res.x, gfx.res.y); gfx_AddUpdateRect (0, 0, gfx.res.x, gfx.res.y);
chat.changed = 1; chat.changed = 1;
chat.lineschanged = 1; chat.lineschanged = 1;
chat_drawbox (); chat_drawbox ();
mw_draw_chat (); mw_draw_chat ();
gfx_UpdateRects (); gfx_UpdateRects ();
} }
chat_loop (&event); chat_loop (&event);
} }

Loading…
Cancel
Save