changed drawing preview/network players if only level preview redefined
authorHolger Schemel <info@artsoft.org>
Thu, 7 Feb 2019 18:34:46 +0000 (19:34 +0100)
committerHolger Schemel <info@artsoft.org>
Sun, 10 Feb 2019 14:44:22 +0000 (15:44 +0100)
Problem: Drawing preview players (for team mode levels) and network
players (when connected to network server) in the main menu was added
at a time where already quite some custom artwork was created, which
did not know of these artwork definitions, so redefining the level
preview area might conflict with those player graphics added later
(and therefore maybe not redefined by these custom artwork sets).

Solution: If the position of the level preview is redefined, but the
positions of the preview or network player graphics are not redefined,
just skip drawing these player graphics.

src/files.c
src/libgame/system.h
src/main.h
src/tools.c

index cd411a09dbc49547e602ac7cbaab135f5ebd6644..3881fbf2847cf79f8e5be33fb51b273ff3467043 100644 (file)
@@ -10264,6 +10264,25 @@ static void LoadMenuDesignSettingsFromFilename(char *filename)
     }
   }
 
+  // special case: check if network and preview player positions are redefined,
+  // to compare this later against the main menu level preview being redefined
+  struct TokenIntPtrInfo menu_config_players[] =
+  {
+    { "main.network_players.x",        &menu.main.network_players.redefined    },
+    { "main.network_players.y",        &menu.main.network_players.redefined    },
+    { "main.preview_players.x",        &menu.main.preview_players.redefined    },
+    { "main.preview_players.y",        &menu.main.preview_players.redefined    },
+    { "preview.x",             &preview.redefined                      },
+    { "preview.y",             &preview.redefined                      }
+  };
+
+  for (i = 0; i < ARRAY_SIZE(menu_config_players); i++)
+    *menu_config_players[i].value = FALSE;
+
+  for (i = 0; i < ARRAY_SIZE(menu_config_players); i++)
+    if (getHashEntry(setup_file_hash, menu_config_players[i].token) != NULL)
+      *menu_config_players[i].value = TRUE;
+
   // read (and overwrite with) values that may be specified in config file
   for (i = 0; image_config_vars[i].token != NULL; i++)
   {
index c7df978523968fd7427ad9f16aa6060cf687272c..f498816e9c94351dfd8e2cbeafac022680f1df43 100644 (file)
@@ -1643,6 +1643,8 @@ struct TextPosInfo
   int tile_size;               // special case for list of network players
   int border_size;             // special case for list of preview players
   int vertical;                        // special case for list of preview players
+
+  boolean redefined;           // redefined by custom artwork
 };
 
 struct MouseActionInfo
index 9e1e04dd96bc7bb9b26e19d59db6dbe85f0e1151..ba83a4d6c730ac07775e2e63f55da0fde0152519 100644 (file)
@@ -2851,6 +2851,8 @@ struct PreviewInfo
   int step_offset;
   int step_delay;
   int anim_mode;
+
+  boolean redefined;           // redefined by custom artwork
 };
 
 struct EditorTabsInfo
index 2505f402bc83c843e2b265c2ea5eaeb35064db04..55f00ac327732c1f816e588c53f6179ccb6105b9 100644 (file)
@@ -3523,6 +3523,10 @@ void DrawPreviewPlayers(void)
   if (game_status != GAME_MODE_MAIN)
     return;
 
+  // do not draw preview players if level preview redefined, but players aren't
+  if (preview.redefined && !menu.main.preview_players.redefined)
+    return;
+
   boolean player_found[MAX_PLAYERS];
   int num_players = 0;
   int i, x, y;
@@ -3628,6 +3632,10 @@ static void DrawNetworkPlayersExt(boolean force)
   if (!network.connected && !force)
     return;
 
+  // do not draw network players if level preview redefined, but players aren't
+  if (preview.redefined && !menu.main.network_players.redefined)
+    return;
+
   int num_players = 0;
   int i;