added count of MM wall tiles to element properties page in level editor
authorHolger Schemel <info@artsoft.org>
Thu, 23 Mar 2023 11:32:04 +0000 (12:32 +0100)
committerHolger Schemel <info@artsoft.org>
Thu, 23 Mar 2023 11:32:04 +0000 (12:32 +0100)
src/editor.c

index 718d42fa5f0ac6e945cbcc5bcfa1f42fccd37863..2c46dc655a898b5812915c332ce5bc38d07a93f6 100644 (file)
@@ -3973,6 +3973,7 @@ static boolean getDrawModeHiRes(void);
 static int getTabulatorBarWidth(void);
 static int getTabulatorBarHeight(void);
 static Pixel getTabulatorBarColor(void);
+static int numHiresTiles(int);
 
 static int num_editor_gadgets = 0;     // dynamically determined
 
@@ -9756,6 +9757,7 @@ static void DrawPropertiesInfo(void)
   float percentage;
   int num_elements_in_level = 0;
   int num_similar_in_level = 0;
+  int num_hires_tiles_in_level = 0;
   int num_standard_properties = 0;
   int font1_nr = FONT_TEXT_1;
   int font2_nr = FONT_TEXT_2;
@@ -9785,15 +9787,29 @@ static void DrawPropertiesInfo(void)
   // ----- print number of elements / percentage of this element in level
 
   for (y = 0; y < lev_fieldy; y++)
+  {
     for (x = 0; x < lev_fieldx; x++)
+    {
       if (Tile[x][y] == properties_element)
+      {
        num_elements_in_level++;
+      }
+      else if (IS_MM_WALL(Tile[x][y]) &&
+              map_mm_wall_element(Tile[x][y]) == properties_element)
+      {
+       num_hires_tiles_in_level += numHiresTiles(Tile[x][y]);
+      }
+    }
+  }
 
   percentage = num_elements_in_level * 100.0 / (lev_fieldx * lev_fieldy);
 
   DrawTextS(xpos, ypos, font1_nr, num_elements_text);
 
-  if (num_elements_in_level > 0)
+  if (num_hires_tiles_in_level > 0)
+    DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
+             "%d wall tiles", num_hires_tiles_in_level);
+  else if (num_elements_in_level > 0)
     DrawTextF(xpos + num_elements_text_len, ypos + font2_yoffset, font2_nr,
              "%d (%.2f %%)", num_elements_in_level, percentage);
   else
@@ -9803,10 +9819,16 @@ static void DrawPropertiesInfo(void)
   // ----- print number of similar elements / percentage of them in level
 
   for (y = 0; y < lev_fieldy; y++)
+  {
     for (x = 0; x < lev_fieldx; x++)
+    {
       if (strEqual(element_info[Tile[x][y]].class_name,
                   element_info[properties_element].class_name))
+      {
        num_similar_in_level++;
+      }
+    }
+  }
 
   if (num_similar_in_level != num_elements_in_level)
   {
@@ -11967,6 +11989,23 @@ static boolean isHiresDrawElement(int element)
   return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY);
 }
 
+static int numHiresTiles(int element)
+{
+  if (!IS_MM_WALL(element))
+    return 1;
+
+  int bits = MM_WALL_BITS(element);
+  int num_bits = 0;
+
+  while (bits)
+  {
+    bits &= bits - 1;
+    num_bits++;
+  }
+
+  return num_bits;
+}
+
 static void SetDrawModeHiRes(int element)
 {
   draw_mode_hires =