added updating virtual buttons setup screen depending on screen orientation
authorHolger Schemel <info@artsoft.org>
Sat, 12 May 2018 00:21:18 +0000 (02:21 +0200)
committerHolger Schemel <info@artsoft.org>
Tue, 5 Jun 2018 18:58:42 +0000 (20:58 +0200)
src/events.c
src/screens.c
src/screens.h

index 2120931852677da9e9a8e70cd4692aa341a77b18..9aad2bca87dfa837891244e5099d004c97a7d629 100644 (file)
@@ -649,12 +649,7 @@ void HandleWindowEvent(WindowEvent *event)
          int x, y;
 
          if (game_status == GAME_MODE_SETUP)
-         {
-           // save active virtual buttons (in case of just configuring them)
-           for (x = 0; x < MAX_GRID_XSIZE; x++)
-             for (y = 0; y < MAX_GRID_YSIZE; y++)
-               setup.touch.grid_button[nr][x][y] = overlay.grid_button[x][y];
-         }
+           RedrawSetupScreenAfterScreenRotation(nr);
 
          nr = GRID_ACTIVE_NR();
 
index 88c92a13e7593b53e85a1ff15f0dab61b2708f8f..6f6e7a13dec6b5c2c28e709dbdd3e75e23c19d42 100644 (file)
@@ -82,8 +82,9 @@
 #define SETUP_MODE_CHOOSE_GRID_YSIZE_0 33
 #define SETUP_MODE_CHOOSE_GRID_XSIZE_1 34
 #define SETUP_MODE_CHOOSE_GRID_YSIZE_1 35
+#define SETUP_MODE_CONFIG_VIRT_BUTTONS 36
 
-#define MAX_SETUP_MODES                        36
+#define MAX_SETUP_MODES                        37
 
 #define MAX_MENU_MODES                 MAX(MAX_INFO_MODES, MAX_SETUP_MODES)
 
@@ -5389,8 +5390,12 @@ static void execSetupChooseGridYSize_1()
 
 static void execSetupConfigureVirtualButtons()
 {
+  setup_mode = SETUP_MODE_CONFIG_VIRT_BUTTONS;
+
   ConfigureVirtualButtons();
 
+  setup_mode = SETUP_MODE_TOUCH;
+
   DrawSetupScreen();
 }
 
@@ -6012,7 +6017,7 @@ static struct TokenInfo setup_info_touch[] =
   { 0,                 NULL,                   NULL                    }
 };
 
-static struct TokenInfo setup_info_touch_virtual_buttons[] =
+static struct TokenInfo setup_info_touch_virtual_buttons_0[] =
 {
   { TYPE_ENTER_LIST,   execSetupChooseTouchControls, "Touch Control Type:" },
   { TYPE_STRING,       &touch_controls_text,   ""                      },
@@ -6031,6 +6036,31 @@ static struct TokenInfo setup_info_touch_virtual_buttons[] =
   { 0,                 NULL,                   NULL                    }
 };
 
+static struct TokenInfo setup_info_touch_virtual_buttons_1[] =
+{
+  { TYPE_ENTER_LIST,   execSetupChooseTouchControls, "Touch Control Type:" },
+  { TYPE_STRING,       &touch_controls_text,   ""                      },
+  { TYPE_EMPTY,                NULL,                   ""                      },
+  { TYPE_ENTER_LIST,   execSetupChooseGridXSize_1, "Horizontal Buttons (Portrait):"    },
+  { TYPE_STRING,       &grid_size_text[1][0],  ""                      },
+  { TYPE_ENTER_LIST,   execSetupChooseGridYSize_1, "Vertical Buttons (Portrait):"      },
+  { TYPE_STRING,       &grid_size_text[1][1],  ""                      },
+  { TYPE_ENTER_LIST,   execSetupChooseTransparency, "Transparency:"    },
+  { TYPE_STRING,       &transparency_text,     ""                      },
+  { TYPE_EMPTY,                NULL,                   ""                      },
+  { TYPE_ENTER_LIST,   execSetupConfigureVirtualButtons, "Configure Virtual Buttons" },
+  { TYPE_EMPTY,                NULL,                   ""                      },
+  { TYPE_LEAVE_MENU,   execSetupMain,          "Back"                  },
+
+  { 0,                 NULL,                   NULL                    }
+};
+
+static struct TokenInfo *setup_info_touch_virtual_buttons[] =
+{
+  setup_info_touch_virtual_buttons_0,
+  setup_info_touch_virtual_buttons_1
+};
+
 static struct TokenInfo setup_info_touch_wipe_gestures[] =
 {
   { TYPE_ENTER_LIST,   execSetupChooseTouchControls, "Touch Control Type:" },
@@ -6465,7 +6495,7 @@ static void DrawSetupScreen_Generic()
     title_string = STR_SETUP_TOUCH;
 
     if (strEqual(setup.touch.control_type, TOUCH_CONTROL_VIRTUAL_BUTTONS))
-      setup_info = setup_info_touch_virtual_buttons;
+      setup_info = setup_info_touch_virtual_buttons[GRID_ACTIVE_NR()];
     else if (strEqual(setup.touch.control_type, TOUCH_CONTROL_WIPE_GESTURES))
       setup_info = setup_info_touch_wipe_gestures;
   }
@@ -7763,6 +7793,24 @@ void RedrawSetupScreenAfterFullscreenToggle()
   }
 }
 
+void RedrawSetupScreenAfterScreenRotation(int nr)
+{
+  int x, y;
+
+  if (setup_mode == SETUP_MODE_TOUCH)
+  {
+    // update virtual button settings (depending on screen orientation)
+    DrawSetupScreen();
+  }
+  else if (setup_mode == SETUP_MODE_CONFIG_VIRT_BUTTONS)
+  {
+    // save already configured virtual buttons
+    for (x = 0; x < MAX_GRID_XSIZE; x++)
+      for (y = 0; y < MAX_GRID_YSIZE; y++)
+       setup.touch.grid_button[nr][x][y] = overlay.grid_button[x][y];
+  }
+}
+
 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
 {
   if (setup_mode == SETUP_MODE_INPUT)
index 7af2a0083bc55a3e1fcc69f8db6590902962afe8..418c41f4f07afe4f1ad1d1878339d3d997cff224 100644 (file)
@@ -25,6 +25,7 @@ void DrawMainMenu(void);
 void DrawHallOfFame(int);
 
 void RedrawSetupScreenAfterFullscreenToggle();
+void RedrawSetupScreenAfterScreenRotation(int);
 
 void HandleTitleScreen(int, int, int, int, int);
 void HandleMainMenu(int, int, int, int, int);