1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
6 // Copyright (C) 1993-1996 by id Software, Inc.
8 // This source is available for distribution and/or modification
9 // only under the terms of the DOOM Source Code License as
10 // published by id Software. All rights reserved.
12 // The source is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
18 // Revision 1.1 2000/02/29 18:21:04 stegerg
19 // Doom port based on ADoomPPC. Read README.AROS!
22 // DESCRIPTION: Heads-up displays
24 //-----------------------------------------------------------------------------
50 // Locally used constants, shortcuts.
52 #define HU_TITLE (mapnames[(gameepisode-1)*9+gamemap-1])
53 #define HU_TITLE2 (mapnames2[gamemap-1])
54 #define HU_TITLEP (mapnamesp[gamemap-1])
55 #define HU_TITLET (mapnamest[gamemap-1])
56 #define HU_TITLEHEIGHT 1
58 //#define HU_TITLEY (167 - SWAPSHORT(hu_font[0]->height))
59 #define HU_TITLEY (SCREENHEIGHT-(200-(167 - SWAPSHORT(hu_font[0]->height))))
61 #define HU_INPUTTOGGLE 't'
62 #define HU_INPUTX HU_MSGX
63 #define HU_INPUTY (HU_MSGY + HU_MSGHEIGHT*(SWAPSHORT(hu_font[0]->height) +1))
64 #define HU_INPUTWIDTH 64
65 #define HU_INPUTHEIGHT 1
83 char* player_names
[] =
92 char chat_char
; // remove later.
94 patch_t
* hu_font
[HU_FONTSIZE
];
95 static hu_textline_t w_title
;
97 static hu_itext_t w_chat
;
98 static boolean always_off
= false;
99 static char chat_dest
[MAXPLAYERS
];
100 static hu_itext_t w_inputbuffer
[MAXPLAYERS
];
102 static boolean message_on
;
103 boolean message_dontfuckwithme
;
104 static boolean message_nottobefuckedwith
;
106 static hu_stext_t w_message
;
107 static int message_counter
;
109 extern int showMessages
;
110 extern boolean automapactive
;
112 static boolean headsupactive
= false;
115 // Builtin map names.
116 // The actual names can be found in DStrings.h.
119 char* mapnames
[] = // DOOM shareware/registered/retail (Ultimate) names.
173 char* mapnames2
[] = // DOOM 2 map names.
212 char* mapnamesp
[] = // Plutonia WAD map names.
251 char *mapnamest
[] = // TNT WAD map names.
290 const char* shiftxform
;
292 const char french_shiftxform
[] =
295 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
296 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
297 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
299 ' ', '!', '"', '#', '$', '%', '&',
321 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
322 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
324 '!', // shift-backslash - OH MY GOD DOES WATCOM SUCK
328 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
329 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
330 '{', '|', '}', '~', 127
334 const char english_shiftxform
[] =
338 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
339 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
340 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
342 ' ', '!', '"', '#', '$', '%', '&',
364 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
365 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
367 '!', // shift-backslash - OH MY GOD DOES WATCOM SUCK
371 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
372 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
373 '{', '|', '}', '~', 127
376 char frenchKeyMap
[128]=
379 1,2,3,4,5,6,7,8,9,10,
380 11,12,13,14,15,16,17,18,19,20,
381 21,22,23,24,25,26,27,28,29,30,
383 ' ','!','"','#','$','%','&','%','(',')','*','+',';','-',':','!',
384 '0','1','2','3','4','5','6','7','8','9',':','M','<','=','>','?',
385 '@','Q','B','C','D','E','F','G','H','I','J','K','L',',','N','O',
386 'P','A','R','S','T','U','V','Z','X','Y','W','^','\\','$','^','_',
387 '@','Q','B','C','D','E','F','G','H','I','J','K','L',',','N','O',
388 'P','A','R','S','T','U','V','Z','X','Y','W','^','\\','$','^',127
391 char ForeignTranslation(unsigned char ch
)
393 return ch
< 128 ? frenchKeyMap
[ch
] : ch
;
403 if (language
==french
)
404 shiftxform
= french_shiftxform
;
406 shiftxform
= english_shiftxform
;
408 // load the heads-up font
410 for (i
=0;i
<HU_FONTSIZE
;i
++)
412 sprintf(buffer
, "STCFN%.3d", j
++);
413 hu_font
[i
] = (patch_t
*) W_CacheLumpName(buffer
, PU_STATIC
);
420 headsupactive
= false;
432 plr
= &players
[consoleplayer
];
434 message_dontfuckwithme
= false;
435 message_nottobefuckedwith
= false;
438 // create the message widget
439 HUlib_initSText(&w_message
,
440 HU_MSGX
, HU_MSGY
, HU_MSGHEIGHT
,
442 HU_FONTSTART
, &message_on
);
444 // create the map title widget
445 HUlib_initTextLine(&w_title
,
446 HU_TITLEX
, HU_TITLEY
,
474 HUlib_addCharToTextLine(&w_title
, *(s
++));
476 // create the chat widget
477 HUlib_initIText(&w_chat
,
478 HU_INPUTX
, HU_INPUTY
,
480 HU_FONTSTART
, &chat_on
);
482 // create the inputbuffer widgets
483 for (i
=0 ; i
<MAXPLAYERS
; i
++)
484 HUlib_initIText(&w_inputbuffer
[i
], 0, 0, 0, 0, &always_off
);
486 headsupactive
= true;
493 HUlib_drawSText(&w_message
);
494 HUlib_drawIText(&w_chat
);
496 HUlib_drawTextLine(&w_title
, false);
503 HUlib_eraseSText(&w_message
);
504 HUlib_eraseIText(&w_chat
);
505 HUlib_eraseTextLine(&w_title
);
515 // tick down message counter if message is up
516 if (message_counter
&& !--message_counter
)
519 message_nottobefuckedwith
= false;
522 if (showMessages
|| message_dontfuckwithme
)
525 // display message if necessary
526 if ((plr
->message
&& !message_nottobefuckedwith
)
527 || (plr
->message
&& message_dontfuckwithme
))
529 HUlib_addMessageToSText(&w_message
, 0, plr
->message
);
532 message_counter
= HU_MSGTIMEOUT
;
533 message_nottobefuckedwith
= message_dontfuckwithme
;
534 message_dontfuckwithme
= 0;
537 } // else message_on = false;
539 // check for incoming chat characters
542 for (i
=0 ; i
<MAXPLAYERS
; i
++)
544 if (!playeringame
[i
])
546 if (i
!= consoleplayer
547 && (c
= players
[i
].cmd
.chatchar
))
549 if (c
<= HU_BROADCAST
)
553 if (c
>= 'a' && c
<= 'z')
554 c
= (char) shiftxform
[(unsigned char) c
];
555 rc
= HUlib_keyInIText(&w_inputbuffer
[i
], c
);
556 if (rc
&& c
== KEY_ENTER
)
558 if (w_inputbuffer
[i
].l
.len
559 && (chat_dest
[i
] == consoleplayer
+1
560 || chat_dest
[i
] == HU_BROADCAST
))
562 HUlib_addMessageToSText(&w_message
,
564 w_inputbuffer
[i
].l
.l
);
566 message_nottobefuckedwith
= true;
568 message_counter
= HU_MSGTIMEOUT
;
569 if ( gamemode
== commercial
)
570 S_StartSound(0, sfx_radio
);
572 S_StartSound(0, sfx_tink
);
574 HUlib_resetIText(&w_inputbuffer
[i
]);
577 players
[i
].cmd
.chatchar
= 0;
584 #define QUEUESIZE 128
586 static char chatchars
[QUEUESIZE
];
591 void HU_queueChatChar(char c
)
593 if (((head
+ 1) & (QUEUESIZE
-1)) == tail
)
595 plr
->message
= HUSTR_MSGU
;
600 head
= (head
+ 1) & (QUEUESIZE
-1);
604 char HU_dequeueChatChar(void)
611 tail
= (tail
+ 1) & (QUEUESIZE
-1);
621 boolean
HU_Responder(event_t
*ev
)
624 static char lastmessage
[HU_MAXLINELENGTH
+1];
626 boolean eatkey
= false;
627 static boolean shiftdown
= false;
628 static boolean altdown
= false;
633 static char destination_keys
[MAXPLAYERS
] =
641 static int num_nobrainers
= 0;
644 for (i
=0 ; i
<MAXPLAYERS
; i
++)
645 numplayers
+= playeringame
[i
];
647 if (ev
->data1
== KEY_RSHIFT
)
649 shiftdown
= ev
->type
== ev_keydown
;
652 else if (ev
->data1
== KEY_RALT
|| ev
->data1
== KEY_LALT
)
654 altdown
= ev
->type
== ev_keydown
;
658 if (ev
->type
!= ev_keydown
)
663 if (ev
->data1
== HU_MSGREFRESH
)
666 message_counter
= HU_MSGTIMEOUT
;
669 else if (netgame
&& ev
->data1
== HU_INPUTTOGGLE
)
671 eatkey
= chat_on
= true;
672 HUlib_resetIText(&w_chat
);
673 HU_queueChatChar(HU_BROADCAST
);
675 else if (netgame
&& numplayers
> 2)
677 for (i
=0; i
<MAXPLAYERS
; i
++)
679 if (ev
->data1
== destination_keys
[i
])
681 if (playeringame
[i
] && i
!=consoleplayer
)
683 eatkey
= chat_on
= true;
684 HUlib_resetIText(&w_chat
);
685 HU_queueChatChar(i
+1);
688 else if (i
== consoleplayer
)
691 if (num_nobrainers
< 3)
692 plr
->message
= HUSTR_TALKTOSELF1
;
693 else if (num_nobrainers
< 6)
694 plr
->message
= HUSTR_TALKTOSELF2
;
695 else if (num_nobrainers
< 9)
696 plr
->message
= HUSTR_TALKTOSELF3
;
697 else if (num_nobrainers
< 32)
698 plr
->message
= HUSTR_TALKTOSELF4
;
700 plr
->message
= HUSTR_TALKTOSELF5
;
715 // fprintf(stderr, "got here\n");
716 macromessage
= chat_macros
[c
];
718 // kill last message with a '\n'
719 HU_queueChatChar(KEY_ENTER
); // DEBUG!!!
721 // send the macro message
722 while (*macromessage
)
723 HU_queueChatChar(*macromessage
++);
724 HU_queueChatChar(KEY_ENTER
);
726 // leave chat mode and notify that it was sent
728 strcpy(lastmessage
, chat_macros
[c
]);
729 plr
->message
= lastmessage
;
734 if (language
==french
)
735 c
= ForeignTranslation(c
);
736 if (shiftdown
|| (c
>= 'a' && c
<= 'z'))
738 eatkey
= HUlib_keyInIText(&w_chat
, c
);
741 // static unsigned char buf[20]; // DEBUG
744 // sprintf(buf, "KEY: %d => %d", ev->data1, c);
745 // plr->message = buf;
752 strcpy(lastmessage
, w_chat
.l
.l
);
753 plr
->message
= lastmessage
;
756 else if (c
== KEY_ESCAPE
)