2006-03-20 16:43:15 +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
2009-05-03 12:31:30 +00:00
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE .
2006-03-20 16:43:15 +00:00
COPYRIGHT 1993 - 1998 PARALLAX SOFTWARE CORPORATION . ALL RIGHTS RESERVED .
*/
2008-04-06 20:23:28 +00:00
2006-03-20 16:43:15 +00:00
/*
*
* Inferno main menu .
*
*/
# include <stdio.h>
# include <string.h>
# include "menu.h"
# include "inferno.h"
# include "game.h"
# include "gr.h"
# include "key.h"
# include "iff.h"
# include "u_mem.h"
# include "error.h"
# include "bm.h"
# include "screens.h"
# include "joy.h"
# include "vecmat.h"
# include "effects.h"
# include "slew.h"
# include "gamemine.h"
# include "gamesave.h"
# include "palette.h"
# include "args.h"
# include "newdemo.h"
# include "timer.h"
# include "sounds.h"
# include "gameseq.h"
# include "text.h"
# include "gamefont.h"
# include "newmenu.h"
2009-03-04 21:04:43 +00:00
# include "net_ipx.h"
2006-03-20 16:43:15 +00:00
# include "scores.h"
# include "playsave.h"
# include "kconfig.h"
# include "titles.h"
# include "credits.h"
# include "texmap.h"
# include "polyobj.h"
# include "state.h"
# include "mission.h"
# include "songs.h"
# include "config.h"
# include "gauges.h"
# include "hudmsg.h" //for HUD_max_num_disp
2009-11-29 16:46:13 +00:00
# include "multi.h"
# ifdef USE_IPX
# include "net_ipx.h"
# endif
# ifdef USE_UDP
# include "net_udp.h"
2008-04-24 14:27:54 +00:00
# endif
2006-03-20 16:43:15 +00:00
# ifdef EDITOR
# include "editor/editor.h"
# endif
2008-07-26 17:57:13 +00:00
// Menu IDs...
enum MENUS
{
MENU_NEW_GAME = 0 ,
MENU_GAME ,
MENU_EDITOR ,
MENU_VIEW_SCORES ,
MENU_QUIT ,
MENU_LOAD_GAME ,
MENU_SAVE_GAME ,
MENU_DEMO_PLAY ,
MENU_LOAD_LEVEL ,
MENU_CONFIG ,
MENU_REJOIN_NETGAME ,
MENU_DIFFICULTY ,
MENU_HELP ,
MENU_NEW_PLAYER ,
2009-11-29 16:46:13 +00:00
# if defined(USE_UDP) || defined (USE_IPX)
2008-07-26 17:57:13 +00:00
MENU_MULTIPLAYER ,
# endif
MENU_SHOW_CREDITS ,
MENU_ORDER_INFO ,
MENU_PLAY_SONG ,
2009-11-29 16:46:13 +00:00
# ifdef USE_UDP
2009-11-24 09:48:53 +00:00
MENU_START_UDP_NETGAME ,
MENU_JOIN_MANUAL_UDP_NETGAME ,
MENU_JOIN_LIST_UDP_NETGAME ,
2009-11-29 16:46:13 +00:00
# endif
# ifdef USE_IPX
2008-07-26 17:57:13 +00:00
MENU_START_IPX_NETGAME ,
MENU_JOIN_IPX_NETGAME ,
2009-11-24 09:48:53 +00:00
MENU_START_KALI_NETGAME , // xKali support (not Windows Kali! Windows Kali is over IPX!)
2008-07-26 17:57:13 +00:00
MENU_JOIN_KALI_NETGAME ,
# endif
} ;
2006-03-20 16:43:15 +00:00
//ADD_ITEM("Start netgame...", MENU_START_NETGAME, -1 );
//ADD_ITEM("Send net message...", MENU_SEND_NET_MESSAGE, -1 );
# define ADD_ITEM(t,value,key) do { m[num_options].type=NM_TYPE_MENU; m[num_options].text=t; menu_choice[num_options]=value;num_options++; } while (0)
2009-05-03 12:31:30 +00:00
// Function Prototypes added after LINTING
void do_option ( int select ) ;
void do_new_game_menu ( void ) ;
2009-11-24 09:48:53 +00:00
void do_multi_player_menu ( ) ;
2007-07-26 23:56:00 +00:00
extern void newmenu_close ( ) ;
2008-03-23 13:03:26 +00:00
extern void ReorderPrimary ( ) ;
extern void ReorderSecondary ( ) ;
2007-07-26 23:56:00 +00:00
2010-01-07 14:49:07 +00:00
int autodemo_menu_check ( newmenu * menu , d_event * event , void * userdata )
2006-03-20 16:43:15 +00:00
{
int curtime ;
2010-01-07 14:49:07 +00:00
menu = menu ;
userdata = userdata ;
if ( event - > type = = EVENT_KEY_COMMAND )
{
// Don't allow them to hit ESC in the main menu.
if ( ( ( d_event_keycommand * ) event ) - > keycode = = KEY_ESC )
return 1 ;
}
else if ( event - > type ! = EVENT_IDLE )
return 0 ;
2006-03-20 16:43:15 +00:00
2009-11-24 22:43:41 +00:00
curtime = timer_get_fixed_seconds ( ) ;
2008-01-13 13:27:58 +00:00
if ( keyd_time_when_last_pressed + i2f ( 45 ) < curtime | | GameArg . SysAutoDemo )
{
if ( curtime < 0 ) curtime = 0 ;
keyd_time_when_last_pressed = curtime ; // Reset timer so that disk won't thrash if no demos.
newdemo_start_playback ( NULL ) ; // Randomly pick a file
if ( Newdemo_state = = ND_STATE_PLAYBACK )
{
Function_mode = FMODE_GAME ;
2010-01-07 14:49:07 +00:00
return - 2 ;
2006-03-20 16:43:15 +00:00
}
}
2010-01-07 14:49:07 +00:00
return 0 ;
2006-03-20 16:43:15 +00:00
}
static int main_menu_choice = 0 ;
// -----------------------------------------------------------------------------
// Create the main menu.
void create_main_menu ( newmenu_item * m , int * menu_choice , int * callers_num_options )
{
int num_options ;
# ifndef DEMO_ONLY
num_options = 0 ;
set_screen_mode ( SCREEN_MENU ) ;
ADD_ITEM ( TXT_NEW_GAME , MENU_NEW_GAME , KEY_N ) ;
2009-05-03 12:31:30 +00:00
ADD_ITEM ( TXT_LOAD_GAME , MENU_LOAD_GAME , KEY_L ) ;
2009-11-29 16:46:13 +00:00
# if defined(USE_UDP) || defined(USE_IPX)
2006-03-20 16:43:15 +00:00
ADD_ITEM ( TXT_MULTIPLAYER_ , MENU_MULTIPLAYER , - 1 ) ;
# endif
2009-05-03 12:31:30 +00:00
2006-03-20 16:43:15 +00:00
ADD_ITEM ( TXT_OPTIONS_ , MENU_CONFIG , - 1 ) ;
ADD_ITEM ( TXT_CHANGE_PILOTS , MENU_NEW_PLAYER , unused ) ;
ADD_ITEM ( TXT_VIEW_DEMO , MENU_DEMO_PLAY , 0 ) ;
ADD_ITEM ( TXT_VIEW_SCORES , MENU_VIEW_SCORES , KEY_V ) ;
2009-05-31 07:20:26 +00:00
if ( ! cfexist ( " warning.pcx " ) ) /* SHAREWARE */
2009-05-03 12:31:30 +00:00
ADD_ITEM ( TXT_ORDERING_INFO , MENU_ORDER_INFO , - 1 ) ;
2006-03-20 16:43:15 +00:00
ADD_ITEM ( TXT_CREDITS , MENU_SHOW_CREDITS , - 1 ) ;
# endif
ADD_ITEM ( TXT_QUIT , MENU_QUIT , KEY_Q ) ;
2009-05-03 12:31:30 +00:00
# ifndef RELEASE
2006-03-20 16:43:15 +00:00
if ( ! ( Game_mode & GM_MULTI ) ) {
//m[num_options].type=NM_TYPE_TEXT;
//m[num_options++].text=" Debug options:";
ADD_ITEM ( " Load level... " , MENU_LOAD_LEVEL , KEY_N ) ;
# ifdef EDITOR
ADD_ITEM ( " Editor " , MENU_EDITOR , KEY_E ) ;
# endif
}
ADD_ITEM ( " Play song " , MENU_PLAY_SONG , - 1 ) ;
2009-05-03 12:31:30 +00:00
# endif
2006-03-20 16:43:15 +00:00
* callers_num_options = num_options ;
}
//returns number of item chosen
int DoMenu ( )
{
int menu_choice [ 25 ] ;
newmenu_item m [ 25 ] ;
int num_options = 0 ;
if ( Players [ Player_num ] . callsign [ 0 ] = = 0 ) {
RegisterPlayer ( ) ;
return 0 ;
}
2007-03-31 21:39:48 +00:00
2006-03-20 16:43:15 +00:00
do {
2009-05-03 12:31:30 +00:00
create_main_menu ( m , menu_choice , & num_options ) ; // may have to change, eg, maybe selected pilot and no save games.
2006-03-20 16:43:15 +00:00
keyd_time_when_last_pressed = timer_get_fixed_seconds ( ) ; // .. 20 seconds from now!
2009-05-03 12:31:30 +00:00
if ( main_menu_choice < 0 )
main_menu_choice = 0 ;
2010-01-07 14:49:07 +00:00
main_menu_choice = newmenu_do2 ( " " , NULL , num_options , m , autodemo_menu_check , NULL , main_menu_choice , Menu_pcx_name ) ;
2009-05-03 12:31:30 +00:00
if ( main_menu_choice > - 1 ) do_option ( menu_choice [ main_menu_choice ] ) ;
2006-03-20 16:43:15 +00:00
} while ( Function_mode = = FMODE_MENU ) ;
return main_menu_choice ;
}
extern void show_order_form ( void ) ; // John didn't want this in inferno.h so I just externed it.
2010-01-08 01:55:12 +00:00
int select_song_callback ( listbox * lb , d_event * event , void * userdata )
{
int citem = listbox_get_citem ( lb ) ;
userdata = userdata ;
if ( event - > type ! = EVENT_NEWMENU_SELECTED )
return 0 ;
if ( citem > - 1 )
songs_play_song ( citem , 0 ) ;
return 1 ; // stay in menu until user escapes
}
2006-03-20 16:43:15 +00:00
//returns flag, true means quit menu
void do_option ( int select )
{
switch ( select ) {
case MENU_NEW_GAME :
do_new_game_menu ( ) ;
break ;
case MENU_GAME :
break ;
case MENU_DEMO_PLAY :
2009-05-03 12:31:30 +00:00
{
2009-12-08 11:01:36 +00:00
char demo_file [ PATH_MAX ] ;
if ( get_filename ( TXT_SELECT_DEMO , " .dem " , demo_file , 1 ) )
2009-05-03 12:31:30 +00:00
newdemo_start_playback ( demo_file ) ;
2006-03-20 16:43:15 +00:00
break ;
2009-05-03 12:31:30 +00:00
}
2006-03-20 16:43:15 +00:00
case MENU_LOAD_GAME :
2009-05-03 12:31:30 +00:00
state_restore_all ( 0 ) ;
2006-03-20 16:43:15 +00:00
break ;
# ifdef EDITOR
case MENU_EDITOR :
Function_mode = FMODE_EDITOR ;
init_cockpit ( ) ;
break ;
# endif
case MENU_VIEW_SCORES :
scores_view ( - 1 ) ;
break ;
2009-05-03 12:31:30 +00:00
# if 1 //def SHAREWARE
2006-03-20 16:43:15 +00:00
case MENU_ORDER_INFO :
show_order_form ( ) ;
break ;
2009-05-03 12:31:30 +00:00
# endif
2006-03-20 16:43:15 +00:00
case MENU_QUIT :
# ifdef EDITOR
if ( ! SafetyCheck ( ) ) break ;
# endif
Function_mode = FMODE_EXIT ;
break ;
case MENU_NEW_PLAYER :
RegisterPlayer ( ) ; //1 == allow escape out of menu
break ;
2009-05-03 12:31:30 +00:00
# ifndef RELEASE
2006-03-20 16:43:15 +00:00
2010-01-08 01:55:12 +00:00
case MENU_PLAY_SONG :
{
char * m [ MAX_NUM_SONGS ] ;
int i ;
2006-03-20 16:43:15 +00:00
2010-01-08 01:55:12 +00:00
for ( i = 0 ; i < Num_songs ; i + + )
m [ i ] = Songs [ i ] . filename ;
newmenu_listbox ( " Select Song " , Num_songs , m , 1 , select_song_callback , NULL ) ;
2006-03-20 16:43:15 +00:00
break ;
2010-01-08 01:55:12 +00:00
}
2009-05-03 12:31:30 +00:00
case MENU_LOAD_LEVEL :
2008-01-23 17:25:09 +00:00
if ( Current_mission | | select_mission ( 0 , " Load Level \n \n Select mission " ) )
{
newmenu_item m ;
char text [ 10 ] = " " ;
int new_level_num ;
m . type = NM_TYPE_INPUT ; m . text_len = 10 ; m . text = text ;
2010-01-07 14:49:07 +00:00
newmenu_do ( NULL , " Enter level to load " , 1 , & m , NULL , NULL ) ;
2008-01-23 17:25:09 +00:00
new_level_num = atoi ( m . text ) ;
if ( new_level_num ! = 0 & & new_level_num > = Last_secret_level & & new_level_num < = Last_level ) {
StartNewGame ( new_level_num ) ;
}
2006-03-20 16:43:15 +00:00
}
break ;
2009-05-03 12:31:30 +00:00
# endif //ifndef RELEASE
2006-03-20 16:43:15 +00:00
2009-11-29 16:46:13 +00:00
# ifdef USE_UDP
2009-11-24 09:48:53 +00:00
case MENU_START_UDP_NETGAME :
multi_protocol = MULTI_PROTO_UDP ;
net_udp_start_game ( ) ;
break ;
case MENU_JOIN_MANUAL_UDP_NETGAME :
multi_protocol = MULTI_PROTO_UDP ;
net_udp_manual_join_game ( ) ;
break ;
case MENU_JOIN_LIST_UDP_NETGAME :
multi_protocol = MULTI_PROTO_UDP ;
//net_udp_list_join_game();
break ;
2009-11-29 16:46:13 +00:00
# endif
# ifdef USE_IPX
2007-05-31 22:30:18 +00:00
case MENU_START_IPX_NETGAME :
2009-04-09 07:41:30 +00:00
multi_protocol = MULTI_PROTO_IPX ;
2009-03-20 12:10:38 +00:00
ipxdrv_set ( NETPROTO_IPX ) ;
2009-04-09 07:41:30 +00:00
net_ipx_start_game ( ) ;
2008-11-09 23:51:19 +00:00
break ;
2007-05-31 22:30:18 +00:00
case MENU_JOIN_IPX_NETGAME :
2009-04-09 07:41:30 +00:00
multi_protocol = MULTI_PROTO_IPX ;
2009-03-20 12:10:38 +00:00
ipxdrv_set ( NETPROTO_IPX ) ;
2009-04-09 07:41:30 +00:00
net_ipx_join_game ( ) ;
2008-11-09 23:51:19 +00:00
break ;
2007-05-31 22:30:18 +00:00
case MENU_START_KALI_NETGAME :
2009-04-09 07:41:30 +00:00
multi_protocol = MULTI_PROTO_IPX ;
2009-03-20 12:10:38 +00:00
ipxdrv_set ( NETPROTO_KALINIX ) ;
2009-04-09 07:41:30 +00:00
net_ipx_start_game ( ) ;
2008-11-09 23:51:19 +00:00
break ;
2007-05-31 22:30:18 +00:00
case MENU_JOIN_KALI_NETGAME :
2009-04-09 07:41:30 +00:00
multi_protocol = MULTI_PROTO_IPX ;
2009-03-20 12:10:38 +00:00
ipxdrv_set ( NETPROTO_KALINIX ) ;
2009-04-09 07:41:30 +00:00
net_ipx_join_game ( ) ;
2006-03-20 16:43:15 +00:00
break ;
2009-11-29 16:46:13 +00:00
# endif
# if defined(USE_UDP) || defined(USE_IPX)
2006-03-20 16:43:15 +00:00
case MENU_MULTIPLAYER :
do_multi_player_menu ( ) ;
break ;
2009-11-29 16:46:13 +00:00
# endif
2006-03-20 16:43:15 +00:00
case MENU_CONFIG :
do_options_menu ( ) ;
break ;
case MENU_SHOW_CREDITS :
2008-05-24 08:59:35 +00:00
songs_stop_all ( ) ;
2008-10-16 17:27:02 +00:00
credits_show ( NULL ) ;
2006-03-20 16:43:15 +00:00
break ;
default :
Error ( " Unknown option %d in do_option " , select ) ;
break ;
2009-05-03 12:31:30 +00:00
}
2006-03-20 16:43:15 +00:00
}
2009-12-08 11:01:36 +00:00
void delete_player_saved_games ( char * name )
{
int i ;
char filename [ FILENAME_LEN + 9 ] ;
for ( i = 0 ; i < 10 ; i + + )
{
sprintf ( filename , GameArg . SysUsePlayersDir ? " Players/%s.sg%x " : " %s.sg%x " , name , i ) ;
PHYSFS_delete ( filename ) ;
}
}
int fname_sort_func ( char * * e0 , char * * e1 )
{
return stricmp ( * e0 , * e1 ) ;
}
2010-01-07 14:49:07 +00:00
enum file_mode
2009-12-08 11:01:36 +00:00
{
2010-01-07 14:49:07 +00:00
FILE_PLAYER_MODE = 1 ,
FILE_DEMO_MODE
2009-12-08 11:01:36 +00:00
} ;
2010-01-15 13:02:28 +00:00
typedef struct file_list
{
enum file_mode mode ;
char * * list ; // just to free it in below callback
} file_list ;
int filename_menu_handler ( listbox * lb , d_event * event , file_list * l )
2009-12-08 11:01:36 +00:00
{
2010-01-07 14:49:07 +00:00
char * * items = listbox_get_items ( lb ) ;
int citem = listbox_get_citem ( lb ) ;
if ( event - > type ! = EVENT_KEY_COMMAND )
return 0 ;
switch ( ( ( d_event_keycommand * ) event ) - > keycode )
2009-12-08 11:01:36 +00:00
{
case KEY_CTRLED + KEY_D :
2010-01-15 13:02:28 +00:00
if ( ( ( l - > mode = = FILE_PLAYER_MODE ) & & ( citem > 0 ) ) | | ( ( l - > mode = = FILE_DEMO_MODE ) & & ( citem > = 0 ) ) )
2009-12-08 11:01:36 +00:00
{
int x = 1 ;
2010-01-15 13:02:28 +00:00
if ( l - > mode = = FILE_PLAYER_MODE )
x = nm_messagebox ( NULL , 2 , TXT_YES , TXT_NO , " %s %s? " , TXT_DELETE_PILOT , items [ citem ] + ( ( ( l - > mode = = FILE_PLAYER_MODE ) & & items [ citem ] [ 0 ] = = ' $ ' ) ? 1 : 0 ) ) ;
else if ( l - > mode = = FILE_DEMO_MODE )
x = nm_messagebox ( NULL , 2 , TXT_YES , TXT_NO , " %s %s? " , TXT_DELETE_DEMO , items [ citem ] + ( ( ( l - > mode = = FILE_DEMO_MODE ) & & items [ citem ] [ 0 ] = = ' $ ' ) ? 1 : 0 ) ) ;
2009-12-08 11:01:36 +00:00
if ( x = = 0 ) {
char * p ;
char plxfile [ PATH_MAX ] ;
int ret ;
char name [ PATH_MAX ] ;
2010-01-07 14:49:07 +00:00
p = items [ citem ] + strlen ( items [ citem ] ) ;
2010-01-15 13:02:28 +00:00
if ( l - > mode = = FILE_PLAYER_MODE )
2009-12-08 11:01:36 +00:00
* p = ' . ' ;
2010-01-15 13:02:28 +00:00
strcpy ( name , ( l - > mode = = FILE_DEMO_MODE ) ? DEMO_DIR : ( ( ( l - > mode = = FILE_PLAYER_MODE ) & & GameArg . SysUsePlayersDir ) ? " Players/ " : " " ) ) ;
2010-01-07 14:49:07 +00:00
strcat ( name , items [ citem ] ) ;
2009-12-08 11:01:36 +00:00
ret = ! PHYSFS_delete ( name ) ;
2010-01-15 13:02:28 +00:00
if ( l - > mode = = FILE_PLAYER_MODE )
2009-12-08 11:01:36 +00:00
* p = 0 ;
2010-01-15 13:02:28 +00:00
if ( ( ! ret ) & & ( l - > mode = = FILE_PLAYER_MODE ) ) {
2010-01-07 14:49:07 +00:00
delete_player_saved_games ( items [ citem ] ) ;
2009-12-08 11:01:36 +00:00
// delete PLX file
2010-01-07 14:49:07 +00:00
sprintf ( plxfile , GameArg . SysUsePlayersDir ? " Players/%.8s.plx " : " %.8s.plx " , items [ citem ] ) ;
2009-12-08 11:01:36 +00:00
if ( cfexist ( plxfile ) )
PHYSFS_delete ( plxfile ) ;
}
if ( ret ) {
2010-01-15 13:02:28 +00:00
if ( l - > mode = = FILE_PLAYER_MODE )
nm_messagebox ( NULL , 1 , TXT_OK , " %s %s %s " , TXT_COULDNT , TXT_DELETE_PILOT , items [ citem ] + ( ( ( l - > mode = = FILE_PLAYER_MODE ) & & items [ citem ] [ 0 ] = = ' $ ' ) ? 1 : 0 ) ) ;
else if ( l - > mode = = FILE_DEMO_MODE )
nm_messagebox ( NULL , 1 , TXT_OK , " %s %s %s " , TXT_COULDNT , TXT_DELETE_DEMO , items [ citem ] + ( ( ( l - > mode = = FILE_DEMO_MODE ) & & items [ citem ] [ 0 ] = = ' $ ' ) ? 1 : 0 ) ) ;
2010-01-07 14:49:07 +00:00
}
else
listbox_delete_item ( lb , citem ) ;
2009-12-08 11:01:36 +00:00
}
2010-01-07 14:49:07 +00:00
return 1 ;
2009-12-08 11:01:36 +00:00
}
break ;
case KEY_CTRLED + KEY_C :
2010-01-15 13:02:28 +00:00
if ( l - > mode = = FILE_DEMO_MODE )
2009-12-08 11:01:36 +00:00
{
int x = 1 ;
char bakname [ PATH_MAX ] ;
// Get backup name
2010-01-15 13:02:28 +00:00
change_filename_extension ( bakname , items [ citem ] + ( ( ( l - > mode = = FILE_DEMO_MODE ) & & items [ citem ] [ 0 ] = = ' $ ' ) ? 1 : 0 ) , DEMO_BACKUP_EXT ) ;
2009-12-08 11:01:36 +00:00
x = nm_messagebox ( NULL , 2 , TXT_YES , TXT_NO , " Are you sure you want to \n "
" swap the endianness of \n "
" %s? If the file is \n "
" already endian native, D1X \n "
" will likely crash. A backup \n "
2010-01-15 13:02:28 +00:00
" %s will be created " , items [ citem ] + ( ( ( l - > mode = = FILE_DEMO_MODE ) & & items [ citem ] [ 0 ] = = ' $ ' ) ? 1 : 0 ) , bakname ) ;
2010-01-07 14:49:07 +00:00
if ( ! x )
newdemo_swap_endian ( items [ citem ] ) ;
2009-12-08 11:01:36 +00:00
2010-01-07 14:49:07 +00:00
return 1 ;
2009-12-08 11:01:36 +00:00
}
break ;
}
2010-01-07 14:49:07 +00:00
return 0 ;
2009-12-08 11:01:36 +00:00
}
int get_filename ( char * title , char * type , char * filename , int allow_abort_flag )
{
char * * m ;
char * * f ;
2010-01-15 13:02:28 +00:00
file_list * l ;
2009-12-08 11:01:36 +00:00
char * types [ ] = { type , NULL } ;
int i = 0 , NumItems ;
int citem = 0 ;
2010-01-15 13:02:28 +00:00
MALLOC ( l , file_list , 1 ) ;
if ( ! l )
return 0 ;
l - > mode = 0 ;
2009-12-08 11:01:36 +00:00
if ( ! stricmp ( type , " .plr " ) )
2010-01-15 13:02:28 +00:00
l - > mode = FILE_PLAYER_MODE ;
2009-12-08 11:01:36 +00:00
else if ( ! stricmp ( type , " .dem " ) )
2010-01-15 13:02:28 +00:00
l - > mode = FILE_DEMO_MODE ;
2009-12-08 11:01:36 +00:00
2010-01-15 13:02:28 +00:00
l - > list = PHYSFSX_findFiles ( ( l - > mode = = FILE_DEMO_MODE ) ? DEMO_DIR : ( ( ( l - > mode = = FILE_PLAYER_MODE ) & & GameArg . SysUsePlayersDir ) ? " Players/ " : " " ) , types ) ;
if ( ! l - > list )
{
d_free ( l ) ;
2009-12-08 11:01:36 +00:00
return 0 ; // memory error
2010-01-15 13:02:28 +00:00
}
if ( ! * l - > list & & ( l - > mode = = FILE_DEMO_MODE ) & & ( citem > - 1 ) )
2009-12-08 11:01:36 +00:00
{
nm_messagebox ( NULL , 1 , TXT_OK , " %s %s \n %s " , TXT_NO_DEMO_FILES , TXT_USE_F5 , TXT_TO_CREATE_ONE ) ;
2010-01-15 13:02:28 +00:00
PHYSFS_freeList ( l - > list ) ;
d_free ( l ) ;
2009-12-08 11:01:36 +00:00
return 0 ;
}
2010-01-15 13:02:28 +00:00
else if ( ! * l - > list & & ( l - > mode = = FILE_PLAYER_MODE ) ) {
2009-12-08 11:01:36 +00:00
strcpy ( filename , TXT_CREATE_NEW ) ; // make a new player without showing listbox
2010-01-15 13:02:28 +00:00
PHYSFS_freeList ( l - > list ) ;
d_free ( l ) ;
2009-12-08 11:01:36 +00:00
return 0 ;
}
2010-01-15 13:02:28 +00:00
else if ( ! * l - > list ) {
2009-12-08 11:01:36 +00:00
nm_messagebox ( NULL , 1 , " Ok " , " %s \n '%s' %s " , TXT_NO_FILES_MATCHING , type , TXT_WERE_FOUND ) ;
2010-01-15 13:02:28 +00:00
PHYSFS_freeList ( l - > list ) ;
d_free ( l ) ;
2009-12-08 11:01:36 +00:00
return 0 ;
} // else create a player file
2010-01-15 13:02:28 +00:00
for ( NumItems = 0 ; l - > list [ NumItems ] ! = NULL ; NumItems + + ) { }
if ( l - > mode = = FILE_PLAYER_MODE )
2009-12-08 11:01:36 +00:00
NumItems + + ;
MALLOC ( m , char * , NumItems ) ;
if ( m = = NULL )
{
2010-01-15 13:02:28 +00:00
PHYSFS_freeList ( l - > list ) ;
d_free ( l ) ;
2009-12-08 11:01:36 +00:00
return 0 ;
}
2010-01-15 13:02:28 +00:00
if ( l - > mode = = FILE_PLAYER_MODE )
2009-12-08 11:01:36 +00:00
m [ i + + ] = TXT_CREATE_NEW ;
2010-01-15 13:02:28 +00:00
for ( f = l - > list ; * f ! = NULL ; f + + )
2009-12-08 11:01:36 +00:00
{
m [ i + + ] = * f ;
2010-01-15 13:02:28 +00:00
if ( l - > mode = = FILE_PLAYER_MODE )
2009-12-08 11:01:36 +00:00
{
char * p ;
p = strchr ( * f , ' . ' ) ;
if ( p )
* p = ' \0 ' ; // chop the .plr
if ( ( p - * f ) > 8 )
* f [ 8 ] = 0 ; // sorry guys, can only have up to eight chars for the player name
}
}
// Sort by name, except the <Create New Player> string if applicable
2010-01-15 13:02:28 +00:00
qsort ( & m [ l - > mode = = FILE_PLAYER_MODE ? 1 : 0 ] , NumItems - ( l - > mode = = FILE_PLAYER_MODE ) , sizeof ( char * ) , ( int ( * ) ( const void * , const void * ) ) fname_sort_func ) ;
2009-12-08 11:01:36 +00:00
2010-01-15 13:02:28 +00:00
if ( l - > mode = = FILE_PLAYER_MODE )
2009-12-08 11:01:36 +00:00
for ( i = 0 ; i < NumItems ; i + + )
if ( ! stricmp ( Players [ Player_num ] . callsign , m [ i ] ) )
citem = i ;
2010-01-15 13:02:28 +00:00
citem = newmenu_listbox1 ( title , NumItems , m , allow_abort_flag , citem , ( int ( * ) ( listbox * , d_event * , void * ) ) filename_menu_handler , ( void * ) l - > mode ) ;
2009-12-08 11:01:36 +00:00
if ( citem > - 1 )
2010-01-15 13:02:28 +00:00
strncpy ( filename , m [ citem ] + ( ( ( l - > mode = = FILE_PLAYER_MODE ) & & m [ citem ] [ 0 ] = = ' $ ' ) ? 1 : 0 ) , PATH_MAX ) ;
2009-12-08 11:01:36 +00:00
2010-01-15 13:02:28 +00:00
PHYSFS_freeList ( l - > list ) ;
2009-12-08 11:01:36 +00:00
d_free ( m ) ;
2010-01-15 13:02:28 +00:00
d_free ( l ) ;
2009-12-08 11:01:36 +00:00
2010-01-07 14:49:07 +00:00
if ( citem < 0 )
2009-12-08 11:01:36 +00:00
return 0 ; // aborted
return 1 ;
}
2006-03-20 16:43:15 +00:00
int do_difficulty_menu ( )
{
int s ;
newmenu_item m [ 5 ] ;
m [ 0 ] . type = NM_TYPE_MENU ; m [ 0 ] . text = MENU_DIFFICULTY_TEXT ( 0 ) ;
m [ 1 ] . type = NM_TYPE_MENU ; m [ 1 ] . text = MENU_DIFFICULTY_TEXT ( 1 ) ;
m [ 2 ] . type = NM_TYPE_MENU ; m [ 2 ] . text = MENU_DIFFICULTY_TEXT ( 2 ) ;
m [ 3 ] . type = NM_TYPE_MENU ; m [ 3 ] . text = MENU_DIFFICULTY_TEXT ( 3 ) ;
m [ 4 ] . type = NM_TYPE_MENU ; m [ 4 ] . text = MENU_DIFFICULTY_TEXT ( 4 ) ;
2010-01-07 14:49:07 +00:00
s = newmenu_do1 ( NULL , TXT_DIFFICULTY_LEVEL , NDL , m , NULL , NULL , Difficulty_level ) ;
2006-03-20 16:43:15 +00:00
if ( s > - 1 ) {
if ( s ! = Difficulty_level )
2009-05-03 12:31:30 +00:00
{
2008-04-13 00:28:36 +00:00
PlayerCfg . DefaultDifficulty = s ;
2006-03-20 16:43:15 +00:00
write_player_file ( ) ;
}
Difficulty_level = s ;
return 1 ;
}
return 0 ;
}
void do_new_game_menu ( )
{
int new_level_num , player_highest_level ;
2008-01-23 17:25:09 +00:00
if ( ! select_mission ( 0 , " New Game \n \n Select mission " ) )
return ;
2006-03-20 16:43:15 +00:00
new_level_num = 1 ;
player_highest_level = get_highest_level ( ) ;
if ( player_highest_level > Last_level )
player_highest_level = Last_level ;
if ( player_highest_level > 1 ) {
2008-01-23 17:25:09 +00:00
newmenu_item m [ 4 ] ;
2006-03-20 16:43:15 +00:00
char info_text [ 80 ] ;
char num_text [ 10 ] ;
int choice ;
2008-01-23 17:25:09 +00:00
int n_items ;
2006-03-20 16:43:15 +00:00
try_again :
sprintf ( info_text , " %s %d " , TXT_START_ANY_LEVEL , player_highest_level ) ;
m [ 0 ] . type = NM_TYPE_TEXT ; m [ 0 ] . text = info_text ;
m [ 1 ] . type = NM_TYPE_INPUT ; m [ 1 ] . text_len = 10 ; m [ 1 ] . text = num_text ;
2008-01-23 17:25:09 +00:00
n_items = 2 ;
2006-03-20 16:43:15 +00:00
strcpy ( num_text , " 1 " ) ;
2010-01-07 14:49:07 +00:00
choice = newmenu_do ( NULL , TXT_SELECT_START_LEV , n_items , m , NULL , NULL ) ;
2006-03-20 16:43:15 +00:00
if ( choice = = - 1 | | m [ 1 ] . text [ 0 ] = = 0 )
return ;
new_level_num = atoi ( m [ 1 ] . text ) ;
if ( ! ( new_level_num > 0 & & new_level_num < = player_highest_level ) ) {
m [ 0 ] . text = TXT_ENTER_TO_CONT ;
nm_messagebox ( NULL , 1 , TXT_OK , TXT_INVALID_LEVEL ) ;
goto try_again ;
}
}
2007-09-28 22:44:04 +00:00
2008-04-13 00:28:36 +00:00
Difficulty_level = PlayerCfg . DefaultDifficulty ;
2006-03-20 16:43:15 +00:00
if ( ! do_difficulty_menu ( ) )
return ;
StartNewGame ( new_level_num ) ;
}
2010-01-17 14:42:59 +00:00
void do_sound_menu ( ) ;
void input_config ( ) ;
void change_res ( ) ;
void do_graphics_menu ( ) ;
void do_misc_menu ( ) ;
2010-01-07 14:49:07 +00:00
int options_menuset ( newmenu * menu , d_event * event , void * userdata )
2009-05-03 12:31:30 +00:00
{
2010-01-17 14:42:59 +00:00
switch ( event - > type )
2009-05-03 12:31:30 +00:00
{
2010-01-17 14:42:59 +00:00
case EVENT_IDLE : // FIXME: Should become EVENT_ITEM_CHANGED later
if ( newmenu_get_citem ( menu ) = = 4 )
{
gr_palette_set_gamma ( newmenu_get_items ( menu ) [ 4 ] . value ) ;
}
return 0 ; // for idle events
break ;
case EVENT_NEWMENU_SELECTED :
switch ( newmenu_get_citem ( menu ) )
{
case 0 : do_sound_menu ( ) ; break ;
case 2 : input_config ( ) ; break ;
case 5 : change_res ( ) ; break ;
case 6 : do_graphics_menu ( ) ; break ;
case 8 : ReorderPrimary ( ) ; break ;
case 9 : ReorderSecondary ( ) ; break ;
case 10 : do_misc_menu ( ) ; break ;
}
break ; // stay in menu until escape
case EVENT_CLOSE :
write_player_file ( ) ;
break ;
default :
return 0 ;
2009-05-03 12:31:30 +00:00
}
2010-01-07 14:49:07 +00:00
userdata + + ; //kill warning
2010-01-17 14:42:59 +00:00
return 1 ;
2009-05-03 12:31:30 +00:00
}
2008-10-19 12:53:30 +00:00
int gcd ( int a , int b )
2006-03-20 16:43:15 +00:00
{
2008-10-19 12:53:30 +00:00
if ( ! b )
return a ;
return gcd ( b , a % b ) ;
2006-03-20 16:43:15 +00:00
}
2010-01-07 14:49:07 +00:00
int change_res_poll ( ) { return 0 ; }
2008-10-19 12:53:30 +00:00
2006-03-20 16:43:15 +00:00
void change_res ( )
{
2008-10-19 12:53:30 +00:00
newmenu_item m [ 15 ] ;
u_int32_t modes [ 15 ] ;
2006-03-20 16:43:15 +00:00
int i = 0 , mc = 0 , num_presets = 0 ;
2008-04-06 20:23:28 +00:00
char customres [ 16 ] , aspect [ 16 ] ;
2006-03-20 16:43:15 +00:00
int fullscreenc ;
2008-04-06 20:23:28 +00:00
u_int32_t screen_mode = 0 , aspect_mode = 0 ;
2006-03-20 16:43:15 +00:00
2008-10-19 12:53:30 +00:00
// the list of pre-defined resolutions
2009-11-17 14:27:39 +00:00
if ( gr_check_mode ( SM ( 320 , 200 ) ) ) { m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 320x200 (16x10) " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 320 , 200 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 320 , 200 ) ; mc + + ; }
if ( gr_check_mode ( SM ( 640 , 480 ) ) ) { m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 640x480 (4x3) " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 640 , 480 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 640 , 480 ) ; mc + + ; }
if ( gr_check_mode ( SM ( 800 , 600 ) ) ) { m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 800x600 (4x3) " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 800 , 600 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 800 , 600 ) ; mc + + ; }
if ( gr_check_mode ( SM ( 1024 , 768 ) ) ) { m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 1024x768 (4x3) " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 1024 , 768 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 1024 , 768 ) ; mc + + ; }
if ( gr_check_mode ( SM ( 1280 , 800 ) ) ) { m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 1280x800 (16x10) " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 1280 , 800 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 1280 , 800 ) ; mc + + ; }
if ( gr_check_mode ( SM ( 1280 , 1024 ) ) ) { m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 1280x1024 (5x4) " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 1280 , 1024 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 1280 , 1024 ) ; mc + + ; }
if ( gr_check_mode ( SM ( 1440 , 900 ) ) ) { m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 1440x900 (16x10) " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 1440 , 900 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 1440 , 900 ) ; mc + + ; }
if ( gr_check_mode ( SM ( 1600 , 1200 ) ) ) { m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 1600x1200 (4x3) " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 1600 , 1200 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 1600 , 1200 ) ; mc + + ; }
if ( gr_check_mode ( SM ( 1920 , 1200 ) ) ) { m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 1920x1200 (16x10) " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 1920 , 1200 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 1920 , 1200 ) ; mc + + ; }
2006-03-20 16:43:15 +00:00
num_presets = mc ;
2008-10-19 12:53:30 +00:00
// now see which field is true and break there
m [ mc ] . value = 0 ;
2006-03-20 16:43:15 +00:00
for ( i = 0 ; i < mc ; i + + )
if ( m [ mc ] . value )
break ;
2008-10-19 12:53:30 +00:00
// the field for custom resolution and aspect
m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " use custom values " ; m [ mc ] . value = ( i = = mc ) ; m [ mc ] . group = 0 ; modes [ mc ] = 0 ; mc + + ;
m [ mc ] . type = NM_TYPE_TEXT ; m [ mc ] . text = " resolution: " ; mc + + ;
2006-03-20 16:43:15 +00:00
sprintf ( customres , " %ix%i " , SM_W ( Game_screen_mode ) , SM_H ( Game_screen_mode ) ) ;
m [ mc ] . type = NM_TYPE_INPUT ; m [ mc ] . text = customres ; m [ mc ] . text_len = 11 ; modes [ mc ] = 0 ; mc + + ;
2008-04-06 20:23:28 +00:00
m [ mc ] . type = NM_TYPE_TEXT ; m [ mc ] . text = " aspect: " ; mc + + ;
sprintf ( aspect , " %ix%i " , GameCfg . AspectY , GameCfg . AspectX ) ;
m [ mc ] . type = NM_TYPE_INPUT ; m [ mc ] . text = aspect ; m [ mc ] . text_len = 11 ; modes [ mc ] = 0 ; mc + + ;
2008-10-19 12:53:30 +00:00
// fullscreen toggle
2006-03-20 16:43:15 +00:00
fullscreenc = mc ; m [ mc ] . type = NM_TYPE_CHECK ; m [ mc ] . text = " Fullscreen " ; m [ mc ] . value = gr_check_fullscreen ( ) ; mc + + ;
2008-10-19 12:53:30 +00:00
// create the menu
2010-01-07 14:49:07 +00:00
i = newmenu_do1 ( NULL , " Screen Resolution " , mc , m , change_res_poll , NULL , 0 ) ;
2006-03-20 16:43:15 +00:00
2008-10-19 12:53:30 +00:00
// menu is done, now do what we need to do
// now check for fullscreen toggle and apply if necessary
2006-03-20 16:43:15 +00:00
if ( m [ fullscreenc ] . value ! = gr_check_fullscreen ( ) )
gr_toggle_fullscreen ( ) ;
2008-10-19 12:53:30 +00:00
// check which preset field was selected
2006-03-20 16:43:15 +00:00
for ( i = 0 ; ( m [ i ] . value = = 0 ) & & ( i < num_presets ) ; i + + ) ;
2008-10-19 12:53:30 +00:00
if ( modes [ i ] = = 0 ) // no preset selected, use custom values and set screen_mode and aspect
2006-03-20 16:43:15 +00:00
{
2008-04-06 20:23:28 +00:00
if ( ! strchr ( customres , ' x ' ) )
2006-03-20 16:43:15 +00:00
return ;
2008-10-19 12:53:30 +00:00
2008-10-29 11:03:31 +00:00
screen_mode = SM ( atoi ( customres ) , atoi ( strchr ( customres , ' x ' ) + 1 ) ) ;
2008-10-19 12:53:30 +00:00
if ( SM_W ( screen_mode ) < 320 | | SM_H ( screen_mode ) < 200 ) // oh oh - the resolution is too small. Revert!
{
nm_messagebox ( TXT_WARNING , 1 , " OK " , " Entered resolution is too small. \n Reverting ... " ) ;
return ;
}
if ( strchr ( aspect , ' x ' ) ) // we even have a custom aspect set up
{
aspect_mode = SM ( atoi ( aspect ) , atoi ( strchr ( aspect , ' x ' ) + 1 ) ) ;
GameCfg . AspectY = SM_W ( aspect_mode ) / gcd ( SM_W ( aspect_mode ) , SM_H ( aspect_mode ) ) ;
GameCfg . AspectX = SM_H ( aspect_mode ) / gcd ( SM_W ( aspect_mode ) , SM_H ( aspect_mode ) ) ;
}
2006-03-20 16:43:15 +00:00
}
2008-10-19 12:53:30 +00:00
else // a preset field is selected - set screen_mode and aspect
2006-03-20 16:43:15 +00:00
{
screen_mode = modes [ i ] ;
2008-10-19 12:53:30 +00:00
GameCfg . AspectY = SM_W ( screen_mode ) / gcd ( SM_W ( screen_mode ) , SM_H ( screen_mode ) ) ;
GameCfg . AspectX = SM_H ( screen_mode ) / gcd ( SM_W ( screen_mode ) , SM_H ( screen_mode ) ) ;
2006-03-20 16:43:15 +00:00
}
2007-07-26 23:56:00 +00:00
2008-10-19 12:53:30 +00:00
// clean up and apply everything
2007-07-26 23:56:00 +00:00
newmenu_close ( ) ;
set_screen_mode ( SCREEN_MENU ) ;
2008-11-09 14:31:30 +00:00
Game_screen_mode = screen_mode ;
gr_set_mode ( Game_screen_mode ) ;
2009-02-23 10:15:23 +00:00
init_cockpit ( ) ;
2008-11-09 14:31:30 +00:00
game_init_render_buffers ( SM_W ( screen_mode ) , SM_H ( screen_mode ) , VR_NONE ) ;
2006-03-20 16:43:15 +00:00
}
2010-01-07 14:49:07 +00:00
int input_menuset ( newmenu * menu , d_event * event , void * userdata )
2008-02-24 14:41:27 +00:00
{
int i ;
2008-04-13 00:28:36 +00:00
int oc_type = PlayerCfg . ControlType ;
2010-01-07 14:49:07 +00:00
newmenu_item * items = newmenu_get_items ( menu ) ;
2010-01-17 14:42:59 +00:00
int citem = newmenu_get_citem ( menu ) ;
2008-02-24 14:41:27 +00:00
2010-01-07 14:49:07 +00:00
userdata = userdata ;
2008-02-24 14:41:27 +00:00
2010-01-17 14:42:59 +00:00
switch ( event - > type )
{
case EVENT_IDLE : // FIXME: Should become EVENT_ITEM_CHANGED later
for ( i = 0 ; i < 4 ; i + + )
if ( items [ i ] . value ) PlayerCfg . ControlType = i ;
if ( PlayerCfg . ControlType = = 2 ) PlayerCfg . ControlType = CONTROL_MOUSE ;
if ( PlayerCfg . ControlType = = 3 ) PlayerCfg . ControlType = CONTROL_JOYMOUSE ;
if ( oc_type ! = PlayerCfg . ControlType ) {
kc_set_controls ( ) ;
}
PlayerCfg . JoystickSensitivityX = items [ 10 ] . value ;
PlayerCfg . JoystickSensitivityY = items [ 11 ] . value ;
PlayerCfg . JoystickDeadzone = items [ 12 ] . value ;
PlayerCfg . MouseSensitivityX = items [ 15 ] . value ;
PlayerCfg . MouseSensitivityY = items [ 16 ] . value ;
PlayerCfg . MouseFilter = items [ 17 ] . value ;
return 0 ; // for idle events
break ;
case EVENT_NEWMENU_SELECTED :
i = PlayerCfg . ControlType ;
if ( i = = CONTROL_MOUSE ) i = 2 ;
if ( i = = CONTROL_JOYMOUSE ) i = 3 ;
2008-02-24 14:41:27 +00:00
2010-01-17 14:42:59 +00:00
switch ( citem )
{
case 5 :
kconfig ( i , items [ i ] . text ) ;
break ;
case 6 :
kconfig ( 0 , " KEYBOARD " ) ;
break ;
case 7 :
kconfig ( 4 , " WEAPON KEYS " ) ;
break ;
case 19 :
show_help ( ) ;
break ;
case 20 :
show_netgame_help ( ) ;
break ;
case 21 :
show_newdemo_help ( ) ;
break ;
}
break ; // stay in menu
default :
return 0 ;
2008-02-24 14:41:27 +00:00
}
2010-01-07 14:49:07 +00:00
2010-01-17 14:42:59 +00:00
return 1 ;
2008-02-24 14:41:27 +00:00
}
void input_config ( )
{
2009-01-17 11:02:59 +00:00
newmenu_item m [ 22 ] ;
2010-01-17 14:42:59 +00:00
int i ;
2009-01-17 11:02:59 +00:00
int nitems = 22 ;
2008-02-24 14:41:27 +00:00
m [ 0 ] . type = NM_TYPE_RADIO ; m [ 0 ] . text = " KEYBOARD " ; m [ 0 ] . value = 0 ; m [ 0 ] . group = 0 ;
m [ 1 ] . type = NM_TYPE_RADIO ; m [ 1 ] . text = " JOYSTICK " ; m [ 1 ] . value = 0 ; m [ 1 ] . group = 0 ;
m [ 2 ] . type = NM_TYPE_RADIO ; m [ 2 ] . text = " MOUSE " ; m [ 2 ] . value = 0 ; m [ 2 ] . group = 0 ;
m [ 3 ] . type = NM_TYPE_RADIO ; m [ 3 ] . text = " JOYSTICK & MOUSE " ; m [ 3 ] . value = 0 ; m [ 3 ] . group = 0 ;
m [ 4 ] . type = NM_TYPE_TEXT ; m [ 4 ] . text = " " ;
m [ 5 ] . type = NM_TYPE_MENU ; m [ 5 ] . text = TXT_CUST_ABOVE ;
m [ 6 ] . type = NM_TYPE_MENU ; m [ 6 ] . text = TXT_CUST_KEYBOARD ;
m [ 7 ] . type = NM_TYPE_MENU ; m [ 7 ] . text = " CUSTOMIZE WEAPON KEYS " ;
m [ 8 ] . type = NM_TYPE_TEXT ; m [ 8 ] . text = " " ;
m [ 9 ] . type = NM_TYPE_TEXT ; m [ 9 ] . text = " Joystick " ;
2008-10-16 17:27:02 +00:00
m [ 10 ] . type = NM_TYPE_SLIDER ; m [ 10 ] . text = " X Sensitivity " ; m [ 10 ] . value = PlayerCfg . JoystickSensitivityX ; m [ 10 ] . min_value = 0 ; m [ 10 ] . max_value = 16 ;
m [ 11 ] . type = NM_TYPE_SLIDER ; m [ 11 ] . text = " Y Sensitivity " ; m [ 11 ] . value = PlayerCfg . JoystickSensitivityY ; m [ 11 ] . min_value = 0 ; m [ 11 ] . max_value = 16 ;
m [ 12 ] . type = NM_TYPE_SLIDER ; m [ 12 ] . text = " Deadzone " ; m [ 12 ] . value = PlayerCfg . JoystickDeadzone ; m [ 12 ] . min_value = 0 ; m [ 12 ] . max_value = 16 ;
m [ 13 ] . type = NM_TYPE_TEXT ; m [ 13 ] . text = " " ;
m [ 14 ] . type = NM_TYPE_TEXT ; m [ 14 ] . text = " Mouse " ;
m [ 15 ] . type = NM_TYPE_SLIDER ; m [ 15 ] . text = " X Sensitivity " ; m [ 15 ] . value = PlayerCfg . MouseSensitivityX ; m [ 15 ] . min_value = 0 ; m [ 15 ] . max_value = 16 ;
m [ 16 ] . type = NM_TYPE_SLIDER ; m [ 16 ] . text = " Y Sensitivity " ; m [ 16 ] . value = PlayerCfg . MouseSensitivityY ; m [ 16 ] . min_value = 0 ; m [ 16 ] . max_value = 16 ;
2009-01-17 11:02:59 +00:00
m [ 17 ] . type = NM_TYPE_CHECK ; m [ 17 ] . text = " Mouse Smoothing/Filtering " ; m [ 17 ] . value = PlayerCfg . MouseFilter ;
m [ 18 ] . type = NM_TYPE_TEXT ; m [ 18 ] . text = " " ;
m [ 19 ] . type = NM_TYPE_MENU ; m [ 19 ] . text = " GAME SYSTEM KEYS " ;
m [ 20 ] . type = NM_TYPE_MENU ; m [ 20 ] . text = " NETGAME SYSTEM KEYS " ;
m [ 21 ] . type = NM_TYPE_MENU ; m [ 21 ] . text = " DEMO SYSTEM KEYS " ;
2008-02-24 14:41:27 +00:00
2010-01-17 14:42:59 +00:00
i = PlayerCfg . ControlType ;
if ( i = = CONTROL_MOUSE ) i = 2 ;
if ( i = = CONTROL_JOYMOUSE ) i = 3 ;
m [ i ] . value = 1 ;
2008-02-24 14:41:27 +00:00
2010-01-17 14:42:59 +00:00
newmenu_do1 ( NULL , TXT_CONTROLS , nitems , m , input_menuset , NULL , 5 ) ;
2008-02-24 14:41:27 +00:00
}
2008-04-13 00:28:36 +00:00
void do_graphics_menu ( )
{
2008-10-28 17:04:35 +00:00
newmenu_item m [ 9 ] ;
2008-04-13 00:28:36 +00:00
int i = 0 , j = 0 ;
do {
m [ 0 ] . type = NM_TYPE_TEXT ; m [ 0 ] . text = " Texture Filtering: " ;
2008-04-22 08:29:29 +00:00
m [ 1 ] . type = NM_TYPE_RADIO ; m [ 1 ] . text = " None (Classical) " ; m [ 1 ] . value = 0 ; m [ 1 ] . group = 0 ;
m [ 2 ] . type = NM_TYPE_RADIO ; m [ 2 ] . text = " Bilinear " ; m [ 2 ] . value = 0 ; m [ 2 ] . group = 0 ;
m [ 3 ] . type = NM_TYPE_RADIO ; m [ 3 ] . text = " Trilinear " ; m [ 3 ] . value = 0 ; m [ 3 ] . group = 0 ;
m [ 4 ] . type = NM_TYPE_TEXT ; m [ 4 ] . text = " " ;
m [ 5 ] . type = NM_TYPE_CHECK ; m [ 5 ] . text = " Transparency Effects " ; m [ 5 ] . value = PlayerCfg . OglAlphaEffects ;
m [ 6 ] . type = NM_TYPE_CHECK ; m [ 6 ] . text = " Vectorial Reticle " ; m [ 6 ] . value = PlayerCfg . OglReticle ;
2008-10-28 17:04:35 +00:00
m [ 7 ] . type = NM_TYPE_CHECK ; m [ 7 ] . text = " VSync " ; m [ 7 ] . value = GameCfg . VSync ;
m [ 8 ] . type = NM_TYPE_CHECK ; m [ 8 ] . text = " 4x multisampling " ; m [ 8 ] . value = GameCfg . Multisample ;
2008-04-22 08:29:29 +00:00
m [ GameCfg . TexFilt + 1 ] . value = 1 ;
2008-04-13 00:28:36 +00:00
2010-01-07 14:49:07 +00:00
i = newmenu_do1 ( NULL , " Graphics Options " , sizeof ( m ) / sizeof ( * m ) , m , NULL , NULL , i ) ;
2008-04-13 00:28:36 +00:00
2008-10-30 15:00:32 +00:00
if ( GameCfg . VSync ! = m [ 7 ] . value | | GameCfg . Multisample ! = m [ 8 ] . value )
nm_messagebox ( NULL , 1 , TXT_OK , " To apply VSync or 4x Multisample \n you need to restart the program " ) ;
2008-04-13 00:28:36 +00:00
for ( j = 0 ; j < = 2 ; j + + )
2008-04-22 08:29:29 +00:00
if ( m [ j + 1 ] . value )
2008-04-13 00:28:36 +00:00
GameCfg . TexFilt = j ;
2008-04-22 08:29:29 +00:00
PlayerCfg . OglAlphaEffects = m [ 5 ] . value ;
PlayerCfg . OglReticle = m [ 6 ] . value ;
2008-10-28 17:04:35 +00:00
GameCfg . VSync = m [ 7 ] . value ;
2008-10-30 15:00:32 +00:00
GameCfg . Multisample = m [ 8 ] . value ;
2008-04-22 08:29:29 +00:00
gr_set_attributes ( ) ;
2009-01-15 23:58:36 +00:00
gr_set_mode ( Game_screen_mode ) ;
2008-04-13 00:28:36 +00:00
} while ( i > - 1 ) ;
}
2009-03-03 12:55:27 +00:00
void set_extmusic_volume ( int volume ) ;
2008-05-24 08:59:35 +00:00
2010-01-07 14:49:07 +00:00
int sound_menuset ( newmenu * menu , d_event * event , void * userdata )
2006-10-08 17:53:50 +00:00
{
2010-01-07 14:49:07 +00:00
newmenu_item * items = newmenu_get_items ( menu ) ;
if ( event - > type ! = EVENT_IDLE ) // FIXME: Should become EVENT_ITEM_CHANGED later
return 0 ;
userdata = userdata ;
2006-03-20 16:43:15 +00:00
2008-04-06 20:23:28 +00:00
if ( GameCfg . DigiVolume ! = items [ 0 ] . value ) {
GameCfg . DigiVolume = items [ 0 ] . value ;
digi_set_digi_volume ( ( GameCfg . DigiVolume * 32768 ) / 8 ) ;
2006-10-08 17:53:50 +00:00
digi_play_sample_once ( SOUND_DROP_BOMB , F1_0 ) ;
}
2009-05-03 12:31:30 +00:00
2008-05-24 08:59:35 +00:00
if ( GameCfg . MusicVolume ! = items [ 1 ] . value ) {
GameCfg . MusicVolume = items [ 1 ] . value ;
2009-03-03 12:55:27 +00:00
if ( EXT_MUSIC_ON )
set_extmusic_volume ( GameCfg . MusicVolume ) ;
2008-05-24 08:59:35 +00:00
else
digi_set_midi_volume ( ( GameCfg . MusicVolume * 128 ) / 8 ) ;
2006-10-08 17:53:50 +00:00
}
2009-05-03 12:31:30 +00:00
2010-01-07 14:49:07 +00:00
return 0 ;
2006-03-20 16:43:15 +00:00
}
2006-10-08 17:53:50 +00:00
void do_sound_menu ( )
2006-03-20 16:43:15 +00:00
{
2008-05-07 14:02:01 +00:00
# ifdef USE_SDLMIXER
2009-05-06 12:19:28 +00:00
newmenu_item m [ 10 ] ;
2008-05-07 14:02:01 +00:00
# else
2009-05-06 12:19:28 +00:00
newmenu_item m [ 7 ] ;
2008-05-07 14:02:01 +00:00
# endif
2006-10-08 17:53:50 +00:00
int i = 0 ;
2008-05-24 08:59:35 +00:00
int nitems ;
2006-03-20 16:43:15 +00:00
2006-10-08 17:53:50 +00:00
do {
2008-05-24 08:59:35 +00:00
if ( GameCfg . SndEnableRedbook & & GameCfg . JukeboxOn )
GameCfg . JukeboxOn = 0 ;
nitems = 0 ;
m [ nitems ] . type = NM_TYPE_SLIDER ; m [ nitems ] . text = TXT_FX_VOLUME ; m [ nitems ] . value = GameCfg . DigiVolume ; m [ nitems ] . min_value = 0 ; m [ nitems + + ] . max_value = 8 ;
m [ nitems ] . type = NM_TYPE_SLIDER ; m [ nitems ] . text = " music volume " ; m [ nitems ] . value = GameCfg . MusicVolume ; m [ nitems ] . min_value = 0 ; m [ nitems + + ] . max_value = 8 ;
m [ nitems ] . type = NM_TYPE_TEXT ; m [ nitems + + ] . text = " " ;
2009-03-03 12:55:27 +00:00
m [ nitems ] . type = NM_TYPE_RADIO ; m [ nitems ] . text = " MIDI Music enabled " ; m [ nitems ] . value = ( ! GameCfg . SndEnableRedbook & & ! GameCfg . JukeboxOn ) ; m [ nitems ] . group = 0 ; nitems + + ;
2008-05-24 08:59:35 +00:00
m [ nitems ] . type = NM_TYPE_RADIO ; m [ nitems ] . text = " CD Music enabled " ; m [ nitems ] . value = GameCfg . SndEnableRedbook ; m [ nitems ] . group = 0 ; nitems + + ;
2008-05-01 21:40:34 +00:00
# ifdef USE_SDLMIXER
2009-03-03 12:55:27 +00:00
m [ nitems ] . type = NM_TYPE_RADIO ; m [ nitems ] . text = " jukebox enabled " ; m [ nitems ] . value = GameCfg . JukeboxOn ; m [ nitems ] . group = 0 ; nitems + + ;
2008-05-24 08:59:35 +00:00
m [ nitems ] . type = NM_TYPE_TEXT ; m [ nitems + + ] . text = " path to music for jukebox: " ;
2008-11-01 01:19:52 +00:00
m [ nitems ] . type = NM_TYPE_INPUT ; m [ nitems ] . text = GameCfg . JukeboxPath ; m [ nitems + + ] . text_len = NM_MAX_TEXT_LEN - 1 ;
2008-05-01 21:40:34 +00:00
# endif
2009-05-06 12:19:28 +00:00
m [ nitems ] . type = NM_TYPE_CHECK ; m [ nitems ] . text = " Force Mac Descent CD track order " ; m [ nitems + + ] . value = GameCfg . OrigTrackOrder ;
2008-05-24 08:59:35 +00:00
m [ nitems ] . type = NM_TYPE_CHECK ; m [ nitems ] . text = TXT_REVERSE_STEREO ; m [ nitems + + ] . value = GameCfg . ReverseStereo ;
2010-01-07 14:49:07 +00:00
i = newmenu_do1 ( NULL , " Sound Effects & Music " , nitems , m , sound_menuset , NULL , i ) ;
2006-03-20 16:43:15 +00:00
2008-05-24 08:59:35 +00:00
GameCfg . ReverseStereo = m [ nitems - 1 ] . value ;
2009-05-06 12:19:28 +00:00
GameCfg . OrigTrackOrder = m [ nitems - 2 ] . value ;
2008-05-24 08:59:35 +00:00
if ( ( GameCfg . SndEnableRedbook ! = m [ 4 ] . value )
# ifdef USE_SDLMIXER
2008-06-04 19:30:43 +00:00
| | ( GameCfg . JukeboxOn ! = m [ 5 ] . value ) | | ( GameCfg . JukeboxOn )
2008-05-24 08:59:35 +00:00
# endif
)
{
GameCfg . SndEnableRedbook = m [ 4 ] . value ;
2008-05-01 21:40:34 +00:00
# ifdef USE_SDLMIXER
2008-05-24 08:59:35 +00:00
GameCfg . JukeboxOn = m [ 5 ] . value ;
2008-05-01 21:40:34 +00:00
# endif
2009-03-03 12:55:27 +00:00
ext_music_stop ( ) ;
ext_music_unload ( ) ;
ext_music_select_system ( GameCfg . JukeboxOn ? EXT_MUSIC_JUKEBOX : EXT_MUSIC_REDBOOK ) ;
2008-05-24 08:59:35 +00:00
if ( Function_mode = = FMODE_GAME )
songs_play_level_song ( Current_level_num ) ;
2009-03-03 12:55:27 +00:00
else
2008-05-24 08:59:35 +00:00
songs_play_song ( SONG_TITLE , 1 ) ;
}
2006-03-20 16:43:15 +00:00
2006-10-08 17:53:50 +00:00
} while ( i > - 1 ) ;
2006-03-20 16:43:15 +00:00
}
2008-04-13 00:28:36 +00:00
# define ADD_CHECK(n,txt,v) do { m[n].type=NM_TYPE_CHECK; m[n].text=txt; m[n].value=v;} while (0)
void do_misc_menu ( )
2006-03-20 16:43:15 +00:00
{
2008-10-28 17:04:35 +00:00
newmenu_item m [ 4 ] ;
2006-03-20 16:43:15 +00:00
int i = 0 ;
do {
2008-04-13 00:28:36 +00:00
ADD_CHECK ( 0 , " Ship auto-leveling " , PlayerCfg . AutoLeveling ) ;
ADD_CHECK ( 1 , " Show reticle " , PlayerCfg . ReticleOn ) ;
ADD_CHECK ( 2 , " Persistent Debris " , PlayerCfg . PersistentDebris ) ;
2008-10-28 17:04:35 +00:00
ADD_CHECK ( 3 , " Screenshots w/o HUD " , PlayerCfg . PRShot ) ;
2006-10-08 17:53:50 +00:00
2010-01-07 14:49:07 +00:00
i = newmenu_do1 ( NULL , " Misc Options " , sizeof ( m ) / sizeof ( * m ) , m , NULL , NULL , i ) ;
2006-03-20 16:43:15 +00:00
2008-04-13 00:28:36 +00:00
PlayerCfg . AutoLeveling = m [ 0 ] . value ;
PlayerCfg . ReticleOn = m [ 1 ] . value ;
PlayerCfg . PersistentDebris = m [ 2 ] . value ;
2008-10-28 17:04:35 +00:00
PlayerCfg . PRShot = m [ 3 ] . value ;
2006-10-08 17:53:50 +00:00
2006-03-20 16:43:15 +00:00
} while ( i > - 1 ) ;
}
2009-11-28 07:51:06 +00:00
2009-11-29 16:46:13 +00:00
# if defined(USE_UDP) || defined(USE_IPX)
2006-03-20 16:43:15 +00:00
void do_multi_player_menu ( )
{
2009-11-24 09:48:53 +00:00
int menu_choice [ 12 ] ;
newmenu_item m [ 12 ] ;
2006-03-20 16:43:15 +00:00
int choice = 0 , num_options = 0 ;
int old_game_mode ;
do {
old_game_mode = Game_mode ;
num_options = 0 ;
2009-12-08 11:01:36 +00:00
2009-11-29 16:46:13 +00:00
# ifdef USE_UDP
2009-11-24 09:48:53 +00:00
m [ num_options ] . type = NM_TYPE_TEXT ; m [ num_options ] . text = " UDP: " ; num_options + + ;
m [ num_options ] . type = NM_TYPE_MENU ; m [ num_options ] . text = " HOST GAME " ; menu_choice [ num_options ] = MENU_START_UDP_NETGAME ; num_options + + ;
m [ num_options ] . type = NM_TYPE_MENU ; m [ num_options ] . text = " FIND LAN GAMES " ; menu_choice [ num_options ] = MENU_JOIN_LIST_UDP_NETGAME ; num_options + + ;
//m[num_options].type=NM_TYPE_MENU; m[num_options].text="FIND LAN/ONLINE GAMES"; menu_choice[num_options]=MENU_JOIN_LIST_UDP_NETGAME; num_options++;
m [ num_options ] . type = NM_TYPE_MENU ; m [ num_options ] . text = " JOIN GAME MANUALLY " ; menu_choice [ num_options ] = MENU_JOIN_MANUAL_UDP_NETGAME ; num_options + + ;
2009-11-29 16:46:13 +00:00
# endif
2009-11-24 09:48:53 +00:00
2009-11-29 16:46:13 +00:00
# ifdef USE_IPX
2009-11-24 09:48:53 +00:00
m [ num_options ] . type = NM_TYPE_TEXT ; m [ num_options ] . text = " " ; num_options + + ;
m [ num_options ] . type = NM_TYPE_TEXT ; m [ num_options ] . text = " IPX: " ; num_options + + ;
m [ num_options ] . type = NM_TYPE_MENU ; m [ num_options ] . text = " HOST GAME " ; menu_choice [ num_options ] = MENU_START_IPX_NETGAME ; num_options + + ;
m [ num_options ] . type = NM_TYPE_MENU ; m [ num_options ] . text = " JOIN GAME " ; menu_choice [ num_options ] = MENU_JOIN_IPX_NETGAME ; num_options + + ;
2006-03-20 16:43:15 +00:00
# ifdef __LINUX__
2009-11-24 09:48:53 +00:00
m [ num_options ] . type = NM_TYPE_TEXT ; m [ num_options ] . text = " " ; num_options + + ;
m [ num_options ] . type = NM_TYPE_TEXT ; m [ num_options ] . text = " XKALI: " ; num_options + + ;
m [ num_options ] . type = NM_TYPE_MENU ; m [ num_options ] . text = " HOST GAME " ; menu_choice [ num_options ] = MENU_START_KALI_NETGAME ; num_options + + ;
m [ num_options ] . type = NM_TYPE_MENU ; m [ num_options ] . text = " JOIN GAME " ; menu_choice [ num_options ] = MENU_JOIN_KALI_NETGAME ; num_options + + ;
2009-11-29 16:46:13 +00:00
# endif
# endif
2006-03-20 16:43:15 +00:00
2010-01-07 14:49:07 +00:00
choice = newmenu_do1 ( NULL , TXT_MULTIPLAYER , num_options , m , NULL , NULL , choice ) ;
2006-03-20 16:43:15 +00:00
2007-05-31 22:30:18 +00:00
if ( choice > - 1 )
2006-03-20 16:43:15 +00:00
do_option ( menu_choice [ choice ] ) ;
if ( old_game_mode ! = Game_mode )
2007-05-31 22:30:18 +00:00
break ; // leave menu
2006-03-20 16:43:15 +00:00
} while ( choice > - 1 ) ;
}
2009-11-29 16:46:13 +00:00
# endif
2008-04-13 00:28:36 +00:00
void do_options_menu ( )
{
newmenu_item m [ 11 ] ;
2010-01-17 14:42:59 +00:00
m [ 0 ] . type = NM_TYPE_MENU ; m [ 0 ] . text = " Sound effects & music... " ;
m [ 1 ] . type = NM_TYPE_TEXT ; m [ 1 ] . text = " " ;
m [ 2 ] . type = NM_TYPE_MENU ; m [ 2 ] . text = TXT_CONTROLS_ ;
m [ 3 ] . type = NM_TYPE_TEXT ; m [ 3 ] . text = " " ;
m [ 4 ] . type = NM_TYPE_SLIDER ;
m [ 4 ] . text = TXT_BRIGHTNESS ;
m [ 4 ] . value = gr_palette_get_gamma ( ) ;
m [ 4 ] . min_value = 0 ;
m [ 4 ] . max_value = 16 ;
m [ 5 ] . type = NM_TYPE_MENU ; m [ 5 ] . text = " Screen resolution... " ;
2008-04-13 00:28:36 +00:00
# ifdef OGL
2010-01-17 14:42:59 +00:00
m [ 6 ] . type = NM_TYPE_MENU ; m [ 6 ] . text = " Graphics Options... " ;
2008-04-13 00:28:36 +00:00
# else
2010-01-17 14:42:59 +00:00
m [ 6 ] . type = NM_TYPE_TEXT ; m [ 6 ] . text = " " ;
2008-04-13 00:28:36 +00:00
# endif
2010-01-17 14:42:59 +00:00
m [ 7 ] . type = NM_TYPE_TEXT ; m [ 7 ] . text = " " ;
m [ 8 ] . type = NM_TYPE_MENU ; m [ 8 ] . text = " Primary autoselect ordering... " ;
m [ 9 ] . type = NM_TYPE_MENU ; m [ 9 ] . text = " Secondary autoselect ordering... " ;
m [ 10 ] . type = NM_TYPE_MENU ; m [ 10 ] . text = " Misc Options... " ;
2008-04-13 00:28:36 +00:00
2010-01-17 14:42:59 +00:00
newmenu_do1 ( NULL , TXT_OPTIONS , sizeof ( m ) / sizeof ( * m ) , m , options_menuset , NULL , 0 ) ;
2008-04-13 00:28:36 +00:00
}