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.9 2003/06/03 04:00:40 taylor
17 * Polish language support (Janusz Dziemidowicz)
19 * Revision 1.8 2003/05/25 02:30:44 taylor
22 * Revision 1.7 2002/06/09 04:41:27 relnev
23 * added copyright header
25 * Revision 1.6 2002/06/09 03:16:05 relnev
28 * removed unneeded asm, old sdl 2d setup.
30 * fixed crash caused by opengl_get_region.
32 * Revision 1.5 2002/05/28 08:52:03 relnev
33 * implemented two assembly stubs.
35 * cleaned up a few warnings.
37 * added a little demo hackery to make it progress a little farther.
39 * Revision 1.4 2002/05/28 04:56:51 theoddone33
40 * runs a little bit now
42 * Revision 1.3 2002/05/26 20:22:48 theoddone33
43 * Most of network/ works
45 * Revision 1.2 2002/05/04 04:36:56 theoddone33
46 * More changes, took out a lot of the sound stuff which will bite later but
49 * Revision 1.1.1.1 2002/05/03 03:28:11 root
53 * 12 10/29/99 10:40p Jefff
54 * hack to make german medal names display without actually changing them
56 * 11 9/02/99 3:41p Jefff
57 * changed badge voice handling to be similar to promotion voice handling
59 * 10 8/26/99 8:49p Jefff
60 * Updated medals screen and about everything that ever touches medals in
61 * one way or another. Sheesh.
63 * 9 7/16/99 1:50p Dave
64 * 8 bit aabitmaps. yay.
66 * 8 3/19/99 9:51a Dave
67 * Checkin to repair massive source safe crash. Also added support for
68 * pof-style nebulae, and some new weapons code.
70 * 8 3/15/99 10:29a Neilk
72 * 7 1/30/99 5:08p Dave
73 * More new hi-res stuff.Support for nice D3D textures.
75 * 6 12/18/98 1:13a Dave
76 * Rough 1024x768 support for Direct3D. Proper detection and usage through
79 * 5 11/30/98 1:07p Dave
80 * 16 bit conversion, first run.
82 * 4 10/23/98 3:51p Dave
83 * Full support for tstrings.tbl and foreign languages. All that remains
84 * is to make it active in Fred.
86 * 3 10/13/98 9:29a Dave
87 * Started neatening up freespace.h. Many variables renamed and
88 * reorganized. Added AlphaColors.[h,cpp]
90 * 2 10/07/98 10:54a Dave
93 * 1 10/07/98 10:51a Dave
95 * 26 6/13/98 3:18p Hoffoss
96 * NOX()ed out a bunch of strings that shouldn't be translated.
98 * 25 6/01/98 11:43a John
99 * JAS & MK: Classified all strings for localization.
101 * 24 5/01/98 12:34p John
102 * Added code to force FreeSpace to run in the same dir as exe and made
103 * all the parse error messages a little nicer.
105 * 23 4/27/98 3:13p Allender
106 * make ctrl-enter work on medals screen
108 * 22 4/23/98 8:27p Allender
109 * basic support for cutscene playback. Into movie code in place. Tech
110 * room can view cutscenes stored in CDROM_dir variable
112 * 21 4/12/98 8:30p Allender
113 * minor medal changes to show number of medals if > 1
115 * 20 4/10/98 4:51p Hoffoss
116 * Made several changes related to tooltips.
118 * 19 3/18/98 12:03p John
119 * Marked all the new strings as externalized or not.
121 * 18 3/11/98 5:02p Dave
122 * Put in code to support new medals artwork. Assorted multiplayer bug
125 * 17 3/07/98 5:44p Dave
126 * Finished player info popup. Ironed out a few todo bugs.
128 * 16 3/05/98 5:11p Allender
129 * fix up medals screen (again). Don't do state transition when viewing
130 * medals from debriefing screen.
132 * 15 3/05/98 2:32p Hoffoss
133 * Renamed Rank_bitmap to Rank_bm so it isn't named the same as the
134 * variable in the debrief screen which confuses the debugger.
136 * 14 2/22/98 2:48p John
137 * More String Externalization Classification
139 * 13 2/09/98 5:21p Hoffoss
140 * Made exit from medals screen to previous screen (instead of assuming
141 * it's the barracks) work.
143 * 12 1/27/98 4:23p Allender
144 * enhanced internal scoring mechanisms.
146 * 11 11/12/97 4:40p Dave
147 * Put in multiplayer campaign support parsing, loading and saving. Made
148 * command-line variables better named. Changed some things on the initial
149 * pilot select screen.
151 * 10 11/12/97 9:30a Dave
152 * Fixed rank insignia tooltip not showing up.
154 * 9 11/06/97 4:39p Allender
155 * a ton of medal work. Removed an uneeded elemen in the scoring
156 * structure. Fix up medals screen to apprioriate display medals (after
157 * mask was changed). Fix Fred to only display medals which may actually
158 * be granted. Added image_filename to player struct for Jason Hoffoss
160 * 8 11/05/97 4:43p Allender
161 * reworked medal/rank system to read all data from tables. Made Fred
162 * read medals.tbl. Changed ai-warp to ai-warp-out which doesn't require
163 * waypoint for activation
171 #include "snazzyui.h"
173 #include "gamesequence.h"
174 #include "animplay.h"
176 #include "freespace.h"
184 #include "alphacolors.h"
185 #include "localize.h"
186 #include "missionscreencommon.h" // for common_set_interface_palette
188 //#define MAX_MEDAL_TYPES 63 // the # of medals which exist so far
191 #define CALLSIGN_X 198
192 #define CALLSIGN_Y 80
193 #define CALLSIGN_W (439-CALLSIGN_X)
194 #define CALLSIGN_H (116-CALLSIGN_Y)
197 // define for the medal information
198 medal_stuff Medals[NUM_MEDALS];
199 badge_stuff Badge_info[MAX_BADGES];
201 // holds indices into Medals array of the badges for # kills
202 int Badge_index[MAX_BADGES];
204 // the rank section of the screen
206 // not in Medal_coords but needs to be set
207 // to not interfere with other medals
208 #define RANK_MEDAL_REGION 16 // region number of the rank medal
210 #define RANK_MEDAL_REGION 12 // region number of the rank medal
213 #warning Find real FS2_DEMO spot for medals
214 // coords for indiv medal bitmaps
215 int Medal_coords[GR_NUM_RESOLUTIONS][NUM_MEDALS][2] = {
218 { 108, 74 }, // Conspicuous Gallantry
219 { 473, 73 }, // Vasudan Alliance
220 { 146, 150 }, // Distinguished Flying Cross
221 { 219, 152 }, // Commendation Medal
222 { 360, 150 }, // Galatea Survivor
223 { 432, 150 }, // Legion of Merit
224 { 88, 243 }, // Meritorious Unit
225 { 168, 243 }, // Medal of Honor
226 { 248, 250 }, // Galactic Service
227 { 328, 250 }, // Military Defense
228 { 406, 244 }, // Good Conduct
229 { 483, 243 }, // Distinguished Service Cross
231 { 373, 109 }, // Double Ace
233 { 403, 109 }, // Triple Ace
235 { 287, 186 }, // Wings
237 { 89, 47 }, // eps. peg. lib
238 { 486, 47 }, // imp. order o' vasuda
239 { 129, 130 }, // dist flying cross
240 { 208, 132 }, // soc service
241 { 361, 131 }, // dist intel cross
242 { 439, 130 }, // order of galatea
243 { 64, 234 }, // meritorious unit comm.
244 { 153, 234 }, // medal of valor
245 { 239, 241 }, // gtva leg of honor
246 { 326, 240 }, // allied defense citation
247 { 411, 234 }, // neb campaign victory
248 { 494, 234 }, // ntf campaign victory
250 { 283, 91 }, // wings
251 { 372, 76 }, // bronze kills badge
252 { 403, 76 }, // silver kills badge
254 { 435, 76 }, // gold kills badge
255 { 300, 152 }, // SOC unit crest
260 { 143, 75 }, // eps. peg. lib
261 { 777, 75 }, // imp. order o' vasuda
262 { 206, 208 }, // dist flying cross
263 { 333, 212 }, // soc service
264 { 578, 210 }, // dist intel cross
265 { 703, 208 }, // order of galatea
266 { 103, 374 }, // meritorious unit comm.
267 { 245, 374 }, // medal of valor
268 { 383, 386 }, // gtva leg of honor
269 { 522, 384 }, // allied defense citation
270 { 658, 374 }, // neb campaign victory
271 { 790, 374 }, // ntf campaign victory
272 { 302, 128 }, // rank
273 { 453, 146 }, // wings
274 { 595, 121 }, // bronze kills badge
275 { 646, 121 }, // silver kills badge
276 #if !(defined(FS2_DEMO) || defined(MAKE_FS1))
277 { 696, 121 }, // gold kills badge
278 { 480, 244 }, // SOC unit crest
284 // coords for the medal/rank title
285 static int Rank_label_coords[2] = {
289 static int Rank_coords[2] = {
293 // I couldn't think of a better way to do this so define
294 // the base center point for each medal to center the label on
296 // x = the horizontal center point of the bitmap
297 // y = the base of the medal bitmap itself
298 static int Medals_label_coords[NUM_MEDALS][2] = {
300 { 137, 158 }, // Conspicuous Gallantry
301 { 502, 154 }, // Vasudan Alliance
302 { 176, 238 }, // Distinguished Flying Cross
303 { 249, 244 }, // Commendation Medal
304 { 390, 238 }, // Galatea Survivor
305 { 462, 237 }, // Legion of Merit
306 { 121, 345 }, // Meritorious Unit
307 { 199, 346 }, // Medal of Honor
308 { 280, 349 }, // Galactic Service
309 { 360, 350 }, // Military Defense
310 { 438, 349 }, // Good Conduct
311 { 517, 353 }, // Distinguished Service Cross
313 { 385, 129 }, // Double Ace
315 { 415, 129 }, // Triple Ace
317 { 319, 216 }, // Wings
320 // coords for the medal title
321 static int Medals_label_coords[GR_NUM_RESOLUTIONS][3] = {
322 { 241, 458, 300 }, // GR_640 x, y, w
323 { 386, 734, 480 } // GR_1024 x, y, w
327 #define MEDALS_NUM_BUTTONS 1
328 #define MEDALS_EXIT 0
329 ui_button_info Medals_buttons[GR_NUM_RESOLUTIONS][MEDALS_NUM_BUTTONS] = {
332 ui_button_info("MX_17", 561, 411, -1, -1, 17),
334 ui_button_info("MEB_18", 574, 432, -1, -1, 18),
338 ui_button_info("2_MEB_18", 919, 691, -1, -1, 18),
343 #define MEDALS_NUM_TEXT 0
345 #define MEDALS_NUM_TEXT 1
347 UI_XSTR Medals_text[GR_NUM_RESOLUTIONS][MEDALS_NUM_TEXT] = {
349 // not needed for FS1
351 {"Exit", 1466, 587, 416, UI_XSTR_COLOR_PINK, -1, &Medals_buttons[GR_640][MEDALS_EXIT].button },
355 // not needed for FS1
357 {"Exit", 1466, 943, 673, UI_XSTR_COLOR_PINK, -1, &Medals_buttons[GR_1024][MEDALS_EXIT].button },
362 static char* Medals_background_filename[GR_NUM_RESOLUTIONS] = {
363 "MedalsDisplayEmpty",
364 "2_MedalsDisplayEmpty"
367 static char* Medals_mask_filename[GR_NUM_RESOLUTIONS] = {
372 static int Medals_callsign_y[GR_NUM_RESOLUTIONS] = {
380 scoring_struct *Player_score=NULL;
383 player *Medals_player;
385 // -----------------------------------------------------------------------------
386 // Main medals screen state
388 #define NUM_MEDAL_REGIONS NUM_MEDALS + 1 // the extra one is for the rank medal
390 static bitmap *Medals_mask;
391 int Medals_mask_w, Medals_mask_h;
392 static int Medal_palette; // Medal palette bitmap
393 static int Medals_bitmap_mask; // the mask for the medal case
394 static int Medals_bitmap; // the medal case itself
395 static int Medal_bitmaps[NUM_MEDALS]; // bitmaps for the individual medals
396 static int Rank_bm; // bitmap for the rank medal
398 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
400 static UI_WINDOW Medals_window;
402 //#define MAX_MEDALS_BUTTONS 1
403 //#define MEDAL_BUTTON_EXIT 0
404 //static UI_BUTTON Medal_buttons[MAX_MEDALS_BUTTONS];
406 /*static char *Medal_button_names[MAX_MEDALS_BUTTONS] = {
413 static int Medal_button_coords[MAX_MEDALS_BUTTONS][2] = {
416 static int Medal_button_masks[MAX_MEDALS_BUTTONS] = {
422 #define MEDAL_BITMAP_INIT (1<<0)
423 #define MASK_BITMAP_INIT (1<<1)
426 void parse_medal_tbl()
428 int rval, num_medals, i, bi;
430 if ((rval = setjmp(parse_abort)) != 0) {
431 Error(LOCATION, "Error parsing 'medals.tbl'\r\nError code = %i.\r\n", rval);
437 read_file_text("medals.tbl");
441 // parse in all the rank names
444 required_string("#Medals");
445 while ( required_string_either("#End", "$Name:") ) {
446 Assert ( num_medals < NUM_MEDALS);
447 required_string("$Name:");
448 stuff_string( Medals[num_medals].name, F_NAME, NULL );
449 required_string("$Bitmap:");
450 stuff_string( Medals[num_medals].bitmap, F_NAME, NULL );
451 required_string("$Num mods:");
452 stuff_int( &Medals[num_medals].num_versions);
454 // some medals are based on kill counts. When string +Num Kills: is present, we know that
455 // this medal is a badge and should be treated specially
456 Medals[num_medals].kills_needed = 0;
457 if ( optional_string("+Num Kills:") ) {
458 char buf[MULTITEXT_LENGTH + 1];
460 Assert( bi < MAX_BADGES );
461 stuff_int( &Medals[num_medals].kills_needed );
462 Badge_index[bi] = num_medals;
464 required_string("$Wavefile 1:");
465 stuff_string(Badge_info[bi].voice_base, F_NAME, NULL, MAX_FILENAME_LEN);
466 required_string("$Wavefile 2:");
467 stuff_string(Badge_info[bi].voice_base2, F_NAME, NULL, MAX_FILENAME_LEN);
469 #warning FS2_DEMO HACK: Wavefile 1/2: wave1? wave2?
470 required_string("$Wavefile 1:");
471 stuff_string(Badge_info[bi].voice_base, F_NAME, NULL, MAX_FILENAME_LEN);
472 required_string("$Wavefile 2:");
473 stuff_string(Badge_info[bi].voice_base, F_NAME, NULL, MAX_FILENAME_LEN);
474 //stuff_string(Badge_info[bi].wave2, F_NAME, NULL, MAX_FILENAME_LEN);
476 required_string("$Wavefile Base:");
477 stuff_string(Badge_info[bi].voice_base, F_NAME, NULL, MAX_FILENAME_LEN);
480 required_string("$Promotion Text:");
481 stuff_string(buf, F_MULTITEXT, NULL);
482 Badge_info[bi].promotion_text = strdup(buf);
490 required_string("#End");
491 Assert( num_medals == NUM_MEDALS );
493 // be sure that the badges kill numbers show up in order
494 for (i = 0; i < MAX_BADGES-1; i++ ) {
495 if ( Medals[Badge_index[i]].kills_needed >= Medals[Badge_index[i+1]].kills_needed ){
496 Error(LOCATION, "Badges must appear sorted by lowest kill # first in medals.tbl\nFind Allender for most information.");
500 // close localization
504 void medal_main_init(player *pl, int mode)
511 Player_score = &Medals_player->stats;
514 if(Cmdline_gimme_all_medals){
516 for(idx=0; idx < NUM_MEDALS; idx++){
517 Medals_player->stats.medals[idx] = 1;
525 Medals_window.create( 0, 0, gr_screen.max_w, gr_screen.max_h, 0 );
527 // create the interface buttons
528 for (idx=0; idx<MEDALS_NUM_BUTTONS; idx++) {
530 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);
532 // set the sound to play when highlighted
533 Medals_buttons[gr_screen.res][idx].button.set_highlight_action(common_play_highlight_sound);
535 // set the ani for the button
536 Medals_buttons[gr_screen.res][idx].button.set_bmaps(Medals_buttons[gr_screen.res][idx].filename);
539 Medals_buttons[gr_screen.res][idx].button.link_hotspot(Medals_buttons[gr_screen.res][idx].hotspot);
543 for (idx=0; idx<MEDALS_NUM_TEXT; idx++) {
544 Medals_window.add_XSTR(&Medals_text[gr_screen.res][idx]);
550 //init_medal_palette();
552 common_set_interface_palette("MedalsPalette");
555 Medals_bitmap = bm_load(Medals_background_filename[gr_screen.res]);
556 if (Medals_bitmap < 0) {
557 Error(LOCATION, "Error loading medal background bitmap %s", Medals_background_filename[gr_screen.res]);
559 Init_flags |= MEDAL_BITMAP_INIT;
565 Medals_bitmap_mask = bm_load(Medals_mask_filename[gr_screen.res]);
566 if(Medals_bitmap_mask < 0){
567 Error(LOCATION, "Error loading medal mask file %s", Medals_mask_filename[gr_screen.res]);
569 Init_flags |= MASK_BITMAP_INIT;
570 Medals_mask = bm_lock(Medals_bitmap_mask, 8, BMP_AABITMAP);
571 bm_get_info(Medals_bitmap_mask, &Medals_mask_w, &Medals_mask_h);
573 init_medal_bitmaps();
574 init_snazzy_regions();
576 gr_set_color_fast(&Color_normal);
578 Medals_window.set_mask_bmap(Medals_mask_filename[gr_screen.res]);
581 // this is just a hack to display translated names without actually changing the names,
582 // which would break stuff
583 void medals_translate_name(char *name, int max_len)
586 if (!strcmp(name, "Conspicuous Gallantry")) {
587 strncpy(name, "Tapferkeitsmedaille", max_len);
589 } else if (!strcmp(name, "Vasudan Alliance")) {
590 strncpy(name, "Vasudanischen Allianz", max_len);
592 } else if (!strcmp(name, "Distinguished Flying Cross")) {
593 strncpy(name, "Kreuz f\x81r Fliegerleistungen", max_len);
595 } else if (!strcmp(name, "Commendation Medal")) {
596 strncpy(name, "Anerkennungsmedaille", max_len);
598 } else if (!strcmp(name, "Galatea Survivor")) {
599 strncpy(name, "Galatea-\x9A""berlebender", max_len);
601 } else if (!strcmp(name, "Legion of Merit")) {
602 strncpy(name, "Verdienstlegion", max_len);
604 } else if (!strcmp(name, "Meritorious Unit")) {
605 strncpy(name, "Verdienstmedaille", max_len);
607 } else if (!strcmp(name, "Medal of Honor")) {
608 strncpy(name, "Ehrenmedaille", max_len);
610 } else if (!strcmp(name, "Galactic Service")) {
611 strncpy(name, "Galaktischer Dienst", max_len);
613 } else if (!strcmp(name, "Military Defense")) {
614 strncpy(name, "Verteidigungsmedaille", max_len);
616 } else if (!strcmp(name, "Good Conduct")) {
617 strncpy(name, "Medaille f\x81r gute F\x81hrung", max_len);
619 } else if (!strcmp(name, "Distinguished Service Cross")) {
620 strncpy(name, "Kreuz f\x81r Einsatz", max_len);
622 } else if (!strcmp(name, "Ace")) {
623 strncpy(name, "Bronzener Stern", max_len);
625 } else if (!strcmp(name, "Double Ace")) {
626 strncpy(name, "Silberner Stern", max_len);
628 } else if (!strcmp(name, "Triple Ace")) {
629 strncpy(name, "Goldener Stern", max_len);
631 } else if (!strcmp(name, "Wings")) {
632 strncpy(name, "Pilotenabzeichen", max_len);
634 } else if (!strcmp(name, "Rank")) {
635 strncpy(name, "Dienstgrad", max_len);
638 if (!strcmp(name, "Epsilon Pegasi Liberation")) {
639 strncpy(name, "Epsilon Pegasi Befreiungsmedaille", max_len);
641 } else if (!strcmp(name, "Imperial Order of Vasuda")) {
642 strncpy(name, "Imperialer Orden von Vasuda ", max_len);
644 } else if (!strcmp(name, "Distinguished Flying Cross")) {
645 strncpy(name, "Fliegerkreuz Erster Klasse", max_len);
647 } else if (!strcmp(name, "SOC Service Medallion")) {
648 strncpy(name, "SEK-Dienstmedaille ", max_len);
650 } else if (!strcmp(name, "Intelligence Cross")) {
651 strncpy(name, "Geheimdienstkreuz am Bande", max_len);
653 } else if (!strcmp(name, "Order of Galatea")) {
654 strncpy(name, "Orden von Galatea ", max_len);
656 } else if (!strcmp(name, "Meritorious Unit Commendation")) {
657 strncpy(name, "Ehrenspange der Allianz", max_len);
659 } else if (!strcmp(name, "Medal of Valor")) {
660 strncpy(name, "Tapferkeitsmedaille ", max_len);
662 } else if (!strcmp(name, "GTVA Legion of Honor")) {
663 strncpy(name, "Orden der GTVA-Ehrenlegion", max_len);
665 } else if (!strcmp(name, "Allied Defense Citation")) {
666 strncpy(name, "Alliierte Abwehrspange ", max_len);
668 } else if (!strcmp(name, "Nebula Campaign Victory Star")) {
669 strncpy(name, "Nebel-Siegesstern", max_len);
671 } else if (!strcmp(name, "NTF Campaign Victory Star")) {
672 strncpy(name, "NTF-Siegesstern ", max_len);
674 } else if (!strcmp(name, "Rank")) {
675 strncpy(name, "Dienstgrad", max_len);
677 } else if (!strcmp(name, "Wings")) {
678 strncpy(name, "Fliegerspange", max_len);
680 } else if (!strcmp(name, "Ace")) {
681 strncpy(name, "Flieger-As", max_len);
683 } else if (!strcmp(name, "Double Ace")) {
684 strncpy(name, "Doppel-As ", max_len);
686 } else if (!strcmp(name, "Triple Ace")) {
687 strncpy(name, "Dreifach-As ", max_len);
689 } else if (!strcmp(name, "SOC Unit Crest")) {
690 strncpy(name, "SEK-Abzeichen ", max_len);
695 // this is just a hack to display translated names without actually changing the names,
696 // which would break stuff
697 void medals_translate_name_pl(char *name, int max_len)
699 if (!strcmp(name, "Epsilon Pegasi Liberation")) {
700 strncpy(name, "Order Wyzwolenia Epsilon Pegasi", max_len);
702 } else if (!strcmp(name, "Imperial Order of Vasuda")) {
703 strncpy(name, "Imperialny Order Vasudy", max_len);
705 } else if (!strcmp(name, "Distinguished Flying Cross")) {
706 strncpy(name, "Krzy\xBF Wybitnego Pilota", max_len);
708 } else if (!strcmp(name, "SOC Service Medallion")) {
709 strncpy(name, "Krzy\xBF S\xB3u\xBF\x62 Specjalnych", max_len);
711 } else if (!strcmp(name, "Intelligence Cross")) {
712 strncpy(name, "Krzy\xBF Wywiadu", max_len);
714 } else if (!strcmp(name, "Order of Galatea")) {
715 strncpy(name, "Order Galatei", max_len);
717 } else if (!strcmp(name, "Meritorious Unit Commendation")) {
718 strncpy(name, "Medal Pochwalny", max_len);
720 } else if (!strcmp(name, "Medal of Valor")) {
721 strncpy(name, "Medal za Odwag\xEA", max_len);
723 } else if (!strcmp(name, "GTVA Legion of Honor")) {
724 strncpy(name, "Legia Honorowa GTVA", max_len);
726 } else if (!strcmp(name, "Allied Defense Citation")) {
727 strncpy(name, "Order za Obron\xEA Sojuszu", max_len);
729 } else if (!strcmp(name, "Nebula Campaign Victory Star")) {
730 strncpy(name, "Gwiazda Wiktorii Kampanii w Mg\xB3\x61wicy", max_len);
732 } else if (!strcmp(name, "NTF Campaign Victory Star")) {
733 strncpy(name, "Gwiazda Wiktorii Kampanii NTF", max_len);
735 } else if (!strcmp(name, "Rank")) {
736 strncpy(name, "Ranga", max_len);
738 } else if (!strcmp(name, "Wings")) {
739 strncpy(name, "Skrzyd\xB3\x61", max_len);
741 } else if (!strcmp(name, "Ace")) {
742 strncpy(name, "As", max_len);
744 } else if (!strcmp(name, "Double Ace")) {
745 strncpy(name, "Podw\xF3jny As", max_len);
747 } else if (!strcmp(name, "Triple Ace")) {
748 strncpy(name, "Potr\xF3jny As", max_len);
750 } else if (!strcmp(name, "SOC Unit Crest")) {
751 strncpy(name, "Tarcza S\xB3u\xBF\x62 Specjalnych", max_len);
756 void blit_label(char *label, int *coordsx, int *coordsy, int num)
758 void blit_label(char *label, int *coords, int num)
764 gr_set_color_fast(&Color_bright);
766 // translate medal names before displaying
767 // cant translate in table cuz the names are used in comparisons
769 char translated_label[256];
770 strncpy(translated_label, label, 256);
771 medals_translate_name(translated_label, 256);
773 // set correct string
775 sprintf( text, NOX("%s (%d)"), translated_label, num );
777 sprintf( text, "%s", translated_label );
780 char translated_label[256];
781 strncpy(translated_label, label, 256);
782 medals_translate_name_pl(translated_label, 256);
784 // set correct string
786 sprintf( text, NOX("%s (%d)"), translated_label, num );
788 sprintf( text, "%s", translated_label );
791 // set correct string
793 sprintf( text, NOX("%s (%d)"), label, num );
795 sprintf( text, "%s", label );
799 // find correct coords
800 gr_get_string_size(&sw, NULL, text);
802 x = *coordsx - sw / 2;
805 x = Medals_label_coords[gr_screen.res][0] + (Medals_label_coords[gr_screen.res][2] - sw) / 2;
806 y = Medals_label_coords[gr_screen.res][1];
810 gr_string(x, y, text);
816 gr_set_color_fast(&Color_bright_blue);
818 gr_set_color_fast(&Color_normal);
821 // nothing special, just do it.
822 gr_string(0x8000, Medals_callsign_y[gr_screen.res], Medals_player->callsign);
827 int region,selected, k;
829 k = Medals_window.process();
831 // process an exit command
832 if ((k == KEY_ESC) && (Medals_mode == MM_NORMAL)) {
833 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
836 // draw the background medal display case
838 GR_MAYBE_CLEAR_RES(Medals_bitmap);
839 if(Medals_bitmap != -1){
840 gr_set_bitmap(Medals_bitmap);
844 // check to see if a button was pressed
845 if( (k == (KEY_CTRLED|KEY_ENTER)) || (Medals_buttons[gr_screen.res][MEDALS_EXIT].button.pressed()) ) {
846 gamesnd_play_iface(SND_COMMIT_PRESSED);
847 if(Medals_mode == MM_NORMAL){
848 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
850 // any calling popup function will know to close the screen down
855 // blit medals also takes care of blitting the rank insignia
859 region = snazzy_menu_do((ubyte*)Medals_mask->data, Medals_mask_w, Medals_mask_h, NUM_MEDAL_REGIONS, Medal_regions, &selected);
862 if (Medals_mode == MM_NORMAL) {
863 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
865 // any calling popup function will know to close the screen down
870 case RANK_MEDAL_REGION :
872 blit_label(Ranks[Player_score->rank].name, &Rank_label_coords[0], &Rank_label_coords[1], 1);
874 blit_label(Ranks[Player_score->rank].name, &Medal_coords[gr_screen.res][region][0], 1);
882 if (Player_score->medals[region] > 0){
884 blit_label(Medals[region].name, &Medals_label_coords[region][0], &Medals_label_coords[region][1], Player_score->medals[region] );
886 blit_label(Medals[region].name, &Medal_coords[gr_screen.res][region][0], Player_score->medals[region] );
892 Medals_window.draw();
899 void medal_main_close()
902 if (Init_flags & MEDAL_BITMAP_INIT)
903 bm_unload(Medals_bitmap);
905 if (Init_flags & MASK_BITMAP_INIT) {
906 bm_unlock(Medals_bitmap_mask);
907 bm_unload(Medals_bitmap_mask);
910 for (idx=0; idx < NUM_MEDALS; idx++) {
911 if (Medal_bitmaps[idx] > -1){
912 bm_unload(Medal_bitmaps[idx]);
917 Medals_window.destroy();
920 common_free_interface_palette();
924 palette_restore_palette();
928 void init_medal_palette()
930 Medal_palette = bm_load("MedalsPalette.pcx");
931 if(Medal_palette > -1){
932 #ifndef HARDWARE_ONLY
933 palette_use_bm_palette(Medal_palette);
939 // function to load in the medals for this player. It loads medals that the player has (known
940 // by whether or not a non-zero number is present in the player's medal array), then loads the
943 void init_medal_bitmaps()
946 Assert(Player_score);
948 for (idx=0; idx<NUM_MEDALS; idx++) {
949 Medal_bitmaps[idx] = -1;
950 if (Player_score->medals[idx] > 0) {
952 char filename[NAME_LENGTH], base[NAME_LENGTH];
954 // possibly load a different filename that is specified by the bitmap filename
955 // for this medal. if the player has > 1 of these types of medals, then determien
956 // which of the possible version to use based on the player's count of this medal
957 strcpy( filename, Medals[idx].bitmap );
959 _splitpath( filename, NULL, NULL, base, NULL );
961 num_medals = Player_score->medals[idx];
963 // can't display more than the maximum number of version for this medal
964 if ( num_medals > Medals[idx].num_versions )
965 num_medals = Medals[idx].num_versions;
967 if ( num_medals > 1 ) {
968 // append the proper character onto the end of the medal filename. Base version
969 // has no character. next version is a, then b, etc.
970 sprintf( base, "%s%c", base, (num_medals-2)+'a');
974 if (gr_screen.res == GR_1024) {
975 sprintf( filename, "2_%s", base );
978 // base now contains the actual medal bitmap filename needed to load
979 // we don't need to pass extension to bm_load anymore, so just use the basename
981 Medal_bitmaps[idx] = bm_load( filename );
982 Assert( Medal_bitmaps[idx] != -1 );
986 // load up rank insignia
987 if (gr_screen.res == GR_1024) {
988 char filename[NAME_LENGTH];
989 sprintf(filename, "2_%s", Ranks[Player_score->rank].bitmap);
990 Rank_bm = bm_load(filename);
992 Rank_bm = bm_load(Ranks[Player_score->rank].bitmap);
996 void init_snazzy_regions()
1000 // snazzy regions for the medals/ranks, etc.
1001 for (idx=0; idx<NUM_MEDALS; idx++) {
1002 if (idx == RANK_MEDAL_REGION)
1005 snazzy_menu_add_region(&Medal_regions[idx], "", idx, 0);
1008 // add the rank medal region
1009 snazzy_menu_add_region(&Medal_regions[RANK_MEDAL_REGION], "", RANK_MEDAL_REGION,0);
1013 // blit the medals -- this includes the rank insignia
1018 for (idx=0; idx<NUM_MEDALS; idx++) {
1019 if (Player_score->medals[idx] > 0) {
1020 gr_set_bitmap(Medal_bitmaps[idx]);
1021 gr_bitmap(Medal_coords[gr_screen.res][idx][0], Medal_coords[gr_screen.res][idx][1]);
1025 // now blit rank, since that "medal" doesnt get loaded (or drawn) the normal way
1026 gr_set_bitmap(Rank_bm);
1028 gr_bitmap(Rank_coords[0], Rank_coords[1]);
1030 gr_bitmap(Medal_coords[gr_screen.res][RANK_MEDAL_REGION][0], Medal_coords[gr_screen.res][RANK_MEDAL_REGION][1]);