From 05722dec97510c5aa8ff677ee5da6022eb89fad6 Mon Sep 17 00:00:00 2001 From: Chris Taylor Date: Mon, 19 Mar 2012 14:08:25 +0800 Subject: [PATCH] Remove all remaining uses of Function_mode, checking for the existence of EditorWindow where necessary instead --- CHANGELOG.txt | 1 + editor/med.c | 9 ++++----- main/endlevel.c | 6 +++++- main/gamecntl.c | 3 --- main/gamesave.c | 4 ++-- main/inferno.c | 1 - main/inferno.h | 17 ++++------------- main/menu.c | 2 -- main/powerup.c | 2 +- main/render.c | 6 +++--- main/slew.c | 6 +++++- 11 files changed, 25 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index fc610e4fa..4d7511cd1 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -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 -------- diff --git a/editor/med.c b/editor/med.c index d74d305be..55b17fcad 100644 --- a/editor/med.c +++ b/editor/med.c @@ -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(); diff --git a/main/endlevel.c b/main/endlevel.c index 79fd61de2..cd4700e37 100644 --- a/main/endlevel.c +++ b/main/endlevel.c @@ -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 diff --git a/main/gamecntl.c b/main/gamecntl.c index a6f958990..e553d32a2 100644 --- a/main/gamecntl.c +++ b/main/gamecntl.c @@ -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: diff --git a/main/gamesave.c b/main/gamesave.c index 42b5c0234..977274af8 100644 --- a/main/gamesave.c +++ b/main/gamesave.c @@ -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); } diff --git a/main/inferno.c b/main/inferno.c index 77095bca2..2d67b9704 100644 --- a/main/inferno.c +++ b/main/inferno.c @@ -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; diff --git a/main/inferno.h b/main/inferno.h index 06918123e..a477cd9d9 100644 --- a/main/inferno.h +++ b/main/inferno.h @@ -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 @@ -7,13 +8,13 @@ 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. +AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* * - * Header file for Inferno. Should be included in all source files. + * Header file for Inferno. Should be included in all source files. * */ @@ -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 diff --git a/main/menu.c b/main/menu.c index 4fa40c49a..93d592c42 100644 --- a/main/menu.c +++ b/main/menu.c @@ -547,8 +547,6 @@ int do_option ( int select) break; #ifdef EDITOR case MENU_EDITOR: - Function_mode = FMODE_EDITOR; - create_new_mine(); SetPlayerFromCurseg(); diff --git a/main/powerup.c b/main/powerup.c index 47671855a..dcafffb8e 100644 --- a/main/powerup.c +++ b/main/powerup.c @@ -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 diff --git a/main/render.c b/main/render.c index c28be4f01..a80c12c6a 100644 --- a/main/render.c +++ b/main/render.c @@ -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 diff --git a/main/slew.c b/main/slew.c index f76f793d9..bc67ea322 100644 --- a/main/slew.c +++ b/main/slew.c @@ -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;