Author Topic: [Request] Per-Mission Briefing Backgrounds  (Read 4312 times)

0 Members and 1 Guest are viewing this topic.

Offline Yarn

  • 210
Re: [Request] Per-Mission Briefing Backgrounds
I'm actually almost ready to post a PR. The only thing that isn't finished yet is the fiction viewer.
"Your fighter is running out of oil.  Please check under the hood and add more if necessary"
--strings.tbl, entry 177

"Freespace is very tired.  It is shutting down to get some rest."
--strings.tbl, entry 178

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: [Request] Per-Mission Briefing Backgrounds
It will be the battle of the PRs then!  Did you use a common function for saving data to the mission file and loading the background bitmap?  Because I realized that the same common function used for loading from the mission file could be applied to the other two cases:

Code: [Select]
void CFred_mission_save::save_custom_bitmap(const char *expected_string_640, const char *expected_string_1024, const char *string_field_640, const char *string_field_1024)
{
if (Format_fs2_open != FSO_FORMAT_RETAIL)
{
if (*string_field_640 != '\0')
{
fout("\n%s %s", expected_string_640, string_field_640);
}

if (*string_field_640 != '\0')
{
fout("\n%s %s", expected_string_1024, string_field_1024);
}
}
}

Code: [Select]
// Try to load background bitmaps as appropriate
int mission_ui_background_load(const char *custom_background, const char *single_background, const char *multi_background)
{
int background_bitmap = -1;

if (*custom_background != '\0')
{
background_bitmap = bm_load(custom_background);
if (background_bitmap < 0)
mprintf(("Failed to load custom background bitmap %s!\n", custom_background));
}

// if special background failed to load, or if no special background was supplied, load the standard bitmap
if (background_bitmap < 0)
{
if (Game_mode & GM_MULTIPLAYER)
background_bitmap = bm_load(multi_background);
else
background_bitmap = bm_load(single_background);
}

// return what we've got
return background_bitmap;
}

With these functions, the code across all background bitmaps is the same, with only minimal work to link them together.

 

Offline Yarn

  • 210
Re: [Request] Per-Mission Briefing Backgrounds
I'll add those functions to my branch (which you can find here: https://github.com/Yarn366/fs2open.github.com/tree/per_mission_ui_backgrounds).
"Your fighter is running out of oil.  Please check under the hood and add more if necessary"
--strings.tbl, entry 177

"Freespace is very tired.  It is shutting down to get some rest."
--strings.tbl, entry 178

 

Offline Yarn

  • 210
Re: [Request] Per-Mission Briefing Backgrounds
Here's my pull request: https://github.com/scp-fs2open/fs2open.github.com/pull/353
And here are some test builds: https://dl.dropboxusercontent.com/u/89353583/FreeSpace/per_mission_ui_backgrounds.7z

For briefing backgrounds, use this syntax in the #Briefing section, just below $start_briefing:
Code: [Select]
$briefing_background_640: image.png
$briefing_background_1024: 2_image.png
$ship_select_background_640: image.png
$ship_select_background_1024: 2_image.png
$weapon_select_background_640: image.png
$weapon_select_background_1024: 2_image.png
The $briefing_background_xxx fields apply to both standard and red-alert briefings.

For debriefings, command briefings, and the fiction viewer, use this syntax at the beginning of the appropriate section:
Code: [Select]
$Background 640: image.png
$Background 1024: 2_image.png
Keep in mind that if you specify a fiction viewer background, then the FreeSpace 2 layout will be used unless an explicit layout is specified via one of the methods below.

All fields above apply to both single-player and multiplayer. Also, in team-vs.-team missions, you need to specify custom backgrounds for every team that should use them.

I also added two ways of setting which fiction viewer layout to use. One way is to specify it in the mission file. To do so, add the following line just below the $Background xxx fields in the fiction viewer section (assuming they exist):
Code: [Select]
$UI: FS2 ;; can be "FS2" (for FreeSpace 2) or "WCS" (for Wing Commander Saga)

You can also specify the layout in game_settings.tbl. To do so, place the following line in the #OTHER SETTINGS section just after $Beams Use Damage Factors (if it exists):
Code: [Select]
$Default fiction viewer UI: FS2 ;; can be "FS2", "WCS", or "auto" (the default setting)
Missions that specify a fiction viewer UI will override this setting.


None of this can be edited in FRED yet, although these fields should be preserved when the mission is resaved.
"Your fighter is running out of oil.  Please check under the hood and add more if necessary"
--strings.tbl, entry 177

"Freespace is very tired.  It is shutting down to get some rest."
--strings.tbl, entry 178

  

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: [Request] Per-Mission Briefing Backgrounds
Super. :yes:  I will check out the PR.

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: [Request] Per-Mission Briefing Backgrounds
Question. How does this code handle CommanBrief vs CommandBriefB? (The B version has the scroll buttons for text that goes below the text box.) Does this code consider that or is that the responsibility of the modder?
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: [Request] Per-Mission Briefing Backgrounds
Yarn's code assumes that if you specify a custom command briefing background, it will be the type that supports scroll buttons.

Also, I merged the PR, so it should appear in the next nightly build.  Be advised that $background_640 was changed to $briefing_background_640 (and ditto for 1024), since there are now ship and weapon selection background definitions in the same section.

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: [Request] Per-Mission Briefing Backgrounds
OK, that works for me! I just tested everything out and it works great.

BtA has no more holdout features for a new SCP release.
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline Echelon9

  • 210
Re: [Request] Per-Mission Briefing Backgrounds
The initial implementation of this feature in the FS2Open engine has incorrectly used low-level memory handling.

See here for the comment. Would strongly advise you await a release with the eventual fix for this (should be simple enough).

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: [Request] Per-Mission Briefing Backgrounds
Err, crap.  Will fix that.

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: [Request] Per-Mission Briefing Backgrounds
I submitted a PR.

During my search through the codebase for other instances of similar errors, I ran across this bit in the options_multi_vox_button_pressed() function in optionsmenumulti.cpp:
Code: [Select]
// clear the comp buffer
memset(Om_vox_comp_buffer,128,OM_VOX_COMP_SIZE);

The value 128 doesn't fit in an unsigned char, so this may not produce the expected result.  (I'm surprised this hasn't been found by clang.  Technically the middle argument is an int but it's always converted to unsigned char.)

 

Offline m!m

  • 211
Re: [Request] Per-Mission Briefing Backgrounds
If it's an unsigned char then the biggest value is 256 so 128 is a valid value. However "clearing" a buffer by setting every byte to 128 seems a little weird so it might be some kind of programming error.