Changeset - r9269:58c968498b46
[Not reviewed]
master
0 1 0
rubidium - 17 years ago 2008-05-17 08:00:13
rubidium@openttd.org
(svn r13135) -Codechange: make a class of the NetworkJoinStatusWindow.
1 file changed with 21 insertions and 19 deletions:
0 comments (0 inline, 0 general)
src/network/network_gui.cpp
Show inline comments
 
@@ -1597,13 +1597,16 @@ void ShowNetworkNeedPassword(NetworkPass
 
	ShowQueryString(STR_EMPTY, caption, 20, 180, FindWindowById(WC_NETWORK_STATUS_WINDOW, 0), CS_ALPHANUMERAL);
 
}
 

	
 

	
 
static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e)
 
struct NetworkJoinStatusWindow : Window {
 
	NetworkJoinStatusWindow(const WindowDesc *desc) : Window(desc)
 
{
 
	switch (e->event) {
 
		case WE_PAINT: {
 
		this->parent = FindWindowById(WC_NETWORK_WINDOW, 0);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
			uint8 progress; // used for progress bar
 
			DrawWindowWidgets(w);
 
		DrawWindowWidgets(this);
 

	
 
			DrawStringCentered(125, 35, STR_NETWORK_CONNECTING_1 + _network_join_status, TC_GREY);
 
			switch (_network_join_status) {
 
@@ -1626,27 +1629,28 @@ static void NetworkJoinStatusWindowWndPr
 
			}
 

	
 
			/* Draw nice progress bar :) */
 
			DrawFrameRect(20, 18, (int)((w->width - 20) * progress / 100), 28, 10, FR_NONE);
 
		} break;
 
		DrawFrameRect(20, 18, (int)((this->width - 20) * progress / 100), 28, 10, FR_NONE);
 
	}
 

	
 
		case WE_CLICK:
 
			if (e->we.click.widget == 2) { //Disconnect button
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		if (widget == 2) { //Disconnect button
 
				NetworkDisconnect();
 
				SwitchMode(SM_MENU);
 
				ShowNetworkGameWindow();
 
			}
 
			break;
 
	}
 

	
 
		case WE_ON_EDIT_TEXT:
 
			if (StrEmpty(e->we.edittext.str)) {
 
	virtual void OnQueryTextFinished(char *str)
 
	{
 
		if (StrEmpty(str)) {
 
				NetworkDisconnect();
 
				ShowNetworkGameWindow();
 
			} else {
 
				SEND_COMMAND(PACKET_CLIENT_PASSWORD)(pw_type, e->we.edittext.str);
 
			}
 
			break;
 
			SEND_COMMAND(PACKET_CLIENT_PASSWORD)(pw_type, str);
 
	}
 
}
 
};
 

	
 
static const Widget _network_join_status_window_widget[] = {
 
{    WWT_CAPTION,   RESIZE_NONE,    14,     0,   249,     0,    13, STR_NETWORK_CONNECTING, STR_018C_WINDOW_TITLE_DRAG_THIS},
 
@@ -1660,15 +1664,13 @@ static const WindowDesc _network_join_st
 
	WC_NETWORK_STATUS_WINDOW, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_MODAL,
 
	_network_join_status_window_widget,
 
	NetworkJoinStatusWindowWndProc,
 
	NULL,
 
};
 

	
 
void ShowJoinStatusWindow()
 
{
 
	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
 
	Window *w = new Window(&_network_join_status_window_desc);
 
	/* Parent the status window to the lobby */
 
	if (w != NULL) w->parent = FindWindowById(WC_NETWORK_WINDOW, 0);
 
	new NetworkJoinStatusWindow(&_network_join_status_window_desc);
 
}
 

	
 
static void SendChat(const char *buf, DestType type, int dest)
0 comments (0 inline, 0 general)