2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/Stats/Medals.cpp $
16 * Revision 1.13 2004/09/20 01:31:45 theoddone33
19 * Revision 1.12 2004/07/04 11:39:06 taylor
20 * fix missing debrief text, crash on exit, path separator's, warning fixes, no GR_SOFT
22 * Revision 1.11 2003/08/03 16:10:30 taylor
23 * cleanup; compile warning fixes
25 * Revision 1.10 2003/06/11 18:30:33 taylor
28 * Revision 1.9 2003/06/03 04:00:40 taylor
29 * Polish language support (Janusz Dziemidowicz)
31 * Revision 1.8 2003/05/25 02:30:44 taylor
34 * Revision 1.7 2002/06/09 04:41:27 relnev
35 * added copyright header
37 * Revision 1.6 2002/06/09 03:16:05 relnev
40 * removed unneeded asm, old sdl 2d setup.
42 * fixed crash caused by opengl_get_region.
44 * Revision 1.5 2002/05/28 08:52:03 relnev
45 * implemented two assembly stubs.
47 * cleaned up a few warnings.
49 * added a little demo hackery to make it progress a little farther.
51 * Revision 1.4 2002/05/28 04:56:51 theoddone33
52 * runs a little bit now
54 * Revision 1.3 2002/05/26 20:22:48 theoddone33
55 * Most of network/ works
57 * Revision 1.2 2002/05/04 04:36:56 theoddone33
58 * More changes, took out a lot of the sound stuff which will bite later but
61 * Revision 1.1.1.1 2002/05/03 03:28:11 root
65 * 12 10/29/99 10:40p Jefff
66 * hack to make german medal names display without actually changing them
68 * 11 9/02/99 3:41p Jefff
69 * changed badge voice handling to be similar to promotion voice handling
71 * 10 8/26/99 8:49p Jefff
72 * Updated medals screen and about everything that ever touches medals in
73 * one way or another. Sheesh.
75 * 9 7/16/99 1:50p Dave
76 * 8 bit aabitmaps. yay.
78 * 8 3/19/99 9:51a Dave
79 * Checkin to repair massive source safe crash. Also added support for
80 * pof-style nebulae, and some new weapons code.
82 * 8 3/15/99 10:29a Neilk
84 * 7 1/30/99 5:08p Dave
85 * More new hi-res stuff.Support for nice D3D textures.
87 * 6 12/18/98 1:13a Dave
88 * Rough 1024x768 support for Direct3D. Proper detection and usage through
91 * 5 11/30/98 1:07p Dave
92 * 16 bit conversion, first run.
94 * 4 10/23/98 3:51p Dave
95 * Full support for tstrings.tbl and foreign languages. All that remains
96 * is to make it active in Fred.
98 * 3 10/13/98 9:29a Dave
99 * Started neatening up freespace.h. Many variables renamed and
100 * reorganized. Added AlphaColors.[h,cpp]
102 * 2 10/07/98 10:54a Dave
105 * 1 10/07/98 10:51a Dave
107 * 26 6/13/98 3:18p Hoffoss
108 * NOX()ed out a bunch of strings that shouldn't be translated.
110 * 25 6/01/98 11:43a John
111 * JAS & MK: Classified all strings for localization.
113 * 24 5/01/98 12:34p John
114 * Added code to force FreeSpace to run in the same dir as exe and made
115 * all the parse error messages a little nicer.
117 * 23 4/27/98 3:13p Allender
118 * make ctrl-enter work on medals screen
120 * 22 4/23/98 8:27p Allender
121 * basic support for cutscene playback. Into movie code in place. Tech
122 * room can view cutscenes stored in CDROM_dir variable
124 * 21 4/12/98 8:30p Allender
125 * minor medal changes to show number of medals if > 1
127 * 20 4/10/98 4:51p Hoffoss
128 * Made several changes related to tooltips.
130 * 19 3/18/98 12:03p John
131 * Marked all the new strings as externalized or not.
133 * 18 3/11/98 5:02p Dave
134 * Put in code to support new medals artwork. Assorted multiplayer bug
137 * 17 3/07/98 5:44p Dave
138 * Finished player info popup. Ironed out a few todo bugs.
140 * 16 3/05/98 5:11p Allender
141 * fix up medals screen (again). Don't do state transition when viewing
142 * medals from debriefing screen.
144 * 15 3/05/98 2:32p Hoffoss
145 * Renamed Rank_bitmap to Rank_bm so it isn't named the same as the
146 * variable in the debrief screen which confuses the debugger.
148 * 14 2/22/98 2:48p John
149 * More String Externalization Classification
151 * 13 2/09/98 5:21p Hoffoss
152 * Made exit from medals screen to previous screen (instead of assuming
153 * it's the barracks) work.
155 * 12 1/27/98 4:23p Allender
156 * enhanced internal scoring mechanisms.
158 * 11 11/12/97 4:40p Dave
159 * Put in multiplayer campaign support parsing, loading and saving. Made
160 * command-line variables better named. Changed some things on the initial
161 * pilot select screen.
163 * 10 11/12/97 9:30a Dave
164 * Fixed rank insignia tooltip not showing up.
166 * 9 11/06/97 4:39p Allender
167 * a ton of medal work. Removed an uneeded elemen in the scoring
168 * structure. Fix up medals screen to apprioriate display medals (after
169 * mask was changed). Fix Fred to only display medals which may actually
170 * be granted. Added image_filename to player struct for Jason Hoffoss
172 * 8 11/05/97 4:43p Allender
173 * reworked medal/rank system to read all data from tables. Made Fred
174 * read medals.tbl. Changed ai-warp to ai-warp-out which doesn't require
175 * waypoint for activation
183 #include "snazzyui.h"
185 #include "gamesequence.h"
186 #include "animplay.h"
188 #include "freespace.h"
196 #include "alphacolors.h"
197 #include "localize.h"
198 #include "missionscreencommon.h" // for common_set_interface_palette
200 //#define MAX_MEDAL_TYPES 63 // the # of medals which exist so far
203 #define CALLSIGN_X 198
204 #define CALLSIGN_Y 80
205 #define CALLSIGN_W (439-CALLSIGN_X)
206 #define CALLSIGN_H (116-CALLSIGN_Y)
209 // define for the medal information
210 medal_stuff Medals[NUM_MEDALS];
211 badge_stuff Badge_info[MAX_BADGES];
213 // holds indices into Medals array of the badges for # kills
214 int Badge_index[MAX_BADGES];
216 // the rank section of the screen
218 // not in Medal_coords but needs to be set
219 // to not interfere with other medals
220 #define RANK_MEDAL_REGION 16 // region number of the rank medal
222 #define RANK_MEDAL_REGION 12 // region number of the rank medal
226 #warning Find real FS2_DEMO spot for medals
228 // coords for indiv medal bitmaps
229 int Medal_coords[GR_NUM_RESOLUTIONS][NUM_MEDALS][2] = {
232 { 108, 74 }, // Conspicuous Gallantry
233 { 473, 73 }, // Vasudan Alliance
234 { 146, 150 }, // Distinguished Flying Cross
235 { 219, 152 }, // Commendation Medal
236 { 360, 150 }, // Galatea Survivor
237 { 432, 150 }, // Legion of Merit
238 { 88, 243 }, // Meritorious Unit
239 { 168, 243 }, // Medal of Honor
240 { 248, 250 }, // Galactic Service
241 { 328, 250 }, // Military Defense
242 { 406, 244 }, // Good Conduct
243 { 483, 243 }, // Distinguished Service Cross
245 { 373, 109 }, // Double Ace
247 { 403, 109 }, // Triple Ace
249 { 287, 186 }, // Wings
251 { 89, 47 }, // eps. peg. lib
252 { 486, 47 }, // imp. order o' vasuda
253 { 129, 130 }, // dist flying cross
254 { 208, 132 }, // soc service
255 { 361, 131 }, // dist intel cross
256 { 439, 130 }, // order of galatea
257 { 64, 234 }, // meritorious unit comm.
258 { 153, 234 }, // medal of valor
259 { 239, 241 }, // gtva leg of honor
260 { 326, 240 }, // allied defense citation
261 { 411, 234 }, // neb campaign victory
262 { 494, 234 }, // ntf campaign victory
264 { 283, 91 }, // wings
265 { 372, 76 }, // bronze kills badge
266 { 403, 76 }, // silver kills badge
268 { 435, 76 }, // gold kills badge
269 { 300, 152 }, // SOC unit crest
274 { 143, 75 }, // eps. peg. lib
275 { 777, 75 }, // imp. order o' vasuda
276 { 206, 208 }, // dist flying cross
277 { 333, 212 }, // soc service
278 { 578, 210 }, // dist intel cross
279 { 703, 208 }, // order of galatea
280 { 103, 374 }, // meritorious unit comm.
281 { 245, 374 }, // medal of valor
282 { 383, 386 }, // gtva leg of honor
283 { 522, 384 }, // allied defense citation
284 { 658, 374 }, // neb campaign victory
285 { 790, 374 }, // ntf campaign victory
286 { 302, 128 }, // rank
287 { 453, 146 }, // wings
288 { 595, 121 }, // bronze kills badge
289 { 646, 121 }, // silver kills badge
290 #if !(defined(FS2_DEMO) || defined(MAKE_FS1))
291 { 696, 121 }, // gold kills badge
292 { 480, 244 }, // SOC unit crest
298 // coords for the medal/rank title
299 static int Rank_label_coords[2] = {
303 static int Rank_coords[2] = {
307 // I couldn't think of a better way to do this so define
308 // the base center point for each medal to center the label on
310 // x = the horizontal center point of the bitmap
311 // y = the base of the medal bitmap itself
312 static int Medals_label_coords[NUM_MEDALS][2] = {
314 { 137, 158 }, // Conspicuous Gallantry
315 { 502, 154 }, // Vasudan Alliance
316 { 176, 238 }, // Distinguished Flying Cross
317 { 249, 244 }, // Commendation Medal
318 { 390, 238 }, // Galatea Survivor
319 { 462, 237 }, // Legion of Merit
320 { 121, 345 }, // Meritorious Unit
321 { 199, 346 }, // Medal of Honor
322 { 280, 349 }, // Galactic Service
323 { 360, 350 }, // Military Defense
324 { 438, 349 }, // Good Conduct
325 { 517, 353 }, // Distinguished Service Cross
327 { 385, 129 }, // Double Ace
329 { 415, 129 }, // Triple Ace
331 { 319, 216 }, // Wings
334 // coords for the medal title
335 static int Medals_label_coords[GR_NUM_RESOLUTIONS][3] = {
336 { 241, 458, 300 }, // GR_640 x, y, w
337 { 386, 734, 480 } // GR_1024 x, y, w
341 #define MEDALS_NUM_BUTTONS 1
342 #define MEDALS_EXIT 0
343 ui_button_info Medals_buttons[GR_NUM_RESOLUTIONS][MEDALS_NUM_BUTTONS] = {
346 ui_button_info("MX_17", 561, 411, -1, -1, 17),
348 ui_button_info("MEB_18", 574, 432, -1, -1, 18),
352 ui_button_info("2_MEB_18", 919, 691, -1, -1, 18),
357 #define MEDALS_NUM_TEXT 0
359 #define MEDALS_NUM_TEXT 1
361 UI_XSTR Medals_text[GR_NUM_RESOLUTIONS][MEDALS_NUM_TEXT] = {
363 // not needed for FS1
365 {"Exit", 1466, 587, 416, UI_XSTR_COLOR_PINK, -1, &Medals_buttons[GR_640][MEDALS_EXIT].button },
369 // not needed for FS1
371 {"Exit", 1466, 943, 673, UI_XSTR_COLOR_PINK, -1, &Medals_buttons[GR_1024][MEDALS_EXIT].button },
376 static char* Medals_background_filename[GR_NUM_RESOLUTIONS] = {
377 "MedalsDisplayEmpty",
378 "2_MedalsDisplayEmpty"
381 static char* Medals_mask_filename[GR_NUM_RESOLUTIONS] = {
386 static int Medals_callsign_y[GR_NUM_RESOLUTIONS] = {
394 scoring_struct *Player_score=NULL;
397 player *Medals_player;
399 // -----------------------------------------------------------------------------
400 // Main medals screen state
402 #define NUM_MEDAL_REGIONS NUM_MEDALS + 1 // the extra one is for the rank medal
404 static bitmap *Medals_mask;
405 int Medals_mask_w, Medals_mask_h;
406 //static int Medal_palette; // Medal palette bitmap - no longer used
407 static int Medals_bitmap_mask; // the mask for the medal case
408 static int Medals_bitmap; // the medal case itself
409 static int Medal_bitmaps[NUM_MEDALS]; // bitmaps for the individual medals
410 static int Rank_bm; // bitmap for the rank medal
412 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
414 static UI_WINDOW Medals_window;
416 //#define MAX_MEDALS_BUTTONS 1
417 //#define MEDAL_BUTTON_EXIT 0
418 //static UI_BUTTON Medal_buttons[MAX_MEDALS_BUTTONS];
420 /*static char *Medal_button_names[MAX_MEDALS_BUTTONS] = {
427 static int Medal_button_coords[MAX_MEDALS_BUTTONS][2] = {
430 static int Medal_button_masks[MAX_MEDALS_BUTTONS] = {
436 #define MEDAL_BITMAP_INIT (1<<0)
437 #define MASK_BITMAP_INIT (1<<1)
440 void parse_medal_tbl()
442 int rval, num_medals, i, bi;
444 if ((rval = setjmp(parse_abort)) != 0) {
445 Error(LOCATION, "Error parsing 'medals.tbl'\r\nError code = %i.\r\n", rval);
451 read_file_text("medals.tbl");
455 // parse in all the rank names
458 required_string("#Medals");
459 while ( required_string_either("#End", "$Name:") ) {
460 Assert ( num_medals < NUM_MEDALS);
461 required_string("$Name:");
462 stuff_string( Medals[num_medals].name, F_NAME, NULL );
463 required_string("$Bitmap:");
464 stuff_string( Medals[num_medals].bitmap, F_NAME, NULL );
465 required_string("$Num mods:");
466 stuff_int( &Medals[num_medals].num_versions);
468 // some medals are based on kill counts. When string +Num Kills: is present, we know that
469 // this medal is a badge and should be treated specially
470 Medals[num_medals].kills_needed = 0;
471 if ( optional_string("+Num Kills:") ) {
472 char buf[MULTITEXT_LENGTH + 1];
474 Assert( bi < MAX_BADGES );
475 stuff_int( &Medals[num_medals].kills_needed );
476 Badge_index[bi] = num_medals;
478 required_string("$Wavefile 1:");
479 stuff_string(Badge_info[bi].voice_base, F_NAME, NULL, MAX_FILENAME_LEN);
480 required_string("$Wavefile 2:");
481 stuff_string(Badge_info[bi].voice_base2, F_NAME, NULL, MAX_FILENAME_LEN);
483 #warning FS2_DEMO HACK: Wavefile 1/2: wave1? wave2?
484 required_string("$Wavefile 1:");
485 stuff_string(Badge_info[bi].voice_base, F_NAME, NULL, MAX_FILENAME_LEN);
486 required_string("$Wavefile 2:");
487 stuff_string(Badge_info[bi].voice_base, F_NAME, NULL, MAX_FILENAME_LEN);
488 //stuff_string(Badge_info[bi].wave2, F_NAME, NULL, MAX_FILENAME_LEN);
490 required_string("$Wavefile Base:");
491 stuff_string(Badge_info[bi].voice_base, F_NAME, NULL, MAX_FILENAME_LEN);
494 required_string("$Promotion Text:");
495 stuff_string(buf, F_MULTITEXT, NULL);
496 Badge_info[bi].promotion_text = strdup(buf);
504 required_string("#End");
505 Assert( num_medals == NUM_MEDALS );
507 // be sure that the badges kill numbers show up in order
508 for (i = 0; i < MAX_BADGES-1; i++ ) {
509 if ( Medals[Badge_index[i]].kills_needed >= Medals[Badge_index[i+1]].kills_needed ){
510 Error(LOCATION, "Badges must appear sorted by lowest kill # first in medals.tbl\nFind Allender for most information.");
514 // close localization
518 void medal_main_init(player *pl, int mode)
525 Player_score = &Medals_player->stats;
528 if(Cmdline_gimme_all_medals){
530 for(idx=0; idx < NUM_MEDALS; idx++){
531 Medals_player->stats.medals[idx] = 1;
539 Medals_window.create( 0, 0, gr_screen.max_w, gr_screen.max_h, 0 );
541 // create the interface buttons
542 for (idx=0; idx<MEDALS_NUM_BUTTONS; idx++) {
544 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);
546 // set the sound to play when highlighted
547 Medals_buttons[gr_screen.res][idx].button.set_highlight_action(common_play_highlight_sound);
549 // set the ani for the button
550 Medals_buttons[gr_screen.res][idx].button.set_bmaps(Medals_buttons[gr_screen.res][idx].filename);
553 Medals_buttons[gr_screen.res][idx].button.link_hotspot(Medals_buttons[gr_screen.res][idx].hotspot);
557 for (idx=0; idx<MEDALS_NUM_TEXT; idx++) {
558 Medals_window.add_XSTR(&Medals_text[gr_screen.res][idx]);
564 //init_medal_palette();
566 common_set_interface_palette("MedalsPalette");
569 Medals_bitmap = bm_load(Medals_background_filename[gr_screen.res]);
570 if (Medals_bitmap < 0) {
571 Error(LOCATION, "Error loading medal background bitmap %s", Medals_background_filename[gr_screen.res]);
573 Init_flags |= MEDAL_BITMAP_INIT;
579 Medals_bitmap_mask = bm_load(Medals_mask_filename[gr_screen.res]);
580 if(Medals_bitmap_mask < 0){
581 Error(LOCATION, "Error loading medal mask file %s", Medals_mask_filename[gr_screen.res]);
583 Init_flags |= MASK_BITMAP_INIT;
584 Medals_mask = bm_lock(Medals_bitmap_mask, 8, BMP_AABITMAP);
585 bm_get_info(Medals_bitmap_mask, &Medals_mask_w, &Medals_mask_h);
587 init_medal_bitmaps();
588 init_snazzy_regions();
590 gr_set_color_fast(&Color_normal);
592 Medals_window.set_mask_bmap(Medals_mask_filename[gr_screen.res]);
595 // this is just a hack to display translated names without actually changing the names,
596 // which would break stuff
597 void medals_translate_name(char *name, int max_len)
600 if (!strcmp(name, "Conspicuous Gallantry")) {
601 strncpy(name, "Tapferkeitsmedaille", max_len);
603 } else if (!strcmp(name, "Vasudan Alliance")) {
604 strncpy(name, "Vasudanischen Allianz", max_len);
606 } else if (!strcmp(name, "Distinguished Flying Cross")) {
607 strncpy(name, "Kreuz f\x81r Fliegerleistungen", max_len);
609 } else if (!strcmp(name, "Commendation Medal")) {
610 strncpy(name, "Anerkennungsmedaille", max_len);
612 } else if (!strcmp(name, "Galatea Survivor")) {
613 strncpy(name, "Galatea-\x9A""berlebender", max_len);
615 } else if (!strcmp(name, "Legion of Merit")) {
616 strncpy(name, "Verdienstlegion", max_len);
618 } else if (!strcmp(name, "Meritorious Unit")) {
619 strncpy(name, "Verdienstmedaille", max_len);
621 } else if (!strcmp(name, "Medal of Honor")) {
622 strncpy(name, "Ehrenmedaille", max_len);
624 } else if (!strcmp(name, "Galactic Service")) {
625 strncpy(name, "Galaktischer Dienst", max_len);
627 } else if (!strcmp(name, "Military Defense")) {
628 strncpy(name, "Verteidigungsmedaille", max_len);
630 } else if (!strcmp(name, "Good Conduct")) {
631 strncpy(name, "Medaille f\x81r gute F\x81hrung", max_len);
633 } else if (!strcmp(name, "Distinguished Service Cross")) {
634 strncpy(name, "Kreuz f\x81r Einsatz", max_len);
636 } else if (!strcmp(name, "Ace")) {
637 strncpy(name, "Bronzener Stern", max_len);
639 } else if (!strcmp(name, "Double Ace")) {
640 strncpy(name, "Silberner Stern", max_len);
642 } else if (!strcmp(name, "Triple Ace")) {
643 strncpy(name, "Goldener Stern", max_len);
645 } else if (!strcmp(name, "Wings")) {
646 strncpy(name, "Pilotenabzeichen", max_len);
648 } else if (!strcmp(name, "Rank")) {
649 strncpy(name, "Dienstgrad", max_len);
652 if (!strcmp(name, "Epsilon Pegasi Liberation")) {
653 strncpy(name, "Epsilon Pegasi Befreiungsmedaille", max_len);
655 } else if (!strcmp(name, "Imperial Order of Vasuda")) {
656 strncpy(name, "Imperialer Orden von Vasuda ", max_len);
658 } else if (!strcmp(name, "Distinguished Flying Cross")) {
659 strncpy(name, "Fliegerkreuz Erster Klasse", max_len);
661 } else if (!strcmp(name, "SOC Service Medallion")) {
662 strncpy(name, "SEK-Dienstmedaille ", max_len);
664 } else if (!strcmp(name, "Intelligence Cross")) {
665 strncpy(name, "Geheimdienstkreuz am Bande", max_len);
667 } else if (!strcmp(name, "Order of Galatea")) {
668 strncpy(name, "Orden von Galatea ", max_len);
670 } else if (!strcmp(name, "Meritorious Unit Commendation")) {
671 strncpy(name, "Ehrenspange der Allianz", max_len);
673 } else if (!strcmp(name, "Medal of Valor")) {
674 strncpy(name, "Tapferkeitsmedaille ", max_len);
676 } else if (!strcmp(name, "GTVA Legion of Honor")) {
677 strncpy(name, "Orden der GTVA-Ehrenlegion", max_len);
679 } else if (!strcmp(name, "Allied Defense Citation")) {
680 strncpy(name, "Alliierte Abwehrspange ", max_len);
682 } else if (!strcmp(name, "Nebula Campaign Victory Star")) {
683 strncpy(name, "Nebel-Siegesstern", max_len);
685 } else if (!strcmp(name, "NTF Campaign Victory Star")) {
686 strncpy(name, "NTF-Siegesstern ", max_len);
688 } else if (!strcmp(name, "Rank")) {
689 strncpy(name, "Dienstgrad", max_len);
691 } else if (!strcmp(name, "Wings")) {
692 strncpy(name, "Fliegerspange", max_len);
694 } else if (!strcmp(name, "Ace")) {
695 strncpy(name, "Flieger-As", max_len);
697 } else if (!strcmp(name, "Double Ace")) {
698 strncpy(name, "Doppel-As ", max_len);
700 } else if (!strcmp(name, "Triple Ace")) {
701 strncpy(name, "Dreifach-As ", max_len);
703 } else if (!strcmp(name, "SOC Unit Crest")) {
704 strncpy(name, "SEK-Abzeichen ", max_len);
709 // this is just a hack to display translated names without actually changing the names,
710 // which would break stuff
711 void medals_translate_name_pl(char *name, int max_len)
713 if (!strcmp(name, "Epsilon Pegasi Liberation")) {
714 strncpy(name, "Order Wyzwolenia Epsilon Pegasi", max_len);
716 } else if (!strcmp(name, "Imperial Order of Vasuda")) {
717 strncpy(name, "Imperialny Order Vasudy", max_len);
719 } else if (!strcmp(name, "Distinguished Flying Cross")) {
720 strncpy(name, "Krzy\xBF Wybitnego Pilota", max_len);
722 } else if (!strcmp(name, "SOC Service Medallion")) {
723 strncpy(name, "Krzy\xBF S\xB3u\xBF\x62 Specjalnych", max_len);
725 } else if (!strcmp(name, "Intelligence Cross")) {
726 strncpy(name, "Krzy\xBF Wywiadu", max_len);
728 } else if (!strcmp(name, "Order of Galatea")) {
729 strncpy(name, "Order Galatei", max_len);
731 } else if (!strcmp(name, "Meritorious Unit Commendation")) {
732 strncpy(name, "Medal Pochwalny", max_len);
734 } else if (!strcmp(name, "Medal of Valor")) {
735 strncpy(name, "Medal za Odwag\xEA", max_len);
737 } else if (!strcmp(name, "GTVA Legion of Honor")) {
738 strncpy(name, "Legia Honorowa GTVA", max_len);
740 } else if (!strcmp(name, "Allied Defense Citation")) {
741 strncpy(name, "Order za Obron\xEA Sojuszu", max_len);
743 } else if (!strcmp(name, "Nebula Campaign Victory Star")) {
744 strncpy(name, "Gwiazda Wiktorii Kampanii w Mg\xB3\x61wicy", max_len);
746 } else if (!strcmp(name, "NTF Campaign Victory Star")) {
747 strncpy(name, "Gwiazda Wiktorii Kampanii NTF", max_len);
749 } else if (!strcmp(name, "Rank")) {
750 strncpy(name, "Ranga", max_len);
752 } else if (!strcmp(name, "Wings")) {
753 strncpy(name, "Skrzyd\xB3\x61", max_len);
755 } else if (!strcmp(name, "Ace")) {
756 strncpy(name, "As", max_len);
758 } else if (!strcmp(name, "Double Ace")) {
759 strncpy(name, "Podw\xF3jny As", max_len);
761 } else if (!strcmp(name, "Triple Ace")) {
762 strncpy(name, "Potr\xF3jny As", max_len);
764 } else if (!strcmp(name, "SOC Unit Crest")) {
765 strncpy(name, "Tarcza S\xB3u\xBF\x62 Specjalnych", max_len);
770 void blit_label(char *label, int *coordsx, int *coordsy, int num)
772 void blit_label(char *label, int *coords, int num)
778 gr_set_color_fast(&Color_bright);
780 // translate medal names before displaying
781 // cant translate in table cuz the names are used in comparisons
783 char translated_label[256];
784 strncpy(translated_label, label, 256);
785 medals_translate_name(translated_label, 256);
787 // set correct string
789 sprintf( text, NOX("%s (%d)"), translated_label, num );
791 sprintf( text, "%s", translated_label );
794 char translated_label[256];
795 strncpy(translated_label, label, 256);
796 medals_translate_name_pl(translated_label, 256);
798 // set correct string
800 sprintf( text, NOX("%s (%d)"), translated_label, num );
802 sprintf( text, "%s", translated_label );
805 // set correct string
807 sprintf( text, NOX("%s (%d)"), label, num );
809 sprintf( text, "%s", label );
813 // find correct coords
814 gr_get_string_size(&sw, NULL, text);
816 x = *coordsx - sw / 2;
819 x = Medals_label_coords[gr_screen.res][0] + (Medals_label_coords[gr_screen.res][2] - sw) / 2;
820 y = Medals_label_coords[gr_screen.res][1];
824 gr_string(x, y, text);
830 gr_set_color_fast(&Color_bright_blue);
832 gr_set_color_fast(&Color_normal);
835 // nothing special, just do it.
836 gr_string(0x8000, Medals_callsign_y[gr_screen.res], Medals_player->callsign);
841 int region,selected, k;
843 k = Medals_window.process();
845 // process an exit command
846 if ((k == KEY_ESC) && (Medals_mode == MM_NORMAL)) {
847 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
850 // draw the background medal display case
852 GR_MAYBE_CLEAR_RES(Medals_bitmap);
853 if(Medals_bitmap != -1){
854 gr_set_bitmap(Medals_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
858 // check to see if a button was pressed
859 if( (k == (KEY_CTRLED|KEY_ENTER)) || (Medals_buttons[gr_screen.res][MEDALS_EXIT].button.pressed()) ) {
860 gamesnd_play_iface(SND_COMMIT_PRESSED);
861 if(Medals_mode == MM_NORMAL){
862 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
864 // any calling popup function will know to close the screen down
869 // blit medals also takes care of blitting the rank insignia
873 region = snazzy_menu_do((ubyte*)Medals_mask->data, Medals_mask_w, Medals_mask_h, NUM_MEDAL_REGIONS, Medal_regions, &selected);
876 if (Medals_mode == MM_NORMAL) {
877 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
879 // any calling popup function will know to close the screen down
884 case RANK_MEDAL_REGION :
886 blit_label(Ranks[Player_score->rank].name, &Rank_label_coords[0], &Rank_label_coords[1], 1);
888 blit_label(Ranks[Player_score->rank].name, &Medal_coords[gr_screen.res][region][0], 1);
896 if (Player_score->medals[region] > 0){
898 blit_label(Medals[region].name, &Medals_label_coords[region][0], &Medals_label_coords[region][1], Player_score->medals[region] );
900 blit_label(Medals[region].name, &Medal_coords[gr_screen.res][region][0], Player_score->medals[region] );
906 Medals_window.draw();
913 void medal_main_close()
916 if (Init_flags & MEDAL_BITMAP_INIT)
917 bm_unload(Medals_bitmap);
919 if (Init_flags & MASK_BITMAP_INIT) {
920 bm_unlock(Medals_bitmap_mask);
921 bm_unload(Medals_bitmap_mask);
924 for (idx=0; idx < NUM_MEDALS; idx++) {
925 if (Medal_bitmaps[idx] > -1){
926 bm_unload(Medal_bitmaps[idx]);
931 Medals_window.destroy();
934 common_free_interface_palette();
938 palette_restore_palette();
941 // free up memory from table parsing
942 void medal_tbl_close()
946 for (i=0; i<MAX_BADGES; i++) {
947 if (Badge_info[i].promotion_text) {
948 free(Badge_info[i].promotion_text);
949 Badge_info[i].promotion_text = NULL;
955 void init_medal_palette()
957 Medal_palette = bm_load("MedalsPalette.pcx");
958 if(Medal_palette > -1){
959 #ifndef HARDWARE_ONLY
960 palette_use_bm_palette(Medal_palette);
966 // function to load in the medals for this player. It loads medals that the player has (known
967 // by whether or not a non-zero number is present in the player's medal array), then loads the
970 void init_medal_bitmaps()
973 Assert(Player_score);
975 for (idx=0; idx<NUM_MEDALS; idx++) {
976 Medal_bitmaps[idx] = -1;
977 if (Player_score->medals[idx] > 0) {
979 char filename[NAME_LENGTH], base[NAME_LENGTH];
981 // possibly load a different filename that is specified by the bitmap filename
982 // for this medal. if the player has > 1 of these types of medals, then determien
983 // which of the possible version to use based on the player's count of this medal
984 strcpy( filename, Medals[idx].bitmap );
986 _splitpath( filename, NULL, NULL, base, NULL );
988 num_medals = Player_score->medals[idx];
990 // can't display more than the maximum number of version for this medal
991 if ( num_medals > Medals[idx].num_versions )
992 num_medals = Medals[idx].num_versions;
994 if ( num_medals > 1 ) {
995 // append the proper character onto the end of the medal filename. Base version
996 // has no character. next version is a, then b, etc.
997 sprintf( base, "%s%c", base, (num_medals-2)+'a');
1001 if (gr_screen.res == GR_1024) {
1002 sprintf( filename, "2_%s", base );
1005 // base now contains the actual medal bitmap filename needed to load
1006 // we don't need to pass extension to bm_load anymore, so just use the basename
1008 Medal_bitmaps[idx] = bm_load( filename );
1009 Assert( Medal_bitmaps[idx] != -1 );
1013 // load up rank insignia
1014 if (gr_screen.res == GR_1024) {
1015 char filename[NAME_LENGTH];
1016 sprintf(filename, "2_%s", Ranks[Player_score->rank].bitmap);
1017 Rank_bm = bm_load(filename);
1019 Rank_bm = bm_load(Ranks[Player_score->rank].bitmap);
1023 void init_snazzy_regions()
1027 // snazzy regions for the medals/ranks, etc.
1028 for (idx=0; idx<NUM_MEDALS; idx++) {
1029 if (idx == RANK_MEDAL_REGION)
1032 snazzy_menu_add_region(&Medal_regions[idx], "", idx, 0);
1035 // add the rank medal region
1036 snazzy_menu_add_region(&Medal_regions[RANK_MEDAL_REGION], "", RANK_MEDAL_REGION,0);
1040 // blit the medals -- this includes the rank insignia
1045 for (idx=0; idx<NUM_MEDALS; idx++) {
1046 if (Player_score->medals[idx] > 0) {
1047 gr_set_bitmap(Medal_bitmaps[idx], GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1048 gr_bitmap(Medal_coords[gr_screen.res][idx][0], Medal_coords[gr_screen.res][idx][1]);
1052 // now blit rank, since that "medal" doesnt get loaded (or drawn) the normal way
1053 gr_set_bitmap(Rank_bm, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1055 gr_bitmap(Rank_coords[0], Rank_coords[1]);
1057 gr_bitmap(Medal_coords[gr_screen.res][RANK_MEDAL_REGION][0], Medal_coords[gr_screen.res][RANK_MEDAL_REGION][1]);