added "multiple_actions" option for clickable global animations
[rocksndiamonds.git] / src / screens.c
index 6f6e7a13dec6b5c2c28e709dbdd3e75e23c19d42..067f630aa2be16bc287964e6039def923020b006 100644 (file)
@@ -749,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,
   },
@@ -1148,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;
@@ -1651,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);
@@ -6026,8 +6030,10 @@ static struct TokenInfo setup_info_touch_virtual_buttons_0[] =
   { 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,                   ""                      },
@@ -6045,8 +6051,10 @@ static struct TokenInfo setup_info_touch_virtual_buttons_1[] =
   { 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_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,                   ""                      },
@@ -7554,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)
              {
@@ -8018,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,
@@ -8085,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,
@@ -8157,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,
@@ -8234,7 +8251,9 @@ static void HandleScreenGadgets(struct GadgetInfo *gi)
 {
   int id = gi->custom_id;
   int button = gi->event.button;
-  int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
+  int step = (button == MB_LEFTBUTTON   ? 1 :
+             button == MB_MIDDLEBUTTON ? 5 :
+             button == MB_RIGHTBUTTON  ? 10 : 1);
 
   switch (id)
   {
@@ -8291,3 +8310,50 @@ static void HandleScreenGadgets(struct GadgetInfo *gi)
       break;
   }
 }
+
+void DumpScreenIdentifiers()
+{
+  int i;
+
+  Print("Active screen elements on current screen:\n");
+
+  for (i = 0; main_controls[i].nr != -1; i++)
+  {
+    struct MainControlInfo *mci = &main_controls[i];
+
+    if (mci->button_graphic != -1)
+    {
+      char *token = getTokenFromImageID(mci->button_graphic);
+
+      Print("- '%s'\n", token);
+    }
+  }
+
+  Print("Done.\n");
+}
+
+boolean DoScreenAction(int image_id)
+{
+  int i;
+
+  if (game_status != GAME_MODE_MAIN)
+    return FALSE;
+
+  for (i = 0; main_controls[i].nr != -1; i++)
+  {
+    struct MainControlInfo *mci = &main_controls[i];
+    struct MenuPosInfo *pos = mci->pos_button;
+
+    if (mci->button_graphic == image_id)
+    {
+      int x = mSX + pos->x;
+      int y = mSY + pos->y;
+
+      HandleMainMenu(x, y, 0, 0, MB_MENU_CHOICE);
+
+      return TRUE;
+    }
+  }
+
+  return FALSE;
+}