// SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1999-2018 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. // See the 'LICENSE' file for more details. //----------------------------------------------------------------------------- /// \file hu_stuff.c /// \brief Heads up display #include "doomdef.h" #include "byteptr.h" #include "hu_stuff.h" #include "m_menu.h" // gametype_cons_t #include "m_cond.h" // emblems #include "d_clisrv.h" #include "g_game.h" #include "g_input.h" #include "i_video.h" #include "i_system.h" #include "st_stuff.h" // ST_HEIGHT #include "r_local.h" #include "keys.h" #include "v_video.h" #include "w_wad.h" #include "z_zone.h" #include "console.h" #include "am_map.h" #include "d_main.h" #include "p_local.h" // camera, camera2, camera3, camera4 #include "p_tick.h" #ifdef HWRENDER #include "hardware/hw_main.h" #endif #ifdef HAVE_BLUA #include "lua_hud.h" #include "lua_hook.h" #endif #include "s_sound.h" // song credits #include "k_kart.h" // coords are scaled #define HU_INPUTX 0 #define HU_INPUTY 0 #define HU_SERVER_SAY 1 // Server message (dedicated). #define HU_CSAY 2 // Server CECHOes to everyone. //------------------------------------------- // heads up font //------------------------------------------- patch_t *hu_font[HU_FONTSIZE]; patch_t *kart_font[KART_FONTSIZE]; // SRB2kart patch_t *tny_font[HU_FONTSIZE]; patch_t *tallnum[10]; // 0-9 patch_t *nightsnum[10]; // 0-9 // Level title and credits fonts patch_t *lt_font[LT_FONTSIZE]; patch_t *cred_font[CRED_FONTSIZE]; // ping font // Note: I'd like to adress that at this point we might *REALLY* want to work towards a common drawString function that can take any font we want because this is really turning into a MESS. :V -Lat' patch_t *pingnum[10]; patch_t *pinggfx[5]; // small ping graphic patch_t *framecounter; patch_t *frameslash; // framerate stuff. Used in screen.c static player_t *plr; boolean chat_on; // entering a chat message? static char w_chat[HU_MAXMSGLEN]; static size_t c_input = 0; // let's try to make the chat input less shitty. static boolean headsupactive = false; boolean hu_showscores; // draw rankings static char hu_tick; patch_t *rflagico; patch_t *bflagico; patch_t *rmatcico; patch_t *bmatcico; patch_t *tagico; patch_t *tallminus; //------------------------------------------- // coop hud //------------------------------------------- patch_t *emeraldpics[7]; patch_t *tinyemeraldpics[7]; static patch_t *emblemicon; static patch_t *tokenicon; //------------------------------------------- // misc vars //------------------------------------------- // crosshair 0 = off, 1 = cross, 2 = angle, 3 = point, see m_menu.c static patch_t *crosshair[HU_CROSSHAIRS]; // 3 precached crosshair graphics // song credits static patch_t *songcreditbg; // ------- // protos. // ------- static void HU_DrawRankings(void); //====================================================================== // KEYBOARD LAYOUTS FOR ENTERING TEXT //====================================================================== char *shiftxform; char english_shiftxform[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, ' ', '!', '"', '#', '$', '%', '&', '"', // shift-' '(', ')', '*', '+', '<', // shift-, '_', // shift-- '>', // shift-. '?', // shift-/ ')', // shift-0 '!', // shift-1 '@', // shift-2 '#', // shift-3 '$', // shift-4 '%', // shift-5 '^', // shift-6 '&', // shift-7 '*', // shift-8 '(', // shift-9 ':', ':', // shift-; '<', '+', // shift-= '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', // shift-[ '|', // shift-backslash - OH MY GOD DOES WATCOM SUCK '}', // shift-] '"', '_', '~', // shift-` 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', 127 }; static char cechotext[1024]; static tic_t cechotimer = 0; static tic_t cechoduration = 5*TICRATE; static INT32 cechoflags = 0; //====================================================================== // HEADS UP INIT //====================================================================== #ifndef NONET // just after static void Command_Say_f(void); static void Command_Sayto_f(void); static void Command_Sayteam_f(void); static void Command_CSay_f(void); static void Got_Saycmd(UINT8 **p, INT32 playernum); #endif void HU_LoadGraphics(void) { char buffer[9]; INT32 i, j; if (dedicated) return; j = HU_FONTSTART; for (i = 0; i < HU_FONTSIZE; i++, j++) { // cache the heads-up font for entire game execution sprintf(buffer, "STCFN%.3d", j); if (W_CheckNumForName(buffer) == LUMPERROR) hu_font[i] = NULL; else hu_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); // tiny version of the heads-up font sprintf(buffer, "TNYFN%.3d", j); if (W_CheckNumForName(buffer) == LUMPERROR) tny_font[i] = NULL; else tny_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } // cache the level title font for entire game execution lt_font[0] = (patch_t *)W_CachePatchName("LTFNT039", PU_HUDGFX); /// \note fake start hack // Number support lt_font[9] = (patch_t *)W_CachePatchName("LTFNT048", PU_HUDGFX); lt_font[10] = (patch_t *)W_CachePatchName("LTFNT049", PU_HUDGFX); lt_font[11] = (patch_t *)W_CachePatchName("LTFNT050", PU_HUDGFX); lt_font[12] = (patch_t *)W_CachePatchName("LTFNT051", PU_HUDGFX); lt_font[13] = (patch_t *)W_CachePatchName("LTFNT052", PU_HUDGFX); lt_font[14] = (patch_t *)W_CachePatchName("LTFNT053", PU_HUDGFX); lt_font[15] = (patch_t *)W_CachePatchName("LTFNT054", PU_HUDGFX); lt_font[16] = (patch_t *)W_CachePatchName("LTFNT055", PU_HUDGFX); lt_font[17] = (patch_t *)W_CachePatchName("LTFNT056", PU_HUDGFX); lt_font[18] = (patch_t *)W_CachePatchName("LTFNT057", PU_HUDGFX); // SRB2kart j = KART_FONTSTART; for (i = 0; i < KART_FONTSIZE; i++, j++) { // cache the heads-up font for entire game execution sprintf(buffer, "MKFNT%.3d", j); if (W_CheckNumForName(buffer) == LUMPERROR) kart_font[i] = NULL; else kart_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } // j = LT_FONTSTART; for (i = 0; i < LT_FONTSIZE; i++) { sprintf(buffer, "LTFNT%.3d", j); j++; if (W_CheckNumForName(buffer) == LUMPERROR) lt_font[i] = NULL; else lt_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } // cache the credits font for entire game execution (why not?) j = CRED_FONTSTART; for (i = 0; i < CRED_FONTSIZE; i++) { sprintf(buffer, "CRFNT%.3d", j); j++; if (W_CheckNumForName(buffer) == LUMPERROR) cred_font[i] = NULL; else cred_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } //cache numbers too! for (i = 0; i < 10; i++) { sprintf(buffer, "STTNUM%d", i); tallnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); sprintf(buffer, "NGTNUM%d", i); nightsnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); sprintf(buffer, "PINGN%d", i); pingnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); } // minus for negative tallnums tallminus = (patch_t *)W_CachePatchName("STTMINUS", PU_HUDGFX); // cache the crosshairs, don't bother to know which one is being used, // just cache all 3, they're so small anyway. for (i = 0; i < HU_CROSSHAIRS; i++) { sprintf(buffer, "CROSHAI%c", '1'+i); crosshair[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } emblemicon = W_CachePatchName("EMBLICON", PU_HUDGFX); tokenicon = W_CachePatchName("TOKNICON", PU_HUDGFX); emeraldpics[0] = W_CachePatchName("CHAOS1", PU_HUDGFX); emeraldpics[1] = W_CachePatchName("CHAOS2", PU_HUDGFX); emeraldpics[2] = W_CachePatchName("CHAOS3", PU_HUDGFX); emeraldpics[3] = W_CachePatchName("CHAOS4", PU_HUDGFX); emeraldpics[4] = W_CachePatchName("CHAOS5", PU_HUDGFX); emeraldpics[5] = W_CachePatchName("CHAOS6", PU_HUDGFX); emeraldpics[6] = W_CachePatchName("CHAOS7", PU_HUDGFX); tinyemeraldpics[0] = W_CachePatchName("TEMER1", PU_HUDGFX); tinyemeraldpics[1] = W_CachePatchName("TEMER2", PU_HUDGFX); tinyemeraldpics[2] = W_CachePatchName("TEMER3", PU_HUDGFX); tinyemeraldpics[3] = W_CachePatchName("TEMER4", PU_HUDGFX); tinyemeraldpics[4] = W_CachePatchName("TEMER5", PU_HUDGFX); tinyemeraldpics[5] = W_CachePatchName("TEMER6", PU_HUDGFX); tinyemeraldpics[6] = W_CachePatchName("TEMER7", PU_HUDGFX); songcreditbg = W_CachePatchName("K_SONGCR", PU_HUDGFX); // cache ping gfx: for (i = 0; i < 5; i++) { sprintf(buffer, "PINGGFX%d", i+1); pinggfx[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } // fps stuff framecounter = W_CachePatchName("FRAMER", PU_HUDGFX); frameslash = W_CachePatchName("FRAMESL", PU_HUDGFX);; } // Initialise Heads up // once at game startup. // void HU_Init(void) { #ifndef NONET COM_AddCommand("say", Command_Say_f); COM_AddCommand("sayto", Command_Sayto_f); COM_AddCommand("sayteam", Command_Sayteam_f); COM_AddCommand("csay", Command_CSay_f); RegisterNetXCmd(XD_SAY, Got_Saycmd); #endif // set shift translation table shiftxform = english_shiftxform; HU_LoadGraphics(); } static inline void HU_Stop(void) { headsupactive = false; } // // Reset Heads up when consoleplayer spawns // void HU_Start(void) { if (headsupactive) HU_Stop(); plr = &players[consoleplayer]; headsupactive = true; } //====================================================================== // EXECUTION //====================================================================== #ifndef NONET // EVERY CHANGE IN THIS SCRIPT IS LOL XD! BY VINCYTM static UINT32 chat_nummsg_log = 0; static UINT32 chat_nummsg_min = 0; static UINT32 chat_scroll = 0; static tic_t chat_scrolltime = 0; static UINT32 chat_maxscroll = 0; // how far can we scroll? //static chatmsg_t chat_mini[CHAT_BUFSIZE]; // Display the last few messages sent. //static chatmsg_t chat_log[CHAT_BUFSIZE]; // Keep every message sent to us in memory so we can scroll n shit, it's cool. static char chat_log[CHAT_BUFSIZE][255]; // hold the last 48 or so messages in that log. static char chat_mini[8][255]; // display up to 8 messages that will fade away / get overwritten static tic_t chat_timers[8]; static boolean chat_scrollmedown = false; // force instant scroll down on the chat log. Happens when you open it / send a message. // remove text from minichat table static INT16 addy = 0; // use this to make the messages scroll smoothly when one fades away static void HU_removeChatText_Mini(void) { // MPC: Don't create new arrays, just iterate through an existing one size_t i; for(i=0;i