Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: mjn.mixael on June 10, 2011, 01:10:36 pm

Title: Credits.tbl
Post by: mjn.mixael on June 10, 2011, 01:10:36 pm
I was hoping to get a little more control for the credits screen.

Basically, the images currently are chosen at random.. sorta of. I watched it a couple different times and checked out the code. I'm pretty sure that currently FSO chooses one random start image index and the plays through the credits images in sequence. I'm 99% sure this is the way it works.

I'm thinking to simply add a check for a flag in the credits table (say.. $Start Image Index) where if the flag exists use that as the starting index, but if the flag is not present, go ahead and use the rand function (like it currently does).

I was wondering if anyone might be able to add this little option in there for me?
Title: Re: Credits.tbl
Post by: Goober5000 on June 10, 2011, 04:46:32 pm
Easily done.  Remind me later if someone else hasn't done it by then.
Title: Re: Credits.tbl
Post by: mjn.mixael on June 10, 2011, 05:48:33 pm
Great. Since it seems so easy, I went ahead and put a mantis request in.

http://scp.indiegames.us/mantis/view.php?id=2453 (http://scp.indiegames.us/mantis/view.php?id=2453)
Title: Re: Credits.tbl
Post by: portej05 on June 12, 2011, 08:49:42 pm
5 minute hack attempt to get @Goober5000 started - I'm not 100% about the file string handling.

Code: [Select]
Index: credits.cpp
===================================================================
--- credits.cpp (revision 7239)
+++ credits.cpp (working copy)
@@ -210,7 +210,7 @@
 static int Credits_frametime; // frametime of credits_do_frame() loop in ms
 static int Credits_last_time; // timestamp used to calc frametime (in ms)
 static float Credits_counter;
-static int Credits_artwork_index;
+static int Credits_artwork_index = -1;
 static int Credits_bmps[NUM_IMAGES];
 
 char *Credit_text = NULL;
@@ -326,6 +326,11 @@
  read_file_text("credits.tbl", CF_TYPE_TABLES);
  reset_parse();
 
+ if ( optional_string( "$Start Image Index:" ) )
+ {
+ stuff_int( &Credits_artwork_index );
+ }
+
  // keep reading everything in
  strcpy(Credit_text, fs2_open_credit_text);
     
@@ -505,7 +510,10 @@
  Buttons[EXIT_BUTTON][gr_screen.res].button.set_hotkey(KEY_CTRLED | KEY_ENTER);
 
  Background_bitmap = bm_load(Credits_bitmap_fname[gr_screen.res]);
- Credits_artwork_index = rand() % NUM_IMAGES;
+ if ( Credits_artwork_index == -1 )
+ {
+ Credits_artwork_index = rand() % NUM_IMAGES;
+ }
  for (i=0; i<NUM_IMAGES; i++){
  Credits_bmps[i] = -1;
  }


edit: Should mention that you put $Start Image Index: <integer> at the start of the table, and there's no bound checking done.
edit2: Should also mention that this hasn't really been tested...
Title: Re: Credits.tbl
Post by: Goober5000 on June 12, 2011, 10:36:51 pm
Heh... I've already coded it, but I did something very similar to what you did.  Except I included bounds checking. :p

Anyway, I'm committing it.  Though Mjn.Mixael, Mantis is really supposed to only be used for bugfixes, not feature requests.