Add new company/spectate option back to the company toolbar dropdown
This commit is contained in:
@@ -5660,3 +5660,6 @@ STR_CM_LOGIN_WINDOW_CHANGE_PASSWORD_HELPTEXT :{BLACK}Change password
|
|||||||
STR_CM_LOGIN_WINDOW_SIGN_IN_HELPTEXT :{BLACK}Sign in (you must be on the correct community server)
|
STR_CM_LOGIN_WINDOW_SIGN_IN_HELPTEXT :{BLACK}Sign in (you must be on the correct community server)
|
||||||
STR_CM_LOGIN_WINDOW_USERNAME_DISPLAY :{WHITE}{RAW_STRING}
|
STR_CM_LOGIN_WINDOW_USERNAME_DISPLAY :{WHITE}{RAW_STRING}
|
||||||
STR_CM_LOGIN_WINDOW_PASSWORD_DISPLAY :{WHITE}{STRING}
|
STR_CM_LOGIN_WINDOW_PASSWORD_DISPLAY :{WHITE}{STRING}
|
||||||
|
|
||||||
|
STR_CM_NETWORK_COMPANY_LIST_NEW_COMPANY :New company
|
||||||
|
STR_CM_NETWORK_COMPANY_LIST_SPECTATE :Spectate
|
||||||
|
|||||||
@@ -214,7 +214,9 @@ static void PopupMainToolbMenu(Window *w, int widget, StringID string, int count
|
|||||||
|
|
||||||
/** Enum for the Company Toolbar's network related buttons */
|
/** Enum for the Company Toolbar's network related buttons */
|
||||||
static const int CTMN_CLIENT_LIST = -1; ///< Show the client list
|
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_NEW_COMPANY = -3; ///< Create a new company
|
||||||
|
static const int CTMN_SPECTATOR = -4; ///< Show a company window as spectator
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pop up a generic company list menu.
|
* Pop up a generic company list menu.
|
||||||
@@ -232,8 +234,13 @@ static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0)
|
|||||||
|
|
||||||
/* Add the client list button for the companies menu */
|
/* Add the client list button for the companies menu */
|
||||||
list.emplace_back(new DropDownListStringItem(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, CTMN_CLIENT_LIST, false));
|
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_CM_NETWORK_COMPANY_LIST_NEW_COMPANY, CTMN_NEW_COMPANY, NetworkMaxCompaniesReached()));
|
||||||
|
} else {
|
||||||
|
list.emplace_back(new DropDownListStringItem(STR_CM_NETWORK_COMPANY_LIST_SPECTATE, CTMN_SPECTATE, false));
|
||||||
|
}
|
||||||
|
break;
|
||||||
case WID_TN_STORY:
|
case WID_TN_STORY:
|
||||||
list.emplace_back(new DropDownListStringItem(STR_STORY_BOOK_SPECTATOR, CTMN_SPECTATOR, false));
|
list.emplace_back(new DropDownListStringItem(STR_STORY_BOOK_SPECTATOR, CTMN_SPECTATOR, false));
|
||||||
break;
|
break;
|
||||||
@@ -659,6 +666,24 @@ static CallBackFunction MenuClickCompany(int index)
|
|||||||
case CTMN_CLIENT_LIST:
|
case CTMN_CLIENT_LIST:
|
||||||
ShowClientList();
|
ShowClientList();
|
||||||
return CBF_NONE;
|
return CBF_NONE;
|
||||||
|
|
||||||
|
case CTMN_NEW_COMPANY:
|
||||||
|
if (_network_server) {
|
||||||
|
DoCommandP(0, CCA_NEW, _network_own_client_id, CMD_COMPANY_CTRL);
|
||||||
|
} else {
|
||||||
|
NetworkSendCommand(0, CCA_NEW, 0, CMD_COMPANY_CTRL, nullptr, {}, _local_company);
|
||||||
|
}
|
||||||
|
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);
|
ShowCompany((CompanyID)index);
|
||||||
|
|||||||
Reference in New Issue
Block a user