summaryrefslogtreecommitdiff
path: root/src/signs_gui.cpp
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-12-19 20:59:29 +0000
committertruebrain <truebrain@openttd.org>2011-12-19 20:59:29 +0000
commite7cd301d3c9990b4ef9f0748789bb5e0318c0d24 (patch)
tree6be6c3a41b29a52a74a289293a012e7167f48884 /src/signs_gui.cpp
parentafcf07ac8a0d5adede1b412600042a9f3b482648 (diff)
downloadopenttd-e7cd301d3c9990b4ef9f0748789bb5e0318c0d24.tar.xz
(svn r23621) -Add: allow manipulation of signs via GameScripts
Diffstat (limited to 'src/signs_gui.cpp')
-rw-r--r--src/signs_gui.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index 589af1cae..9c54ff2de 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -75,6 +75,7 @@ struct SignList {
const Sign *si;
FOR_ALL_SIGNS(si) *this->signs.Append() = si;
+ this->signs.SetFilterState(true);
this->FilterSignList();
this->signs.Compact();
this->signs.RebuildDone();
@@ -119,6 +120,13 @@ struct SignList {
return (filter_info.case_sensitive ? strstr(buf1, filter_info.string) : strcasestr(buf1, filter_info.string)) != NULL;
}
+ /** Filter sign list excluding OWNER_DEITY */
+ static bool CDECL OwnerDeityFilter(const Sign * const *a, FilterInfo filter_info)
+ {
+ /* You should never be able to edit signs of owner DEITY */
+ return (*a)->owner != OWNER_DEITY;
+ }
+
/** Filter sign list by owner */
static bool CDECL OwnerVisibilityFilter(const Sign * const *a, FilterInfo filter_info)
{
@@ -132,6 +140,7 @@ struct SignList {
{
FilterInfo filter_info = {this->filter_string, this->match_case};
this->signs.Filter(&SignNameFilter, filter_info);
+ this->signs.Filter(&OwnerDeityFilter, filter_info);
if (!HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS)) {
this->signs.Filter(&OwnerVisibilityFilter, filter_info);
}
@@ -196,14 +205,11 @@ struct SignListWindow : QueryStringBaseWindow, SignList {
/* Copy new filter string */
strecpy(this->filter_string, new_filter_string, lastof(this->filter_string));
- this->signs.SetFilterState(true);
-
this->EnableWidget(WID_SIL_FILTER_CLEAR_BTN);
} else {
/* There is no new string -> clear this->filter_string */
this->filter_string[0] = '\0';
- this->signs.SetFilterState(!HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS)); // keep sign list filtering active if competitor signs should be hidden
this->DisableWidget(WID_SIL_FILTER_CLEAR_BTN);
}
@@ -378,11 +384,6 @@ 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. */