added key shortcut to dump identifiers for all gadgets on current screen
[rocksndiamonds.git] / src / libgame / gadgets.c
index a797c75475a1a9b41bf9f6cb2e25a79a67f5f406..c793ce13c599ecc2adb7050d98fcf9f7165d9796 100644 (file)
@@ -13,6 +13,7 @@
 #include <string.h>
 
 #include "gadgets.h"
+#include "image.h"
 #include "text.h"
 #include "misc.h"
 
@@ -782,6 +783,10 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap)
   {
     switch(tag)
     {
+      case GDI_IMAGE_ID:
+       gi->image_id = va_arg(ap, int);
+       break;
+
       case GDI_CUSTOM_ID:
        gi->custom_id = va_arg(ap, int);
        break;
@@ -1281,6 +1286,7 @@ struct GadgetInfo *CreateGadget(int first_tag, ...)
 
   /* always start with reliable default values */
   new_gadget->id = getNewGadgetID();
+  new_gadget->image_id = -1;
   new_gadget->callback_info = default_callback_info;
   new_gadget->callback_action = default_callback_action;
   new_gadget->active = TRUE;
@@ -2267,3 +2273,16 @@ boolean HandleGadgetsKeyInput(Key key)
 
   return TRUE;
 }
+
+void DumpGadgetIdentifiers()
+{
+  struct GadgetInfo *gi;
+
+  printf("Gadgets on current screen (any prefix 'gfx.' can be omitted):\n");
+
+  for (gi = gadget_list_first_entry; gi != NULL; gi = gi->next)
+    if (gi->mapped && gi->image_id != -1)
+      printf("- '%s'\n", getTokenFromImageID(gi->image_id));
+
+  printf("Done.\n");
+}