123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602 |
- #include "doomstat.h"
- #include "hu_stuff.h"
- #include "hu_lib.h"
- #include "st_stuff.h"
- #include "w_wad.h"
- #include "s_sound.h"
- #include "dstrings.h"
- #include "sounds.h"
- #include "d_deh.h"
- #include "g_game.h"
- #include "r_main.h"
- #include "doomiphone.h"
- #include <stdbool.h>
- int hud_active;
- int hud_displayed;
- int hud_nosecrets;
- int hud_distributed;
- int hud_graph_keys=1;
- #define HU_TITLE (*mapnames[(gameepisode-1)*9+gamemap-1])
- #define HU_TITLE2 (*mapnames2[gamemap-1])
- #define HU_TITLEP (*mapnamesp[gamemap-1])
- #define HU_TITLET (*mapnamest[gamemap-1])
- #define HU_TITLEHEIGHT 1
- #define HU_TITLEX 0
- #define HU_TITLEY ((200-ST_HEIGHT) - 1 - hu_font[0].height)
- #define HU_COORDX (320 - 13*hu_font2['A'-HU_FONTSTART].width)
- #define HU_COORDX_Y (1 + 0*hu_font['A'-HU_FONTSTART].height)
- #define HU_COORDY_Y (2 + 1*hu_font['A'-HU_FONTSTART].height)
- #define HU_COORDZ_Y (3 + 2*hu_font['A'-HU_FONTSTART].height)
- #define HU_GAPY 8
- #define HU_HUDHEIGHT (6*HU_GAPY)
- #define HU_HUDX 2
- #define HU_HUDY (200-HU_HUDHEIGHT-1)
- #define HU_MONSECX (HU_HUDX)
- #define HU_MONSECY (HU_HUDY+0*HU_GAPY)
- #define HU_KEYSX (HU_HUDX)
- #define HU_KEYSGX (HU_HUDX+4*hu_font2['A'-HU_FONTSTART].width)
- #define HU_KEYSY (HU_HUDY+1*HU_GAPY)
- #define HU_WEAPX (HU_HUDX)
- #define HU_WEAPY (HU_HUDY+2*HU_GAPY)
- #define HU_AMMOX (HU_HUDX)
- #define HU_AMMOY (HU_HUDY+3*HU_GAPY)
- #define HU_HEALTHX (HU_HUDX)
- #define HU_HEALTHY (HU_HUDY+4*HU_GAPY)
- #define HU_ARMORX (HU_HUDX)
- #define HU_ARMORY (HU_HUDY+5*HU_GAPY)
- #define HU_HUDX_LL 2
- #define HU_HUDY_LL (200-2*HU_GAPY-1)
- #define HU_HUDX_LR (320-120)
- #define HU_HUDY_LR (200-2*HU_GAPY-1)
- #define HU_HUDX_UR (320-96)
- #define HU_HUDY_UR 2
- #define HU_MONSECX_D (HU_HUDX_LL)
- #define HU_MONSECY_D (HU_HUDY_LL+0*HU_GAPY)
- #define HU_KEYSX_D (HU_HUDX_LL)
- #define HU_KEYSGX_D (HU_HUDX_LL+4*hu_font2['A'-HU_FONTSTART].width)
- #define HU_KEYSY_D (HU_HUDY_LL+1*HU_GAPY)
- #define HU_WEAPX_D (HU_HUDX_LR)
- #define HU_WEAPY_D (HU_HUDY_LR+0*HU_GAPY)
- #define HU_AMMOX_D (HU_HUDX_LR)
- #define HU_AMMOY_D (HU_HUDY_LR+1*HU_GAPY)
- #define HU_HEALTHX_D (HU_HUDX_UR)
- #define HU_HEALTHY_D (HU_HUDY_UR+0*HU_GAPY)
- #define HU_ARMORX_D (HU_HUDX_UR)
- #define HU_ARMORY_D (HU_HUDY_UR+1*HU_GAPY)
- #define HU_INPUTX HU_MSGX
- #define HU_INPUTY (HU_MSGY + HU_MSGHEIGHT*(hu_font[0].height) +1)
- #define HU_INPUTWIDTH 64
- #define HU_INPUTHEIGHT 1
- #define key_alt KEYD_RALT
- #define key_shift KEYD_RSHIFT
- const char* chat_macros[] =
- {
- HUSTR_CHATMACRO0,
- HUSTR_CHATMACRO1,
- HUSTR_CHATMACRO2,
- HUSTR_CHATMACRO3,
- HUSTR_CHATMACRO4,
- HUSTR_CHATMACRO5,
- HUSTR_CHATMACRO6,
- HUSTR_CHATMACRO7,
- HUSTR_CHATMACRO8,
- HUSTR_CHATMACRO9
- };
- const char* player_names[] =
- {
- HUSTR_PLRGREEN,
- HUSTR_PLRINDIGO,
- HUSTR_PLRBROWN,
- HUSTR_PLRRED
- };
- int plyrcoltran[MAXPLAYERS]={CR_GREEN,CR_GRAY,CR_BROWN,CR_RED};
- char chat_char;
- static player_t* plr;
- patchnum_t hu_font[HU_FONTSIZE];
- patchnum_t hu_font2[HU_FONTSIZE];
- patchnum_t hu_fontk[HU_FONTSIZE];
- patchnum_t hu_msgbg[9];
- static hu_textline_t w_title;
- static hu_stext_t w_message;
- static hu_itext_t w_chat;
- static hu_itext_t w_inputbuffer[MAXPLAYERS];
- static hu_textline_t w_coordx;
- static hu_textline_t w_coordy;
- static hu_textline_t w_coordz;
- static hu_textline_t w_ammo;
- static hu_textline_t w_health;
- static hu_textline_t w_armor;
- static hu_textline_t w_weapon;
- static hu_textline_t w_keys;
- static hu_textline_t w_gkeys;
- static hu_textline_t w_monsec;
- static hu_mtext_t w_rtext;
- static boolean always_off = false;
- static char chat_dest[MAXPLAYERS];
- boolean chat_on;
- static boolean message_on;
- static boolean message_list;
- boolean message_dontfuckwithme;
- static boolean message_nottobefuckedwith;
- static int message_counter;
- extern int showMessages;
- extern boolean automapactive;
- static boolean headsupactive = false;
- int hudcolor_titl;
- int hudcolor_xyco;
- int hudcolor_mesg;
- int hudcolor_chat;
- int hud_msg_lines;
- int hudcolor_list;
- int hud_list_bgon;
- static char hud_coordstrx[32];
- static char hud_coordstry[32];
- static char hud_coordstrz[32];
- static char hud_ammostr[80];
- static char hud_healthstr[80];
- static char hud_armorstr[80];
- static char hud_weapstr[80];
- static char hud_keysstr[80];
- static char hud_gkeysstr[80];
- static char hud_monsecstr[80];
- extern char **mapnames[];
- extern char **mapnames2[];
- extern char **mapnamesp[];
- extern char **mapnamest[];
- extern int map_point_coordinates;
- const char* shiftxform;
- const 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,
- ' ', '!', '"', '#', '$', '%', '&',
- '"',
- '(', ')', '*', '+',
- '<',
- '_',
- '>',
- '?',
- ')',
- '!',
- '@',
- '#',
- '$',
- '%',
- '^',
- '&',
- '*',
- '(',
- ':',
- ':',
- '<',
- '+',
- '>', '?', '@',
- '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',
- '[',
- '!',
- ']',
- '"', '_',
- '\'',
- '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
- };
- void HU_Init(void)
- {
- int i;
- int j;
- char buffer[9];
- shiftxform = english_shiftxform;
-
- j = HU_FONTSTART;
- for (i=0;i<HU_FONTSIZE;i++,j++)
- {
- if ('0'<=j && j<='9')
- {
- sprintf(buffer, "DIG%.1d",j-48);
- R_SetPatchNum(&hu_font2[i], buffer);
- sprintf(buffer, "STCFN%.3d",j);
- R_SetPatchNum(&hu_font[i], buffer);
- }
- else if ('A'<=j && j<='Z')
- {
- sprintf(buffer, "DIG%c",j);
- R_SetPatchNum(&hu_font2[i], buffer);
- sprintf(buffer, "STCFN%.3d",j);
- R_SetPatchNum(&hu_font[i], buffer);
- }
- else if (j=='-')
- {
- R_SetPatchNum(&hu_font2[i], "DIG45");
- R_SetPatchNum(&hu_font[i], "STCFN045");
- }
- else if (j=='/')
- {
- R_SetPatchNum(&hu_font2[i], "DIG47");
- R_SetPatchNum(&hu_font[i], "STCFN047");
- }
- else if (j==':')
- {
- R_SetPatchNum(&hu_font2[i], "DIG58");
- R_SetPatchNum(&hu_font[i], "STCFN058");
- }
- else if (j=='[')
- {
- R_SetPatchNum(&hu_font2[i], "DIG91");
- R_SetPatchNum(&hu_font[i], "STCFN091");
- }
- else if (j==']')
- {
- R_SetPatchNum(&hu_font2[i], "DIG93");
- R_SetPatchNum(&hu_font[i], "STCFN093");
- }
- else if (j<97)
- {
- sprintf(buffer, "STCFN%.3d",j);
- R_SetPatchNum(&hu_font2[i], buffer);
- R_SetPatchNum(&hu_font[i], buffer);
-
- }
- else if (j>122)
- {
- sprintf(buffer, "STBR%.3d",j);
- R_SetPatchNum(&hu_font2[i], buffer);
- R_SetPatchNum(&hu_font[i], buffer);
- }
- else
- hu_font[i] = hu_font[0];
- }
-
- for (i=0; i<9; i++) {
- sprintf(buffer, "BOX%c%c", "UCL"[i/3], "LCR"[i%3]);
- R_SetPatchNum(&hu_msgbg[i], buffer);
- }
-
- for (i=0; i<6; i++) {
- sprintf(buffer, "STKEYS%d", i);
- R_SetPatchNum(&hu_fontk[i], buffer);
- }
- }
- static void HU_Stop(void)
- {
- headsupactive = false;
- }
- void HU_Start(void)
- {
- int i;
- const char* s;
- if (headsupactive)
- HU_Stop();
- plr = &players[displayplayer];
- message_on = false;
- message_dontfuckwithme = false;
- message_nottobefuckedwith = false;
- chat_on = false;
-
-
- HUlib_initSText
- (
- &w_message,
- HU_MSGX,
- HU_MSGY,
- HU_MSGHEIGHT,
- hu_font,
- HU_FONTSTART,
- hudcolor_mesg,
- &message_on
- );
-
-
- HUlib_initTextLine
- (
- &w_title,
- HU_TITLEX,
- HU_TITLEY,
- hu_font,
- HU_FONTSTART,
- hudcolor_titl
- );
-
-
-
- HUlib_initTextLine
- (
- &w_health,
- hud_distributed? HU_HEALTHX_D : HU_HEALTHX,
- hud_distributed? HU_HEALTHY_D : HU_HEALTHY,
- hu_font2,
- HU_FONTSTART,
- CR_GREEN
- );
-
-
-
- HUlib_initTextLine
- (
- &w_armor,
- hud_distributed? HU_ARMORX_D : HU_ARMORX,
- hud_distributed? HU_ARMORY_D : HU_ARMORY,
- hu_font2,
- HU_FONTSTART,
- CR_GREEN
- );
-
-
-
- HUlib_initTextLine
- (
- &w_ammo,
- hud_distributed? HU_AMMOX_D : HU_AMMOX,
- hud_distributed? HU_AMMOY_D : HU_AMMOY,
- hu_font2,
- HU_FONTSTART,
- CR_GOLD
- );
-
-
-
- HUlib_initTextLine
- (
- &w_weapon,
- hud_distributed? HU_WEAPX_D : HU_WEAPX,
- hud_distributed? HU_WEAPY_D : HU_WEAPY,
- hu_font2,
- HU_FONTSTART,
- CR_GRAY
- );
-
-
-
- HUlib_initTextLine
- (
- &w_keys,
- hud_distributed? HU_KEYSX_D : HU_KEYSX,
- hud_distributed? HU_KEYSY_D : HU_KEYSY,
- hu_font2,
- HU_FONTSTART,
- CR_GRAY
- );
-
-
-
- HUlib_initTextLine
- (
- &w_gkeys,
- hud_distributed? HU_KEYSGX_D : HU_KEYSGX,
- hud_distributed? HU_KEYSY_D : HU_KEYSY,
- hu_fontk,
- HU_FONTSTART,
- CR_RED
- );
-
-
-
- HUlib_initTextLine
- (
- &w_monsec,
- hud_distributed? HU_MONSECX_D : HU_MONSECX,
- hud_distributed? HU_MONSECY_D : HU_MONSECY,
- hu_font2,
- HU_FONTSTART,
- CR_GRAY
- );
-
-
- if (hud_msg_lines>HU_MAXMESSAGES)
- hud_msg_lines=HU_MAXMESSAGES;
-
- message_list = hud_msg_lines > 1;
-
- HUlib_initMText
- (
- &w_rtext,
- 0,
- 0,
- 320,
- (hud_msg_lines+2)*HU_REFRESHSPACING,
- hu_font,
- HU_FONTSTART,
- hudcolor_list,
- hu_msgbg,
- &message_list
- );
-
- if (gamestate == GS_LEVEL)
- switch (gamemode)
- {
- case shareware:
- case registered:
- case retail:
- s = HU_TITLE;
- break;
- case commercial:
- default:
- s = (gamemission==pack_tnt) ? HU_TITLET :
- (gamemission==pack_plut) ? HU_TITLEP : HU_TITLE2;
- break;
- } else s = "";
- while (*s)
- HUlib_addCharToTextLine(&w_title, *(s++));
-
-
-
- HUlib_initTextLine
- (
- &w_coordx,
- HU_COORDX,
- HU_COORDX_Y,
- hu_font,
- HU_FONTSTART,
- hudcolor_xyco
- );
- HUlib_initTextLine
- (
- &w_coordy,
- HU_COORDX,
- HU_COORDY_Y,
- hu_font,
- HU_FONTSTART,
- hudcolor_xyco
- );
- HUlib_initTextLine
- (
- &w_coordz,
- HU_COORDX,
- HU_COORDZ_Y,
- hu_font,
- HU_FONTSTART,
- hudcolor_xyco
- );
-
-
- if (map_point_coordinates)
- {
- sprintf(hud_coordstrx,"X: %-5d",0);
- s = hud_coordstrx;
- while (*s)
- HUlib_addCharToTextLine(&w_coordx, *(s++));
- sprintf(hud_coordstry,"Y: %-5d",0);
- s = hud_coordstry;
- while (*s)
- HUlib_addCharToTextLine(&w_coordy, *(s++));
- sprintf(hud_coordstrz,"Z: %-5d",0);
- s = hud_coordstrz;
- while (*s)
- HUlib_addCharToTextLine(&w_coordz, *(s++));
- }
-
- strcpy(hud_ammostr,"AMM ");
- s = hud_ammostr;
- while (*s)
- HUlib_addCharToTextLine(&w_ammo, *(s++));
-
- strcpy(hud_healthstr,"HEL ");
- s = hud_healthstr;
- while (*s)
- HUlib_addCharToTextLine(&w_health, *(s++));
-
- strcpy(hud_armorstr,"ARM ");
- s = hud_armorstr;
- while (*s)
- HUlib_addCharToTextLine(&w_armor, *(s++));
-
- strcpy(hud_weapstr,"WEA ");
- s = hud_weapstr;
- while (*s)
- HUlib_addCharToTextLine(&w_weapon, *(s++));
-
- if (!deathmatch)
- strcpy(hud_keysstr,"KEY ");
- else
- strcpy(hud_keysstr,"FRG ");
- s = hud_keysstr;
- while (*s)
- HUlib_addCharToTextLine(&w_keys, *(s++));
-
- strcpy(hud_gkeysstr," ");
- s = hud_gkeysstr;
- while (*s)
- HUlib_addCharToTextLine(&w_gkeys, *(s++));
-
- strcpy(hud_monsecstr,"STS ");
- s = hud_monsecstr;
- while (*s)
- HUlib_addCharToTextLine(&w_monsec, *(s++));
-
- HUlib_initIText
- (
- &w_chat,
- HU_INPUTX,
- HU_INPUTY,
- hu_font,
- HU_FONTSTART,
- hudcolor_chat,
- &chat_on
- );
-
- for (i=0 ; i<MAXPLAYERS ; i++)
- HUlib_initIText
- (
- &w_inputbuffer[i],
- 0,
- 0,
- 0,
- 0,
- hudcolor_chat,
- &always_off
- );
-
- headsupactive = true;
- }
- void HU_MoveHud(void)
- {
- static int ohud_distributed=-1;
-
- if (hud_distributed!=ohud_distributed)
- {
- w_ammo.x = hud_distributed? HU_AMMOX_D : HU_AMMOX;
- w_ammo.y = hud_distributed? HU_AMMOY_D : HU_AMMOY;
- w_weapon.x = hud_distributed? HU_WEAPX_D : HU_WEAPX;
- w_weapon.y = hud_distributed? HU_WEAPY_D : HU_WEAPY;
- w_keys.x = hud_distributed? HU_KEYSX_D : HU_KEYSX;
- w_keys.y = hud_distributed? HU_KEYSY_D : HU_KEYSY;
- w_gkeys.x = hud_distributed? HU_KEYSGX_D : HU_KEYSGX;
- w_gkeys.y = hud_distributed? HU_KEYSY_D : HU_KEYSY;
- w_monsec.x = hud_distributed? HU_MONSECX_D : HU_MONSECX;
- w_monsec.y = hud_distributed? HU_MONSECY_D : HU_MONSECY;
- w_health.x = hud_distributed? HU_HEALTHX_D : HU_HEALTHX;
- w_health.y = hud_distributed? HU_HEALTHY_D : HU_HEALTHY;
- w_armor.x = hud_distributed? HU_ARMORX_D : HU_ARMORX;
- w_armor.y = hud_distributed? HU_ARMORY_D : HU_ARMORY;
- }
- ohud_distributed = hud_distributed;
- }
- void HU_Drawer(void)
- {
- char *s;
- player_t *player;
- char ammostr[80];
- char healthstr[80];
- char armorstr[80];
- int i,doit;
- player = &players[displayplayer];
-
- if (automapmode & am_active)
- {
-
- HUlib_drawTextLine(&w_title, false);
-
-
- if (map_point_coordinates)
- {
- sprintf(hud_coordstrx,"X: %-5d", (player->mo->x)>>FRACBITS);
- HUlib_clearTextLine(&w_coordx);
- s = hud_coordstrx;
- while (*s)
- HUlib_addCharToTextLine(&w_coordx, *(s++));
- HUlib_drawTextLine(&w_coordx, false);
-
-
- sprintf(hud_coordstry,"Y: %-5d", (player->mo->y)>>FRACBITS);
- HUlib_clearTextLine(&w_coordy);
- s = hud_coordstry;
- while (*s)
- HUlib_addCharToTextLine(&w_coordy, *(s++));
- HUlib_drawTextLine(&w_coordy, false);
-
-
-
- sprintf(hud_coordstrz,"Z: %-5d", (player->mo->z)>>FRACBITS);
- HUlib_clearTextLine(&w_coordz);
- s = hud_coordstrz;
- while (*s)
- HUlib_addCharToTextLine(&w_coordz, *(s++));
- HUlib_drawTextLine(&w_coordz, false);
- }
- }
-
-
-
- if
- (
- hud_active>0 &&
- hud_displayed &&
- viewheight==SCREENHEIGHT &&
- !(automapmode & am_active)
- )
- {
- doit = !(gametic&1);
- if (doit)
- {
- HU_MoveHud();
-
-
- HUlib_clearTextLine(&w_ammo);
- strcpy(hud_ammostr,"AMM ");
- if (weaponinfo[player->readyweapon].ammo == am_noammo)
- {
- strcat(hud_ammostr,"\x7f\x7f\x7f\x7f\x7f\x7f\x7f N/A");
- w_ammo.cm = CR_GRAY;
- }
- else
- {
- int ammo = player->ammo[weaponinfo[player->readyweapon].ammo];
- int fullammo = player->maxammo[weaponinfo[player->readyweapon].ammo];
- int ammopct = (100*ammo)/fullammo;
- int ammobars = ammopct/4;
-
- sprintf(ammostr,"%d/%d",ammo,fullammo);
-
-
- for (i=4;i<4+ammobars/4;)
- hud_ammostr[i++] = 123;
-
- switch(ammobars%4)
- {
- case 0:
- break;
- case 1:
- hud_ammostr[i++] = 126;
- break;
- case 2:
- hud_ammostr[i++] = 125;
- break;
- case 3:
- hud_ammostr[i++] = 124;
- break;
- }
-
- while(i<4+7)
- hud_ammostr[i++] = 127;
- hud_ammostr[i] = '\0';
- strcat(hud_ammostr,ammostr);
-
- if (ammopct<ammo_red)
- w_ammo.cm = CR_RED;
- else if (ammopct<ammo_yellow)
- w_ammo.cm = CR_GOLD;
- else
- w_ammo.cm = CR_GREEN;
- }
-
- s = hud_ammostr;
- while (*s)
- HUlib_addCharToTextLine(&w_ammo, *(s++));
- }
-
- HUlib_drawTextLine(&w_ammo, false);
-
- if (doit)
- {
- int health = player->health;
- int healthbars = health>100? 25 : health/4;
-
- HUlib_clearTextLine(&w_health);
-
- sprintf(healthstr,"%3d",health);
-
-
- for (i=4;i<4+healthbars/4;)
- hud_healthstr[i++] = 123;
-
- switch(healthbars%4)
- {
- case 0:
- break;
- case 1:
- hud_healthstr[i++] = 126;
- break;
- case 2:
- hud_healthstr[i++] = 125;
- break;
- case 3:
- hud_healthstr[i++] = 124;
- break;
- }
-
- while(i<4+7)
- hud_healthstr[i++] = 127;
- hud_healthstr[i] = '\0';
- strcat(hud_healthstr,healthstr);
-
- if (health<health_red)
- w_health.cm = CR_RED;
- else if (health<health_yellow)
- w_health.cm = CR_GOLD;
- else if (health<=health_green)
- w_health.cm = CR_GREEN;
- else
- w_health.cm = CR_BLUE;
-
- s = hud_healthstr;
- while (*s)
- HUlib_addCharToTextLine(&w_health, *(s++));
- }
-
- HUlib_drawTextLine(&w_health, false);
-
- if (doit)
- {
- int armor = player->armorpoints;
- int armorbars = armor>100? 25 : armor/4;
-
- HUlib_clearTextLine(&w_armor);
-
- sprintf(armorstr,"%3d",armor);
-
-
- for (i=4;i<4+armorbars/4;)
- hud_armorstr[i++] = 123;
-
- switch(armorbars%4)
- {
- case 0:
- break;
- case 1:
- hud_armorstr[i++] = 126;
- break;
- case 2:
- hud_armorstr[i++] = 125;
- break;
- case 3:
- hud_armorstr[i++] = 124;
- break;
- }
-
- while(i<4+7)
- hud_armorstr[i++] = 127;
- hud_armorstr[i] = '\0';
- strcat(hud_armorstr,armorstr);
-
- if (armor<armor_red)
- w_armor.cm = CR_RED;
- else if (armor<armor_yellow)
- w_armor.cm = CR_GOLD;
- else if (armor<=armor_green)
- w_armor.cm = CR_GREEN;
- else
- w_armor.cm = CR_BLUE;
-
- s = hud_armorstr;
- while (*s)
- HUlib_addCharToTextLine(&w_armor, *(s++));
- }
-
- HUlib_drawTextLine(&w_armor, false);
-
- if (doit)
- {
- int w;
- int ammo,fullammo,ammopct;
-
- HUlib_clearTextLine(&w_weapon);
- i=4; hud_weapstr[i] = '\0';
-
- for (w=0;w<=wp_supershotgun;w++)
- {
- int ok=1;
-
- switch (gamemode)
- {
- case shareware:
- if (w>=wp_plasma && w!=wp_chainsaw)
- ok=0;
- break;
- case retail:
- case registered:
- if (w>=wp_supershotgun)
- ok=0;
- break;
- default:
- case commercial:
- break;
- }
- if (!ok) continue;
- ammo = player->ammo[weaponinfo[w].ammo];
- fullammo = player->maxammo[weaponinfo[w].ammo];
- ammopct=0;
-
- if (!player->weaponowned[w])
- continue;
- ammopct = fullammo? (100*ammo)/fullammo : 100;
-
- hud_weapstr[i++] = '\x1b';
- if (weaponinfo[w].ammo==am_noammo)
- hud_weapstr[i++] = player->powers[pw_strength]? '0'+CR_GREEN : '0'+CR_GRAY;
- else if (ammopct<ammo_red)
- hud_weapstr[i++] = '0'+CR_RED;
- else if (ammopct<ammo_yellow)
- hud_weapstr[i++] = '0'+CR_GOLD;
- else
- hud_weapstr[i++] = '0'+CR_GREEN;
- hud_weapstr[i++] = '0'+w+1;
- hud_weapstr[i++] = ' ';
- hud_weapstr[i] = '\0';
- }
-
- s = hud_weapstr;
- while (*s)
- HUlib_addCharToTextLine(&w_weapon, *(s++));
- }
-
- HUlib_drawTextLine(&w_weapon, false);
- if (doit && hud_active>1)
- {
- int k;
- hud_keysstr[4] = '\0';
-
- if (!deathmatch && hud_graph_keys)
- {
- i=0;
- hud_gkeysstr[i] = '\0';
-
- for (k=0;k<6;k++)
- {
-
- if (!player->cards[k])
- continue;
- hud_gkeysstr[i++] = '!'+k;
- hud_gkeysstr[i++] = ' ';
- hud_gkeysstr[i++] = ' ';
- }
- hud_gkeysstr[i]='\0';
- }
- else
- {
- i=4;
- hud_keysstr[i] = '\0';
-
- if (deathmatch)
- {
- int top1=-999,top2=-999,top3=-999,top4=-999;
- int idx1=-1,idx2=-1,idx3=-1,idx4=-1;
- int fragcount,m;
- char numbuf[32];
-
- for (k=0;k<MAXPLAYERS;k++)
- {
-
- if (!playeringame[k])
- continue;
- fragcount = 0;
-
-
- for (m=0;m<MAXPLAYERS;m++)
- {
- if (!playeringame[m]) continue;
- fragcount += (m!=k)? players[k].frags[m] : -players[k].frags[m];
- }
-
- if (fragcount>top1)
- {
- top4=top3; top3=top2; top2 = top1; top1=fragcount;
- idx4=idx3; idx3=idx2; idx2 = idx1; idx1=k;
- }
- else if (fragcount>top2)
- {
- top4=top3; top3=top2; top2=fragcount;
- idx4=idx3; idx3=idx2; idx2=k;
- }
- else if (fragcount>top3)
- {
- top4=top3; top3=fragcount;
- idx4=idx3; idx3=k;
- }
- else if (fragcount>top4)
- {
- top4=fragcount;
- idx4=k;
- }
- }
-
- if (idx1>-1)
- {
- sprintf(numbuf,"%5d",top1);
-
- hud_keysstr[i++] = '\x1b';
- hud_keysstr[i++] = '0'+plyrcoltran[idx1&3];
- s = numbuf;
- while (*s)
- hud_keysstr[i++] = *(s++);
- }
-
- if (idx2>-1)
- {
- sprintf(numbuf,"%5d",top2);
-
- hud_keysstr[i++] = '\x1b';
- hud_keysstr[i++] = '0'+plyrcoltran[idx2&3];
- s = numbuf;
- while (*s)
- hud_keysstr[i++] = *(s++);
- }
-
- if (idx3>-1)
- {
- sprintf(numbuf,"%5d",top3);
-
- hud_keysstr[i++] = '\x1b';
- hud_keysstr[i++] = '0'+plyrcoltran[idx3&3];
- s = numbuf;
- while (*s)
- hud_keysstr[i++] = *(s++);
- }
-
- if (idx4>-1)
- {
- sprintf(numbuf,"%5d",top4);
-
- hud_keysstr[i++] = '\x1b';
- hud_keysstr[i++] = '0'+plyrcoltran[idx4&3];
- s = numbuf;
- while (*s)
- hud_keysstr[i++] = *(s++);
- }
- hud_keysstr[i] = '\0';
- }
- else
- {
-
- for (k=0;k<6;k++)
- {
-
- if (!player->cards[k])
- continue;
-
- hud_keysstr[i++] = '\x1b';
- switch(k)
- {
- case 0:
- hud_keysstr[i++] = '0'+CR_BLUE;
- hud_keysstr[i++] = 'B';
- hud_keysstr[i++] = 'C';
- hud_keysstr[i++] = ' ';
- break;
- case 1:
- hud_keysstr[i++] = '0'+CR_GOLD;
- hud_keysstr[i++] = 'Y';
- hud_keysstr[i++] = 'C';
- hud_keysstr[i++] = ' ';
- break;
- case 2:
- hud_keysstr[i++] = '0'+CR_RED;
- hud_keysstr[i++] = 'R';
- hud_keysstr[i++] = 'C';
- hud_keysstr[i++] = ' ';
- break;
- case 3:
- hud_keysstr[i++] = '0'+CR_BLUE;
- hud_keysstr[i++] = 'B';
- hud_keysstr[i++] = 'S';
- hud_keysstr[i++] = ' ';
- break;
- case 4:
- hud_keysstr[i++] = '0'+CR_GOLD;
- hud_keysstr[i++] = 'Y';
- hud_keysstr[i++] = 'S';
- hud_keysstr[i++] = ' ';
- break;
- case 5:
- hud_keysstr[i++] = '0'+CR_RED;
- hud_keysstr[i++] = 'R';
- hud_keysstr[i++] = 'S';
- hud_keysstr[i++] = ' ';
- break;
- }
- hud_keysstr[i]='\0';
- }
- }
- }
- }
-
- if (hud_active>1)
- {
- HUlib_clearTextLine(&w_keys);
- HUlib_clearTextLine(&w_gkeys);
-
- s = hud_keysstr;
- while (*s)
- HUlib_addCharToTextLine(&w_keys, *(s++));
- HUlib_drawTextLine(&w_keys, false);
-
- if (!deathmatch)
- {
-
- s = hud_gkeysstr;
- while (*s)
- HUlib_addCharToTextLine(&w_gkeys, *(s++));
-
- HUlib_drawTextLine(&w_gkeys, false);
- }
- }
-
- if (!hud_nosecrets)
- {
- if (hud_active>1 && doit)
- {
-
- HUlib_clearTextLine(&w_monsec);
-
-
- sprintf
- (
- hud_monsecstr,
- "STS \x1b\x36K \x1b\x33%d \x1b\x36M \x1b\x33%d \x1b\x37I \x1b\x33%d/%d \x1b\x35S \x1b\x33%d/%d",
- player->killcount,totallive,
- player->itemcount,totalitems,
- player->secretcount,totalsecret
- );
-
- s = hud_monsecstr;
- while (*s)
- HUlib_addCharToTextLine(&w_monsec, *(s++));
- }
-
- if (hud_active>1)
- HUlib_drawTextLine(&w_monsec, false);
- }
- }
-
- HU_Erase();
-
-
- if (hud_msg_lines<=1)
- message_list = false;
-
- if (!message_list)
- HUlib_drawSText(&w_message);
-
- if (hud_msg_lines>1 && message_list)
- HUlib_drawMText(&w_rtext);
-
- HUlib_drawIText(&w_chat);
- }
- void HU_Erase(void)
- {
-
- if (!message_list)
- HUlib_eraseSText(&w_message);
- else
- HUlib_eraseMText(&w_rtext);
-
- HUlib_eraseIText(&w_chat);
-
- HUlib_eraseTextLine(&w_title);
- }
- static boolean bsdown;
- static int bscounter;
- void HU_Ticker(void)
- {
- int i, rc;
- char c;
-
- if (message_counter && !--message_counter)
- {
- message_on = false;
- message_nottobefuckedwith = false;
- }
- if (bsdown && bscounter++ > 9) {
- HUlib_keyInIText(&w_chat, (unsigned char)key_backspace);
- bscounter = 8;
- }
-
-
- if (showMessages || message_dontfuckwithme)
- {
-
- if ((plr->message && !message_nottobefuckedwith)
- || (plr->message && message_dontfuckwithme))
- {
- #ifdef IPHONE
-
- iphoneSetNotifyText( "%s", plr->message );
- #else
-
- HUlib_addMessageToSText(&w_message, 0, plr->message);
-
- HUlib_addMessageToMText(&w_rtext, 0, plr->message);
- #endif
-
- plr->message = 0;
-
- message_on = true;
-
- message_counter = HU_MSGTIMEOUT;
-
- message_nottobefuckedwith = message_dontfuckwithme;
-
- message_dontfuckwithme = 0;
- }
- }
-
- if (netgame)
- {
- for (i=0; i<MAXPLAYERS; i++)
- {
- if (!playeringame[i])
- continue;
- if (i != consoleplayer
- && (c = players[i].cmd.chatchar))
- {
- if (c <= HU_BROADCAST)
- chat_dest[i] = c;
- else
- {
- if (c >= 'a' && c <= 'z')
- c = (char) shiftxform[(unsigned char) c];
- rc = HUlib_keyInIText(&w_inputbuffer[i], c);
- if (rc && c == KEYD_ENTER)
- {
- if (w_inputbuffer[i].l.len
- && (chat_dest[i] == consoleplayer+1
- || chat_dest[i] == HU_BROADCAST))
- {
- HUlib_addMessageToSText(&w_message,
- player_names[i],
- w_inputbuffer[i].l.l);
- message_nottobefuckedwith = true;
- message_on = true;
- message_counter = HU_MSGTIMEOUT;
- if ( gamemode == commercial )
- S_StartSound(0, sfx_radio);
- else
- S_StartSound(0, sfx_tink);
- }
- HUlib_resetIText(&w_inputbuffer[i]);
- }
- }
- players[i].cmd.chatchar = 0;
- }
- }
- }
- }
- #define QUEUESIZE 128
- static char chatchars[QUEUESIZE];
- static int head = 0;
- static int tail = 0;
- static void HU_queueChatChar(char c)
- {
- if (((head + 1) & (QUEUESIZE-1)) == tail)
- {
- plr->message = HUSTR_MSGU;
- }
- else
- {
- chatchars[head] = c;
- head = (head + 1) & (QUEUESIZE-1);
- }
- }
- char HU_dequeueChatChar(void)
- {
- char c;
- if (head != tail)
- {
- c = chatchars[tail];
- tail = (tail + 1) & (QUEUESIZE-1);
- }
- else
- {
- c = 0;
- }
- return c;
- }
- boolean HU_Responder(event_t *ev)
- {
- static char lastmessage[HU_MAXLINELENGTH+1];
- const char* macromessage;
- boolean eatkey = false;
- static boolean shiftdown = false;
- static boolean altdown = false;
- unsigned char c;
- int i;
- int numplayers;
- static int num_nobrainers = 0;
- numplayers = 0;
- for (i=0 ; i<MAXPLAYERS ; i++)
- numplayers += playeringame[i];
- if (ev->data1 == key_shift)
- {
- shiftdown = ev->type == ev_keydown;
- return false;
- }
- else if (ev->data1 == key_alt)
- {
- altdown = ev->type == ev_keydown;
- return false;
- }
- else if (ev->data1 == key_backspace)
- {
- bsdown = ev->type == ev_keydown;
- bscounter = 0;
- }
- if (ev->type != ev_keydown)
- return false;
- if (!chat_on)
- {
- if (ev->data1 == key_enter)
- {
- #ifndef INSTRUMENTED
- if (hud_msg_lines>1)
- {
- if (message_list) HU_Erase();
- message_list = !message_list;
- }
- #endif
- if (!message_list)
- {
- message_on = true;
- message_counter = HU_MSGTIMEOUT;
- }
- eatkey = true;
- }
-
-
- else if (!demoplayback && !message_list && netgame && numplayers > 1)
- {
- if (ev->data1 == key_chat)
- {
- eatkey = chat_on = true;
- HUlib_resetIText(&w_chat);
- HU_queueChatChar(HU_BROADCAST);
- }
- else if (numplayers > 2)
- {
- for (i=0; i<MAXPLAYERS ; i++)
- {
- if (ev->data1 == destination_keys[i])
- {
- if (playeringame[i] && i!=consoleplayer)
- {
- eatkey = chat_on = true;
- HUlib_resetIText(&w_chat);
- HU_queueChatChar((char)(i+1));
- break;
- }
- else if (i == consoleplayer)
- {
- num_nobrainers++;
- if (num_nobrainers < 3)
- plr->message = HUSTR_TALKTOSELF1;
- else if (num_nobrainers < 6)
- plr->message = HUSTR_TALKTOSELF2;
- else if (num_nobrainers < 9)
- plr->message = HUSTR_TALKTOSELF3;
- else if (num_nobrainers < 32)
- plr->message = HUSTR_TALKTOSELF4;
- else
- plr->message = HUSTR_TALKTOSELF5;
- }
- }
- }
- }
- }
- }
- else if (!message_list)
- {
- c = ev->data1;
-
- if (altdown)
- {
- c = c - '0';
- if (c > 9)
- return false;
- macromessage = chat_macros[c];
-
- HU_queueChatChar((char)key_enter);
-
- while (*macromessage)
- HU_queueChatChar(*macromessage++);
- HU_queueChatChar((char)key_enter);
-
- chat_on = false;
- strcpy(lastmessage, chat_macros[c]);
- plr->message = lastmessage;
- eatkey = true;
- }
- else
- {
- if (shiftdown || (c >= 'a' && c <= 'z'))
- c = shiftxform[c];
- eatkey = HUlib_keyInIText(&w_chat, c);
- if (eatkey)
- HU_queueChatChar(c);
- if (c == key_enter)
- {
- chat_on = false;
- if (w_chat.l.len)
- {
- strcpy(lastmessage, w_chat.l.l);
- plr->message = lastmessage;
- }
- }
- else if (c == key_escape)
- chat_on = false;
- }
- }
- return eatkey;
- }
|