fixed ignoring clicks on global animations after executing event actions
[rocksndiamonds.git] / src / screens.c
index 88c92a13e7593b53e85a1ff15f0dab61b2708f8f..89b9d3d48c515478dc2894924fd96ef9de463004 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)
 
@@ -748,19 +749,19 @@ static struct MainControlInfo main_controls[] =
 #endif
   {
     MAIN_CONTROL_FIRST_LEVEL,
-    NULL,                              -1,
+    &menu.main.button.first_level,     IMG_MENU_BUTTON_FIRST_LEVEL,
     &menu.main.text.first_level,       &main_text_first_level,
     NULL,                              NULL,
   },
   {
     MAIN_CONTROL_LAST_LEVEL,
-    NULL,                              -1,
+    &menu.main.button.last_level,      IMG_MENU_BUTTON_LAST_LEVEL,
     &menu.main.text.last_level,                &main_text_last_level,
     NULL,                              NULL,
   },
   {
     MAIN_CONTROL_LEVEL_NUMBER,
-    NULL,                              -1,
+    &menu.main.button.level_number,    IMG_MENU_BUTTON_LEVEL_NUMBER,
     &menu.main.text.level_number,      &main_text_level_number,
     NULL,                              NULL,
   },
@@ -1147,8 +1148,8 @@ static void InitializeMainControls()
 
     if (pos_text != NULL)              /* (x/y may be -1/-1 here) */
     {
-      /* calculate size for non-clickable text -- needed for text alignment */
-      boolean calculate_text_size = (pos_button == NULL && text != NULL);
+      /* calculate text size -- needed for text alignment */
+      boolean calculate_text_size = (text != NULL);
 
       if (pos_text->width == -1 || calculate_text_size)
        pos_text->width = text_width;
@@ -1650,6 +1651,10 @@ void DrawMainMenu()
   FreeScreenGadgets();
   CreateScreenGadgets();
 
+  /* may be required if audio buttons shown on tape and changed in setup menu */
+  FreeGameButtons();
+  CreateGameButtons();
+
   /* map gadgets for main menu screen */
   MapTapeButtons();
   MapScreenMenuGadgets(SCREEN_MASK_MAIN);
@@ -5389,8 +5394,12 @@ static void execSetupChooseGridYSize_1()
 
 static void execSetupConfigureVirtualButtons()
 {
+  setup_mode = SETUP_MODE_CONFIG_VIRT_BUTTONS;
+
   ConfigureVirtualButtons();
 
+  setup_mode = SETUP_MODE_TOUCH;
+
   DrawSetupScreen();
 }
 
@@ -6012,7 +6021,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,   ""                      },
@@ -6021,8 +6030,10 @@ static struct TokenInfo setup_info_touch_virtual_buttons[] =
   { TYPE_STRING,       &grid_size_text[0][0],  ""                      },
   { TYPE_ENTER_LIST,   execSetupChooseGridYSize_0, "Vertical Buttons (Landscape):"     },
   { TYPE_STRING,       &grid_size_text[0][1],  ""                      },
-  { TYPE_ENTER_LIST,   execSetupChooseTransparency, "Transparency:"    },
+  { TYPE_ENTER_LIST,   execSetupChooseTransparency, "Button Transparency:" },
   { TYPE_STRING,       &transparency_text,     ""                      },
+  { TYPE_SWITCH,       &setup.touch.draw_outlined, "Draw Buttons Outlined:" },
+  { TYPE_SWITCH,       &setup.touch.draw_pressed, "Highlight Pressed Buttons:" },
   { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_ENTER_LIST,   execSetupConfigureVirtualButtons, "Configure Virtual Buttons" },
   { TYPE_EMPTY,                NULL,                   ""                      },
@@ -6031,6 +6042,33 @@ 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, "Button Transparency:" },
+  { TYPE_STRING,       &transparency_text,     ""                      },
+  { TYPE_SWITCH,       &setup.touch.draw_outlined, "Draw Buttons Outlined:" },
+  { TYPE_SWITCH,       &setup.touch.draw_pressed, "Highlight Pressed Buttons:" },
+  { 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 +6503,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;
   }
@@ -7524,13 +7562,19 @@ boolean ConfigureVirtualButtonsMain()
 
            /* press 'Enter' to keep the existing key binding */
            if (key == KSYM_Return ||
+#if defined(TARGET_SDL2)
                key == KSYM_Menu ||
+#endif
                key == KSYM_space)
            {
              step_nr++;
            }
-           else if (key == KSYM_BackSpace ||
-                    key == KSYM_Back)
+           else if (key == KSYM_BackSpace
+#if defined(TARGET_SDL2)
+                    ||
+                    key == KSYM_Back
+#endif
+                    )
            {
              if (step_nr == 0)
              {
@@ -7763,6 +7807,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)
@@ -7970,6 +8032,7 @@ static void CreateScreenMenubuttons()
 
     gi = CreateGadget(GDI_CUSTOM_ID, id,
                      GDI_CUSTOM_TYPE_ID, i,
+                     GDI_IMAGE_ID, gfx_unpressed,
                      GDI_INFO_TEXT, menubutton_info[i].infotext,
                      GDI_X, x,
                      GDI_Y, y,
@@ -8037,6 +8100,7 @@ static void CreateScreenScrollbuttons()
 
     gi = CreateGadget(GDI_CUSTOM_ID, id,
                      GDI_CUSTOM_TYPE_ID, i,
+                     GDI_IMAGE_ID, gfx_unpressed,
                      GDI_INFO_TEXT, scrollbutton_info[i].infotext,
                      GDI_X, x,
                      GDI_Y, y,
@@ -8109,6 +8173,7 @@ static void CreateScreenScrollbars()
 
     gi = CreateGadget(GDI_CUSTOM_ID, id,
                      GDI_CUSTOM_TYPE_ID, i,
+                     GDI_IMAGE_ID, gfx_unpressed,
                      GDI_INFO_TEXT, scrollbar_info[i].infotext,
                      GDI_X, x,
                      GDI_Y, y,