From 2443a8a09966a9940e1420c91d24a297325c2a00 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 3 Apr 2002 00:06:22 +0200 Subject: [PATCH] rnd-20020403-1-src --- Makefile | 3 + src/editor.c | 49 ++++++++-------- src/editor.h | 1 + src/events.c | 4 ++ src/files.c | 5 +- src/game.c | 50 ++++++++-------- src/game.h | 1 + src/libgame/system.h | 1 + src/screens.c | 135 +++++++++++++++++++++++++++++-------------- src/timestamp.h | 2 +- 10 files changed, 159 insertions(+), 92 deletions(-) diff --git a/Makefile b/Makefile index 3794cd87..74814455 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,9 @@ clean: # development only stuff # #-----------------------------------------------------------------------------# +run: + @$(MAKE_CMD) TARGET=x11 && ./rocksndiamonds --verbose + backup: ./Scripts/make_backup.sh src 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); + } +} diff --git a/src/editor.h b/src/editor.h index 466b571f..e23c7329 100644 --- a/src/editor.h +++ b/src/editor.h @@ -29,5 +29,6 @@ void UnmapLevelEditorGadgets(); void DrawLevelEd(void); void HandleLevelEditorKeyInput(Key); void HandleEditorGadgetInfoText(void *ptr); +void RequestExitLevelEditor(boolean); #endif diff --git a/src/events.c b/src/events.c index c002c78e..a4b60829 100644 --- a/src/events.c +++ b/src/events.c @@ -477,6 +477,7 @@ void HandleKey(Key key, int key_status) /* allow quick escape to the main menu with the Escape key */ if (key == KSYM_Escape && game_status != MAINMENU && + game_status != PLAYING && game_status != LEVELED && game_status != CHOOSELEVEL && game_status != SETUP) @@ -592,6 +593,9 @@ void HandleKey(Key key, int key_status) { switch(key) { + case KSYM_Escape: + RequestQuitGame(); + break; #ifdef DEBUG case KSYM_0: diff --git a/src/files.c b/src/files.c index 5da89a73..2a723971 100644 --- a/src/files.c +++ b/src/files.c @@ -1180,8 +1180,9 @@ void SaveScore(int level_nr) #define SETUP_TOKEN_HANDICAP 12 #define SETUP_TOKEN_TIME_LIMIT 13 #define SETUP_TOKEN_FULLSCREEN 14 +#define SETUP_TOKEN_ASK_ON_ESCAPE 15 -#define NUM_GLOBAL_SETUP_TOKENS 15 +#define NUM_GLOBAL_SETUP_TOKENS 16 /* shortcut setup */ #define SETUP_TOKEN_SAVE_GAME 0 @@ -1230,6 +1231,7 @@ static struct TokenInfo global_setup_tokens[] = { TYPE_SWITCH, &si.team_mode, "team_mode" }, { TYPE_SWITCH, &si.handicap, "handicap" }, { TYPE_SWITCH, &si.time_limit, "time_limit" }, + { TYPE_SWITCH, &si.ask_on_escape, "ask_on_escape" }, { TYPE_SWITCH, &si.fullscreen, "fullscreen" } }; @@ -1283,6 +1285,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->handicap = TRUE; si->time_limit = TRUE; si->fullscreen = FALSE; + si->ask_on_escape = TRUE; si->shortcut.save_game = DEFAULT_KEY_SAVE_GAME; si->shortcut.load_game = DEFAULT_KEY_LOAD_GAME; diff --git a/src/game.c b/src/game.c index 0c369f03..6d536ec6 100644 --- a/src/game.c +++ b/src/game.c @@ -6305,6 +6305,31 @@ void RaiseScoreElement(int element) } } +void RequestQuitGame() +{ + if (AllPlayersGone || + !setup.ask_on_escape || + level_editor_test_game || + Request("Do you really want to quit the game ?", + REQ_ASK | REQ_STAY_CLOSED)) + { +#if defined(PLATFORM_UNIX) + if (options.network) + SendToServer_StopPlaying(); + else +#endif + { + game_status = MAINMENU; + DrawMainMenu(); + } + } + else + { + OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK); + } +} + + /* ---------- new game button stuff ---------------------------------------- */ /* graphic position values for game buttons */ @@ -6453,30 +6478,7 @@ static void HandleGameButtons(struct GadgetInfo *gi) switch (id) { case GAME_CTRL_ID_STOP: - if (AllPlayersGone) - { - CloseDoor(DOOR_CLOSE_1); - game_status = MAINMENU; - DrawMainMenu(); - break; - } - - if (level_editor_test_game || - Request("Do you really want to quit the game ?", - REQ_ASK | REQ_STAY_CLOSED)) - { -#if defined(PLATFORM_UNIX) - if (options.network) - SendToServer_StopPlaying(); - else -#endif - { - game_status = MAINMENU; - DrawMainMenu(); - } - } - else - OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK); + RequestQuitGame(); break; case GAME_CTRL_ID_PAUSE: diff --git a/src/game.h b/src/game.h index 9bf009eb..3a66264e 100644 --- a/src/game.h +++ b/src/game.h @@ -92,6 +92,7 @@ boolean PlaceBomb(struct PlayerInfo *); void PlaySoundLevel(int, int, int); void RaiseScore(int); void RaiseScoreElement(int); +void RequestQuitGame(void); void CreateGameButtons(); void UnmapGameButtons(); diff --git a/src/libgame/system.h b/src/libgame/system.h index ac01255a..3dbae599 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -305,6 +305,7 @@ struct SetupInfo boolean handicap; boolean time_limit; boolean fullscreen; + boolean ask_on_escape; struct SetupShortcutInfo shortcut; struct SetupInputInfo input[MAX_PLAYERS]; diff --git a/src/screens.c b/src/screens.c index 50383cdf..46324314 100644 --- a/src/screens.c +++ b/src/screens.c @@ -30,9 +30,11 @@ #define SETUP_MODE_SHORTCUT 2 #define SETUP_MODE_GRAPHICS 3 #define SETUP_MODE_SOUND 4 -#define SETUP_MODE_CHOOSE_SOUNDS 5 +#define SETUP_MODE_CHOOSE_GRAPHICS 5 +#define SETUP_MODE_CHOOSE_SOUNDS 6 +#define SETUP_MODE_CHOOSE_MUSIC 7 -#define MAX_SETUP_MODES 6 +#define MAX_SETUP_MODES 8 /* for input setup functions */ #define SETUPINPUT_SCREEN_POS_START 0 @@ -1348,7 +1350,7 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) static struct TokenInfo *setup_info; static int num_setup_info; -static char *custom_artwork; +static char *custom_graphics, *custom_sounds, *custom_music; static void execSetupMain() { @@ -1356,20 +1358,41 @@ static void execSetupMain() DrawSetupScreen(); } +static void execSetupGraphics() +{ + custom_graphics = artwork.gfx_current->name; + + setup_mode = SETUP_MODE_GRAPHICS; + DrawSetupScreen(); +} + static void execSetupSound() { - custom_artwork = artwork.snd_current->name; + custom_sounds = artwork.snd_current->name; + custom_music = artwork.mus_current->name; setup_mode = SETUP_MODE_SOUND; DrawSetupScreen(); } +static void execSetupChooseGraphics() +{ + setup_mode = SETUP_MODE_CHOOSE_GRAPHICS; + DrawSetupScreen(); +} + static void execSetupChooseSounds() { setup_mode = SETUP_MODE_CHOOSE_SOUNDS; DrawSetupScreen(); } +static void execSetupChooseMusic() +{ + setup_mode = SETUP_MODE_CHOOSE_MUSIC; + DrawSetupScreen(); +} + static void execSetupInput() { setup_mode = SETUP_MODE_INPUT; @@ -1384,7 +1407,9 @@ static void execSetupShortcut() static void execExitSetupChooseArtwork() { - if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS) + if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS) + execSetupGraphics(); + else execSetupSound(); } @@ -1402,49 +1427,56 @@ static void execSaveAndExitSetup() static struct TokenInfo setup_info_main[] = { - { TYPE_ENTER_MENU, execSetupSound, "Sound Setup" }, - { TYPE_ENTER_MENU, execSetupInput, "Input Devices" }, - { TYPE_ENTER_MENU, execSetupShortcut, "Key Shortcuts" }, -#if 0 - { TYPE_EMPTY, NULL, "" }, - { TYPE_SWITCH, &setup.sound, "Sound:", }, - { TYPE_SWITCH, &setup.sound_loops, " Sound Loops:" }, - { TYPE_SWITCH, &setup.sound_music, " Game Music:" }, -#endif - { TYPE_SWITCH, &setup.toons, "Toons:" }, -#if 0 - { TYPE_SWITCH, &setup.double_buffering,"Buffered gfx:" }, -#endif - { TYPE_SWITCH, &setup.scroll_delay, "Scroll Delay:" }, - { TYPE_SWITCH, &setup.soft_scrolling, "Soft Scroll.:" }, + { TYPE_ENTER_MENU, execSetupGraphics, "Graphics Setup" }, + { TYPE_ENTER_MENU, execSetupSound, "Sound Setup" }, + { TYPE_ENTER_MENU, execSetupInput, "Input Devices" }, + { TYPE_ENTER_MENU, execSetupShortcut, "Key Shortcuts" }, + { TYPE_EMPTY, NULL, "" }, #if 0 - { TYPE_SWITCH, &setup.fading, "Fading:" }, + { TYPE_SWITCH, &setup.double_buffering,"Buffered gfx:" }, + { TYPE_SWITCH, &setup.fading, "Fading:" }, #endif - { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" }, - { TYPE_SWITCH, &setup.quick_doors, "Quick Doors:" }, - { TYPE_SWITCH, &setup.autorecord, "Auto-Record:" }, - { TYPE_SWITCH, &setup.team_mode, "Team-Mode:" }, - { TYPE_SWITCH, &setup.handicap, "Handicap:" }, - { TYPE_SWITCH, &setup.time_limit, "Timelimit:" }, - { TYPE_EMPTY, NULL, "" }, - { TYPE_LEAVE_MENU, execExitSetup, "Exit" }, - { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and exit" }, - { 0, NULL, NULL } + { TYPE_SWITCH, &setup.quick_doors, "Quick Doors:" }, + { TYPE_SWITCH, &setup.ask_on_escape, "Ask on Esc:" }, + { TYPE_SWITCH, &setup.toons, "Toons:" }, + { TYPE_SWITCH, &setup.autorecord, "Auto-Record:" }, + { TYPE_SWITCH, &setup.team_mode, "Team-Mode:" }, + { TYPE_SWITCH, &setup.handicap, "Handicap:" }, + { TYPE_SWITCH, &setup.time_limit, "Timelimit:" }, + { TYPE_EMPTY, NULL, "" }, + { TYPE_LEAVE_MENU, execExitSetup, "Exit" }, + { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and exit" }, + { 0, NULL, NULL } +}; + +static struct TokenInfo setup_info_graphics[] = +{ + { TYPE_ENTER_MENU, execSetupChooseGraphics,"Custom Graphics" }, + { TYPE_STRING, &custom_graphics, "" }, + { TYPE_EMPTY, NULL, "" }, + { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" }, + { TYPE_SWITCH, &setup.scroll_delay, "Scroll Delay:" }, + { TYPE_SWITCH, &setup.soft_scrolling, "Soft Scroll.:" }, + { TYPE_EMPTY, NULL, "" }, + { TYPE_LEAVE_MENU, execSetupMain, "Exit" }, + { 0, NULL, NULL } }; static struct TokenInfo setup_info_sound[] = { - { TYPE_SWITCH, &setup.sound, "Sound:", }, - { TYPE_EMPTY, NULL, "" }, - { TYPE_SWITCH, &setup.sound_simple, "Simple Sound:" }, - { TYPE_SWITCH, &setup.sound_loops, "Sound Loops:" }, - { TYPE_SWITCH, &setup.sound_music, "Game Music:" }, - { TYPE_EMPTY, NULL, "" }, - { TYPE_ENTER_MENU, execSetupChooseSounds, "Custom Sounds" }, - { TYPE_STRING, &custom_artwork, "" }, - { TYPE_EMPTY, NULL, "" }, - { TYPE_LEAVE_MENU, execSetupMain, "Exit" }, - { 0, NULL, NULL } + { TYPE_SWITCH, &setup.sound, "Sound:", }, + { TYPE_EMPTY, NULL, "" }, + { TYPE_SWITCH, &setup.sound_simple, "Simple Sound:" }, + { TYPE_SWITCH, &setup.sound_loops, "Sound Loops:" }, + { TYPE_SWITCH, &setup.sound_music, "Game Music:" }, + { TYPE_EMPTY, NULL, "" }, + { TYPE_ENTER_MENU, execSetupChooseSounds, "Custom Sounds" }, + { TYPE_STRING, &custom_sounds, "" }, + { TYPE_ENTER_MENU, execSetupChooseMusic, "Custom Music" }, + { TYPE_STRING, &custom_music, "" }, + { TYPE_EMPTY, NULL, "" }, + { TYPE_LEAVE_MENU, execSetupMain, "Exit" }, + { 0, NULL, NULL } }; static struct TokenInfo setup_info_shortcut[] = @@ -1575,6 +1607,11 @@ static void DrawSetupScreen_Generic() setup_info = setup_info_main; title_string = "Setup"; } + else if (setup_mode == SETUP_MODE_GRAPHICS) + { + setup_info = setup_info_graphics; + title_string = "Setup Graphics"; + } else if (setup_mode == SETUP_MODE_SOUND) { setup_info = setup_info_sound; @@ -1593,6 +1630,7 @@ static void DrawSetupScreen_Generic() { void *value_ptr = setup_info[i].value; int ypos = MENU_SCREEN_START_YPOS + i; + int font_size = FS_BIG; /* set some entries to "unchangeable" according to other variables */ if ((value_ptr == &setup.sound && !audio.sound_available) || @@ -1602,7 +1640,10 @@ static void DrawSetupScreen_Generic() (value_ptr == &setup.fullscreen && !video.fullscreen_available)) setup_info[i].type |= TYPE_GHOSTED; - DrawText(SX + 32, SY + ypos * 32, setup_info[i].text, FS_BIG, FC_GREEN); + if (setup_info[i].type & TYPE_ENTER_OR_LEAVE_MENU) + font_size = FS_BIG; + + DrawText(SX + 32, SY + ypos * 32, setup_info[i].text, font_size, FC_GREEN); if (setup_info[i].type & TYPE_ENTER_MENU) initCursor(i, GFX_ARROW_BLUE_RIGHT); @@ -2303,8 +2344,12 @@ void DrawSetupScreen() { if (setup_mode == SETUP_MODE_INPUT) DrawSetupScreen_Input(); + else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS) + DrawChooseTree(&artwork.gfx_current); else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS) DrawChooseTree(&artwork.snd_current); + else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC) + DrawChooseTree(&artwork.mus_current); else DrawSetupScreen_Generic(); } @@ -2313,8 +2358,12 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) { if (setup_mode == SETUP_MODE_INPUT) HandleSetupScreen_Input(mx, my, dx, dy, button); + else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS) + HandleChooseTree(mx, my, dx, dy, button, &artwork.gfx_current); else if (setup_mode == SETUP_MODE_CHOOSE_SOUNDS) HandleChooseTree(mx, my, dx, dy, button, &artwork.snd_current); + else if (setup_mode == SETUP_MODE_CHOOSE_MUSIC) + HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current); else HandleSetupScreen_Generic(mx, my, dx, dy, button); } diff --git a/src/timestamp.h b/src/timestamp.h index cb5f4843..3a865842 100644 --- a/src/timestamp.h +++ b/src/timestamp.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2002-04-02 04:37]" +#define COMPILE_DATE_STRING "[2002-04-03 00:02]" -- 2.34.1