rnd-20100407-1-src
authorHolger Schemel <info@artsoft.org>
Wed, 7 Apr 2010 21:47:50 +0000 (23:47 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:59:00 +0000 (10:59 +0200)
* added initial, experimental support for different viewport properties
  (with "viewports" being menu/playfield area and doors; currently the
  size of the menu/playfield area and door positions can be redefined)

12 files changed:
ChangeLog
src/conf_gfx.c
src/conf_var.c
src/conftime.h
src/editor.c
src/game.c
src/init.h
src/main.c
src/main.h
src/screens.c
src/tools.c
src/tools.h

index 7558d728f60a8fc6779fa0a7b24599b5af228a56..285539ca6c81e536aef0fab68b7e52dfa0df544b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
+2010-04-07
+       * added initial, experimental support for different viewport properties
+         (with "viewports" being menu/playfield area and doors; currently the
+         size of the menu/playfield area and door positions can be redefined)
+
 2010-04-02
-       * added initial, experimental support for different screen sizes
+       * added initial, experimental support for different window sizes
 
 2010-03-27
        * added support for native Sokoban solution files in pure 'udlrUDLR'
index 87127ad11bc620985af6ef9373ede4be569268f6..156d48557ef3222f458b989dbba4a07728e09f60 100644 (file)
@@ -6406,8 +6406,26 @@ struct ConfigInfo image_config[] =
   { "[player].sleeping_delay_fixed",           "2000"                  },
   { "[player].sleeping_delay_random",          "2000"                  },
 
-  { "global.screen.width",                     "672"                   },
-  { "global.screen.height",                    "560"                   },
+  { "viewport.window.width",                   "672"                   },
+  { "viewport.window.height",                  "560"                   },
+  { "viewport.playfield.menu.width",           "17"                    },
+  { "viewport.playfield.menu.height",          "17"                    },
+  { "viewport.playfield.game.width",           "17"                    },
+  { "viewport.playfield.game.height",          "17"                    },
+  { "viewport.playfield.editor.width",         "17"                    },
+  { "viewport.playfield.editor.height",                "17"                    },
+  { "viewport.door_1.menu.x",                  "566"                   },
+  { "viewport.door_1.menu.y",                  "60"                    },
+  { "viewport.door_1.game.x",                  "566"                   },
+  { "viewport.door_1.game.y",                  "60"                    },
+  { "viewport.door_1.editor.x",                        "566"                   },
+  { "viewport.door_1.editor.y",                        "60"                    },
+  { "viewport.door_2.menu.x",                  "566"                   },
+  { "viewport.door_2.menu.y",                  "400"                   },
+  { "viewport.door_2.game.x",                  "566"                   },
+  { "viewport.door_2.game.y",                  "400"                   },
+  { "viewport.door_2.editor.x",                        "566"                   },
+  { "viewport.door_2.editor.y",                        "356"                   },
 
   { NULL,                                      NULL                    }
 };
index 83a5e0d9f28a34ed2a829d0df4db4116eacbe4ee..0f2cd01c4b73c353a0f4a22c3da4faacf7171a62 100644 (file)
@@ -5093,12 +5093,84 @@ struct TokenIntPtrInfo image_config_vars[] =
     &game.player_sleeping_delay_random
   },
   {
-    "global.screen.width",
-    &global.screen.width
+    "viewport.window.width",
+    &viewport.window.width
   },
   {
-    "global.screen.height",
-    &global.screen.height
+    "viewport.window.height",
+    &viewport.window.height
+  },
+  {
+    "viewport.playfield.menu.width",
+    &viewport.playfield.menu.width
+  },
+  {
+    "viewport.playfield.menu.height",
+    &viewport.playfield.menu.height
+  },
+  {
+    "viewport.playfield.game.width",
+    &viewport.playfield.game.width
+  },
+  {
+    "viewport.playfield.game.height",
+    &viewport.playfield.game.height
+  },
+  {
+    "viewport.playfield.editor.width",
+    &viewport.playfield.editor.width
+  },
+  {
+    "viewport.playfield.editor.height",
+    &viewport.playfield.editor.height
+  },
+  {
+    "viewport.door_1.menu.x",
+    &viewport.door_1.menu.x
+  },
+  {
+    "viewport.door_1.menu.y",
+    &viewport.door_1.menu.y
+  },
+  {
+    "viewport.door_1.game.x",
+    &viewport.door_1.game.x
+  },
+  {
+    "viewport.door_1.game.y",
+    &viewport.door_1.game.y
+  },
+  {
+    "viewport.door_1.editor.x",
+    &viewport.door_1.editor.x
+  },
+  {
+    "viewport.door_1.editor.y",
+    &viewport.door_1.editor.y
+  },
+  {
+    "viewport.door_2.menu.x",
+    &viewport.door_2.menu.x
+  },
+  {
+    "viewport.door_2.menu.y",
+    &viewport.door_2.menu.y
+  },
+  {
+    "viewport.door_2.game.x",
+    &viewport.door_2.game.x
+  },
+  {
+    "viewport.door_2.game.y",
+    &viewport.door_2.game.y
+  },
+  {
+    "viewport.door_2.editor.x",
+    &viewport.door_2.editor.x
+  },
+  {
+    "viewport.door_2.editor.y",
+    &viewport.door_2.editor.y
   },
   {
     NULL,
index 636b81e760bf2440a5319c8f23c84e8bff270b84..15df429df33c909c57113c56bdd0361e8cdcc7fc 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2010-04-02 22:02"
+#define COMPILE_DATE_STRING "2010-04-07 23:40"
index 6c20b638e058857dd4fc9c55e05b295af59a4c5e..83df2e15c5048d51ef8dc7bce33d29cc7f367ec4 100644 (file)
@@ -1047,7 +1047,11 @@ static struct
   /* ---------- current level number --------------------------------------- */
 
   {
+#if 1
+    -1, -1,    /* these values are not constant, but can change at runtime */
+#else
     DX + 5 - SX,                       DY + 3 - SY,
+#endif
     1,                                 100,
     GADGET_ID_SELECT_LEVEL_DOWN,       GADGET_ID_SELECT_LEVEL_UP,
     GADGET_ID_SELECT_LEVEL_TEXT,       GADGET_ID_NONE,
@@ -2474,25 +2478,41 @@ static struct
 {
   {
     ED_SCROLLBUTTON_XPOS,   ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE,
+#if 1
+    -1, -1,    /* these values are not constant, but can change at runtime */
+#else
     ED_SCROLL_UP_XPOS,      ED_SCROLL_UP_YPOS,
+#endif
     GADGET_ID_SCROLL_UP,
     "scroll level editing area up"
   },
   {
     ED_SCROLLBUTTON_XPOS,   ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE,
+#if 1
+    -1, -1,    /* these values are not constant, but can change at runtime */
+#else
     ED_SCROLL_DOWN_XPOS,    ED_SCROLL_DOWN_YPOS,
+#endif
     GADGET_ID_SCROLL_DOWN,
     "scroll level editing area down"
   },
   {
     ED_SCROLLBUTTON_XPOS,   ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE,
+#if 1
+    -1, -1,    /* these values are not constant, but can change at runtime */
+#else
     ED_SCROLL_LEFT_XPOS,    ED_SCROLL_LEFT_YPOS,
+#endif
     GADGET_ID_SCROLL_LEFT,
     "scroll level editing area left"
   },
   {
     ED_SCROLLBUTTON_XPOS,   ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE,
+#if 1
+    -1, -1,    /* these values are not constant, but can change at runtime */
+#else
     ED_SCROLL_RIGHT_XPOS,   ED_SCROLL_RIGHT_YPOS,
+#endif
     GADGET_ID_SCROLL_RIGHT,
     "scroll level editing area right"
   },
@@ -2524,29 +2544,49 @@ static struct
 {
   {
     ED_SCROLLBAR_XPOS,                 ED_SCROLLBAR_YPOS,
+#if 1
+    -1, -1,    /* these values are not constant, but can change at runtime */
+    -1, -1,    /* these values are not constant, but can change at runtime */
+    -1, -1,    /* these values are not constant, but can change at runtime */
+    -1, -1,    /* these values are not constant, but can change at runtime */
+#else
     SX + ED_SCROLL_HORIZONTAL_XPOS,    SY + ED_SCROLL_HORIZONTAL_YPOS,
     ED_SCROLL_HORIZONTAL_XSIZE,                ED_SCROLL_HORIZONTAL_YSIZE,
     SX,                                        SY,
     SXSIZE,                            SYSIZE,
+#endif
     GD_TYPE_SCROLLBAR_HORIZONTAL,
     GADGET_ID_SCROLL_HORIZONTAL,
     "scroll level editing area horizontally"
   },
   {
     ED_SCROLLBAR_XPOS,                 ED_SCROLLBAR_YPOS,
+#if 1
+    -1, -1,    /* these values are not constant, but can change at runtime */
+    -1, -1,    /* these values are not constant, but can change at runtime */
+    -1, -1,    /* these values are not constant, but can change at runtime */
+    -1, -1,    /* these values are not constant, but can change at runtime */
+#else
     SX + ED_SCROLL_VERTICAL_XPOS,      SY + ED_SCROLL_VERTICAL_YPOS,
     ED_SCROLL_VERTICAL_XSIZE,          ED_SCROLL_VERTICAL_YSIZE,
     SX,                                        SY,
     SXSIZE,                            SYSIZE,
+#endif
     GD_TYPE_SCROLLBAR_VERTICAL,
     GADGET_ID_SCROLL_VERTICAL,
     "scroll level editing area vertically"
   },
   {
     ED_SCROLLBAR2_XPOS,                        ED_SCROLLBAR2_YPOS,
+#if 1
+    -1, -1,    /* these values are not constant, but can change at runtime */
+    ED_SCROLL2_VERTICAL_XSIZE,         ED_SCROLL2_VERTICAL_YSIZE,
+    -1, -1,    /* these values are not constant, but can change at runtime */
+#else
     DX + ED_SCROLL2_VERTICAL_XPOS,     DY + ED_SCROLL2_VERTICAL_YPOS,
     ED_SCROLL2_VERTICAL_XSIZE,         ED_SCROLL2_VERTICAL_YSIZE,
     DX,                                        DY,
+#endif
     DXSIZE,                            DYSIZE,
     GD_TYPE_SCROLLBAR_VERTICAL,
     GADGET_ID_SCROLL_LIST_VERTICAL,
@@ -2992,7 +3032,12 @@ static struct
   {
     0,                                 0,
     GADGET_ID_DRAWING_LEVEL,           GADGET_ID_NONE,
-    NULL,                              MAX_ED_FIELDX, MAX_ED_FIELDY,
+    NULL,
+#if 1
+    -1, -1,    /* these values are not constant, but can change at runtime */
+#else
+    MAX_ED_FIELDX, MAX_ED_FIELDY,
+#endif
     NULL, NULL, NULL,                  NULL
   },
 
@@ -3254,7 +3299,11 @@ static struct
 */
 
 /* actual size of level editor drawing area */
+#if 1
+static int ed_fieldx, ed_fieldy;
+#else
 static int ed_fieldx = MAX_ED_FIELDX - 1, ed_fieldy = MAX_ED_FIELDY - 1;
+#endif
 
 /* actual position of level editor drawing area in level playfield */
 static int level_xpos = -1, level_ypos = -1;
@@ -5311,6 +5360,16 @@ static void CreateControlButtons()
     level_editor_gadget[id] = gi;
   }
 
+  /* these values are not constant, but can change at runtime */
+  scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_UP].x    = ED_SCROLL_UP_XPOS;
+  scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_UP].y    = ED_SCROLL_UP_YPOS;
+  scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].x  = ED_SCROLL_DOWN_XPOS;
+  scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].y  = ED_SCROLL_DOWN_YPOS;
+  scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_LEFT].x  = ED_SCROLL_LEFT_XPOS;
+  scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_LEFT].y  = ED_SCROLL_LEFT_YPOS;
+  scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS;
+  scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS;
+
   /* create buttons for scrolling of drawing area and element list */
   for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++)
   {
@@ -5426,6 +5485,10 @@ static void CreateCounterButtons()
   int max_infotext_len = getMaxInfoTextLength();
   int i;
 
+  /* these values are not constant, but can change at runtime */
+  counterbutton_info[ED_COUNTER_ID_SELECT_LEVEL].x = DX + 5 - SX;
+  counterbutton_info[ED_COUNTER_ID_SELECT_LEVEL].y = DY + 3 - SY;
+
   for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++)
   {
     int j;
@@ -5580,6 +5643,10 @@ static void CreateDrawingAreas()
 {
   int i;
 
+  /* these values are not constant, but can change at runtime */
+  drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX;
+  drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY;
+
   for (i = 0; i < ED_NUM_DRAWING_AREAS; i++)
   {
     struct GadgetInfo *gi;
@@ -5947,6 +6014,40 @@ static void CreateScrollbarGadgets()
 {
   int i;
 
+  /* these values are not constant, but can change at runtime */
+  scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x =
+    SX + ED_SCROLL_HORIZONTAL_XPOS;
+  scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y =
+    SY + ED_SCROLL_HORIZONTAL_YPOS;
+  scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width =
+    ED_SCROLL_HORIZONTAL_XSIZE;
+  scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height =
+    ED_SCROLL_HORIZONTAL_YSIZE;
+  scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x      = SX;
+  scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y      = SY;
+  scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width  = SXSIZE;
+  scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE;
+
+  scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].x =
+    SX + ED_SCROLL_VERTICAL_XPOS;
+  scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].y =
+    SY + ED_SCROLL_VERTICAL_YPOS;
+  scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].width =
+    ED_SCROLL_VERTICAL_XSIZE;
+  scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].height =
+    ED_SCROLL_VERTICAL_YSIZE;
+  scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x      = SX;
+  scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y      = SY;
+  scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width  = SXSIZE;
+  scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE;
+
+  scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].x =
+    DX + ED_SCROLL2_VERTICAL_XPOS;
+  scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].y =
+    DY + ED_SCROLL2_VERTICAL_YPOS;
+  scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = DX;
+  scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = DY;
+
   for (i = 0; i < ED_NUM_SCROLLBARS; i++)
   {
     int id = scrollbar_info[i].gadget_id;
@@ -6149,6 +6250,10 @@ void CreateLevelEditorGadgets()
   /* setting 'game_status' is needed to get the right fonts for the editor */
   game_status = GAME_MODE_EDITOR;
 
+  /* these values are not constant, but can change at runtime */
+  ed_fieldx = MAX_ED_FIELDX - 1;
+  ed_fieldy = MAX_ED_FIELDY - 1;
+
   ReinitializeElementList();
 
   CreateControlButtons();
@@ -7342,6 +7447,11 @@ void DrawLevelEd()
 
   redraw_mask |= REDRAW_ALL;
 
+#if 1
+  FreeLevelEditorGadgets();
+  CreateLevelEditorGadgets();
+#endif
+
   ReinitializeElementList();           /* update dynamic level element list */
   ReinitializeElementListButtons();    /* custom element may look different */
 
@@ -10005,7 +10115,11 @@ static void SelectArea(int from_x, int from_y, int to_x, int to_y,
 static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
                         int button, int mode)
 {
+#if 1
+  static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
+#else
   static short brush_buffer[MAX_ED_FIELDX][MAX_ED_FIELDY];
+#endif
   static int brush_width, brush_height;
   static int last_cursor_x = -1, last_cursor_y = -1;
   static boolean delete_old_brush;
index 556c22b29aa87abd23b7a6975809761c739c2389..e671dbe4db71d3b44f97ecce958ea36c620cef8b 100644 (file)
@@ -3720,6 +3720,11 @@ void InitGame()
 
   game_status = GAME_MODE_PLAYING;
 
+#if 1
+  /* needed if different viewport properties defined for playing */
+  ChangeViewportPropertiesIfNeeded();
+#endif
+
   InitGameEngine();
   InitGameControlValues();
 
index 02985dd67964fcda54dc4a0d787fc3897f391c92..42bc9f740525d79035a0abfdd5c8bbb1d6297b1a 100644 (file)
@@ -44,6 +44,7 @@ void RedrawBackground();
 void KeyboardAutoRepeatOffUnlessAutoplay();
 
 void InitGfxBuffers();
+void InitGadgets();
 
 void OpenAll(void);
 void CloseAllAndExit(int);
index 02e492578db269aea9ab6d9b0c4df0a6941b2ba9..aab51a3824fce88fde27434e27eb7497915e3a4b 100644 (file)
@@ -39,7 +39,11 @@ SDL_Thread          *server_thread;
 
 int                    key_joystick_mapping = 0;
 
+#if 1
+boolean                        redraw[MAX_LEV_FIELDX + 2][MAX_LEV_FIELDY + 2];
+#else
 boolean                        redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
+#endif
 int                    redraw_x1 = 0, redraw_y1 = 0;
 
 short                  Feld[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
@@ -84,8 +88,11 @@ int                  ActiveFont[NUM_FONTS];
 int                    lev_fieldx, lev_fieldy;
 int                    scroll_x, scroll_y;
 
-int                    WIN_XSIZE = 672;
-int                    WIN_YSIZE = 560;
+int                    WIN_XSIZE = 672, WIN_YSIZE = 560;
+int                    SCR_FIELDX = 17, SCR_FIELDY = 17;
+int                    DX = 566, DY = 60;
+int                    VX = 566, VY = 400;
+int                    EX = 566, EY = 356;
 
 int                    FX = SX, FY = SY;
 int                    ScrollStepSize;
@@ -94,8 +101,13 @@ int                 ScreenGfxPos = 0;
 int                    BorderElement = EL_STEELWALL;
 int                    GameFrameDelay = GAME_FRAME_DELAY;
 int                    FfwdFrameDelay = FFWD_FRAME_DELAY;
+#if 1
+int                    BX1, BY1;
+int                    BX2, BY2;
+#else
 int                    BX1 = 0, BY1 = 0;
 int                    BX2 = SCR_FIELDX - 1, BY2 = SCR_FIELDY - 1;
+#endif
 int                    SBX_Left, SBX_Right;
 int                    SBY_Upper, SBY_Lower;
 int                    ZX, ZY;
@@ -115,6 +127,7 @@ struct SetupInfo    setup;
 struct GameInfo                game;
 struct GlobalInfo      global;
 struct BorderInfo      border;
+struct ViewportInfo    viewport;
 struct TitleFadingInfo fading;
 struct TitleFadingInfo title_initial_default;
 struct TitleFadingInfo title_default;
index 8632855a043f5b6a4a2a8e6094a2acaa5014d9e3..09306600a7dbbcc6e9b06e0f445f98690ef72555 100644 (file)
 
 #define DEFAULT_FULLSCREEN_MODE                "800x600"
 
+#if 0
 #define SCR_FIELDX                     17
 #define SCR_FIELDY                     17
+#endif
 #define MAX_BUF_XSIZE                  (SCR_FIELDX + 2)
 #define MAX_BUF_YSIZE                  (SCR_FIELDY + 2)
 #define MIN_LEV_FIELDX                 3
 #define SY                     8
 #define REAL_SX                        (SX - 2)
 #define REAL_SY                        (SY - 2)
+#if 0
 #define DX                     566
 #define DY                     60
 #define VX                     DX
 #define VY                     400
 #define EX                     DX
 #define EY                     (VY - 44)
+#endif
 #define TILESIZE               32
 #define TILEX                  TILESIZE
 #define TILEY                  TILESIZE
@@ -2448,8 +2452,21 @@ struct GlobalInfo
   int fading_status;
   int fading_type;
 #endif
+};
+
+struct SubViewportInfo
+{
+  struct Rect menu;
+  struct Rect game;
+  struct Rect editor;
+};
 
-  struct Rect screen;
+struct ViewportInfo
+{
+  struct Rect window;
+  struct SubViewportInfo playfield;
+  struct SubViewportInfo door_1;
+  struct SubViewportInfo door_2;
 };
 
 struct ElementChangeInfo
@@ -2802,7 +2819,11 @@ extern SDL_Thread               *server_thread;
 
 extern int                     key_joystick_mapping;
 
+#if 1
+extern boolean                 redraw[MAX_LEV_FIELDX + 2][MAX_LEV_FIELDY + 2];
+#else
 extern boolean                 redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
+#endif
 extern int                     redraw_x1, redraw_y1;
 
 extern short                   Feld[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
@@ -2848,6 +2869,10 @@ extern int                       lev_fieldx, lev_fieldy;
 extern int                     scroll_x, scroll_y;
 
 extern int                     WIN_XSIZE, WIN_YSIZE;
+extern int                     SCR_FIELDX, SCR_FIELDY;
+extern int                     DX, DY;
+extern int                     VX, VY;
+extern int                     EX, EY;
 
 extern int                     FX, FY;
 extern int                     ScrollStepSize;
@@ -2875,6 +2900,7 @@ extern struct HiScore             highscore[];
 extern struct TapeInfo         tape;
 extern struct GlobalInfo       global;
 extern struct BorderInfo       border;
+extern struct ViewportInfo     viewport;
 extern struct TitleFadingInfo  fading;
 extern struct TitleFadingInfo  fading_none;
 extern struct TitleFadingInfo  title_initial_default;
index 9fbd5b1b487ea80e54320890e3389d04a3043a19..94f0824e47639679c062c615c7a25968f157529f 100644 (file)
@@ -1025,7 +1025,11 @@ static boolean insideTextPosRect(struct TextPosInfo *rect, int x, int y)
 
 static void drawCursorExt(int xpos, int ypos, boolean active, int graphic)
 {
+#if 1
+  static int cursor_array[MAX_LEV_FIELDY];
+#else
   static int cursor_array[SCR_FIELDY];
+#endif
   int x = mSX + TILEX * xpos;
   int y = mSY + TILEY * (MENU_SCREEN_START_YPOS + ypos);
 
@@ -1286,8 +1290,8 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading)
 #endif
 
 #if 1
-  /* needed if newly loaded custom artwork requires a different screen mode */
-  ChangeScreenModeIfNeeded();
+  /* needed if different viewport properties defined for menues */
+  ChangeViewportPropertiesIfNeeded();
 #endif
 
 #if defined(TARGET_SDL)
@@ -1777,6 +1781,11 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
 
        FadeSetEnterScreen();
 
+#if 1
+       /* needed if different viewport properties defined for editor */
+       ChangeViewportPropertiesIfNeeded();
+#endif
+
        DrawLevelEd();
       }
       else if (pos == MAIN_CONTROL_INFO)
@@ -5673,13 +5682,21 @@ static struct
 {
   {
     IMG_MENU_BUTTON_UP, IMG_MENU_BUTTON_UP_ACTIVE,
+#if 1
+    -1, -1,    /* these values are not constant, but can change at runtime */
+#else
     SC_SCROLL_UP_XPOS, SC_SCROLL_UP_YPOS,
+#endif
     SCREEN_CTRL_ID_SCROLL_UP,
     "scroll up"
   },
   {
     IMG_MENU_BUTTON_DOWN, IMG_MENU_BUTTON_DOWN_ACTIVE,
+#if 1
+    -1, -1,    /* these values are not constant, but can change at runtime */
+#else
     SC_SCROLL_DOWN_XPOS, SC_SCROLL_DOWN_YPOS,
+#endif
     SCREEN_CTRL_ID_SCROLL_DOWN,
     "scroll down"
   }
@@ -5705,8 +5722,13 @@ static struct
 #else
     IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE,
 #endif
+#if 1
+    -1, -1,    /* these values are not constant, but can change at runtime */
+    -1, -1,    /* these values are not constant, but can change at runtime */
+#else
     SC_SCROLL_VERTICAL_XPOS, SC_SCROLL_VERTICAL_YPOS,
     SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
+#endif
     GD_TYPE_SCROLLBAR_VERTICAL,
     SCREEN_CTRL_ID_SCROLL_VERTICAL,
     "scroll level series vertically"
@@ -5772,6 +5794,12 @@ static void CreateScreenScrollbuttons()
   unsigned long event_mask;
   int i;
 
+  /* these values are not constant, but can change at runtime */
+  scrollbutton_info[0].x = SC_SCROLL_UP_XPOS;
+  scrollbutton_info[0].y = SC_SCROLL_UP_YPOS;
+  scrollbutton_info[1].x = SC_SCROLL_DOWN_XPOS;
+  scrollbutton_info[1].y = SC_SCROLL_DOWN_YPOS;
+
   for (i = 0; i < NUM_SCREEN_SCROLLBUTTONS; i++)
   {
     Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
@@ -5827,6 +5855,12 @@ static void CreateScreenScrollbars()
 {
   int i;
 
+  /* these values are not constant, but can change at runtime */
+  scrollbar_info[0].x = SC_SCROLL_VERTICAL_XPOS;
+  scrollbar_info[0].y = SC_SCROLL_VERTICAL_YPOS;
+  scrollbar_info[0].width  = SC_SCROLL_VERTICAL_XSIZE;
+  scrollbar_info[0].height = SC_SCROLL_VERTICAL_YSIZE;
+
   for (i = 0; i < NUM_SCREEN_SCROLLBARS; i++)
   {
     Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
index ef61869106a2e681607cdaf56ac031aec3508488..30df9f7cafa12b121a177f0cbd1221e6bc8e7280 100644 (file)
@@ -349,6 +349,10 @@ void BackToFront()
 
   if (redraw_mask & REDRAW_FIELD)
   {
+#if 0
+    printf("::: REDRAW_FIELD\n");
+#endif
+
     if (game_status != GAME_MODE_PLAYING ||
        redraw_mask & REDRAW_FROM_BACKBUFFER)
     {
@@ -431,6 +435,10 @@ void BackToFront()
 
   if (redraw_mask & REDRAW_TILES)
   {
+#if 0
+    printf("::: REDRAW_TILES\n");
+#endif
+
     for (x = 0; x < SCR_FIELDX; x++)
       for (y = 0 ; y < SCR_FIELDY; y++)
        if (redraw[redraw_x1 + x][redraw_y1 + y])
@@ -8078,22 +8086,85 @@ void ToggleFullscreenIfNeeded()
   }
 }
 
-void ChangeScreenModeIfNeeded()
+void ChangeViewportPropertiesIfNeeded()
 {
-  if (global.screen.width  == WIN_XSIZE &&
-      global.screen.height == WIN_YSIZE)
-    return;
-
-  WIN_XSIZE = global.screen.width;
-  WIN_YSIZE = global.screen.height;
+  if (viewport.window.width  != WIN_XSIZE ||
+      viewport.window.height != WIN_YSIZE)
+  {
+    WIN_XSIZE = viewport.window.width;
+    WIN_YSIZE = viewport.window.height;
 
-  InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen);
-  InitGfxBuffers();
+    InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen);
+    InitGfxBuffers();
 
 #if 1
-  SetDrawDeactivationMask(REDRAW_NONE);
-  SetDrawBackgroundMask(REDRAW_FIELD);
+    SetDrawDeactivationMask(REDRAW_NONE);
+    SetDrawBackgroundMask(REDRAW_FIELD);
 
-  // RedrawBackground();
+    // RedrawBackground();
 #endif
+  }
+
+  if (game_status == GAME_MODE_PLAYING)
+  {
+    if (viewport.playfield.game.width  != SCR_FIELDX ||
+       viewport.playfield.game.height != SCR_FIELDY ||
+       viewport.door_1.game.x != DX ||
+       viewport.door_1.game.y != DY ||
+       viewport.door_2.game.x != VX ||
+       viewport.door_2.game.y != VY)
+    {
+      SCR_FIELDX = viewport.playfield.game.width;
+      SCR_FIELDY = viewport.playfield.game.height;
+
+      DX = viewport.door_1.game.x;
+      DY = viewport.door_1.game.y;
+      VX = viewport.door_2.game.x;
+      VY = viewport.door_2.game.y;
+
+      InitGfxBuffers();
+    }
+  }
+  else if (game_status == GAME_MODE_EDITOR)
+  {
+    if (viewport.playfield.editor.width  != SCR_FIELDX ||
+       viewport.playfield.editor.height != SCR_FIELDY ||
+       viewport.door_1.editor.x != DX ||
+       viewport.door_1.editor.y != DY ||
+       viewport.door_2.editor.x != EX ||
+       viewport.door_2.editor.y != EY)
+    {
+      SCR_FIELDX = viewport.playfield.editor.width;
+      SCR_FIELDY = viewport.playfield.editor.height;
+
+      DX = viewport.door_1.editor.x;
+      DY = viewport.door_1.editor.y;
+      EX = viewport.door_2.editor.x;
+      EY = viewport.door_2.editor.y;
+
+      InitGfxBuffers();
+    }
+  }
+  else         /* any menu screen */
+  {
+    if (viewport.playfield.menu.width  != SCR_FIELDX ||
+       viewport.playfield.menu.height != SCR_FIELDY ||
+       viewport.door_1.menu.x != DX ||
+       viewport.door_1.menu.y != DY ||
+       viewport.door_2.menu.x != VX ||
+       viewport.door_2.menu.y != VY)
+    {
+      SCR_FIELDX = viewport.playfield.menu.width;
+      SCR_FIELDY = viewport.playfield.menu.height;
+
+      DX = viewport.door_1.menu.x;
+      DY = viewport.door_1.menu.y;
+      VX = viewport.door_2.menu.x;
+      VY = viewport.door_2.menu.y;
+
+      InitGfxBuffers();
+      InitGadgets();
+      InitToons();
+    }
+  }
 }
index 2ae83cfed178bfbbfdbf6e2f2dcb71587e649f16..0fd7aa7e0eb0a71579d05b990b0bfff6b0f7258e 100644 (file)
@@ -215,6 +215,6 @@ void PlaySoundActivating();
 void PlaySoundSelecting();
 
 void ToggleFullscreenIfNeeded();
-void ChangeScreenModeIfNeeded();
+void ChangeViewportPropertiesIfNeeded();
 
 #endif /* TOOLS_H */