summaryrefslogtreecommitdiff
path: root/src/editor
diff options
context:
space:
mode:
Diffstat (limited to 'src/editor')
-rw-r--r--src/editor/editor.cpp26
-rw-r--r--src/editor/editor.h1
-rw-r--r--src/editor/gui.cpp17
-rw-r--r--src/editor/view3d.cpp8
4 files changed, 38 insertions, 14 deletions
diff --git a/src/editor/editor.cpp b/src/editor/editor.cpp
index 63360d1..3873913 100644
--- a/src/editor/editor.cpp
+++ b/src/editor/editor.cpp
@@ -4,6 +4,31 @@
GAME_EDITOR* editor = 0;
+void editor_clear_gui_state_refs( GAME_EDITOR* e ) {
+ if( !e )
+ return;
+
+ e->gui.new_map_popup = 0;
+
+ e->gui.v2d = 0;
+ e->gui.v3d = 0;
+ e->gui.gridlabel = 0;
+ e->gui.props = 0;
+ e->gui.tool = 0;
+
+ e->gui.assets = 0;
+ e->gui.status = 0;
+ e->gui.assets_scroll = 0;
+
+ e->gui.header_toolbar = 0;
+ e->gui.header_viewtype_label = 0;
+ e->gui.header_back = 0;
+ e->gui.header_mode_2d = 0;
+ e->gui.header_mode_3d = 0;
+ e->gui.header_mode_sim = 0;
+ e->gui.header_viewtype = 0;
+}
+
static void editor_push_undo_action( GAME_EDITOR* e, const GAME_EDITOR::EDITOR_UNDO_ACTION& action ) {
if( !e )
return;
@@ -410,6 +435,7 @@ STAT editor_close( GAME_EDITOR* e ) {
I32 w = e->wnd->w, h = e->wnd->h;
gui_free( e->wnd );
+ editor_clear_gui_state_refs( e );
e->wnd = gui_editorwindow( w, h );
} );
diff --git a/src/editor/editor.h b/src/editor/editor.h
index 2067df5..ad43705 100644
--- a/src/editor/editor.h
+++ b/src/editor/editor.h
@@ -128,6 +128,7 @@ extern STAT editor_load_map( GAME_EDITOR* e, const char* mapname );
extern STAT editor_save_map( GAME_EDITOR* e );
extern STAT editor_new_map( GAME_EDITOR* e, const char* mapname );
extern STAT editor_close( GAME_EDITOR* e );
+extern void editor_clear_gui_state_refs( GAME_EDITOR* e );
extern void editor_resize( GAME_EDITOR* e, I32 w, I32 h );
extern void editor_register_grid_dependency( GAME_EDITOR* e, void* tag, EDITOR_GRID_DEP_CALLBACK cb );
extern void editor_notify_grid_change( GAME_EDITOR* e );
diff --git a/src/editor/gui.cpp b/src/editor/gui.cpp
index 04e69f1..ea03e8f 100644
--- a/src/editor/gui.cpp
+++ b/src/editor/gui.cpp
@@ -469,7 +469,7 @@ static GUI_EDITOR_TOOLBAR* gui_editor_toolbar( I32 x, I32 y, I32 w, I32 h, const
}
static void editor_raise_header_toolbar( GAME_EDITOR* e ) {
- if( !e || !e->gui.header_toolbar )
+ if( !e || !e->map || !e->wnd || !e->gui.header_toolbar )
return;
GUI_BASE* bar = e->gui.header_toolbar;
@@ -1071,7 +1071,7 @@ static void editor_layout_map_view( GAME_EDITOR* e ) {
void gui_editorwindow_draw_fn( void* ptr ) {
GUI_EDITORWINDOW* wnd = (GUI_EDITORWINDOW*)ptr;
editor_raise_header_toolbar( editor );
- GUI_BASE* toolbar = editor ? editor->gui.header_toolbar : 0;
+ GUI_BASE* toolbar = ( editor && editor->map ) ? editor->gui.header_toolbar : 0;
GUI_EDITOR_TOOLBAR* tbar = (GUI_EDITOR_TOOLBAR*)toolbar;
U8 menu_open = tbar && ( tbar->file_open || tbar->edit_open );
F32 saved_mx = input.mouse.pos.x;
@@ -1107,7 +1107,7 @@ static void gui_editorwindow_input_fn( void* ptr ) {
GUI_EDITORWINDOW* wnd = (GUI_EDITORWINDOW*)ptr;
editor_raise_header_toolbar( editor );
- GUI_BASE* toolbar = editor ? editor->gui.header_toolbar : 0;
+ GUI_BASE* toolbar = ( editor && editor->map ) ? editor->gui.header_toolbar : 0;
if( toolbar && toolbar->enabled && toolbar->input_fn )
toolbar->input_fn( toolbar );
@@ -1246,16 +1246,7 @@ void editor_create_map_view( GAME_EDITOR* e ) {
gui_free( *ptr );
} );
w->children.clear();
- e->gui.assets = 0;
- e->gui.status = 0;
- e->gui.assets_scroll = 0;
- e->gui.header_toolbar = 0;
- e->gui.header_viewtype_label = 0;
- e->gui.header_back = 0;
- e->gui.header_mode_2d = 0;
- e->gui.header_mode_3d = 0;
- e->gui.header_mode_sim = 0;
- e->gui.header_viewtype = 0;
+ editor_clear_gui_state_refs( e );
e->gui.view2d_type = EDITOR_2DVIEW_TOP_DOWN;
e->gui.view_mode = EDITOR_VIEWMODE_2D;
diff --git a/src/editor/view3d.cpp b/src/editor/view3d.cpp
index 3729823..292760a 100644
--- a/src/editor/view3d.cpp
+++ b/src/editor/view3d.cpp
@@ -48,7 +48,7 @@ void gui_editor_3dview_draw_showpos( GUI_EDITOR_3DVIEW* view ) {
void gui_editor_3dview_draw_fn( void* ptr ) {
GUI_EDITOR_3DVIEW* view = (GUI_EDITOR_3DVIEW*)ptr;
- if( !objl->pl )
+ if( !editor || !editor->map || !objl->pl )
return;
I32 x = gui_relx( view );
@@ -82,6 +82,9 @@ void gui_editor_3dview_draw_fn( void* ptr ) {
void gui_editor_3dview_input_fn( void* ptr ) {
GUI_EDITOR_3DVIEW* view = (GUI_EDITOR_3DVIEW*)ptr;
+ if( !editor || !editor->map )
+ return;
+
if( !input.mouselock )
gui_base_input_fn( view );
@@ -108,6 +111,9 @@ void gui_editor_3dview_create_toolbar( GUI_EDITOR_3DVIEW* view ) {
I32 x = 1, y = view->h - 4;
gui_button( x, y, 90, 18, "compile bsp", pfn( void* b ) {
+ if( !editor || !editor->map )
+ return;
+
if( editor->map->bsp )
bsp_free( editor->map->bsp );
bsp_build_map( editor->map );