rnd-20020403-1-src
authorHolger Schemel <info@artsoft.org>
Tue, 2 Apr 2002 22:06:22 +0000 (00:06 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:36:47 +0000 (10:36 +0200)
Makefile
src/editor.c
src/editor.h
src/events.c
src/files.c
src/game.c
src/game.h
src/libgame/system.h
src/screens.c
src/timestamp.h

index 3794cd878840e9bb6928fe6e8690ea0dc2dcdf2e..74814455f1904c82c1a172cda2649a680c14cb33 100644 (file)
--- 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
 
index 196f9fb47b29bcbc683ff545d3293976eeb1418f..920f0861ccf408ed2d16f36831b4b937c861f700 100644 (file)
@@ -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);
+  }
+}
index 466b571fb8c2550ab6c388713ad5292e29665a6e..e23c7329d887dbfb02c2f62adb07df571c1eaf51 100644 (file)
@@ -29,5 +29,6 @@ void UnmapLevelEditorGadgets();
 void DrawLevelEd(void);
 void HandleLevelEditorKeyInput(Key);
 void HandleEditorGadgetInfoText(void *ptr);
+void RequestExitLevelEditor(boolean);
 
 #endif
index c002c78ebbd6588dafeb1e64a90da9f801ba67ae..a4b60829e90a139f35aeff1bc19a9cbfab278b3e 100644 (file)
@@ -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:
index 5da89a735d83216a0e8d023ec966ecaa29204d3b..2a72397139931fb4d9c735428353d0925c65e1cb 100644 (file)
@@ -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;
index 0c369f03ae7363a53b4b83d59ae75d2449e7a08b..6d536ec61824da1b027d525fa4620b2cc341e2d5 100644 (file)
@@ -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:
index 9bf009eb7ac98878af0e0f3739369e0b08404dd2..3a66264e4f57df98a6648880d76ffeea90340573 100644 (file)
@@ -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();
index ac01255a687e6296206cfa2b04b440f0b37b33ae..3dbae5993fc16cd86a53162c84440553c66eed52 100644 (file)
@@ -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];
index 50383cdf86ab1e3cd4ec6a880b7091a210f252ee..46324314fdaf3e008e172b220e23959c47100090 100644 (file)
 #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);
 }
index cb5f48438a3bd84c1fa7c49a69daeb964f7fde82..3a865842946ac3c6df3ddc7d15da211a7697dc2f 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2002-04-02 04:37]"
+#define COMPILE_DATE_STRING "[2002-04-03 00:02]"