Remove all remaining uses of Function_mode, checking for the existence of EditorWindow where necessary instead

This commit is contained in:
Chris Taylor 2012-03-19 14:09:26 +08:00
parent e28ba63503
commit b542189ab6
11 changed files with 23 additions and 30 deletions

View file

@ -3,6 +3,7 @@ D2X-Rebirth Changelog
20120319
--------
editor/med.c, include/editor/editor.h, include/ui.h, main/gamecntl.c, main/gameseq.c, main/inferno.c, main/menu.c: The editor now falls back to the main event loop in inferno.c, File->Exit now works as intended and get closer to making the editor and game work together
editor/med.c, main/endlevel.c, main/gamecntl.c, main/gamesave.c, main/inferno.c, main/inferno.h, main/menu.c, main/powerup.c, main/render.c, main/slew.c: Remove all remaining uses of Function_mode, checking for the existence of EditorWindow where necessary instead
20120318
--------

View file

@ -107,7 +107,7 @@ vms_vector Ed_view_target={0,0,0};
int gamestate_not_restored = 0;
UI_DIALOG * EditorWindow;
UI_DIALOG * EditorWindow = NULL;
int Large_view_index = -1;
@ -417,8 +417,8 @@ void init_editor()
restore_effect_bitmap_icons();
if (!set_screen_mode(SCREEN_EDITOR)) {
set_screen_mode(SCREEN_GAME);
Function_mode=FMODE_GAME; //force back into game
set_screen_mode(SCREEN_MENU);
show_menus(); //force back into menu
return;
}
@ -921,6 +921,7 @@ void close_editor_screen()
window_close(Pad_info);
ui_close_dialog(EditorWindow);
EditorWindow = NULL;
close_all_windows();
@ -1000,13 +1001,11 @@ void close_editor() {
case 2:
if (Game_wind)
window_close(Game_wind);
Function_mode = FMODE_MENU;
set_screen_mode(SCREEN_MENU); //put up menu screen
show_menus();
break;
case 3:
Function_mode=FMODE_GAME; //force back into game
set_screen_mode(SCREEN_GAME); //put up game screen
Game_mode = GM_EDITOR;
editor_reset_stuff_on_level();

View file

@ -66,6 +66,10 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "ogl_init.h"
#endif
#ifdef EDITOR
#include "editor/editor.h"
#endif
typedef struct flythrough_data {
object *obj;
vms_angvec angles; //orientation in angles
@ -1120,7 +1124,7 @@ void endlevel_render_mine(fix eye_offset)
vm_vec_scale_add2(&Viewer_eye,&Viewer->orient.rvec,eye_offset);
#ifdef EDITOR
if (Function_mode==FMODE_EDITOR)
if (EditorWindow)
Viewer_eye = Viewer->pos;
#endif

View file

@ -417,7 +417,6 @@ int pause_handler(window *wind, d_event *event, char *msg)
case 0:
break;
case KEY_ESC:
//Function_mode = FMODE_MENU; // Don't like this, just press escape twice (kreatordxx)
window_close(wind);
return 1;
case KEY_F1:
@ -1451,8 +1450,6 @@ int HandleTestKey(int key)
#ifdef NETWORK
multi_leave_game();
#endif
Function_mode = FMODE_EDITOR;
init_editor();
break;
case KEY_Q + KEY_SHIFTED + KEY_DEBUGGED:

View file

@ -1389,7 +1389,7 @@ int load_level(char * filename_passed)
#ifdef EDITOR
//If a Descent 1 level and the Descent 1 pig isn't present, pretend it's a Descent 2 level.
if ((Function_mode == FMODE_EDITOR) && (Gamesave_current_version <= 3) && !d1_pig_present)
if (EditorWindow && (Gamesave_current_version <= 3) && !d1_pig_present)
{
if (!no_old_level_file_error)
Warning("A Descent 1 level was loaded,\n"
@ -1402,7 +1402,7 @@ int load_level(char * filename_passed)
#endif
#ifdef EDITOR
if (Function_mode == FMODE_EDITOR)
if (EditorWindow)
editor_status("Loaded NEW mine %s, \"%s\"",filename,Current_level_name);
#endif
@ -1722,7 +1722,7 @@ int save_level_sub(char * filename, int compiled_version)
// if ( !compiled_version )
{
if (Function_mode == FMODE_EDITOR)
if (EditorWindow)
editor_status("Saved mine %s, \"%s\"",filename,Current_level_name);
}

View file

@ -102,7 +102,6 @@ char copyright[] = "DESCENT II COPYRIGHT (C) 1994-1996 PARALLAX SOFTWARE CORPOR
//Current version number
char desc_id_exit_num = 0;
int Function_mode=FMODE_MENU; //game or editor?
int Screen_mode=-1; //game screen or editor screen?
int descent_critical_error = 0;
unsigned int descent_critical_deverror = 0;

View file

@ -44,31 +44,22 @@ struct d_event;
#define KEY_MAC(x)
#endif
/**
** Constants
**/
// How close two points must be in all dimensions to be considered the
// same point.
// How close two points must be in all dimensions to be considered the same point.
#define FIX_EPSILON 10
// the maximum length of a filename
#define FILENAME_LEN 13
//for Function_mode variable
#define FMODE_EXIT 0 // leaving the program
#define FMODE_MENU 1 // Using the menu
#define FMODE_GAME 2 // running the game
#define FMODE_EDITOR 3 // running the editor
/**
** Global variables
**/
extern jmp_buf LeaveEvents;
extern int Quitting;
extern int Function_mode; // in game or editor?
extern int Screen_mode; // editor screen or game screen?
// Default event handler for everything except the editor

View file

@ -575,8 +575,6 @@ int do_option ( int select)
break;
#ifdef EDITOR
case MENU_EDITOR:
Function_mode = FMODE_EDITOR;
create_new_mine();
SetPlayerFromCurseg();
load_palette(NULL,1,0);

View file

@ -121,7 +121,7 @@ void draw_powerup(object *obj)
draw_object_blob(obj, Vclip[obj->rtype.vclip_info.vclip_num].frames[obj->rtype.vclip_info.framenum] );
#ifdef EDITOR
if ((Function_mode == FMODE_EDITOR) && (Cur_object_index == obj-Objects))
if (EditorWindow && (Cur_object_index == obj-Objects))
if (blob_vertices[0] != 0x80000)
draw_blob_outline();
#endif

View file

@ -643,7 +643,7 @@ void do_render_object(int objnum, int window_num)
//check for editor object
#ifdef EDITOR
if (Function_mode==FMODE_EDITOR && objnum==Cur_object_index) {
if (EditorWindow && objnum==Cur_object_index) {
save_3d_outline = g3d_interp_outline;
g3d_interp_outline=1;
}
@ -668,7 +668,7 @@ void do_render_object(int objnum, int window_num)
#ifdef EDITOR
if (Function_mode==FMODE_EDITOR && objnum==Cur_object_index)
if (EditorWindow && objnum==Cur_object_index)
g3d_interp_outline = save_3d_outline;
#endif
@ -1619,7 +1619,7 @@ void render_frame(fix eye_offset, int window_num)
}
#ifdef EDITOR
if (Function_mode==FMODE_EDITOR)
if (EditorWindow)
Viewer_eye = Viewer->pos;
#endif

View file

@ -19,6 +19,10 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*/
#ifdef EDITOR
#include "editor/editor.h"
#endif
#ifdef RCS
static char rcsid[] = "$Id: slew.c,v 1.1.1.1 2006/03/17 19:56:35 zicodxx Exp $";
#endif
@ -92,7 +96,7 @@ int do_slew_movement(object *obj, int check_keys )
if (!slew_obj || slew_obj->control_type!=CT_SLEW) return 0;
if (check_keys) {
if (Function_mode == FMODE_EDITOR) {
if (EditorWindow) {
obj->mtype.phys_info.velocity.x += VEL_SPEED * keyd_pressed[KEY_PAD9] * FrameTime;
obj->mtype.phys_info.velocity.x -= VEL_SPEED * keyd_pressed[KEY_PAD7] * FrameTime;
obj->mtype.phys_info.velocity.y += VEL_SPEED * keyd_pressed[KEY_PADMINUS] * FrameTime;