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 .
*/
/*
*
* Inferno main menu .
*
*/
# ifdef HAVE_CONFIG_H
# include <conf.h>
# endif
# 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"
# ifdef NETWORK
# include "network.h"
2008-01-02 15:36:51 +00:00
# include "netdrv.h"
2006-03-20 17:12:09 +00:00
# include "multi.h"
# endif
# 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 "movie.h"
# include "gamepal.h"
# include "gauges.h"
# include "powerup.h"
# include "strutil.h"
# ifdef EDITOR
# include "editor/editor.h"
# endif
//char *menu_difficulty_text[] = { "Trainee", "Rookie", "Fighter", "Hotshot", "Insane" };
# define MENU_NEW_GAME 0
# define MENU_GAME 1
# define MENU_EDITOR 2
# define MENU_VIEW_SCORES 3
# define MENU_QUIT 4
# define MENU_LOAD_GAME 5
# define MENU_SAVE_GAME 6
# define MENU_DEMO_PLAY 8
# define MENU_LOAD_LEVEL 9
# define MENU_START_IPX_NETGAME 10
# define MENU_JOIN_IPX_NETGAME 11
# define MENU_CONFIG 13
# define MENU_REJOIN_NETGAME 14
# define MENU_DIFFICULTY 15
# define MENU_HELP 19
# define MENU_NEW_PLAYER 20
# define MENU_MULTIPLAYER 21
# define MENU_SHOW_CREDITS 23
# define MENU_ORDER_INFO 24
# define MENU_PLAY_SONG 25
//#define MENU_START_TCP_NETGAME 26 // TCP/IP support was planned in Descent II,
//#define MENU_JOIN_TCP_NETGAME 27 // but never realized.
# define MENU_START_APPLETALK_NETGAME 28
# define MENU_JOIN_APPLETALK_NETGAME 29
# define MENU_START_UDP_NETGAME 30 // UDP/IP support copied from d1x
# define MENU_JOIN_UDP_NETGAME 31
# define MENU_START_KALI_NETGAME 32 // Kali support copied from d1x
# define MENU_JOIN_KALI_NETGAME 33
//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)
//unused - extern int last_joy_time; //last time the joystick was used
# ifndef NDEBUG
extern int Speedtest_on ;
# else
# define Speedtest_on 0
# endif
// Function Prototypes added after LINTING
void do_option ( int select ) ;
void do_new_game_menu ( void ) ;
# ifdef NETWORK
void do_multi_player_menu ( void ) ;
2007-05-30 14:16:49 +00:00
void do_ip_manual_join_menu ( ) ;
2008-01-02 15:36:51 +00:00
int UDPConnectManual ( char * addr ) ;
2006-03-20 17:12:09 +00:00
# endif //NETWORK
2007-03-22 11:32:22 +00:00
extern void newmenu_close ( ) ;
2008-03-23 13:03:42 +00:00
extern void ReorderPrimary ( ) ;
extern void ReorderSecondary ( ) ;
2006-03-20 17:12:09 +00:00
//returns the number of demo files on the disk
int newdemo_count_demos ( ) ;
// ------------------------------------------------------------------------
void autodemo_menu_check ( int nitems , newmenu_item * items , int * last_key , int citem )
{
int curtime ;
nitems = nitems ;
items = items ;
citem = citem ;
// Don't allow them to hit ESC in the main menu.
if ( * last_key = = KEY_ESC ) * last_key = 0 ;
2008-01-13 13:27:58 +00:00
curtime = timer_get_approx_seconds ( ) ;
if ( keyd_time_when_last_pressed + i2f ( 25 ) < curtime | | GameArg . SysAutoDemo )
{
int n_demos ;
n_demos = newdemo_count_demos ( ) ;
2006-03-20 17:12:09 +00:00
try_again : ;
2008-01-13 13:27:58 +00:00
if ( ( ( d_rand ( ) % ( n_demos + 1 ) ) = = 0 ) & & ! GameArg . SysAutoDemo )
{
# ifndef SHAREWARE
2006-03-20 17:12:09 +00:00
# ifdef OGL
2008-01-13 13:27:58 +00:00
Screen_mode = - 1 ;
2006-03-20 17:12:09 +00:00
# endif
2008-01-13 13:27:58 +00:00
PlayMovie ( " intro.mve " , 0 ) ;
songs_play_song ( SONG_TITLE , 1 ) ;
* last_key = - 3 ; //exit menu to force redraw even if not going to game mode. -3 tells menu system not to restore
set_screen_mode ( SCREEN_MENU ) ;
# endif // end of ifndef shareware
}
else
{
WIN ( HideCursorW ( ) ) ;
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 ;
* last_key = - 3 ; //exit menu to get into game mode. -3 tells menu system not to restore
2006-03-20 17:12:09 +00:00
}
2008-01-13 13:27:58 +00:00
else
goto try_again ; //keep trying until we get a demo that works
2006-03-20 17:12:09 +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 ;
2006-08-30 18:12:04 +00:00
set_screen_mode ( SCREEN_MENU ) ;
2006-03-20 17:12:09 +00:00
ADD_ITEM ( TXT_NEW_GAME , MENU_NEW_GAME , KEY_N ) ;
ADD_ITEM ( TXT_LOAD_GAME , MENU_LOAD_GAME , KEY_L ) ;
# ifdef NETWORK
ADD_ITEM ( TXT_MULTIPLAYER_ , MENU_MULTIPLAYER , - 1 ) ;
# endif
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 ) ;
if ( cfexist ( " orderd2.pcx " ) ) /* SHAREWARE */
ADD_ITEM ( TXT_ORDERING_INFO , MENU_ORDER_INFO , - 1 ) ;
ADD_ITEM ( TXT_CREDITS , MENU_SHOW_CREDITS , - 1 ) ;
# endif
ADD_ITEM ( TXT_QUIT , MENU_QUIT , KEY_Q ) ;
# ifndef RELEASE
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 );
# endif
* 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-04 14:23:19 +00:00
load_palette ( MENU_PALETTE , 0 , 1 ) ; //get correct palette
2006-03-20 17:12:09 +00:00
do {
create_main_menu ( m , menu_choice , & num_options ) ; // may have to change, eg, maybe selected pilot and no save games.
keyd_time_when_last_pressed = timer_get_fixed_seconds ( ) ; // .. 20 seconds from now!
if ( main_menu_choice < 0 )
main_menu_choice = 0 ;
main_menu_choice = newmenu_do2 ( " " , NULL , num_options , m , autodemo_menu_check , main_menu_choice , Menu_pcx_name ) ;
if ( main_menu_choice > - 1 ) do_option ( menu_choice [ main_menu_choice ] ) ;
} 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.
//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 :
{
char demo_file [ 16 ] ;
2007-11-21 12:46:09 +00:00
if ( newmenu_get_filename ( TXT_SELECT_DEMO , " .dem " , demo_file , 1 ) )
2006-03-20 17:12:09 +00:00
newdemo_start_playback ( demo_file ) ;
break ;
}
case MENU_LOAD_GAME :
state_restore_all ( 0 , 0 , NULL ) ;
break ;
# ifdef EDITOR
case MENU_EDITOR :
Function_mode = FMODE_EDITOR ;
init_cockpit ( ) ;
break ;
# endif
case MENU_VIEW_SCORES :
scores_view ( - 1 ) ;
break ;
# if 1 //def SHAREWARE
case MENU_ORDER_INFO :
show_order_form ( ) ;
break ;
# endif
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 ;
# ifndef RELEASE
case MENU_PLAY_SONG : {
int i ;
char * m [ MAX_NUM_SONGS ] ;
for ( i = 0 ; i < Num_songs ; i + + ) {
m [ i ] = Songs [ i ] . filename ;
}
i = newmenu_listbox ( " Select Song " , Num_songs , m , 1 , NULL ) ;
if ( i > - 1 ) {
songs_play_song ( i , 0 ) ;
}
}
break ;
case MENU_LOAD_LEVEL :
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 ;
newmenu_do ( NULL , " Enter level to load " , 1 , & m , NULL ) ;
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 ) ;
}
}
break ;
# endif //ifndef RELEASE
# ifdef NETWORK
case MENU_START_IPX_NETGAME :
case MENU_JOIN_IPX_NETGAME :
case MENU_START_KALI_NETGAME :
case MENU_JOIN_KALI_NETGAME :
switch ( select & ~ 0x1 ) {
2008-01-02 15:36:51 +00:00
case MENU_START_IPX_NETGAME : NetDrvSet ( NETPROTO_IPX ) ; break ;
case MENU_START_KALI_NETGAME : NetDrvSet ( NETPROTO_KALINIX ) ; break ;
2007-05-30 14:16:49 +00:00
default : Int3 ( ) ;
2006-03-20 17:12:09 +00:00
}
if ( ( select & 0x1 ) = = 0 ) // MENU_START_*_NETGAME
network_start_game ( ) ;
else // MENU_JOIN_*_NETGAME
network_join_game ( ) ;
break ;
2007-05-30 14:16:49 +00:00
case MENU_START_UDP_NETGAME :
2008-01-02 15:36:51 +00:00
NetDrvSet ( NETPROTO_UDP ) ;
2006-03-20 17:12:09 +00:00
network_start_game ( ) ;
break ;
2007-05-30 14:16:49 +00:00
case MENU_JOIN_UDP_NETGAME :
2008-01-02 15:36:51 +00:00
NetDrvSet ( NETPROTO_UDP ) ;
2007-05-30 14:16:49 +00:00
do_ip_manual_join_menu ( ) ;
2006-03-20 17:12:09 +00:00
break ;
2007-05-30 14:16:49 +00:00
2006-03-20 17:12:09 +00:00
case MENU_MULTIPLAYER :
do_multi_player_menu ( ) ;
break ;
# endif //NETWORK
case MENU_CONFIG :
do_options_menu ( ) ;
break ;
case MENU_SHOW_CREDITS :
songs_stop_all ( ) ;
2008-02-24 14:41:27 +00:00
credits_show ( ) ;
2006-03-20 17:12:09 +00:00
break ;
default :
Error ( " Unknown option %d in do_option " , select ) ;
break ;
}
}
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 ) ;
s = newmenu_do1 ( NULL , TXT_DIFFICULTY_LEVEL , NDL , m , NULL , Difficulty_level ) ;
if ( s > - 1 ) {
if ( s ! = Difficulty_level )
{
2008-04-13 00:28:36 +00:00
PlayerCfg . DefaultDifficulty = s ;
2006-03-20 17:12:09 +00:00
write_player_file ( ) ;
}
Difficulty_level = s ;
return 1 ;
}
return 0 ;
}
void do_new_game_menu ( )
{
int new_level_num , player_highest_level ;
if ( ! select_mission ( 0 , " New Game \n \n Select mission " ) )
return ;
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 ) {
newmenu_item m [ 4 ] ;
char info_text [ 80 ] ;
char num_text [ 10 ] ;
int choice ;
int n_items ;
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 ;
n_items = 2 ;
strcpy ( num_text , " 1 " ) ;
choice = newmenu_do ( NULL , TXT_SELECT_START_LEV , n_items , m , NULL ) ;
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 17:12:09 +00:00
if ( ! do_difficulty_menu ( ) )
return ;
StartNewGame ( new_level_num ) ;
}
extern void GameLoop ( int , int ) ;
void options_menuset ( int nitems , newmenu_item * items , int * last_key , int citem )
{
2006-10-08 23:19:46 +00:00
if ( citem = = 4 )
2006-03-20 17:12:09 +00:00
{
2006-10-08 23:19:46 +00:00
gr_palette_set_gamma ( items [ 4 ] . value ) ;
2006-03-20 17:12:09 +00:00
}
nitems + + ; //kill warning
last_key + + ; //kill warning
}
// added on 9/20/98 by Victor Rachels to attempt to add screen res change ingame
// Changed on 3/24/99 by Owen Evans to make it work =)
void change_res_poll ( )
{
}
void change_res ( )
{
2008-05-21 21:50:14 +00:00
newmenu_item m [ 14 ] ;
u_int32_t modes [ 14 ] ;
2006-03-20 17:12:09 +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 17:12:09 +00:00
int fullscreenc ;
2008-04-06 20:23:28 +00:00
u_int32_t screen_mode = 0 , aspect_mode = 0 ;
2006-03-20 17:12:09 +00:00
int screen_width = 0 ;
int screen_height = 0 ;
m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 320x200 " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 320 , 200 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 320 , 200 ) ; mc + + ;
m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 640x480 " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 640 , 480 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 640 , 480 ) ; mc + + ;
m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 800x600 " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 800 , 600 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 800 , 600 ) ; mc + + ;
m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 1024x768 " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 1024 , 768 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 1024 , 768 ) ; mc + + ;
2008-05-21 21:50:14 +00:00
m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 1280x800 " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 1280 , 800 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 1280 , 800 ) ; mc + + ;
2006-03-20 17:12:09 +00:00
m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 1280x1024 " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 1280 , 1024 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 1280 , 1024 ) ; mc + + ;
2008-05-21 21:50:14 +00:00
m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 1440x900 " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 1440 , 900 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 1440 , 900 ) ; mc + + ;
m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 1600x1200 " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 1600 , 1200 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 1600 , 1200 ) ; mc + + ;
m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " 1920x1200 " ; m [ mc ] . value = ( Game_screen_mode = = SM ( 1920 , 1200 ) ) ; m [ mc ] . group = 0 ; modes [ mc ] = SM ( 1920 , 1200 ) ; mc + + ;
2006-08-30 18:12:04 +00:00
2006-03-20 17:12:09 +00:00
num_presets = mc ;
2006-08-30 18:12:04 +00:00
m [ mc ] . value = 0 ; // make sure we count and reach the right selection
for ( i = 0 ; i < 8 ; i + + )
2006-03-20 17:12:09 +00:00
if ( m [ mc ] . value )
break ;
2006-08-30 18:12:04 +00:00
m [ mc ] . type = NM_TYPE_RADIO ; m [ mc ] . text = " custom: " ; m [ mc ] . value = ( i = = mc ) ; m [ mc ] . group = 0 ; modes [ mc ] = 0 ; mc + + ;
2006-03-20 17:12:09 +00:00
sprintf ( customres , " %ix%i " , SM_W ( Game_screen_mode ) , SM_H ( Game_screen_mode ) ) ;
2006-08-30 18:12:04 +00:00
m [ mc ] . type = NM_TYPE_INPUT ; m [ mc ] . text = customres ; m [ mc ] . text_len = 11 ; modes [ mc ] = 0 ; mc + + ;
2006-03-20 17:12:09 +00:00
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 + + ;
2006-03-20 17:12:09 +00:00
fullscreenc = mc ; m [ mc ] . type = NM_TYPE_CHECK ; m [ mc ] . text = " Fullscreen " ; m [ mc ] . value = gr_check_fullscreen ( ) ; mc + + ;
2008-04-06 20:23:28 +00:00
2006-08-30 18:12:04 +00:00
i = newmenu_do1 ( NULL , " Screen Resolution " , mc , m , & change_res_poll , 0 ) ;
2006-03-20 17:12:09 +00:00
if ( m [ fullscreenc ] . value ! = gr_check_fullscreen ( ) )
{
gr_toggle_fullscreen ( ) ;
Game_screen_mode = - 1 ;
2008-04-06 20:23:28 +00:00
GameCfg . WindowMode = ! m [ fullscreenc ] . value ;
2006-03-20 17:12:09 +00:00
}
for ( i = 0 ; ( m [ i ] . value = = 0 ) & & ( i < num_presets ) ; i + + ) ;
2006-08-30 18:12:04 +00:00
if ( modes [ i ] = = 0 )
2006-03-20 17:12:09 +00:00
{
2008-04-06 20:23:28 +00:00
if ( ! strchr ( customres , ' x ' ) )
2006-03-20 17:12:09 +00:00
return ;
2008-04-06 20:23:28 +00:00
screen_mode = SM ( atoi ( customres ) , atoi ( strchr ( customres , ' x ' ) + 1 ) ) ;
2006-03-20 17:12:09 +00:00
}
else
{
screen_mode = modes [ i ] ;
}
2008-04-06 20:23:28 +00:00
if ( strchr ( aspect , ' x ' ) )
{
aspect_mode = SM ( atoi ( aspect ) , atoi ( strchr ( aspect , ' x ' ) + 1 ) ) ;
if ( GameCfg . AspectY ! = SM_W ( aspect_mode ) | | GameCfg . AspectX ! = SM_H ( aspect_mode ) )
{
GameCfg . AspectY = SM_W ( aspect_mode ) ;
GameCfg . AspectX = SM_H ( aspect_mode ) ;
gr_set_mode ( Game_screen_mode ) ;
}
}
2006-03-20 17:12:09 +00:00
screen_width = SM_W ( screen_mode ) ;
screen_height = SM_H ( screen_mode ) ;
2006-10-15 12:26:13 +00:00
2007-08-08 18:07:21 +00:00
if ( Game_screen_mode = = screen_mode )
return ;
if ( screen_width < 320 | | screen_height < 200 ) {
nm_messagebox ( TXT_WARNING , 1 , " OK " , " Entered resolution is too small. \n Reverting ... " ) ;
2006-03-20 17:12:09 +00:00
return ;
2007-08-08 18:07:21 +00:00
}
2006-03-20 17:12:09 +00:00
2007-03-22 11:32:22 +00:00
newmenu_close ( ) ;
2006-03-20 17:12:09 +00:00
Game_screen_mode = screen_mode ;
2007-07-26 23:57:29 +00:00
set_screen_mode ( SCREEN_MENU ) ;
2007-04-05 13:23:44 +00:00
game_init_render_buffers ( screen_width , screen_height , VR_NONE , 0 ) ;
2006-03-20 17:12:09 +00:00
}
//End changed section (OE)
2008-02-24 14:41:27 +00:00
void input_menuset ( int nitems , newmenu_item * items , int * last_key , int citem )
{
int i ;
2008-04-13 00:28:36 +00:00
int oc_type = PlayerCfg . ControlType ;
2008-02-24 14:41:27 +00:00
nitems = nitems ;
last_key = last_key ;
citem = citem ;
for ( i = 0 ; i < 4 ; i + + )
2008-04-13 00:28:36 +00:00
if ( items [ i ] . value ) PlayerCfg . ControlType = i ;
2008-02-24 14:41:27 +00:00
2008-04-13 00:28:36 +00:00
if ( PlayerCfg . ControlType = = 2 ) PlayerCfg . ControlType = CONTROL_MOUSE ;
if ( PlayerCfg . ControlType = = 3 ) PlayerCfg . ControlType = CONTROL_JOYMOUSE ;
2008-02-24 14:41:27 +00:00
2008-04-13 00:28:36 +00:00
if ( oc_type ! = PlayerCfg . ControlType ) {
2008-02-24 14:41:27 +00:00
kc_set_controls ( ) ;
}
}
void input_config ( )
{
newmenu_item m [ 14 ] ;
int i , i1 = 5 , j ;
int nitems = 14 ;
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-04-13 00:28:36 +00:00
m [ 10 ] . type = NM_TYPE_SLIDER ; m [ 10 ] . text = " Sensitivity " ; m [ 10 ] . value = PlayerCfg . JoystickSensitivity ; m [ 10 ] . min_value = 0 ; m [ 10 ] . max_value = 16 ;
m [ 11 ] . type = NM_TYPE_SLIDER ; m [ 11 ] . text = " Joystick Deadzone " ; m [ 11 ] . value = PlayerCfg . JoystickDeadzone ; m [ 11 ] . min_value = 0 ; m [ 11 ] . max_value = 16 ;
2008-02-24 14:41:27 +00:00
m [ 12 ] . type = NM_TYPE_TEXT ; m [ 12 ] . text = " Mouse " ;
2008-04-13 00:28:36 +00:00
m [ 13 ] . type = NM_TYPE_SLIDER ; m [ 13 ] . text = " Sensitivity " ; m [ 13 ] . value = PlayerCfg . MouseSensitivity ; m [ 13 ] . min_value = 0 ; m [ 13 ] . max_value = 16 ;
2008-02-24 14:41:27 +00:00
do {
2008-04-13 00:28:36 +00:00
i = PlayerCfg . ControlType ;
2008-02-24 14:41:27 +00:00
if ( i = = CONTROL_MOUSE ) i = 2 ;
if ( i = = CONTROL_JOYMOUSE ) i = 3 ;
m [ i ] . value = 1 ;
i1 = newmenu_do1 ( NULL , TXT_CONTROLS , nitems , m , input_menuset , i1 ) ;
2008-04-13 00:28:36 +00:00
PlayerCfg . JoystickSensitivity = m [ 10 ] . value ;
PlayerCfg . JoystickDeadzone = m [ 11 ] . value ;
PlayerCfg . MouseSensitivity = m [ 13 ] . value ;
2008-02-24 14:41:27 +00:00
for ( j = 0 ; j < = 3 ; j + + )
if ( m [ j ] . value )
2008-04-13 00:28:36 +00:00
PlayerCfg . ControlType = j ;
i = PlayerCfg . ControlType ;
if ( PlayerCfg . ControlType = = 2 )
PlayerCfg . ControlType = CONTROL_MOUSE ;
if ( PlayerCfg . ControlType = = 3 )
PlayerCfg . ControlType = CONTROL_JOYMOUSE ;
2008-02-24 14:41:27 +00:00
switch ( i1 ) {
case 5 :
kconfig ( i , m [ i ] . text ) ;
break ;
case 6 :
kconfig ( 0 , " KEYBOARD " ) ;
break ;
case 7 :
kconfig ( 4 , " WEAPON KEYS " ) ;
break ;
}
} while ( i1 > - 1 ) ;
}
2006-03-20 17:12:09 +00:00
void set_redbook_volume ( int volume ) ;
void sound_menuset ( int nitems , newmenu_item * items , int * last_key , int citem )
{
2006-10-08 17:54:32 +00:00
nitems = nitems ;
2006-03-20 17:12:09 +00:00
* last_key = * last_key ;
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-03-20 17:12:09 +00:00
digi_play_sample_once ( SOUND_DROP_BOMB , F1_0 ) ;
}
2008-05-24 08:59:35 +00:00
if ( GameCfg . MusicVolume ! = items [ 1 ] . value ) {
GameCfg . MusicVolume = items [ 1 ] . value ;
if ( GameCfg . SndEnableRedbook )
set_redbook_volume ( GameCfg . MusicVolume ) ;
else
digi_set_midi_volume ( ( GameCfg . MusicVolume * 128 ) / 8 ) ;
2006-03-20 17:12:09 +00:00
}
citem + + ; //kill warning
}
void do_sound_menu ( )
{
2008-05-07 14:02:01 +00:00
# ifdef USE_SDLMIXER
2008-05-24 08:59:35 +00:00
newmenu_item m [ 9 ] ;
2008-05-07 14:02:01 +00:00
# else
2008-05-24 08:59:35 +00:00
newmenu_item m [ 6 ] ;
2008-05-07 14:02:01 +00:00
# endif
2006-03-20 17:12:09 +00:00
int i = 0 ;
2008-05-24 08:59:35 +00:00
int nitems ;
2006-03-20 17:12:09 +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 = " " ;
m [ nitems ] . type = NM_TYPE_RADIO ; m [ nitems ] . text = " MIDI Music enabled (default) " ; m [ nitems ] . value = ( ! GameCfg . SndEnableRedbook & & ! GameCfg . JukeboxOn ) ; m [ nitems ] . group = 0 ; nitems + + ;
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
2008-05-24 08:59:35 +00:00
m [ nitems ] . type = NM_TYPE_RADIO ; m [ nitems ] . text = " jukebox enabled in game " ; m [ nitems ] . value = GameCfg . JukeboxOn ; m [ nitems ] . group = 0 ; nitems + + ;
m [ nitems ] . type = NM_TYPE_TEXT ; m [ nitems + + ] . text = " path to music for jukebox: " ;
m [ nitems ] . type = NM_TYPE_INPUT ; m [ nitems ] . text = GameCfg . JukeboxPath ; m [ nitems + + ] . text_len = PATH_MAX ;
2008-05-01 21:40:34 +00:00
# endif
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 ;
i = newmenu_do1 ( NULL , " Sound Effects & Music " , nitems , m , sound_menuset , i ) ;
GameCfg . ReverseStereo = m [ nitems - 1 ] . value ;
if ( ( 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
2008-05-24 08:59:35 +00:00
)
{
int restart_menu_music = GameCfg . SndEnableRedbook ! = m [ 4 ] . value ;
GameCfg . SndEnableRedbook = m [ 4 ] . value ;
# ifdef USE_SDLMIXER
GameCfg . JukeboxOn = m [ 5 ] . value ;
# endif
if ( Function_mode = = FMODE_GAME )
songs_play_level_song ( Current_level_num ) ;
else if ( restart_menu_music )
songs_play_song ( SONG_TITLE , 1 ) ;
}
2006-03-20 17:12:09 +00:00
} while ( i > - 1 ) ;
}
2008-04-13 00:28:36 +00:00
void do_graphics_menu ( )
{
2008-04-21 18:39:49 +00:00
newmenu_item m [ 10 ] ;
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 ;
m [ 7 ] . type = NM_TYPE_CHECK ; m [ 7 ] . text = " Screenshots w/o HUD " ; m [ 7 ] . value = PlayerCfg . OglPRShot ;
m [ 8 ] . type = NM_TYPE_CHECK ; m [ 8 ] . text = " VSync " ; m [ 8 ] . value = GameCfg . VSync ;
m [ 9 ] . type = NM_TYPE_CHECK ; m [ 9 ] . text = " 4x multisampling " ; m [ 9 ] . value = GameCfg . Multisample ;
m [ GameCfg . TexFilt + 1 ] . value = 1 ;
2008-04-13 00:28:36 +00:00
i = newmenu_do1 ( NULL , " Graphics Options " , sizeof ( m ) / sizeof ( * m ) , m , NULL , i ) ;
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 ;
PlayerCfg . OglPRShot = m [ 7 ] . value ;
GameCfg . VSync = m [ 8 ] . value ;
GameCfg . Multisample = m [ 9 ] . value ;
gr_set_attributes ( ) ;
2008-04-13 00:28:36 +00:00
} while ( i > - 1 ) ;
}
2006-03-20 17:12:09 +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)
2008-04-13 00:28:36 +00:00
void do_misc_menu ( )
2006-03-20 17:12:09 +00:00
{
2008-04-13 00:28:36 +00:00
newmenu_item m [ 7 ] ;
2006-03-20 17:12:09 +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 , " Missile view " , PlayerCfg . MissileViewEnabled ) ;
ADD_CHECK ( 3 , " Headlight on when picked up " , PlayerCfg . HeadlightActiveDefault ) ;
ADD_CHECK ( 4 , " Show guided missile in main display " , PlayerCfg . GuidedInBigWindow ) ;
ADD_CHECK ( 5 , " Escort robot hot keys " , PlayerCfg . EscortHotKeys ) ;
ADD_CHECK ( 6 , " Persistent Debris " , PlayerCfg . PersistentDebris ) ;
i = newmenu_do1 ( NULL , " Gameplay Options " , sizeof ( m ) / sizeof ( * m ) , m , NULL , i ) ;
2006-03-20 17:12:09 +00:00
2008-04-13 00:28:36 +00:00
PlayerCfg . AutoLeveling = m [ 0 ] . value ;
PlayerCfg . ReticleOn = m [ 1 ] . value ;
PlayerCfg . MissileViewEnabled = m [ 2 ] . value ;
PlayerCfg . HeadlightActiveDefault = m [ 3 ] . value ;
PlayerCfg . GuidedInBigWindow = m [ 4 ] . value ;
PlayerCfg . EscortHotKeys = m [ 5 ] . value ;
PlayerCfg . PersistentDebris = m [ 6 ] . value ;
2006-03-20 17:12:09 +00:00
} while ( i > - 1 ) ;
}
# ifdef NETWORK
void do_multi_player_menu ( )
{
int menu_choice [ 9 ] ;
newmenu_item m [ 9 ] ;
int choice = 0 , num_options = 0 ;
int old_game_mode ;
do {
old_game_mode = Game_mode ;
num_options = 0 ;
# ifdef NATIVE_IPX
2007-05-31 22:30:18 +00:00
ADD_ITEM ( " Start IPX Netgame " , MENU_START_IPX_NETGAME , - 1 ) ;
ADD_ITEM ( " Join IPX Netgame \n " , MENU_JOIN_IPX_NETGAME , - 1 ) ;
2006-03-20 17:12:09 +00:00
# endif //NATIVE_IPX
ADD_ITEM ( " Start UDP/IP Netgame " , MENU_START_UDP_NETGAME , - 1 ) ;
ADD_ITEM ( " Join UDP/IP Netgame \n " , MENU_JOIN_UDP_NETGAME , - 1 ) ;
# ifdef KALINIX
ADD_ITEM ( " Start Kali Netgame " , MENU_START_KALI_NETGAME , - 1 ) ;
2007-05-31 22:30:18 +00:00
ADD_ITEM ( " Join Kali Netgame " , MENU_JOIN_KALI_NETGAME , - 1 ) ;
2006-03-20 17:12:09 +00:00
# endif // KALINIX
choice = newmenu_do1 ( NULL , TXT_MULTIPLAYER , num_options , m , NULL , choice ) ;
2007-05-30 14:16:49 +00:00
if ( choice > - 1 )
2006-03-20 17:12:09 +00:00
do_option ( menu_choice [ choice ] ) ;
if ( old_game_mode ! = Game_mode )
break ; // leave menu
} while ( choice > - 1 ) ;
}
2007-05-30 14:16:49 +00:00
void do_ip_manual_join_menu ( )
{
int menu_choice [ 3 ] ;
newmenu_item m [ 3 ] ;
2007-08-09 12:28:28 +00:00
int choice = 0 , num_options = 0 , j = 0 ;
2007-05-30 14:16:49 +00:00
int old_game_mode ;
2007-08-09 12:28:28 +00:00
char buf [ 128 ] = " " ;
2008-05-16 11:39:27 +00:00
if ( * GameCfg . MplIpHostAddr ) {
sprintf ( buf , " %s " , GameCfg . MplIpHostAddr ) ;
2007-08-09 12:28:28 +00:00
for ( j = 0 ; buf [ j ] ! = ' \0 ' ; j + + ) {
switch ( buf [ j ] ) {
case ' ' :
buf [ j ] = ' \0 ' ;
}
}
}
2006-03-20 17:12:09 +00:00
2007-05-30 14:16:49 +00:00
do {
old_game_mode = Game_mode ;
num_options = 0 ;
2006-03-20 17:12:09 +00:00
2007-08-09 12:28:28 +00:00
m [ num_options ] . type = NM_TYPE_INPUT ; m [ num_options ] . text = buf ; m [ num_options ] . text_len = 128 ; menu_choice [ num_options ] = - 1 ; num_options + + ;
2006-03-20 17:12:09 +00:00
2007-05-30 14:16:49 +00:00
choice = newmenu_do1 ( NULL , " ENTER IP OR HOSTNAME " , num_options , m , NULL , choice ) ;
2006-03-20 17:12:09 +00:00
2007-08-09 12:28:28 +00:00
if ( choice > - 1 ) {
2008-01-02 15:36:51 +00:00
UDPConnectManual ( buf ) ;
2007-08-09 12:28:28 +00:00
}
2006-03-20 17:12:09 +00:00
2007-05-30 14:16:49 +00:00
if ( old_game_mode ! = Game_mode )
2008-05-16 11:39:27 +00:00
{
strncpy ( GameCfg . MplIpHostAddr , buf , 128 ) ;
2007-08-09 12:28:28 +00:00
break ; // leave menu
2008-05-16 11:39:27 +00:00
}
2007-05-30 14:16:49 +00:00
} while ( choice > - 1 ) ;
}
2006-03-20 17:12:09 +00:00
# endif // NETWORK
2008-04-13 00:28:36 +00:00
void do_options_menu ( )
{
newmenu_item m [ 11 ] ;
int i = 0 ;
do {
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... " ;
# ifdef OGL
m [ 6 ] . type = NM_TYPE_MENU ; m [ 6 ] . text = " Graphics Options... " ;
# else
m [ 6 ] . type = NM_TYPE_TEXT ; m [ 6 ] . text = " " ;
# endif
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 = " Gameplay Options... " ;
i = newmenu_do1 ( NULL , TXT_OPTIONS , sizeof ( m ) / sizeof ( * m ) , m , options_menuset , i ) ;
switch ( i ) {
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 ;
}
} while ( i > - 1 ) ;
write_player_file ( ) ;
}