2006-03-20 17:12:09 +00:00
/*
2014-06-01 17:55:23 +00:00
* Portions of this file are copyright Rebirth contributors and licensed as
* described in COPYING . txt .
* Portions of this file are copyright Parallax Software and licensed
* according to the Parallax license below .
* See COPYING . txt for license details .
2006-03-20 17:12:09 +00:00
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
SOFTWARE CORPORATION ( " PARALLAX " ) . PARALLAX , IN DISTRIBUTING THE CODE TO
END - USERS , AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN , GRANTS A
ROYALTY - FREE , PERPETUAL LICENSE TO SUCH END - USERS FOR USE BY SUCH END - USERS
IN USING , DISPLAYING , AND CREATING DERIVATIVE WORKS THEREOF , SO LONG AS
SUCH USE , DISPLAY OR CREATION IS FOR NON - COMMERCIAL , ROYALTY OR REVENUE
FREE PURPOSES . IN NO EVENT SHALL THE END - USER USE THE COMPUTER CODE
CONTAINED HEREIN FOR REVENUE - BEARING PURPOSES . THE END - USER UNDERSTANDS
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE .
COPYRIGHT 1993 - 1999 PARALLAX SOFTWARE CORPORATION . ALL RIGHTS RESERVED .
*/
/*
*
* Routines to display title screens . . .
*
*/
2016-09-24 18:06:10 +00:00
# include "dxxsconf.h"
2006-03-20 17:12:09 +00:00
# include <stdlib.h>
# include <stdio.h>
# include <string.h>
2016-09-24 18:06:11 +00:00
# if DXX_USE_OGL
2006-12-24 09:15:37 +00:00
# include "ogl_init.h"
# endif
2006-03-20 17:12:09 +00:00
# include "pstypes.h"
# include "timer.h"
# include "key.h"
# include "gr.h"
# include "palette.h"
# include "iff.h"
# include "pcx.h"
2014-07-20 01:09:55 +00:00
# include "physfsx.h"
2006-03-20 17:12:09 +00:00
# include "u_mem.h"
# include "joy.h"
2012-11-11 22:12:51 +00:00
# include "titles.h"
2006-03-20 17:12:09 +00:00
# include "gamefont.h"
2013-12-26 04:18:28 +00:00
# include "gameseq.h"
2012-07-07 18:35:06 +00:00
# include "dxxerror.h"
2015-04-02 02:36:57 +00:00
# include "robot.h"
2006-03-20 17:12:09 +00:00
# include "textures.h"
# include "screens.h"
# include "multi.h"
# include "player.h"
# include "digi.h"
# include "text.h"
# include "kmatrix.h"
# include "piggy.h"
# include "songs.h"
# include "newmenu.h"
# include "state.h"
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2006-03-20 17:12:09 +00:00
# include "movie.h"
2013-03-03 01:03:33 +00:00
# endif
2006-03-20 17:12:09 +00:00
# include "menu.h"
# include "mouse.h"
2008-04-06 20:23:28 +00:00
# include "console.h"
2013-03-03 19:41:09 +00:00
# include "args.h"
2013-12-26 04:18:28 +00:00
# include "strutil.h"
2006-03-20 17:12:09 +00:00
2014-08-16 04:15:16 +00:00
# include "compiler-make_unique.h"
2014-08-08 02:54:50 +00:00
# include "compiler-range_for.h"
# include "partial_range.h"
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
2016-07-16 16:52:04 +00:00
constexpr int EMULATING_D1 = 1 ;
2013-03-03 01:03:33 +00:00
# elif defined(DXX_BUILD_DESCENT_II)
2013-09-02 23:58:27 +00:00
static int DefineBriefingBox ( const char * * buf ) ;
2013-03-03 01:03:33 +00:00
# endif
2006-03-20 17:12:09 +00:00
# define MAX_BRIEFING_COLORS 7
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2006-03-20 17:12:09 +00:00
# define SHAREWARE_ENDING_FILENAME "ending.tex"
2013-03-03 01:03:33 +00:00
# endif
2010-03-09 02:41:34 +00:00
# define DEFAULT_BRIEFING_BKG "brief03.pcx"
2006-03-20 17:12:09 +00:00
2014-08-08 02:07:47 +00:00
static array < color_t , MAX_BRIEFING_COLORS > Briefing_text_colors ;
2013-06-08 23:34:31 +00:00
static int Current_color = 0 ;
2014-08-08 02:07:47 +00:00
static color_t Erase_color ;
2006-03-20 17:12:09 +00:00
// added by Jan Bobrowski for variable-size menu screen
static int rescale_x ( int x )
{
return x * GWIDTH / 320 ;
}
static int rescale_y ( int y )
{
return y * GHEIGHT / 200 ;
}
2015-08-12 03:11:46 +00:00
namespace {
2014-09-07 18:06:59 +00:00
struct title_screen : ignore_window_pointer_t
2006-03-20 17:12:09 +00:00
{
2016-10-29 23:16:15 +00:00
grs_main_bitmap title_bm ;
2010-12-10 23:18:17 +00:00
fix64 timer ;
2010-03-22 04:44:35 +00:00
int allow_keys ;
2013-12-22 22:03:07 +00:00
} ;
2006-03-20 17:12:09 +00:00
2015-08-12 03:11:46 +00:00
}
2016-10-04 06:05:44 +00:00
static window_event_result title_handler ( window * , const d_event & event , title_screen * ts )
2010-03-22 04:44:35 +00:00
{
2016-10-27 08:36:24 +00:00
window_event_result result ;
2014-10-04 21:47:13 +00:00
switch ( event . type )
2010-03-22 04:44:35 +00:00
{
2010-03-24 07:26:52 +00:00
case EVENT_MOUSE_BUTTON_DOWN :
2011-01-14 09:51:13 +00:00
if ( event_mouse_get_button ( event ) ! = 0 )
2014-08-06 02:10:49 +00:00
return window_event_result : : ignored ;
2010-03-24 07:26:52 +00:00
else if ( ts - > allow_keys )
{
2014-08-06 02:10:49 +00:00
return window_event_result : : close ;
2010-03-24 07:26:52 +00:00
}
break ;
2010-06-19 16:24:34 +00:00
2010-03-22 04:44:35 +00:00
case EVENT_KEY_COMMAND :
2016-10-27 08:36:24 +00:00
if ( ( result = call_default_handler ( event ) ) = = window_event_result : : ignored )
2010-04-02 05:01:08 +00:00
if ( ts - > allow_keys )
2014-08-06 02:10:49 +00:00
{
return window_event_result : : close ;
}
2016-10-27 08:36:24 +00:00
return result ;
2010-06-19 16:24:34 +00:00
2010-03-22 04:44:35 +00:00
case EVENT_IDLE :
timer_delay2 ( 50 ) ;
2010-12-10 23:18:17 +00:00
if ( timer_query ( ) > ts - > timer )
2010-03-22 04:44:35 +00:00
{
2014-08-06 02:10:49 +00:00
return window_event_result : : close ;
2010-03-22 04:44:35 +00:00
}
break ;
2010-06-19 16:24:34 +00:00
2010-03-22 04:44:35 +00:00
case EVENT_WINDOW_DRAW :
2010-07-15 09:45:25 +00:00
gr_set_current_canvas ( NULL ) ;
2017-01-01 00:45:43 +00:00
show_fullscr ( * grd_curcanv , ts - > title_bm ) ;
2010-03-22 04:44:35 +00:00
break ;
2006-03-20 17:12:09 +00:00
2010-03-22 04:44:35 +00:00
case EVENT_WINDOW_CLOSE :
break ;
2010-06-19 16:24:34 +00:00
2010-03-22 04:44:35 +00:00
default :
break ;
2006-03-20 17:12:09 +00:00
}
2014-08-06 02:10:49 +00:00
return window_event_result : : ignored ;
2006-03-20 17:12:09 +00:00
}
2015-04-02 02:36:55 +00:00
static void show_title_screen ( const char * filename , int allow_keys , int from_hog_only )
2006-03-20 17:12:09 +00:00
{
int pcx_error ;
2011-01-16 10:39:46 +00:00
char new_filename [ PATH_MAX ] = " " ;
2010-06-19 16:24:34 +00:00
2014-11-30 22:09:19 +00:00
auto ts = make_unique < title_screen > ( ) ;
2010-03-22 04:44:35 +00:00
ts - > allow_keys = allow_keys ;
2006-03-20 17:12:09 +00:00
2007-06-29 19:57:18 +00:00
# ifdef RELEASE
2006-03-20 17:12:09 +00:00
if ( from_hog_only )
strcpy ( new_filename , " \x01 " ) ; //only read from hog file
2015-01-18 01:58:33 +00:00
# else
( void ) from_hog_only ;
2007-06-29 19:57:18 +00:00
# endif
2006-03-20 17:12:09 +00:00
strcat ( new_filename , filename ) ;
filename = new_filename ;
2014-11-30 22:09:20 +00:00
gr_init_bitmap_data ( ts - > title_bm ) ;
2016-05-28 17:31:26 +00:00
if ( ( pcx_error = pcx_read_bitmap ( filename , ts - > title_bm , gr_palette ) ) ! = PCX_ERROR_NONE ) {
2006-03-20 17:12:09 +00:00
Error ( " Error loading briefing screen <%s>, PCX load error: %s (%i) \n " , filename , pcx_errormsg ( pcx_error ) , pcx_error ) ;
}
2010-12-10 23:18:17 +00:00
ts - > timer = timer_query ( ) + i2f ( 3 ) ;
2006-03-20 17:12:09 +00:00
2007-08-27 23:01:34 +00:00
gr_palette_load ( gr_palette ) ;
2006-03-20 17:12:09 +00:00
2016-10-15 00:53:20 +00:00
const auto wind = window_create ( grd_curscreen - > sc_canvas , 0 , 0 , SWIDTH , SHEIGHT , title_handler , ts . get ( ) ) ;
2010-03-22 04:44:35 +00:00
if ( ! wind )
{
2015-04-02 02:36:55 +00:00
return ;
2010-03-22 04:44:35 +00:00
}
2010-06-19 16:24:34 +00:00
2016-10-29 12:06:01 +00:00
event_process_all ( ) ;
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2006-10-02 13:51:05 +00:00
int intro_played = 0 ;
2015-10-09 02:46:11 +00:00
# endif
2015-04-02 02:36:55 +00:00
static void show_first_found_title_screen ( const char * oem , const char * share , const char * macshare )
{
const char * filename = oem ;
if ( ( PHYSFSX_exists ( filename , 1 ) ) | |
( filename = share , PHYSFSX_exists ( filename , 1 ) ) | |
( filename = macshare , PHYSFSX_exists ( filename , 1 ) )
)
show_title_screen ( filename , 1 , 1 ) ;
}
2006-10-02 13:51:05 +00:00
2016-08-25 04:05:32 +00:00
namespace dsx {
2006-10-02 13:51:05 +00:00
void show_titles ( void )
{
2016-08-28 22:41:49 +00:00
# if defined(DXX_BUILD_DESCENT_I)
songs_play_song ( SONG_TITLE , 1 ) ;
# endif
2015-12-24 04:01:27 +00:00
if ( CGameArg . SysNoTitles )
2013-03-03 01:03:33 +00:00
return ;
2015-10-09 02:46:09 +00:00
# if defined(DXX_BUILD_DESCENT_I)
2013-03-03 01:03:33 +00:00
2015-10-09 02:46:11 +00:00
show_first_found_title_screen (
" macplay.pcx " , // Mac Shareware
" mplaycd.pcx " , // Mac Registered
" iplogo1.pcx " // PC. Only down here because it's lowres ;-)
) ;
2016-07-31 22:25:49 +00:00
const bool resolution_at_least_640_480 = ( SWIDTH > = 640 & & SHEIGHT > = 480 ) ;
auto & logo_hires_pcx = " logoh.pcx " ;
auto & descent_hires_pcx = " descenth.pcx " ;
show_title_screen ( ( resolution_at_least_640_480 & & PHYSFSX_exists ( logo_hires_pcx , 1 ) ) ? logo_hires_pcx : " logo.pcx " , 1 , 1 ) ;
show_title_screen ( ( resolution_at_least_640_480 & & PHYSFSX_exists ( descent_hires_pcx , 1 ) ) ? descent_hires_pcx : " descent.pcx " , 1 , 1 ) ;
2013-03-03 01:03:33 +00:00
# elif defined(DXX_BUILD_DESCENT_II)
2006-10-02 13:51:05 +00:00
int played = MOVIE_NOT_PLAYED ; //default is not played
int song_playing = 0 ;
2010-04-05 11:54:23 +00:00
# define MOVIE_REQUIRED 1 //(!is_D2_OEM && !is_SHAREWARE && !is_MAC_SHARE) // causes segfault
2006-10-02 13:51:05 +00:00
2016-07-31 22:25:49 +00:00
const auto hiresmode = HIRESMODE ;
2006-10-02 13:51:05 +00:00
{ //show bundler screens
played = MOVIE_NOT_PLAYED ; //default is not played
2013-10-27 21:01:04 +00:00
played = PlayMovie ( NULL , " pre_i.mve " , 0 ) ;
2006-10-02 13:51:05 +00:00
if ( ! played ) {
2015-04-02 02:36:55 +00:00
char filename [ 12 ] ;
2016-07-31 22:25:49 +00:00
strcpy ( filename , hiresmode ? " pre_i1b.pcx " : " pre_i1.pcx " ) ;
2006-10-02 13:51:05 +00:00
2011-06-01 07:59:55 +00:00
while ( PHYSFSX_exists ( filename , 0 ) )
2006-10-02 13:51:05 +00:00
{
show_title_screen ( filename , 1 , 0 ) ;
filename [ 5 ] + + ;
}
}
}
2013-10-27 21:01:04 +00:00
played = PlayMovie ( " intro.tex " , " intro.mve " , MOVIE_REQUIRED ) ;
2006-10-02 13:51:05 +00:00
if ( played ! = MOVIE_NOT_PLAYED )
intro_played = 1 ;
else
{ //didn't get intro movie, try titles
2013-10-27 21:01:04 +00:00
played = PlayMovie ( NULL , " titles.mve " , MOVIE_REQUIRED ) ;
2006-10-02 13:51:05 +00:00
if ( played = = MOVIE_NOT_PLAYED )
{
con_printf ( CON_DEBUG , " \n Playing title song... " ) ;
songs_play_song ( SONG_TITLE , 1 ) ;
song_playing = 1 ;
con_printf ( CON_DEBUG , " \n Showing logo screens... " ) ;
2015-04-02 02:36:55 +00:00
show_first_found_title_screen (
hiresmode ? " iplogo1b.pcx " : " iplogo1.pcx " , // OEM
" iplogo1.pcx " , // SHAREWARE
" mplogo.pcx " // MAC SHAREWARE
) ;
show_first_found_title_screen (
hiresmode ? " logob.pcx " : " logo.pcx " , // OEM
" logo.pcx " , // SHAREWARE
" plogo.pcx " // MAC SHAREWARE
) ;
2006-10-02 13:51:05 +00:00
}
}
{ //show bundler movie or screens
played = MOVIE_NOT_PLAYED ; //default is not played
//check if OEM movie exists, so we don't stop the music if it doesn't
2015-01-17 18:31:42 +00:00
if ( RAIIPHYSFS_File { PHYSFS_openRead ( " oem.mve " ) } )
2006-10-02 13:51:05 +00:00
{
2013-10-27 21:01:04 +00:00
played = PlayMovie ( NULL , " oem.mve " , 0 ) ;
2006-10-02 13:51:05 +00:00
song_playing = 0 ; //movie will kill sound
}
if ( ! played )
{
2015-04-02 02:36:55 +00:00
char filename [ 12 ] ;
2016-07-31 22:25:49 +00:00
strcpy ( filename , hiresmode ? " oem1b.pcx " : " oem1.pcx " ) ;
2011-06-01 07:59:55 +00:00
while ( PHYSFSX_exists ( filename , 0 ) )
2006-10-02 13:51:05 +00:00
{
show_title_screen ( filename , 1 , 0 ) ;
filename [ 3 ] + + ;
}
}
}
if ( ! song_playing )
2011-01-16 10:39:46 +00:00
{
con_printf ( CON_DEBUG , " \n Playing title song... " ) ;
2006-10-02 13:51:05 +00:00
songs_play_song ( SONG_TITLE , 1 ) ;
2011-01-16 10:39:46 +00:00
}
con_printf ( CON_DEBUG , " \n Showing logo screen... " ) ;
2016-07-31 22:25:49 +00:00
const auto filename = hiresmode ? " descentb.pcx " : " descent.pcx " ;
2011-06-01 07:59:55 +00:00
if ( PHYSFSX_exists ( filename , 1 ) )
2011-01-16 10:39:46 +00:00
show_title_screen ( filename , 1 , 1 ) ;
2013-03-03 01:03:33 +00:00
# endif
2006-10-02 13:51:05 +00:00
}
2016-08-25 04:05:32 +00:00
}
2006-10-02 13:51:05 +00:00
2016-08-25 04:05:32 +00:00
namespace dsx {
2010-03-18 04:31:47 +00:00
void show_order_form ( )
{
2015-12-24 04:01:27 +00:00
if ( CGameArg . SysNoTitles )
2013-03-03 01:03:33 +00:00
return ;
2015-10-09 02:46:09 +00:00
# if defined(DXX_BUILD_DESCENT_I)
2015-10-09 02:46:11 +00:00
show_first_found_title_screen (
" warning.pcx " , // D1 Registered
" apple.pcx " , // D1 Mac OEM Demo
" order01.pcx " // D1 Demo
) ;
2013-03-03 01:03:33 +00:00
# elif defined(DXX_BUILD_DESCENT_II)
2016-09-11 18:49:16 +00:00
# if !DXX_USE_EDITOR
2010-03-18 04:31:47 +00:00
key_flush ( ) ;
2015-04-02 02:36:55 +00:00
const auto hiresmode = HIRESMODE ;
/*
* If D2 registered , all checks fail and nothing is shown .
*/
const char * exit_screen = hiresmode ? " ordrd2ob.pcx " : " ordrd2o.pcx " ; // OEM
if ( ( PHYSFSX_exists ( exit_screen , 1 ) ) | |
// SHAREWARE, prefer mac if hires
( exit_screen = hiresmode ? " orderd2b.pcx " : " orderd2.pcx " , PHYSFSX_exists ( exit_screen , 1 ) ) | |
// SHAREWARE, have to rescale
( exit_screen = hiresmode ? " orderd2.pcx " : " orderd2b.pcx " , PHYSFSX_exists ( exit_screen , 1 ) ) | |
// D1
( exit_screen = hiresmode ? " warningb.pcx " : " warning.pcx " , PHYSFSX_exists ( exit_screen , 1 ) )
)
show_title_screen ( exit_screen , 1 , 0 ) ;
2013-03-03 01:03:33 +00:00
# endif
2010-03-18 04:31:47 +00:00
# endif
}
2016-08-25 04:05:32 +00:00
}
2010-03-18 04:31:47 +00:00
//-----------------------------------------------------------------------------
2013-12-22 22:03:07 +00:00
struct briefing_screen {
2013-09-01 22:10:33 +00:00
char bs_name [ 13 ] ; // filename, eg merc01. Assumes .lbm suffix.
2006-03-20 17:12:09 +00:00
sbyte level_num ;
sbyte message_num ;
short text_ulx , text_uly ; // upper left x,y of text window
short text_width , text_height ; // width and height of text window
2013-12-22 22:03:07 +00:00
} ;
2006-03-20 17:12:09 +00:00
# define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
# define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
2010-03-25 23:37:19 +00:00
# define ENDING_LEVEL_NUM_OEMSHARE 0x7f
# define ENDING_LEVEL_NUM_REGISTER 0x7e
2006-03-20 17:12:09 +00:00
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2006-03-20 17:12:09 +00:00
# define MAX_BRIEFING_SCREENS 60
2015-04-02 02:36:52 +00:00
static array < briefing_screen , MAX_BRIEFING_SCREENS > Briefing_screens { {
{ " brief03.pcx " , 0 , 3 , 8 , 8 , 257 , 177 }
} } ; // default=0!!!
2013-03-03 01:03:33 +00:00
# endif
2006-03-20 17:12:09 +00:00
2016-07-16 16:52:04 +00:00
constexpr briefing_screen D1_Briefing_screens_full [ ] = {
2006-03-20 17:12:09 +00:00
{ " brief01.pcx " , 0 , 1 , 13 , 140 , 290 , 59 } ,
{ " brief02.pcx " , 0 , 2 , 27 , 34 , 257 , 177 } ,
{ " brief03.pcx " , 0 , 3 , 20 , 22 , 257 , 177 } ,
{ " brief02.pcx " , 0 , 4 , 27 , 34 , 257 , 177 } ,
{ " moon01.pcx " , 1 , 5 , 10 , 10 , 300 , 170 } , // level 1
{ " moon01.pcx " , 2 , 6 , 10 , 10 , 300 , 170 } , // level 2
{ " moon01.pcx " , 3 , 7 , 10 , 10 , 300 , 170 } , // level 3
{ " venus01.pcx " , 4 , 8 , 15 , 15 , 300 , 200 } , // level 4
{ " venus01.pcx " , 5 , 9 , 15 , 15 , 300 , 200 } , // level 5
{ " brief03.pcx " , 6 , 10 , 20 , 22 , 257 , 177 } ,
{ " merc01.pcx " , 6 , 11 , 10 , 15 , 300 , 200 } , // level 6
{ " merc01.pcx " , 7 , 12 , 10 , 15 , 300 , 200 } , // level 7
{ " brief03.pcx " , 8 , 13 , 20 , 22 , 257 , 177 } ,
{ " mars01.pcx " , 8 , 14 , 10 , 100 , 300 , 200 } , // level 8
{ " mars01.pcx " , 9 , 15 , 10 , 100 , 300 , 200 } , // level 9
{ " brief03.pcx " , 10 , 16 , 20 , 22 , 257 , 177 } ,
{ " mars01.pcx " , 10 , 17 , 10 , 100 , 300 , 200 } , // level 10
{ " jup01.pcx " , 11 , 18 , 10 , 40 , 300 , 200 } , // level 11
{ " jup01.pcx " , 12 , 19 , 10 , 40 , 300 , 200 } , // level 12
{ " brief03.pcx " , 13 , 20 , 20 , 22 , 257 , 177 } ,
{ " jup01.pcx " , 13 , 21 , 10 , 40 , 300 , 200 } , // level 13
{ " jup01.pcx " , 14 , 22 , 10 , 40 , 300 , 200 } , // level 14
{ " saturn01.pcx " , 15 , 23 , 10 , 40 , 300 , 200 } , // level 15
{ " brief03.pcx " , 16 , 24 , 20 , 22 , 257 , 177 } ,
{ " saturn01.pcx " , 16 , 25 , 10 , 40 , 300 , 200 } , // level 16
{ " brief03.pcx " , 17 , 26 , 20 , 22 , 257 , 177 } ,
{ " saturn01.pcx " , 17 , 27 , 10 , 40 , 300 , 200 } , // level 17
{ " uranus01.pcx " , 18 , 28 , 100 , 100 , 300 , 200 } , // level 18
{ " uranus01.pcx " , 19 , 29 , 100 , 100 , 300 , 200 } , // level 19
{ " uranus01.pcx " , 20 , 30 , 100 , 100 , 300 , 200 } , // level 20
{ " uranus01.pcx " , 21 , 31 , 100 , 100 , 300 , 200 } , // level 21
{ " neptun01.pcx " , 22 , 32 , 10 , 20 , 300 , 200 } , // level 22
{ " neptun01.pcx " , 23 , 33 , 10 , 20 , 300 , 200 } , // level 23
{ " neptun01.pcx " , 24 , 34 , 10 , 20 , 300 , 200 } , // level 24
{ " pluto01.pcx " , 25 , 35 , 10 , 20 , 300 , 200 } , // level 25
{ " pluto01.pcx " , 26 , 36 , 10 , 20 , 300 , 200 } , // level 26
{ " pluto01.pcx " , 27 , 37 , 10 , 20 , 300 , 200 } , // level 27
{ " aster01.pcx " , - 1 , 38 , 10 , 90 , 300 , 200 } , // secret level -1
{ " aster01.pcx " , - 2 , 39 , 10 , 90 , 300 , 200 } , // secret level -2
{ " aster01.pcx " , - 3 , 40 , 10 , 90 , 300 , 200 } , // secret level -3
2010-03-25 23:37:19 +00:00
{ " end01.pcx " , ENDING_LEVEL_NUM_OEMSHARE , 1 , 23 , 40 , 320 , 200 } , // OEM and shareware end
{ " end02.pcx " , ENDING_LEVEL_NUM_REGISTER , 1 , 5 , 5 , 300 , 200 } , // registered end
{ " end01.pcx " , ENDING_LEVEL_NUM_REGISTER , 2 , 23 , 40 , 320 , 200 } , // registered end
{ " end03.pcx " , ENDING_LEVEL_NUM_REGISTER , 3 , 5 , 5 , 300 , 200 } , // registered end
2006-03-20 17:12:09 +00:00
} ;
2016-07-16 16:52:04 +00:00
constexpr briefing_screen D1_Briefing_screens_share [ ] = {
2012-04-08 13:47:58 +00:00
{ " brief01.pcx " , 0 , 1 , 13 , 140 , 290 , 59 } ,
{ " brief02.pcx " , 0 , 2 , 27 , 34 , 257 , 177 } ,
{ " brief03.pcx " , 0 , 3 , 20 , 22 , 257 , 177 } ,
{ " brief02.pcx " , 0 , 4 , 27 , 34 , 257 , 177 } ,
{ " moon01.pcx " , 1 , 5 , 10 , 10 , 300 , 170 } , // level 1
{ " moon01.pcx " , 2 , 6 , 10 , 10 , 300 , 170 } , // level 2
{ " moon01.pcx " , 3 , 7 , 10 , 10 , 300 , 170 } , // level 3
{ " venus01.pcx " , 4 , 8 , 15 , 15 , 300 , 200 } , // level 4
{ " venus01.pcx " , 5 , 9 , 15 , 15 , 300 , 200 } , // level 5
2013-06-10 22:48:23 +00:00
{ " brief03.pcx " , 6 , 10 , 20 , 22 , 257 , 177 } ,
2012-04-08 13:47:58 +00:00
{ " merc01.pcx " , 6 , 10 , 10 , 15 , 300 , 200 } , // level 6
{ " merc01.pcx " , 7 , 11 , 10 , 15 , 300 , 200 } , // level 7
{ " end01.pcx " , ENDING_LEVEL_NUM_OEMSHARE , 1 , 23 , 40 , 320 , 200 } , // shareware end
} ;
# define D1_Briefing_screens ((PHYSFSX_fsize("descent.hog")==D1_SHAREWARE_MISSION_HOGSIZE || PHYSFSX_fsize("descent.hog")==D1_SHAREWARE_10_MISSION_HOGSIZE)?D1_Briefing_screens_share:D1_Briefing_screens_full)
2013-08-25 22:27:35 +00:00
# define NUM_D1_BRIEFING_SCREENS ((PHYSFSX_fsize("descent.hog")==D1_SHAREWARE_MISSION_HOGSIZE || PHYSFSX_fsize("descent.hog")==D1_SHAREWARE_10_MISSION_HOGSIZE)?(sizeof(D1_Briefing_screens_share) / sizeof(D1_Briefing_screens_share[0])):(sizeof(D1_Briefing_screens_full) / sizeof(D1_Briefing_screens_full[0])))
2006-03-20 17:12:09 +00:00
2013-12-22 22:03:07 +00:00
struct msgstream
{
2010-03-09 02:41:34 +00:00
int x ;
int y ;
2014-08-08 02:54:50 +00:00
color_t color ;
char ch ;
} ;
2006-03-20 17:12:09 +00:00
2015-01-23 03:55:06 +00:00
namespace {
2015-01-17 18:31:40 +00:00
class briefing_screen_deleter : std : : default_delete < briefing_screen >
{
typedef std : : default_delete < briefing_screen > base_deleter ;
public :
briefing_screen_deleter ( ) = default ;
briefing_screen_deleter ( base_deleter & & b ) : base_deleter ( std : : move ( b ) ) { }
void operator ( ) ( briefing_screen * p ) const
{
# if defined(DXX_BUILD_DESCENT_II)
if ( p > = & Briefing_screens . front ( ) & & p < = & Briefing_screens . back ( ) )
return ;
# endif
this - > base_deleter : : operator ( ) ( p ) ;
}
} ;
2014-09-07 18:06:59 +00:00
struct briefing : ignore_window_pointer_t
2006-03-20 17:12:09 +00:00
{
2015-01-17 18:31:40 +00:00
unsigned streamcount ;
2010-03-09 04:59:14 +00:00
short level_num ;
short cur_screen ;
2015-01-17 18:31:40 +00:00
std : : unique_ptr < briefing_screen , briefing_screen_deleter > screen ;
2016-10-29 23:16:15 +00:00
grs_main_bitmap background ;
2011-01-16 10:39:46 +00:00
char background_name [ PATH_MAX ] ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2010-03-10 08:43:47 +00:00
int got_z ;
2015-04-02 02:36:55 +00:00
RAIIdigi_sound hum_channel , printing_channel ;
2014-10-29 03:01:18 +00:00
MVESTREAM_ptr_t pMovie ;
2013-03-03 01:03:33 +00:00
# endif
2014-07-20 21:21:33 +00:00
std : : unique_ptr < char [ ] > text ;
2013-09-02 23:58:27 +00:00
const char * message ;
2010-03-09 02:41:34 +00:00
int text_x , text_y ;
2014-08-08 02:54:50 +00:00
array < msgstream , 2048 > messagestream ;
2010-03-10 08:43:47 +00:00
short tab_stop ;
ubyte flashing_cursor ;
ubyte new_page ;
2010-03-18 04:31:47 +00:00
int new_screen ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2010-03-10 08:43:47 +00:00
ubyte dumb_adjust ;
ubyte line_adjustment ;
2013-03-03 01:03:33 +00:00
char robot_playing ;
2010-03-10 08:43:47 +00:00
short chattering ;
2013-03-03 01:03:33 +00:00
# endif
2010-12-10 23:18:17 +00:00
fix64 start_time ;
fix64 delay_count ;
2010-03-10 08:43:47 +00:00
int robot_num ;
2014-09-06 23:55:43 +00:00
grs_subcanvas_ptr robot_canv ;
2010-03-09 02:41:34 +00:00
vms_angvec robot_angles ;
char bitmap_name [ 32 ] ;
2010-03-10 08:43:47 +00:00
grs_bitmap guy_bitmap ;
sbyte guy_bitmap_show ;
2010-03-09 02:41:34 +00:00
sbyte door_dir , door_div_count , animating_bitmap_type ;
2010-03-10 08:43:47 +00:00
sbyte prev_ch ;
2013-12-22 22:03:07 +00:00
} ;
2010-03-09 02:41:34 +00:00
2015-01-23 03:55:06 +00:00
}
2016-08-25 04:05:32 +00:00
namespace dsx {
2013-06-08 23:34:31 +00:00
static void briefing_init ( briefing * br , short level_num )
2010-03-09 02:41:34 +00:00
{
2010-03-09 04:59:14 +00:00
br - > level_num = level_num ;
2010-03-18 04:31:47 +00:00
if ( EMULATING_D1 & & ( br - > level_num = = 1 ) )
br - > level_num = 0 ; // for start of game stuff
2010-03-09 04:59:14 +00:00
br - > cur_screen = 0 ;
2014-11-30 22:09:20 +00:00
gr_init_bitmap_data ( br - > background ) ;
2010-03-25 23:37:19 +00:00
strncpy ( br - > background_name , DEFAULT_BRIEFING_BKG , sizeof ( br - > background_name ) ) ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
br - > robot_playing = 0 ;
# endif
2010-09-04 08:17:54 +00:00
br - > robot_num = 0 ;
2014-07-20 21:21:33 +00:00
br - > robot_angles = { } ;
2010-03-09 02:41:34 +00:00
br - > bitmap_name [ 0 ] = ' \0 ' ;
br - > door_dir = 1 ;
br - > door_div_count = 0 ;
br - > animating_bitmap_type = 0 ;
2006-03-20 17:12:09 +00:00
}
2016-08-25 04:05:32 +00:00
}
2006-03-20 17:12:09 +00:00
//-----------------------------------------------------------------------------
2010-03-18 04:31:47 +00:00
// Load Descent briefing text.
2016-08-25 04:05:32 +00:00
namespace dsx {
2014-07-23 02:27:22 +00:00
static int load_screen_text ( const d_fname & filename , std : : unique_ptr < char [ ] > & buf )
2006-03-20 17:12:09 +00:00
{
2013-03-03 01:03:33 +00:00
int len , have_binary = 0 ;
2014-07-23 02:27:22 +00:00
auto e = end ( filename ) ;
auto ext = std : : find ( begin ( filename ) , e , ' . ' ) ;
if ( ext = = e )
2012-05-26 17:39:14 +00:00
return ( 0 ) ;
2014-07-23 02:27:22 +00:00
if ( ! d_stricmp ( & * ext , " .txb " ) )
2010-03-18 04:31:47 +00:00
have_binary = 1 ;
2010-08-24 14:02:38 +00:00
2015-01-17 18:31:42 +00:00
auto tfile = PHYSFSX_openReadBuffered ( filename ) ;
2015-01-17 18:31:42 +00:00
if ( ! tfile )
2010-08-24 14:02:38 +00:00
return ( 0 ) ;
2011-06-01 07:59:55 +00:00
len = PHYSFS_fileLength ( tfile ) ;
2014-08-16 04:15:16 +00:00
buf = make_unique < char [ ] > ( len + 1 ) ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
2014-07-20 21:21:33 +00:00
PHYSFS_read ( tfile , buf . get ( ) , 1 , len ) ;
2013-03-03 01:03:33 +00:00
# elif defined(DXX_BUILD_DESCENT_II)
for ( int x = 0 , i = 0 ; i < len ; i + + , x + + ) {
2014-07-20 21:21:33 +00:00
PHYSFS_read ( tfile , & buf [ x ] , 1 , 1 ) ;
if ( buf [ x ] = = 13 )
2010-08-24 14:02:38 +00:00
x - - ;
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
# endif
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
if ( have_binary )
2014-07-20 21:21:33 +00:00
decode_text ( buf . get ( ) , len ) ;
2010-06-19 16:24:34 +00:00
2014-07-20 21:21:33 +00:00
buf [ len ] = ' \0 ' ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
return ( 1 ) ;
2006-03-20 17:12:09 +00:00
}
2016-08-25 04:05:32 +00:00
}
2006-03-20 17:12:09 +00:00
2013-09-02 23:58:27 +00:00
static int get_message_num ( const char * * message )
2006-03-20 17:12:09 +00:00
{
2010-03-18 04:31:47 +00:00
int num = 0 ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
while ( strlen ( * message ) > 0 & & * * message = = ' ' )
( * message ) + + ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
while ( strlen ( * message ) > 0 & & ( * * message > = ' 0 ' ) & & ( * * message < = ' 9 ' ) ) {
num = 10 * num + * * message - ' 0 ' ;
( * message ) + + ;
}
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
while ( strlen ( * message ) > 0 & & * ( * message ) + + ! = 10 ) // Get and drop eoln
;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
return num ;
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2016-08-25 04:05:32 +00:00
namespace dsx {
2015-01-23 03:55:06 +00:00
static void set_briefing_fontcolor ( struct briefing * br ) ;
2016-08-25 04:05:32 +00:00
}
2013-09-02 23:58:27 +00:00
static int get_new_message_num ( const char * * message )
2006-03-20 17:12:09 +00:00
{
2010-03-18 04:31:47 +00:00
int num = 0 ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
while ( strlen ( * message ) > 0 & & * * message = = ' ' )
( * message ) + + ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
while ( strlen ( * message ) > 0 & & ( * * message > = ' 0 ' ) & & ( * * message < = ' 9 ' ) ) {
num = 10 * num + * * message - ' 0 ' ;
( * message ) + + ;
2006-03-20 17:12:09 +00:00
}
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
( * message ) + + ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
return num ;
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
# endif
2006-03-20 17:12:09 +00:00
2013-09-02 23:58:27 +00:00
static void get_message_name ( const char * * message , char * result )
2006-03-20 17:12:09 +00:00
{
2010-03-18 04:31:47 +00:00
while ( strlen ( * message ) > 0 & & * * message = = ' ' )
( * message ) + + ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
while ( strlen ( * message ) > 0 & & ( * * message ! = ' ' ) & & ( * * message ! = 10 ) ) {
if ( * * message ! = ' \n ' )
* result + + = * * message ;
( * message ) + + ;
}
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
if ( * * message ! = 10 )
while ( strlen ( * message ) > 0 & & * ( * message ) + + ! = 10 ) // Get and drop eoln
;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
* result = 0 ;
2006-03-20 17:12:09 +00:00
}
2010-03-18 04:31:47 +00:00
// Return a pointer to the start of text for screen #screen_num.
2013-09-02 23:58:27 +00:00
static const char * get_briefing_message ( const briefing * br , int screen_num )
2006-03-20 17:12:09 +00:00
{
2014-07-20 21:21:33 +00:00
const char * tptr = br - > text . get ( ) ;
2010-03-18 04:31:47 +00:00
int cur_screen = 0 ;
int ch ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
Assert ( screen_num > = 0 ) ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
while ( ( * tptr ! = 0 ) & & ( screen_num ! = cur_screen ) ) {
ch = * tptr + + ;
if ( ch = = ' $ ' ) {
ch = * tptr + + ;
if ( ch = = ' S ' )
cur_screen = get_message_num ( & tptr ) ;
2010-03-01 07:27:51 +00:00
}
2006-03-20 17:12:09 +00:00
}
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
if ( screen_num ! = cur_screen )
return ( NULL ) ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
return tptr ;
2006-03-20 17:12:09 +00:00
}
2013-06-08 23:34:31 +00:00
static void init_char_pos ( briefing * br , int x , int y )
2006-03-20 17:12:09 +00:00
{
2010-03-18 04:31:47 +00:00
br - > text_x = x ;
br - > text_y = y ;
2006-03-20 17:12:09 +00:00
}
2010-03-18 04:31:47 +00:00
// Make sure the text stays on the screen
// Return 1 if new page required
// 0 otherwise
2013-06-08 23:34:31 +00:00
static int check_text_pos ( briefing * br )
2006-03-20 17:12:09 +00:00
{
2010-03-18 04:31:47 +00:00
if ( br - > text_x > br - > screen - > text_ulx + br - > screen - > text_width )
{
br - > text_x = br - > screen - > text_ulx ;
br - > text_y + = br - > screen - > text_uly ;
2006-03-20 17:12:09 +00:00
}
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
if ( br - > text_y > br - > screen - > text_uly + br - > screen - > text_height )
{
br - > new_page = 1 ;
return 1 ;
2006-03-20 17:12:09 +00:00
}
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
return 0 ;
2006-03-20 17:12:09 +00:00
}
2016-08-25 04:05:32 +00:00
namespace dsx {
2014-08-08 02:54:50 +00:00
static void put_char_delay ( briefing * br , char ch )
2006-03-20 17:12:09 +00:00
{
2010-10-10 10:48:24 +00:00
char str [ 2 ] ;
2015-09-29 02:41:22 +00:00
int w ;
2010-06-19 16:24:34 +00:00
2010-10-10 10:48:24 +00:00
str [ 0 ] = ch ; str [ 1 ] = ' \0 ' ;
2010-12-10 23:18:17 +00:00
if ( br - > delay_count & & ( timer_query ( ) < br - > start_time + br - > delay_count ) )
2010-03-18 04:31:47 +00:00
{
br - > message - - ; // Go back to same character
2006-03-20 17:12:09 +00:00
return ;
2010-03-18 04:31:47 +00:00
}
2010-06-19 16:24:34 +00:00
2014-08-08 02:54:50 +00:00
if ( br - > streamcount > = br - > messagestream . size ( ) )
return ;
2010-03-18 04:31:47 +00:00
br - > messagestream [ br - > streamcount ] . x = br - > text_x ;
br - > messagestream [ br - > streamcount ] . y = br - > text_y ;
br - > messagestream [ br - > streamcount ] . color = Briefing_text_colors [ Current_color ] ;
br - > messagestream [ br - > streamcount ] . ch = ch ;
br - > streamcount + + ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
br - > prev_ch = ch ;
2017-01-08 22:31:59 +00:00
gr_get_string_size ( * grd_curcanv - > cv_font , str , & w , nullptr , nullptr ) ;
2010-03-18 04:31:47 +00:00
br - > text_x + = w ;
2010-06-19 16:24:34 +00:00
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2015-02-08 07:42:18 +00:00
if ( ! EMULATING_D1 & & ! br - > chattering ) {
2015-04-02 02:36:55 +00:00
br - > printing_channel . reset ( digi_start_sound ( digi_xlat_sound ( SOUND_BRIEFING_PRINTING ) , F1_0 , 0xFFFF / 2 , 1 , - 1 , - 1 , sound_object_none ) ) ;
2010-03-18 04:31:47 +00:00
br - > chattering = 1 ;
}
2013-03-03 01:03:33 +00:00
# endif
2006-03-20 17:12:09 +00:00
2010-12-10 23:18:17 +00:00
br - > start_time = timer_query ( ) ;
2006-03-20 17:12:09 +00:00
}
2016-08-25 04:05:32 +00:00
}
2006-03-20 17:12:09 +00:00
2013-06-08 23:34:31 +00:00
static void init_spinning_robot ( briefing * br ) ;
2016-08-25 04:05:32 +00:00
namespace dsx {
2013-06-08 23:34:31 +00:00
static int load_briefing_screen ( briefing * br , const char * fname ) ;
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
// Process a character for the briefing,
// including special characters preceded by a '$'.
// Return 1 when page is finished, 0 otherwise
2016-08-25 04:05:32 +00:00
}
namespace dsx {
2013-06-08 23:34:31 +00:00
static int briefing_process_char ( briefing * br )
2006-03-20 17:12:09 +00:00
{
2010-06-21 21:43:10 +00:00
gr_set_curfont ( GAME_FONT ) ;
2014-08-08 02:54:50 +00:00
char ch = * br - > message + + ;
2010-03-18 04:31:47 +00:00
if ( ch = = ' $ ' ) {
2010-03-09 04:59:14 +00:00
ch = * br - > message + + ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2010-03-18 04:31:47 +00:00
if ( ch = = ' D ' ) {
br - > cur_screen = DefineBriefingBox ( & br - > message ) ;
2015-01-17 18:31:40 +00:00
br - > screen . reset ( & Briefing_screens [ br - > cur_screen ] ) ;
2010-03-18 04:31:47 +00:00
init_char_pos ( br , br - > screen - > text_ulx , br - > screen - > text_uly ) ;
br - > line_adjustment = 0 ;
br - > prev_ch = 10 ; // read to eoln
} else if ( ch = = ' U ' ) {
br - > cur_screen = get_message_num ( & br - > message ) ;
2015-01-17 18:31:40 +00:00
br - > screen . reset ( & Briefing_screens [ br - > cur_screen ] ) ;
2010-03-18 04:31:47 +00:00
init_char_pos ( br , br - > screen - > text_ulx , br - > screen - > text_uly ) ;
br - > prev_ch = 10 ; // read to eoln
2013-03-03 01:03:33 +00:00
} else
# endif
if ( ch = = ' C ' ) {
2010-03-18 04:31:47 +00:00
Current_color = get_message_num ( & br - > message ) - 1 ;
2010-07-19 17:30:25 +00:00
if ( Current_color < 0 )
Current_color = 0 ;
else if ( Current_color > MAX_BRIEFING_COLORS - 1 )
Current_color = MAX_BRIEFING_COLORS - 1 ;
2010-03-18 04:31:47 +00:00
br - > prev_ch = 10 ;
} else if ( ch = = ' F ' ) { // toggle flashing cursor
br - > flashing_cursor = ! br - > flashing_cursor ;
br - > prev_ch = 10 ;
while ( * br - > message + + ! = 10 )
;
} else if ( ch = = ' T ' ) {
br - > tab_stop = get_message_num ( & br - > message ) ;
br - > prev_ch = 10 ; // read to eoln
} else if ( ch = = ' R ' ) {
2014-09-06 23:55:43 +00:00
br - > robot_canv . reset ( ) ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2010-03-18 04:31:47 +00:00
if ( br - > robot_playing ) {
2014-10-29 03:01:18 +00:00
DeInitRobotMovie ( br - > pMovie ) ;
2010-03-18 04:31:47 +00:00
br - > robot_playing = 0 ;
}
2013-03-03 01:03:33 +00:00
# endif
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
if ( EMULATING_D1 ) {
init_spinning_robot ( br ) ;
br - > robot_num = get_message_num ( & br - > message ) ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2010-03-09 04:59:14 +00:00
while ( * br - > message + + ! = 10 )
2006-03-20 17:12:09 +00:00
;
2013-03-03 01:03:33 +00:00
# endif
2010-03-18 04:31:47 +00:00
} else {
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2010-03-18 04:31:47 +00:00
char spinRobotName [ ] = " rba.mve " , kludge ; // matt don't change this!
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
kludge = * br - > message + + ;
spinRobotName [ 2 ] = kludge ; // ugly but proud
2010-06-19 16:24:34 +00:00
2014-10-29 03:01:18 +00:00
br - > robot_playing = InitRobotMovie ( spinRobotName , br - > pMovie ) ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
// gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
2010-06-19 16:24:34 +00:00
2010-03-09 02:41:34 +00:00
if ( br - > robot_playing ) {
2014-10-29 03:01:18 +00:00
RotateRobot ( br - > pMovie ) ;
2010-03-18 04:31:47 +00:00
set_briefing_fontcolor ( br ) ;
2006-03-20 17:12:09 +00:00
}
2013-03-03 01:03:33 +00:00
# endif
2010-03-18 04:31:47 +00:00
}
br - > prev_ch = 10 ; // read to eoln
} else if ( ch = = ' N ' ) {
2014-09-06 23:55:43 +00:00
br - > robot_canv . reset ( ) ;
2010-03-18 04:31:47 +00:00
get_message_name ( & br - > message , br - > bitmap_name ) ;
strcat ( br - > bitmap_name , " #0 " ) ;
br - > animating_bitmap_type = 0 ;
br - > prev_ch = 10 ;
} else if ( ch = = ' O ' ) {
2014-09-06 23:55:43 +00:00
br - > robot_canv . reset ( ) ;
2010-03-18 04:31:47 +00:00
get_message_name ( & br - > message , br - > bitmap_name ) ;
strcat ( br - > bitmap_name , " #0 " ) ;
br - > animating_bitmap_type = 1 ;
br - > prev_ch = 10 ;
} else if ( ch = = ' A ' ) {
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2010-03-18 04:31:47 +00:00
br - > line_adjustment = 1 - br - > line_adjustment ;
2013-03-03 01:03:33 +00:00
# endif
2010-03-18 04:31:47 +00:00
} else if ( ch = = ' Z ' ) {
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2010-03-18 04:31:47 +00:00
char fname [ 15 ] ;
int i ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
br - > got_z = 1 ;
br - > dumb_adjust = 1 ;
i = 0 ;
while ( ( fname [ i ] = * br - > message ) ! = ' \n ' ) {
i + + ;
br - > message + + ;
}
fname [ i ] = 0 ;
if ( * br - > message ! = 10 )
while ( * br - > message + + ! = 10 ) // Get and drop eoln
;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
{
char fname2 [ 15 ] ;
2010-06-19 16:24:34 +00:00
2006-03-20 17:12:09 +00:00
i = 0 ;
2010-03-18 04:31:47 +00:00
while ( fname [ i ] ! = ' . ' ) {
fname2 [ i ] = fname [ i ] ;
2006-03-20 17:12:09 +00:00
i + + ;
}
2010-03-18 04:31:47 +00:00
fname2 [ i + + ] = ' b ' ;
fname2 [ i + + ] = ' . ' ;
fname2 [ i + + ] = ' p ' ;
fname2 [ i + + ] = ' c ' ;
fname2 [ i + + ] = ' x ' ;
fname2 [ i + + ] = 0 ;
2010-06-19 16:24:34 +00:00
2011-06-01 07:59:55 +00:00
if ( ( HIRESMODE & & PHYSFSX_exists ( fname2 , 1 ) ) | | ! PHYSFSX_exists ( fname , 1 ) )
2010-03-18 04:31:47 +00:00
strcpy ( fname , fname2 ) ;
load_briefing_screen ( br , fname ) ;
2006-03-20 17:12:09 +00:00
}
2010-06-19 16:24:34 +00:00
2013-03-03 01:03:33 +00:00
# endif
2010-03-18 04:31:47 +00:00
} else if ( ch = = ' B ' ) {
char bitmap_name [ 32 ] ;
2013-01-06 21:03:57 +00:00
palette_array_t temp_palette ;
2010-03-18 04:31:47 +00:00
int iff_error ;
2014-09-06 23:55:43 +00:00
br - > robot_canv . reset ( ) ;
2010-03-18 04:31:47 +00:00
get_message_name ( & br - > message , bitmap_name ) ;
strcat ( bitmap_name , " .bbm " ) ;
2014-11-30 22:09:20 +00:00
gr_init_bitmap_data ( br - > guy_bitmap ) ;
2016-05-28 17:31:27 +00:00
iff_error = iff_read_bitmap ( bitmap_name , br - > guy_bitmap , & temp_palette ) ;
2015-02-08 00:55:20 +00:00
# if defined(DXX_BUILD_DESCENT_II)
gr_remap_bitmap_good ( br - > guy_bitmap , temp_palette , - 1 , - 1 ) ;
# endif
2010-03-18 04:31:47 +00:00
Assert ( iff_error = = IFF_NO_ERROR ) ;
2011-09-26 23:31:19 +00:00
( void ) iff_error ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
br - > guy_bitmap_show = 1 ;
br - > prev_ch = 10 ;
} else if ( ch = = ' S ' ) {
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2010-03-18 04:31:47 +00:00
br - > chattering = 0 ;
2015-04-02 02:36:55 +00:00
br - > printing_channel . reset ( ) ;
2013-03-03 01:03:33 +00:00
# endif
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
br - > new_screen = 1 ;
return 1 ;
} else if ( ch = = ' P ' ) { // New page.
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2010-03-10 08:43:47 +00:00
if ( ! br - > got_z ) {
2006-03-20 17:12:09 +00:00
Int3 ( ) ; // Hey ryan!!!! You gotta load a screen before you start
2010-03-18 04:31:47 +00:00
// printing to it! You know, $Z !!!
2010-03-09 02:41:34 +00:00
load_briefing_screen ( br , HIRESMODE ? " end01b.pcx " : " end01.pcx " ) ;
2006-03-20 17:12:09 +00:00
}
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
br - > chattering = 0 ;
2015-04-02 02:36:55 +00:00
br - > printing_channel . reset ( ) ;
2013-03-03 01:03:33 +00:00
# endif
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
br - > new_page = 1 ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
while ( * br - > message ! = 10 ) {
br - > message + + ; // drop carriage return after special escape sequence
2007-03-22 11:32:22 +00:00
}
2010-03-18 04:31:47 +00:00
br - > message + + ;
br - > prev_ch = 10 ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
return 1 ;
} else if ( ch = = ' $ ' | | ch = = ' ; ' ) // Print a $/;
put_char_delay ( br , ch ) ;
} else if ( ch = = ' \t ' ) { // Tab
2015-06-13 22:42:20 +00:00
const auto & & fspacx = FSPACX ( ) ;
if ( br - > text_x - br - > screen - > text_ulx < fspacx ( br - > tab_stop ) )
br - > text_x = br - > screen - > text_ulx + fspacx ( br - > tab_stop ) ;
2010-03-18 04:31:47 +00:00
} else if ( ( ch = = ' ; ' ) & & ( br - > prev_ch = = 10 ) ) {
while ( * br - > message + + ! = 10 )
;
br - > prev_ch = 10 ;
} else if ( ch = = ' \\ ' ) {
br - > prev_ch = ch ;
} else if ( ch = = 10 ) {
if ( br - > prev_ch ! = ' \\ ' ) {
2010-03-10 08:43:47 +00:00
br - > prev_ch = ch ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
if ( br - > dumb_adjust )
2010-03-18 04:31:47 +00:00
br - > dumb_adjust - - ;
2013-03-03 01:03:33 +00:00
else
# endif
br - > text_y + = FSPACY ( 5 ) + FSPACY ( 5 ) * 3 / 5 ;
2010-03-18 04:31:47 +00:00
br - > text_x = br - > screen - > text_ulx ;
if ( br - > text_y > br - > screen - > text_uly + br - > screen - > text_height ) {
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
load_briefing_screen ( br , D1_Briefing_screens [ br - > cur_screen ] . bs_name ) ;
# elif defined(DXX_BUILD_DESCENT_II)
2010-03-18 04:31:47 +00:00
load_briefing_screen ( br , Briefing_screens [ br - > cur_screen ] . bs_name ) ;
2013-03-03 01:03:33 +00:00
# endif
2010-03-18 04:31:47 +00:00
br - > text_x = br - > screen - > text_ulx ;
br - > text_y = br - > screen - > text_uly ;
}
} else {
if ( ch = = 13 ) //Can this happen? Above says ch==10
Int3 ( ) ;
br - > prev_ch = ch ;
}
} else {
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2010-03-18 04:31:47 +00:00
if ( ! br - > got_z ) {
2016-10-17 03:49:32 +00:00
LevelError ( " briefing wrote to screen without using $Z to load a screen; loading default. " ) ;
//Int3(); // Hey ryan!!!! You gotta load a screen before you start
2010-03-18 04:31:47 +00:00
// printing to it! You know, $Z !!!
load_briefing_screen ( br , HIRESMODE ? " end01b.pcx " : " end01.pcx " ) ;
}
2013-03-03 01:03:33 +00:00
# endif
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
put_char_delay ( br , ch ) ;
}
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
return 0 ;
}
2016-08-25 04:05:32 +00:00
}
2010-03-18 04:31:47 +00:00
2016-08-25 04:05:32 +00:00
namespace dsx {
2013-06-08 23:34:31 +00:00
static void set_briefing_fontcolor ( briefing * br )
2010-03-18 04:31:47 +00:00
{
Briefing_text_colors [ 0 ] = gr_find_closest_color_current ( 0 , 40 , 0 ) ;
Briefing_text_colors [ 1 ] = gr_find_closest_color_current ( 40 , 33 , 35 ) ;
Briefing_text_colors [ 2 ] = gr_find_closest_color_current ( 8 , 31 , 54 ) ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
if ( EMULATING_D1 ) {
//green
Briefing_text_colors [ 0 ] = gr_find_closest_color_current ( 0 , 54 , 0 ) ;
//white
Briefing_text_colors [ 1 ] = gr_find_closest_color_current ( 42 , 38 , 32 ) ;
//Begin D1X addition
//red
Briefing_text_colors [ 2 ] = gr_find_closest_color_current ( 63 , 0 , 0 ) ;
}
2010-06-19 16:24:34 +00:00
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
( void ) br ;
# elif defined(DXX_BUILD_DESCENT_II)
2010-03-18 04:31:47 +00:00
if ( br - > robot_playing )
{
Briefing_text_colors [ 0 ] = gr_find_closest_color_current ( 0 , 31 , 0 ) ;
}
2013-03-03 01:03:33 +00:00
# endif
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
//blue
Briefing_text_colors [ 3 ] = gr_find_closest_color_current ( 0 , 0 , 54 ) ;
//gray
Briefing_text_colors [ 4 ] = gr_find_closest_color_current ( 14 , 14 , 14 ) ;
//yellow
Briefing_text_colors [ 5 ] = gr_find_closest_color_current ( 54 , 54 , 0 ) ;
//purple
Briefing_text_colors [ 6 ] = gr_find_closest_color_current ( 0 , 54 , 54 ) ;
//End D1X addition
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
Erase_color = gr_find_closest_color_current ( 0 , 0 , 0 ) ;
}
2016-08-25 04:05:32 +00:00
}
2010-03-18 04:31:47 +00:00
2014-08-08 02:54:50 +00:00
static void redraw_messagestream ( const msgstream & stream , unsigned & lastcolor )
2010-03-18 04:31:47 +00:00
{
2014-08-08 02:54:50 +00:00
char msgbuf [ 2 ] = { stream . ch , 0 } ;
if ( lastcolor ! = stream . color )
{
lastcolor = stream . color ;
gr_set_fontcolor ( stream . color , - 1 ) ;
2010-03-18 04:31:47 +00:00
}
2017-01-08 22:32:00 +00:00
gr_string ( * grd_curcanv , stream . x + 1 , stream . y , msgbuf ) ;
2010-03-18 04:31:47 +00:00
}
2013-06-08 23:34:31 +00:00
static void flash_cursor ( briefing * br , int cursor_flag )
2010-03-18 04:31:47 +00:00
{
if ( cursor_flag = = 0 )
return ;
2010-06-19 16:24:34 +00:00
2015-09-29 02:41:22 +00:00
gr_set_fontcolor ( ( timer_query ( ) % ( F1_0 / 2 ) ) > F1_0 / 4 ? Briefing_text_colors [ Current_color ] : Erase_color , - 1 ) ;
2010-06-19 16:24:34 +00:00
2017-01-08 22:32:00 +00:00
gr_string ( * grd_curcanv , br - > text_x , br - > text_y , " _ " ) ;
2010-03-18 04:31:47 +00:00
}
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
# define EXIT_DOOR_MAX 14
# define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
# define DOOR_DIV_INIT 6
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
//-----------------------------------------------------------------------------
2013-06-08 23:34:31 +00:00
static void show_animated_bitmap ( briefing * br )
2010-03-18 04:31:47 +00:00
{
2013-12-08 18:22:17 +00:00
grs_canvas * curcanv_save ;
2010-03-18 04:31:47 +00:00
grs_bitmap * bitmap_ptr ;
2016-09-24 18:06:11 +00:00
# if DXX_USE_OGL
2010-06-19 16:24:34 +00:00
float scale = 1.0 ;
2016-06-05 01:04:26 +00:00
if ( ( static_cast < float > ( SWIDTH ) / 320 ) < ( static_cast < float > ( SHEIGHT ) / 200 ) )
scale = ( static_cast < float > ( SWIDTH ) / 320 ) ;
2010-06-19 16:24:34 +00:00
else
2016-06-05 01:04:26 +00:00
scale = ( static_cast < float > ( SHEIGHT ) / 200 ) ;
2011-09-26 23:31:19 +00:00
# endif
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
// Only plot every nth frame.
if ( br - > door_div_count ) {
if ( br - > bitmap_name [ 0 ] ! = 0 ) {
bitmap_index bi ;
bi = piggy_find_bitmap ( br - > bitmap_name ) ;
bitmap_ptr = & GameBitmaps [ bi . index ] ;
PIGGY_PAGE_IN ( bi ) ;
2016-09-24 18:06:11 +00:00
# if DXX_USE_OGL
2016-12-29 03:27:12 +00:00
ogl_ubitmapm_cs ( * grd_curcanv , rescale_x ( 220 ) , rescale_y ( 45 ) , bitmap_ptr - > bm_w * scale , bitmap_ptr - > bm_h * scale , * bitmap_ptr , 255 , F1_0 ) ;
2010-03-18 04:31:47 +00:00
# else
2017-01-01 00:45:43 +00:00
gr_bitmapm ( * grd_curcanv , rescale_x ( 220 ) , rescale_y ( 45 ) , * bitmap_ptr ) ;
2010-03-18 04:31:47 +00:00
# endif
2006-03-20 17:12:09 +00:00
}
2010-03-18 04:31:47 +00:00
br - > door_div_count - - ;
return ;
}
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
br - > door_div_count = DOOR_DIV_INIT ;
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
if ( br - > bitmap_name [ 0 ] ! = 0 ) {
char * pound_signp ;
int num , dig1 , dig2 ;
bitmap_index bi ;
2014-09-06 23:55:43 +00:00
grs_subcanvas_ptr bitmap_canv ;
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
switch ( br - > animating_bitmap_type ) {
2015-01-17 18:31:40 +00:00
case 0 : bitmap_canv = gr_create_sub_canvas ( * grd_curcanv , rescale_x ( 220 ) , rescale_y ( 45 ) , 64 , 64 ) ; break ;
case 1 : bitmap_canv = gr_create_sub_canvas ( * grd_curcanv , rescale_x ( 220 ) , rescale_y ( 45 ) , 94 , 94 ) ; break ; // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
2010-03-18 04:31:47 +00:00
default : Int3 ( ) ; // Impossible, illegal value for br->animating_bitmap_type
2006-03-20 17:12:09 +00:00
}
2010-03-18 04:31:47 +00:00
curcanv_save = grd_curcanv ;
2014-09-06 23:55:43 +00:00
grd_curcanv = bitmap_canv . get ( ) ;
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
pound_signp = strchr ( br - > bitmap_name , ' # ' ) ;
Assert ( pound_signp ! = NULL ) ;
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
dig1 = * ( pound_signp + 1 ) ;
dig2 = * ( pound_signp + 2 ) ;
if ( dig2 = = 0 )
num = dig1 - ' 0 ' ;
else
num = ( dig1 - ' 0 ' ) * 10 + ( dig2 - ' 0 ' ) ;
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
switch ( br - > animating_bitmap_type ) {
case 0 :
num + = br - > door_dir ;
if ( num > EXIT_DOOR_MAX ) {
num = EXIT_DOOR_MAX ;
br - > door_dir = - 1 ;
} else if ( num < 0 ) {
num = 0 ;
br - > door_dir = 1 ;
}
break ;
case 1 :
num + + ;
if ( num > OTHER_THING_MAX )
num = 0 ;
break ;
}
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
Assert ( num < 100 ) ;
if ( num > = 10 ) {
* ( pound_signp + 1 ) = ( num / 10 ) + ' 0 ' ;
* ( pound_signp + 2 ) = ( num % 10 ) + ' 0 ' ;
* ( pound_signp + 3 ) = 0 ;
} else {
* ( pound_signp + 1 ) = ( num % 10 ) + ' 0 ' ;
* ( pound_signp + 2 ) = 0 ;
}
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
bi = piggy_find_bitmap ( br - > bitmap_name ) ;
bitmap_ptr = & GameBitmaps [ bi . index ] ;
PIGGY_PAGE_IN ( bi ) ;
2016-09-24 18:06:11 +00:00
# if DXX_USE_OGL
2016-12-29 03:27:12 +00:00
ogl_ubitmapm_cs ( * grd_curcanv , 0 , 0 , bitmap_ptr - > bm_w * scale , bitmap_ptr - > bm_h * scale , * bitmap_ptr , 255 , F1_0 ) ;
2010-03-18 04:31:47 +00:00
# else
2017-01-01 00:45:43 +00:00
gr_bitmapm ( * grd_curcanv , 0 , 0 , * bitmap_ptr ) ;
2006-03-20 17:12:09 +00:00
# endif
2010-03-18 04:31:47 +00:00
grd_curcanv = curcanv_save ;
2007-03-22 11:32:22 +00:00
2010-03-18 04:31:47 +00:00
switch ( br - > animating_bitmap_type ) {
case 0 :
if ( num = = EXIT_DOOR_MAX ) {
br - > door_dir = - 1 ;
br - > door_div_count = 64 ;
} else if ( num = = 0 ) {
br - > door_dir = 1 ;
br - > door_div_count = 64 ;
}
break ;
case 1 :
break ;
2006-03-20 17:12:09 +00:00
}
}
2010-03-18 04:31:47 +00:00
}
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
//-----------------------------------------------------------------------------
2013-06-08 23:34:31 +00:00
static void show_briefing_bitmap ( grs_bitmap * bmp )
2010-03-18 04:31:47 +00:00
{
2013-12-08 18:22:17 +00:00
grs_canvas * curcanv_save ;
2006-03-20 17:12:09 +00:00
2016-12-29 03:27:11 +00:00
const bool hiresmode = HIRESMODE ;
const auto w = static_cast < float > ( SWIDTH ) / ( hiresmode ? 640 : 320 ) ;
const auto h = static_cast < float > ( SHEIGHT ) / ( hiresmode ? 480 : 200 ) ;
const float scale = ( w < h ) ? w : h ;
2016-12-28 15:28:08 +00:00
auto bitmap_canv = gr_create_sub_canvas ( * grd_curcanv , rescale_x ( 220 ) , rescale_y ( 55 ) , bmp - > bm_w * scale , bmp - > bm_h * scale ) ;
2010-03-18 04:31:47 +00:00
curcanv_save = grd_curcanv ;
gr_set_current_canvas ( bitmap_canv ) ;
2017-01-01 00:45:43 +00:00
show_fullscr ( * grd_curcanv , * bmp ) ;
2010-03-18 04:31:47 +00:00
gr_set_current_canvas ( curcanv_save ) ;
}
2007-03-22 11:32:22 +00:00
2010-03-18 04:31:47 +00:00
//-----------------------------------------------------------------------------
2013-06-08 23:34:31 +00:00
static void init_spinning_robot ( briefing * br ) //(int x,int y,int w,int h)
2010-03-18 04:31:47 +00:00
{
int x = rescale_x ( 138 ) ;
int y = rescale_y ( 55 ) ;
int w = rescale_x ( 166 ) ;
int h = rescale_y ( 138 ) ;
2006-03-20 17:12:09 +00:00
2015-01-17 18:31:40 +00:00
br - > robot_canv = gr_create_sub_canvas ( * grd_curcanv , x , y , w , h ) ;
2006-03-20 17:12:09 +00:00
}
2013-06-08 23:34:31 +00:00
static void show_spinning_robot_frame ( briefing * br , int robot_num )
2006-03-20 17:12:09 +00:00
{
2010-03-18 04:31:47 +00:00
grs_canvas * curcanv_save ;
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
if ( robot_num ! = - 1 ) {
2010-03-26 21:27:55 +00:00
br - > robot_angles . p = br - > robot_angles . b = 0 ;
2010-03-18 04:31:47 +00:00
br - > robot_angles . h + = 150 ;
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
curcanv_save = grd_curcanv ;
2014-09-06 23:55:43 +00:00
grd_curcanv = br - > robot_canv . get ( ) ;
2010-03-18 04:31:47 +00:00
Assert ( Robot_info [ robot_num ] . model_num ! = - 1 ) ;
draw_model_picture ( Robot_info [ robot_num ] . model_num , & br - > robot_angles ) ;
grd_curcanv = curcanv_save ;
2006-03-20 17:12:09 +00:00
}
}
//-----------------------------------------------------------------------------
2010-03-18 04:31:47 +00:00
# define KEY_DELAY_DEFAULT ((F1_0*20) / 1000)
2006-03-20 17:12:09 +00:00
2016-08-25 04:05:32 +00:00
namespace dsx {
2013-06-08 23:34:31 +00:00
static void init_new_page ( briefing * br )
2010-03-18 04:31:47 +00:00
{
br - > new_page = 0 ;
br - > robot_num = - 1 ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
load_briefing_screen ( br , br - > background_name ) ;
br - > text_x = br - > screen - > text_ulx ;
br - > text_y = br - > screen - > text_uly ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
br - > streamcount = 0 ;
if ( br - > guy_bitmap_show ) {
2014-11-30 22:09:20 +00:00
gr_free_bitmap_data ( br - > guy_bitmap ) ;
2010-03-18 04:31:47 +00:00
br - > guy_bitmap_show = 0 ;
}
2010-06-19 16:24:34 +00:00
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2010-03-18 04:31:47 +00:00
if ( br - > robot_playing )
{
2014-10-29 03:01:18 +00:00
DeInitRobotMovie ( br - > pMovie ) ;
2010-03-18 04:31:47 +00:00
br - > robot_playing = 0 ;
}
2013-03-03 01:03:33 +00:00
# endif
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
br - > start_time = 0 ;
br - > delay_count = KEY_DELAY_DEFAULT ;
}
2016-08-25 04:05:32 +00:00
}
2006-03-20 17:12:09 +00:00
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2013-09-02 23:58:27 +00:00
static int DefineBriefingBox ( const char * * buf )
2010-03-18 04:31:47 +00:00
{
int n , i = 0 ;
char name [ 20 ] ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
n = get_new_message_num ( buf ) ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
Assert ( n < MAX_BRIEFING_SCREENS ) ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
while ( * * buf ! = ' ' ) {
name [ i + + ] = * * buf ;
( * buf ) + + ;
2006-03-20 17:12:09 +00:00
}
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
name [ i ] = ' \0 ' ; // slap a delimiter on this guy
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
strcpy ( Briefing_screens [ n ] . bs_name , name ) ;
Briefing_screens [ n ] . level_num = get_new_message_num ( buf ) ;
Briefing_screens [ n ] . message_num = get_new_message_num ( buf ) ;
Briefing_screens [ n ] . text_ulx = get_new_message_num ( buf ) ;
Briefing_screens [ n ] . text_uly = get_new_message_num ( buf ) ;
Briefing_screens [ n ] . text_width = get_new_message_num ( buf ) ;
Briefing_screens [ n ] . text_height = get_message_num ( buf ) ; // NOTICE!!!
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
Briefing_screens [ n ] . text_ulx = rescale_x ( Briefing_screens [ n ] . text_ulx ) ;
Briefing_screens [ n ] . text_uly = rescale_y ( Briefing_screens [ n ] . text_uly ) ;
Briefing_screens [ n ] . text_width = rescale_x ( Briefing_screens [ n ] . text_width ) ;
Briefing_screens [ n ] . text_height = rescale_y ( Briefing_screens [ n ] . text_height ) ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
return ( n ) ;
}
2013-03-03 01:03:33 +00:00
# endif
2010-03-18 04:31:47 +00:00
2016-08-25 04:05:32 +00:00
namespace dsx {
2013-06-08 23:34:31 +00:00
static void free_briefing_screen ( briefing * br ) ;
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
// -----------------------------------------------------------------------------
// loads a briefing screen
2016-08-25 04:05:32 +00:00
}
namespace dsx {
2013-06-08 23:34:31 +00:00
static int load_briefing_screen ( briefing * br , const char * fname )
2010-03-18 04:31:47 +00:00
{
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
int pcx_error ;
char fname2 [ PATH_MAX ] , forigin [ PATH_MAX ] ;
free_briefing_screen ( br ) ;
snprintf ( fname2 , sizeof ( char ) * PATH_MAX , " %s " , fname ) ;
snprintf ( forigin , sizeof ( char ) * PATH_MAX , " %s " , PHYSFS_getRealDir ( fname ) ) ;
d_strlwr ( forigin ) ;
// check if we have a hires version of this image (not included in PC-version by default)
// Also if this hires image comes via external AddOn pack, only apply if requested image would be loaded from descent.hog - not a seperate mission which might want to show something else.
if ( SWIDTH > = 640 & & SHEIGHT > = 480 & & ( strstr ( forigin , " descent.hog " ) ! = NULL ) )
{
char * ptr ;
if ( ( ptr = strrchr ( fname2 , ' . ' ) ) )
* ptr = ' \0 ' ;
strncat ( fname2 , " h.pcx " , sizeof ( char ) * PATH_MAX ) ;
if ( ! PHYSFSX_exists ( fname2 , 1 ) )
snprintf ( fname2 , sizeof ( char ) * PATH_MAX , " %s " , fname ) ;
}
2014-11-30 22:09:20 +00:00
gr_init_bitmap_data ( br - > background ) ;
2013-03-03 01:03:33 +00:00
if ( d_stricmp ( br - > background_name , fname2 ) )
strncpy ( br - > background_name , fname2 , sizeof ( br - > background_name ) ) ;
if ( ( ! d_stricmp ( fname2 , " brief02.pcx " ) | | ! d_stricmp ( fname2 , " brief02h.pcx " ) ) & & cheats . baldguy )
2016-05-28 17:31:26 +00:00
if ( bald_guy_load ( " btexture.xxx " , & br - > background , gr_palette ) = = 0 )
2013-03-03 01:03:33 +00:00
{
return 0 ;
}
2016-05-28 17:31:26 +00:00
if ( ( pcx_error = pcx_read_bitmap ( fname2 , br - > background , gr_palette ) ) ! = PCX_ERROR_NONE )
2013-03-03 01:03:33 +00:00
{
Error ( " Error loading briefing screen <%s>, PCX load error: %s (%i) \n " , fname2 , pcx_errormsg ( pcx_error ) , pcx_error ) ;
}
// Hack: Make sure black parts of robot are shown black
2013-01-06 21:11:53 +00:00
if ( MacPig & & gr_palette [ 0 ] . r = = 63 & &
2013-03-03 01:03:33 +00:00
( ! d_stricmp ( fname2 , " brief03.pcx " ) | | ! d_stricmp ( fname2 , " end01.pcx " ) | |
! d_stricmp ( fname2 , " brief03h.pcx " ) | | ! d_stricmp ( fname2 , " end01h.pcx " )
) )
{
2016-11-19 17:24:52 +00:00
swap_0_255 ( br - > background ) ;
2013-01-06 21:11:53 +00:00
gr_palette [ 0 ] . r = gr_palette [ 0 ] . g = gr_palette [ 0 ] . b = 0 ;
gr_palette [ 255 ] . r = gr_palette [ 255 ] . g = gr_palette [ 255 ] . b = 63 ;
2013-03-03 01:03:33 +00:00
}
2017-01-01 00:45:43 +00:00
show_fullscr ( * grd_curcanv , br - > background ) ;
2013-03-03 01:03:33 +00:00
gr_palette_load ( gr_palette ) ;
set_briefing_fontcolor ( NULL ) ;
2015-01-17 18:31:40 +00:00
br - > screen = make_unique < briefing_screen > ( D1_Briefing_screens [ br - > cur_screen ] ) ;
2013-03-03 01:03:33 +00:00
br - > screen - > text_ulx = rescale_x ( br - > screen - > text_ulx ) ;
br - > screen - > text_uly = rescale_y ( br - > screen - > text_uly ) ;
br - > screen - > text_width = rescale_x ( br - > screen - > text_width ) ;
br - > screen - > text_height = rescale_y ( br - > screen - > text_height ) ;
init_char_pos ( br , br - > screen - > text_ulx , br - > screen - > text_uly ) ;
# elif defined(DXX_BUILD_DESCENT_II)
2010-03-18 04:31:47 +00:00
int pcx_error ;
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
free_briefing_screen ( br ) ;
2014-11-30 22:09:20 +00:00
gr_init_bitmap_data ( br - > background ) ;
2012-05-18 23:36:43 +00:00
if ( d_stricmp ( br - > background_name , fname ) )
2010-03-25 23:37:19 +00:00
strncpy ( br - > background_name , fname , sizeof ( br - > background_name ) ) ;
2006-03-20 17:12:09 +00:00
2016-05-28 17:31:26 +00:00
if ( ( pcx_error = pcx_read_bitmap ( fname , br - > background , gr_palette ) ) ! = PCX_ERROR_NONE )
2010-03-18 04:31:47 +00:00
Error ( " Error loading briefing screen <%s>, PCX load error: %s (%i) \n " , fname , pcx_errormsg ( pcx_error ) , pcx_error ) ;
2017-01-01 00:45:43 +00:00
show_fullscr ( * grd_curcanv , br - > background ) ;
2012-05-18 23:36:43 +00:00
if ( EMULATING_D1 & & ! d_stricmp ( fname , " brief03.pcx " ) ) // HACK, FIXME: D1 missions should use their own palette (PALETTE.256), but texture replacements not complete
2010-03-18 04:31:47 +00:00
gr_use_palette_table ( " groupa.256 " ) ;
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
gr_palette_load ( gr_palette ) ;
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
set_briefing_fontcolor ( br ) ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
if ( EMULATING_D1 )
{
br - > got_z = 1 ;
2015-01-17 18:31:40 +00:00
br - > screen = make_unique < briefing_screen > ( Briefing_screens [ br - > cur_screen ] ) ;
2010-03-18 04:31:47 +00:00
br - > screen - > text_ulx = rescale_x ( br - > screen - > text_ulx ) ;
br - > screen - > text_uly = rescale_y ( br - > screen - > text_uly ) ;
br - > screen - > text_width = rescale_x ( br - > screen - > text_width ) ;
br - > screen - > text_height = rescale_y ( br - > screen - > text_height ) ;
init_char_pos ( br , br - > screen - > text_ulx , br - > screen - > text_uly ) ;
2006-03-20 17:12:09 +00:00
}
2010-06-19 16:24:34 +00:00
2013-03-03 01:03:33 +00:00
# endif
2010-03-18 04:31:47 +00:00
return 1 ;
}
2016-08-25 04:05:32 +00:00
}
2007-08-08 12:38:13 +00:00
2016-08-25 04:05:32 +00:00
namespace dsx {
2013-06-08 23:34:31 +00:00
static void free_briefing_screen ( briefing * br )
2010-03-18 04:31:47 +00:00
{
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2010-03-09 02:41:34 +00:00
if ( br - > robot_playing )
2007-08-08 12:38:13 +00:00
{
2014-10-29 03:01:18 +00:00
DeInitRobotMovie ( br - > pMovie ) ;
2010-03-18 04:31:47 +00:00
br - > robot_playing = 0 ;
2007-08-08 12:38:13 +00:00
}
2013-03-03 01:03:33 +00:00
# endif
2014-09-06 23:55:43 +00:00
br - > robot_canv . reset ( ) ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2015-04-02 02:36:55 +00:00
br - > printing_channel . reset ( ) ;
2013-03-03 01:03:33 +00:00
# endif
2015-01-17 18:31:40 +00:00
if ( EMULATING_D1 )
br - > screen . reset ( ) ;
2006-03-20 17:12:09 +00:00
}
2016-08-25 04:05:32 +00:00
}
2006-03-20 17:12:09 +00:00
2016-08-25 04:05:32 +00:00
namespace dsx {
2013-06-08 23:34:31 +00:00
static int new_briefing_screen ( briefing * br , int first )
2006-03-20 17:12:09 +00:00
{
2010-03-18 04:31:47 +00:00
br - > new_screen = 0 ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
if ( ! first )
br - > cur_screen + + ;
while ( ( br - > cur_screen < NUM_D1_BRIEFING_SCREENS ) & & ( D1_Briefing_screens [ br - > cur_screen ] . level_num ! = br - > level_num ) )
{
br - > cur_screen + + ;
if ( ( br - > cur_screen = = NUM_D1_BRIEFING_SCREENS ) & & ( br - > level_num = = 0 ) )
{
// Showed the pre-game briefing, now show level 1 briefing
br - > level_num + + ;
br - > cur_screen = 0 ;
}
}
if ( br - > cur_screen = = NUM_D1_BRIEFING_SCREENS )
return 0 ; // finished
if ( ! load_briefing_screen ( br , D1_Briefing_screens [ br - > cur_screen ] . bs_name ) )
return 0 ;
br - > message = get_briefing_message ( br , D1_Briefing_screens [ br - > cur_screen ] . message_num ) ;
# elif defined(DXX_BUILD_DESCENT_II)
2010-03-25 03:08:01 +00:00
br - > got_z = 0 ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
if ( EMULATING_D1 )
{
if ( ! first )
br - > cur_screen + + ;
else
2013-03-03 01:03:33 +00:00
for ( int i = 0 ; i < NUM_D1_BRIEFING_SCREENS ; i + + )
2014-07-05 19:25:09 +00:00
Briefing_screens [ i ] = D1_Briefing_screens [ i ] ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
while ( ( br - > cur_screen < NUM_D1_BRIEFING_SCREENS ) & & ( Briefing_screens [ br - > cur_screen ] . level_num ! = br - > level_num ) )
{
br - > cur_screen + + ;
if ( ( br - > cur_screen = = NUM_D1_BRIEFING_SCREENS ) & & ( br - > level_num = = 0 ) )
{
// Showed the pre-game briefing, now show level 1 briefing
br - > level_num + + ;
br - > cur_screen = 0 ;
}
}
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
if ( br - > cur_screen = = NUM_D1_BRIEFING_SCREENS )
return 0 ; // finished
2010-03-01 07:27:51 +00:00
2010-03-18 04:31:47 +00:00
if ( ! load_briefing_screen ( br , Briefing_screens [ br - > cur_screen ] . bs_name ) )
return 0 ;
2006-03-20 17:12:09 +00:00
}
2010-03-18 04:31:47 +00:00
else if ( first )
{
br - > cur_screen = br - > level_num ;
2015-01-17 18:31:40 +00:00
br - > screen . reset ( & Briefing_screens [ 0 ] ) ;
2010-03-18 04:31:47 +00:00
init_char_pos ( br , br - > screen - > text_ulx , br - > screen - > text_uly - ( 8 * ( 1 + HIRESMODE ) ) ) ;
}
else
return 0 ; // finished
2006-03-20 17:12:09 +00:00
2010-03-18 04:31:47 +00:00
br - > message = get_briefing_message ( br , EMULATING_D1 ? Briefing_screens [ br - > cur_screen ] . message_num : br - > cur_screen ) ;
2015-04-02 02:36:55 +00:00
br - > printing_channel . reset ( ) ;
2013-03-03 01:03:33 +00:00
br - > dumb_adjust = 0 ;
br - > line_adjustment = 1 ;
br - > chattering = 0 ;
br - > robot_playing = 0 ;
# endif
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
if ( br - > message = = NULL )
return 0 ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
Current_color = 0 ;
br - > streamcount = 0 ;
br - > tab_stop = 0 ;
br - > flashing_cursor = 0 ;
br - > new_page = 0 ;
br - > start_time = 0 ;
br - > delay_count = KEY_DELAY_DEFAULT ;
br - > robot_num = - 1 ;
br - > bitmap_name [ 0 ] = 0 ;
br - > guy_bitmap_show = 0 ;
br - > prev_ch = - 1 ;
2010-06-19 16:24:34 +00:00
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2015-04-02 02:36:55 +00:00
if ( songs_is_playing ( ) = = - 1 & & ! br - > hum_channel )
br - > hum_channel . reset ( digi_start_sound ( digi_xlat_sound ( SOUND_BRIEFING_HUM ) , F1_0 / 2 , 0xFFFF / 2 , 1 , - 1 , - 1 , sound_object_none ) ) ;
2013-03-03 01:03:33 +00:00
# endif
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
return 1 ;
2006-03-20 17:12:09 +00:00
}
2016-08-25 04:05:32 +00:00
}
2006-03-20 17:12:09 +00:00
//-----------------------------------------------------------------------------
2016-08-25 04:05:32 +00:00
namespace dsx {
2016-10-04 06:05:44 +00:00
static window_event_result briefing_handler ( window * , const d_event & event , briefing * br )
2010-03-18 04:31:47 +00:00
{
2016-10-27 08:36:24 +00:00
window_event_result result ;
2014-10-04 21:47:13 +00:00
switch ( event . type )
2010-03-18 04:31:47 +00:00
{
case EVENT_WINDOW_ACTIVATED :
case EVENT_WINDOW_DEACTIVATED :
key_flush ( ) ;
break ;
2010-06-19 16:24:34 +00:00
2010-03-24 07:26:52 +00:00
case EVENT_MOUSE_BUTTON_DOWN :
2011-01-14 09:51:13 +00:00
if ( event_mouse_get_button ( event ) = = 0 )
2010-03-24 07:26:52 +00:00
{
if ( br - > new_screen )
{
if ( ! new_briefing_screen ( br , 0 ) )
{
2014-08-06 02:10:49 +00:00
return window_event_result : : close ;
2010-03-24 07:26:52 +00:00
}
}
else if ( br - > new_page )
init_new_page ( br ) ;
else
br - > delay_count = 0 ;
2014-08-06 02:10:49 +00:00
return window_event_result : : handled ;
2010-03-24 07:26:52 +00:00
}
break ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
case EVENT_KEY_COMMAND :
{
2011-01-14 09:51:13 +00:00
int key = event_key_get ( event ) ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
switch ( key )
{
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
case KEY_ALTED + KEY_B : // B - ALTED... BALT... BALD... get it?
cheats . baldguy = ! cheats . baldguy ;
break ;
# endif
2010-03-18 04:31:47 +00:00
case KEY_ESC :
2014-08-06 02:10:49 +00:00
return window_event_result : : close ;
2010-03-18 04:31:47 +00:00
case KEY_SPACEBAR :
case KEY_ENTER :
br - > delay_count = 0 ;
// fall through
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
default :
2016-10-27 08:36:24 +00:00
if ( ( result = call_default_handler ( event ) ) ! = window_event_result : : ignored )
return result ;
2010-04-02 05:01:08 +00:00
else if ( br - > new_screen )
2010-03-18 04:31:47 +00:00
{
if ( ! new_briefing_screen ( br , 0 ) )
{
2014-08-06 02:10:49 +00:00
return window_event_result : : close ;
2010-03-18 04:31:47 +00:00
}
}
else if ( br - > new_page )
init_new_page ( br ) ;
break ;
}
break ;
}
2011-02-14 22:52:33 +00:00
case EVENT_WINDOW_DRAW :
gr_set_current_canvas ( NULL ) ;
2010-03-18 04:31:47 +00:00
timer_delay2 ( 50 ) ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
if ( ! ( br - > new_screen | | br - > new_page ) )
while ( ! briefing_process_char ( br ) & & ! br - > delay_count )
{
check_text_pos ( br ) ;
if ( br - > new_page )
break ;
}
check_text_pos ( br ) ;
2010-03-24 13:59:42 +00:00
if ( br - > background . bm_data )
2017-01-01 00:45:43 +00:00
show_fullscr ( * grd_curcanv , br - > background ) ;
2010-03-18 04:31:47 +00:00
if ( br - > guy_bitmap_show )
show_briefing_bitmap ( & br - > guy_bitmap ) ;
if ( br - > bitmap_name [ 0 ] ! = 0 )
show_animated_bitmap ( br ) ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2010-03-18 04:31:47 +00:00
if ( br - > robot_playing )
2014-10-29 03:01:18 +00:00
RotateRobot ( br - > pMovie ) ;
2013-03-03 01:03:33 +00:00
# endif
2010-03-18 04:31:47 +00:00
if ( br - > robot_num ! = - 1 )
show_spinning_robot_frame ( br , br - > robot_num ) ;
gr_set_curfont ( GAME_FONT ) ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
gr_set_fontcolor ( Briefing_text_colors [ Current_color ] , - 1 ) ;
2014-08-08 02:54:50 +00:00
{
unsigned lastcolor = ~ 0u ;
2016-02-12 04:02:28 +00:00
range_for ( const auto b , partial_const_range ( br - > messagestream , br - > streamcount ) )
2014-08-08 02:54:50 +00:00
redraw_messagestream ( b , lastcolor ) ;
}
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
if ( br - > new_page | | br - > new_screen )
flash_cursor ( br , br - > flashing_cursor ) ;
else if ( br - > flashing_cursor )
2017-01-08 22:32:00 +00:00
gr_string ( * grd_curcanv , br - > text_x , br - > text_y , " _ " ) ;
2010-03-18 04:31:47 +00:00
break ;
case EVENT_WINDOW_CLOSE :
free_briefing_screen ( br ) ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2015-04-02 02:36:55 +00:00
br - > hum_channel . reset ( ) ;
2013-03-03 01:03:33 +00:00
# endif
2010-03-18 04:31:47 +00:00
break ;
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
default :
break ;
}
2014-08-06 02:10:49 +00:00
return window_event_result : : ignored ;
2010-03-18 04:31:47 +00:00
}
2016-08-25 04:05:32 +00:00
}
2010-03-18 04:31:47 +00:00
2016-01-09 16:38:12 +00:00
namespace dsx {
2014-07-23 02:27:22 +00:00
void do_briefing_screens ( const d_fname & filename , int level_num )
2006-03-20 17:12:09 +00:00
{
2014-07-26 22:45:01 +00:00
if ( ! * static_cast < const char * > ( filename ) )
2006-03-20 17:12:09 +00:00
return ;
2014-08-16 04:15:16 +00:00
auto br = make_unique < briefing > ( ) ;
2014-07-20 21:21:33 +00:00
briefing_init ( br . get ( ) , level_num ) ;
2010-06-19 16:24:34 +00:00
2014-07-20 21:21:33 +00:00
if ( ! load_screen_text ( filename , br - > text ) )
2010-03-09 02:41:34 +00:00
{
2006-03-20 17:12:09 +00:00
return ;
2010-03-09 02:41:34 +00:00
}
2010-06-19 16:24:34 +00:00
2016-10-15 00:53:20 +00:00
const auto wind = window_create ( grd_curscreen - > sc_canvas , 0 , 0 , SWIDTH , SHEIGHT , briefing_handler , br . get ( ) ) ;
2010-03-18 04:31:47 +00:00
if ( ! wind )
{
return ;
}
2006-03-20 17:12:09 +00:00
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
if ( ! ( EMULATING_D1 | | is_SHAREWARE | | is_MAC_SHARE | | is_D2_OEM | | ! PLAYING_BUILTIN_MISSION ) )
songs_stop_all ( ) ;
else
# endif
2010-04-05 13:48:23 +00:00
{
if ( ( songs_is_playing ( ) ! = SONG_BRIEFING ) & & ( songs_is_playing ( ) ! = SONG_ENDGAME ) )
songs_play_song ( SONG_BRIEFING , 1 ) ;
}
2006-03-20 17:12:09 +00:00
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
set_screen_mode ( SCREEN_MENU ) ;
# elif defined(DXX_BUILD_DESCENT_II)
2007-09-01 14:02:49 +00:00
// set screen correctly for robot movies
set_screen_mode ( SCREEN_MOVIE ) ;
2013-03-03 01:03:33 +00:00
# endif
2006-03-20 17:12:09 +00:00
gr_set_current_canvas ( NULL ) ;
2014-07-20 21:21:33 +00:00
if ( ! new_briefing_screen ( br . get ( ) , 1 ) )
2010-03-09 04:59:14 +00:00
{
2010-03-18 04:31:47 +00:00
window_close ( wind ) ;
return ;
2006-03-20 17:12:09 +00:00
}
2010-06-19 16:24:34 +00:00
2010-03-18 04:31:47 +00:00
// Stay where we are in the stack frame until briefing done
// Too complicated otherwise
2016-10-29 12:06:01 +00:00
event_process_all ( ) ;
2007-02-06 19:23:33 +00:00
}
2010-03-25 23:37:19 +00:00
2014-07-23 02:27:22 +00:00
void do_end_briefing_screens ( const d_fname & filename )
2010-03-25 23:37:19 +00:00
{
int level_num_screen = Current_level_num , showorder = 0 ;
2010-06-19 16:24:34 +00:00
2014-07-26 22:45:01 +00:00
if ( ! * static_cast < const char * > ( filename ) )
2010-03-25 23:37:19 +00:00
return ; // no filename, no ending
if ( EMULATING_D1 )
{
2016-08-28 22:41:47 +00:00
unsigned song ;
2012-05-18 23:36:43 +00:00
if ( d_stricmp ( filename , BIMD1_ENDING_FILE_OEM ) = = 0 )
2010-03-25 23:37:19 +00:00
{
2016-08-28 22:41:47 +00:00
song = SONG_ENDGAME ;
2010-03-25 23:37:19 +00:00
level_num_screen = ENDING_LEVEL_NUM_OEMSHARE ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
showorder = 1 ;
# endif
2010-03-25 23:37:19 +00:00
}
2012-05-18 23:36:43 +00:00
else if ( d_stricmp ( filename , BIMD1_ENDING_FILE_SHARE ) = = 0 )
2010-03-25 23:37:19 +00:00
{
2016-08-28 22:41:47 +00:00
song = SONG_BRIEFING ;
2010-03-25 23:37:19 +00:00
level_num_screen = ENDING_LEVEL_NUM_OEMSHARE ;
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_I)
showorder = 1 ;
# endif
2010-03-25 23:37:19 +00:00
}
else
{
2016-08-28 22:41:47 +00:00
song = SONG_ENDGAME ;
2010-03-25 23:37:19 +00:00
level_num_screen = ENDING_LEVEL_NUM_REGISTER ;
}
2016-08-28 22:41:47 +00:00
songs_play_song ( song , 1 ) ;
2010-03-25 23:37:19 +00:00
}
2013-03-03 01:03:33 +00:00
# if defined(DXX_BUILD_DESCENT_II)
2010-03-25 23:37:19 +00:00
else if ( PLAYING_BUILTIN_MISSION )
{
2016-08-28 22:41:47 +00:00
unsigned song ;
if ( ( d_stricmp ( filename , BIMD2_ENDING_FILE_OEM ) = = 0 & & ( song = SONG_TITLE , true ) ) | |
( d_stricmp ( filename , BIMD2_ENDING_FILE_SHARE ) = = 0 & & ( song = SONG_ENDGAME , true ) ) )
2010-03-25 23:37:19 +00:00
{
2016-08-28 22:41:47 +00:00
songs_play_song ( song , 1 ) ;
2010-03-25 23:37:19 +00:00
level_num_screen = 1 ;
showorder = 1 ;
}
}
else
{
2011-06-04 09:38:10 +00:00
songs_play_song ( SONG_ENDGAME , 1 ) ;
2010-07-08 22:12:53 +00:00
level_num_screen = Last_level + 1 ;
2010-03-25 23:37:19 +00:00
}
2013-03-03 01:03:33 +00:00
# endif
2010-03-25 23:37:19 +00:00
do_briefing_screens ( filename , level_num_screen ) ;
if ( showorder )
show_order_form ( ) ;
}
2016-01-09 16:38:12 +00:00
}