added support for multiple pre-defined ".class" parameters
authorHolger Schemel <info@artsoft.org>
Wed, 5 Feb 2025 19:35:36 +0000 (20:35 +0100)
committerHolger Schemel <info@artsoft.org>
Wed, 5 Feb 2025 19:35:36 +0000 (20:35 +0100)
src/files.c
src/files.h
src/game.c
src/libgame/system.h

index 076985589e02fbaa2a7605d9c02f2c5774a99453..fe306f03820aa7f8be92f6e158795a71cc973a13 100644 (file)
@@ -13380,8 +13380,25 @@ static int get_anim_action_parameter_value(char *token)
 
 static int get_class_parameter_value(char *value)
 {
-  int result = (strEqual(value, ARG_UNDEFINED) ? ARG_UNDEFINED_VALUE :
-                get_hash_from_string(value));
+  int result = CLASS_DEFAULT;
+
+  if (strEqual(value, ARG_UNDEFINED))
+    return ARG_UNDEFINED_VALUE;
+
+  if (string_has_parameter(value, "mm_engine_only"))
+    result |= CLASS_MM_ENGINE_ONLY;
+
+  if (string_has_parameter(value, "extra_panel_items"))
+    result |= CLASS_EXTRA_PANEL_ITEMS;
+
+  if (string_has_parameter(value, "bd_pre_hatching"))
+    result |= CLASS_BD_PRE_HATCHING;
+
+  if (string_has_parameter(value, "bd_post_hatching"))
+    result |= CLASS_BD_POST_HATCHING;
+
+  if (result == CLASS_DEFAULT)
+    result = get_hash_from_string(value);
 
   return result;
 }
@@ -13567,6 +13584,15 @@ boolean isClass(int class, char *value)
   return (class == get_hash_from_string(value));
 }
 
+boolean hasClass(int class, int value)
+{
+  if (class < CLASS_NONE ||
+      class > CLASS_MAX)
+    return FALSE;
+
+  return ((class & value) != 0);
+}
+
 void InitMenuDesignSettings_FromHash(SetupFileHash *setup_file_hash,
                                     boolean ignore_defaults)
 {
index 415d00dbcd3ef96b28f4e8725f399e6ff7b5ee1d..9ecea42087a04330f27518657c46453cf454e014 100644 (file)
@@ -127,5 +127,6 @@ int GetGlobalAnimEventValueCount(int);
 int get_parameter_value(char *, char *, int);
 
 boolean isClass(int, char *);
+boolean hasClass(int, int);
 
 #endif // FILES_H
index cb25d06a3f192c7e6d51cf2ff3b9bffaf0ecb973..b240c1f9e9dd84895395f05a327229e1171a8711 100644 (file)
@@ -3051,15 +3051,15 @@ static void DisplayGameControlValues(void)
     if (PANEL_DEACTIVATED(pos))
       continue;
 
-    if (isClass(pos->class, "extra_panel_items") &&
+    if (hasClass(pos->class, CLASS_EXTRA_PANEL_ITEMS) &&
        !setup.prefer_extra_panel_items)
       continue;
 
-    if (isClass(pos->class, "bd_pre_hatching") &&
+    if (hasClass(pos->class, CLASS_BD_PRE_HATCHING) &&
         (level.game_engine_type != GAME_ENGINE_TYPE_BD || game_bd.game->cave->hatched))
       continue;
 
-    if (isClass(pos->class, "bd_post_hatching") &&
+    if (hasClass(pos->class, CLASS_BD_POST_HATCHING) &&
         (level.game_engine_type == GAME_ENGINE_TYPE_BD && !game_bd.game->cave->hatched))
       continue;
 
@@ -3151,7 +3151,7 @@ static void DisplayGameControlValues(void)
       int width, height;
       int dst_x = PANEL_XPOS(pos);
       int dst_y = PANEL_YPOS(pos);
-      boolean skip = (isClass(pos->class, "mm_engine_only") &&
+      boolean skip = (hasClass(pos->class, CLASS_MM_ENGINE_ONLY) &&
                      level.game_engine_type != GAME_ENGINE_TYPE_MM);
 
       if (graphic != IMG_UNDEFINED && !skip)
index 6ca2afbed498cdf6b0c69d9482b23858871d1853..c9ae6d094bf66680d98d720ae208ff6e7a222269 100644 (file)
 // values for special global animation delay actions
 #define ANIM_DELAY_ACTION_NONE         -1
 
+// values for special drawing classes
+#define CLASS_NONE                     0
+
+// values used for game panel graphics
+#define CLASS_MM_ENGINE_ONLY           (1 << 0)
+#define CLASS_EXTRA_PANEL_ITEMS                (1 << 1)
+#define CLASS_BD_PRE_HATCHING          (1 << 2)
+#define CLASS_BD_POST_HATCHING         (1 << 3)
+
+#define CLASS_MAX                      ((1 << 4) - 1)
+
+#define CLASS_DEFAULT                  CLASS_NONE
+
 // values for special drawing styles and event handling
 #define STYLE_NONE                     0