]> icculus.org git repositories - taylor/freespace2.git/blob - src/menuui/credits.cpp
added copyright header
[taylor/freespace2.git] / src / menuui / credits.cpp
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
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
6  * the source.
7  */
8
9 /*
10  * $Logfile: /Freespace2/code/MenuUI/Credits.cpp $
11  * $Revision$
12  * $Date$
13  * $Author$
14  *
15  * C source file for displaying game credits
16  *
17  * $Log$
18  * Revision 1.4  2002/06/09 04:41:22  relnev
19  * added copyright header
20  *
21  * Revision 1.3  2002/05/27 22:43:02  theoddone33
22  * Fix more glide symbols
23  *
24  * Revision 1.2  2002/05/07 03:16:46  theoddone33
25  * The Great Newline Fix
26  *
27  * Revision 1.1.1.1  2002/05/03 03:28:09  root
28  * Initial import.
29  *
30  * 
31  * 20    9/14/99 5:14a Dave
32  * Fixed credits drawing in Glide.
33  * 
34  * 19    9/13/99 1:53p Dave
35  * Fixed completely brain dead code in credits_init().
36  * 
37  * 18    9/09/99 10:55a Jefff
38  * 
39  * 17    9/03/99 11:45a Jefff
40  * 
41  * 16    9/01/99 5:28p Jefff
42  * hi res art shows up now
43  * 
44  * 15    9/01/99 4:20p Jefff
45  * mo' pictures
46  * 
47  * 14    9/01/99 12:19p Jefff
48  * text splitting for long lines
49  * 
50  * 13    7/19/99 2:13p Dave
51  * Added some new strings for Heiko.
52  * 
53  * 12    2/03/99 6:06p Dave
54  * Groundwork for FS2 PXO usertracker support.  Gametracker support next.
55  * 
56  * 11    2/03/99 11:44a Dave
57  * Fixed d3d transparent textures.
58  * 
59  * 10    2/01/99 5:55p Dave
60  * Removed the idea of explicit bitmaps for buttons. Fixed text
61  * highlighting for disabled gadgets.
62  * 
63  * 9     1/30/99 9:01p Dave
64  * Coord fixes.
65  * 
66  * 8     1/30/99 5:08p Dave
67  * More new hi-res stuff.Support for nice D3D textures.
68  * 
69  * 7     1/29/99 12:47a Dave
70  * Put in sounds for beam weapon. A bunch of interface screens (tech
71  * database stuff).
72  * 
73  * 6     1/28/99 1:46a Dave
74  * Updated coords and bitmaps.
75  * 
76  * 5     1/14/99 5:15p Neilk
77  * changed credits, command debrief interfaces to high resolution support
78  * 
79  * 4     11/20/98 4:08p Dave
80  * Fixed flak effect in multiplayer.
81  * 
82  * 3     10/13/98 9:28a Dave
83  * Started neatening up freespace.h. Many variables renamed and
84  * reorganized. Added AlphaColors.[h,cpp]
85  * 
86  * 2     10/07/98 10:53a Dave
87  * Initial checkin.
88  * 
89  * 1     10/07/98 10:49a Dave
90  * 
91  * 18    6/19/98 3:51p Lawrance
92  * deal with foreign chars in the credits
93  * 
94  * 17    6/01/98 11:43a John
95  * JAS & MK:  Classified all strings for localization.
96  * 
97  * 16    5/24/98 9:01p Lawrance
98  * Add commit sounds when accept is pressed
99  * 
100  * 15    5/20/98 1:04p Hoffoss
101  * Made credits screen use new artwork and removed rating field usage from
102  * Fred (a goal struct member).
103  * 
104  * 14    5/12/98 4:17p Hoffoss
105  * Make ctrl-arrows (up/down) switch between tech room screens.
106  * 
107  * 13    5/12/98 11:21a Hoffoss
108  * Disabled cutscene screen and simulator room.
109  * 
110  * 12    5/11/98 8:04p Hoffoss
111  * Fixed minor bugs.
112  * 
113  * 11    4/22/98 3:35p John
114  * String externalization marking
115  * 
116  * 10    4/22/98 10:46a Hoffoss
117  * Added images to credits screen.
118  * 
119  * 9     4/21/98 7:07p Hoffoss
120  * Fixed problem where when switching screens flashes old tab hilight once
121  * before switching to new state.
122  * 
123  * 8     4/17/98 3:28p Hoffoss
124  * Added new credits screen code.
125  * 
126  * 7     3/05/98 11:15p Hoffoss
127  * Changed non-game key checking to use game_check_key() instead of
128  * game_poll().
129  * 
130  * 6     2/22/98 12:19p John
131  * Externalized some strings
132  * 
133  * 5     1/05/98 2:30p John
134  * made credits.tbl display
135  * 
136  * 4     9/19/97 5:14p Lawrance
137  * use new naming convention for spooled music
138  * 
139  * 3     8/31/97 6:38p Lawrance
140  * pass in frametime to do_frame loop
141  * 
142  * 2     4/22/97 11:06a Lawrance
143  * credits music playing, credits screen is a separate state
144  *
145  * $NoKeywords: $
146  */
147
148 #include <stdlib.h>
149
150 #include "gamesequence.h"
151 #include "font.h"
152 #include "key.h"
153 #include "bmpman.h"
154 #include "2d.h"
155 #include "timer.h"
156 #include "gamesnd.h"
157 #include "audiostr.h"
158 #include "eventmusic.h" /* for Master_event_music_volume */
159 #include "cfile.h"
160 #include "ui.h"
161 #include "missionscreencommon.h"
162 #include "player.h"
163 #include "freespace.h"
164 #include "alphacolors.h"
165 #include "localize.h"
166
167 #define CREDITS_MUSIC_DELAY     2000
168 #define CREDITS_SCROLL_RATE     15.0f
169 #define CREDITS_ARTWORK_DISPLAY_TIME    9.0f
170 #define CREDITS_ARTWORK_FADE_TIME               1.0f
171
172 #define NUM_BUTTONS                             5
173 #define NUM_IMAGES                              46
174
175 #define TECH_DATABASE_BUTTON    0
176 #define SIMULATOR_BUTTON                1
177 #define CUTSCENES_BUTTON                2
178 #define CREDITS_BUTTON                  3
179 #define EXIT_BUTTON                             4
180
181 // inidicies for coordinates
182 #define CREDITS_X_COORD 0
183 #define CREDITS_Y_COORD 1
184 #define CREDITS_W_COORD 2
185 #define CREDITS_H_COORD 3
186
187 static char* Credits_bitmap_fname[GR_NUM_RESOLUTIONS] = {
188         "Credits",                      // GR_640
189         "2_Credits"
190 };
191
192 static char* Credits_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = {
193         "Credits-M",                    // GR_640
194         "2_Credits-M"
195 };
196
197 int Credits_image_coords[GR_NUM_RESOLUTIONS][4] = {
198         {
199                 219, 15, 394, 286                       // GR_640
200         },
201         {
202                 351, 25, 629, 455                       // GR_1024
203         }
204 };
205
206 // x, y, w, h
207 int Credits_text_coords[GR_NUM_RESOLUTIONS][4] = {
208         {
209                 26, 316, 482, 157                       // GR_640
210         },
211         {
212                 144, 507, 568, 249                      // GR_640
213         }
214 };
215
216 struct credits_screen_buttons {
217         char *filename;
218         int x, y, xt, yt;
219         int hotspot;
220         UI_BUTTON button;  // because we have a class inside this struct, we need the constructor below..
221
222         credits_screen_buttons(char *name, int x1, int y1, int xt1, int yt1, int h) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h) {}
223 };
224
225 static int Background_bitmap;
226 /*
227 static int CreditsWin01 = -1;
228 static int CreditsWin02 = -1;
229 static int CreditsWin03 = -1;
230 static int CreditsWin04 = -1;
231 */
232 static UI_WINDOW Ui_window;
233
234 static credits_screen_buttons Buttons[NUM_BUTTONS][GR_NUM_RESOLUTIONS] = {
235 //XSTR:OFF
236         {
237                         credits_screen_buttons("TDB_00", 7, 3, 37, 7, 0),                       // GR_640
238                         credits_screen_buttons("2_TDB_00", 12, 5, 59, 12, 0)                    // GR_1024
239         },
240         {
241                         credits_screen_buttons("TDB_01", 7, 18, 37, 23, 1),             // GR_640
242                         credits_screen_buttons("2_TDB_01", 12, 31, 59, 37, 1)           // GR_1024
243         },
244         {
245                         credits_screen_buttons("TDB_02", 7, 34, 37, 38, 2),             // GR_640
246                         credits_screen_buttons("2_TDB_02", 12, 56, 59, 62, 2)           // GR_1024
247         },
248         {
249                         credits_screen_buttons("TDB_03", 7, 49, 37, 54, 3),             // GR_640
250                         credits_screen_buttons("2_TDB_03", 12, 81, 59, 88, 3)           // GR_1024
251         },
252         {
253                         credits_screen_buttons("CRB_04", 571, 425, 588, 413, 4),        // GR_640
254                         credits_screen_buttons("2_CRB_04", 914, 681, 953, 668, 4)       // GR_1024
255         }
256 //XSTR:ON
257 };
258
259 static int      Credits_music_handle = -1;
260 static int      Credits_music_begin_timestamp;
261
262 static int      Credits_frametime;              // frametime of credits_do_frame() loop in ms
263 static int      Credits_last_time;              // timestamp used to calc frametime (in ms)
264 static float Credits_counter;
265 static int Credits_artwork_index;
266 static int Credits_bmps[NUM_IMAGES];
267
268 char *Credit_text = NULL;
269 int Credit_text_malloced = 0;                   // TRUE if credit_text was malloced
270
271 // Positions for credits...
272 float Credit_start_pos, Credit_stop_pos, Credit_position = 0.0f;
273
274 void credits_stop_music()
275 {
276         if ( Credits_music_handle != -1 ) {
277                 audiostream_close_file(Credits_music_handle);
278                 Credits_music_handle = -1;
279         }
280 }
281
282 void credits_load_music(char* fname)
283 {
284         if ( Credits_music_handle != -1 ){
285                 return;
286         }
287
288         if ( fname ){
289                 Credits_music_handle = audiostream_open( fname, ASF_EVENTMUSIC );
290         }
291 }
292
293 void credits_start_music()
294 {
295         if (Credits_music_handle != -1) {
296                 if ( !audiostream_is_playing(Credits_music_handle) ){
297                         audiostream_play(Credits_music_handle, Master_event_music_volume);
298                 }
299         } else {
300                 nprintf(("Warning", "Cannot play credits music\n"));
301         }
302 }
303
304 int credits_screen_button_pressed(int n)
305 {
306         switch (n) {
307         case TECH_DATABASE_BUTTON:
308                 gamesnd_play_iface(SND_SWITCH_SCREENS);
309                 gameseq_post_event(GS_EVENT_TECH_MENU);
310                 return 1;
311
312         case SIMULATOR_BUTTON:
313                 gamesnd_play_iface(SND_SWITCH_SCREENS);
314                 gameseq_post_event(GS_EVENT_SIMULATOR_ROOM);
315                 return 1;
316
317         case CUTSCENES_BUTTON:
318                 gamesnd_play_iface(SND_SWITCH_SCREENS);
319                 gameseq_post_event(GS_EVENT_GOTO_VIEW_CUTSCENES_SCREEN);
320                 return 1;
321
322         case EXIT_BUTTON:
323                 gamesnd_play_iface(SND_COMMIT_PRESSED);
324                 gameseq_post_event(GS_EVENT_MAIN_MENU);
325                 game_flush();
326                 break;
327         }
328
329         return 0;
330 }
331
332 void credits_init()
333 {
334         int i, w, h;
335         credits_screen_buttons *b;
336         char line[512] = "";    
337         char *linep1, *linep2;  
338
339         int credits_spooled_music_index = event_music_get_spooled_music_index("Cinema");        
340         if(credits_spooled_music_index != -1){
341                 char *credits_wavfile_name = Spooled_music[credits_spooled_music_index].filename;               
342                 if(credits_wavfile_name != NULL){
343                         credits_load_music(credits_wavfile_name);
344                 }
345         }
346
347         // Use this id to trigger the start of music playing on the briefing screen
348         Credits_music_begin_timestamp = timestamp(CREDITS_MUSIC_DELAY);
349
350         Credits_frametime = 0;
351         Credits_last_time = timer_get_milliseconds();
352
353         Credit_text = NULL;
354         Credit_text_malloced = 0;
355
356         // allocate enough space for credits text
357         CFILE *fp = cfopen( NOX("credits.tbl"), "rb" );
358         if(fp != NULL){
359                 int size;
360                 size = cfilelength(fp);
361                 Credit_text = (char *) malloc(size + 200);
362                 cfclose(fp);
363
364                 // open localization and parse
365                 lcl_ext_open();
366                 read_file_text("credits.tbl");
367                 reset_parse();
368
369                 // keep reading everything in
370                 strcpy(Credit_text,"");         
371                 while(!check_for_string_raw("#end")){                   
372                         stuff_string_line(line, 511);
373                         linep1 = line;
374
375                         do {
376                                 linep2 = split_str_once(linep1, Credits_text_coords[gr_screen.res][2]);
377                                 strcat(Credit_text, linep1);
378                                 strcat(Credit_text, "\n");                      
379                                 linep1 = linep2;
380                         } while (linep2 != NULL);
381                 }               
382
383                 // close localization
384                 lcl_ext_close();        
385         } else {
386                 Credit_text = NOX("No credits available.\n");
387         }       
388
389         int ch;
390         for ( i = 0; Credit_text[i]; i++ ) {
391                         ch = Credit_text[i];
392                         switch (ch) {
393                         case -4:
394                                 ch = 129;
395                                 break;
396
397                         case -28:
398                                 ch = 132;
399                                 break;
400
401                         case -10:
402                                 ch = 148;
403                                 break;
404
405                         case -23:
406                                 ch = 130;
407                                 break;
408
409                         case -30:
410                                 ch = 131;
411                                 break;
412
413                         case -25:
414                                 ch = 135;
415                                 break;
416
417                         case -21:
418                                 ch = 137;
419                                 break;
420
421                         case -24:
422                                 ch = 138;
423                                 break;
424
425                         case -17:
426                                 ch = 139;
427                                 break;
428
429                         case -18:
430                                 ch = 140;
431                                 break;
432
433                         case -60:
434                                 ch = 142;
435                                 break;
436
437                         case -55:
438                                 ch = 144;
439                                 break;
440
441                         case -12:
442                                 ch = 147;
443                                 break;
444
445                         case -14:
446                                 ch = 149;
447                                 break;
448
449                         case -5:
450                                 ch = 150;
451                                 break;
452
453                         case -7:
454                                 ch = 151;
455                                 break;
456
457                         case -42:
458                                 ch = 153;
459                                 break;
460
461                         case -36:
462                                 ch = 154;
463                                 break;
464
465                         case -31:
466                                 ch = 160;
467                                 break;
468
469                         case -19:
470                                 ch = 161;
471                                 break;
472
473                         case -13:
474                                 ch = 162;
475                                 break;
476
477                         case -6:
478                                 ch = 163;
479                                 break;
480
481                         case -32:
482                                 ch = 133;
483                                 break;
484
485                         case -22:
486                                 ch = 136;
487                                 break;
488
489                         case -20:
490                                 ch = 141;
491                                 break;
492                         }
493                         Credit_text[i] = (char)ch;
494         }
495
496         gr_get_string_size(&w, &h, Credit_text);
497
498         Credit_start_pos = i2fl(Credits_text_coords[gr_screen.res][CREDITS_H_COORD]);
499         Credit_stop_pos = -i2fl(h);
500         Credit_position = Credit_start_pos;
501
502         Ui_window.create(0, 0, gr_screen.max_w, gr_screen.max_h, 0);
503         Ui_window.set_mask_bmap(Credits_bitmap_mask_fname[gr_screen.res]);
504         common_set_interface_palette("InterfacePalette");  // set the interface palette
505
506         for (i=0; i<NUM_BUTTONS; i++) {
507                 b = &Buttons[i][gr_screen.res];
508
509                 b->button.create(&Ui_window, "", b->x, b->y, 60, 30, (i < 2), 1);
510                 // set up callback for when a mouse first goes over a button
511                 b->button.set_highlight_action(common_play_highlight_sound);
512                 b->button.set_bmaps(b->filename);
513                 b->button.link_hotspot(b->hotspot);
514         }
515
516         // add some text
517         Ui_window.add_XSTR("Technical Database", 1055, Buttons[TECH_DATABASE_BUTTON][gr_screen.res].xt,  Buttons[TECH_DATABASE_BUTTON][gr_screen.res].yt, &Buttons[TECH_DATABASE_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_GREEN);
518         Ui_window.add_XSTR("Mission Simulator", 1056, Buttons[SIMULATOR_BUTTON][gr_screen.res].xt,  Buttons[SIMULATOR_BUTTON][gr_screen.res].yt, &Buttons[SIMULATOR_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_GREEN);
519         Ui_window.add_XSTR("Cutscenes", 1057, Buttons[CUTSCENES_BUTTON][gr_screen.res].xt,  Buttons[CUTSCENES_BUTTON][gr_screen.res].yt, &Buttons[CUTSCENES_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_GREEN);
520         Ui_window.add_XSTR("Credits", 1058, Buttons[CREDITS_BUTTON][gr_screen.res].xt,  Buttons[CREDITS_BUTTON][gr_screen.res].yt, &Buttons[CREDITS_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_GREEN);
521         Ui_window.add_XSTR("Exit", 1420, Buttons[EXIT_BUTTON][gr_screen.res].xt,  Buttons[EXIT_BUTTON][gr_screen.res].yt, &Buttons[EXIT_BUTTON][gr_screen.res].button, UI_XSTR_COLOR_PINK);
522
523         if (Player->flags & PLAYER_FLAGS_IS_MULTI) {
524                 Buttons[SIMULATOR_BUTTON][gr_screen.res].button.disable();
525                 Buttons[CUTSCENES_BUTTON][gr_screen.res].button.disable();
526         }
527
528         Buttons[EXIT_BUTTON][gr_screen.res].button.set_hotkey(KEY_CTRLED | KEY_ENTER);
529
530         Background_bitmap = bm_load(Credits_bitmap_fname[gr_screen.res]);
531         Credits_artwork_index = rand() % NUM_IMAGES;
532         for (i=0; i<NUM_IMAGES; i++){
533                 Credits_bmps[i] = -1;
534         }
535
536         // CreditsWin01 = bm_load(NOX("CreditsWin01"));
537         // CreditsWin02 = bm_load(NOX("CreditsWin02"));
538         // CreditsWin03 = bm_load(NOX("CreditsWin03"));
539         // CreditsWin04 = bm_load(NOX("CreditsWin04"));
540 }
541
542 void credits_close()
543 {       
544         int i;
545
546         /*
547         if (CreditsWin01 != -1){
548                 bm_unload(CreditsWin01);
549                 CreditsWin01 = -1;
550         }
551         if (CreditsWin02 != -1){
552                 bm_unload(CreditsWin02);
553                 CreditsWin02 = -1;
554         }
555         if (CreditsWin03 != -1){
556                 bm_unload(CreditsWin03);
557                 CreditsWin03 = -1;
558         }
559         if (CreditsWin04 != -1){
560                 bm_unload(CreditsWin04);
561                 CreditsWin04 = -1;
562         }
563         */
564
565         for (i=0; i<NUM_IMAGES; i++){
566                 if (Credits_bmps[i] >= 0){
567                         bm_unload(Credits_bmps[i]);
568                         Credits_bmps[i] = -1;
569                 }
570         }       
571
572         credits_stop_music();
573
574         if (Credit_text) {
575                 if (Credit_text_malloced){
576                         free(Credit_text);
577                 }
578
579                 Credit_text = NULL;
580         }
581
582         if (Background_bitmap){
583                 bm_unload(Background_bitmap);
584         }
585
586         Ui_window.destroy();
587         common_free_interface_palette();                // restore game palette
588 }
589
590 void credits_do_frame(float frametime)
591 {
592         int i, k, next, percent, bm1, bm2;
593         int bx1, by1, bw1, bh1;
594         int bx2, by2, bw2, bh2;
595
596         // Use this id to trigger the start of music playing on the credits screen
597         if ( timestamp_elapsed(Credits_music_begin_timestamp) ) {
598                 Credits_music_begin_timestamp = 0;
599                 credits_start_music();
600         }
601
602         k = Ui_window.process();
603         switch (k) {
604         case KEY_ESC:
605                 gameseq_post_event(GS_EVENT_MAIN_MENU);
606                 key_flush();
607                 break;
608
609         case KEY_CTRLED | KEY_UP:
610         case KEY_SHIFTED | KEY_TAB:
611                 if ( !(Player->flags & PLAYER_FLAGS_IS_MULTI) ) {
612                         credits_screen_button_pressed(CUTSCENES_BUTTON);
613                         break;
614                 }
615                 // else, react like tab key.
616
617         case KEY_CTRLED | KEY_DOWN:
618         case KEY_TAB:
619                 credits_screen_button_pressed(TECH_DATABASE_BUTTON);
620                 break;
621
622         default:
623                 break;
624         } // end switch
625
626         for (i=0; i<NUM_BUTTONS; i++){
627                 if (Buttons[i][gr_screen.res].button.pressed()){
628                         if (credits_screen_button_pressed(i)){
629                                 return;
630                         }
631                 }
632         }
633
634         gr_reset_clip();        
635         GR_MAYBE_CLEAR_RES(Background_bitmap);
636         if (Background_bitmap >= 0) {
637                 gr_set_bitmap(Background_bitmap);
638                 gr_bitmap(0, 0);
639         } 
640
641         percent = (int) (100.0f - (CREDITS_ARTWORK_DISPLAY_TIME - Credits_counter) * 100.0f / CREDITS_ARTWORK_FADE_TIME);
642         if (percent < 0){
643                 percent = 0;
644         }
645
646         next = Credits_artwork_index + 1;
647         if (next >= NUM_IMAGES){
648                 next = 0;
649         }
650
651         if (Credits_bmps[Credits_artwork_index] < 0) {
652                 char buf[40];
653
654                 if (gr_screen.res == GR_1024) {
655                         sprintf(buf, NOX("2_CrIm%0.2d"), Credits_artwork_index);
656                 } else {
657                         sprintf(buf, NOX("CrIm%0.2d"), Credits_artwork_index);
658                 }
659                 Credits_bmps[Credits_artwork_index] = bm_load(buf);
660         }
661
662         if (Credits_bmps[next] < 0) {
663                 char buf[40];
664
665                 if (gr_screen.res == GR_1024) {
666                         sprintf(buf, NOX("2_CrIm%0.2d"), Credits_artwork_index);
667                 } else {
668                         sprintf(buf, NOX("CrIm%0.2d"), next);
669                 }
670                 Credits_bmps[next] = bm_load(buf);
671         }
672
673         bm1 = Credits_bmps[Credits_artwork_index];
674         bm2 = Credits_bmps[next];
675
676         if((bm1 != -1) && (bm2 != -1)){
677                 Assert(percent >= 0 && percent <= 100);
678
679                 // get width and height
680                 bm_get_info(bm1, &bw1, &bh1, NULL, NULL, NULL); 
681                 bm_get_info(bm2, &bw2, &bh2, NULL, NULL, NULL); 
682         
683                 // determine where to draw the coords
684                 bx1 = Credits_image_coords[gr_screen.res][CREDITS_X_COORD] + ((Credits_image_coords[gr_screen.res][CREDITS_W_COORD] - bw1)/2);
685                 by1 = Credits_image_coords[gr_screen.res][CREDITS_Y_COORD] + ((Credits_image_coords[gr_screen.res][CREDITS_H_COORD] - bh1)/2);
686                 bx2 = Credits_image_coords[gr_screen.res][CREDITS_X_COORD] + ((Credits_image_coords[gr_screen.res][CREDITS_W_COORD] - bw2)/2);
687                 by2 = Credits_image_coords[gr_screen.res][CREDITS_Y_COORD] + ((Credits_image_coords[gr_screen.res][CREDITS_H_COORD] - bh2)/2);
688
689                 gr_cross_fade(bm1, bm2, bx1, by1, bx2, by2, (float)percent / 100.0f);
690         }
691
692         /*
693         if (CreditsWin01 != -1) {
694                 gr_set_bitmap(CreditsWin01);
695                 gr_bitmap(233, 5);
696         }
697
698         if (CreditsWin02 != -1) {
699                 gr_set_bitmap(CreditsWin02);
700                 gr_bitmap(616, 8);
701         }
702
703         if (CreditsWin03 != -1) {
704                 gr_set_bitmap(CreditsWin03);
705                 gr_bitmap(233, 299);
706         }
707
708         if (CreditsWin04 != -1) {
709                 gr_set_bitmap(CreditsWin04);
710                 gr_bitmap(215, 8);
711         }
712         */
713
714         Ui_window.draw();
715
716         for (i=TECH_DATABASE_BUTTON; i<=CREDITS_BUTTON; i++){
717                 if (Buttons[i][gr_screen.res].button.button_down()){
718                         break;
719                 }
720         }
721
722         if (i > CREDITS_BUTTON){
723                 Buttons[CREDITS_BUTTON][gr_screen.res].button.draw_forced(2);
724         }
725
726         gr_set_clip(Credits_text_coords[gr_screen.res][CREDITS_X_COORD], Credits_text_coords[gr_screen.res][CREDITS_Y_COORD], Credits_text_coords[gr_screen.res][CREDITS_W_COORD], Credits_text_coords[gr_screen.res][CREDITS_H_COORD]);
727         gr_set_font(FONT1);
728         gr_set_color_fast(&Color_normal);
729
730         int sy;
731         if ( Credit_position > 0 ) {
732                 sy = fl2i(Credit_position+0.5f);
733         } else {
734                 sy = fl2i(Credit_position-0.5f);
735         }
736
737         // HACK - I don't want to change the string code, so we'll just use a special version here
738         if(gr_screen.mode == GR_GLIDE){
739 #ifndef PLAT_UNIX
740                 extern void gr_glide_string_hack(int sx, int sy, char *s);
741                 gr_glide_string_hack(0x8000, sy, Credit_text);
742 #endif
743         } else {
744                 gr_string(0x8000, sy, Credit_text);
745         }
746
747         int temp_time;
748         temp_time = timer_get_milliseconds();
749
750         Credits_frametime = temp_time - Credits_last_time;
751         Credits_last_time = temp_time;
752         timestamp_inc(Credits_frametime / 1000.0f);
753
754         float fl_frametime = i2fl(Credits_frametime) / 1000.f;
755         if (keyd_pressed[KEY_LSHIFT]) {
756                 Credit_position -= fl_frametime * CREDITS_SCROLL_RATE * 4.0f;
757         } else {
758                 Credit_position -= fl_frametime * CREDITS_SCROLL_RATE;
759         }
760
761         if (Credit_position < Credit_stop_pos){
762                 Credit_position = Credit_start_pos;
763         }
764
765         Credits_counter += fl_frametime;
766         while (Credits_counter >= CREDITS_ARTWORK_DISPLAY_TIME) {
767                 Credits_counter -= CREDITS_ARTWORK_DISPLAY_TIME;
768                 Credits_artwork_index = next;
769         }
770
771         gr_flip();
772 }
773