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