Handle player selection and demo playing in filename_menu_handler, fixing bug where it won't leave the player listbox if there's no LastPlayer; close do_options dialog when changing resolution

This commit is contained in:
kreatordxx 2010-02-06 05:21:45 +00:00
parent e5adf29b6c
commit 5f73aa9005
5 changed files with 118 additions and 240 deletions

View file

@ -3,6 +3,7 @@ D1X-Rebirth Changelog
20100206
--------
main/newmenu.c: Set the correct scroll position for the listbox when it's shown
main/gameseq.c, main/gameseq.h, main/menu.c, main/menu.h: Handle player selection and demo playing in filename_menu_handler, fixing bug where it won't leave the player listbox if there's no LastPlayer; close do_options dialog when changing resolution
20100205
--------

View file

@ -590,10 +590,10 @@ try_again:
//Inputs the player's name, without putting up the background screen
int RegisterPlayer()
{
char filename[PATH_MAX];
int allow_abort_flag = 1;
if ( Players[Player_num].callsign[0] == 0 ) {
if ( Players[Player_num].callsign[0] == 0 )
{
// Read the last player's name from config file, not lastplr.txt
strncpy( Players[Player_num].callsign, GameCfg.LastPlayer, CALLSIGN_LEN );
@ -601,26 +601,7 @@ int RegisterPlayer()
allow_abort_flag = 0;
}
do_menu_again:
;
if (get_filename(TXT_SELECT_PILOT, ".plr", filename, allow_abort_flag))
{
if ( filename[0] == '<' ) {
// They selected 'create new pilot'
if (!MakeNewPlayerFile(allow_abort_flag))
//return 0; // They hit Esc during enter name stage
goto do_menu_again;
} else {
strncpy(Players[Player_num].callsign,filename, CALLSIGN_LEN);
strlwr(Players[Player_num].callsign);
}
}
if (read_player_file() != EZERO)
goto do_menu_again;
WriteConfigFile(); // Update lastplr
select_filename(TXT_SELECT_PILOT, ".plr", allow_abort_flag);
return 1;
}

View file

@ -1,3 +1,4 @@
/* $Id: gameseq.h,v 1.1.1.1 2006/03/17 19:57:54 zicodxx Exp $ */
/*
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
@ -10,163 +11,14 @@ 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-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*/
/*
* $Source: /cvsroot/dxx-rebirth/d1x-rebirth/main/gameseq.h,v $
* $Revision: 1.1.1.1 $
* $Author: zicodxx $
* $Date: 2006/03/17 19:45:04 $
*
* Prototypes for functions for game sequencing.
*
* $Log: gameseq.h,v $
* Revision 1.1.1.1 2006/03/17 19:45:04 zicodxx
* initial import
*
* Revision 1.1.1.1 1999/06/14 22:12:27 donut
* Import of d1x 1.37 source.
*
* Revision 2.0 1995/02/27 11:32:03 john
* New version 2.0, which has no anonymous unions, builds with
* Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
*
* Revision 1.41 1995/02/07 10:51:54 rob
* fix typo.
*
* Revision 1.40 1995/02/06 20:10:16 rob
* Extern'ed DoEndLevelScoreGlitz.
*
* Revision 1.39 1995/02/01 16:34:13 john
* Linted.
*
* Revision 1.38 1995/01/27 11:15:03 rob
* Added extern for player position vars.
*
* Revision 1.37 1995/01/20 22:47:38 matt
* Mission system implemented, though imcompletely
*
* Revision 1.36 1995/01/17 13:36:08 john
* Moved pig loading into StartNewLevelSub.
*
* Revision 1.35 1995/01/04 12:21:28 john
* *** empty log message ***
*
* Revision 1.34 1995/01/04 12:20:47 john
* Declearations to work better with game state save.
*
*
* Revision 1.33 1994/12/08 09:46:35 matt
* Made level name len a multiple of 4 for alignment
*
* Revision 1.32 1994/11/29 16:33:29 rob
* Added new defines for last_secret_level based on shareware or not shareware.
*
* Revision 1.31 1994/11/26 15:30:20 matt
* Allow escape out of change pilot menu
*
* Revision 1.30 1994/11/21 17:29:38 matt
* Cleaned up sequencing & game saving for secret levels
*
* Revision 1.29 1994/11/21 15:55:03 matt
* Corrected LAST_LEVEL
*
* Revision 1.28 1994/11/20 22:12:43 mike
* set LAST_LEVEL based on SHAREWARE.
*
* Revision 1.27 1994/11/09 10:55:51 matt
* Cleaned up initialization for editor -> game transitions
*
* Revision 1.26 1994/11/08 17:50:48 rob
* ADded prototype for StartNewLEvel.
*
*
* Revision 1.25 1994/11/07 17:50:57 rob
* Added extern prototype for init_player_stats_level called for
* network games.
*
* Revision 1.24 1994/10/25 15:40:03 yuan
* *** empty log message ***
*
* Revision 1.23 1994/10/22 00:08:52 matt
* Fixed up problems with bonus & game sequencing
* Player doesn't get credit for hostages unless he gets them out alive
*
* Revision 1.22 1994/10/18 18:57:08 matt
* Added main menu option to enter new player name
*
* Revision 1.21 1994/10/07 23:37:32 matt
* Added prototype
*
* Revision 1.20 1994/10/07 16:02:53 matt
* Loading saved game no longer clears players weapons & other stats
*
* Revision 1.19 1994/10/06 14:12:46 matt
* Added flash effect when player appears
*
* Revision 1.18 1994/10/03 13:34:44 matt
* Added new (and hopefully better) game sequencing functions
*
* Revision 1.17 1994/09/30 15:19:53 matt
* Added new game sequencing functions, but left them disabled for now.
*
* Revision 1.16 1994/09/28 17:24:34 matt
* Added first draft of game save/load system
*
* Revision 1.15 1994/09/27 12:29:42 matt
* Changed level naming
*
* Revision 1.14 1994/09/02 11:53:55 mike
* Rename init_player_stats to init_player_stats_game.
*
* Revision 1.13 1994/08/31 20:57:34 matt
* Cleaned up endlevel/death code
*
* Revision 1.12 1994/08/23 18:45:06 yuan
* Added level 10 capability.. (LEDGES)
*
* Revision 1.11 1994/08/18 10:47:38 john
* Cleaned up game sequencing and player death stuff
* in preparation for making the player explode into
* pieces when dead.
*
* Revision 1.10 1994/08/15 15:24:45 john
* Made players know who killed them; Disabled cheat menu
* during net player; fixed bug with not being able to turn
* of invulnerability; Made going into edit/starting new leve
* l drop you out of a net game; made death dialog box.
*
* Revision 1.9 1994/08/13 12:20:56 john
* Made the networking uise the Players array.
*
* Revision 1.8 1994/07/22 12:36:24 matt
* Cleaned up editor/game interactions some more.
*
* Revision 1.7 1994/07/19 20:15:33 matt
* Name for each level now saved in the .SAV file & stored in Current_level_name
*
* Revision 1.6 1994/07/02 13:49:33 matt
* Cleaned up includes
*
* Revision 1.5 1994/07/02 13:09:52 matt
* Moved player stats struct from gameseq.h to player.h
*
* Revision 1.4 1994/07/01 16:35:35 yuan
* Added key system
*
* Revision 1.3 1994/06/26 14:07:35 matt
* Added prototypes
*
* Revision 1.2 1994/06/24 17:03:56 john
* Added VFX support. Also took all game sequencing stuff like
* EndGame out and put it into gameseq.c
*
* Revision 1.1 1994/06/24 14:13:53 john
* Initial revision
*
*
*/
#ifndef _GAMESEQ_H
#define _GAMESEQ_H
@ -187,7 +39,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
// extern int Secret_level_table[MAX_SECRET_LEVELS_PER_MISSION];
#define LEVEL_NAME_LEN 36 //make sure this is multipe of 4!
#define LEVEL_NAME_LEN 36 //make sure this is multiple of 4!
// Current_level_num starts at 1 for the first level
// -1,-2,-3 are secret levels
@ -206,6 +58,7 @@ extern int Player_highest_level;
// called once at program startup to get the player's name
int RegisterPlayer();
int MakeNewPlayerFile(int allow_abort);
// Inputs the player's name, without putting up the background screen
void RegisterPlayerSub(int allow_abort_flag);
@ -230,7 +83,7 @@ void ResumeSavedGame(int start_level);
void PlayerFinishedLevel(int secret_flag);
// called when the player has died
void DoPlayerDead();
void DoPlayerDead(void);
// load a level off disk. level numbers start at 1.
// Secret levels are -1,-2,-3
@ -269,4 +122,4 @@ extern void DoEndLevelScoreGlitz(int network);
extern int MaxNumNetPlayers;
extern int NumNetPlayerPositions;
#endif
#endif /* _GAMESEQ_H */

View file

@ -257,12 +257,8 @@ void do_option ( int select)
case MENU_GAME:
break;
case MENU_DEMO_PLAY:
{
char demo_file[PATH_MAX];
if (get_filename(TXT_SELECT_DEMO, ".dem", demo_file, 1))
newdemo_start_playback(demo_file);
select_filename(TXT_SELECT_DEMO, ".dem", 1);
break;
}
case MENU_LOAD_GAME:
state_restore_all(0);
break;
@ -420,14 +416,11 @@ typedef struct file_list
char **list; // just to free it in below callback
} file_list;
int filename_menu_handler( listbox *lb, d_event *event, file_list *l )
int filename_menu_keycommand( listbox *lb, d_event *event, file_list *l )
{
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)
{
case KEY_CTRLED+KEY_D:
@ -506,7 +499,65 @@ int filename_menu_handler( listbox *lb, d_event *event, file_list *l )
return 0;
}
int get_filename(char *title, char *type, char *filename, int allow_abort_flag)
int filename_menu_handler( listbox *lb, d_event *event, file_list *l )
{
char **items = listbox_get_items(lb);
int citem = listbox_get_citem(lb);
switch (event->type)
{
case EVENT_KEY_COMMAND:
return filename_menu_keycommand(lb, event, l);
break;
case EVENT_NEWMENU_SELECTED:
if (citem < 0)
return 0; // shouldn't happen
switch (l->mode)
{
case FILE_PLAYER_MODE:
if (citem == 0)
{
// They selected 'create new pilot'
return !MakeNewPlayerFile(1);
}
else
{
strncpy(Players[Player_num].callsign,items[citem] + ((items[citem][0]=='$')?1:0), CALLSIGN_LEN);
strlwr(Players[Player_num].callsign);
}
break;
case FILE_DEMO_MODE:
newdemo_start_playback(items[citem]);
// return 1; // later - when the listbox uses the main loop
break;
}
break;
case EVENT_WINDOW_CLOSE:
if (l->mode == FILE_PLAYER_MODE)
{
if (read_player_file() != EZERO)
return 1; // abort close!
WriteConfigFile(); // Update lastplr
}
PHYSFS_freeList(l->list);
d_free(items);
d_free(l);
break;
default:
break;
}
return 0;
}
int select_filename(char *title, char *type, int allow_abort_flag)
{
char **m;
char **f;
@ -539,7 +590,7 @@ int get_filename(char *title, char *type, char *filename, int allow_abort_flag)
return 0;
}
else if ( !*l->list && (l->mode == FILE_PLAYER_MODE) ) {
strcpy(filename, TXT_CREATE_NEW); // make a new player without showing listbox
MakeNewPlayerFile(allow_abort_flag); // make a new player without showing listbox
PHYSFS_freeList(l->list);
d_free(l);
return 0;
@ -591,17 +642,7 @@ int get_filename(char *title, char *type, char *filename, int allow_abort_flag)
if (!stricmp(Players[Player_num].callsign, m[i]) )
citem = i;
citem = newmenu_listbox1(title, NumItems, m, allow_abort_flag, citem, (int (*)(listbox *, d_event *, void *))filename_menu_handler, l);
if ( citem > -1 )
strncpy( filename, m[citem] + (((l->mode == FILE_PLAYER_MODE) && m[citem][0]=='$')?1:0), PATH_MAX );
PHYSFS_freeList(l->list);
d_free(m);
d_free(l);
if (citem < 0)
return 0; // aborted
newmenu_listbox1(title, NumItems, m, allow_abort_flag, citem, (int (*)(listbox *, d_event *, void *))filename_menu_handler, l);
return 1;
}
@ -821,6 +862,8 @@ void change_res()
gr_set_mode(Game_screen_mode);
init_cockpit();
game_init_render_buffers(SM_W(screen_mode), SM_H(screen_mode), VR_NONE);
window_close(window_get_front()); // close options dialog - it will be messy with a different resolution
//do_options_menu(); // reopen it. D'OH: Can't yet, not until we have a main event loop for it
}
int input_menuset(newmenu *menu, d_event *event, void *userdata)

View file

@ -23,7 +23,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
// returns number of item chosen
extern int DoMenu();
extern void do_options_menu();
extern int get_filename(char *title, char *type, char *filename, int allow_abort_flag);
extern int select_filename(char *title, char *type, int allow_abort_flag);
#define Menu_pcx_name (((SWIDTH>=640&&SHEIGHT>=480) && cfexist("menuh.pcx"))?"menuh.pcx":"menu.pcx")
#define STARS_BACKGROUND (((SWIDTH>=640&&SHEIGHT>=480) && cfexist("starsb.pcx"))?"starsb.pcx":"stars.pcx")