moved setting overlay grid size and buttons to separate function
authorHolger Schemel <info@artsoft.org>
Sat, 31 Oct 2020 22:49:58 +0000 (23:49 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 31 Oct 2020 22:49:58 +0000 (23:49 +0100)
src/events.c
src/libgame/system.c
src/libgame/system.h

index aade635e02388745f5679e3336d1f11ffb731e80..e3632df02a71a2c3081f1fb634d0b128d6c7e1dc 100644 (file)
@@ -673,19 +673,10 @@ void HandleWindowEvent(WindowEvent *event)
        // check if screen orientation has changed (should always be true here)
        if (nr != GRID_ACTIVE_NR())
        {
        // check if screen orientation has changed (should always be true here)
        if (nr != GRID_ACTIVE_NR())
        {
-         int x, y;
-
          if (game_status == GAME_MODE_SETUP)
            RedrawSetupScreenAfterScreenRotation(nr);
 
          if (game_status == GAME_MODE_SETUP)
            RedrawSetupScreenAfterScreenRotation(nr);
 
-         nr = GRID_ACTIVE_NR();
-
-         overlay.grid_xsize = setup.touch.grid_xsize[nr];
-         overlay.grid_ysize = setup.touch.grid_ysize[nr];
-
-         for (x = 0; x < MAX_GRID_XSIZE; x++)
-           for (y = 0; y < MAX_GRID_YSIZE; y++)
-             overlay.grid_button[x][y] = setup.touch.grid_button[nr][x][y];
+         SetOverlayGridSizeAndButtons();
        }
       }
     }
        }
       }
     }
index 67995e3d82c2da295693988cc924af443b93dfa4..e750b78d365a39ebe8dbd4c2e45d9e51bb7d083e 100644 (file)
@@ -352,30 +352,35 @@ void InitTileCursorInfo(void)
 
 void InitOverlayInfo(void)
 {
 
 void InitOverlayInfo(void)
 {
-  int nr = GRID_ACTIVE_NR();
-  int x, y;
-
   overlay.enabled = FALSE;
   overlay.active = FALSE;
 
   overlay.show_grid = FALSE;
 
   overlay.enabled = FALSE;
   overlay.active = FALSE;
 
   overlay.show_grid = FALSE;
 
-  overlay.grid_xsize = setup.touch.grid_xsize[nr];
-  overlay.grid_ysize = setup.touch.grid_ysize[nr];
-
-  for (x = 0; x < MAX_GRID_XSIZE; x++)
-    for (y = 0; y < MAX_GRID_YSIZE; y++)
-      overlay.grid_button[x][y] = setup.touch.grid_button[nr][x][y];
-
   overlay.grid_button_highlight = CHAR_GRID_BUTTON_NONE;
   overlay.grid_button_action = JOY_NO_ACTION;
 
   overlay.grid_button_highlight = CHAR_GRID_BUTTON_NONE;
   overlay.grid_button_action = JOY_NO_ACTION;
 
+  SetOverlayGridSizeAndButtons();
+
 #if defined(USE_TOUCH_INPUT_OVERLAY)
   if (strEqual(setup.touch.control_type, TOUCH_CONTROL_VIRTUAL_BUTTONS))
     overlay.enabled = TRUE;
 #endif
 }
 
 #if defined(USE_TOUCH_INPUT_OVERLAY)
   if (strEqual(setup.touch.control_type, TOUCH_CONTROL_VIRTUAL_BUTTONS))
     overlay.enabled = TRUE;
 #endif
 }
 
+void SetOverlayGridSizeAndButtons(void)
+{
+  int nr = GRID_ACTIVE_NR();
+  int x, y;
+
+  overlay.grid_xsize = setup.touch.grid_xsize[nr];
+  overlay.grid_ysize = setup.touch.grid_ysize[nr];
+
+  for (x = 0; x < MAX_GRID_XSIZE; x++)
+    for (y = 0; y < MAX_GRID_YSIZE; y++)
+      overlay.grid_button[x][y] = setup.touch.grid_button[nr][x][y];
+}
+
 void SetTileCursorEnabled(boolean enabled)
 {
   tile_cursor.enabled = enabled;
 void SetTileCursorEnabled(boolean enabled)
 {
   tile_cursor.enabled = enabled;
index 44f97e073fa671c08a677b0b92648b2cdc9dccde..0d74426f92be24ccb9a3cd3e36832fe72903da6a 100644 (file)
@@ -1813,6 +1813,7 @@ void InitGfxCustomArtworkInfo(void);
 void InitGfxOtherSettings(void);
 void InitTileCursorInfo(void);
 void InitOverlayInfo(void);
 void InitGfxOtherSettings(void);
 void InitTileCursorInfo(void);
 void InitOverlayInfo(void);
+void SetOverlayGridSizeAndButtons(void);
 void SetTileCursorEnabled(boolean);
 void SetTileCursorActive(boolean);
 void SetTileCursorTargetXY(int, int);
 void SetTileCursorEnabled(boolean);
 void SetTileCursorActive(boolean);
 void SetTileCursorTargetXY(int, int);