KMATRIX.C 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/main/rcs/kmatrix.c $
  15. * $Revision: 2.3 $
  16. * $Author: john $
  17. * $Date: 1995/05/02 17:01:22 $
  18. *
  19. * Kill matrix displayed at end of level.
  20. *
  21. * $Log: kmatrix.c $
  22. * Revision 2.3 1995/05/02 17:01:22 john
  23. * Fixed bug with kill list not showing up in VFX mode.
  24. *
  25. * Revision 2.2 1995/03/21 14:38:20 john
  26. * Ifdef'd out the NETWORK code.
  27. *
  28. * Revision 2.1 1995/03/06 15:22:54 john
  29. * New screen techniques.
  30. *
  31. * Revision 2.0 1995/02/27 11:25:56 john
  32. * New version 2.0, which has no anonymous unions, builds with
  33. * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  34. *
  35. * Revision 1.19 1995/02/15 14:47:23 john
  36. * Added code to keep track of kills during endlevel.
  37. *
  38. * Revision 1.18 1995/02/08 11:00:06 rob
  39. * Moved string to localized file
  40. *
  41. * Revision 1.17 1995/02/01 23:45:55 rob
  42. * Fixed string.
  43. *
  44. * Revision 1.16 1995/01/30 21:47:11 rob
  45. * Added a line of instructions.
  46. *
  47. * Revision 1.15 1995/01/20 16:58:43 rob
  48. * careless careless careless...
  49. *
  50. *
  51. * Revision 1.14 1995/01/20 13:43:48 rob
  52. * Longer time to view.
  53. *
  54. * Revision 1.13 1995/01/20 13:42:34 rob
  55. * Fixed sorting bug.
  56. *
  57. * Revision 1.12 1995/01/19 17:35:21 rob
  58. * Fixed coloration of player names in team mode.
  59. *
  60. * Revision 1.11 1995/01/16 21:26:15 rob
  61. * Fixed it!!
  62. *
  63. * Revision 1.10 1995/01/16 18:55:41 rob
  64. * Added include of network.h
  65. *
  66. * Revision 1.9 1995/01/16 18:22:35 rob
  67. * Fixed problem with signs.
  68. *
  69. * Revision 1.8 1995/01/12 16:07:51 rob
  70. * ADded sorting before display.
  71. *
  72. * Revision 1.7 1995/01/04 08:46:53 rob
  73. * JOHN CHECKED IN FOR ROB !!!
  74. *
  75. * Revision 1.6 1994/12/09 20:17:20 yuan
  76. * Touched up
  77. *
  78. * Revision 1.5 1994/12/09 19:46:35 yuan
  79. * Localized the sucker.
  80. *
  81. * Revision 1.4 1994/12/09 19:24:58 rob
  82. * Yuan's fix to the centering.
  83. *
  84. * Revision 1.3 1994/12/09 19:02:37 yuan
  85. * Cleaned up a bit.
  86. *
  87. * Revision 1.2 1994/12/09 16:19:46 yuan
  88. * kill matrix stuff.
  89. *
  90. * Revision 1.1 1994/12/09 15:08:58 yuan
  91. * Initial revision
  92. *
  93. *
  94. */
  95. #pragma off (unreferenced)
  96. static char rcsid[] = "$Id: kmatrix.c 2.3 1995/05/02 17:01:22 john Exp $";
  97. #pragma on (unreferenced)
  98. #ifdef NETWORK
  99. #include <stdio.h>
  100. #include <stdlib.h>
  101. #include <string.h>
  102. #include <ctype.h>
  103. #include <io.h>
  104. #include <stdarg.h>
  105. #include <dos.h>
  106. #include <conio.h>
  107. #include "error.h"
  108. #include "types.h"
  109. #include "gr.h"
  110. #include "mono.h"
  111. #include "key.h"
  112. #include "palette.h"
  113. #include "game.h"
  114. #include "gamefont.h"
  115. #include "mem.h"
  116. #include "newmenu.h"
  117. #include "menu.h"
  118. #include "player.h"
  119. #include "screens.h"
  120. #include "gamefont.h"
  121. #include "mouse.h"
  122. #include "joy.h"
  123. #include "timer.h"
  124. #include "text.h"
  125. #include "multi.h"
  126. #include "kmatrix.h"
  127. #include "gauges.h"
  128. #include "pcx.h"
  129. #include "network.h"
  130. #define CENTERING_OFFSET(x) ((300 - (70 + (x)*25 ))/2)
  131. int kmatrix_kills_changed = 0;
  132. void kmatrix_draw_item( int i, int *sorted )
  133. {
  134. int j, x, y;
  135. y = 50+i*9;
  136. // Print player name.
  137. gr_printf( CENTERING_OFFSET(N_players), y, "%s", Players[sorted[i]].callsign );
  138. for (j=0; j<N_players; j++) {
  139. x = 70 + CENTERING_OFFSET(N_players) + j*25;
  140. if (sorted[i]==sorted[j]) {
  141. if (kill_matrix[sorted[i]][sorted[j]] == 0) {
  142. gr_set_fontcolor( BM_XRGB(10,10,10),-1 );
  143. gr_printf( x, y, "%d", kill_matrix[sorted[i]][sorted[j]] );
  144. } else {
  145. gr_set_fontcolor( BM_XRGB(25,25,25),-1 );
  146. gr_printf( x, y, "-%d", kill_matrix[sorted[i]][sorted[j]] );
  147. }
  148. } else {
  149. if (kill_matrix[sorted[i]][sorted[j]] <= 0) {
  150. gr_set_fontcolor( BM_XRGB(10,10,10),-1 );
  151. gr_printf( x, y, "%d", kill_matrix[sorted[i]][sorted[j]] );
  152. } else {
  153. gr_set_fontcolor( BM_XRGB(25,25,25),-1 );
  154. gr_printf( x, y, "%d", kill_matrix[sorted[i]][sorted[j]] );
  155. }
  156. }
  157. }
  158. x = 70 + CENTERING_OFFSET(N_players) + N_players*25;
  159. gr_set_fontcolor( BM_XRGB(25,25,25),-1 );
  160. gr_printf( x ,y,"%4d",Players[sorted[i]].net_kills_total);
  161. }
  162. void kmatrix_draw_names(int *sorted)
  163. {
  164. int j, x;
  165. int color;
  166. for (j=0; j<N_players; j++) {
  167. if (Game_mode & GM_TEAM)
  168. color = get_team(sorted[j]);
  169. else
  170. color = sorted[j];
  171. x = 70 + CENTERING_OFFSET(N_players) + j*25;
  172. gr_set_fontcolor(gr_getcolor(player_rgb[color].r,player_rgb[color].g,player_rgb[color].b),-1 );
  173. gr_printf( x, 40, "%c", Players[sorted[j]].callsign[0] );
  174. }
  175. x = 70 + CENTERING_OFFSET(N_players) + N_players*25;
  176. gr_set_fontcolor( BM_XRGB(31,31,31),-1 );
  177. gr_printf( x, 40, TXT_KILLS);
  178. }
  179. void kmatrix_draw_deaths(int *sorted)
  180. {
  181. int j, x, y;
  182. y = 55 + N_players * 9;
  183. // gr_set_fontcolor(gr_getcolor(player_rgb[j].r,player_rgb[j].g,player_rgb[j].b),-1 );
  184. gr_set_fontcolor( BM_XRGB(31,31,31),-1 );
  185. x = CENTERING_OFFSET(N_players);
  186. gr_printf( x, y, TXT_DEATHS );
  187. for (j=0; j<N_players; j++) {
  188. x = 70 + CENTERING_OFFSET(N_players) + j*25;
  189. gr_printf( x, y, "%d", Players[sorted[j]].net_killed_total );
  190. }
  191. y = 55 + 72 + 12;
  192. x = 35;
  193. {
  194. int sw, sh, aw;
  195. gr_get_string_size(TXT_PRESS_ANY_KEY2, &sw, &sh, &aw);
  196. gr_printf( 160-(sw/2), y, TXT_PRESS_ANY_KEY2);
  197. }
  198. }
  199. void kmatrix_redraw()
  200. {
  201. int i, pcx_error, color;
  202. int sorted[MAX_NUM_NET_PLAYERS];
  203. multi_sort_kill_list();
  204. gr_set_current_canvas(NULL);
  205. pcx_error = pcx_read_bitmap("STARS.PCX",&grd_curcanv->cv_bitmap,grd_curcanv->cv_bitmap.bm_type,NULL);
  206. Assert(pcx_error == PCX_ERROR_NONE);
  207. grd_curcanv->cv_font = Gamefonts[GFONT_MEDIUM_3];
  208. gr_string( 0x8000, 15, TXT_KILL_MATRIX_TITLE );
  209. grd_curcanv->cv_font = Gamefonts[GFONT_SMALL];
  210. multi_get_kill_list(sorted);
  211. kmatrix_draw_names(sorted);
  212. for (i=0; i<N_players; i++ ) {
  213. // mprintf((0, "Sorted kill list pos %d = %d.\n", i+1, sorted[i]));
  214. if (Game_mode & GM_TEAM)
  215. color = get_team(sorted[i]);
  216. else
  217. color = sorted[i];
  218. gr_set_fontcolor(gr_getcolor(player_rgb[color].r,player_rgb[color].g,player_rgb[color].b),-1 );
  219. kmatrix_draw_item( i, sorted );
  220. }
  221. kmatrix_draw_deaths(sorted);
  222. }
  223. #define MAX_VIEW_TIME F1_0*60
  224. void kmatrix_view(int network)
  225. {
  226. int i, k, done;
  227. fix entry_time = timer_get_approx_seconds();
  228. int key;
  229. set_screen_mode( SCREEN_MENU );
  230. kmatrix_redraw();
  231. gr_palette_fade_in( gr_palette,32, 0);
  232. game_flush_inputs();
  233. done = 0;
  234. while(!done) {
  235. for (i=0; i<4; i++ )
  236. if (joy_get_button_down_cnt(i)>0) done=1;
  237. for (i=0; i<3; i++ )
  238. if (mouse_button_down_count(i)>0) done=1;
  239. k = key_inkey();
  240. switch( k ) {
  241. case KEY_ENTER:
  242. case KEY_SPACEBAR:
  243. case KEY_ESC:
  244. done=1;
  245. break;
  246. case KEY_PRINT_SCREEN:
  247. save_screen_shot(0);
  248. break;
  249. case KEY_BACKSP:
  250. Int3();
  251. break;
  252. default:
  253. break;
  254. }
  255. if (timer_get_approx_seconds() > entry_time+MAX_VIEW_TIME)
  256. done=1;
  257. if (network && (Game_mode & GM_NETWORK))
  258. {
  259. kmatrix_kills_changed = 0;
  260. network_endlevel_poll2(0, NULL, &key, 0);
  261. if ( kmatrix_kills_changed ) {
  262. kmatrix_redraw();
  263. }
  264. if (key < -1)
  265. done = 1;
  266. }
  267. }
  268. // Restore background and exit
  269. gr_palette_fade_out( gr_palette, 32, 0 );
  270. game_flush_inputs();
  271. }
  272. #endif
  273.