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.14 2005/03/29 02:18:47 taylor
17 * Various 64-bit platform fixes
18 * Fix compiler errors with MAKE_FS1 and fix gr_set_bitmap() too
19 * Make sure that turrets can fire at asteroids for FS1 (needed for a couple missions)
20 * Streaming audio support (big thanks to Pierre Willenbrock!!)
21 * Removed dependance on strings.tbl for FS1 since we don't actually need it now
23 * Revision 1.13 2004/09/20 01:31:45 theoddone33
26 * Revision 1.12 2004/07/04 11:39:06 taylor
27 * fix missing debrief text, crash on exit, path separator's, warning fixes, no GR_SOFT
29 * Revision 1.11 2003/08/03 16:10:30 taylor
30 * cleanup; compile warning fixes
32 * Revision 1.10 2003/06/11 18:30:33 taylor
35 * Revision 1.9 2003/06/03 04:00:40 taylor
36 * Polish language support (Janusz Dziemidowicz)
38 * Revision 1.8 2003/05/25 02:30:44 taylor
41 * Revision 1.7 2002/06/09 04:41:27 relnev
42 * added copyright header
44 * Revision 1.6 2002/06/09 03:16:05 relnev
47 * removed unneeded asm, old sdl 2d setup.
49 * fixed crash caused by opengl_get_region.
51 * Revision 1.5 2002/05/28 08:52:03 relnev
52 * implemented two assembly stubs.
54 * cleaned up a few warnings.
56 * added a little demo hackery to make it progress a little farther.
58 * Revision 1.4 2002/05/28 04:56:51 theoddone33
59 * runs a little bit now
61 * Revision 1.3 2002/05/26 20:22:48 theoddone33
62 * Most of network/ works
64 * Revision 1.2 2002/05/04 04:36:56 theoddone33
65 * More changes, took out a lot of the sound stuff which will bite later but
68 * Revision 1.1.1.1 2002/05/03 03:28:11 root
72 * 12 10/29/99 10:40p Jefff
73 * hack to make german medal names display without actually changing them
75 * 11 9/02/99 3:41p Jefff
76 * changed badge voice handling to be similar to promotion voice handling
78 * 10 8/26/99 8:49p Jefff
79 * Updated medals screen and about everything that ever touches medals in
80 * one way or another. Sheesh.
82 * 9 7/16/99 1:50p Dave
83 * 8 bit aabitmaps. yay.
85 * 8 3/19/99 9:51a Dave
86 * Checkin to repair massive source safe crash. Also added support for
87 * pof-style nebulae, and some new weapons code.
89 * 8 3/15/99 10:29a Neilk
91 * 7 1/30/99 5:08p Dave
92 * More new hi-res stuff.Support for nice D3D textures.
94 * 6 12/18/98 1:13a Dave
95 * Rough 1024x768 support for Direct3D. Proper detection and usage through
98 * 5 11/30/98 1:07p Dave
99 * 16 bit conversion, first run.
101 * 4 10/23/98 3:51p Dave
102 * Full support for tstrings.tbl and foreign languages. All that remains
103 * is to make it active in Fred.
105 * 3 10/13/98 9:29a Dave
106 * Started neatening up freespace.h. Many variables renamed and
107 * reorganized. Added AlphaColors.[h,cpp]
109 * 2 10/07/98 10:54a Dave
112 * 1 10/07/98 10:51a Dave
114 * 26 6/13/98 3:18p Hoffoss
115 * NOX()ed out a bunch of strings that shouldn't be translated.
117 * 25 6/01/98 11:43a John
118 * JAS & MK: Classified all strings for localization.
120 * 24 5/01/98 12:34p John
121 * Added code to force FreeSpace to run in the same dir as exe and made
122 * all the parse error messages a little nicer.
124 * 23 4/27/98 3:13p Allender
125 * make ctrl-enter work on medals screen
127 * 22 4/23/98 8:27p Allender
128 * basic support for cutscene playback. Into movie code in place. Tech
129 * room can view cutscenes stored in CDROM_dir variable
131 * 21 4/12/98 8:30p Allender
132 * minor medal changes to show number of medals if > 1
134 * 20 4/10/98 4:51p Hoffoss
135 * Made several changes related to tooltips.
137 * 19 3/18/98 12:03p John
138 * Marked all the new strings as externalized or not.
140 * 18 3/11/98 5:02p Dave
141 * Put in code to support new medals artwork. Assorted multiplayer bug
144 * 17 3/07/98 5:44p Dave
145 * Finished player info popup. Ironed out a few todo bugs.
147 * 16 3/05/98 5:11p Allender
148 * fix up medals screen (again). Don't do state transition when viewing
149 * medals from debriefing screen.
151 * 15 3/05/98 2:32p Hoffoss
152 * Renamed Rank_bitmap to Rank_bm so it isn't named the same as the
153 * variable in the debrief screen which confuses the debugger.
155 * 14 2/22/98 2:48p John
156 * More String Externalization Classification
158 * 13 2/09/98 5:21p Hoffoss
159 * Made exit from medals screen to previous screen (instead of assuming
160 * it's the barracks) work.
162 * 12 1/27/98 4:23p Allender
163 * enhanced internal scoring mechanisms.
165 * 11 11/12/97 4:40p Dave
166 * Put in multiplayer campaign support parsing, loading and saving. Made
167 * command-line variables better named. Changed some things on the initial
168 * pilot select screen.
170 * 10 11/12/97 9:30a Dave
171 * Fixed rank insignia tooltip not showing up.
173 * 9 11/06/97 4:39p Allender
174 * a ton of medal work. Removed an uneeded elemen in the scoring
175 * structure. Fix up medals screen to apprioriate display medals (after
176 * mask was changed). Fix Fred to only display medals which may actually
177 * be granted. Added image_filename to player struct for Jason Hoffoss
179 * 8 11/05/97 4:43p Allender
180 * reworked medal/rank system to read all data from tables. Made Fred
181 * read medals.tbl. Changed ai-warp to ai-warp-out which doesn't require
182 * waypoint for activation
190 #include "snazzyui.h"
192 #include "gamesequence.h"
193 #include "animplay.h"
195 #include "freespace.h"
203 #include "alphacolors.h"
204 #include "localize.h"
205 #include "missionscreencommon.h" // for common_set_interface_palette
207 //#define MAX_MEDAL_TYPES 63 // the # of medals which exist so far
210 #define CALLSIGN_X 198
211 #define CALLSIGN_Y 80
212 #define CALLSIGN_W (439-CALLSIGN_X)
213 #define CALLSIGN_H (116-CALLSIGN_Y)
216 // define for the medal information
217 medal_stuff Medals[NUM_MEDALS];
218 badge_stuff Badge_info[MAX_BADGES];
220 // holds indices into Medals array of the badges for # kills
221 int Badge_index[MAX_BADGES];
223 // the rank section of the screen
225 // not in Medal_coords but needs to be set
226 // to not interfere with other medals
227 #define RANK_MEDAL_REGION 16 // region number of the rank medal
229 #define RANK_MEDAL_REGION 12 // region number of the rank medal
233 #warning Find real FS2_DEMO spot for medals
235 // coords for indiv medal bitmaps
236 int Medal_coords[GR_NUM_RESOLUTIONS][NUM_MEDALS][2] = {
239 { 108, 74 }, // Conspicuous Gallantry
240 { 473, 73 }, // Vasudan Alliance
241 { 146, 150 }, // Distinguished Flying Cross
242 { 219, 152 }, // Commendation Medal
243 { 360, 150 }, // Galatea Survivor
244 { 432, 150 }, // Legion of Merit
245 { 88, 243 }, // Meritorious Unit
246 { 168, 243 }, // Medal of Honor
247 { 248, 250 }, // Galactic Service
248 { 328, 250 }, // Military Defense
249 { 406, 244 }, // Good Conduct
250 { 483, 243 }, // Distinguished Service Cross
252 { 373, 109 }, // Double Ace
254 { 403, 109 }, // Triple Ace
256 { 287, 186 }, // Wings
258 { 89, 47 }, // eps. peg. lib
259 { 486, 47 }, // imp. order o' vasuda
260 { 129, 130 }, // dist flying cross
261 { 208, 132 }, // soc service
262 { 361, 131 }, // dist intel cross
263 { 439, 130 }, // order of galatea
264 { 64, 234 }, // meritorious unit comm.
265 { 153, 234 }, // medal of valor
266 { 239, 241 }, // gtva leg of honor
267 { 326, 240 }, // allied defense citation
268 { 411, 234 }, // neb campaign victory
269 { 494, 234 }, // ntf campaign victory
271 { 283, 91 }, // wings
272 { 372, 76 }, // bronze kills badge
273 { 403, 76 }, // silver kills badge
275 { 435, 76 }, // gold kills badge
276 { 300, 152 }, // SOC unit crest
281 { 143, 75 }, // eps. peg. lib
282 { 777, 75 }, // imp. order o' vasuda
283 { 206, 208 }, // dist flying cross
284 { 333, 212 }, // soc service
285 { 578, 210 }, // dist intel cross
286 { 703, 208 }, // order of galatea
287 { 103, 374 }, // meritorious unit comm.
288 { 245, 374 }, // medal of valor
289 { 383, 386 }, // gtva leg of honor
290 { 522, 384 }, // allied defense citation
291 { 658, 374 }, // neb campaign victory
292 { 790, 374 }, // ntf campaign victory
293 { 302, 128 }, // rank
294 { 453, 146 }, // wings
295 { 595, 121 }, // bronze kills badge
296 { 646, 121 }, // silver kills badge
297 #if !(defined(FS2_DEMO) || defined(MAKE_FS1))
298 { 696, 121 }, // gold kills badge
299 { 480, 244 }, // SOC unit crest
305 // coords for the medal/rank title
306 static int Rank_label_coords[2] = {
310 static int Rank_coords[2] = {
314 // I couldn't think of a better way to do this so define
315 // the base center point for each medal to center the label on
317 // x = the horizontal center point of the bitmap
318 // y = the base of the medal bitmap itself
319 static int Medals_label_coords[NUM_MEDALS][2] = {
321 { 137, 158 }, // Conspicuous Gallantry
322 { 502, 154 }, // Vasudan Alliance
323 { 176, 238 }, // Distinguished Flying Cross
324 { 249, 244 }, // Commendation Medal
325 { 390, 238 }, // Galatea Survivor
326 { 462, 237 }, // Legion of Merit
327 { 121, 345 }, // Meritorious Unit
328 { 199, 346 }, // Medal of Honor
329 { 280, 349 }, // Galactic Service
330 { 360, 350 }, // Military Defense
331 { 438, 349 }, // Good Conduct
332 { 517, 353 }, // Distinguished Service Cross
334 { 385, 129 }, // Double Ace
336 { 415, 129 }, // Triple Ace
338 { 319, 216 }, // Wings
341 // coords for the medal title
342 static int Medals_label_coords[GR_NUM_RESOLUTIONS][3] = {
343 { 241, 458, 300 }, // GR_640 x, y, w
344 { 386, 734, 480 } // GR_1024 x, y, w
348 #define MEDALS_NUM_BUTTONS 1
349 #define MEDALS_EXIT 0
350 ui_button_info Medals_buttons[GR_NUM_RESOLUTIONS][MEDALS_NUM_BUTTONS] = {
353 ui_button_info("MX_17", 561, 411, -1, -1, 17),
355 ui_button_info("MEB_18", 574, 432, -1, -1, 18),
359 ui_button_info("2_MEB_18", 919, 691, -1, -1, 18),
364 #define MEDALS_NUM_TEXT 1
366 UI_XSTR Medals_text[GR_NUM_RESOLUTIONS][MEDALS_NUM_TEXT] = {
368 {"Exit", 1466, 587, 416, UI_XSTR_COLOR_PINK, -1, &Medals_buttons[GR_640][MEDALS_EXIT].button },
371 {"Exit", 1466, 943, 673, UI_XSTR_COLOR_PINK, -1, &Medals_buttons[GR_1024][MEDALS_EXIT].button },
376 static const char* Medals_background_filename[GR_NUM_RESOLUTIONS] = {
377 "MedalsDisplayEmpty",
378 "2_MedalsDisplayEmpty"
381 static const 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 SDL_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 SDL_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 SDL_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)
522 SDL_assert(pl != NULL);
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);
558 for (idx=0; idx<MEDALS_NUM_TEXT; idx++) {
559 Medals_window.add_XSTR(&Medals_text[gr_screen.res][idx]);
566 //init_medal_palette();
568 common_set_interface_palette("MedalsPalette");
571 Medals_bitmap = bm_load(Medals_background_filename[gr_screen.res]);
572 if (Medals_bitmap < 0) {
573 Error(LOCATION, "Error loading medal background bitmap %s", Medals_background_filename[gr_screen.res]);
575 Init_flags |= MEDAL_BITMAP_INIT;
581 Medals_bitmap_mask = bm_load(Medals_mask_filename[gr_screen.res]);
582 if(Medals_bitmap_mask < 0){
583 Error(LOCATION, "Error loading medal mask file %s", Medals_mask_filename[gr_screen.res]);
585 Init_flags |= MASK_BITMAP_INIT;
586 Medals_mask = bm_lock(Medals_bitmap_mask, 8, BMP_AABITMAP);
587 bm_get_info(Medals_bitmap_mask, &Medals_mask_w, &Medals_mask_h);
589 init_medal_bitmaps();
590 init_snazzy_regions();
592 gr_set_color_fast(&Color_normal);
594 Medals_window.set_mask_bmap(Medals_mask_filename[gr_screen.res]);
597 // this is just a hack to display translated names without actually changing the names,
598 // which would break stuff
599 void medals_translate_name(char *name, int max_len)
602 if (!strcmp(name, "Conspicuous Gallantry")) {
603 SDL_strlcpy(name, "Tapferkeitsmedaille", max_len);
605 } else if (!strcmp(name, "Vasudan Alliance")) {
606 SDL_strlcpy(name, "Vasudanischen Allianz", max_len);
608 } else if (!strcmp(name, "Distinguished Flying Cross")) {
609 SDL_strlcpy(name, "Kreuz f\x81r Fliegerleistungen", max_len);
611 } else if (!strcmp(name, "Commendation Medal")) {
612 SDL_strlcpy(name, "Anerkennungsmedaille", max_len);
614 } else if (!strcmp(name, "Galatea Survivor")) {
615 SDL_strlcpy(name, "Galatea-\x9A""berlebender", max_len);
617 } else if (!strcmp(name, "Legion of Merit")) {
618 SDL_strlcpy(name, "Verdienstlegion", max_len);
620 } else if (!strcmp(name, "Meritorious Unit")) {
621 SDL_strlcpy(name, "Verdienstmedaille", max_len);
623 } else if (!strcmp(name, "Medal of Honor")) {
624 SDL_strlcpy(name, "Ehrenmedaille", max_len);
626 } else if (!strcmp(name, "Galactic Service")) {
627 SDL_strlcpy(name, "Galaktischer Dienst", max_len);
629 } else if (!strcmp(name, "Military Defense")) {
630 SDL_strlcpy(name, "Verteidigungsmedaille", max_len);
632 } else if (!strcmp(name, "Good Conduct")) {
633 SDL_strlcpy(name, "Medaille f\x81r gute F\x81hrung", max_len);
635 } else if (!strcmp(name, "Distinguished Service Cross")) {
636 SDL_strlcpy(name, "Kreuz f\x81r Einsatz", max_len);
638 } else if (!strcmp(name, "Ace")) {
639 SDL_strlcpy(name, "Bronzener Stern", max_len);
641 } else if (!strcmp(name, "Double Ace")) {
642 SDL_strlcpy(name, "Silberner Stern", max_len);
644 } else if (!strcmp(name, "Triple Ace")) {
645 SDL_strlcpy(name, "Goldener Stern", max_len);
647 } else if (!strcmp(name, "Wings")) {
648 SDL_strlcpy(name, "Pilotenabzeichen", max_len);
650 } else if (!strcmp(name, "Rank")) {
651 SDL_strlcpy(name, "Dienstgrad", max_len);
654 if (!strcmp(name, "Epsilon Pegasi Liberation")) {
655 SDL_strlcpy(name, "Epsilon Pegasi Befreiungsmedaille", max_len);
657 } else if (!strcmp(name, "Imperial Order of Vasuda")) {
658 SDL_strlcpy(name, "Imperialer Orden von Vasuda ", max_len);
660 } else if (!strcmp(name, "Distinguished Flying Cross")) {
661 SDL_strlcpy(name, "Fliegerkreuz Erster Klasse", max_len);
663 } else if (!strcmp(name, "SOC Service Medallion")) {
664 SDL_strlcpy(name, "SEK-Dienstmedaille ", max_len);
666 } else if (!strcmp(name, "Intelligence Cross")) {
667 SDL_strlcpy(name, "Geheimdienstkreuz am Bande", max_len);
669 } else if (!strcmp(name, "Order of Galatea")) {
670 SDL_strlcpy(name, "Orden von Galatea ", max_len);
672 } else if (!strcmp(name, "Meritorious Unit Commendation")) {
673 SDL_strlcpy(name, "Ehrenspange der Allianz", max_len);
675 } else if (!strcmp(name, "Medal of Valor")) {
676 SDL_strlcpy(name, "Tapferkeitsmedaille ", max_len);
678 } else if (!strcmp(name, "GTVA Legion of Honor")) {
679 SDL_strlcpy(name, "Orden der GTVA-Ehrenlegion", max_len);
681 } else if (!strcmp(name, "Allied Defense Citation")) {
682 SDL_strlcpy(name, "Alliierte Abwehrspange ", max_len);
684 } else if (!strcmp(name, "Nebula Campaign Victory Star")) {
685 SDL_strlcpy(name, "Nebel-Siegesstern", max_len);
687 } else if (!strcmp(name, "NTF Campaign Victory Star")) {
688 SDL_strlcpy(name, "NTF-Siegesstern ", max_len);
690 } else if (!strcmp(name, "Rank")) {
691 SDL_strlcpy(name, "Dienstgrad", max_len);
693 } else if (!strcmp(name, "Wings")) {
694 SDL_strlcpy(name, "Fliegerspange", max_len);
696 } else if (!strcmp(name, "Ace")) {
697 SDL_strlcpy(name, "Flieger-As", max_len);
699 } else if (!strcmp(name, "Double Ace")) {
700 SDL_strlcpy(name, "Doppel-As ", max_len);
702 } else if (!strcmp(name, "Triple Ace")) {
703 SDL_strlcpy(name, "Dreifach-As ", max_len);
705 } else if (!strcmp(name, "SOC Unit Crest")) {
706 SDL_strlcpy(name, "SEK-Abzeichen ", max_len);
711 // this is just a hack to display translated names without actually changing the names,
712 // which would break stuff
713 void medals_translate_name_pl(char *name, int max_len)
715 if (!strcmp(name, "Epsilon Pegasi Liberation")) {
716 SDL_strlcpy(name, "Order Wyzwolenia Epsilon Pegasi", max_len);
718 } else if (!strcmp(name, "Imperial Order of Vasuda")) {
719 SDL_strlcpy(name, "Imperialny Order Vasudy", max_len);
721 } else if (!strcmp(name, "Distinguished Flying Cross")) {
722 SDL_strlcpy(name, "Krzy\xBF Wybitnego Pilota", max_len);
724 } else if (!strcmp(name, "SOC Service Medallion")) {
725 SDL_strlcpy(name, "Krzy\xBF S\xB3u\xBF\x62 Specjalnych", max_len);
727 } else if (!strcmp(name, "Intelligence Cross")) {
728 SDL_strlcpy(name, "Krzy\xBF Wywiadu", max_len);
730 } else if (!strcmp(name, "Order of Galatea")) {
731 SDL_strlcpy(name, "Order Galatei", max_len);
733 } else if (!strcmp(name, "Meritorious Unit Commendation")) {
734 SDL_strlcpy(name, "Medal Pochwalny", max_len);
736 } else if (!strcmp(name, "Medal of Valor")) {
737 SDL_strlcpy(name, "Medal za Odwag\xEA", max_len);
739 } else if (!strcmp(name, "GTVA Legion of Honor")) {
740 SDL_strlcpy(name, "Legia Honorowa GTVA", max_len);
742 } else if (!strcmp(name, "Allied Defense Citation")) {
743 SDL_strlcpy(name, "Order za Obron\xEA Sojuszu", max_len);
745 } else if (!strcmp(name, "Nebula Campaign Victory Star")) {
746 SDL_strlcpy(name, "Gwiazda Wiktorii Kampanii w Mg\xB3\x61wicy", max_len);
748 } else if (!strcmp(name, "NTF Campaign Victory Star")) {
749 SDL_strlcpy(name, "Gwiazda Wiktorii Kampanii NTF", max_len);
751 } else if (!strcmp(name, "Rank")) {
752 SDL_strlcpy(name, "Ranga", max_len);
754 } else if (!strcmp(name, "Wings")) {
755 SDL_strlcpy(name, "Skrzyd\xB3\x61", max_len);
757 } else if (!strcmp(name, "Ace")) {
758 SDL_strlcpy(name, "As", max_len);
760 } else if (!strcmp(name, "Double Ace")) {
761 SDL_strlcpy(name, "Podw\xF3jny As", max_len);
763 } else if (!strcmp(name, "Triple Ace")) {
764 SDL_strlcpy(name, "Potr\xF3jny As", max_len);
766 } else if (!strcmp(name, "SOC Unit Crest")) {
767 SDL_strlcpy(name, "Tarcza S\xB3u\xBF\x62 Specjalnych", max_len);
772 void blit_label(char *label, int *coordsx, int *coordsy, int num)
774 void blit_label(char *label, int *coords, int num)
779 char translated_label[256];
781 gr_set_color_fast(&Color_bright);
783 // translate medal names before displaying
784 // cant translate in table cuz the names are used in comparisons
786 SDL_strlcpy(translated_label, label, sizeof(translated_label));
787 medals_translate_name(translated_label, sizeof(translated_label));
789 // set correct string
791 SDL_snprintf( text, sizeof(text), NOX("%s (%d)"), translated_label, num );
793 SDL_snprintf( text, sizeof(text), "%s", translated_label );
796 SDL_strlcpy(translated_label, label, sizeof(translated_label));
797 medals_translate_name_pl(translated_label, sizeof(translated_label));
799 // set correct string
801 SDL_snprintf( text, sizeof(text), NOX("%s (%d)"), translated_label, num );
803 SDL_snprintf( text, sizeof(text), "%s", translated_label );
806 // set correct string
808 SDL_snprintf( text, sizeof(text), NOX("%s (%d)"), label, num );
810 SDL_snprintf( text, sizeof(text), "%s", label );
814 // find correct coords
815 gr_get_string_size(&sw, NULL, text);
817 x = *coordsx - sw / 2;
820 x = Medals_label_coords[gr_screen.res][0] + (Medals_label_coords[gr_screen.res][2] - sw) / 2;
821 y = Medals_label_coords[gr_screen.res][1];
825 gr_string(x, y, text);
831 gr_set_color_fast(&Color_bright_blue);
833 gr_set_color_fast(&Color_normal);
836 // nothing special, just do it.
837 gr_string(0x8000, Medals_callsign_y[gr_screen.res], Medals_player->callsign);
842 int region,selected, k;
844 k = Medals_window.process();
846 // process an exit command
847 if ((k == SDLK_ESCAPE) && (Medals_mode == MM_NORMAL)) {
848 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
851 // draw the background medal display case
853 GR_MAYBE_CLEAR_RES(Medals_bitmap);
854 if(Medals_bitmap != -1){
855 gr_set_bitmap(Medals_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
859 // check to see if a button was pressed
860 if( (k == (KEY_CTRLED|SDLK_RETURN)) || (Medals_buttons[gr_screen.res][MEDALS_EXIT].button.pressed()) ) {
861 gamesnd_play_iface(SND_COMMIT_PRESSED);
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 // blit medals also takes care of blitting the rank insignia
874 region = snazzy_menu_do((ubyte*)Medals_mask->data, Medals_mask_w, Medals_mask_h, NUM_MEDAL_REGIONS, Medal_regions, &selected);
877 if (Medals_mode == MM_NORMAL) {
878 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
880 // any calling popup function will know to close the screen down
885 case RANK_MEDAL_REGION :
887 blit_label(Ranks[Player_score->rank].name, &Rank_label_coords[0], &Rank_label_coords[1], 1);
889 blit_label(Ranks[Player_score->rank].name, &Medal_coords[gr_screen.res][region][0], 1);
897 if (Player_score->medals[region] > 0){
899 blit_label(Medals[region].name, &Medals_label_coords[region][0], &Medals_label_coords[region][1], Player_score->medals[region] );
901 blit_label(Medals[region].name, &Medal_coords[gr_screen.res][region][0], Player_score->medals[region] );
907 Medals_window.draw();
914 void medal_main_close()
917 if (Init_flags & MEDAL_BITMAP_INIT)
918 bm_unload(Medals_bitmap);
920 if (Init_flags & MASK_BITMAP_INIT) {
921 bm_unlock(Medals_bitmap_mask);
922 bm_unload(Medals_bitmap_mask);
925 for (idx=0; idx < NUM_MEDALS; idx++) {
926 if (Medal_bitmaps[idx] > -1){
927 bm_unload(Medal_bitmaps[idx]);
932 Medals_window.destroy();
935 common_free_interface_palette();
939 palette_restore_palette();
942 // free up memory from table parsing
943 void medal_tbl_close()
947 for (i=0; i<MAX_BADGES; i++) {
948 if (Badge_info[i].promotion_text) {
949 free(Badge_info[i].promotion_text);
950 Badge_info[i].promotion_text = NULL;
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 SDL_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 SDL_strlcpy( filename, Medals[idx].bitmap, sizeof(filename) );
975 base_filename(filename, base, sizeof(base));
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 SDL_snprintf( base, sizeof(base), "%s%c", base, (num_medals-2)+'a');
990 if (gr_screen.res == GR_1024) {
991 SDL_snprintf( filename, sizeof(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 SDL_assert( Medal_bitmaps[idx] != -1 );
1002 // load up rank insignia
1003 if (gr_screen.res == GR_1024) {
1004 char filename[NAME_LENGTH];
1005 SDL_snprintf(filename, sizeof(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], GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
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, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
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]);