mirror of https://github.com/OpenTTD/OpenTTD
(svn r17737) -Codechange: remove the chat window when you were chatting with someone who lost his/her connection or when you were team chatting and moved out of the company.
parent
c53682810f
commit
58a36f038b
|
@ -89,6 +89,9 @@ void SetLocalCompany(CompanyID new_company)
|
||||||
/* company could also be COMPANY_SPECTATOR or OWNER_NONE */
|
/* company could also be COMPANY_SPECTATOR or OWNER_NONE */
|
||||||
assert(Company::IsValidID(new_company) || new_company == COMPANY_SPECTATOR || new_company == OWNER_NONE);
|
assert(Company::IsValidID(new_company) || new_company == COMPANY_SPECTATOR || new_company == OWNER_NONE);
|
||||||
|
|
||||||
|
/* Delete the chat window, if you were team chatting. */
|
||||||
|
InvalidateWindowData(WC_SEND_NETWORK_MSG, DESTTYPE_TEAM, _local_company);
|
||||||
|
|
||||||
_local_company = new_company;
|
_local_company = new_company;
|
||||||
|
|
||||||
/* Delete any construction windows... */
|
/* Delete any construction windows... */
|
||||||
|
|
|
@ -94,6 +94,15 @@ static ClientID _network_client_id = CLIENT_ID_FIRST;
|
||||||
/* Some externs / forwards */
|
/* Some externs / forwards */
|
||||||
extern void StateGameLoop();
|
extern void StateGameLoop();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basically a client is leaving us right now.
|
||||||
|
*/
|
||||||
|
NetworkClientInfo::~NetworkClientInfo()
|
||||||
|
{
|
||||||
|
/* Delete the chat window, if you were chatting with this client. */
|
||||||
|
InvalidateWindowData(WC_SEND_NETWORK_MSG, DESTTYPE_CLIENT, this->client_id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the CI given it's raw index
|
* Return the CI given it's raw index
|
||||||
* @param index the index to search for
|
* @param index the index to search for
|
||||||
|
|
|
@ -30,7 +30,7 @@ struct NetworkClientInfo : NetworkClientInfoPool::PoolItem<&_networkclientinfo_p
|
||||||
char unique_id[NETWORK_UNIQUE_ID_LENGTH]; ///< Every play sends an unique id so we can indentify him
|
char unique_id[NETWORK_UNIQUE_ID_LENGTH]; ///< Every play sends an unique id so we can indentify him
|
||||||
|
|
||||||
NetworkClientInfo(ClientID client_id = INVALID_CLIENT_ID) : client_id(client_id) {}
|
NetworkClientInfo(ClientID client_id = INVALID_CLIENT_ID) : client_id(client_id) {}
|
||||||
~NetworkClientInfo() { client_id = INVALID_CLIENT_ID; }
|
~NetworkClientInfo();
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FOR_ALL_CLIENT_INFOS_FROM(var, start) FOR_ALL_ITEMS_FROM(NetworkClientInfo, clientinfo_index, var, start)
|
#define FOR_ALL_CLIENT_INFOS_FROM(var, start) FOR_ALL_ITEMS_FROM(NetworkClientInfo, clientinfo_index, var, start)
|
||||||
|
|
|
@ -292,7 +292,7 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
|
||||||
assert((uint)this->dtype < lengthof(chat_captions));
|
assert((uint)this->dtype < lengthof(chat_captions));
|
||||||
this->dest_string = chat_captions[this->dtype];
|
this->dest_string = chat_captions[this->dtype];
|
||||||
|
|
||||||
this->InitNested(desc);
|
this->InitNested(desc, type);
|
||||||
|
|
||||||
this->SetFocusedWidget(NWCW_TEXTBOX);
|
this->SetFocusedWidget(NWCW_TEXTBOX);
|
||||||
InvalidateWindowData(WC_NEWS_WINDOW, 0, this->height);
|
InvalidateWindowData(WC_NEWS_WINDOW, 0, this->height);
|
||||||
|
@ -505,6 +505,11 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
|
||||||
{
|
{
|
||||||
ShowOnScreenKeyboard(this, wid, NWCW_CLOSE, NWCW_SENDBUTTON);
|
ShowOnScreenKeyboard(this, wid, NWCW_CLOSE, NWCW_SENDBUTTON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void OnInvalidateData(int data)
|
||||||
|
{
|
||||||
|
if (data == this->dest) delete this;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const NWidgetPart _nested_chat_window_widgets[] = {
|
static const NWidgetPart _nested_chat_window_widgets[] = {
|
||||||
|
@ -530,7 +535,7 @@ static const WindowDesc _chat_window_desc(
|
||||||
|
|
||||||
void ShowNetworkChatQueryWindow(DestType type, int dest)
|
void ShowNetworkChatQueryWindow(DestType type, int dest)
|
||||||
{
|
{
|
||||||
DeleteWindowById(WC_SEND_NETWORK_MSG, 0);
|
DeleteWindowByClass(WC_SEND_NETWORK_MSG);
|
||||||
new NetworkChatWindow(&_chat_window_desc, type, dest);
|
new NetworkChatWindow(&_chat_window_desc, type, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue