X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Feditor.c;h=920f0861ccf408ed2d16f36831b4b937c861f700;hb=2443a8a09966a9940e1420c91d24a297325c2a00;hp=196f9fb47b29bcbc683ff545d3293976eeb1418f;hpb=335f4db8f7a8bea9b06eeea911b6d1e1d4de4623;p=rocksndiamonds.git diff --git a/src/editor.c b/src/editor.c index 196f9fb4..920f0861 100644 --- a/src/editor.c +++ b/src/editor.c @@ -3946,27 +3946,7 @@ static void HandleControlButtons(struct GadgetInfo *gi) break; case GADGET_ID_EXIT: - if (!LevelChanged() || - Request("Level has changed! Exit without saving ?", - REQ_ASK | REQ_STAY_OPEN)) - { - CloseDoor(DOOR_CLOSE_1); - - /* - CloseDoor(DOOR_CLOSE_ALL); - */ - - game_status = MAINMENU; - DrawMainMenu(); - } - else - { - CloseDoor(DOOR_CLOSE_1); - BlitBitmap(pix[PIX_DB_DOOR], pix[PIX_DB_DOOR], - DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE,DYSIZE, - DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1); - OpenDoor(DOOR_OPEN_1); - } + RequestExitLevelEditor(TRUE); /* if level has changed, ask user */ break; default: @@ -4051,8 +4031,7 @@ void HandleLevelEditorKeyInput(Key key) case KSYM_Escape: if (edit_mode == ED_MODE_DRAWING) { - game_status = MAINMENU; - DrawMainMenu(); + RequestExitLevelEditor(setup.ask_on_escape); } else { @@ -4258,3 +4237,27 @@ static void HandleDrawingAreaInfo(struct GadgetInfo *gi) "Content area %d position: %d, %d", id - GADGET_ID_ELEM_CONTENT_0 + 1, sx, sy); } + +void RequestExitLevelEditor(boolean ask_if_level_has_changed) +{ + if (!ask_if_level_has_changed || + !LevelChanged() || + Request("Level has changed! Exit without saving ?", + REQ_ASK | REQ_STAY_OPEN)) + { + CloseDoor(DOOR_CLOSE_1); + /* + CloseDoor(DOOR_CLOSE_ALL); + */ + game_status = MAINMENU; + DrawMainMenu(); + } + else + { + CloseDoor(DOOR_CLOSE_1); + BlitBitmap(pix[PIX_DB_DOOR], pix[PIX_DB_DOOR], + DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE,DYSIZE, + DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1); + OpenDoor(DOOR_OPEN_1); + } +}