From: Holger Schemel Date: Thu, 7 Feb 2019 18:34:46 +0000 (+0100) Subject: changed drawing preview/network players if only level preview redefined X-Git-Tag: 4.1.2.0~26 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=a8cbd6caea4467607417ffe93ca70122b6862ff2;p=rocksndiamonds.git changed drawing preview/network players if only level preview redefined 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. --- diff --git a/src/files.c b/src/files.c index cd411a09..3881fbf2 100644 --- a/src/files.c +++ b/src/files.c @@ -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++) { diff --git a/src/libgame/system.h b/src/libgame/system.h index c7df9785..f498816e 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -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 diff --git a/src/main.h b/src/main.h index 9e1e04dd..ba83a4d6 100644 --- a/src/main.h +++ b/src/main.h @@ -2851,6 +2851,8 @@ struct PreviewInfo int step_offset; int step_delay; int anim_mode; + + boolean redefined; // redefined by custom artwork }; struct EditorTabsInfo diff --git a/src/tools.c b/src/tools.c index 2505f402..55f00ac3 100644 --- a/src/tools.c +++ b/src/tools.c @@ -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;