]> icculus.org git repositories - taylor/freespace2.git/blob - src/stats/medals.cpp
runs a little bit now
[taylor/freespace2.git] / src / stats / medals.cpp
1 /*
2  * $Logfile: /Freespace2/code/Stats/Medals.cpp $
3  * $Revision$
4  * $Date$
5  * $Author$
6  * 
7  * $Log$
8  * Revision 1.4  2002/05/28 04:56:51  theoddone33
9  * runs a little bit now
10  *
11  * Revision 1.3  2002/05/26 20:22:48  theoddone33
12  * Most of network/ works
13  *
14  * Revision 1.2  2002/05/04 04:36:56  theoddone33
15  * More changes, took out a lot of the sound stuff which will bite later but
16  * I don't care.
17  *
18  * Revision 1.1.1.1  2002/05/03 03:28:11  root
19  * Initial import.
20  *
21  * 
22  * 12    10/29/99 10:40p Jefff
23  * hack to make german medal names display without actually changing them
24  * 
25  * 11    9/02/99 3:41p Jefff
26  * changed badge voice handling to be similar to promotion voice handling
27  * 
28  * 10    8/26/99 8:49p Jefff
29  * Updated medals screen and about everything that ever touches medals in
30  * one way or another.  Sheesh.
31  * 
32  * 9     7/16/99 1:50p Dave
33  * 8 bit aabitmaps. yay.
34  * 
35  * 8     3/19/99 9:51a Dave
36  * Checkin to repair massive source safe crash. Also added support for
37  * pof-style nebulae, and some new weapons code.
38  * 
39  * 8     3/15/99 10:29a Neilk
40  * 
41  * 7     1/30/99 5:08p Dave
42  * More new hi-res stuff.Support for nice D3D textures.
43  * 
44  * 6     12/18/98 1:13a Dave
45  * Rough 1024x768 support for Direct3D. Proper detection and usage through
46  * the launcher.
47  * 
48  * 5     11/30/98 1:07p Dave
49  * 16 bit conversion, first run.
50  * 
51  * 4     10/23/98 3:51p Dave
52  * Full support for tstrings.tbl and foreign languages. All that remains
53  * is to make it active in Fred.
54  * 
55  * 3     10/13/98 9:29a Dave
56  * Started neatening up freespace.h. Many variables renamed and
57  * reorganized. Added AlphaColors.[h,cpp]
58  * 
59  * 2     10/07/98 10:54a Dave
60  * Initial checkin.
61  * 
62  * 1     10/07/98 10:51a Dave
63  * 
64  * 26    6/13/98 3:18p Hoffoss
65  * NOX()ed out a bunch of strings that shouldn't be translated.
66  * 
67  * 25    6/01/98 11:43a John
68  * JAS & MK:  Classified all strings for localization.
69  * 
70  * 24    5/01/98 12:34p John
71  * Added code to force FreeSpace to run in the same dir as exe and made
72  * all the parse error messages a little nicer.
73  * 
74  * 23    4/27/98 3:13p Allender
75  * make ctrl-enter work on medals screen
76  * 
77  * 22    4/23/98 8:27p Allender
78  * basic support for cutscene playback.  Into movie code in place.  Tech
79  * room can view cutscenes stored in CDROM_dir variable
80  * 
81  * 21    4/12/98 8:30p Allender
82  * minor medal changes to show number of medals if > 1
83  * 
84  * 20    4/10/98 4:51p Hoffoss
85  * Made several changes related to tooltips.
86  * 
87  * 19    3/18/98 12:03p John
88  * Marked all the new strings as externalized or not.
89  * 
90  * 18    3/11/98 5:02p Dave
91  * Put in code to support new medals artwork. Assorted multiplayer bug
92  * fixes.
93  * 
94  * 17    3/07/98 5:44p Dave
95  * Finished player info popup. Ironed out a few todo bugs.
96  * 
97  * 16    3/05/98 5:11p Allender
98  * fix up medals screen (again).  Don't do state transition when viewing
99  * medals from debriefing screen.
100  * 
101  * 15    3/05/98 2:32p Hoffoss
102  * Renamed Rank_bitmap to Rank_bm so it isn't named the same as the
103  * variable in the debrief screen which confuses the debugger.
104  * 
105  * 14    2/22/98 2:48p John
106  * More String Externalization Classification
107  * 
108  * 13    2/09/98 5:21p Hoffoss
109  * Made exit from medals screen to previous screen (instead of assuming
110  * it's the barracks) work.
111  * 
112  * 12    1/27/98 4:23p Allender
113  * enhanced internal scoring mechanisms.
114  * 
115  * 11    11/12/97 4:40p Dave
116  * Put in multiplayer campaign support parsing, loading and saving. Made
117  * command-line variables better named. Changed some things on the initial
118  * pilot select screen.
119  * 
120  * 10    11/12/97 9:30a Dave
121  * Fixed rank insignia tooltip not showing up.
122  * 
123  * 9     11/06/97 4:39p Allender
124  * a ton of medal work.  Removed an uneeded elemen in the scoring
125  * structure.  Fix up medals screen to apprioriate display medals (after
126  * mask was changed).  Fix Fred to only display medals which may actually
127  * be granted.  Added image_filename to player struct for Jason Hoffoss
128  * 
129  * 8     11/05/97 4:43p Allender
130  * reworked medal/rank system to read all data from tables.  Made Fred
131  * read medals.tbl.  Changed ai-warp to ai-warp-out which doesn't require
132  * waypoint for activation
133  *
134  * $NoKeywords: $
135  */
136
137
138 #include "medals.h"
139 #include "2d.h"
140 #include "snazzyui.h"
141 #include "bmpman.h"
142 #include "gamesequence.h"
143 #include "animplay.h"
144 #include "mouse.h"
145 #include "freespace.h"
146 #include "scoring.h"
147 #include "player.h"
148 #include "palman.h"
149 #include "ui.h"
150 #include "key.h"
151 #include "cmdline.h"
152 #include "gamesnd.h"
153 #include "alphacolors.h"
154 #include "localize.h"
155
156 //#define MAX_MEDAL_TYPES 63 // the # of medals which exist so far
157
158 /*
159 #define CALLSIGN_X 198
160 #define CALLSIGN_Y 80
161 #define CALLSIGN_W (439-CALLSIGN_X)
162 #define CALLSIGN_H (116-CALLSIGN_Y)
163 */
164
165 // define for the medal information
166 medal_stuff Medals[NUM_MEDALS];
167 badge_stuff Badge_info[MAX_BADGES];
168
169 // holds indices into Medals array of the badges for # kills
170 int Badge_index[MAX_BADGES];
171
172 // the rank section of the screen
173 #define RANK_MEDAL_REGION               12                      // region number of the rank medal
174
175 #warning Find real FS2_DEMO spot for medals
176 // coords for indiv medal bitmaps
177 int Medal_coords[GR_NUM_RESOLUTIONS][NUM_MEDALS][2] = {
178         {                               // GR_640
179                 { 89, 47 },                                     // eps. peg. lib
180                 { 486, 47 },                            // imp. order o' vasuda
181                 { 129, 130 },                           // dist flying cross
182                 { 208, 132 },                           // soc service
183                 { 361, 131 },                           // dist intel cross
184                 { 439, 130 },                           // order of galatea
185                 { 64, 234 },                            // meritorious unit comm.
186                 { 153, 234 },                           // medal of valor
187                 { 239, 241 },                           // gtva leg of honor
188                 { 326, 240 },                           // allied defense citation
189                 { 411, 234 },                           // neb campaign victory
190                 { 494, 234 },                           // ntf campaign victory
191                 { 189, 80 },                            // rank
192                 { 283, 91 },                            // wings
193                 { 372, 76 },                            // bronze kills badge
194                 { 403, 76 },                            // silver kills badge
195 #ifndef FS2_DEMO
196                 { 435, 76 },                            // gold kills badge
197                 { 300, 152 },                           // SOC unit crest
198 #endif
199         },
200         {                               // GR_1024
201                 { 143, 75 },                            // eps. peg. lib
202                 { 777, 75 },                            // imp. order o' vasuda
203                 { 206, 208 },                           // dist flying cross
204                 { 333, 212 },                           // soc service
205                 { 578, 210 },                           // dist intel cross
206                 { 703, 208 },                           // order of galatea
207                 { 103, 374 },                           // meritorious unit comm.
208                 { 245, 374 },                           // medal of valor
209                 { 383, 386 },                           // gtva leg of honor
210                 { 522, 384 },                           // allied defense citation
211                 { 658, 374 },                           // neb campaign victory
212                 { 790, 374 },                           // ntf campaign victory
213                 { 302, 128 },                           // rank
214                 { 453, 146 },                           // wings
215                 { 595, 121 },                           // bronze kills badge
216                 { 646, 121 },                           // silver kills badge
217 #ifndef FS2_DEMO
218                 { 696, 121 },                           // gold kills badge
219                 { 480, 244 },                           // SOC unit crest
220 #endif
221         }
222 };
223
224 // coords for the medal title
225 static int Medals_label_coords[GR_NUM_RESOLUTIONS][3] = {
226         { 241, 458, 300 },                      // GR_640 x, y, w
227         { 386, 734, 480 }                               // GR_1024 x, y, w
228 };
229
230 #define MEDALS_NUM_BUTTONS                      1
231 #define MEDALS_EXIT                                     0       
232 ui_button_info Medals_buttons[GR_NUM_RESOLUTIONS][MEDALS_NUM_BUTTONS] = {
233         { // GR_640
234                 ui_button_info("MEB_18",        574,    432,    -1,     -1,     18),
235         },
236         { // GR_1024
237                 ui_button_info("2_MEB_18",      919,    691,    -1,     -1,     18),
238         }
239 };
240
241 #define MEDALS_NUM_TEXT                         1
242 UI_XSTR Medals_text[GR_NUM_RESOLUTIONS][MEDALS_NUM_TEXT] = {
243         {       // GR_640
244                 {"Exit",                1466,           587,    416,    UI_XSTR_COLOR_PINK, -1, &Medals_buttons[GR_640][MEDALS_EXIT].button },
245         },
246         {       // GR_1024
247                 {"Exit",                1466,           943,    673,    UI_XSTR_COLOR_PINK, -1, &Medals_buttons[GR_1024][MEDALS_EXIT].button },
248         },
249 };
250
251 static char* Medals_background_filename[GR_NUM_RESOLUTIONS] = {
252         "MedalsDisplayEmpty",
253         "2_MedalsDisplayEmpty"
254 };
255
256 static char* Medals_mask_filename[GR_NUM_RESOLUTIONS] = {
257         "Medals-m",
258         "2_Medals-m"
259 };
260
261 static int Medals_callsign_y[GR_NUM_RESOLUTIONS] = {
262         54, 89
263 };
264
265 scoring_struct *Player_score=NULL;
266
267 int Medals_mode;
268 player *Medals_player;
269
270 // -----------------------------------------------------------------------------
271 // Main medals screen state
272 //
273 #define NUM_MEDAL_REGIONS                       NUM_MEDALS + 1                          // the extra one is for the rank medal
274
275 static bitmap *Medals_mask;
276 int Medals_mask_w, Medals_mask_h;
277 static int Medal_palette;              // Medal palette bitmap
278 static int Medals_bitmap_mask;         // the mask for the medal case
279 static int Medals_bitmap;              // the medal case itself
280 static int Medal_bitmaps[NUM_MEDALS];  // bitmaps for the individual medals
281 static int Rank_bm;                                                     // bitmap for the rank medal
282
283 static MENU_REGION Medal_regions[NUM_MEDAL_REGIONS]; // a semi-hack for now because we only have 4 medals, but we also include the close button
284
285 static UI_WINDOW Medals_window;
286
287 //#define MAX_MEDALS_BUTTONS                                            1
288 //#define MEDAL_BUTTON_EXIT                                             0
289 //static UI_BUTTON Medal_buttons[MAX_MEDALS_BUTTONS];
290
291 /*static char *Medal_button_names[MAX_MEDALS_BUTTONS] = {
292 //XSTR:OFF
293         "MX_17"
294 //XSTR:ON
295 };
296 */
297 /*
298 static int Medal_button_coords[MAX_MEDALS_BUTTONS][2] = {
299         {561,411}
300 };
301 static int Medal_button_masks[MAX_MEDALS_BUTTONS] = {
302         17
303 };
304 */
305
306
307 #define MEDAL_BITMAP_INIT (1<<0)
308 #define MASK_BITMAP_INIT  (1<<1)
309 int Init_flags;
310
311 void parse_medal_tbl()
312 {
313         int rval, num_medals, i, bi;
314
315         if ((rval = setjmp(parse_abort)) != 0) {
316                 Error(LOCATION, "Error parsing 'medals.tbl'\r\nError code = %i.\r\n", rval);
317         } 
318
319         // open localization
320         lcl_ext_open();
321
322         read_file_text("medals.tbl");
323
324         reset_parse();
325
326         // parse in all the rank names
327         num_medals = 0;
328         bi = 0;
329         required_string("#Medals");
330         while ( required_string_either("#End", "$Name:") ) {
331                 Assert ( num_medals < NUM_MEDALS);
332                 required_string("$Name:");
333                 stuff_string( Medals[num_medals].name, F_NAME, NULL );
334                 required_string("$Bitmap:");
335                 stuff_string( Medals[num_medals].bitmap, F_NAME, NULL );
336                 required_string("$Num mods:");
337                 stuff_int( &Medals[num_medals].num_versions);
338
339                 // some medals are based on kill counts.  When string +Num Kills: is present, we know that
340                 // this medal is a badge and should be treated specially
341                 Medals[num_medals].kills_needed = 0;
342                 if ( optional_string("+Num Kills:") ) {
343                         char buf[MULTITEXT_LENGTH + 1];
344
345                         Assert( bi < MAX_BADGES );
346                         stuff_int( &Medals[num_medals].kills_needed );
347                         Badge_index[bi] = num_medals;
348
349                         required_string("$Wavefile Base:");
350                         stuff_string(Badge_info[bi].voice_base, F_NAME, NULL, MAX_FILENAME_LEN);
351
352                         //required_string("$Wavefile 2:");
353                         //stuff_string(Badge_info[bi].wave2, F_NAME, NULL, MAX_FILENAME_LEN);
354
355                         required_string("$Promotion Text:");
356                         stuff_string(buf, F_MULTITEXT, NULL);
357                         Badge_info[bi].promotion_text = strdup(buf);
358
359                         bi++;
360                 }
361
362                 num_medals++;
363         }
364
365         required_string("#End");
366         Assert( num_medals == NUM_MEDALS );
367
368         // be sure that the badges kill numbers show up in order
369         for (i = 0; i < MAX_BADGES-1; i++ ) {
370                 if ( Medals[Badge_index[i]].kills_needed >= Medals[Badge_index[i+1]].kills_needed ){
371                         Error(LOCATION, "Badges must appear sorted by lowest kill # first in medals.tbl\nFind Allender for most information.");
372                 }
373         }
374
375         // close localization
376         lcl_ext_close();
377 }
378
379 void medal_main_init(player *pl, int mode)
380 {
381         int idx;
382
383         Assert(pl != NULL);
384         Medals_player = pl;
385
386    Player_score = &Medals_player->stats;
387
388         #ifndef NDEBUG
389         if(Cmdline_gimme_all_medals){
390                 //int idx;
391                 for(idx=0; idx < NUM_MEDALS; idx++){
392                         Medals_player->stats.medals[idx] = 1;           
393                 }
394         }
395         #endif
396
397         Medals_mode = mode;
398
399         snazzy_menu_init();
400         Medals_window.create( 0, 0, gr_screen.max_w, gr_screen.max_h, 0 );      
401
402         // create the interface buttons
403         for (idx=0; idx<MEDALS_NUM_BUTTONS; idx++) {
404                 // create the object
405                 Medals_buttons[gr_screen.res][idx].button.create(&Medals_window, "", Medals_buttons[gr_screen.res][idx].x, Medals_buttons[gr_screen.res][idx].y, 1, 1, 0, 1);
406
407                 // set the sound to play when highlighted
408                 Medals_buttons[gr_screen.res][idx].button.set_highlight_action(common_play_highlight_sound);
409
410                 // set the ani for the button
411                 Medals_buttons[gr_screen.res][idx].button.set_bmaps(Medals_buttons[gr_screen.res][idx].filename);
412
413                 // set the hotspot
414                 Medals_buttons[gr_screen.res][idx].button.link_hotspot(Medals_buttons[gr_screen.res][idx].hotspot);
415         }       
416
417         // add all xstrs
418         for (idx=0; idx<MEDALS_NUM_TEXT; idx++) {
419                 Medals_window.add_XSTR(&Medals_text[gr_screen.res][idx]);
420         }
421
422
423         Init_flags = 0; 
424
425         //init_medal_palette();
426         
427         Medals_bitmap = bm_load(Medals_background_filename[gr_screen.res]);
428         if (Medals_bitmap < 0) {
429            Error(LOCATION, "Error loading medal background bitmap %s", Medals_background_filename[gr_screen.res]);
430         } else {
431                 Init_flags |= MEDAL_BITMAP_INIT;
432         }
433
434         Medals_mask_w = -1;
435         Medals_mask_h = -1;
436       
437         Medals_bitmap_mask = bm_load(Medals_mask_filename[gr_screen.res]);
438         if(Medals_bitmap_mask < 0){
439                 Error(LOCATION, "Error loading medal mask file %s", Medals_mask_filename[gr_screen.res]);
440         } else {
441                 Init_flags |= MASK_BITMAP_INIT;
442                 Medals_mask = bm_lock(Medals_bitmap_mask, 8, BMP_AABITMAP);
443                 bm_get_info(Medals_bitmap_mask, &Medals_mask_w, &Medals_mask_h);
444         }
445         init_medal_bitmaps();
446         init_snazzy_regions();
447
448         gr_set_color_fast(&Color_normal);
449
450         Medals_window.set_mask_bmap(Medals_mask_filename[gr_screen.res]);
451 }
452
453 // this is just a hack to display translated names without actually changing the names, 
454 // which would break stuff
455 void medals_translate_name(char *name, int max_len)
456 {
457         if (!strcmp(name, "Epsilon Pegasi Liberation")) {
458                 strncpy(name, "Epsilon Pegasi Befreiungsmedaille", max_len);
459
460         } else if (!strcmp(name, "Imperial Order of Vasuda")) {
461                 strncpy(name, "Imperialer Orden von Vasuda ", max_len);
462
463         } else if (!strcmp(name, "Distinguished Flying Cross")) {
464                 strncpy(name, "Fliegerkreuz Erster Klasse", max_len);
465
466         } else if (!strcmp(name, "SOC Service Medallion")) {
467                 strncpy(name, "SEK-Dienstmedaille ", max_len);
468
469         } else if (!strcmp(name, "Intelligence Cross")) {
470                 strncpy(name, "Geheimdienstkreuz am Bande", max_len);
471
472         } else if (!strcmp(name, "Order of Galatea")) {
473                 strncpy(name, "Orden von Galatea ", max_len);
474
475         } else if (!strcmp(name, "Meritorious Unit Commendation")) {
476                 strncpy(name, "Ehrenspange der Allianz", max_len);
477
478         } else if (!strcmp(name, "Medal of Valor")) {
479                 strncpy(name, "Tapferkeitsmedaille ", max_len);
480
481         } else if (!strcmp(name, "GTVA Legion of Honor")) {
482                 strncpy(name, "Orden der GTVA-Ehrenlegion", max_len);
483
484         } else if (!strcmp(name, "Allied Defense Citation")) {
485                 strncpy(name, "Alliierte Abwehrspange ", max_len);
486
487         } else if (!strcmp(name, "Nebula Campaign Victory Star")) {
488                 strncpy(name, "Nebel-Siegesstern", max_len);
489
490         } else if (!strcmp(name, "NTF Campaign Victory Star")) {
491                 strncpy(name, "NTF-Siegesstern ", max_len);
492
493         } else if (!strcmp(name, "Rank")) {
494                 strncpy(name, "Dienstgrad", max_len);
495
496         } else if (!strcmp(name, "Wings")) {
497                 strncpy(name, "Fliegerspange", max_len);
498
499         } else if (!strcmp(name, "Ace")) {
500                 strncpy(name, "Flieger-As", max_len);   
501
502         } else if (!strcmp(name, "Double Ace")) {
503                 strncpy(name, "Doppel-As ", max_len);
504
505         } else if (!strcmp(name, "Triple Ace")) {
506                 strncpy(name, "Dreifach-As ", max_len);
507                 
508         } else if (!strcmp(name, "SOC Unit Crest")) {
509                 strncpy(name, "SEK-Abzeichen ", max_len);       
510         }
511 }
512
513 void blit_label(char *label, int *coords, int num)
514 {
515         int x, y, sw;
516         char text[256];
517
518         gr_set_color_fast(&Color_bright);
519
520         // translate medal names before displaying
521         // cant translate in table cuz the names are used in comparisons
522         if (Lcl_gr) {
523                 char translated_label[256];
524                 strncpy(translated_label, label, 256);
525                 medals_translate_name(translated_label, 256);
526
527                 // set correct string
528                 if ( num > 1 ) {
529                         sprintf( text, NOX("%s (%d)"), translated_label, num );
530                 } else {
531                         sprintf( text, "%s", translated_label );
532                 }               
533         } else {
534                 // set correct string
535                 if ( num > 1 ) {
536                         sprintf( text, NOX("%s (%d)"), label, num );
537                 } else {
538                         sprintf( text, "%s", label );
539                 }
540         }
541
542         // find correct coords
543         gr_get_string_size(&sw, NULL, text);
544         x = Medals_label_coords[gr_screen.res][0] + (Medals_label_coords[gr_screen.res][2] - sw) / 2;
545         y = Medals_label_coords[gr_screen.res][1];
546
547         // do it
548         gr_string(x, y, text);
549 }
550
551 void blit_callsign()
552 {
553         gr_set_color_fast(&Color_normal);
554
555         // nothing special, just do it.
556         gr_string(0x8000, Medals_callsign_y[gr_screen.res], Medals_player->callsign);
557 }
558
559 int medal_main_do()
560 {
561    int region,selected, k;
562
563         k = Medals_window.process();    
564
565         // process an exit command
566         if ((k == KEY_ESC) && (Medals_mode == MM_NORMAL)) {
567                 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
568         }
569
570         // draw the background medal display case
571         gr_reset_clip();
572         GR_MAYBE_CLEAR_RES(Medals_bitmap);
573         if(Medals_bitmap != -1){
574                 gr_set_bitmap(Medals_bitmap);
575                 gr_bitmap(0,0);
576         }
577
578         // check to see if a button was pressed
579         if( (k == (KEY_CTRLED|KEY_ENTER)) || (Medals_buttons[gr_screen.res][MEDALS_EXIT].button.pressed()) ) {  
580                 gamesnd_play_iface(SND_COMMIT_PRESSED);
581                 if(Medals_mode == MM_NORMAL){
582                         gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
583                 } else {
584                         // any calling popup function will know to close the screen down
585                         return 0;
586                 }               
587         }
588
589         // blit medals also takes care of blitting the rank insignia
590         blit_medals(); 
591         blit_callsign();        
592         
593         region = snazzy_menu_do((ubyte*)Medals_mask->data, Medals_mask_w, Medals_mask_h, NUM_MEDAL_REGIONS, Medal_regions, &selected);
594         switch (region) {
595                 case ESC_PRESSED:
596                         if (Medals_mode == MM_NORMAL) {
597                                 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
598                         } else {
599                                 // any calling popup function will know to close the screen down
600                                 return 0;
601                         }
602                         break;
603
604                 case RANK_MEDAL_REGION :
605                         blit_label(Ranks[Player_score->rank].name, &Medal_coords[gr_screen.res][region][0], 1);
606                         break;
607
608                 case -1:
609                         break;
610
611                 default :
612         if (Player_score->medals[region] > 0){
613                                 blit_label(Medals[region].name, &Medal_coords[gr_screen.res][region][0], Player_score->medals[region] );
614                         }
615                         break;
616         } // end switch
617
618         Medals_window.draw();
619
620         gr_flip();
621
622         return 1;
623 }
624
625 void medal_main_close()
626 {
627         int idx;
628         if (Init_flags & MEDAL_BITMAP_INIT)
629                 bm_unload(Medals_bitmap);
630
631         if (Init_flags & MASK_BITMAP_INIT) {
632                 bm_unlock(Medals_bitmap_mask);
633                 bm_unload(Medals_bitmap_mask);
634         }
635
636    for (idx=0; idx < NUM_MEDALS; idx++) {
637                 if (Medal_bitmaps[idx] > -1){
638                         bm_unload(Medal_bitmaps[idx]);
639                 }
640         }
641
642    Player_score = NULL;
643         Medals_window.destroy();
644         snazzy_menu_close();
645         palette_restore_palette();
646 }
647
648 /*
649 void init_medal_palette()
650 {
651         Medal_palette = bm_load("MedalsPalette.pcx");
652         if(Medal_palette > -1){
653 #ifndef HARDWARE_ONLY
654                 palette_use_bm_palette(Medal_palette);
655 #endif
656         }
657 }
658 */
659
660 // function to load in the medals for this player.  It loads medals that the player has (known
661 // by whether or not a non-zero number is present in the player's medal array), then loads the
662 // rank bitmap
663
664 void init_medal_bitmaps()
665 {
666         int idx;
667         Assert(Player_score);
668
669         for (idx=0; idx<NUM_MEDALS; idx++) {
670                 Medal_bitmaps[idx] = -1;
671                 if (Player_score->medals[idx] > 0) {
672                         int num_medals;
673                         char filename[NAME_LENGTH], base[NAME_LENGTH];
674                         
675                         // possibly load a different filename that is specified by the bitmap filename
676                         // for this medal.  if the player has > 1 of these types of medals, then determien
677                         // which of the possible version to use based on the player's count of this medal
678                         strcpy( filename, Medals[idx].bitmap );
679 #ifdef PLAT_UNIX
680                         STUB_FUNCTION;
681 #else
682                         _splitpath( filename, NULL, NULL, base, NULL );
683 #endif
684
685                         num_medals = Player_score->medals[idx];
686
687                         // can't display more than the maximum number of version for this medal
688                         if ( num_medals > Medals[idx].num_versions )
689                                 num_medals = Medals[idx].num_versions;
690
691                         if ( num_medals > 1 ) {
692                                 // append the proper character onto the end of the medal filename.  Base version
693                                 // has no character. next version is a, then b, etc.
694                                 sprintf( base, "%s%c", base, (num_medals-2)+'a');
695                         }
696         
697                         // hi-res support
698                         if (gr_screen.res == GR_1024) {
699                                 sprintf( filename, "2_%s", base );
700                         }
701
702                         // base now contains the actual medal bitmap filename needed to load
703                         // we don't need to pass extension to bm_load anymore, so just use the basename
704                         // as is.
705          Medal_bitmaps[idx] = bm_load( filename );
706                         Assert( Medal_bitmaps[idx] != -1 );
707                 }
708         }
709
710         // load up rank insignia
711         if (gr_screen.res == GR_1024) {
712                 char filename[NAME_LENGTH];
713                 sprintf(filename, "2_%s", Ranks[Player_score->rank].bitmap);
714                 Rank_bm = bm_load(filename);
715         } else {
716                 Rank_bm = bm_load(Ranks[Player_score->rank].bitmap);
717         }
718 }
719
720 void init_snazzy_regions()
721 {
722         int idx;
723
724         // snazzy regions for the medals/ranks, etc.
725         for (idx=0; idx<NUM_MEDALS; idx++) {
726                 if (idx == RANK_MEDAL_REGION) 
727                         continue;
728
729                 snazzy_menu_add_region(&Medal_regions[idx], "", idx, 0);
730         }
731
732         // add the rank medal region
733         snazzy_menu_add_region(&Medal_regions[RANK_MEDAL_REGION], "", RANK_MEDAL_REGION,0);
734 }
735
736
737 // blit the medals -- this includes the rank insignia
738 void blit_medals()
739 {
740         int idx;
741
742         for (idx=0; idx<NUM_MEDALS; idx++) {
743                 if (Player_score->medals[idx] > 0) {
744                         gr_set_bitmap(Medal_bitmaps[idx]);
745                         gr_bitmap(Medal_coords[gr_screen.res][idx][0], Medal_coords[gr_screen.res][idx][1]);
746                 }
747         }
748
749         // now blit rank, since that "medal" doesnt get loaded (or drawn) the normal way
750         gr_set_bitmap(Rank_bm);
751         gr_bitmap(Medal_coords[gr_screen.res][RANK_MEDAL_REGION][0], Medal_coords[gr_screen.res][RANK_MEDAL_REGION][1]);
752 }
753