diff options
author | Simon Howard | 2006-01-13 23:56:00 +0000 |
---|---|---|
committer | Simon Howard | 2006-01-13 23:56:00 +0000 |
commit | d78780cfc3f4c5c601bc19ae7976c2ae26ac9495 (patch) | |
tree | 19f4f9685b34ab4bdb690525b82c5361b8772361 /src | |
parent | 8a6bdf645f50726000d2491cb52d41b69acd87a4 (diff) | |
download | chocolate-doom-d78780cfc3f4c5c601bc19ae7976c2ae26ac9495.tar.gz chocolate-doom-d78780cfc3f4c5c601bc19ae7976c2ae26ac9495.tar.bz2 chocolate-doom-d78780cfc3f4c5c601bc19ae7976c2ae26ac9495.zip |
Add text-mode I/O functions.
Use text-mode screen for the waiting screen.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 291
Diffstat (limited to 'src')
-rw-r--r-- | src/d_main.c | 17 | ||||
-rw-r--r-- | src/d_net.c | 11 | ||||
-rw-r--r-- | src/g_game.c | 10 | ||||
-rw-r--r-- | src/net_gui.c | 248 |
4 files changed, 85 insertions, 201 deletions
diff --git a/src/d_main.c b/src/d_main.c index 91c83d71..f90b331d 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: d_main.c 280 2006-01-10 22:14:13Z fraggle $ +// $Id: d_main.c 291 2006-01-13 23:56:00Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -22,6 +22,10 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.38 2006/01/13 23:56:00 fraggle +// Add text-mode I/O functions. +// Use text-mode screen for the waiting screen. +// // Revision 1.37 2006/01/10 22:14:13 fraggle // Shut up compiler warnings // @@ -166,7 +170,7 @@ //----------------------------------------------------------------------------- -static const char rcsid[] = "$Id: d_main.c 280 2006-01-10 22:14:13Z fraggle $"; +static const char rcsid[] = "$Id: d_main.c 291 2006-01-13 23:56:00Z fraggle $"; #define BGCOLOR 7 #define FGCOLOR 8 @@ -220,7 +224,6 @@ static const char rcsid[] = "$Id: d_main.c 280 2006-01-10 22:14:13Z fraggle $"; #include "st_stuff.h" #include "am_map.h" #include "net_client.h" -#include "net_gui.h" #include "p_setup.h" #include "r_local.h" @@ -544,7 +547,9 @@ void D_DoomLoop (void) printf ("debug output to: %s\n",filename); debugfile = fopen (filename,"w"); } - + + I_InitGraphics (); + while (1) { // frame syncronous IO operations @@ -1590,10 +1595,6 @@ void D_DoomMain (void) printf ("ST_Init: Init status bar.\n"); ST_Init (); - I_InitGraphics (); - - NET_WaitForStart(); - // start the apropriate game based on parms p = M_CheckParm ("-record"); diff --git a/src/d_net.c b/src/d_net.c index 7af0cd01..7327850d 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: d_net.c 250 2006-01-02 21:04:10Z fraggle $ +// $Id: d_net.c 291 2006-01-13 23:56:00Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -22,6 +22,10 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.16 2006/01/13 23:56:00 fraggle +// Add text-mode I/O functions. +// Use text-mode screen for the waiting screen. +// // Revision 1.15 2006/01/02 21:04:10 fraggle // Create NET_SV_Shutdown function to shut down the server. Call it // when quitting the game. Print the IP of the server correctly when @@ -85,7 +89,7 @@ //----------------------------------------------------------------------------- -static const char rcsid[] = "$Id: d_net.c 250 2006-01-02 21:04:10Z fraggle $"; +static const char rcsid[] = "$Id: d_net.c 291 2006-01-13 23:56:00Z fraggle $"; #include "d_main.h" @@ -99,6 +103,7 @@ static const char rcsid[] = "$Id: d_net.c 250 2006-01-02 21:04:10Z fraggle $"; #include "doomstat.h" #include "net_client.h" +#include "net_gui.h" #include "net_io.h" #include "net_server.h" #include "net_sdl.h" @@ -650,6 +655,8 @@ void D_CheckNetGame (void) if (NET_CL_Connect(addr)) { printf("connected to %s\n", NET_AddrToString(addr)); + + NET_WaitForStart(); } else { diff --git a/src/g_game.c b/src/g_game.c index 001cb19e..9afe6ace 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: g_game.c 237 2006-01-01 23:53:15Z fraggle $ +// $Id: g_game.c 291 2006-01-13 23:56:00Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -22,6 +22,10 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.19 2006/01/13 23:56:00 fraggle +// Add text-mode I/O functions. +// Use text-mode screen for the waiting screen. +// // Revision 1.18 2006/01/01 23:53:15 fraggle // Remove GS_WAITINGSTART gamestate. This will be independent of the main // loop to avoid interfering with the main game code too much. @@ -98,7 +102,7 @@ static const char -rcsid[] = "$Id: g_game.c 237 2006-01-01 23:53:15Z fraggle $"; +rcsid[] = "$Id: g_game.c 291 2006-01-13 23:56:00Z fraggle $"; #include <string.h> #include <stdlib.h> @@ -109,8 +113,6 @@ rcsid[] = "$Id: g_game.c 237 2006-01-01 23:53:15Z fraggle $"; #include "deh_main.h" #include "deh_misc.h" -#include "net_gui.h" - #include "z_zone.h" #include "f_finale.h" #include "m_argv.h" diff --git a/src/net_gui.c b/src/net_gui.c index 1ee0555f..7abdc68d 100644 --- a/src/net_gui.c +++ b/src/net_gui.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_gui.c 284 2006-01-12 02:11:52Z fraggle $ +// $Id: net_gui.c 291 2006-01-13 23:56:00Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -21,6 +21,10 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.9 2006/01/13 23:56:00 fraggle +// Add text-mode I/O functions. +// Use text-mode screen for the waiting screen. +// // Revision 1.8 2006/01/12 02:11:52 fraggle // Game start packets // @@ -59,233 +63,103 @@ // start the game. // +#include <ctype.h> + +#include "config.h" #include "doomstat.h" +#include "i_system.h" + #include "net_client.h" #include "net_gui.h" #include "net_server.h" -#include "d_event.h" -#include "d_main.h" -#include "i_system.h" -#include "i_video.h" -#include "m_menu.h" -#include "m_random.h" -#include "r_defs.h" -#include "s_sound.h" -#include "sounds.h" -#include "v_video.h" -#include "w_wad.h" -#include "z_zone.h" - -static patch_t *player_face; -static patch_t *player_backdrops[4]; -static boolean have_music; - -extern void M_WriteText(int x, int y, char *string); +#include "txt_main.h" +#include "txt_gui.h" +#include "txt_io.h" -static void Drawer(void) +static void ProcessEvents(void) { - patch_t *backdrop; - int backdrop_lumpnum; - int i, y; - - // Use INTERPIC or TITLEPIC if we don't have it - - backdrop_lumpnum = W_CheckNumForName("INTERPIC"); - - if (backdrop_lumpnum < 0) - { - backdrop_lumpnum = W_CheckNumForName("TITLEPIC"); - } - - backdrop = (patch_t *) W_CacheLumpNum(backdrop_lumpnum, PU_CACHE); - - // draw the backdrop + int c; - V_DrawPatch(0, 0, 0, backdrop); - - // draw players - - y = 100 - 16 * net_clients_in_game - 24; - - M_WriteText(32, y, "Players currently waiting:"); - - y += 24; - - for (i=0; i<net_clients_in_game; ++i) + while ((c = TXT_GetChar()) > 0) { - V_DrawPatch(32, y, 0, player_backdrops[i]); - - // draw the face to indicate which one we are - - if (i == net_player_number) + switch (tolower(c)) { - V_DrawPatch(32, y, 0, player_face); + case 27: + case 'q': + I_Quit(); + break; + + case ' ': + NET_CL_StartGame(); + break; } - M_WriteText(80, y+12, net_player_names[i]); - M_WriteText(200, y+12, net_player_addresses[i]); - y += 32; - } - - y += 16; - - if (net_client_controller) - { - M_WriteText(32, y, "Press space to start the game..."); - } - else - { - M_WriteText(32, y, "Waiting for the game to start..."); } } -// play some random music +#define WINDOW_X 15 +#define WINDOW_Y 5 +#define WINDOW_W 50 +#define WINDOW_H 12 -static void RandomMusic(void) +static void DrawScreen(void) { - musicenum_t mus; - - if (gamemode == commercial) - { - mus = mus_runnin + M_Random() % 32; - } - else if (gamemode == shareware) - { - mus = mus_e1m1 + M_Random() % 9; - } - else - { - mus = mus_e1m1 + M_Random() % 27; - } - - S_ChangeMusic(mus, 0); - - // If music is not playing straight away, it is turned off. Don't - // try to play any more music. + char buf[40]; + int i; - have_music = S_MusicPlaying(); -} + TXT_DrawDesktop(PACKAGE_STRING); + TXT_DrawWindow("Waiting for game start...", + WINDOW_X, WINDOW_Y, + WINDOW_W, WINDOW_H); -static void ProcessEvents(void) -{ - event_t *ev; + TXT_BGColor(TXT_COLOR_BLUE, 0); + TXT_FGColor(TXT_COLOR_BRIGHT_WHITE); - while ((ev = D_PopEvent()) != NULL) + for (i=0; i<MAXPLAYERS; ++i) { - if (M_Responder(ev)) - { - continue; - } - - // process event ... - - if (ev->type == ev_keydown && ev->data1 == 'm') - { - // Music change + snprintf(buf, 39, "%i. ", i + 1); + TXT_GotoXY(WINDOW_X + 2, WINDOW_Y + 4 + i); + TXT_Puts(buf); - RandomMusic(); - } - else if (ev->type == ev_keydown && ev->data1 == ' ') + if (i < net_clients_in_game) { - // Start game + snprintf(buf, 15, "%s", net_player_names[i]); + TXT_GotoXY(WINDOW_X + 5, WINDOW_Y + 4 + i); + TXT_Puts(buf); - NET_CL_StartGame(); + snprintf(buf, 16, "%s", net_player_addresses[i]); + TXT_GotoXY(WINDOW_X + 33, WINDOW_Y + 4 + i); + TXT_Puts(buf); } } -} -static void NET_InitGUI(void) -{ - char buf[8]; - int i; + TXT_GotoXY(WINDOW_X + 2, WINDOW_Y + WINDOW_H - 2); + TXT_Puts("%brightgreen%SPACE%/%%brightcyan%=%/%Start game"); - player_face = W_CacheLumpName("STFST01", PU_STATIC); + TXT_GotoXY(WINDOW_X + WINDOW_W - 11, WINDOW_Y + WINDOW_H - 2); + TXT_Puts("%brightgreen%ESC%/%%brightcyan%=%/%Abort"); + + TXT_DrawSeparator(WINDOW_X, WINDOW_Y + WINDOW_H - 3, WINDOW_W); - for (i=0 ; i<MAXPLAYERS ; i++) - { - sprintf(buf, "STPB%d", i); - player_backdrops[i] = W_CacheLumpName(buf, PU_STATIC); - } + TXT_UpdateScreen(); } -// Displays a graphical screen while waiting for the game to start. - void NET_WaitForStart(void) { - int last_tic_time; - int nowtime; - int runtics; - int i; - - if (!net_client_connected || !net_waiting_for_start) - { - return; - } - - NET_InitGUI(); - - M_ClearRandom(); - - // play some soothing music while we wait - - RandomMusic(); - - // cheap hack: pretend to be on a demo screen so the mouse wont - // be grabbed - - gamestate = GS_DEMOSCREEN; - - last_tic_time = I_GetTime(); + TXT_Init(); while (net_waiting_for_start) { - // Keyboard/mouse events, etc. - - I_StartTic(); ProcessEvents(); - - // Run the menu, etc. - - nowtime = I_GetTime(); - runtics = nowtime - last_tic_time; - - if (runtics > 0) - { - for (i=0; i<runtics; ++i) - { - M_Ticker(); - } - - last_tic_time = nowtime; - - // Draw the screen - - Drawer(); - M_Drawer(); - I_FinishUpdate(); - - // check if the music has finished - start another track! - - if (have_music && !S_MusicPlaying()) - { - RandomMusic(); - } - } - - // Network stuff + DrawScreen(); NET_CL_Run(); NET_SV_Run(); - if (!net_client_connected) - { - I_Error("Disconnected from server"); - } - - // Don't hog the CPU - - I_Sleep(10); + I_Sleep(50); } + + TXT_Shutdown(); } |