changeset 18753:8d2cdabac894 draft

(svn r23601) -Fix: fix the conflict in window number
author truebrain <truebrain@openttd.org>
date Mon, 19 Dec 2011 20:50:21 +0000
parents 8712c7857433
children 114868c40989
files src/ai/ai_gui.cpp src/bootstrap_gui.cpp src/company_cmd.cpp src/genworld.cpp src/misc_gui.cpp src/network/network.cpp src/network/network_client.cpp src/network/network_content.cpp src/network/network_content_gui.cpp src/network/network_gui.cpp src/newgrf_config.cpp src/newgrf_gui.cpp src/news_gui.cpp src/rail_gui.cpp src/road_gui.cpp src/settings.cpp src/settings_gui.cpp src/signs_gui.cpp src/window_type.h
diffstat 19 files changed, 146 insertions(+), 108 deletions(-) [+]
line wrap: on
line diff
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -149,7 +149,7 @@
 			for (int i = 0; i < this->selected; i++) it++;
 			AIConfig::GetConfig(slot)->Change((*it).second->GetName(), (*it).second->GetVersion());
 		}
-		SetWindowDirty(WC_GAME_OPTIONS, 0);
+		SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_AI);
 	}
 
 	virtual void OnClick(Point pt, int widget, int click_count)
@@ -583,7 +583,7 @@
 
 	AIConfigWindow() : Window()
 	{
-		this->InitNested(&_ai_config_desc); // Initializes 'this->line_height' as a side effect.
+		this->InitNested(&_ai_config_desc, WN_GAME_OPTIONS_AI); // Initializes 'this->line_height' as a side effect.
 		this->vscroll = this->GetScrollbar(WID_AIC_SCROLLBAR);
 		this->selected_slot = INVALID_COMPANY;
 		NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_AIC_LIST);
@@ -752,7 +752,7 @@
 /** Open the AI config window. */
 void ShowAIConfigWindow()
 {
-	DeleteWindowById(WC_GAME_OPTIONS, 0);
+	DeleteWindowByClass(WC_GAME_OPTIONS);
 	new AIConfigWindow();
 }
 
--- a/src/bootstrap_gui.cpp
+++ b/src/bootstrap_gui.cpp
@@ -132,7 +132,7 @@
 	/** Start listening to the content client events. */
 	BootstrapAskForDownloadWindow() : Window()
 	{
-		this->InitNested(&_bootstrap_query_desc);
+		this->InitNested(&_bootstrap_query_desc, WN_CONFIRM_POPUP_QUERY_BOOTSTRAP);
 		_network_content_client.AddCallback(this);
 	}
 
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -812,7 +812,7 @@
 			if (ci == NULL) return CommandCost();
 
 			/* Delete multiplayer progress bar */
-			DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+			DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
 
 			Company *c = DoStartupNewCompany(false);
 
--- a/src/genworld.cpp
+++ b/src/genworld.cpp
@@ -83,7 +83,7 @@
 	_gw.abortp   = NULL;
 	_gw.threaded = false;
 
-	DeleteWindowById(WC_MODAL_PROGRESS, 0);
+	DeleteWindowByClass(WC_MODAL_PROGRESS);
 	ShowFirstError();
 	MarkWholeScreenDirty();
 }
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -443,7 +443,7 @@
 
 	AboutWindow() : Window()
 	{
-		this->InitNested(&_about_desc);
+		this->InitNested(&_about_desc, WN_GAME_OPTIONS_ABOUT);
 
 		this->counter = 5;
 		this->text_position = this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->pos_y + this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->current_y;
@@ -501,7 +501,7 @@
 
 void ShowAboutWindow()
 {
-	DeleteWindowById(WC_GAME_OPTIONS, 0);
+	DeleteWindowByClass(WC_GAME_OPTIONS);
 	new AboutWindow();
 }
 
@@ -1114,7 +1114,7 @@
 		this->flags = flags;
 		InitializeTextBuffer(&this->text, this->edit_str_buf, max_bytes, max_chars);
 
-		this->InitNested(desc);
+		this->InitNested(desc, WN_QUERY_STRING);
 
 		this->parent = parent;
 
@@ -1245,7 +1245,7 @@
  */
 void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
 {
-	DeleteWindowById(WC_QUERY_STRING, 0);
+	DeleteWindowByClass(WC_QUERY_STRING);
 	new QueryStringWindow(str, caption, ((flags & QSF_LEN_IN_CHARS) ? MAX_CHAR_LENGTH : 1) * maxsize, maxsize, &_query_string_desc, parent, afilter, flags);
 }
 
@@ -1267,7 +1267,7 @@
 		this->message = message;
 		this->proc    = callback;
 
-		this->InitNested(desc);
+		this->InitNested(desc, WN_CONFIRM_POPUP_QUERY);
 
 		this->parent = parent;
 		this->left = parent->left + (parent->width / 2) - (this->width / 2);
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -791,7 +791,7 @@
 
 	if (_settings_client.network.server_advertise) NetworkUDPRemoveAdvertise(blocking);
 
-	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
 
 	NetworkClose(close_admins);
 
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -181,7 +181,7 @@
 		this->CloseConnection(res);
 		_networking = false;
 
-		DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+		DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
 		return;
 	}
 
@@ -314,7 +314,7 @@
 {
 	my_client->status = STATUS_COMPANY_INFO;
 	_network_join_status = NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO;
-	SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
+	SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
 
 	Packet *p = new Packet(PACKET_CLIENT_COMPANY_INFO);
 	my_client->SendPacket(p);
@@ -326,7 +326,7 @@
 {
 	my_client->status = STATUS_JOIN;
 	_network_join_status = NETWORK_JOIN_STATUS_AUTHORIZING;
-	SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
+	SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
 
 	Packet *p = new Packet(PACKET_CLIENT_JOIN);
 	p->Send_string(_openttd_revision);
@@ -531,7 +531,7 @@
 {
 	/* We try to join a server which is full */
 	ShowErrorMessage(STR_NETWORK_ERROR_SERVER_FULL, INVALID_STRING_ID, WL_CRITICAL);
-	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
 
 	return NETWORK_RECV_STATUS_SERVER_FULL;
 }
@@ -540,7 +540,7 @@
 {
 	/* We try to join a server where we are banned */
 	ShowErrorMessage(STR_NETWORK_ERROR_SERVER_BANNED, INVALID_STRING_ID, WL_CRITICAL);
-	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
 
 	return NETWORK_RECV_STATUS_SERVER_BANNED;
 }
@@ -578,7 +578,7 @@
 
 		p->Recv_string(company_info->clients, sizeof(company_info->clients));
 
-		SetWindowDirty(WC_NETWORK_WINDOW, 0);
+		SetWindowDirty(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME);
 
 		return NETWORK_RECV_STATUS_OKAY;
 	}
@@ -675,7 +675,7 @@
 			ShowErrorMessage(STR_NETWORK_ERROR_LOSTCONNECTION, INVALID_STRING_ID, WL_CRITICAL);
 	}
 
-	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
 
 	return NETWORK_RECV_STATUS_SERVER_ERROR;
 }
@@ -770,7 +770,7 @@
 	/* But... only now we set the join status to waiting, instead of requesting. */
 	_network_join_status = NETWORK_JOIN_STATUS_WAITING;
 	_network_join_waiting = p->Recv_uint8();
-	SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
+	SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
 
 	return NETWORK_RECV_STATUS_OKAY;
 }
@@ -790,7 +790,7 @@
 	_network_join_bytes_total = 0;
 
 	_network_join_status = NETWORK_JOIN_STATUS_DOWNLOADING;
-	SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
+	SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
 
 	return NETWORK_RECV_STATUS_OKAY;
 }
@@ -801,7 +801,7 @@
 	if (this->savegame == NULL) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
 
 	_network_join_bytes_total = p->Recv_uint32();
-	SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
+	SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
 
 	return NETWORK_RECV_STATUS_OKAY;
 }
@@ -815,7 +815,7 @@
 	this->savegame->AddPacket(p);
 
 	_network_join_bytes = (uint32)this->savegame->written_bytes;
-	SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
+	SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
 
 	return NETWORK_RECV_STATUS_OKAY;
 }
@@ -826,7 +826,7 @@
 	if (this->savegame == NULL) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
 
 	_network_join_status = NETWORK_JOIN_STATUS_PROCESSING;
-	SetWindowDirty(WC_NETWORK_STATUS_WINDOW, 0);
+	SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
 
 	/*
 	 * Make sure everything is set for reading.
@@ -847,7 +847,7 @@
 	this->last_packet = _realtime_tick;
 
 	if (!load_success) {
-		DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+		DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
 		ShowErrorMessage(STR_NETWORK_ERROR_SAVEGAMEERROR, INVALID_STRING_ID, WL_CRITICAL);
 		return NETWORK_RECV_STATUS_SAVEGAME;
 	}
--- a/src/network/network_content.cpp
+++ b/src/network/network_content.cpp
@@ -475,7 +475,7 @@
 		/* We have a file opened, thus are downloading internal content */
 		size_t toRead = (size_t)(p->size - p->pos);
 		if (fwrite(p->buffer + p->pos, 1, toRead, this->curFile) != toRead) {
-			DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+			DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD);
 			ShowErrorMessage(STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD, STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD_FILE_NOT_WRITABLE, WL_ERROR);
 			this->Close();
 			fclose(this->curFile);
@@ -509,7 +509,7 @@
 		const char *filename = GetFullFilename(this->curInfo, true);
 		if (filename == NULL || (this->curFile = fopen(filename, "wb")) == NULL) {
 			/* Unless that fails ofcourse... */
-			DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+			DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD);
 			ShowErrorMessage(STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD, STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD_FILE_NOT_WRITABLE, WL_ERROR);
 			return false;
 		}
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -55,7 +55,7 @@
 	_network_content_client.AddCallback(this);
 	_network_content_client.DownloadSelectedContent(this->total_files, this->total_bytes);
 
-	this->InitNested(desc, 0);
+	this->InitNested(desc, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD);
 }
 
 BaseNetworkContentDownloadStatusWindow::~BaseNetworkContentDownloadStatusWindow()
@@ -117,7 +117,7 @@
 	 */
 	NetworkContentDownloadStatusWindow() : BaseNetworkContentDownloadStatusWindow(&_network_content_download_status_window_desc)
 	{
-		this->parent = FindWindowById(WC_NETWORK_WINDOW, 1);
+		this->parent = FindWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST);
 	}
 
 	/** Free whatever we've allocated */
@@ -163,17 +163,17 @@
 
 				case CONTENT_TYPE_BASE_GRAPHICS:
 					BaseGraphics::FindSets();
-					SetWindowDirty(WC_GAME_OPTIONS, 0);
+					SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_OPTIONS);
 					break;
 
 				case CONTENT_TYPE_BASE_SOUNDS:
 					BaseSounds::FindSets();
-					SetWindowDirty(WC_GAME_OPTIONS, 0);
+					SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_OPTIONS);
 					break;
 
 				case CONTENT_TYPE_BASE_MUSIC:
 					BaseMusic::FindSets();
-					SetWindowDirty(WC_GAME_OPTIONS, 0);
+					SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_OPTIONS);
 					break;
 
 				case CONTENT_TYPE_NEWGRF:
@@ -193,7 +193,7 @@
 		}
 
 		/* Always invalidate the download window; tell it we are going to be gone */
-		InvalidateWindowData(WC_NETWORK_WINDOW, 1, 2);
+		InvalidateWindowData(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST, 2);
 	}
 
 	virtual void OnClick(Point pt, int widget, int click_count)
@@ -205,7 +205,7 @@
 			} else {
 				/* If downloading succeeded, close the online content window. This will close
 				 * the current window as well. */
-				DeleteWindowById(WC_NETWORK_WINDOW, 1);
+				DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST);
 			}
 		}
 	}
@@ -357,7 +357,7 @@
 	{
 		this->CreateNestedTree(desc);
 		this->vscroll = this->GetScrollbar(WID_NCL_SCROLLBAR);
-		this->FinishInitNested(desc, 1);
+		this->FinishInitNested(desc, WN_NETWORK_WINDOW_CONTENT_LIST);
 
 		this->GetWidget<NWidgetStacked>(WID_NCL_SEL_ALL_UPDATE)->SetDisplayedPlane(select_all);
 
@@ -658,7 +658,7 @@
 				break;
 
 			case WID_NCL_DOWNLOAD:
-				if (BringWindowToFrontById(WC_NETWORK_STATUS_WINDOW, 0) == NULL) new NetworkContentDownloadStatusWindow();
+				if (BringWindowToFrontById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD) == NULL) new NetworkContentDownloadStatusWindow();
 				break;
 		}
 	}
@@ -801,7 +801,7 @@
 		}
 
 		/* If data == 2 then the status window caused this OnInvalidate */
-		this->SetWidgetDisabledState(WID_NCL_DOWNLOAD, this->filesize_sum == 0 || (FindWindowById(WC_NETWORK_STATUS_WINDOW, 0) != NULL && data != 2));
+		this->SetWidgetDisabledState(WID_NCL_DOWNLOAD, this->filesize_sum == 0 || (FindWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD) != NULL && data != 2));
 		this->SetWidgetDisabledState(WID_NCL_UNSELECT, this->filesize_sum == 0);
 		this->SetWidgetDisabledState(WID_NCL_SELECT_ALL, !show_select_all);
 		this->SetWidgetDisabledState(WID_NCL_SELECT_UPDATE, !show_select_upgrade);
@@ -915,7 +915,7 @@
 		_network_content_client.RequestContentList(cv, true);
 	}
 
-	DeleteWindowById(WC_NETWORK_WINDOW, 1);
+	DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST);
 	new NetworkContentListWindow(&_network_content_list_desc, cv != NULL);
 #else
 	ShowErrorMessage(STR_CONTENT_NO_ZLIB, STR_CONTENT_NO_ZLIB_SUB, WL_ERROR);
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -74,7 +74,7 @@
  */
 void UpdateNetworkGameWindow(bool unselect)
 {
-	InvalidateWindowData(WC_NETWORK_WINDOW, 0, unselect ? 1 : 0);
+	InvalidateWindowData(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME, unselect ? 1 : 0);
 }
 
 typedef GUIList<NetworkGameList*> GUIGameServerList;
@@ -425,7 +425,7 @@
 	{
 		this->CreateNestedTree(desc);
 		this->vscroll = this->GetScrollbar(WID_NG_SCROLLBAR);
-		this->FinishInitNested(desc, 0);
+		this->FinishInitNested(desc, WN_NETWORK_WINDOW_GAME);
 
 		ttd_strlcpy(this->edit_str_buf, _settings_client.network.client_name, this->edit_str_size);
 		this->afilter = CS_ALPHANUMERAL;
@@ -651,7 +651,7 @@
 		this->field = widget;
 		switch (widget) {
 			case WID_NG_CANCEL: // Cancel button
-				DeleteWindowById(WC_NETWORK_WINDOW, 0);
+				DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME);
 				break;
 
 			case WID_NG_CONN_BTN: // 'Connection' droplist
@@ -980,7 +980,8 @@
 void ShowNetworkGameWindow()
 {
 	static bool first = true;
-	DeleteWindowById(WC_NETWORK_WINDOW, 0);
+	DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_LOBBY);
+	DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_START);
 
 	/* Only show once */
 	if (first) {
@@ -1000,7 +1001,7 @@
 
 	NetworkStartServerWindow(const WindowDesc *desc) : QueryStringBaseWindow(NETWORK_NAME_LENGTH)
 	{
-		this->InitNested(desc, 0);
+		this->InitNested(desc, WN_NETWORK_WINDOW_START);
 
 		ttd_strlcpy(this->edit_str_buf, _settings_client.network.server_name, this->edit_str_size);
 
@@ -1316,7 +1317,8 @@
 
 static void ShowNetworkStartServerWindow()
 {
-	DeleteWindowById(WC_NETWORK_WINDOW, 0);
+	DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME);
+	DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_LOBBY);
 
 	new NetworkStartServerWindow(&_network_start_server_window_desc);
 }
@@ -1332,7 +1334,7 @@
 	{
 		this->CreateNestedTree(desc);
 		this->vscroll = this->GetScrollbar(WID_NL_SCROLLBAR);
-		this->FinishInitNested(desc, 0);
+		this->FinishInitNested(desc, WN_NETWORK_WINDOW_LOBBY);
 		this->OnResize();
 	}
 
@@ -1608,7 +1610,8 @@
  */
 static void ShowNetworkLobbyWindow(NetworkGameList *ngl)
 {
-	DeleteWindowById(WC_NETWORK_WINDOW, 0);
+	DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_START);
+	DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME);
 
 	NetworkTCPQueryServer(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port)); // company info
 	NetworkUDPQueryServer(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port)); // general data
@@ -1623,7 +1626,7 @@
  */
 NetworkCompanyInfo *GetLobbyCompanyInfo(CompanyID company)
 {
-	NetworkLobbyWindow *lobby = dynamic_cast<NetworkLobbyWindow*>(FindWindowById(WC_NETWORK_WINDOW, 0));
+	NetworkLobbyWindow *lobby = dynamic_cast<NetworkLobbyWindow*>(FindWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_LOBBY));
 	return (lobby != NULL && company < MAX_COMPANIES) ? &lobby->company_info[company] : NULL;
 }
 
@@ -1990,8 +1993,8 @@
 
 	NetworkJoinStatusWindow(const WindowDesc *desc) : Window()
 	{
-		this->parent = FindWindowById(WC_NETWORK_WINDOW, 0);
-		this->InitNested(desc, 0);
+		this->parent = FindWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME);
+		this->InitNested(desc, WN_NETWORK_STATUS_WINDOW_JOIN);
 	}
 
 	virtual void DrawWidget(const Rect &r, int widget) const
@@ -2100,13 +2103,13 @@
 
 void ShowJoinStatusWindow()
 {
-	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
 	new NetworkJoinStatusWindow(&_network_join_status_window_desc);
 }
 
 void ShowNetworkNeedPassword(NetworkPasswordType npt)
 {
-	NetworkJoinStatusWindow *w = (NetworkJoinStatusWindow *)FindWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+	NetworkJoinStatusWindow *w = (NetworkJoinStatusWindow *)FindWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
 	if (w == NULL) return;
 	w->password_type = npt;
 
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -277,7 +277,7 @@
 		SB(config->param[this->param_nr], this->first_bit, this->num_bit, value);
 	}
 	config->num_params = max<uint>(config->num_params, this->param_nr + 1);
-	SetWindowClassesDirty(WC_GAME_OPTIONS); // Is always the newgrf window
+	SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_NEWGRF_STATE);
 }
 
 /**
@@ -688,7 +688,7 @@
 
 	/* Yes... these are the NewGRF windows */
 	InvalidateWindowClassesData(WC_SAVELOAD, 0, true);
-	InvalidateWindowData(WC_GAME_OPTIONS, 0, GOID_NEWGRF_RESCANNED, true);
+	InvalidateWindowData(WC_GAME_OPTIONS, WN_GAME_OPTIONS_NEWGRF_STATE, GOID_NEWGRF_RESCANNED, true);
 	if (callback != NULL) ((NewGRFScanCallback*)callback)->OnNewGRFsScanned();
 
 	DeleteWindowByClass(WC_MODAL_PROGRESS);
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -284,7 +284,7 @@
 				if (!this->action14present && this->grf_config->num_params > 0) {
 					this->grf_config->num_params--;
 					this->InvalidateData();
-					SetWindowClassesDirty(WC_GAME_OPTIONS); // Is always the newgrf window
+					SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_NEWGRF_STATE);
 				}
 				break;
 
@@ -293,7 +293,7 @@
 				if (!this->action14present && c->num_params < c->num_valid_params) {
 					c->param[c->num_params++] = 0;
 					this->InvalidateData();
-					SetWindowClassesDirty(WC_GAME_OPTIONS); // Is always the newgrf window
+					SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_NEWGRF_STATE);
 				}
 				break;
 			}
@@ -349,7 +349,7 @@
 			case WID_NP_RESET:
 				this->grf_config->SetParameterDefaults();
 				this->InvalidateData();
-				SetWindowClassesDirty(WC_GAME_OPTIONS); // Is always the newgrf window
+				SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_NEWGRF_STATE);
 				break;
 
 			case WID_NP_ACCEPT:
@@ -727,7 +727,7 @@
 
 		this->GetWidget<NWidgetStacked>(WID_NS_SHOW_REMOVE)->SetDisplayedPlane(this->editable ? 0 : 1);
 		this->GetWidget<NWidgetStacked>(WID_NS_SHOW_APPLY)->SetDisplayedPlane(this->editable ? 0 : SZSP_HORIZONTAL);
-		this->FinishInitNested(desc);
+		this->FinishInitNested(desc, WN_GAME_OPTIONS_NEWGRF_STATE);
 
 		InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size);
 		this->SetFocusedWidget(WID_NS_FILTER);
@@ -1940,7 +1940,7 @@
 	/** Create the window. */
 	ScanProgressWindow() : Window(), last_name(NULL), scanned(0)
 	{
-		this->InitNested(&_scan_progress_desc);
+		this->InitNested(&_scan_progress_desc, 1);
 	}
 
 	/** Free the last name buffer. */
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -1089,7 +1089,7 @@
 
 	MessageOptionsWindow(const WindowDesc *desc) : Window()
 	{
-		this->InitNested(desc);
+		this->InitNested(desc, WN_GAME_OPTIONS_MESSAGE_OPTION);
 		/* Set up the initial disabled buttons in the case of 'off' or 'full' */
 		NewsDisplay all_val = _news_type_data[0].display;
 		for (int i = 0; i < NT_END; i++) {
@@ -1345,6 +1345,6 @@
  */
 void ShowMessageOptions()
 {
-	DeleteWindowById(WC_GAME_OPTIONS, 0);
+	DeleteWindowByClass(WC_GAME_OPTIONS);
 	new MessageOptionsWindow(&_message_options_desc);
 }
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -414,9 +414,9 @@
 	RailType railtype;    ///< Rail type to build.
 	int last_user_action; ///< Last started user action.
 
-	BuildRailToolbarWindow(const WindowDesc *desc, WindowNumber window_number, RailType railtype) : Window()
+	BuildRailToolbarWindow(const WindowDesc *desc, RailType railtype) : Window()
 	{
-		this->InitNested(desc);
+		this->InitNested(desc, TRANSPORT_RAIL);
 		this->SetupRailToolbar(railtype);
 		this->DisableWidget(WID_RAT_REMOVE);
 		this->last_user_action = WIDGET_LIST_END;
@@ -735,6 +735,7 @@
 		DeleteWindowById(WC_BUILD_SIGNAL, TRANSPORT_RAIL);
 		DeleteWindowById(WC_BUILD_STATION, TRANSPORT_RAIL);
 		DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_RAIL);
+		DeleteWindowById(WC_BUILD_WAYPOINT, TRANSPORT_RAIL);
 		DeleteWindowById(WC_SELECT_STATION, 0);
 		DeleteWindowByClass(WC_BUILD_BRIDGE);
 	}
@@ -841,7 +842,7 @@
 	DeleteWindowByClass(WC_BUILD_TOOLBAR);
 	_cur_railtype = railtype;
 	_remove_button_clicked = false;
-	return new BuildRailToolbarWindow(&_build_rail_desc, TRANSPORT_RAIL, railtype);
+	return new BuildRailToolbarWindow(&_build_rail_desc, railtype);
 }
 
 EventState RailToolbarGlobalHotkeys(uint16 key, uint16 keycode)
@@ -1533,14 +1534,14 @@
 			case WID_BS_DRAG_SIGNALS_DENSITY_DECREASE:
 				if (_settings_client.gui.drag_signals_density > 1) {
 					_settings_client.gui.drag_signals_density--;
-					SetWindowDirty(WC_GAME_OPTIONS, 0);
+					SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_SETTINGS);
 				}
 				break;
 
 			case WID_BS_DRAG_SIGNALS_DENSITY_INCREASE:
 				if (_settings_client.gui.drag_signals_density < 20) {
 					_settings_client.gui.drag_signals_density++;
-					SetWindowDirty(WC_GAME_OPTIONS, 0);
+					SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_SETTINGS);
 				}
 				break;
 
@@ -1777,7 +1778,7 @@
 
 static const WindowDesc _build_waypoint_desc(
 	WDP_AUTO, 0, 0,
-	WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
+	WC_BUILD_WAYPOINT, WC_BUILD_TOOLBAR,
 	WDF_CONSTRUCTION,
 	_nested_build_waypoint_widgets, lengthof(_nested_build_waypoint_widgets)
 );
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -826,7 +826,7 @@
 Window *ShowBuildRoadScenToolbar()
 {
 	_cur_roadtype = ROADTYPE_ROAD;
-	return AllocateWindowDescFront<BuildRoadToolbarWindow>(&_build_road_scen_desc, 0);
+	return AllocateWindowDescFront<BuildRoadToolbarWindow>(&_build_road_scen_desc, TRANSPORT_ROAD);
 }
 
 EventState RoadToolbarEditorGlobalHotkeys(uint16 key, uint16 keycode)
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1717,7 +1717,7 @@
 			GamelogStopAction();
 		}
 
-		SetWindowDirty(WC_GAME_OPTIONS, 0);
+		SetWindowClassesDirty(WC_GAME_OPTIONS);
 	}
 
 	return CommandCost();
@@ -1754,7 +1754,7 @@
 			return CommandCost();
 		}
 
-		SetWindowDirty(WC_GAME_OPTIONS, 0);
+		SetWindowClassesDirty(WC_GAME_OPTIONS);
 	}
 
 	return CommandCost();
@@ -1783,7 +1783,9 @@
 			Write_ValidateSetting(var2, sd, value);
 		}
 		if (sd->desc.proc != NULL) sd->desc.proc((int32)ReadValue(var, sd->save.conv));
-		SetWindowDirty(WC_GAME_OPTIONS, 0);
+
+		SetWindowClassesDirty(WC_GAME_OPTIONS);
+
 		return true;
 	}
 
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -130,7 +130,7 @@
 		this->opt = &GetGameSettings();
 		this->reload = false;
 
-		this->InitNested(desc);
+		this->InitNested(desc, WN_GAME_OPTIONS_GAME_OPTIONS);
 		this->OnInvalidateData(0);
 	}
 
@@ -464,7 +464,7 @@
 			case WID_GO_TOWNNAME_DROPDOWN: // Town names
 				if (_game_mode == GM_MENU || Town::GetNumItems() == 0) {
 					this->opt->game_creation.town_name = index;
-					SetWindowDirty(WC_GAME_OPTIONS, 0);
+					SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_OPTIONS);
 				}
 				break;
 
@@ -603,7 +603,7 @@
 /** Open the game options window. */
 void ShowGameOptions()
 {
-	DeleteWindowById(WC_GAME_OPTIONS, 0);
+	DeleteWindowByClass(WC_GAME_OPTIONS);
 	new GameOptionsWindow(&_game_options_desc);
 }
 
@@ -624,7 +624,7 @@
 
 	GameDifficultyWindow(const WindowDesc *desc) : Window()
 	{
-		this->InitNested(desc);
+		this->InitNested(desc, WN_GAME_OPTIONS_GAME_DIFFICULTY);
 
 		/* Setup disabled buttons when creating window
 		 * disable all other difficulty buttons during gameplay except for 'custom' */
@@ -879,7 +879,7 @@
 /** Open the game-difficulty window. */
 void ShowGameDifficulty()
 {
-	DeleteWindowById(WC_GAME_OPTIONS, 0);
+	DeleteWindowByClass(WC_GAME_OPTIONS);
 	new GameDifficultyWindow(&_game_difficulty_desc);
 }
 
@@ -1594,7 +1594,7 @@
 
 		this->CreateNestedTree(desc);
 		this->vscroll = this->GetScrollbar(WID_GS_SCROLLBAR);
-		this->FinishInitNested(desc, 0);
+		this->FinishInitNested(desc, WN_GAME_OPTIONS_GAME_SETTINGS);
 
 		this->vscroll->SetCount(_settings_main_page.Length());
 	}
@@ -1793,7 +1793,7 @@
 /** Open advanced settings window. */
 void ShowGameSettings()
 {
-	DeleteWindowById(WC_GAME_OPTIONS, 0);
+	DeleteWindowByClass(WC_GAME_OPTIONS);
 	new GameSettingsWindow(&_settings_selection_desc);
 }
 
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -479,7 +479,7 @@
 		this->caption = STR_EDIT_SIGN_CAPTION;
 		this->afilter = CS_ALPHANUMERAL;
 
-		this->InitNested(desc);
+		this->InitNested(desc, WN_QUERY_STRING_SIGN);
 
 		this->LowerWidget(WID_QES_TEXT);
 		UpdateSignEditWindow(si);
@@ -656,7 +656,7 @@
 void ShowRenameSignWindow(const Sign *si)
 {
 	/* Delete all other edit windows */
-	DeleteWindowById(WC_QUERY_STRING, 0);
+	DeleteWindowByClass(WC_QUERY_STRING);
 
 	new SignWindow(&_query_sign_edit_desc, si);
 }
@@ -667,7 +667,7 @@
  */
 void DeleteRenameSignWindow(SignID sign)
 {
-	SignWindow *w = dynamic_cast<SignWindow *>(FindWindowById(WC_QUERY_STRING, 0));
+	SignWindow *w = dynamic_cast<SignWindow *>(FindWindowById(WC_QUERY_STRING, WN_QUERY_STRING_SIGN));
 
 	if (w != NULL && w->cur_sign == sign) delete w;
 }
--- a/src/window_type.h
+++ b/src/window_type.h
@@ -13,6 +13,33 @@
 #define WINDOW_TYPE_H
 
 /**
+ * Window numbers.
+ */
+enum WindowNumberEnum {
+	WN_GAME_OPTIONS_AI = 0,          ///< AI settings.
+	WN_GAME_OPTIONS_ABOUT,           ///< About window.
+	WN_GAME_OPTIONS_NEWGRF_STATE,    ///< NewGRF settings.
+	WN_GAME_OPTIONS_MESSAGE_OPTION,  ///< News settings.
+	WN_GAME_OPTIONS_GAME_OPTIONS,    ///< Game options.
+	WN_GAME_OPTIONS_GAME_DIFFICULTY, ///< Game difficulty.
+	WN_GAME_OPTIONS_GAME_SETTINGS,   ///< Game settings.
+
+	WN_QUERY_STRING = 0,  ///< Query string.
+	WN_QUERY_STRING_SIGN, ///< Query string for signs.
+
+	WN_CONFIRM_POPUP_QUERY = 0,       ///< Query popup confirm.
+	WN_CONFIRM_POPUP_QUERY_BOOTSTRAP, ///< Query popup confirm for bootstrap.
+
+	WN_NETWORK_WINDOW_GAME = 0,     ///< Network game window.
+	WN_NETWORK_WINDOW_LOBBY,        ///< Network lobby window.
+	WN_NETWORK_WINDOW_CONTENT_LIST, ///< Network content list.
+	WN_NETWORK_WINDOW_START,        ///< Network start server.
+
+	WN_NETWORK_STATUS_WINDOW_JOIN = 0,         ///< Network join status.
+	WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD, ///< Network content download status.
+};
+
+/**
  * Window classes.
  */
 enum WindowClass {
@@ -39,7 +66,7 @@
 
 	/**
 	 * Build toolbar; Window numbers:
-	 *   - 0 = #RailToolbarWidgets
+	 *   - #TRANSPORT_RAIL = #RailToolbarWidgets
 	 *   - #TRANSPORT_AIR = #AirportToolbarWidgets
 	 *   - #TRANSPORT_WATER = #DockToolbarWidgets
 	 *   - #TRANSPORT_ROAD = #RoadToolbarWidgets
@@ -48,8 +75,8 @@
 
 	/**
 	 * Scenario build toolbar; Window numbers:
-	 *   - 0 = #RoadToolbarWidgets
 	 *   - #TRANSPORT_WATER = #DockToolbarWidgets
+	 *   - #TRANSPORT_ROAD = #RoadToolbarWidgets
 	 */
 	WC_SCEN_BUILD_TOOLBAR,
 
@@ -90,16 +117,16 @@
 	WC_TOOLTIPS,
 
 	/**
-	 * Query string window; Window numbers: (TODO - CONFLICT)
-	 *   - 0 = #QueryStringWidgets
-	 *   - 0 = #QueryEditSignWidgets
+	 * Query string window; Window numbers:
+	 *   - #WN_QUERY_STRING = #QueryStringWidgets
+	 *   - #WN_QUERY_STRING_SIGN = #QueryEditSignWidgets
 	 */
 	WC_QUERY_STRING,
 
 	/**
-	 * Popup with confirm question; Window numbers: (TODO - CONFLICT)
-	 *   - 0 = #BootstrapAskForDownloadWidgets
-	 *   - 0 = #QueryWidgets
+	 * Popup with confirm question; Window numbers:
+	 *   - #WN_CONFIRM_POPUP_QUERY = #QueryWidgets
+	 *   - #WN_CONFIRM_POPUP_QUERY_BOOTSTRAP = #BootstrapAskForDownloadWidgets
 	 */
 	WC_CONFIRM_POPUP_QUERY,
 
@@ -365,15 +392,20 @@
 	WC_TRUCK_STATION,
 
 	/**
-	 * Build depot; Window numbers: (TODO - CONFLICT)
+	 * Build depot; Window numbers:
 	 *   - #TRANSPORT_WATER = #BuildDockDepotWidgets
 	 *   - #TRANSPORT_RAIL = #BuildRailDepotWidgets
-	 *   - #TRANSPORT_RAIL = #BuildRailWaypointWidgets
 	 *   - #TRANSPORT_ROAD = #BuildRoadDepotWidgets
 	 */
 	WC_BUILD_DEPOT,
 
 	/**
+	 * Build waypoint; Window numbers:
+	 *   - #TRANSPORT_RAIL = #BuildRailWaypointWidgets
+	 */
+	WC_BUILD_WAYPOINT,
+
+	/**
 	 * Found a town; Window numbers:
 	 *   - 0 = #TownFoundingWidgets
 	 */
@@ -407,19 +439,19 @@
 	WC_GENERATE_LANDSCAPE,
 
 	/**
-	 * Progress report of landscape generation; Window numbers: (TODO - CONFLICT)
+	 * Progress report of landscape generation; Window numbers:
 	 *   - 0 = #GenerationProgressWidgets
-	 *   - 0 = #ScanProgressWidgets
+	 *   - 1 = #ScanProgressWidgets
 	 */
 	WC_MODAL_PROGRESS,
 
 
 	/**
-	 * Network window; Window numbers: (TODO - CONFLICT)
-	 *   - 0 = #NetworkGameWidgets
-	 *   - 0 = #NetworkLobbyWidgets
-	 *   - 1 = #NetworkContentListWidgets
-	 *   - 1 = #NetworkStartServerWidgets
+	 * Network window; Window numbers:
+	 *   - #WN_NETWORK_WINDOW_GAME = #NetworkGameWidgets
+	 *   - #WN_NETWORK_WINDOW_LOBBY = #NetworkLobbyWidgets
+	 *   - #WN_NETWORK_WINDOW_CONTENT_LIST = #NetworkContentListWidgets
+	 *   - #WN_NETWORK_WINDOW_START = #NetworkStartServerWidgets
 	 */
 	WC_NETWORK_WINDOW,
 
@@ -436,9 +468,9 @@
 	WC_CLIENT_LIST_POPUP,
 
 	/**
-	 * Network status window; Window numbers: (TODO - CONFLICT)
-	 *   - 0 = #NetworkJoinStatusWidgets
-	 *   - 0 = #NetworkContentDownloadStatusWidgets
+	 * Network status window; Window numbers:
+	 *   - #WN_NETWORK_STATUS_WINDOW_JOIN = #NetworkJoinStatusWidgets
+	 *   - #WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD = #NetworkContentDownloadStatusWidgets
 	 */
 	WC_NETWORK_STATUS_WINDOW,
 
@@ -554,14 +586,14 @@
 	WC_MUSIC_TRACK_SELECTION,
 
 	/**
-	 * Game options window; Window numbers: (TODO - CONFLICT)
-	 *   - 0 = #AIConfigWidgets
-	 *   - 0 = #AboutWidgets
-	 *   - 0 = #NewGRFStateWidgets
-	 *   - 0 = #MessageOptionWidgets
-	 *   - 0 = #GameOptionsWidgets
-	 *   - 0 = #GameDifficultyWidgets
-	 *   - 0 = #GameSettingsWidgets
+	 * Game options window; Window numbers:
+	 *   - #WN_GAME_OPTIONS_AI = #AIConfigWidgets
+	 *   - #WN_GAME_OPTIONS_ABOUT = #AboutWidgets
+	 *   - #WN_GAME_OPTIONS_NEWGRF_STATE = #NewGRFStateWidgets
+	 *   - #WN_GAME_OPTIONS_MESSAGE_OPTION = #MessageOptionWidgets
+	 *   - #WN_GAME_OPTIONS_GAME_OPTIONS = #GameOptionsWidgets
+	 *   - #WN_GAME_OPTIONS_GAME_DIFFICULTY = #GameDifficultyWidgets
+	 *   - #WN_GAME_OPTIONS_GAME_SETTINGS = #GameSettingsWidgets
 	 */
 	WC_GAME_OPTIONS,