home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / main / scores.c < prev    next >
Text File  |  1998-06-08  |  19KB  |  663 lines

  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/scores.c $
  15.  * $Revision: 2.2 $
  16.  * $Author: john $
  17.  * $Date: 1995/06/15 12:13:54 $
  18.  *
  19.  * Inferno High Scores and Statistics System
  20.  *
  21.  * $Log: scores.c $
  22.  * Revision 2.2  1995/06/15  12:13:54  john
  23.  * Made end game, win game and title sequences all go
  24.  * on after 5 minutes automatically.
  25.  * 
  26.  * Revision 2.1  1995/03/06  15:23:57  john
  27.  * New screen techniques.
  28.  * 
  29.  * Revision 2.0  1995/02/27  11:30:53  john
  30.  * New version 2.0, which has no anonymous unions, builds with
  31.  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  32.  * 
  33.  * Revision 1.109  1995/02/09  12:23:19  rob
  34.  * Added assert for length of filename.
  35.  * 
  36.  * Revision 1.108  1995/01/03  17:33:24  john
  37.  * Made scrolling textbox. Used it for scores cool saying.
  38.  * 
  39.  * Revision 1.107  1994/12/28  10:42:51  john
  40.  * More VFX tweaking.
  41.  * 
  42.  * Revision 1.106  1994/12/28  10:26:19  john
  43.  * Fixed some VFX problems.
  44.  * 
  45.  * Revision 1.105  1994/12/15  16:42:12  adam
  46.  * some fix
  47.  * 
  48.  * Revision 1.104  1994/12/14  11:59:19  john
  49.  * Changed the default high scores.
  50.  * 
  51.  * Revision 1.103  1994/12/09  00:41:12  mike
  52.  * fix hang in automap print screen
  53.  * 
  54.  * Revision 1.102  1994/12/07  00:36:26  mike
  55.  * scores sequencing stuff.
  56.  * 
  57.  * Revision 1.101  1994/12/06  15:14:21  yuan
  58.  * Localization
  59.  * 
  60.  * Revision 1.100  1994/12/03  17:07:52  yuan
  61.  * Localization 368
  62.  * 
  63.  * Revision 1.99  1994/12/03  14:49:27  mark
  64.  * Fixed john's bug with previous.
  65.  * 
  66.  * Revision 1.98  1994/12/03  14:43:54  john
  67.  * Added enter, space  to exit scores.
  68.  * 
  69.  * Revision 1.97  1994/12/03  14:32:34  john
  70.  * Added integrated-super-deluxe-ctrl-r to reset high scores.
  71.  * 
  72.  * Revision 1.96  1994/12/01  20:15:20  yuan
  73.  * Localization
  74.  * 
  75.  * Revision 1.95  1994/11/30  19:36:36  john
  76.  * Made Gravis Ultrasound work again.  Made the scores blink
  77.  * at a constant rate.  Revamped the newmenu background storage,
  78.  * which hopefully fixed some bugs.  Made menus in ame not pause
  79.  * sound, except for the pause key.               ^== Game!
  80.  * 
  81.  * Revision 1.94  1994/11/30  12:32:08  john
  82.  * Made secret levels print correctly.
  83.  * 
  84.  * Revision 1.93  1994/11/30  12:06:47  mike
  85.  * fix bug: looper not initialized.
  86.  * 
  87.  * Revision 1.92  1994/11/29  13:20:04  john
  88.  * changed the "Wow! You placed .." to something better.
  89.  * 
  90.  * Revision 1.91  1994/11/29  01:35:38  john
  91.  * Made it so that even if you don't get a high score, you still show
  92.  * up on the chart..
  93.  * 
  94.  * Revision 1.90  1994/11/23  17:29:29  mike
  95.  * fix xx-xx level bug in high scores.
  96.  * 
  97.  * Revision 1.89  1994/11/22  16:55:27  mike
  98.  * allow high scores even in pudly trainee level.
  99.  * 
  100.  * Revision 1.88  1994/11/21  17:28:33  john
  101.  * Changed default score values.
  102.  * 
  103.  * Revision 1.87  1994/11/18  23:37:53  john
  104.  * Changed some shorts to ints.
  105.  * 
  106.  * Revision 1.86  1994/11/13  15:39:24  john
  107.  * Added critical error handler to game.  Took out -editor command line
  108.  * option because it didn't work anymore and wasn't worth fixing.  Made scores
  109.  * not use MINER enviroment variable on release version, and made scores
  110.  * not print an error if there is no descent.hi.
  111.  * 
  112.  * Revision 1.85  1994/11/06  10:15:58  john
  113.  * Took out kill % and hostage %
  114.  * 
  115.  * Revision 1.84  1994/11/05  15:03:39  john
  116.  * Added non-popup menu for the main menu, so that scores and credits don't have to save
  117.  * the background.
  118.  * 
  119.  * Revision 1.83  1994/11/05  14:05:57  john
  120.  * Fixed fade transitions between all screens by making gr_palette_fade_in and out keep
  121.  * track of whether the palette is faded in or not.  Then, wherever the code needs to fade out,
  122.  * it just calls gr_palette_fade_out and it will fade out if it isn't already.  The same with fade_in.
  123.  * This eliminates the need for all the flags like Menu_fade_out, game_fade_in palette, etc.
  124.  * 
  125.  * Revision 1.82  1994/11/04  20:11:41  john
  126.  * Neatening up palette stuff with demos.
  127.  * 
  128.  * Revision 1.81  1994/11/04  12:02:34  john
  129.  * Fixed fading transitions a bit more.
  130.  * 
  131.  * Revision 1.80  1994/10/27  12:10:39  john
  132.  * Moved kill % a little to the right.
  133.  * 
  134.  * Revision 1.79  1994/10/24  20:25:03  john
  135.  * Fixed bug with space at end of 1 line message.
  136.  * Made Enter go between the two input lines.
  137.  * 
  138.  * Revision 1.78  1994/10/24  18:20:18  john
  139.  * Made the current high score flash.
  140.  * 
  141.  * Revision 1.77  1994/10/24  13:37:22  mike
  142.  * Fix grammar error.  --anal Mike.
  143.  * 
  144.  * Revision 1.76  1994/10/22  13:19:19  john
  145.  * Made joy/mouse buttons leave score screen.
  146.  * 
  147.  * Revision 1.75  1994/10/21  15:26:57  john
  148.  * Used PrtScr instead of F2.
  149.  * 
  150.  * Revision 1.74  1994/10/21  13:54:21  matt
  151.  * Replace '1' with special wide '1' to make numbers line up
  152.  * 
  153.  * Revision 1.73  1994/10/19  20:48:01  john
  154.  * Made so that people playing on wimp level
  155.  * can't get high scores.
  156.  * 
  157.  * Revision 1.72  1994/10/19  15:14:05  john
  158.  * Took % hits out of player structure, made %kills work properly.
  159.  * 
  160.  * Revision 1.71  1994/10/19  14:39:27  john
  161.  * Finished up; added keys to prtscr, int3.
  162.  * 
  163.  * Revision 1.70  1994/10/19  12:44:09  john
  164.  * Added hours field to player structure.
  165.  * 
  166.  * Revision 1.69  1994/10/19  11:25:21  john
  167.  * Looking good.
  168.  * 
  169.  * Revision 1.68  1994/10/19  10:54:12  john
  170.  * Test version.
  171.  * 
  172.  * Revision 1.67  1994/10/19  10:00:27  john
  173.  * *** empty log message ***
  174.  * 
  175.  * Revision 1.66  1994/10/19  09:59:03  john
  176.  * Made cool saying have the potential to be up to 50 chars
  177.  * 
  178.  * Revision 1.65  1994/10/19  09:53:30  john
  179.  * Working version of scores.
  180.  * 
  181.  * Revision 1.64  1994/10/18  21:07:46  john
  182.  * Fixed bug that didn't print name correctly.
  183.  * 
  184.  * Revision 1.63  1994/10/18  18:21:46  john
  185.  * NEw score system.
  186.  * 
  187.  * Revision 1.62  1994/10/17  20:31:42  john
  188.  * Made the text for the difficulty labels global so that
  189.  * the high score screen can print "rookie" or whatever.
  190.  * 
  191.  * Revision 1.61  1994/10/17  17:27:44  john
  192.  * Added starting_level to high score system.
  193.  * 
  194.  * Revision 1.60  1994/10/17  16:56:35  john
  195.  * Added starting level to stats menu.
  196.  * 
  197.  * Revision 1.59  1994/10/17  16:55:25  john
  198.  * Added starting level, but didn't hook it to anything.
  199.  * 
  200.  * Revision 1.58  1994/10/17  16:47:17  john
  201.  * Added diff. level.
  202.  * 
  203.  * Revision 1.57  1994/10/17  15:49:53  john
  204.  * Added stats screen.
  205.  * 
  206.  * Revision 1.56  1994/10/03  23:02:29  matt
  207.  * After player added or not to scores, scores are now displayed
  208.  * 
  209.  * Revision 1.55  1994/09/01  18:09:38  john
  210.  * Made commas in scores work correctly .
  211.  * 
  212.  * 
  213.  * Revision 1.54  1994/09/01  18:03:57  john
  214.  * Neatened up scores a bit.
  215.  * 
  216.  * Revision 1.53  1994/08/26  14:27:37  john
  217.  * Made it prompt for name
  218.  * 
  219.  * Revision 1.52  1994/08/26  13:03:17  john
  220.  * *** empty log message ***
  221.  * 
  222.  * Revision 1.51  1994/08/26  13:01:52  john
  223.  * Put high score system in.
  224.  * 
  225.  * Revision 1.50  1994/08/10  19:57:01  john
  226.  * Changed font stuff; Took out old menu; messed up lots of
  227.  * other stuff like game sequencing messages, etc.
  228.  * 
  229.  * Revision 1.49  1994/07/25  15:40:27  matt
  230.  * Took out debugging code accidentally left in.
  231.  * 
  232.  *
  233.  */
  234.  
  235. #pragma off (unreferenced)
  236. static char rcsid[] = "$Id: scores.c 2.2 1995/06/15 12:13:54 john Exp $";
  237. #pragma on (unreferenced)
  238.  
  239. #include <stdio.h>
  240. #include <stdlib.h>
  241. #include <string.h>
  242. #include <ctype.h>
  243. #include <io.h>
  244. #include <stdarg.h>
  245. #include <dos.h>
  246. #include <conio.h>
  247.  
  248. #include "error.h"
  249. #include "types.h"
  250. #include "gr.h"
  251. #include "mono.h"
  252. #include "key.h"
  253. #include "palette.h"
  254. #include "game.h"
  255. #include "gamefont.h"
  256. #include "mem.h"
  257. #include "newmenu.h"
  258. #include "menu.h"
  259. #include "player.h"
  260. #include "screens.h"
  261. #include "gamefont.h"
  262. #include "mouse.h"
  263. #include "joy.h"
  264. #include "timer.h"
  265. #include "text.h"
  266. #include "vfx.h"
  267.  
  268. #define VERSION_NUMBER         1
  269. #define SCORES_FILENAME     "DESCENT.HI"
  270. #define COOL_MESSAGE_LEN     50
  271. #define MAX_HIGH_SCORES     10
  272.  
  273. typedef struct stats_info {
  274.     char        name[CALLSIGN_LEN+1];
  275.     int        score;
  276.     byte        starting_level;
  277.     byte        ending_level;
  278.     byte      diff_level;
  279.     short     kill_ratio;    // 0-100
  280.     short        hostage_ratio;   // 
  281.     int        seconds;            // How long it took in seconds...
  282. } stats_info;
  283.  
  284. typedef struct all_scores {
  285.     char            signature[3];            // DHS
  286.     byte            version;                    // version
  287.     char            cool_saying[COOL_MESSAGE_LEN];
  288.     stats_info    stats[MAX_HIGH_SCORES];
  289. } all_scores;
  290.  
  291. static all_scores Scores;
  292.  
  293. stats_info Last_game;
  294.  
  295. char scores_filename[128];
  296.  
  297. #define XX  (7)
  298. #define YY  (-3)
  299.  
  300. char * get_scores_filename()
  301. {
  302. #ifndef RELEASE
  303.     // Only use the MINER variable for internal developement
  304.     char *p;
  305.     p=getenv( "MINER" );
  306.     if (p)    {
  307.         sprintf( scores_filename, "%s\\game\\%s", p, SCORES_FILENAME );
  308.         Assert(strlen(scores_filename) < 128);
  309.         return scores_filename;
  310.     }
  311. #endif
  312.     sprintf( scores_filename, "%s", SCORES_FILENAME );
  313.     return scores_filename;
  314. }
  315.  
  316.  
  317. void scores_read()
  318. {
  319.     FILE * fp;
  320.     int fsize;
  321.  
  322.     // clear score array...
  323.     memset( &Scores, 0, sizeof(all_scores) );
  324.  
  325.     fp = fopen( get_scores_filename(), "rb" );
  326.     if (fp==NULL) {
  327.         int i;
  328.  
  329.          // No error message needed, code will work without a scores file
  330.         sprintf( Scores.cool_saying, TXT_REGISTER_DESCENT );
  331.         sprintf( Scores.stats[0].name, "Parallax" );
  332.         sprintf( Scores.stats[1].name, "Mike" );
  333.         sprintf( Scores.stats[2].name, "Matt" );
  334.         sprintf( Scores.stats[3].name, "John" );
  335.         sprintf( Scores.stats[4].name, "Yuan" );
  336.         sprintf( Scores.stats[5].name, "Adam" );
  337.         sprintf( Scores.stats[6].name, "Mark" );
  338.         sprintf( Scores.stats[7].name, "Allender" );
  339.         sprintf( Scores.stats[8].name, "Jasen" );
  340.         sprintf( Scores.stats[9].name, "Rob" );
  341.  
  342.         for (i=0; i<10; i++)
  343.             Scores.stats[i].score = (10-i)*1000;
  344.         return;
  345.     }
  346.         
  347.     fsize = filelength( fileno( fp ));
  348.  
  349.     if ( fsize != sizeof(all_scores) )    {
  350.         fclose(fp);
  351.         return;
  352.     }
  353.     // Read 'em in...
  354.     fread( &Scores, sizeof(all_scores),1, fp );
  355.     fclose(fp);
  356.  
  357.     if ( (Scores.version!=VERSION_NUMBER)||(Scores.signature[0]!='D')||(Scores.signature[1]!='H')||(Scores.signature[2]!='S') )    {
  358.         memset( &Scores, 0, sizeof(all_scores) );
  359.         return;
  360.     }
  361. }
  362.  
  363. void scores_write()
  364. {
  365.     FILE * fp;
  366.  
  367.     fp = fopen( get_scores_filename(), "wb" );
  368.     if (fp==NULL) {
  369.         nm_messagebox( TXT_WARNING, 1, TXT_OK, "%s\n'%s'", TXT_UNABLE_TO_OPEN, get_scores_filename()  );
  370.         return;
  371.     }
  372.  
  373.     Scores.signature[0]='D';
  374.     Scores.signature[1]='H';
  375.     Scores.signature[2]='S';
  376.     Scores.version = VERSION_NUMBER;
  377.     fwrite( &Scores,sizeof(all_scores),1, fp );
  378.     fclose(fp);
  379. }
  380.  
  381. void int_to_string( int number, char *dest )
  382. {
  383.     int i,l,c;
  384.     char buffer[20],*p;
  385.  
  386.     sprintf( buffer, "%d", number );
  387.  
  388.     l = strlen(buffer);
  389.     if (l<=3) {
  390.         // Don't bother with less than 3 digits
  391.         sprintf( dest, "%d", number );
  392.         return;
  393.     }
  394.  
  395.     c = 0;
  396.     p=dest;
  397.     for (i=l-1; i>=0; i-- )    {
  398.         if (c==3) {
  399.             *p++=',';
  400.             c = 0;
  401.         }
  402.         c++;
  403.         *p++ = buffer[i];
  404.     }
  405.     *p++ = '\0';
  406.     strrev(dest);
  407. }
  408.  
  409. void scores_fill_struct(stats_info * stats)
  410. {
  411.         strcpy( stats->name, Players[Player_num].callsign );
  412.         stats->score = Players[Player_num].score;
  413.         stats->ending_level = Players[Player_num].level;
  414.         if (Players[Player_num].num_robots_total > 0 )    
  415.             stats->kill_ratio = (Players[Player_num].num_kills_total*100)/Players[Player_num].num_robots_total;
  416.         else
  417.             stats->kill_ratio = 0;
  418.  
  419.         if (Players[Player_num].hostages_total > 0 )    
  420.             stats->hostage_ratio = (Players[Player_num].hostages_rescued_total*100)/Players[Player_num].hostages_total;
  421.         else
  422.             stats->hostage_ratio = 0;
  423.  
  424.         stats->seconds = f2i(Players[Player_num].time_total)+(Players[Player_num].hours_total*3600);
  425.  
  426.         stats->diff_level = Difficulty_level;
  427.         stats->starting_level = Players[Player_num].starting_level;
  428. }
  429.  
  430. //char * score_placement[10] = { TXT_1ST, TXT_2ND, TXT_3RD, TXT_4TH, TXT_5TH, TXT_6TH, TXT_7TH, TXT_8TH, TXT_9TH, TXT_10TH };
  431.  
  432. void scores_maybe_add_player(int abort_flag)
  433. {
  434.     char text1[COOL_MESSAGE_LEN+10];
  435.     newmenu_item m[10];
  436.     int i,position;
  437.  
  438.     scores_read();
  439.     
  440.     position = MAX_HIGH_SCORES;
  441.     for (i=0; i<MAX_HIGH_SCORES; i++ )    {
  442.         if ( Players[Player_num].score > Scores.stats[i].score )    {
  443.             position = i;
  444.             break;
  445.         }
  446.     }
  447.     
  448.     if ( position == MAX_HIGH_SCORES ) {
  449.         if (abort_flag)
  450.             return;
  451.         scores_fill_struct( &Last_game );
  452.     } else {
  453. //--        if ( Difficulty_level < 1 )    {
  454. //--            nm_messagebox( "GRADUATION TIME!", 1, "Ok", "If you would had been\nplaying at a higher difficulty\nlevel, you would have placed\n#%d on the high score list.", position+1 );
  455. //--            return;
  456. //--        }
  457.  
  458.         if ( position==0 )    {
  459.             strcpy( text1,  "" );
  460.             m[0].type = NM_TYPE_TEXT; m[0].text = TXT_COOL_SAYING;
  461.             m[1].type = NM_TYPE_INPUT; m[1].text = text1; m[1].text_len = COOL_MESSAGE_LEN-5;
  462.             newmenu_do( TXT_HIGH_SCORE, TXT_YOU_PLACED_1ST, 2, m, NULL );
  463.             strncpy( Scores.cool_saying, text1, COOL_MESSAGE_LEN );
  464.             if (strlen(Scores.cool_saying)<1)
  465.                 sprintf( Scores.cool_saying, "No Comment" );
  466.         } else {
  467.             nm_messagebox( TXT_HIGH_SCORE, 1, TXT_OK, "%s %s!", TXT_YOU_PLACED, *(&TXT_1ST + position) );
  468.         }
  469.     
  470.         // move everyone down...
  471.         for ( i=MAX_HIGH_SCORES-1; i>position; i-- )    {
  472.             Scores.stats[i] = Scores.stats[i-1];
  473.         }
  474.  
  475.         scores_fill_struct( &Scores.stats[position] );
  476.     
  477.         scores_write();
  478.  
  479.     }
  480.     scores_view(position);
  481. }
  482.  
  483.  
  484.  
  485. #define TEXT_FONT          (Gamefonts[GFONT_MEDIUM_3])
  486.  
  487. void scores_rprintf(int x, int y, char * format, ... )
  488. {
  489.     va_list args;
  490.     char buffer[128];
  491.     int w, h, aw;
  492.     char *p;
  493.  
  494.     va_start(args, format );
  495.     vsprintf(buffer,format,args);
  496.     va_end(args);
  497.  
  498.     //replace the digit '1' with special wider 1
  499.     for (p=buffer;*p;p++)
  500.         if (*p=='1') *p=132;
  501.  
  502.     gr_get_string_size(buffer, &w, &h, &aw );
  503.  
  504.     gr_string( x-w, y, buffer );
  505. }
  506.  
  507.  
  508. void scores_draw_item( int  i, stats_info * stats )
  509. {
  510.     char buffer[20];
  511.  
  512.         int y;
  513.  
  514.         y = 7+70+i*9;
  515.  
  516.         if (i==0) y -= 8;
  517.  
  518.         if ( i==MAX_HIGH_SCORES )     {
  519.             y += 8;
  520.             //scores_rprintf( 17+33+XX, y+YY, "" );
  521.         } else {
  522.             scores_rprintf( 17+33+XX, y+YY, "%d.", i+1 );
  523.         }
  524.  
  525.         if (strlen(stats->name)==0) {
  526.             gr_printf( 26+33+XX, y+YY, TXT_EMPTY );
  527.             return;
  528.         }
  529.         gr_printf( 26+33+XX, y+YY, "%s", stats->name );
  530.         int_to_string(stats->score, buffer);
  531.         scores_rprintf( 109+33+XX, y+YY, "%s", buffer );
  532.  
  533.         gr_printf( 125+33+XX, y+YY, "%s", MENU_DIFFICULTY_TEXT(stats->diff_level) );
  534.  
  535.         if ( (stats->starting_level > 0 ) && (stats->ending_level > 0 ))
  536.             scores_rprintf( 192+33+XX, y+YY, "%d-%d", stats->starting_level, stats->ending_level );
  537.         else if ( (stats->starting_level < 0 ) && (stats->ending_level > 0 ))
  538.             scores_rprintf( 192+33+XX, y+YY, "S%d-%d", -stats->starting_level, stats->ending_level );
  539.         else if ( (stats->starting_level < 0 ) && (stats->ending_level < 0 ))
  540.             scores_rprintf( 192+33+XX, y+YY, "S%d-S%d", -stats->starting_level, -stats->ending_level );
  541.         else if ( (stats->starting_level > 0 ) && (stats->ending_level < 0 ))
  542.             scores_rprintf( 192+33+XX, y+YY, "%d-S%d", stats->starting_level, -stats->ending_level );
  543.  
  544.         {
  545.             int h, m, s;
  546.             h = stats->seconds/3600;
  547.             s = stats->seconds%3600;
  548.             m = s / 60;
  549.             s = s % 60;
  550.             scores_rprintf( 311-42+XX, y+YY, "%d:%02d:%02d", h, m, s );
  551.         }
  552. }
  553.  
  554. void scores_view(int citem)
  555. {
  556.     fix time_out_value;
  557.     fix t1;
  558.     int i,done,looper;
  559.     int k;
  560.     byte fades[64] = { 1,1,1,2,2,3,4,4,5,6,8,9,10,12,13,15,16,17,19,20,22,23,24,26,27,28,28,29,30,30,31,31,31,31,31,30,30,29,28,28,27,26,24,23,22,20,19,17,16,15,13,12,10,9,8,6,5,4,4,3,2,2,1,1 };
  561.  
  562. ReshowScores:
  563.     scores_read();
  564.  
  565.     set_screen_mode(SCREEN_MENU);
  566.     
  567.     gr_set_current_canvas(NULL);
  568.     
  569.     nm_draw_background(0,0,grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );
  570.  
  571.     grd_curcanv->cv_font = Gamefonts[GFONT_MEDIUM_3];
  572.  
  573.     gr_string( 0x8000, 15, TXT_HIGH_SCORES );
  574.  
  575.     grd_curcanv->cv_font = Gamefonts[GFONT_SMALL];
  576.  
  577.     gr_set_fontcolor( BM_XRGB(31,26,5), -1 );
  578.     gr_string(  31+33+XX, 46+7+YY, TXT_NAME );
  579.     gr_string(  82+33+XX, 46+7+YY, TXT_SCORE );
  580.     gr_string( 127+33+XX, 46+7+YY, TXT_SKILL );
  581.     gr_string( 170+33+XX, 46+7+YY, TXT_LEVELS );
  582. //    gr_string( 202, 46, "Kills" );
  583. //    gr_string( 234, 46, "Rescues" );
  584.     gr_string( 288-42+XX, 46+7+YY, TXT_TIME );
  585.  
  586.     if ( citem < 0 )    
  587.         gr_string( 0x8000, 175, TXT_PRESS_CTRL_R );
  588.  
  589.     gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
  590.  
  591.     gr_printf( 0x8000, 31, "%c%s%c  - %s", 34, Scores.cool_saying, 34, Scores.stats[0].name );
  592.     
  593.     for (i=0; i<MAX_HIGH_SCORES; i++ )        {
  594.         if (i==0)    {
  595.             gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
  596.         } else {
  597.             gr_set_fontcolor( gr_fade_table[BM_XRGB(28,28,28)+((28-i*2)*256)], -1 );
  598.         }                                                         
  599.         scores_draw_item( i, &Scores.stats[i] );
  600.     }
  601.  
  602.     gr_palette_fade_in( gr_palette,32, 0);
  603.  
  604.     game_flush_inputs();
  605.  
  606.     done = 0;
  607.     looper = 0;
  608.  
  609.     time_out_value = timer_get_fixed_seconds()+i2f(60*5);
  610.     while(!done)    {
  611.         if ( citem > -1 )    {
  612.     
  613.             t1    = timer_get_fixed_seconds();
  614.             if ( t1 > time_out_value ) done = 1;
  615.             while ( timer_get_fixed_seconds() < t1+F1_0/128 );    
  616.  
  617.             gr_set_fontcolor( gr_fade_table[fades[looper]*256+BM_XRGB(28,28,28)], -1 );
  618.             looper++;
  619.             if (looper>63) looper=0;
  620.             if ( citem ==  MAX_HIGH_SCORES )
  621.                 scores_draw_item( MAX_HIGH_SCORES, &Last_game );
  622.             else
  623.                 scores_draw_item( citem, &Scores.stats[citem] );
  624.         }
  625.  
  626.         for (i=0; i<4; i++ )    
  627.             if (joy_get_button_down_cnt(i)>0) done=1;
  628.         for (i=0; i<3; i++ )    
  629.             if (mouse_button_down_count(i)>0) done=1;
  630.  
  631.         k = key_inkey();
  632.         switch( k )    {
  633.         case KEY_CTRLED+KEY_R:        
  634.             if ( citem < 0 )        {
  635.                 // Reset scores...
  636.                 if ( nm_messagebox( NULL, 2,  TXT_NO, TXT_YES, TXT_RESET_HIGH_SCORES )==1 )    {
  637.                     remove( get_scores_filename() );
  638.                     gr_palette_fade_out( gr_palette, 32, 0 );
  639.                     goto ReshowScores;
  640.                 }
  641.             }
  642.             break;
  643.         case KEY_BACKSP:                Int3(); k = 0; break;
  644.         case KEY_PRINT_SCREEN:        save_screen_shot(0); k = 0; break;
  645.             
  646.         case KEY_ENTER:
  647.         case KEY_SPACEBAR:
  648.         case KEY_ESC:
  649.             done=1;
  650.             break;
  651.         }
  652.     }
  653.  
  654. // Restore background and exit
  655.     gr_palette_fade_out( gr_palette, 32, 0 );
  656.     gr_set_current_canvas(NULL);
  657.  
  658.     game_flush_inputs();
  659.     
  660. }
  661. 
  662. 
  663.