From 3fb66890eeb3689e645fa6d520aecc0c0908031f Mon Sep 17 00:00:00 2001 From: planetmaker Date: Mon, 1 Aug 2011 18:41:21 +0000 Subject: (svn r22708) -Feature [FS#4701]: Display option to hide competitors' signs and station names (Zuu) --- src/signs_gui.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/signs_gui.cpp') diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index d64be87e1..e0ab72e01 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -26,6 +26,7 @@ #include "string_func.h" #include "core/geometry_func.hpp" #include "hotkeys.h" +#include "transparency.h" #include "table/strings.h" #include "table/sprites.h" @@ -116,11 +117,22 @@ struct SignList { return (filter_info.case_sensitive ? strstr(buf1, filter_info.string) : strcasestr(buf1, filter_info.string)) != NULL; } + /** Filter sign list by owner */ + static bool CDECL OwnerVisibilityFilter(const Sign * const *a, FilterInfo filter_info) + { + assert(!HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS)); + /* Hide sign if non-own signs are hidden in the viewport */ + return (*a)->owner == _local_company; + } + /** Filter out signs from the sign list that does not match the name filter */ void FilterSignList() { FilterInfo filter_info = {this->filter_string, this->match_case}; this->signs.Filter(&SignNameFilter, filter_info); + if (!HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS)) { + this->signs.Filter(&OwnerVisibilityFilter, filter_info); + } } }; @@ -199,7 +211,7 @@ struct SignListWindow : QueryStringBaseWindow, SignList { /* There is no new string -> clear this->filter_string */ this->filter_string[0] = '\0'; - this->signs.SetFilterState(false); + this->signs.SetFilterState(!HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS)); // keep sign list filtering active if competitor signs should be hidden this->DisableWidget(SLW_FILTER_CLEAR_BTN); } @@ -374,10 +386,15 @@ struct SignListWindow : QueryStringBaseWindow, SignList { */ virtual void OnInvalidateData(int data = 0, bool gui_scope = true) { + if (data == -1) { + /* The DO_SHOW_COMPETITOR_SIGNS display option has changed */ + this->signs.SetFilterState(!StrEmpty(this->filter_string) || !HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS)); + } + /* When there is a filter string, we always need to rebuild the list even if * the amount of signs in total is unchanged, as the subset of signs that is * accepted by the filter might has changed. */ - if (data == 0 || !StrEmpty(this->filter_string)) { // New or deleted sign, or there is a filter string + if (data == 0 || data == -1 || !StrEmpty(this->filter_string)) { // New or deleted sign, changed visibility setting or there is a filter string /* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */ this->signs.ForceRebuild(); } else { // Change of sign contents while there is no filter string -- cgit v1.2.3-54-g00ecf