Change: Return 'New company/Spectate' option to company toolbar menu

(cherry picked from commit dc2bbfd3f4c78ea14631c2005544bb6898faf1b0)

Include spectate option part
This commit is contained in:
dP
2021-09-02 20:54:56 +03:00
committed by Jonathan G Rennison
parent b67efb7e38
commit 40a6181a16
2 changed files with 16 additions and 2 deletions

View File

@@ -211,7 +211,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.
@@ -229,8 +230,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;
@@ -619,6 +623,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);