From b5ed6bb19c12fbcd053fb19320d50d3ac4f5409a Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sun, 19 Jul 2009 13:27:39 +0100 Subject: [PATCH] Add save button to the editor --- src/Editor.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Editor.cpp b/src/Editor.cpp index 890dc79..3868b62 100644 --- a/src/Editor.cpp +++ b/src/Editor.cpp @@ -57,6 +57,8 @@ public: LEVEL_TOOL, START_TOOL, STATION_TOOL, BUILDING_TOOL }; void setTool(Tool aTool) { myTool = aTool; } + + IMapPtr map() { return myMap; } private: void buildGUI(); @@ -99,6 +101,7 @@ namespace { }; Fl_Menu_Button* theToolMenu; + Fl_Button* theSaveButton; ModelViewer* theModelViewer; Editor* theEditor = NULL; @@ -108,6 +111,11 @@ namespace { theToolMenu->label(theToolMenu->text()); theEditor->setTool(aTool); } + + void onSaveClick(Fl_Widget* aWidget) + { + theEditor->map()->save(); + } } // Add the editor panel to the FLTK window @@ -121,6 +129,9 @@ void addEditorGUI() theModelViewer = new ModelViewer(0, 40, panelW, 200); theModelViewer->setModel(loadBuilding("white_house")->model()); + + theSaveButton = new Fl_Button(0, 248, panelW, 25, "Save"); + theSaveButton->callback(onSaveClick); } Editor::Editor(IMapPtr aMap) @@ -544,21 +555,10 @@ void Editor::onKeyUp(SDLKey aKey) void Editor::onKeyDown(SDLKey aKey) { switch (aKey) { - case SDLK_x: - // Write out to disk - myMap->save(); - break; case SDLK_g: // Toggle grid myMap->setGrid(true); break; - case SDLK_p: - // Switch to play mode - { - IScreenPtr game = makeGameScreen(myMap); - getGameWindow()->switchScreen(game); - } - break; default: break; } -- 2.39.2