Changeset - r13220:c788cc7e3fde
[Not reviewed]
master
0 4 0
rubidium - 15 years ago 2009-10-07 17:36:33
rubidium@openttd.org
(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.
4 files changed with 23 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/company_cmd.cpp
Show inline comments
 
@@ -86,12 +86,15 @@ void Company::PostDestructor(size_t inde
 
 */
 
void SetLocalCompany(CompanyID new_company)
 
{
 
	/* company could also be COMPANY_SPECTATOR or 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;
 

	
 
	/* Delete any construction windows... */
 
	DeleteConstructionWindows();
 

	
 
	/* ... and redraw the whole screen. */
src/network/network.cpp
Show inline comments
 
@@ -92,12 +92,21 @@ static byte _network_clients_connected =
 
static ClientID _network_client_id = CLIENT_ID_FIRST;
 

	
 
/* Some externs / forwards */
 
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
 
 * @param index the index to search for
 
 * @return return a pointer to the corresponding NetworkClientInfo struct
 
 */
 
NetworkClientInfo *NetworkFindClientInfoFromIndex(ClientIndex index)
 
{
src/network/network_base.h
Show inline comments
 
@@ -27,13 +27,13 @@ struct NetworkClientInfo : NetworkClient
 
	CompanyID client_playas;                        ///< As which company is this client playing (CompanyID)
 
	NetworkAddress client_address;                  ///< IP-address of the client (so he can be banned)
 
	Date join_date;                                 ///< Gamedate the client has joined
 
	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() { 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(var) FOR_ALL_CLIENT_INFOS_FROM(var, 0)
 

	
 
#endif /* ENABLE_NETWORK */
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -274,13 +274,13 @@ enum NetWorkChatWidgets {
 

	
 
struct NetworkChatWindow : public QueryStringBaseWindow {
 
	DestType dtype;
 
	StringID dest_string;
 
	int dest;
 

	
 
	NetworkChatWindow (const WindowDesc *desc, DestType type, int dest) : QueryStringBaseWindow(NETWORK_CHAT_LENGTH)
 
	NetworkChatWindow(const WindowDesc *desc, DestType type, int dest) : QueryStringBaseWindow(NETWORK_CHAT_LENGTH)
 
	{
 
		this->dtype   = type;
 
		this->dest    = dest;
 
		this->afilter = CS_ALPHANUMERAL;
 
		InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, 0);
 

	
 
@@ -289,20 +289,20 @@ struct NetworkChatWindow : public QueryS
 
			STR_NETWORK_CHAT_COMPANY_CAPTION,
 
			STR_NETWORK_CHAT_CLIENT_CAPTION
 
		};
 
		assert((uint)this->dtype < lengthof(chat_captions));
 
		this->dest_string = chat_captions[this->dtype];
 

	
 
		this->InitNested(desc);
 
		this->InitNested(desc, type);
 

	
 
		this->SetFocusedWidget(NWCW_TEXTBOX);
 
		InvalidateWindowData(WC_NEWS_WINDOW, 0, this->height);
 
		_chat_tab_completion_active = false;
 
	}
 

	
 
	~NetworkChatWindow ()
 
	~NetworkChatWindow()
 
	{
 
		InvalidateWindowData(WC_NEWS_WINDOW, 0, 0);
 
	}
 

	
 
	/**
 
	 * Find the next item of the list of things that can be auto-completed.
 
@@ -502,12 +502,17 @@ struct NetworkChatWindow : public QueryS
 
	}
 

	
 
	virtual void OnOpenOSKWindow(int wid)
 
	{
 
		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[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY, NWCW_CLOSE),
 
		NWidget(WWT_PANEL, COLOUR_GREY, NWCW_BACKGROUND),
 
@@ -527,11 +532,11 @@ static const WindowDesc _chat_window_des
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET,
 
	NULL, _nested_chat_window_widgets, lengthof(_nested_chat_window_widgets)
 
);
 

	
 
void ShowNetworkChatQueryWindow(DestType type, int dest)
 
{
 
	DeleteWindowById(WC_SEND_NETWORK_MSG, 0);
 
	new NetworkChatWindow (&_chat_window_desc, type, dest);
 
	DeleteWindowByClass(WC_SEND_NETWORK_MSG);
 
	new NetworkChatWindow(&_chat_window_desc, type, dest);
 
}
 

	
 
#endif /* ENABLE_NETWORK */
0 comments (0 inline, 0 general)