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