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.10 2003/06/11 18:30:33 taylor
19 * Revision 1.9 2003/06/03 04:00:40 taylor
20 * Polish language support (Janusz Dziemidowicz)
22 * Revision 1.8 2003/05/25 02:30:44 taylor
25 * Revision 1.7 2002/06/09 04:41:27 relnev
26 * added copyright header
28 * Revision 1.6 2002/06/09 03:16:05 relnev
31 * removed unneeded asm, old sdl 2d setup.
33 * fixed crash caused by opengl_get_region.
35 * Revision 1.5 2002/05/28 08:52:03 relnev
36 * implemented two assembly stubs.
38 * cleaned up a few warnings.
40 * added a little demo hackery to make it progress a little farther.
42 * Revision 1.4 2002/05/28 04:56:51 theoddone33
43 * runs a little bit now
45 * Revision 1.3 2002/05/26 20:22:48 theoddone33
46 * Most of network/ works
48 * Revision 1.2 2002/05/04 04:36:56 theoddone33
49 * More changes, took out a lot of the sound stuff which will bite later but
52 * Revision 1.1.1.1 2002/05/03 03:28:11 root
56 * 12 10/29/99 10:40p Jefff
57 * hack to make german medal names display without actually changing them
59 * 11 9/02/99 3:41p Jefff
60 * changed badge voice handling to be similar to promotion voice handling
62 * 10 8/26/99 8:49p Jefff
63 * Updated medals screen and about everything that ever touches medals in
64 * one way or another. Sheesh.
66 * 9 7/16/99 1:50p Dave
67 * 8 bit aabitmaps. yay.
69 * 8 3/19/99 9:51a Dave
70 * Checkin to repair massive source safe crash. Also added support for
71 * pof-style nebulae, and some new weapons code.
73 * 8 3/15/99 10:29a Neilk
75 * 7 1/30/99 5:08p Dave
76 * More new hi-res stuff.Support for nice D3D textures.
78 * 6 12/18/98 1:13a Dave
79 * Rough 1024x768 support for Direct3D. Proper detection and usage through
82 * 5 11/30/98 1:07p Dave
83 * 16 bit conversion, first run.
85 * 4 10/23/98 3:51p Dave
86 * Full support for tstrings.tbl and foreign languages. All that remains
87 * is to make it active in Fred.
89 * 3 10/13/98 9:29a Dave
90 * Started neatening up freespace.h. Many variables renamed and
91 * reorganized. Added AlphaColors.[h,cpp]
93 * 2 10/07/98 10:54a Dave
96 * 1 10/07/98 10:51a Dave
98 * 26 6/13/98 3:18p Hoffoss
99 * NOX()ed out a bunch of strings that shouldn't be translated.
101 * 25 6/01/98 11:43a John
102 * JAS & MK: Classified all strings for localization.
104 * 24 5/01/98 12:34p John
105 * Added code to force FreeSpace to run in the same dir as exe and made
106 * all the parse error messages a little nicer.
108 * 23 4/27/98 3:13p Allender
109 * make ctrl-enter work on medals screen
111 * 22 4/23/98 8:27p Allender
112 * basic support for cutscene playback. Into movie code in place. Tech
113 * room can view cutscenes stored in CDROM_dir variable
115 * 21 4/12/98 8:30p Allender
116 * minor medal changes to show number of medals if > 1
118 * 20 4/10/98 4:51p Hoffoss
119 * Made several changes related to tooltips.
121 * 19 3/18/98 12:03p John
122 * Marked all the new strings as externalized or not.
124 * 18 3/11/98 5:02p Dave
125 * Put in code to support new medals artwork. Assorted multiplayer bug
128 * 17 3/07/98 5:44p Dave
129 * Finished player info popup. Ironed out a few todo bugs.
131 * 16 3/05/98 5:11p Allender
132 * fix up medals screen (again). Don't do state transition when viewing
133 * medals from debriefing screen.
135 * 15 3/05/98 2:32p Hoffoss
136 * Renamed Rank_bitmap to Rank_bm so it isn't named the same as the
137 * variable in the debrief screen which confuses the debugger.
139 * 14 2/22/98 2:48p John
140 * More String Externalization Classification
142 * 13 2/09/98 5:21p Hoffoss
143 * Made exit from medals screen to previous screen (instead of assuming
144 * it's the barracks) work.
146 * 12 1/27/98 4:23p Allender
147 * enhanced internal scoring mechanisms.
149 * 11 11/12/97 4:40p Dave
150 * Put in multiplayer campaign support parsing, loading and saving. Made
151 * command-line variables better named. Changed some things on the initial
152 * pilot select screen.
154 * 10 11/12/97 9:30a Dave
155 * Fixed rank insignia tooltip not showing up.
157 * 9 11/06/97 4:39p Allender
158 * a ton of medal work. Removed an uneeded elemen in the scoring
159 * structure. Fix up medals screen to apprioriate display medals (after
160 * mask was changed). Fix Fred to only display medals which may actually
161 * be granted. Added image_filename to player struct for Jason Hoffoss
163 * 8 11/05/97 4:43p Allender
164 * reworked medal/rank system to read all data from tables. Made Fred
165 * read medals.tbl. Changed ai-warp to ai-warp-out which doesn't require
166 * waypoint for activation
174 #include "snazzyui.h"
176 #include "gamesequence.h"
177 #include "animplay.h"
179 #include "freespace.h"
187 #include "alphacolors.h"
188 #include "localize.h"
189 #include "missionscreencommon.h" // for common_set_interface_palette
191 //#define MAX_MEDAL_TYPES 63 // the # of medals which exist so far
194 #define CALLSIGN_X 198
195 #define CALLSIGN_Y 80
196 #define CALLSIGN_W (439-CALLSIGN_X)
197 #define CALLSIGN_H (116-CALLSIGN_Y)
200 // define for the medal information
201 medal_stuff Medals[NUM_MEDALS];
202 badge_stuff Badge_info[MAX_BADGES];
204 // holds indices into Medals array of the badges for # kills
205 int Badge_index[MAX_BADGES];
207 // the rank section of the screen
209 // not in Medal_coords but needs to be set
210 // to not interfere with other medals
211 #define RANK_MEDAL_REGION 16 // region number of the rank medal
213 #define RANK_MEDAL_REGION 12 // region number of the rank medal
216 #warning Find real FS2_DEMO spot for medals
217 // coords for indiv medal bitmaps
218 int Medal_coords[GR_NUM_RESOLUTIONS][NUM_MEDALS][2] = {
221 { 108, 74 }, // Conspicuous Gallantry
222 { 473, 73 }, // Vasudan Alliance
223 { 146, 150 }, // Distinguished Flying Cross
224 { 219, 152 }, // Commendation Medal
225 { 360, 150 }, // Galatea Survivor
226 { 432, 150 }, // Legion of Merit
227 { 88, 243 }, // Meritorious Unit
228 { 168, 243 }, // Medal of Honor
229 { 248, 250 }, // Galactic Service
230 { 328, 250 }, // Military Defense
231 { 406, 244 }, // Good Conduct
232 { 483, 243 }, // Distinguished Service Cross
234 { 373, 109 }, // Double Ace
236 { 403, 109 }, // Triple Ace
238 { 287, 186 }, // Wings
240 { 89, 47 }, // eps. peg. lib
241 { 486, 47 }, // imp. order o' vasuda
242 { 129, 130 }, // dist flying cross
243 { 208, 132 }, // soc service
244 { 361, 131 }, // dist intel cross
245 { 439, 130 }, // order of galatea
246 { 64, 234 }, // meritorious unit comm.
247 { 153, 234 }, // medal of valor
248 { 239, 241 }, // gtva leg of honor
249 { 326, 240 }, // allied defense citation
250 { 411, 234 }, // neb campaign victory
251 { 494, 234 }, // ntf campaign victory
253 { 283, 91 }, // wings
254 { 372, 76 }, // bronze kills badge
255 { 403, 76 }, // silver kills badge
257 { 435, 76 }, // gold kills badge
258 { 300, 152 }, // SOC unit crest
263 { 143, 75 }, // eps. peg. lib
264 { 777, 75 }, // imp. order o' vasuda
265 { 206, 208 }, // dist flying cross
266 { 333, 212 }, // soc service
267 { 578, 210 }, // dist intel cross
268 { 703, 208 }, // order of galatea
269 { 103, 374 }, // meritorious unit comm.
270 { 245, 374 }, // medal of valor
271 { 383, 386 }, // gtva leg of honor
272 { 522, 384 }, // allied defense citation
273 { 658, 374 }, // neb campaign victory
274 { 790, 374 }, // ntf campaign victory
275 { 302, 128 }, // rank
276 { 453, 146 }, // wings
277 { 595, 121 }, // bronze kills badge
278 { 646, 121 }, // silver kills badge
279 #if !(defined(FS2_DEMO) || defined(MAKE_FS1))
280 { 696, 121 }, // gold kills badge
281 { 480, 244 }, // SOC unit crest
287 // coords for the medal/rank title
288 static int Rank_label_coords[2] = {
292 static int Rank_coords[2] = {
296 // I couldn't think of a better way to do this so define
297 // the base center point for each medal to center the label on
299 // x = the horizontal center point of the bitmap
300 // y = the base of the medal bitmap itself
301 static int Medals_label_coords[NUM_MEDALS][2] = {
303 { 137, 158 }, // Conspicuous Gallantry
304 { 502, 154 }, // Vasudan Alliance
305 { 176, 238 }, // Distinguished Flying Cross
306 { 249, 244 }, // Commendation Medal
307 { 390, 238 }, // Galatea Survivor
308 { 462, 237 }, // Legion of Merit
309 { 121, 345 }, // Meritorious Unit
310 { 199, 346 }, // Medal of Honor
311 { 280, 349 }, // Galactic Service
312 { 360, 350 }, // Military Defense
313 { 438, 349 }, // Good Conduct
314 { 517, 353 }, // Distinguished Service Cross
316 { 385, 129 }, // Double Ace
318 { 415, 129 }, // Triple Ace
320 { 319, 216 }, // Wings
323 // coords for the medal title
324 static int Medals_label_coords[GR_NUM_RESOLUTIONS][3] = {
325 { 241, 458, 300 }, // GR_640 x, y, w
326 { 386, 734, 480 } // GR_1024 x, y, w
330 #define MEDALS_NUM_BUTTONS 1
331 #define MEDALS_EXIT 0
332 ui_button_info Medals_buttons[GR_NUM_RESOLUTIONS][MEDALS_NUM_BUTTONS] = {
335 ui_button_info("MX_17", 561, 411, -1, -1, 17),
337 ui_button_info("MEB_18", 574, 432, -1, -1, 18),
341 ui_button_info("2_MEB_18", 919, 691, -1, -1, 18),
346 #define MEDALS_NUM_TEXT 0
348 #define MEDALS_NUM_TEXT 1
350 UI_XSTR Medals_text[GR_NUM_RESOLUTIONS][MEDALS_NUM_TEXT] = {
352 // not needed for FS1
354 {"Exit", 1466, 587, 416, UI_XSTR_COLOR_PINK, -1, &Medals_buttons[GR_640][MEDALS_EXIT].button },
358 // not needed for FS1
360 {"Exit", 1466, 943, 673, UI_XSTR_COLOR_PINK, -1, &Medals_buttons[GR_1024][MEDALS_EXIT].button },
365 static char* Medals_background_filename[GR_NUM_RESOLUTIONS] = {
366 "MedalsDisplayEmpty",
367 "2_MedalsDisplayEmpty"
370 static char* Medals_mask_filename[GR_NUM_RESOLUTIONS] = {
375 static int Medals_callsign_y[GR_NUM_RESOLUTIONS] = {
383 scoring_struct *Player_score=NULL;
386 player *Medals_player;
388 // -----------------------------------------------------------------------------
389 // Main medals screen state
391 #define NUM_MEDAL_REGIONS NUM_MEDALS + 1 // the extra one is for the rank medal
393 static bitmap *Medals_mask;
394 int Medals_mask_w, Medals_mask_h;
395 static int Medal_palette; // Medal palette bitmap
396 static int Medals_bitmap_mask; // the mask for the medal case
397 static int Medals_bitmap; // the medal case itself
398 static int Medal_bitmaps[NUM_MEDALS]; // bitmaps for the individual medals
399 static int Rank_bm; // bitmap for the rank medal
401 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
403 static UI_WINDOW Medals_window;
405 //#define MAX_MEDALS_BUTTONS 1
406 //#define MEDAL_BUTTON_EXIT 0
407 //static UI_BUTTON Medal_buttons[MAX_MEDALS_BUTTONS];
409 /*static char *Medal_button_names[MAX_MEDALS_BUTTONS] = {
416 static int Medal_button_coords[MAX_MEDALS_BUTTONS][2] = {
419 static int Medal_button_masks[MAX_MEDALS_BUTTONS] = {
425 #define MEDAL_BITMAP_INIT (1<<0)
426 #define MASK_BITMAP_INIT (1<<1)
429 void parse_medal_tbl()
431 int rval, num_medals, i, bi;
433 if ((rval = setjmp(parse_abort)) != 0) {
434 Error(LOCATION, "Error parsing 'medals.tbl'\r\nError code = %i.\r\n", rval);
440 read_file_text("medals.tbl");
444 // parse in all the rank names
447 required_string("#Medals");
448 while ( required_string_either("#End", "$Name:") ) {
449 Assert ( num_medals < NUM_MEDALS);
450 required_string("$Name:");
451 stuff_string( Medals[num_medals].name, F_NAME, NULL );
452 required_string("$Bitmap:");
453 stuff_string( Medals[num_medals].bitmap, F_NAME, NULL );
454 required_string("$Num mods:");
455 stuff_int( &Medals[num_medals].num_versions);
457 // some medals are based on kill counts. When string +Num Kills: is present, we know that
458 // this medal is a badge and should be treated specially
459 Medals[num_medals].kills_needed = 0;
460 if ( optional_string("+Num Kills:") ) {
461 char buf[MULTITEXT_LENGTH + 1];
463 Assert( bi < MAX_BADGES );
464 stuff_int( &Medals[num_medals].kills_needed );
465 Badge_index[bi] = num_medals;
467 required_string("$Wavefile 1:");
468 stuff_string(Badge_info[bi].voice_base, F_NAME, NULL, MAX_FILENAME_LEN);
469 required_string("$Wavefile 2:");
470 stuff_string(Badge_info[bi].voice_base2, F_NAME, NULL, MAX_FILENAME_LEN);
472 #warning FS2_DEMO HACK: Wavefile 1/2: wave1? wave2?
473 required_string("$Wavefile 1:");
474 stuff_string(Badge_info[bi].voice_base, F_NAME, NULL, MAX_FILENAME_LEN);
475 required_string("$Wavefile 2:");
476 stuff_string(Badge_info[bi].voice_base, F_NAME, NULL, MAX_FILENAME_LEN);
477 //stuff_string(Badge_info[bi].wave2, F_NAME, NULL, MAX_FILENAME_LEN);
479 required_string("$Wavefile Base:");
480 stuff_string(Badge_info[bi].voice_base, F_NAME, NULL, MAX_FILENAME_LEN);
483 required_string("$Promotion Text:");
484 stuff_string(buf, F_MULTITEXT, NULL);
485 Badge_info[bi].promotion_text = strdup(buf);
493 required_string("#End");
494 Assert( num_medals == NUM_MEDALS );
496 // be sure that the badges kill numbers show up in order
497 for (i = 0; i < MAX_BADGES-1; i++ ) {
498 if ( Medals[Badge_index[i]].kills_needed >= Medals[Badge_index[i+1]].kills_needed ){
499 Error(LOCATION, "Badges must appear sorted by lowest kill # first in medals.tbl\nFind Allender for most information.");
503 // close localization
507 void medal_main_init(player *pl, int mode)
514 Player_score = &Medals_player->stats;
517 if(Cmdline_gimme_all_medals){
519 for(idx=0; idx < NUM_MEDALS; idx++){
520 Medals_player->stats.medals[idx] = 1;
528 Medals_window.create( 0, 0, gr_screen.max_w, gr_screen.max_h, 0 );
530 // create the interface buttons
531 for (idx=0; idx<MEDALS_NUM_BUTTONS; idx++) {
533 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);
535 // set the sound to play when highlighted
536 Medals_buttons[gr_screen.res][idx].button.set_highlight_action(common_play_highlight_sound);
538 // set the ani for the button
539 Medals_buttons[gr_screen.res][idx].button.set_bmaps(Medals_buttons[gr_screen.res][idx].filename);
542 Medals_buttons[gr_screen.res][idx].button.link_hotspot(Medals_buttons[gr_screen.res][idx].hotspot);
546 for (idx=0; idx<MEDALS_NUM_TEXT; idx++) {
547 Medals_window.add_XSTR(&Medals_text[gr_screen.res][idx]);
553 //init_medal_palette();
555 common_set_interface_palette("MedalsPalette");
558 Medals_bitmap = bm_load(Medals_background_filename[gr_screen.res]);
559 if (Medals_bitmap < 0) {
560 Error(LOCATION, "Error loading medal background bitmap %s", Medals_background_filename[gr_screen.res]);
562 Init_flags |= MEDAL_BITMAP_INIT;
568 Medals_bitmap_mask = bm_load(Medals_mask_filename[gr_screen.res]);
569 if(Medals_bitmap_mask < 0){
570 Error(LOCATION, "Error loading medal mask file %s", Medals_mask_filename[gr_screen.res]);
572 Init_flags |= MASK_BITMAP_INIT;
573 Medals_mask = bm_lock(Medals_bitmap_mask, 8, BMP_AABITMAP);
574 bm_get_info(Medals_bitmap_mask, &Medals_mask_w, &Medals_mask_h);
576 init_medal_bitmaps();
577 init_snazzy_regions();
579 gr_set_color_fast(&Color_normal);
581 Medals_window.set_mask_bmap(Medals_mask_filename[gr_screen.res]);
584 // this is just a hack to display translated names without actually changing the names,
585 // which would break stuff
586 void medals_translate_name(char *name, int max_len)
589 if (!strcmp(name, "Conspicuous Gallantry")) {
590 strncpy(name, "Tapferkeitsmedaille", max_len);
592 } else if (!strcmp(name, "Vasudan Alliance")) {
593 strncpy(name, "Vasudanischen Allianz", max_len);
595 } else if (!strcmp(name, "Distinguished Flying Cross")) {
596 strncpy(name, "Kreuz f\x81r Fliegerleistungen", max_len);
598 } else if (!strcmp(name, "Commendation Medal")) {
599 strncpy(name, "Anerkennungsmedaille", max_len);
601 } else if (!strcmp(name, "Galatea Survivor")) {
602 strncpy(name, "Galatea-\x9A""berlebender", max_len);
604 } else if (!strcmp(name, "Legion of Merit")) {
605 strncpy(name, "Verdienstlegion", max_len);
607 } else if (!strcmp(name, "Meritorious Unit")) {
608 strncpy(name, "Verdienstmedaille", max_len);
610 } else if (!strcmp(name, "Medal of Honor")) {
611 strncpy(name, "Ehrenmedaille", max_len);
613 } else if (!strcmp(name, "Galactic Service")) {
614 strncpy(name, "Galaktischer Dienst", max_len);
616 } else if (!strcmp(name, "Military Defense")) {
617 strncpy(name, "Verteidigungsmedaille", max_len);
619 } else if (!strcmp(name, "Good Conduct")) {
620 strncpy(name, "Medaille f\x81r gute F\x81hrung", max_len);
622 } else if (!strcmp(name, "Distinguished Service Cross")) {
623 strncpy(name, "Kreuz f\x81r Einsatz", max_len);
625 } else if (!strcmp(name, "Ace")) {
626 strncpy(name, "Bronzener Stern", max_len);
628 } else if (!strcmp(name, "Double Ace")) {
629 strncpy(name, "Silberner Stern", max_len);
631 } else if (!strcmp(name, "Triple Ace")) {
632 strncpy(name, "Goldener Stern", max_len);
634 } else if (!strcmp(name, "Wings")) {
635 strncpy(name, "Pilotenabzeichen", max_len);
637 } else if (!strcmp(name, "Rank")) {
638 strncpy(name, "Dienstgrad", max_len);
641 if (!strcmp(name, "Epsilon Pegasi Liberation")) {
642 strncpy(name, "Epsilon Pegasi Befreiungsmedaille", max_len);
644 } else if (!strcmp(name, "Imperial Order of Vasuda")) {
645 strncpy(name, "Imperialer Orden von Vasuda ", max_len);
647 } else if (!strcmp(name, "Distinguished Flying Cross")) {
648 strncpy(name, "Fliegerkreuz Erster Klasse", max_len);
650 } else if (!strcmp(name, "SOC Service Medallion")) {
651 strncpy(name, "SEK-Dienstmedaille ", max_len);
653 } else if (!strcmp(name, "Intelligence Cross")) {
654 strncpy(name, "Geheimdienstkreuz am Bande", max_len);
656 } else if (!strcmp(name, "Order of Galatea")) {
657 strncpy(name, "Orden von Galatea ", max_len);
659 } else if (!strcmp(name, "Meritorious Unit Commendation")) {
660 strncpy(name, "Ehrenspange der Allianz", max_len);
662 } else if (!strcmp(name, "Medal of Valor")) {
663 strncpy(name, "Tapferkeitsmedaille ", max_len);
665 } else if (!strcmp(name, "GTVA Legion of Honor")) {
666 strncpy(name, "Orden der GTVA-Ehrenlegion", max_len);
668 } else if (!strcmp(name, "Allied Defense Citation")) {
669 strncpy(name, "Alliierte Abwehrspange ", max_len);
671 } else if (!strcmp(name, "Nebula Campaign Victory Star")) {
672 strncpy(name, "Nebel-Siegesstern", max_len);
674 } else if (!strcmp(name, "NTF Campaign Victory Star")) {
675 strncpy(name, "NTF-Siegesstern ", max_len);
677 } else if (!strcmp(name, "Rank")) {
678 strncpy(name, "Dienstgrad", max_len);
680 } else if (!strcmp(name, "Wings")) {
681 strncpy(name, "Fliegerspange", max_len);
683 } else if (!strcmp(name, "Ace")) {
684 strncpy(name, "Flieger-As", max_len);
686 } else if (!strcmp(name, "Double Ace")) {
687 strncpy(name, "Doppel-As ", max_len);
689 } else if (!strcmp(name, "Triple Ace")) {
690 strncpy(name, "Dreifach-As ", max_len);
692 } else if (!strcmp(name, "SOC Unit Crest")) {
693 strncpy(name, "SEK-Abzeichen ", max_len);
698 // this is just a hack to display translated names without actually changing the names,
699 // which would break stuff
700 void medals_translate_name_pl(char *name, int max_len)
702 if (!strcmp(name, "Epsilon Pegasi Liberation")) {
703 strncpy(name, "Order Wyzwolenia Epsilon Pegasi", max_len);
705 } else if (!strcmp(name, "Imperial Order of Vasuda")) {
706 strncpy(name, "Imperialny Order Vasudy", max_len);
708 } else if (!strcmp(name, "Distinguished Flying Cross")) {
709 strncpy(name, "Krzy\xBF Wybitnego Pilota", max_len);
711 } else if (!strcmp(name, "SOC Service Medallion")) {
712 strncpy(name, "Krzy\xBF S\xB3u\xBF\x62 Specjalnych", max_len);
714 } else if (!strcmp(name, "Intelligence Cross")) {
715 strncpy(name, "Krzy\xBF Wywiadu", max_len);
717 } else if (!strcmp(name, "Order of Galatea")) {
718 strncpy(name, "Order Galatei", max_len);
720 } else if (!strcmp(name, "Meritorious Unit Commendation")) {
721 strncpy(name, "Medal Pochwalny", max_len);
723 } else if (!strcmp(name, "Medal of Valor")) {
724 strncpy(name, "Medal za Odwag\xEA", max_len);
726 } else if (!strcmp(name, "GTVA Legion of Honor")) {
727 strncpy(name, "Legia Honorowa GTVA", max_len);
729 } else if (!strcmp(name, "Allied Defense Citation")) {
730 strncpy(name, "Order za Obron\xEA Sojuszu", max_len);
732 } else if (!strcmp(name, "Nebula Campaign Victory Star")) {
733 strncpy(name, "Gwiazda Wiktorii Kampanii w Mg\xB3\x61wicy", max_len);
735 } else if (!strcmp(name, "NTF Campaign Victory Star")) {
736 strncpy(name, "Gwiazda Wiktorii Kampanii NTF", max_len);
738 } else if (!strcmp(name, "Rank")) {
739 strncpy(name, "Ranga", max_len);
741 } else if (!strcmp(name, "Wings")) {
742 strncpy(name, "Skrzyd\xB3\x61", max_len);
744 } else if (!strcmp(name, "Ace")) {
745 strncpy(name, "As", max_len);
747 } else if (!strcmp(name, "Double Ace")) {
748 strncpy(name, "Podw\xF3jny As", max_len);
750 } else if (!strcmp(name, "Triple Ace")) {
751 strncpy(name, "Potr\xF3jny As", max_len);
753 } else if (!strcmp(name, "SOC Unit Crest")) {
754 strncpy(name, "Tarcza S\xB3u\xBF\x62 Specjalnych", max_len);
759 void blit_label(char *label, int *coordsx, int *coordsy, int num)
761 void blit_label(char *label, int *coords, int num)
767 gr_set_color_fast(&Color_bright);
769 // translate medal names before displaying
770 // cant translate in table cuz the names are used in comparisons
772 char translated_label[256];
773 strncpy(translated_label, label, 256);
774 medals_translate_name(translated_label, 256);
776 // set correct string
778 sprintf( text, NOX("%s (%d)"), translated_label, num );
780 sprintf( text, "%s", translated_label );
783 char translated_label[256];
784 strncpy(translated_label, label, 256);
785 medals_translate_name_pl(translated_label, 256);
787 // set correct string
789 sprintf( text, NOX("%s (%d)"), translated_label, num );
791 sprintf( text, "%s", translated_label );
794 // set correct string
796 sprintf( text, NOX("%s (%d)"), label, num );
798 sprintf( text, "%s", label );
802 // find correct coords
803 gr_get_string_size(&sw, NULL, text);
805 x = *coordsx - sw / 2;
808 x = Medals_label_coords[gr_screen.res][0] + (Medals_label_coords[gr_screen.res][2] - sw) / 2;
809 y = Medals_label_coords[gr_screen.res][1];
813 gr_string(x, y, text);
819 gr_set_color_fast(&Color_bright_blue);
821 gr_set_color_fast(&Color_normal);
824 // nothing special, just do it.
825 gr_string(0x8000, Medals_callsign_y[gr_screen.res], Medals_player->callsign);
830 int region,selected, k;
832 k = Medals_window.process();
834 // process an exit command
835 if ((k == KEY_ESC) && (Medals_mode == MM_NORMAL)) {
836 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
839 // draw the background medal display case
841 GR_MAYBE_CLEAR_RES(Medals_bitmap);
842 if(Medals_bitmap != -1){
843 gr_set_bitmap(Medals_bitmap);
847 // check to see if a button was pressed
848 if( (k == (KEY_CTRLED|KEY_ENTER)) || (Medals_buttons[gr_screen.res][MEDALS_EXIT].button.pressed()) ) {
849 gamesnd_play_iface(SND_COMMIT_PRESSED);
850 if(Medals_mode == MM_NORMAL){
851 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
853 // any calling popup function will know to close the screen down
858 // blit medals also takes care of blitting the rank insignia
862 region = snazzy_menu_do((ubyte*)Medals_mask->data, Medals_mask_w, Medals_mask_h, NUM_MEDAL_REGIONS, Medal_regions, &selected);
865 if (Medals_mode == MM_NORMAL) {
866 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
868 // any calling popup function will know to close the screen down
873 case RANK_MEDAL_REGION :
875 blit_label(Ranks[Player_score->rank].name, &Rank_label_coords[0], &Rank_label_coords[1], 1);
877 blit_label(Ranks[Player_score->rank].name, &Medal_coords[gr_screen.res][region][0], 1);
885 if (Player_score->medals[region] > 0){
887 blit_label(Medals[region].name, &Medals_label_coords[region][0], &Medals_label_coords[region][1], Player_score->medals[region] );
889 blit_label(Medals[region].name, &Medal_coords[gr_screen.res][region][0], Player_score->medals[region] );
895 Medals_window.draw();
902 void medal_main_close()
905 if (Init_flags & MEDAL_BITMAP_INIT)
906 bm_unload(Medals_bitmap);
908 if (Init_flags & MASK_BITMAP_INIT) {
909 bm_unlock(Medals_bitmap_mask);
910 bm_unload(Medals_bitmap_mask);
913 for (idx=0; idx < NUM_MEDALS; idx++) {
914 if (Medal_bitmaps[idx] > -1){
915 bm_unload(Medal_bitmaps[idx]);
920 Medals_window.destroy();
923 common_free_interface_palette();
927 palette_restore_palette();
930 // free up memory from table parsing
931 void medal_tbl_close()
935 for (i=0; i<MAX_BADGES; i++) {
936 if (Badge_info[i].promotion_text) {
937 free(Badge_info[i].promotion_text);
938 Badge_info[i].promotion_text = NULL;
944 void init_medal_palette()
946 Medal_palette = bm_load("MedalsPalette.pcx");
947 if(Medal_palette > -1){
948 #ifndef HARDWARE_ONLY
949 palette_use_bm_palette(Medal_palette);
955 // function to load in the medals for this player. It loads medals that the player has (known
956 // by whether or not a non-zero number is present in the player's medal array), then loads the
959 void init_medal_bitmaps()
962 Assert(Player_score);
964 for (idx=0; idx<NUM_MEDALS; idx++) {
965 Medal_bitmaps[idx] = -1;
966 if (Player_score->medals[idx] > 0) {
968 char filename[NAME_LENGTH], base[NAME_LENGTH];
970 // possibly load a different filename that is specified by the bitmap filename
971 // for this medal. if the player has > 1 of these types of medals, then determien
972 // which of the possible version to use based on the player's count of this medal
973 strcpy( filename, Medals[idx].bitmap );
975 _splitpath( filename, NULL, NULL, base, NULL );
977 num_medals = Player_score->medals[idx];
979 // can't display more than the maximum number of version for this medal
980 if ( num_medals > Medals[idx].num_versions )
981 num_medals = Medals[idx].num_versions;
983 if ( num_medals > 1 ) {
984 // append the proper character onto the end of the medal filename. Base version
985 // has no character. next version is a, then b, etc.
986 sprintf( base, "%s%c", base, (num_medals-2)+'a');
990 if (gr_screen.res == GR_1024) {
991 sprintf( filename, "2_%s", base );
994 // base now contains the actual medal bitmap filename needed to load
995 // we don't need to pass extension to bm_load anymore, so just use the basename
997 Medal_bitmaps[idx] = bm_load( filename );
998 Assert( Medal_bitmaps[idx] != -1 );
1002 // load up rank insignia
1003 if (gr_screen.res == GR_1024) {
1004 char filename[NAME_LENGTH];
1005 sprintf(filename, "2_%s", Ranks[Player_score->rank].bitmap);
1006 Rank_bm = bm_load(filename);
1008 Rank_bm = bm_load(Ranks[Player_score->rank].bitmap);
1012 void init_snazzy_regions()
1016 // snazzy regions for the medals/ranks, etc.
1017 for (idx=0; idx<NUM_MEDALS; idx++) {
1018 if (idx == RANK_MEDAL_REGION)
1021 snazzy_menu_add_region(&Medal_regions[idx], "", idx, 0);
1024 // add the rank medal region
1025 snazzy_menu_add_region(&Medal_regions[RANK_MEDAL_REGION], "", RANK_MEDAL_REGION,0);
1029 // blit the medals -- this includes the rank insignia
1034 for (idx=0; idx<NUM_MEDALS; idx++) {
1035 if (Player_score->medals[idx] > 0) {
1036 gr_set_bitmap(Medal_bitmaps[idx]);
1037 gr_bitmap(Medal_coords[gr_screen.res][idx][0], Medal_coords[gr_screen.res][idx][1]);
1041 // now blit rank, since that "medal" doesnt get loaded (or drawn) the normal way
1042 gr_set_bitmap(Rank_bm);
1044 gr_bitmap(Rank_coords[0], Rank_coords[1]);
1046 gr_bitmap(Medal_coords[gr_screen.res][RANK_MEDAL_REGION][0], Medal_coords[gr_screen.res][RANK_MEDAL_REGION][1]);