summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-09-18 20:27:56 +0200
committerGitHub <noreply@github.com>2021-09-18 20:27:56 +0200
commitcd03bac3dd5f18680f250112956ccba1604b51fe (patch)
treeac80c5f69c22b4df9bafd8ad99e93cfcf8852513
parent7acdaaaf2f6c5f4a605031d25a891e16ff603965 (diff)
downloadopenttd-cd03bac3dd5f18680f250112956ccba1604b51fe.tar.xz
Fix: add back 'Spectate' option to company toolbar menu (#9556)
This was removed in ce7406f88b, but people used this to quickly mark themselves as away. Co-authored-by: dP <dp@dpointer.org>
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/toolbar_gui.cpp17
2 files changed, 16 insertions, 2 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index f9f10e94f..0dc42071e 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -2327,6 +2327,7 @@ STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION :{WHITE}Company
# Network company list added strings
STR_NETWORK_COMPANY_LIST_CLIENT_LIST :Online players
+STR_NETWORK_COMPANY_LIST_SPECTATE :Spectate
# Network client list
STR_NETWORK_CLIENT_LIST_CAPTION :{WHITE}Online Players
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index 4cbd13dbf..ddc07854b 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -204,7 +204,8 @@ static void PopupMainToolbMenu(Window *w, int widget, StringID string, int count
/** Enum for the Company Toolbar's network related buttons */
static const int CTMN_CLIENT_LIST = -1; ///< Show the client list
-static const int CTMN_SPECTATOR = -2; ///< Show a company window as spectator
+static const int CTMN_SPECTATE = -2; ///< Become spectator
+static const int CTMN_SPECTATOR = -3; ///< Show a company window as spectator
/**
* Pop up a generic company list menu.
@@ -222,8 +223,11 @@ static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0)
/* Add the client list button for the companies menu */
list.emplace_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, CTMN_CLIENT_LIST, false));
- break;
+ if (_local_company != COMPANY_SPECTATOR) {
+ list.emplace_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, false));
+ }
+ break;
case WID_TN_STORY:
list.emplace_back(new DropDownListStringItem(STR_STORY_BOOK_SPECTATOR, CTMN_SPECTATOR, false));
break;
@@ -603,6 +607,15 @@ static CallBackFunction MenuClickCompany(int index)
case CTMN_CLIENT_LIST:
ShowClientList();
return CBF_NONE;
+
+ case CTMN_SPECTATE:
+ if (_network_server) {
+ NetworkServerDoMove(CLIENT_ID_SERVER, COMPANY_SPECTATOR);
+ MarkWholeScreenDirty();
+ } else {
+ NetworkClientRequestMove(COMPANY_SPECTATOR);
+ }
+ return CBF_NONE;
}
}
ShowCompany((CompanyID)index);