Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: add back 'Spectate' option to company toolbar menu #9556

Merged
merged 1 commit into from Sep 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lang/english.txt
Expand Up @@ -2323,6 +2323,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
Expand Down
17 changes: 15 additions & 2 deletions src/toolbar_gui.cpp
Expand Up @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down