X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Feditor.c;h=920f0861ccf408ed2d16f36831b4b937c861f700;hb=2443a8a09966a9940e1420c91d24a297325c2a00;hp=388083eeaa3ba06accf70853e39221c724c83963;hpb=bf7f1c667ad861d6cadacd0b9d6fe517be977a6e;p=rocksndiamonds.git diff --git a/src/editor.c b/src/editor.c index 388083ee..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: @@ -4018,10 +3998,12 @@ void HandleLevelEditorKeyInput(Key key) DrawLevelText(0, 0, 0, TEXT_BACKSPACE); else if (key == KSYM_Return) DrawLevelText(0, 0, 0, TEXT_NEWLINE); + else if (key == KSYM_Escape) + DrawLevelText(0, 0, 0, TEXT_END); } else if (button_status == MB_RELEASED) { - int i, id; + int i, id = GADGET_ID_NONE; switch (key) { @@ -4046,8 +4028,19 @@ void HandleLevelEditorKeyInput(Key key) button = MB_RIGHTBUTTON; break; + case KSYM_Escape: + if (edit_mode == ED_MODE_DRAWING) + { + RequestExitLevelEditor(setup.ask_on_escape); + } + else + { + DrawDrawingWindow(); + edit_mode = ED_MODE_DRAWING; + } + break; + default: - id = GADGET_ID_NONE; break; } @@ -4083,6 +4076,9 @@ void HandleEditorGadgetInfoText(void *ptr) ClearEditorGadgetInfoText(); + if (gi->event.type == GD_EVENT_INFO_LEAVING) + return; + /* misuse this function to delete brush cursor, if needed */ if (edit_mode == ED_MODE_DRAWING && draw_with_brush) DeleteBrushFromCursor(); @@ -4130,6 +4126,9 @@ static void HandleDrawingAreaInfo(struct GadgetInfo *gi) ClearEditorGadgetInfoText(); + if (gi->event.type == GD_EVENT_INFO_LEAVING) + return; + /* make sure to stay inside drawing area boundaries */ sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx); sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy); @@ -4238,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); + } +}