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:08:25 +08:00
parent 15a6a81176
commit 05722dec97
11 changed files with 25 additions and 32 deletions

View file

@ -3,6 +3,7 @@ D1X-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

@ -61,6 +61,10 @@ COPYRIGHT 1993-1998 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
@ -994,7 +998,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

@ -248,7 +248,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:
@ -826,8 +825,6 @@ int HandleTestKey(int key)
#ifdef NETWORK
multi_leave_game();
#endif
Function_mode = FMODE_EDITOR;
init_editor();
break;
case KEY_C + KEY_SHIFTED + KEY_DEBUGGED:

View file

@ -1220,7 +1220,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
@ -1457,7 +1457,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

@ -87,7 +87,6 @@ char copyright[] = "DESCENT COPYRIGHT (C) 1994,1995 PARALLAX SOFTWARE CORPORAT
#endif
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

@ -1,3 +1,4 @@
/* $Id: inferno.h,v 1.1.1.1 2006/03/17 19:57:28 zicodxx Exp $ */
/*
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
@ -41,23 +42,13 @@ struct d_event;
// 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
// the maximum length of a filename
#define FILENAME_LEN 13
/**
** 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?
extern int Screen_mode; // editor screen or game screen?
extern int MacHog;
// Default event handler for everything except the editor

View file

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

View file

@ -107,7 +107,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

@ -538,7 +538,7 @@ void do_render_object(int objnum)
//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;
}
@ -563,7 +563,7 @@ void do_render_object(int objnum)
#ifdef EDITOR
if (Function_mode==FMODE_EDITOR && objnum==Cur_object_index)
if (EditorWindow && objnum==Cur_object_index)
g3d_interp_outline = save_3d_outline;
#endif
}
@ -1357,7 +1357,7 @@ void render_frame(fix eye_offset)
}
#ifdef EDITOR
if (Function_mode==FMODE_EDITOR)
if (EditorWindow)
Viewer_eye = Viewer->pos;
#endif

View file

@ -121,6 +121,10 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "physics.h"
#include "kconfig.h"
#ifdef EDITOR
#include "editor/editor.h"
#endif
#ifdef RCS
#pragma off (unreferenced)
static char rcsid[] = "$Id: slew.c,v 1.1.1.1 2006/03/17 19:43:42 zicodxx Exp $";
@ -180,7 +184,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;