Changeset - r18686:dfaaba643efc
[Not reviewed]
master
0 9 0
truebrain - 13 years ago 2011-12-16 18:02:27
truebrain@openttd.org
(svn r23544) -Codechange: document and rename widgets to be consistent and understandable
9 files changed with 523 insertions and 524 deletions:
0 comments (0 inline, 0 general)
src/bootstrap_gui.cpp
Show inline comments
 
@@ -57,25 +57,25 @@ public:
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		GfxFillRect(r.left, r.top, r.right, r.bottom, 4, FILLRECT_OPAQUE);
 
		GfxFillRect(r.left, r.top, r.right, r.bottom, 0, FILLRECT_CHECKER);
 
	}
 
};
 

	
 
/** Nested widgets for the download window. */
 
static const NWidgetPart _nested_boostrap_download_status_window_widgets[] = {
 
	NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CONTENT_DOWNLOAD_TITLE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
	NWidget(WWT_PANEL, COLOUR_GREY, NCDSWW_BACKGROUND),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_NCDS_BACKGROUND),
 
		NWidget(NWID_SPACER), SetMinimalSize(350, 0), SetMinimalTextLines(3, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 30),
 
	EndContainer(),
 
};
 

	
 
/** Window description for the download window */
 
static const WindowDesc _bootstrap_download_status_window_desc(
 
	WDP_CENTER, 0, 0,
 
	WC_NETWORK_STATUS_WINDOW, WC_NONE,
 
	WDF_MODAL,
 
	_nested_boostrap_download_status_window_widgets, lengthof(_nested_boostrap_download_status_window_widgets)
 
);
 

	
src/music_gui.cpp
Show inline comments
 
@@ -284,486 +284,486 @@ void MusicLoop()
 

	
 
static void SelectPlaylist(byte list)
 
{
 
	_settings_client.music.playlist = list;
 
	InvalidateWindowData(WC_MUSIC_TRACK_SELECTION, 0);
 
	InvalidateWindowData(WC_MUSIC_WINDOW, 0);
 
}
 

	
 
struct MusicTrackSelectionWindow : public Window {
 
	MusicTrackSelectionWindow(const WindowDesc *desc, WindowNumber number) : Window()
 
	{
 
		this->InitNested(desc, number);
 
		this->LowerWidget(MTSW_LIST_LEFT);
 
		this->LowerWidget(MTSW_LIST_RIGHT);
 
		this->SetWidgetDisabledState(MTSW_CLEAR, _settings_client.music.playlist <= 3);
 
		this->LowerWidget(MTSW_ALL + _settings_client.music.playlist);
 
		this->LowerWidget(WID_MTS_LIST_LEFT);
 
		this->LowerWidget(WID_MTS_LIST_RIGHT);
 
		this->SetWidgetDisabledState(WID_MTS_CLEAR, _settings_client.music.playlist <= 3);
 
		this->LowerWidget(WID_MTS_ALL + _settings_client.music.playlist);
 
	}
 

	
 
	virtual void SetStringParameters(int widget) const
 
	{
 
		switch (widget) {
 
			case MTSW_PLAYLIST:
 
			case WID_MTS_PLAYLIST:
 
				SetDParam(0, STR_MUSIC_PLAYLIST_ALL + _settings_client.music.playlist);
 
				break;
 
		}
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		if (!gui_scope) return;
 
		for (int i = 0; i < 6; i++) {
 
			this->SetWidgetLoweredState(MTSW_ALL + i, i == _settings_client.music.playlist);
 
			this->SetWidgetLoweredState(WID_MTS_ALL + i, i == _settings_client.music.playlist);
 
		}
 
		this->SetWidgetDisabledState(MTSW_CLEAR, _settings_client.music.playlist <= 3);
 
		this->SetWidgetDisabledState(WID_MTS_CLEAR, _settings_client.music.playlist <= 3);
 
		this->SetDirty();
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		switch (widget) {
 
			case MTSW_PLAYLIST: {
 
			case WID_MTS_PLAYLIST: {
 
				Dimension d = {0, 0};
 

	
 
				for (int i = 0; i < 6; i++) {
 
					SetDParam(0, STR_MUSIC_PLAYLIST_ALL + i);
 
					d = maxdim(d, GetStringBoundingBox(STR_PLAYLIST_PROGRAM));
 
				}
 
				d.width += padding.width;
 
				d.height += padding.height;
 
				*size = maxdim(*size, d);
 
				break;
 
			}
 

	
 
			case MTSW_LIST_LEFT: case MTSW_LIST_RIGHT: {
 
			case WID_MTS_LIST_LEFT: case WID_MTS_LIST_RIGHT: {
 
				Dimension d = {0, 0};
 

	
 
				for (uint i = 0; i < NUM_SONGS_AVAILABLE; i++) {
 
					const char *song_name = GetSongName(i);
 
					if (StrEmpty(song_name)) continue;
 

	
 
					SetDParam(0, GetTrackNumber(i));
 
					SetDParam(1, 2);
 
					SetDParamStr(2, GetSongName(i));
 
					Dimension d2 = GetStringBoundingBox(STR_PLAYLIST_TRACK_NAME);
 
					d.width = max(d.width, d2.width);
 
					d.height += d2.height;
 
				}
 
				d.width += padding.width;
 
				d.height += padding.height;
 
				*size = maxdim(*size, d);
 
				break;
 
			}
 
		}
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		switch (widget) {
 
			case MTSW_LIST_LEFT: {
 
			case WID_MTS_LIST_LEFT: {
 
				GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK);
 

	
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				for (uint i = 0; i < NUM_SONGS_AVAILABLE; i++) {
 
					const char *song_name = GetSongName(i);
 
					if (StrEmpty(song_name)) continue;
 

	
 
					SetDParam(0, GetTrackNumber(i));
 
					SetDParam(1, 2);
 
					SetDParamStr(2, song_name);
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_PLAYLIST_TRACK_NAME);
 
					y += FONT_HEIGHT_SMALL;
 
				}
 
				break;
 
			}
 

	
 
			case MTSW_LIST_RIGHT: {
 
			case WID_MTS_LIST_RIGHT: {
 
				GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK);
 

	
 
				int y = r.top + WD_FRAMERECT_TOP;
 
				for (const byte *p = _playlists[_settings_client.music.playlist]; *p != 0; p++) {
 
					uint i = *p - 1;
 
					SetDParam(0, GetTrackNumber(i));
 
					SetDParam(1, 2);
 
					SetDParamStr(2, GetSongName(i));
 
					DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_PLAYLIST_TRACK_NAME);
 
					y += FONT_HEIGHT_SMALL;
 
				}
 
				break;
 
			}
 
		}
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		switch (widget) {
 
			case MTSW_LIST_LEFT: { // add to playlist
 
			case WID_MTS_LIST_LEFT: { // add to playlist
 
				int y = this->GetRowFromWidget(pt.y, widget, 0, FONT_HEIGHT_SMALL);
 

	
 
				if (_settings_client.music.playlist < 4) return;
 
				if (!IsInsideMM(y, 0, BaseMusic::GetUsedSet()->num_available)) return;
 

	
 
				byte *p = _playlists[_settings_client.music.playlist];
 
				for (uint i = 0; i != NUM_SONGS_PLAYLIST - 1; i++) {
 
					if (p[i] == 0) {
 
						/* Find the actual song number */
 
						for (uint j = 0; j < NUM_SONGS_AVAILABLE; j++) {
 
							if (GetTrackNumber(j) == y + 1) {
 
								p[i] = j + 1;
 
								break;
 
							}
 
						}
 
						p[i + 1] = 0;
 
						this->SetDirty();
 
						SelectSongToPlay();
 
						break;
 
					}
 
				}
 
				break;
 
			}
 

	
 
			case MTSW_LIST_RIGHT: { // remove from playlist
 
			case WID_MTS_LIST_RIGHT: { // remove from playlist
 
				int y = this->GetRowFromWidget(pt.y, widget, 0, FONT_HEIGHT_SMALL);
 

	
 
				if (_settings_client.music.playlist < 4) return;
 
				if (!IsInsideMM(y, 0, NUM_SONGS_PLAYLIST)) return;
 

	
 
				byte *p = _playlists[_settings_client.music.playlist];
 
				for (uint i = y; i != NUM_SONGS_PLAYLIST - 1; i++) {
 
					p[i] = p[i + 1];
 
				}
 

	
 
				this->SetDirty();
 
				SelectSongToPlay();
 
				break;
 
			}
 

	
 
			case MTSW_CLEAR: // clear
 
			case WID_MTS_CLEAR: // clear
 
				for (uint i = 0; _playlists[_settings_client.music.playlist][i] != 0; i++) _playlists[_settings_client.music.playlist][i] = 0;
 
				this->SetDirty();
 
				StopMusic();
 
				SelectSongToPlay();
 
				break;
 

	
 
			case MTSW_ALL: case MTSW_OLD: case MTSW_NEW:
 
			case MTSW_EZY: case MTSW_CUSTOM1: case MTSW_CUSTOM2: // set playlist
 
				SelectPlaylist(widget - MTSW_ALL);
 
			case WID_MTS_ALL: case WID_MTS_OLD: case WID_MTS_NEW:
 
			case WID_MTS_EZY: case WID_MTS_CUSTOM1: case WID_MTS_CUSTOM2: // set playlist
 
				SelectPlaylist(widget - WID_MTS_ALL);
 
				StopMusic();
 
				SelectSongToPlay();
 
				break;
 
		}
 
	}
 
};
 

	
 
static const NWidgetPart _nested_music_track_selection_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_PLAYLIST_MUSIC_PROGRAM_SELECTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY),
 
		NWidget(NWID_HORIZONTAL), SetPIP(2, 4, 2),
 
			/* Left panel. */
 
			NWidget(NWID_VERTICAL),
 
				NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_PLAYLIST_TRACK_INDEX, STR_NULL),
 
				NWidget(WWT_PANEL, COLOUR_GREY, MTSW_LIST_LEFT), SetMinimalSize(180, 194), SetDataTip(0x0, STR_PLAYLIST_TOOLTIP_CLICK_TO_ADD_TRACK), EndContainer(),
 
				NWidget(WWT_PANEL, COLOUR_GREY, WID_MTS_LIST_LEFT), SetMinimalSize(180, 194), SetDataTip(0x0, STR_PLAYLIST_TOOLTIP_CLICK_TO_ADD_TRACK), EndContainer(),
 
				NWidget(NWID_SPACER), SetMinimalSize(0, 2),
 
			EndContainer(),
 
			/* Middle buttons. */
 
			NWidget(NWID_VERTICAL),
 
				NWidget(NWID_SPACER), SetMinimalSize(60, 30), // Space above the first button from the title bar.
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, MTSW_ALL), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_ALL, STR_MUSIC_TOOLTIP_SELECT_ALL_TRACKS_PROGRAM),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, MTSW_OLD), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_OLD_STYLE, STR_MUSIC_TOOLTIP_SELECT_OLD_STYLE_MUSIC),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, MTSW_NEW), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_NEW_STYLE, STR_MUSIC_TOOLTIP_SELECT_NEW_STYLE_MUSIC),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, MTSW_EZY), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_EZY_STREET, STR_MUSIC_TOOLTIP_SELECT_EZY_STREET_STYLE),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, MTSW_CUSTOM1), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_CUSTOM_1, STR_MUSIC_TOOLTIP_SELECT_CUSTOM_1_USER_DEFINED),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, MTSW_CUSTOM2), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_CUSTOM_2, STR_MUSIC_TOOLTIP_SELECT_CUSTOM_2_USER_DEFINED),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_MTS_ALL), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_ALL, STR_MUSIC_TOOLTIP_SELECT_ALL_TRACKS_PROGRAM),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_MTS_OLD), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_OLD_STYLE, STR_MUSIC_TOOLTIP_SELECT_OLD_STYLE_MUSIC),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_MTS_NEW), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_NEW_STYLE, STR_MUSIC_TOOLTIP_SELECT_NEW_STYLE_MUSIC),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_MTS_EZY), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_EZY_STREET, STR_MUSIC_TOOLTIP_SELECT_EZY_STREET_STYLE),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_MTS_CUSTOM1), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_CUSTOM_1, STR_MUSIC_TOOLTIP_SELECT_CUSTOM_1_USER_DEFINED),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_MTS_CUSTOM2), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_CUSTOM_2, STR_MUSIC_TOOLTIP_SELECT_CUSTOM_2_USER_DEFINED),
 
				NWidget(NWID_SPACER), SetMinimalSize(0, 16), // Space above 'clear' button
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, MTSW_CLEAR), SetFill(1, 0), SetDataTip(STR_PLAYLIST_CLEAR, STR_PLAYLIST_TOOLTIP_CLEAR_CURRENT_PROGRAM_CUSTOM1),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_MTS_CLEAR), SetFill(1, 0), SetDataTip(STR_PLAYLIST_CLEAR, STR_PLAYLIST_TOOLTIP_CLEAR_CURRENT_PROGRAM_CUSTOM1),
 
				NWidget(NWID_SPACER), SetFill(0, 1),
 
			EndContainer(),
 
			/* Right panel. */
 
			NWidget(NWID_VERTICAL),
 
				NWidget(WWT_LABEL, COLOUR_GREY, MTSW_PLAYLIST), SetDataTip(STR_PLAYLIST_PROGRAM, STR_NULL),
 
				NWidget(WWT_PANEL, COLOUR_GREY, MTSW_LIST_RIGHT), SetMinimalSize(180, 194), SetDataTip(0x0, STR_PLAYLIST_TOOLTIP_CLICK_TO_REMOVE_TRACK), EndContainer(),
 
				NWidget(WWT_LABEL, COLOUR_GREY, WID_MTS_PLAYLIST), SetDataTip(STR_PLAYLIST_PROGRAM, STR_NULL),
 
				NWidget(WWT_PANEL, COLOUR_GREY, WID_MTS_LIST_RIGHT), SetMinimalSize(180, 194), SetDataTip(0x0, STR_PLAYLIST_TOOLTIP_CLICK_TO_REMOVE_TRACK), EndContainer(),
 
				NWidget(NWID_SPACER), SetMinimalSize(0, 2),
 
			EndContainer(),
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
 
static const WindowDesc _music_track_selection_desc(
 
	WDP_AUTO, 0, 0,
 
	WC_MUSIC_TRACK_SELECTION, WC_NONE,
 
	WDF_UNCLICK_BUTTONS,
 
	_nested_music_track_selection_widgets, lengthof(_nested_music_track_selection_widgets)
 
);
 

	
 
static void ShowMusicTrackSelection()
 
{
 
	AllocateWindowDescFront<MusicTrackSelectionWindow>(&_music_track_selection_desc, 0);
 
}
 

	
 
struct MusicWindow : public Window {
 
	static const int slider_width = 3;
 

	
 
	MusicWindow(const WindowDesc *desc, WindowNumber number) : Window()
 
	{
 
		this->InitNested(desc, number);
 
		this->LowerWidget(_settings_client.music.playlist + MW_ALL);
 
		this->SetWidgetLoweredState(MW_SHUFFLE, _settings_client.music.shuffle);
 
		this->LowerWidget(_settings_client.music.playlist + WID_M_ALL);
 
		this->SetWidgetLoweredState(WID_M_SHUFFLE, _settings_client.music.shuffle);
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		switch (widget) {
 
			/* Make sure that MW_SHUFFLE and MW_PROGRAMME have the same size.
 
			 * This can't be done by using NC_EQUALSIZE as the MW_INFO is
 
			/* Make sure that WID_M_SHUFFLE and WID_M_PROGRAMME have the same size.
 
			 * This can't be done by using NC_EQUALSIZE as the WID_M_INFO is
 
			 * between those widgets and of different size. */
 
			case MW_SHUFFLE: case MW_PROGRAMME: {
 
			case WID_M_SHUFFLE: case WID_M_PROGRAMME: {
 
				Dimension d = maxdim(GetStringBoundingBox(STR_MUSIC_PROGRAM), GetStringBoundingBox(STR_MUSIC_SHUFFLE));
 
				d.width += padding.width;
 
				d.height += padding.height;
 
				*size = maxdim(*size, d);
 
				break;
 
			}
 

	
 
			case MW_TRACK_NR: {
 
			case WID_M_TRACK_NR: {
 
				Dimension d = GetStringBoundingBox(STR_MUSIC_TRACK_NONE);
 
				d.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
				d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
				*size = maxdim(*size, d);
 
				break;
 
			}
 

	
 
			case MW_TRACK_NAME: {
 
			case WID_M_TRACK_NAME: {
 
				Dimension d = GetStringBoundingBox(STR_MUSIC_TITLE_NONE);
 
				for (uint i = 0; i < NUM_SONGS_AVAILABLE; i++) {
 
					SetDParamStr(0, GetSongName(i));
 
					d = maxdim(d, GetStringBoundingBox(STR_MUSIC_TITLE_NAME));
 
				}
 
				d.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
				d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
				*size = maxdim(*size, d);
 
				break;
 
			}
 

	
 
			/* Hack-ish: set the proper widget data; only needs to be done once
 
			 * per (Re)Init as that's the only time the language changes. */
 
			case MW_PREV: this->GetWidget<NWidgetCore>(MW_PREV)->widget_data = _current_text_dir == TD_RTL ? SPR_IMG_SKIP_TO_NEXT : SPR_IMG_SKIP_TO_PREV; break;
 
			case MW_NEXT: this->GetWidget<NWidgetCore>(MW_NEXT)->widget_data = _current_text_dir == TD_RTL ? SPR_IMG_SKIP_TO_PREV : SPR_IMG_SKIP_TO_NEXT; break;
 
			case MW_PLAY: this->GetWidget<NWidgetCore>(MW_PLAY)->widget_data = _current_text_dir == TD_RTL ? SPR_IMG_PLAY_MUSIC_RTL : SPR_IMG_PLAY_MUSIC; break;
 
			case WID_M_PREV: this->GetWidget<NWidgetCore>(WID_M_PREV)->widget_data = _current_text_dir == TD_RTL ? SPR_IMG_SKIP_TO_NEXT : SPR_IMG_SKIP_TO_PREV; break;
 
			case WID_M_NEXT: this->GetWidget<NWidgetCore>(WID_M_NEXT)->widget_data = _current_text_dir == TD_RTL ? SPR_IMG_SKIP_TO_PREV : SPR_IMG_SKIP_TO_NEXT; break;
 
			case WID_M_PLAY: this->GetWidget<NWidgetCore>(WID_M_PLAY)->widget_data = _current_text_dir == TD_RTL ? SPR_IMG_PLAY_MUSIC_RTL : SPR_IMG_PLAY_MUSIC; break;
 
		}
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		switch (widget) {
 
			case MW_TRACK_NR: {
 
			case WID_M_TRACK_NR: {
 
				GfxFillRect(r.left + 1, r.top + 1, r.right, r.bottom, PC_BLACK);
 
				StringID str = STR_MUSIC_TRACK_NONE;
 
				if (_song_is_active != 0 && _music_wnd_cursong != 0) {
 
					SetDParam(0, GetTrackNumber(_music_wnd_cursong - 1));
 
					SetDParam(1, 2);
 
					str = STR_MUSIC_TRACK_DIGIT;
 
				}
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, str);
 
				break;
 
			}
 

	
 
			case MW_TRACK_NAME: {
 
			case WID_M_TRACK_NAME: {
 
				GfxFillRect(r.left, r.top + 1, r.right - 1, r.bottom, PC_BLACK);
 
				StringID str = STR_MUSIC_TITLE_NONE;
 
				if (_song_is_active != 0 && _music_wnd_cursong != 0) {
 
					str = STR_MUSIC_TITLE_NAME;
 
					SetDParamStr(0, GetSongName(_music_wnd_cursong - 1));
 
				}
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, str, TC_FROMSTRING, SA_HOR_CENTER);
 
				break;
 
			}
 

	
 
			case MW_MUSIC_VOL: case MW_EFFECT_VOL: {
 
			case WID_M_MUSIC_VOL: case WID_M_EFFECT_VOL: {
 
				DrawFrameRect(r.left, r.top + 2, r.right, r.bottom - 2, COLOUR_GREY, FR_LOWERED);
 
				byte volume = (widget == MW_MUSIC_VOL) ? _settings_client.music.music_vol : _settings_client.music.effect_vol;
 
				byte volume = (widget == WID_M_MUSIC_VOL) ? _settings_client.music.music_vol : _settings_client.music.effect_vol;
 
				int x = (volume * (r.right - r.left) / 127);
 
				if (_current_text_dir == TD_RTL) {
 
					x = r.right - x;
 
				} else {
 
					x += r.left;
 
				}
 
				DrawFrameRect(x, r.top, x + slider_width, r.bottom, COLOUR_GREY, FR_NONE);
 
				break;
 
			}
 
		}
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		if (!gui_scope) return;
 
		for (int i = 0; i < 6; i++) {
 
			this->SetWidgetLoweredState(MW_ALL + i, i == _settings_client.music.playlist);
 
			this->SetWidgetLoweredState(WID_M_ALL + i, i == _settings_client.music.playlist);
 
		}
 
		this->SetDirty();
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		switch (widget) {
 
			case MW_PREV: // skip to prev
 
			case WID_M_PREV: // skip to prev
 
				if (!_song_is_active) return;
 
				SkipToPrevSong();
 
				this->SetDirty();
 
				break;
 

	
 
			case MW_NEXT: // skip to next
 
			case WID_M_NEXT: // skip to next
 
				if (!_song_is_active) return;
 
				SkipToNextSong();
 
				this->SetDirty();
 
				break;
 

	
 
			case MW_STOP: // stop playing
 
			case WID_M_STOP: // stop playing
 
				_settings_client.music.playing = false;
 
				break;
 

	
 
			case MW_PLAY: // start playing
 
			case WID_M_PLAY: // start playing
 
				_settings_client.music.playing = true;
 
				break;
 

	
 
			case MW_MUSIC_VOL: case MW_EFFECT_VOL: { // volume sliders
 
			case WID_M_MUSIC_VOL: case WID_M_EFFECT_VOL: { // volume sliders
 
				int x = pt.x - this->GetWidget<NWidgetBase>(widget)->pos_x;
 

	
 
				byte *vol = (widget == MW_MUSIC_VOL) ? &_settings_client.music.music_vol : &_settings_client.music.effect_vol;
 
				byte *vol = (widget == WID_M_MUSIC_VOL) ? &_settings_client.music.music_vol : &_settings_client.music.effect_vol;
 

	
 
				byte new_vol = x * 127 / this->GetWidget<NWidgetBase>(widget)->current_x;
 
				if (_current_text_dir == TD_RTL) new_vol = 127 - new_vol;
 
				if (new_vol != *vol) {
 
					*vol = new_vol;
 
					if (widget == MW_MUSIC_VOL) MusicVolumeChanged(new_vol);
 
					if (widget == WID_M_MUSIC_VOL) MusicVolumeChanged(new_vol);
 
					this->SetDirty();
 
				}
 

	
 
				_left_button_clicked = false;
 
				break;
 
			}
 

	
 
			case MW_SHUFFLE: // toggle shuffle
 
			case WID_M_SHUFFLE: // toggle shuffle
 
				_settings_client.music.shuffle ^= 1;
 
				this->SetWidgetLoweredState(MW_SHUFFLE, _settings_client.music.shuffle);
 
				this->SetWidgetDirty(MW_SHUFFLE);
 
				this->SetWidgetLoweredState(WID_M_SHUFFLE, _settings_client.music.shuffle);
 
				this->SetWidgetDirty(WID_M_SHUFFLE);
 
				StopMusic();
 
				SelectSongToPlay();
 
				this->SetDirty();
 
				break;
 

	
 
			case MW_PROGRAMME: // show track selection
 
			case WID_M_PROGRAMME: // show track selection
 
				ShowMusicTrackSelection();
 
				break;
 

	
 
			case MW_ALL: case MW_OLD: case MW_NEW:
 
			case MW_EZY: case MW_CUSTOM1: case MW_CUSTOM2: // playlist
 
				SelectPlaylist(widget - MW_ALL);
 
			case WID_M_ALL: case WID_M_OLD: case WID_M_NEW:
 
			case WID_M_EZY: case WID_M_CUSTOM1: case WID_M_CUSTOM2: // playlist
 
				SelectPlaylist(widget - WID_M_ALL);
 
				StopMusic();
 
				SelectSongToPlay();
 
				this->SetDirty();
 
				break;
 
		}
 
	}
 
};
 

	
 
static const NWidgetPart _nested_music_window_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_MUSIC_JAZZ_JUKEBOX_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
	EndContainer(),
 

	
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(NWID_VERTICAL),
 
			NWidget(WWT_PANEL, COLOUR_GREY, -1), SetFill(1, 1), EndContainer(),
 
			NWidget(NWID_HORIZONTAL),
 
				NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, MW_PREV), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_SKIP_TO_PREV, STR_MUSIC_TOOLTIP_SKIP_TO_PREVIOUS_TRACK),
 
				NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, MW_NEXT), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_SKIP_TO_NEXT, STR_MUSIC_TOOLTIP_SKIP_TO_NEXT_TRACK_IN_SELECTION),
 
				NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, MW_STOP), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_STOP_MUSIC, STR_MUSIC_TOOLTIP_STOP_PLAYING_MUSIC),
 
				NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, MW_PLAY), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_PLAY_MUSIC, STR_MUSIC_TOOLTIP_START_PLAYING_MUSIC),
 
				NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_M_PREV), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_SKIP_TO_PREV, STR_MUSIC_TOOLTIP_SKIP_TO_PREVIOUS_TRACK),
 
				NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_M_NEXT), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_SKIP_TO_NEXT, STR_MUSIC_TOOLTIP_SKIP_TO_NEXT_TRACK_IN_SELECTION),
 
				NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_M_STOP), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_STOP_MUSIC, STR_MUSIC_TOOLTIP_STOP_PLAYING_MUSIC),
 
				NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_M_PLAY), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_PLAY_MUSIC, STR_MUSIC_TOOLTIP_START_PLAYING_MUSIC),
 
			EndContainer(),
 
			NWidget(WWT_PANEL, COLOUR_GREY, -1), SetFill(1, 1), EndContainer(),
 
		EndContainer(),
 
		NWidget(WWT_PANEL, COLOUR_GREY, MW_SLIDERS),
 
		NWidget(WWT_PANEL, COLOUR_GREY, WID_M_SLIDERS),
 
			NWidget(NWID_HORIZONTAL), SetPIP(20, 20, 20),
 
				NWidget(NWID_VERTICAL),
 
					NWidget(WWT_LABEL, COLOUR_GREY, -1), SetFill(1, 0), SetDataTip(STR_MUSIC_MUSIC_VOLUME, STR_NULL),
 
					NWidget(WWT_EMPTY, COLOUR_GREY, MW_MUSIC_VOL), SetMinimalSize(67, 0), SetMinimalTextLines(1, 0), SetFill(1, 0), SetDataTip(0x0, STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
 
					NWidget(WWT_EMPTY, COLOUR_GREY, WID_M_MUSIC_VOL), SetMinimalSize(67, 0), SetMinimalTextLines(1, 0), SetFill(1, 0), SetDataTip(0x0, STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
 
					NWidget(NWID_HORIZONTAL),
 
						NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MIN, STR_NULL),
 
						NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
 
						NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
 
						NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
 
						NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
 
						NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
 
						NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MAX, STR_NULL),
 
					EndContainer(),
 
				EndContainer(),
 
				NWidget(NWID_VERTICAL),
 
					NWidget(WWT_LABEL, COLOUR_GREY, -1), SetFill(1, 0), SetDataTip(STR_MUSIC_EFFECTS_VOLUME, STR_NULL),
 
					NWidget(WWT_EMPTY, COLOUR_GREY, MW_EFFECT_VOL), SetMinimalSize(67, 0), SetMinimalTextLines(1, 0), SetFill(1, 0), SetDataTip(0x0, STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
 
					NWidget(WWT_EMPTY, COLOUR_GREY, WID_M_EFFECT_VOL), SetMinimalSize(67, 0), SetMinimalTextLines(1, 0), SetFill(1, 0), SetDataTip(0x0, STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
 
					NWidget(NWID_HORIZONTAL),
 
						NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MIN, STR_NULL),
 
						NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
 
						NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
 
						NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
 
						NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
 
						NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MARKER, STR_NULL), SetFill(1, 0),
 
						NWidget(WWT_LABEL, COLOUR_GREY, -1), SetDataTip(STR_MUSIC_RULER_MAX, STR_NULL),
 
					EndContainer(),
 
				EndContainer(),
 
			EndContainer(),
 
		EndContainer(),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, MW_BACKGROUND),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_M_BACKGROUND),
 
		NWidget(NWID_HORIZONTAL), SetPIP(6, 0, 6),
 
			NWidget(NWID_VERTICAL),
 
				NWidget(NWID_SPACER), SetFill(0, 1),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, MW_SHUFFLE), SetMinimalSize(50, 8), SetDataTip(STR_MUSIC_SHUFFLE, STR_MUSIC_TOOLTIP_TOGGLE_PROGRAM_SHUFFLE),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_SHUFFLE), SetMinimalSize(50, 8), SetDataTip(STR_MUSIC_SHUFFLE, STR_MUSIC_TOOLTIP_TOGGLE_PROGRAM_SHUFFLE),
 
				NWidget(NWID_SPACER), SetFill(0, 1),
 
			EndContainer(),
 
			NWidget(NWID_VERTICAL), SetPadding(0, 0, 3, 3),
 
				NWidget(WWT_LABEL, COLOUR_GREY, MW_TRACK), SetFill(0, 0), SetDataTip(STR_MUSIC_TRACK, STR_NULL),
 
				NWidget(WWT_PANEL, COLOUR_GREY, MW_TRACK_NR), EndContainer(),
 
				NWidget(WWT_LABEL, COLOUR_GREY, WID_M_TRACK), SetFill(0, 0), SetDataTip(STR_MUSIC_TRACK, STR_NULL),
 
				NWidget(WWT_PANEL, COLOUR_GREY, WID_M_TRACK_NR), EndContainer(),
 
			EndContainer(),
 
			NWidget(NWID_VERTICAL), SetPadding(0, 3, 3, 0),
 
				NWidget(WWT_LABEL, COLOUR_GREY, MW_TRACK_TITLE), SetFill(1, 0), SetDataTip(STR_MUSIC_XTITLE, STR_NULL),
 
				NWidget(WWT_PANEL, COLOUR_GREY, MW_TRACK_NAME), SetFill(1, 0), EndContainer(),
 
				NWidget(WWT_LABEL, COLOUR_GREY, WID_M_TRACK_TITLE), SetFill(1, 0), SetDataTip(STR_MUSIC_XTITLE, STR_NULL),
 
				NWidget(WWT_PANEL, COLOUR_GREY, WID_M_TRACK_NAME), SetFill(1, 0), EndContainer(),
 
			EndContainer(),
 
			NWidget(NWID_VERTICAL),
 
				NWidget(NWID_SPACER), SetFill(0, 1),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, MW_PROGRAMME), SetMinimalSize(50, 8), SetDataTip(STR_MUSIC_PROGRAM, STR_MUSIC_TOOLTIP_SHOW_MUSIC_TRACK_SELECTION),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_M_PROGRAMME), SetMinimalSize(50, 8), SetDataTip(STR_MUSIC_PROGRAM, STR_MUSIC_TOOLTIP_SHOW_MUSIC_TRACK_SELECTION),
 
				NWidget(NWID_SPACER), SetFill(0, 1),
 
			EndContainer(),
 
		EndContainer(),
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, MW_ALL), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_ALL, STR_MUSIC_TOOLTIP_SELECT_ALL_TRACKS_PROGRAM),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, MW_OLD), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_OLD_STYLE, STR_MUSIC_TOOLTIP_SELECT_OLD_STYLE_MUSIC),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, MW_NEW), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_NEW_STYLE, STR_MUSIC_TOOLTIP_SELECT_NEW_STYLE_MUSIC),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, MW_EZY), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_EZY_STREET, STR_MUSIC_TOOLTIP_SELECT_EZY_STREET_STYLE),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, MW_CUSTOM1), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_CUSTOM_1, STR_MUSIC_TOOLTIP_SELECT_CUSTOM_1_USER_DEFINED),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, MW_CUSTOM2), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_CUSTOM_2, STR_MUSIC_TOOLTIP_SELECT_CUSTOM_2_USER_DEFINED),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_ALL), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_ALL, STR_MUSIC_TOOLTIP_SELECT_ALL_TRACKS_PROGRAM),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_OLD), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_OLD_STYLE, STR_MUSIC_TOOLTIP_SELECT_OLD_STYLE_MUSIC),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_NEW), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_NEW_STYLE, STR_MUSIC_TOOLTIP_SELECT_NEW_STYLE_MUSIC),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_EZY), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_EZY_STREET, STR_MUSIC_TOOLTIP_SELECT_EZY_STREET_STYLE),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_CUSTOM1), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_CUSTOM_1, STR_MUSIC_TOOLTIP_SELECT_CUSTOM_1_USER_DEFINED),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_CUSTOM2), SetFill(1, 0), SetDataTip(STR_MUSIC_PLAYLIST_CUSTOM_2, STR_MUSIC_TOOLTIP_SELECT_CUSTOM_2_USER_DEFINED),
 
	EndContainer(),
 
};
 

	
 
static const WindowDesc _music_window_desc(
 
	WDP_AUTO, 0, 0,
 
	WC_MUSIC_WINDOW, WC_NONE,
 
	WDF_UNCLICK_BUTTONS,
 
	_nested_music_window_widgets, lengthof(_nested_music_window_widgets)
 
);
 

	
 
void ShowMusicWindow()
 
{
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -305,25 +305,25 @@ struct NetworkChatWindow : public QueryS
 
		InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size);
 

	
 
		static const StringID chat_captions[] = {
 
			STR_NETWORK_CHAT_ALL_CAPTION,
 
			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, type);
 

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

	
 
		PositionNetworkChatWindow(this);
 
	}
 

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

	
 
	/**
 
@@ -459,122 +459,122 @@ struct NetworkChatWindow : public QueryS
 

	
 
			/* Update the textbuffer */
 
			UpdateTextBufferSize(&this->text);
 

	
 
			this->SetDirty();
 
		}
 
		free(pre_buf);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		this->DrawWidgets();
 
		this->DrawEditBox(NWCW_TEXTBOX);
 
		this->DrawEditBox(WID_NC_TEXTBOX);
 
	}
 

	
 
	virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number)
 
	{
 
		Point pt = { 0, _screen.height - sm_height - FindWindowById(WC_STATUS_BAR, 0)->height };
 
		return pt;
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		if (widget != NWCW_DESTINATION) return;
 
		if (widget != WID_NC_DESTINATION) return;
 

	
 
		if (this->dtype == DESTTYPE_CLIENT) {
 
			SetDParamStr(0, NetworkClientInfo::GetByClientID((ClientID)this->dest)->client_name);
 
		}
 
		Dimension d = GetStringBoundingBox(this->dest_string);
 
		d.width  += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
		d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
		*size = maxdim(*size, d);
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		if (widget != NWCW_DESTINATION) return;
 
		if (widget != WID_NC_DESTINATION) return;
 

	
 
		if (this->dtype == DESTTYPE_CLIENT) {
 
			SetDParamStr(0, NetworkClientInfo::GetByClientID((ClientID)this->dest)->client_name);
 
		}
 
		DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, this->dest_string, TC_BLACK, SA_RIGHT);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		switch (widget) {
 
			/* Send */
 
			case NWCW_SENDBUTTON: SendChat(this->text.buf, this->dtype, this->dest);
 
			case WID_NC_SENDBUTTON: SendChat(this->text.buf, this->dtype, this->dest);
 
				/* FALL THROUGH */
 
			case NWCW_CLOSE: /* Cancel */ delete this; break;
 
			case WID_NC_CLOSE: /* Cancel */ delete this; break;
 
		}
 
	}
 

	
 
	virtual void OnMouseLoop()
 
	{
 
		this->HandleEditBox(NWCW_TEXTBOX);
 
		this->HandleEditBox(WID_NC_TEXTBOX);
 
	}
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		EventState state = ES_NOT_HANDLED;
 
		if (keycode == WKC_TAB) {
 
			ChatTabCompletion();
 
			state = ES_HANDLED;
 
		} else {
 
			_chat_tab_completion_active = false;
 
			switch (this->HandleEditBoxKey(NWCW_TEXTBOX, key, keycode, state)) {
 
			switch (this->HandleEditBoxKey(WID_NC_TEXTBOX, key, keycode, state)) {
 
				default: NOT_REACHED();
 
				case HEBR_EDITING: {
 
					Window *osk = FindWindowById(WC_OSK, 0);
 
					if (osk != NULL && osk->parent == this) osk->InvalidateData();
 
					break;
 
				}
 
				case HEBR_CONFIRM:
 
					SendChat(this->text.buf, this->dtype, this->dest);
 
					/* FALL THROUGH */
 
				case HEBR_CANCEL: delete this; break;
 
				case HEBR_NOT_FOCUSED: break;
 
			}
 
		}
 
		return state;
 
	}
 

	
 
	virtual void OnOpenOSKWindow(int wid)
 
	{
 
		ShowOnScreenKeyboard(this, wid, NWCW_CLOSE, NWCW_SENDBUTTON);
 
		ShowOnScreenKeyboard(this, wid, WID_NC_CLOSE, WID_NC_SENDBUTTON);
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		if (data == this->dest) delete this;
 
	}
 
};
 

	
 
/** The widgets of the chat window. */
 
static const NWidgetPart _nested_chat_window_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY, NWCW_CLOSE),
 
		NWidget(WWT_PANEL, COLOUR_GREY, NWCW_BACKGROUND),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY, WID_NC_CLOSE),
 
		NWidget(WWT_PANEL, COLOUR_GREY, WID_NC_BACKGROUND),
 
			NWidget(NWID_HORIZONTAL),
 
				NWidget(WWT_TEXT, COLOUR_GREY, NWCW_DESTINATION), SetMinimalSize(62, 12), SetPadding(1, 0, 1, 0), SetDataTip(STR_NULL, STR_NULL),
 
				NWidget(WWT_EDITBOX, COLOUR_GREY, NWCW_TEXTBOX), SetMinimalSize(100, 12), SetPadding(1, 0, 1, 0), SetResize(1, 0),
 
				NWidget(WWT_TEXT, COLOUR_GREY, WID_NC_DESTINATION), SetMinimalSize(62, 12), SetPadding(1, 0, 1, 0), SetDataTip(STR_NULL, STR_NULL),
 
				NWidget(WWT_EDITBOX, COLOUR_GREY, WID_NC_TEXTBOX), SetMinimalSize(100, 12), SetPadding(1, 0, 1, 0), SetResize(1, 0),
 
																	SetDataTip(STR_NETWORK_CHAT_OSKTITLE, STR_NULL),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, NWCW_SENDBUTTON), SetMinimalSize(62, 12), SetPadding(1, 0, 1, 0), SetDataTip(STR_NETWORK_CHAT_SEND, STR_NULL),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NC_SENDBUTTON), SetMinimalSize(62, 12), SetPadding(1, 0, 1, 0), SetDataTip(STR_NETWORK_CHAT_SEND, STR_NULL),
 
			EndContainer(),
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
 
/** The description of the chat window. */
 
static const WindowDesc _chat_window_desc(
 
	WDP_MANUAL, 640, 14, // x, y, width, height
 
	WC_SEND_NETWORK_MSG, WC_NONE,
 
	0,
 
	_nested_chat_window_widgets, lengthof(_nested_chat_window_widgets)
 
);
src/network/network_content_gui.cpp
Show inline comments
 
@@ -21,29 +21,29 @@
 
#include "../querystring_gui.h"
 
#include "../core/geometry_func.hpp"
 
#include "network_content_gui.h"
 

	
 
#include "../widgets/network_content_widget.h"
 

	
 
#include "table/strings.h"
 
#include "../table/sprites.h"
 

	
 
/** Nested widgets for the download window. */
 
static const NWidgetPart _nested_network_content_download_status_window_widgets[] = {
 
	NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CONTENT_DOWNLOAD_TITLE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
	NWidget(WWT_PANEL, COLOUR_GREY, NCDSWW_BACKGROUND),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_NCDS_BACKGROUND),
 
		NWidget(NWID_SPACER), SetMinimalSize(350, 0), SetMinimalTextLines(3, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 30),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(NWID_SPACER), SetMinimalSize(125, 0),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NCDSWW_CANCELOK), SetMinimalSize(101, 12), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCDS_CANCELOK), SetMinimalSize(101, 12), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
 
			NWidget(NWID_SPACER), SetFill(1, 0),
 
		EndContainer(),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 4),
 
	EndContainer(),
 
};
 

	
 
/** Window description for the download window */
 
static const WindowDesc _network_content_download_status_window_desc(
 
	WDP_CENTER, 0, 0,
 
	WC_NETWORK_STATUS_WINDOW, WC_NONE,
 
	WDF_MODAL,
 
	_nested_network_content_download_status_window_widgets, lengthof(_nested_network_content_download_status_window_widgets)
 
@@ -56,25 +56,25 @@ BaseNetworkContentDownloadStatusWindow::
 
	_network_content_client.DownloadSelectedContent(this->total_files, this->total_bytes);
 

	
 
	this->InitNested(desc, 0);
 
}
 

	
 
BaseNetworkContentDownloadStatusWindow::~BaseNetworkContentDownloadStatusWindow()
 
{
 
	_network_content_client.RemoveCallback(this);
 
}
 

	
 
/* virtual */ void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, int widget) const
 
{
 
	if (widget != NCDSWW_BACKGROUND) return;
 
	if (widget != WID_NCDS_BACKGROUND) return;
 

	
 
	/* Draw nice progress bar :) */
 
	DrawFrameRect(r.left + 20, r.top + 4, r.left + 20 + (int)((this->width - 40LL) * this->downloaded_bytes / this->total_bytes), r.top + 14, COLOUR_MAUVE, FR_NONE);
 

	
 
	int y = r.top + 20;
 
	SetDParam(0, this->downloaded_bytes);
 
	SetDParam(1, this->total_bytes);
 
	SetDParam(2, this->downloaded_bytes * 100LL / this->total_bytes);
 
	DrawString(r.left + 2, r.right - 2, y, STR_CONTENT_DOWNLOAD_PROGRESS_SIZE, TC_FROMSTRING, SA_HOR_CENTER);
 

	
 
	StringID str;
 
	if (this->downloaded_bytes == this->total_bytes) {
 
@@ -189,44 +189,44 @@ public:
 

	
 
				default:
 
					break;
 
			}
 
		}
 

	
 
		/* Always invalidate the download window; tell it we are going to be gone */
 
		InvalidateWindowData(WC_NETWORK_WINDOW, 1, 2);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		if (widget == NCDSWW_CANCELOK) {
 
		if (widget == WID_NCDS_CANCELOK) {
 
			if (this->downloaded_bytes != this->total_bytes) {
 
				_network_content_client.Close();
 
				delete this;
 
			} else {
 
				/* If downloading succeeded, close the online content window. This will close
 
				 * the current window as well. */
 
				DeleteWindowById(WC_NETWORK_WINDOW, 1);
 
			}
 
		}
 
	}
 

	
 
	virtual void OnDownloadProgress(const ContentInfo *ci, int bytes)
 
	{
 
		BaseNetworkContentDownloadStatusWindow::OnDownloadProgress(ci, bytes);
 
		this->receivedTypes.Include(ci->type);
 

	
 
		/* When downloading is finished change cancel in ok */
 
		if (this->downloaded_bytes == this->total_bytes) {
 
			this->GetWidget<NWidgetCore>(NCDSWW_CANCELOK)->widget_data = STR_BUTTON_OK;
 
			this->GetWidget<NWidgetCore>(WID_NCDS_CANCELOK)->widget_data = STR_BUTTON_OK;
 
		}
 
	}
 
};
 

	
 
/** Window that lists the content that's at the content server */
 
class NetworkContentListWindow : public QueryStringBaseWindow, ContentCallback {
 
	/** List with content infos. */
 
	typedef GUIList<const ContentInfo*> GUIContentList;
 

	
 
	static const uint EDITBOX_MAX_SIZE   =  50; ///< Maximum size of the editbox in characters.
 
	static const uint EDITBOX_MAX_LENGTH = 300; ///< Maximum size of the editbox in pixels.
 

	
 
@@ -347,120 +347,120 @@ public:
 
	/**
 
	 * Create the content list window.
 
	 * @param desc the window description to pass to Window's constructor.
 
	 * @param select_all Whether the select all button is allowed or not.
 
	 */
 
	NetworkContentListWindow(const WindowDesc *desc, bool select_all) :
 
			QueryStringBaseWindow(EDITBOX_MAX_SIZE),
 
			auto_select(select_all),
 
			selected(NULL),
 
			list_pos(0)
 
	{
 
		this->CreateNestedTree(desc);
 
		this->vscroll = this->GetScrollbar(NCLWW_SCROLLBAR);
 
		this->vscroll = this->GetScrollbar(WID_NCL_SCROLLBAR);
 
		this->FinishInitNested(desc, 1);
 

	
 
		this->GetWidget<NWidgetStacked>(NCLWW_SEL_ALL_UPDATE)->SetDisplayedPlane(select_all);
 
		this->GetWidget<NWidgetStacked>(WID_NCL_SEL_ALL_UPDATE)->SetDisplayedPlane(select_all);
 

	
 
		this->afilter = CS_ALPHANUMERAL;
 
		InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, EDITBOX_MAX_LENGTH);
 
		this->SetFocusedWidget(NCLWW_FILTER);
 
		this->SetFocusedWidget(WID_NCL_FILTER);
 

	
 
		_network_content_client.AddCallback(this);
 
		this->content.SetListing(this->last_sorting);
 
		this->content.SetFiltering(this->last_filtering);
 
		this->content.SetSortFuncs(this->sorter_funcs);
 
		this->content.SetFilterFuncs(this->filter_funcs);
 
		this->content.ForceRebuild();
 
		this->FilterContentList();
 
		this->SortContentList();
 
		this->InvalidateData();
 
	}
 

	
 
	/** Free everything we allocated */
 
	~NetworkContentListWindow()
 
	{
 
		_network_content_client.RemoveCallback(this);
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		switch (widget) {
 
			case NCLWW_FILTER_CAPT:
 
			case WID_NCL_FILTER_CAPT:
 
				*size = maxdim(*size, GetStringBoundingBox(STR_CONTENT_FILTER_TITLE));
 
				break;
 

	
 
			case NCLWW_TYPE: {
 
			case WID_NCL_TYPE: {
 
				Dimension d = *size;
 
				for (int i = CONTENT_TYPE_BEGIN; i < CONTENT_TYPE_END; i++) {
 
					d = maxdim(d, GetStringBoundingBox(STR_CONTENT_TYPE_BASE_GRAPHICS + i - CONTENT_TYPE_BASE_GRAPHICS));
 
				}
 
				size->width = d.width + WD_MATRIX_RIGHT + WD_MATRIX_LEFT;
 
				break;
 
			}
 

	
 
			case NCLWW_MATRIX:
 
			case WID_NCL_MATRIX:
 
				resize->height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
 
				size->height = 10 * resize->height;
 
				break;
 
		}
 
	}
 

	
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		switch (widget) {
 
			case NCLWW_FILTER_CAPT:
 
			case WID_NCL_FILTER_CAPT:
 
				DrawString(r.left, r.right, r.top, STR_CONTENT_FILTER_TITLE, TC_FROMSTRING, SA_RIGHT);
 
				break;
 

	
 
			case NCLWW_DETAILS:
 
			case WID_NCL_DETAILS:
 
				this->DrawDetails(r);
 
				break;
 

	
 
			case NCLWW_MATRIX:
 
			case WID_NCL_MATRIX:
 
				this->DrawMatrix(r);
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		const SortButtonState arrow = this->content.IsDescSortOrder() ? SBS_DOWN : SBS_UP;
 

	
 
		if (this->content.NeedRebuild()) {
 
			this->BuildContentList();
 
		}
 

	
 
		this->DrawWidgets();
 

	
 
		/* Edit box to filter for keywords */
 
		this->DrawEditBox(NCLWW_FILTER);
 
		this->DrawEditBox(WID_NCL_FILTER);
 

	
 
		switch (this->content.SortType()) {
 
			case NCLWW_CHECKBOX - NCLWW_CHECKBOX: this->DrawSortButtonState(NCLWW_CHECKBOX, arrow); break;
 
			case NCLWW_TYPE     - NCLWW_CHECKBOX: this->DrawSortButtonState(NCLWW_TYPE,     arrow); break;
 
			case NCLWW_NAME     - NCLWW_CHECKBOX: this->DrawSortButtonState(NCLWW_NAME,     arrow); break;
 
			case WID_NCL_CHECKBOX - WID_NCL_CHECKBOX: this->DrawSortButtonState(WID_NCL_CHECKBOX, arrow); break;
 
			case WID_NCL_TYPE     - WID_NCL_CHECKBOX: this->DrawSortButtonState(WID_NCL_TYPE,     arrow); break;
 
			case WID_NCL_NAME     - WID_NCL_CHECKBOX: this->DrawSortButtonState(WID_NCL_NAME,     arrow); break;
 
		}
 
	}
 

	
 
	/**
 
	 * Draw/fill the matrix with the list of content to download.
 
	 * @param r The boundaries of the matrix.
 
	 */
 
	void DrawMatrix(const Rect &r) const
 
	{
 
		const NWidgetBase *nwi_checkbox = this->GetWidget<NWidgetBase>(NCLWW_CHECKBOX);
 
		const NWidgetBase *nwi_name = this->GetWidget<NWidgetBase>(NCLWW_NAME);
 
		const NWidgetBase *nwi_type = this->GetWidget<NWidgetBase>(NCLWW_TYPE);
 
		const NWidgetBase *nwi_checkbox = this->GetWidget<NWidgetBase>(WID_NCL_CHECKBOX);
 
		const NWidgetBase *nwi_name = this->GetWidget<NWidgetBase>(WID_NCL_NAME);
 
		const NWidgetBase *nwi_type = this->GetWidget<NWidgetBase>(WID_NCL_TYPE);
 

	
 

	
 
		/* Fill the matrix with the information */
 
		int sprite_y_offset = WD_MATRIX_TOP + (FONT_HEIGHT_NORMAL - 10) / 2;
 
		uint y = r.top;
 
		int cnt = 0;
 
		for (ConstContentIterator iter = this->content.Get(this->vscroll->GetPosition()); iter != this->content.End() && cnt < this->vscroll->GetCapacity(); iter++, cnt++) {
 
			const ContentInfo *ci = *iter;
 

	
 
			if (ci == this->selected) GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->resize.step_height - 1, PC_GREY);
 

	
 
			SpriteID sprite;
 
@@ -590,91 +590,91 @@ public:
 
				p += seprintf(p, lastof(buf), buf == p ? "%s" : ", %s", ci->name);
 
			}
 
			if (p != buf) {
 
				SetDParamStr(0, buf);
 
				y = DrawStringMultiLine(r.left + DETAIL_LEFT, r.right - DETAIL_RIGHT, y, max_y, STR_CONTENT_DETAIL_SELECTED_BECAUSE_OF);
 
			}
 
		}
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		switch (widget) {
 
			case NCLWW_MATRIX: {
 
				uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, NCLWW_MATRIX);
 
			case WID_NCL_MATRIX: {
 
				uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NCL_MATRIX);
 
				if (id_v >= this->content.Length()) return; // click out of bounds
 

	
 
				this->selected = *this->content.Get(id_v);
 
				this->list_pos = id_v;
 

	
 
				const NWidgetBase *checkbox = this->GetWidget<NWidgetBase>(NCLWW_CHECKBOX);
 
				const NWidgetBase *checkbox = this->GetWidget<NWidgetBase>(WID_NCL_CHECKBOX);
 
				if (click_count > 1 || IsInsideBS(pt.x, checkbox->pos_x, checkbox->current_x)) {
 
					_network_content_client.ToggleSelectedState(this->selected);
 
					this->content.ForceResort();
 
				}
 

	
 
				this->InvalidateData();
 
				break;
 
			}
 

	
 
			case NCLWW_CHECKBOX:
 
			case NCLWW_TYPE:
 
			case NCLWW_NAME:
 
				if (this->content.SortType() == widget - NCLWW_CHECKBOX) {
 
			case WID_NCL_CHECKBOX:
 
			case WID_NCL_TYPE:
 
			case WID_NCL_NAME:
 
				if (this->content.SortType() == widget - WID_NCL_CHECKBOX) {
 
					this->content.ToggleSortOrder();
 
					this->list_pos = this->content.Length() - this->list_pos - 1;
 
				} else {
 
					this->content.SetSortType(widget - NCLWW_CHECKBOX);
 
					this->content.SetSortType(widget - WID_NCL_CHECKBOX);
 
					this->content.ForceResort();
 
					this->SortContentList();
 
				}
 
				this->ScrollToSelected();
 
				this->InvalidateData();
 
				break;
 

	
 
			case NCLWW_SELECT_ALL:
 
			case WID_NCL_SELECT_ALL:
 
				_network_content_client.SelectAll();
 
				this->InvalidateData();
 
				break;
 

	
 
			case NCLWW_SELECT_UPDATE:
 
			case WID_NCL_SELECT_UPDATE:
 
				_network_content_client.SelectUpgrade();
 
				this->InvalidateData();
 
				break;
 

	
 
			case NCLWW_UNSELECT:
 
			case WID_NCL_UNSELECT:
 
				_network_content_client.UnselectAll();
 
				this->InvalidateData();
 
				break;
 

	
 
			case NCLWW_CANCEL:
 
			case WID_NCL_CANCEL:
 
				delete this;
 
				break;
 

	
 
			case NCLWW_OPEN_URL:
 
			case WID_NCL_OPEN_URL:
 
				if (this->selected != NULL) {
 
					extern void OpenBrowser(const char *url);
 
					OpenBrowser(this->selected->url);
 
				}
 
				break;
 

	
 
			case NCLWW_DOWNLOAD:
 
			case WID_NCL_DOWNLOAD:
 
				if (BringWindowToFrontById(WC_NETWORK_STATUS_WINDOW, 0) == NULL) new NetworkContentDownloadStatusWindow();
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnMouseLoop()
 
	{
 
		this->HandleEditBox(NCLWW_FILTER);
 
		this->HandleEditBox(WID_NCL_FILTER);
 
	}
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		switch (keycode) {
 
			case WKC_UP:
 
				/* scroll up by one */
 
				if (this->list_pos > 0) this->list_pos--;
 
				break;
 
			case WKC_DOWN:
 
				/* scroll down by one */
 
				if (this->list_pos < (int)this->content.Length() - 1) this->list_pos++;
 
@@ -689,39 +689,39 @@ public:
 
				break;
 
			case WKC_HOME:
 
				/* jump to beginning */
 
				this->list_pos = 0;
 
				break;
 
			case WKC_END:
 
				/* jump to end */
 
				this->list_pos = this->content.Length() - 1;
 
				break;
 

	
 
			case WKC_SPACE:
 
			case WKC_RETURN:
 
				if (keycode == WKC_RETURN || !IsWidgetFocused(NCLWW_FILTER)) {
 
				if (keycode == WKC_RETURN || !IsWidgetFocused(WID_NCL_FILTER)) {
 
					if (this->selected != NULL) {
 
						_network_content_client.ToggleSelectedState(this->selected);
 
						this->content.ForceResort();
 
						this->InvalidateData();
 
					}
 
					return ES_HANDLED;
 
				}
 
				/* FALL THROUGH, space is pressed and filter isn't focused. */
 

	
 
			default: {
 
				/* Handle editbox input */
 
				EventState state = ES_NOT_HANDLED;
 
				if (this->HandleEditBoxKey(NCLWW_FILTER, key, keycode, state) == HEBR_EDITING) {
 
					this->OnOSKInput(NCLWW_FILTER);
 
				if (this->HandleEditBoxKey(WID_NCL_FILTER, key, keycode, state) == HEBR_EDITING) {
 
					this->OnOSKInput(WID_NCL_FILTER);
 
				}
 

	
 
				return state;
 
			}
 
		}
 

	
 
		if (_network_content_client.Length() == 0) return ES_HANDLED;
 

	
 
		this->selected = *this->content.Get(this->list_pos);
 

	
 
		/* scroll to the new server if it is outside the current range */
 
		this->ScrollToSelected();
 
@@ -731,26 +731,26 @@ public:
 
		return ES_HANDLED;
 
	}
 

	
 
	virtual void OnOSKInput(int wid)
 
	{
 
		this->content.SetFilterState(!StrEmpty(this->edit_str_buf));
 
		this->content.ForceRebuild();
 
		this->InvalidateData();
 
	}
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, NCLWW_MATRIX);
 
		this->GetWidget<NWidgetCore>(NCLWW_MATRIX)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
		this->vscroll->SetCapacityFromWidget(this, WID_NCL_MATRIX);
 
		this->GetWidget<NWidgetCore>(WID_NCL_MATRIX)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 

	
 
	virtual void OnReceiveContentInfo(const ContentInfo *rci)
 
	{
 
		if (this->auto_select && !rci->IsSelected()) _network_content_client.ToggleSelectedState(rci);
 
		this->content.ForceRebuild();
 
		this->InvalidateData();
 
	}
 

	
 
	virtual void OnDownloadComplete(ContentID cid)
 
	{
 
		this->content.ForceResort();
 
@@ -792,103 +792,103 @@ public:
 

	
 
				case ContentInfo::UNSELECTED:
 
					show_select_all = true;
 
					show_select_upgrade |= ci->upgrade;
 
					break;
 

	
 
				default:
 
					break;
 
			}
 
		}
 

	
 
		/* If data == 2 then the status window caused this OnInvalidate */
 
		this->SetWidgetDisabledState(NCLWW_DOWNLOAD, this->filesize_sum == 0 || (FindWindowById(WC_NETWORK_STATUS_WINDOW, 0) != NULL && data != 2));
 
		this->SetWidgetDisabledState(NCLWW_UNSELECT, this->filesize_sum == 0);
 
		this->SetWidgetDisabledState(NCLWW_SELECT_ALL, !show_select_all);
 
		this->SetWidgetDisabledState(NCLWW_SELECT_UPDATE, !show_select_upgrade);
 
		this->SetWidgetDisabledState(NCLWW_OPEN_URL, this->selected == NULL || StrEmpty(this->selected->url));
 
		this->SetWidgetDisabledState(WID_NCL_DOWNLOAD, this->filesize_sum == 0 || (FindWindowById(WC_NETWORK_STATUS_WINDOW, 0) != 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);
 
		this->SetWidgetDisabledState(WID_NCL_OPEN_URL, this->selected == NULL || StrEmpty(this->selected->url));
 

	
 
		this->GetWidget<NWidgetCore>(NCLWW_CANCEL)->widget_data = this->filesize_sum == 0 ? STR_AI_SETTINGS_CLOSE : STR_AI_LIST_CANCEL;
 
		this->GetWidget<NWidgetCore>(WID_NCL_CANCEL)->widget_data = this->filesize_sum == 0 ? STR_AI_SETTINGS_CLOSE : STR_AI_LIST_CANCEL;
 
	}
 
};
 

	
 
Listing NetworkContentListWindow::last_sorting = {false, 1};
 
Filtering NetworkContentListWindow::last_filtering = {false, 0};
 

	
 
NetworkContentListWindow::GUIContentList::SortFunction * const NetworkContentListWindow::sorter_funcs[] = {
 
	&StateSorter,
 
	&TypeSorter,
 
	&NameSorter,
 
};
 

	
 
NetworkContentListWindow::GUIContentList::FilterFunction * const NetworkContentListWindow::filter_funcs[] = {
 
	&TagNameFilter,
 
};
 

	
 
/** The widgets for the content list. */
 
static const NWidgetPart _nested_network_content_list_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE),
 
		NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_CONTENT_TITLE, STR_NULL),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, NCLWW_BACKGROUND),
 
	NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NCL_BACKGROUND),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 7), SetResize(1, 0),
 
		NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(8, 8, 8),
 
			/* Top */
 
			NWidget(WWT_EMPTY, COLOUR_LIGHT_BLUE, NCLWW_FILTER_CAPT), SetFill(1, 0), SetResize(1, 0),
 
			NWidget(WWT_EDITBOX, COLOUR_LIGHT_BLUE, NCLWW_FILTER), SetFill(1, 0), SetResize(1, 0),
 
			NWidget(WWT_EMPTY, COLOUR_LIGHT_BLUE, WID_NCL_FILTER_CAPT), SetFill(1, 0), SetResize(1, 0),
 
			NWidget(WWT_EDITBOX, COLOUR_LIGHT_BLUE, WID_NCL_FILTER), SetFill(1, 0), SetResize(1, 0),
 
						SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
 
		EndContainer(),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 7), SetResize(1, 0),
 
		NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(8, 8, 8),
 
			/* Left side. */
 
			NWidget(NWID_VERTICAL),
 
				NWidget(NWID_HORIZONTAL),
 
					NWidget(NWID_VERTICAL),
 
						NWidget(NWID_HORIZONTAL),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NCLWW_CHECKBOX), SetMinimalSize(13, 1), SetDataTip(STR_EMPTY, STR_NULL),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NCLWW_TYPE),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_CHECKBOX), SetMinimalSize(13, 1), SetDataTip(STR_EMPTY, STR_NULL),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_TYPE),
 
											SetDataTip(STR_CONTENT_TYPE_CAPTION, STR_CONTENT_TYPE_CAPTION_TOOLTIP),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NCLWW_NAME), SetResize(1, 0), SetFill(1, 0),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_NAME), SetResize(1, 0), SetFill(1, 0),
 
											SetDataTip(STR_CONTENT_NAME_CAPTION, STR_CONTENT_NAME_CAPTION_TOOLTIP),
 
						EndContainer(),
 
						NWidget(WWT_MATRIX, COLOUR_LIGHT_BLUE, NCLWW_MATRIX), SetResize(1, 14), SetFill(1, 1), SetScrollbar(NCLWW_SCROLLBAR), SetDataTip(STR_NULL, STR_CONTENT_MATRIX_TOOLTIP),
 
						NWidget(WWT_MATRIX, COLOUR_LIGHT_BLUE, WID_NCL_MATRIX), SetResize(1, 14), SetFill(1, 1), SetScrollbar(WID_NCL_SCROLLBAR), SetDataTip(STR_NULL, STR_CONTENT_MATRIX_TOOLTIP),
 
					EndContainer(),
 
					NWidget(NWID_VSCROLLBAR, COLOUR_LIGHT_BLUE, NCLWW_SCROLLBAR),
 
					NWidget(NWID_VSCROLLBAR, COLOUR_LIGHT_BLUE, WID_NCL_SCROLLBAR),
 
				EndContainer(),
 
			EndContainer(),
 
			/* Right side. */
 
			NWidget(NWID_VERTICAL),
 
				NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, NCLWW_DETAILS), SetResize(1, 1), SetFill(1, 1), EndContainer(),
 
				NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NCL_DETAILS), SetResize(1, 1), SetFill(1, 1), EndContainer(),
 
			EndContainer(),
 
		EndContainer(),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 7), SetResize(1, 0),
 
		/* Bottom. */
 
		NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(8, 8, 8),
 
			NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(8, 8, 8),
 
				NWidget(NWID_SELECTION, INVALID_COLOUR, NCLWW_SEL_ALL_UPDATE), SetResize(1, 0), SetFill(1, 0),
 
					NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NCLWW_SELECT_UPDATE), SetResize(1, 0), SetFill(1, 0),
 
				NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NCL_SEL_ALL_UPDATE), SetResize(1, 0), SetFill(1, 0),
 
					NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_SELECT_UPDATE), SetResize(1, 0), SetFill(1, 0),
 
											SetDataTip(STR_CONTENT_SELECT_UPDATES_CAPTION, STR_CONTENT_SELECT_UPDATES_CAPTION_TOOLTIP),
 
					NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NCLWW_SELECT_ALL), SetResize(1, 0), SetFill(1, 0),
 
					NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_SELECT_ALL), SetResize(1, 0), SetFill(1, 0),
 
											SetDataTip(STR_CONTENT_SELECT_ALL_CAPTION, STR_CONTENT_SELECT_ALL_CAPTION_TOOLTIP),
 
				EndContainer(),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NCLWW_UNSELECT), SetResize(1, 0), SetFill(1, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_UNSELECT), SetResize(1, 0), SetFill(1, 0),
 
											SetDataTip(STR_CONTENT_UNSELECT_ALL_CAPTION, STR_CONTENT_UNSELECT_ALL_CAPTION_TOOLTIP),
 
			EndContainer(),
 
			NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(8, 8, 8),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NCLWW_OPEN_URL), SetResize(1, 0), SetFill(1, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_OPEN_URL), SetResize(1, 0), SetFill(1, 0),
 
											SetDataTip(STR_CONTENT_OPEN_URL, STR_CONTENT_OPEN_URL_TOOLTIP),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NCLWW_CANCEL), SetResize(1, 0), SetFill(1, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_CANCEL), SetResize(1, 0), SetFill(1, 0),
 
											SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NCLWW_DOWNLOAD), SetResize(1, 0), SetFill(1, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NCL_DOWNLOAD), SetResize(1, 0), SetFill(1, 0),
 
											SetDataTip(STR_CONTENT_DOWNLOAD_CAPTION, STR_CONTENT_DOWNLOAD_CAPTION_TOOLTIP),
 
			EndContainer(),
 
		EndContainer(),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 2), SetResize(1, 0),
 
		/* Resize button. */
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
 
			NWidget(WWT_RESIZEBOX, COLOUR_LIGHT_BLUE),
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
src/network/network_gui.cpp
Show inline comments
 
@@ -79,48 +79,48 @@ void UpdateNetworkGameWindow(bool unsele
 

	
 
typedef GUIList<NetworkGameList*> GUIGameServerList;
 
typedef uint16 ServerListPosition;
 
static const ServerListPosition SLP_INVALID = 0xFFFF;
 

	
 
/** Full blown container to make it behave exactly as we want :) */
 
class NWidgetServerListHeader : public NWidgetContainer {
 
	static const uint MINIMUM_NAME_WIDTH_BEFORE_NEW_HEADER = 150; ///< Minimum width before adding a new header
 
	bool visible[6]; ///< The visible headers
 
public:
 
	NWidgetServerListHeader() : NWidgetContainer(NWID_HORIZONTAL)
 
	{
 
		NWidgetLeaf *leaf = new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, NGWW_NAME, STR_NETWORK_SERVER_LIST_GAME_NAME, STR_NETWORK_SERVER_LIST_GAME_NAME_TOOLTIP);
 
		NWidgetLeaf *leaf = new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_NAME, STR_NETWORK_SERVER_LIST_GAME_NAME, STR_NETWORK_SERVER_LIST_GAME_NAME_TOOLTIP);
 
		leaf->SetResize(1, 0);
 
		leaf->SetFill(1, 0);
 
		this->Add(leaf);
 

	
 
		this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, NGWW_CLIENTS, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION_TOOLTIP));
 
		this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, NGWW_MAPSIZE, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION_TOOLTIP));
 
		this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, NGWW_DATE, STR_NETWORK_SERVER_LIST_DATE_CAPTION, STR_NETWORK_SERVER_LIST_DATE_CAPTION_TOOLTIP));
 
		this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, NGWW_YEARS, STR_NETWORK_SERVER_LIST_YEARS_CAPTION, STR_NETWORK_SERVER_LIST_YEARS_CAPTION_TOOLTIP));
 
		this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_CLIENTS, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION_TOOLTIP));
 
		this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_MAPSIZE, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION_TOOLTIP));
 
		this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_DATE, STR_NETWORK_SERVER_LIST_DATE_CAPTION, STR_NETWORK_SERVER_LIST_DATE_CAPTION_TOOLTIP));
 
		this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_YEARS, STR_NETWORK_SERVER_LIST_YEARS_CAPTION, STR_NETWORK_SERVER_LIST_YEARS_CAPTION_TOOLTIP));
 

	
 
		leaf = new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, NGWW_INFO, STR_EMPTY, STR_NETWORK_SERVER_LIST_INFO_ICONS_TOOLTIP);
 
		leaf = new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_INFO, STR_EMPTY, STR_NETWORK_SERVER_LIST_INFO_ICONS_TOOLTIP);
 
		leaf->SetMinimalSize(40, 12);
 
		leaf->SetFill(0, 1);
 
		this->Add(leaf);
 

	
 
		/* First and last are always visible, the rest is implicitly zeroed */
 
		this->visible[0] = true;
 
		*lastof(this->visible) = true;
 
	}
 

	
 
	void SetupSmallestSize(Window *w, bool init_array)
 
	{
 
		/* Oh yeah, we ought to be findable! */
 
		w->nested_array[NGWW_HEADER] = this;
 
		w->nested_array[WID_NG_HEADER] = this;
 

	
 
		this->smallest_x = this->head->smallest_x + this->tail->smallest_x; // First and last are always shown, rest not
 
		this->smallest_y = 0; // Biggest child.
 
		this->fill_x = 1;
 
		this->fill_y = 0;
 
		this->resize_x = 1; // We only resize in this direction
 
		this->resize_y = 0; // We never resize in this direction
 

	
 
		/* First initialise some variables... */
 
		for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
 
			child_wid->SetupSmallestSize(w, init_array);
 
			this->smallest_y = max(this->smallest_y, child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom);
 
@@ -192,28 +192,28 @@ public:
 
			if (!this->visible[i++]) continue;
 
			NWidgetCore *nwid = child_wid->GetWidgetFromPos(x, y);
 
			if (nwid != NULL) return nwid;
 
		}
 
		return NULL;
 
	}
 

	
 
	/**
 
	 * Checks whether the given widget is actually visible.
 
	 * @param widget the widget to check for visibility
 
	 * @return true iff the widget is visible.
 
	 */
 
	bool IsWidgetVisible(NetworkGameWindowWidgets widget) const
 
	bool IsWidgetVisible(NetworkGameWidgets widget) const
 
	{
 
		assert((uint)(widget - NGWW_NAME) < lengthof(this->visible));
 
		return this->visible[widget - NGWW_NAME];
 
		assert((uint)(widget - WID_NG_NAME) < lengthof(this->visible));
 
		return this->visible[widget - WID_NG_NAME];
 
	}
 
};
 

	
 
class NetworkGameWindow : public QueryStringBaseWindow {
 
protected:
 
	/* Runtime saved values */
 
	static Listing last_sorting;
 

	
 
	/* Constants for sorting servers */
 
	static GUIGameServerList::SortFunction * const sorter_funcs[];
 

	
 
	byte field;                   ///< selected text-field
 
@@ -336,65 +336,65 @@ protected:
 
		}
 
		item->next = NULL;
 
	}
 

	
 
	/**
 
	 * Draw a single server line.
 
	 * @param cur_item  the server to draw.
 
	 * @param y         from where to draw?
 
	 * @param highlight does the line need to be highlighted?
 
	 */
 
	void DrawServerLine(const NetworkGameList *cur_item, uint y, bool highlight) const
 
	{
 
		const NWidgetBase *nwi_name = this->GetWidget<NWidgetBase>(NGWW_NAME);
 
		const NWidgetBase *nwi_info = this->GetWidget<NWidgetBase>(NGWW_INFO);
 
		const NWidgetBase *nwi_name = this->GetWidget<NWidgetBase>(WID_NG_NAME);
 
		const NWidgetBase *nwi_info = this->GetWidget<NWidgetBase>(WID_NG_INFO);
 

	
 
		/* show highlighted item with a different colour */
 
		if (highlight) GfxFillRect(nwi_name->pos_x + 1, y - 2, nwi_info->pos_x + nwi_info->current_x - 2, y + FONT_HEIGHT_NORMAL - 1, PC_GREY);
 

	
 
		DrawString(nwi_name->pos_x + WD_FRAMERECT_LEFT, nwi_name->pos_x + nwi_name->current_x - WD_FRAMERECT_RIGHT, y, cur_item->info.server_name, TC_BLACK);
 

	
 
		/* only draw details if the server is online */
 
		if (cur_item->online) {
 
			const NWidgetServerListHeader *nwi_header = this->GetWidget<NWidgetServerListHeader>(NGWW_HEADER);
 
			const NWidgetServerListHeader *nwi_header = this->GetWidget<NWidgetServerListHeader>(WID_NG_HEADER);
 

	
 
			if (nwi_header->IsWidgetVisible(NGWW_CLIENTS)) {
 
				const NWidgetBase *nwi_clients = this->GetWidget<NWidgetBase>(NGWW_CLIENTS);
 
			if (nwi_header->IsWidgetVisible(WID_NG_CLIENTS)) {
 
				const NWidgetBase *nwi_clients = this->GetWidget<NWidgetBase>(WID_NG_CLIENTS);
 
				SetDParam(0, cur_item->info.clients_on);
 
				SetDParam(1, cur_item->info.clients_max);
 
				SetDParam(2, cur_item->info.companies_on);
 
				SetDParam(3, cur_item->info.companies_max);
 
				DrawString(nwi_clients->pos_x, nwi_clients->pos_x + nwi_clients->current_x - 1, y, STR_NETWORK_SERVER_LIST_GENERAL_ONLINE, TC_FROMSTRING, SA_HOR_CENTER);
 
			}
 

	
 
			if (nwi_header->IsWidgetVisible(NGWW_MAPSIZE)) {
 
			if (nwi_header->IsWidgetVisible(WID_NG_MAPSIZE)) {
 
				/* map size */
 
				const NWidgetBase *nwi_mapsize = this->GetWidget<NWidgetBase>(NGWW_MAPSIZE);
 
				const NWidgetBase *nwi_mapsize = this->GetWidget<NWidgetBase>(WID_NG_MAPSIZE);
 
				SetDParam(0, cur_item->info.map_width);
 
				SetDParam(1, cur_item->info.map_height);
 
				DrawString(nwi_mapsize->pos_x, nwi_mapsize->pos_x + nwi_mapsize->current_x - 1, y, STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT, TC_FROMSTRING, SA_HOR_CENTER);
 
			}
 

	
 
			if (nwi_header->IsWidgetVisible(NGWW_DATE)) {
 
			if (nwi_header->IsWidgetVisible(WID_NG_DATE)) {
 
				/* current date */
 
				const NWidgetBase *nwi_date = this->GetWidget<NWidgetBase>(NGWW_DATE);
 
				const NWidgetBase *nwi_date = this->GetWidget<NWidgetBase>(WID_NG_DATE);
 
				YearMonthDay ymd;
 
				ConvertDateToYMD(cur_item->info.game_date, &ymd);
 
				SetDParam(0, ymd.year);
 
				DrawString(nwi_date->pos_x, nwi_date->pos_x + nwi_date->current_x - 1, y, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER);
 
			}
 

	
 
			if (nwi_header->IsWidgetVisible(NGWW_YEARS)) {
 
			if (nwi_header->IsWidgetVisible(WID_NG_YEARS)) {
 
				/* number of years the game is running */
 
				const NWidgetBase *nwi_years = this->GetWidget<NWidgetBase>(NGWW_YEARS);
 
				const NWidgetBase *nwi_years = this->GetWidget<NWidgetBase>(WID_NG_YEARS);
 
				YearMonthDay ymd_cur, ymd_start;
 
				ConvertDateToYMD(cur_item->info.game_date, &ymd_cur);
 
				ConvertDateToYMD(cur_item->info.start_date, &ymd_start);
 
				SetDParam(0, ymd_cur.year - ymd_start.year);
 
				DrawString(nwi_years->pos_x, nwi_years->pos_x + nwi_years->current_x - 1, y, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER);
 
			}
 

	
 
			/* Align the sprites */
 
			y += (FONT_HEIGHT_NORMAL - 10) / 2;
 

	
 
			/* draw a lock if the server is password protected */
 
			if (cur_item->info.use_password) DrawSprite(SPR_LOCK, PAL_NONE, nwi_info->pos_x + 5, y - 1);
 
@@ -415,173 +415,173 @@ protected:
 
	 * scroll up so that the server appears at the top.
 
	 */
 
	void ScrollToSelectedServer()
 
	{
 
		if (this->list_pos == SLP_INVALID) return; // no server selected
 
		this->vscroll->ScrollTowards(this->list_pos);
 
	}
 

	
 
public:
 
	NetworkGameWindow(const WindowDesc *desc) : QueryStringBaseWindow(NETWORK_CLIENT_NAME_LENGTH)
 
	{
 
		this->CreateNestedTree(desc);
 
		this->vscroll = this->GetScrollbar(NGWW_SCROLLBAR);
 
		this->vscroll = this->GetScrollbar(WID_NG_SCROLLBAR);
 
		this->FinishInitNested(desc, 0);
 

	
 
		ttd_strlcpy(this->edit_str_buf, _settings_client.network.client_name, this->edit_str_size);
 
		this->afilter = CS_ALPHANUMERAL;
 
		InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, 120);
 
		this->SetFocusedWidget(NGWW_CLIENT);
 
		this->SetFocusedWidget(WID_NG_CLIENT);
 

	
 
		UpdateNetworkGameWindow(true);
 

	
 
		this->field = NGWW_CLIENT;
 
		this->field = WID_NG_CLIENT;
 
		this->last_joined = NetworkGameListAddItem(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port));
 
		this->server = this->last_joined;
 

	
 
		this->servers.SetListing(this->last_sorting);
 
		this->servers.SetSortFuncs(this->sorter_funcs);
 
		this->servers.ForceRebuild();
 
		this->SortNetworkGameList();
 
	}
 

	
 
	~NetworkGameWindow()
 
	{
 
		this->last_sorting = this->servers.GetListing();
 
	}
 

	
 
	virtual void SetStringParameters(int widget) const
 
	{
 
		switch (widget) {
 
			case NGWW_CONN_BTN:
 
			case WID_NG_CONN_BTN:
 
				SetDParam(0, _lan_internet_types_dropdown[_settings_client.network.lan_internet]);
 
				break;
 
		}
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		switch (widget) {
 
			case NGWW_CONN_BTN:
 
			case WID_NG_CONN_BTN:
 
				*size = maxdim(GetStringBoundingBox(_lan_internet_types_dropdown[0]), GetStringBoundingBox(_lan_internet_types_dropdown[1]));
 
				size->width += padding.width;
 
				size->height += padding.height;
 
				break;
 

	
 
			case NGWW_MATRIX:
 
			case WID_NG_MATRIX:
 
				resize->height = WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM;
 
				size->height = 10 * resize->height;
 
				break;
 

	
 
			case NGWW_LASTJOINED:
 
			case WID_NG_LASTJOINED:
 
				size->height = WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM;
 
				break;
 

	
 
			case NGWW_LASTJOINED_SPACER:
 
			case WID_NG_LASTJOINED_SPACER:
 
				size->width = NWidgetScrollbar::GetVerticalDimension().width;
 
				break;
 

	
 
			case NGWW_NAME:
 
			case WID_NG_NAME:
 
				size->width += 2 * WD_SORTBUTTON_ARROW_WIDTH; // Make space for the arrow
 
				break;
 

	
 
			case NGWW_CLIENTS:
 
			case WID_NG_CLIENTS:
 
				size->width += 2 * WD_SORTBUTTON_ARROW_WIDTH; // Make space for the arrow
 
				SetDParam(0, 255);
 
				SetDParam(1, 255);
 
				SetDParam(2, 15);
 
				SetDParam(3, 15);
 
				*size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_GENERAL_ONLINE));
 
				break;
 

	
 
			case NGWW_MAPSIZE:
 
			case WID_NG_MAPSIZE:
 
				size->width += 2 * WD_SORTBUTTON_ARROW_WIDTH; // Make space for the arrow
 
				SetDParam(0, 2048);
 
				SetDParam(1, 2048);
 
				*size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT));
 
				break;
 

	
 
			case NGWW_DATE:
 
			case NGWW_YEARS:
 
			case WID_NG_DATE:
 
			case WID_NG_YEARS:
 
				size->width += 2 * WD_SORTBUTTON_ARROW_WIDTH; // Make space for the arrow
 
				SetDParam(0, 99999);
 
				*size = maxdim(*size, GetStringBoundingBox(STR_JUST_INT));
 
				break;
 

	
 
			case NGWW_DETAILS_SPACER:
 
			case WID_NG_DETAILS_SPACER:
 
				size->height = 20 + 12 * FONT_HEIGHT_NORMAL;
 
				break;
 
		}
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		switch (widget) {
 
			case NGWW_MATRIX: {
 
			case WID_NG_MATRIX: {
 
				uint16 y = r.top + WD_MATRIX_TOP;
 

	
 
				const int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (int)this->servers.Length());
 

	
 
				for (int i = this->vscroll->GetPosition(); i < max; ++i) {
 
					const NetworkGameList *ngl = this->servers[i];
 
					this->DrawServerLine(ngl, y, ngl == this->server);
 
					y += this->resize.step_height;
 
				}
 
				break;
 
			}
 

	
 
			case NGWW_LASTJOINED:
 
			case WID_NG_LASTJOINED:
 
				/* Draw the last joined server, if any */
 
				if (this->last_joined != NULL) this->DrawServerLine(this->last_joined, r.top + WD_MATRIX_TOP, this->last_joined == this->server);
 
				break;
 

	
 
			case NGWW_DETAILS:
 
			case WID_NG_DETAILS:
 
				this->DrawDetails(r);
 
				break;
 

	
 
			case NGWW_NAME:
 
			case NGWW_CLIENTS:
 
			case NGWW_MAPSIZE:
 
			case NGWW_DATE:
 
			case NGWW_YEARS:
 
			case NGWW_INFO:
 
				if (widget - NGWW_NAME == this->servers.SortType()) this->DrawSortButtonState(widget, this->servers.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
 
			case WID_NG_NAME:
 
			case WID_NG_CLIENTS:
 
			case WID_NG_MAPSIZE:
 
			case WID_NG_DATE:
 
			case WID_NG_YEARS:
 
			case WID_NG_INFO:
 
				if (widget - WID_NG_NAME == this->servers.SortType()) this->DrawSortButtonState(widget, this->servers.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
 
				break;
 
		}
 
	}
 

	
 

	
 
	virtual void OnPaint()
 
	{
 
		if (this->servers.NeedRebuild()) {
 
			this->BuildNetworkGameList();
 
		}
 
		this->SortNetworkGameList();
 

	
 
		NetworkGameList *sel = this->server;
 
		/* 'Refresh' button invisible if no server selected */
 
		this->SetWidgetDisabledState(NGWW_REFRESH, sel == NULL);
 
		this->SetWidgetDisabledState(WID_NG_REFRESH, sel == NULL);
 
		/* 'Join' button disabling conditions */
 
		this->SetWidgetDisabledState(NGWW_JOIN, sel == NULL || // no Selected Server
 
		this->SetWidgetDisabledState(WID_NG_JOIN, sel == NULL || // no Selected Server
 
				!sel->online || // Server offline
 
				sel->info.clients_on >= sel->info.clients_max || // Server full
 
				!sel->info.compatible); // Revision mismatch
 

	
 
		/* 'NewGRF Settings' button invisible if no NewGRF is used */
 
		this->GetWidget<NWidgetStacked>(NGWW_NEWGRF_SEL)->SetDisplayedPlane(sel == NULL || !sel->online || sel->info.grfconfig == NULL);
 
		this->GetWidget<NWidgetStacked>(NGWW_NEWGRF_MISSING_SEL)->SetDisplayedPlane(sel == NULL || !sel->online || sel->info.grfconfig == NULL || !sel->info.version_compatible || sel->info.compatible);
 
		this->GetWidget<NWidgetStacked>(WID_NG_NEWGRF_SEL)->SetDisplayedPlane(sel == NULL || !sel->online || sel->info.grfconfig == NULL);
 
		this->GetWidget<NWidgetStacked>(WID_NG_NEWGRF_MISSING_SEL)->SetDisplayedPlane(sel == NULL || !sel->online || sel->info.grfconfig == NULL || !sel->info.version_compatible || sel->info.compatible);
 

	
 
		this->DrawWidgets();
 
		/* Edit box to set client name */
 
		this->DrawEditBox(NGWW_CLIENT);
 
		this->DrawEditBox(WID_NG_CLIENT);
 
	}
 

	
 
	void DrawDetails(const Rect &r) const
 
	{
 
		NetworkGameList *sel = this->server;
 

	
 
		const int detail_height = 6 + 8 + 6 + 3 * FONT_HEIGHT_NORMAL;
 

	
 
		/* Draw the right menu */
 
		GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.top + detail_height - 1, PC_DARK_BLUE);
 
		if (sel == NULL) {
 
			DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + 6 + 4 + FONT_HEIGHT_NORMAL, STR_NETWORK_SERVER_LIST_GAME_INFO, TC_FROMSTRING, SA_HOR_CENTER);
 
@@ -641,140 +641,140 @@ public:
 
				/* Show: server full, when clients_on == max_clients */
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_SERVER_FULL, TC_FROMSTRING, SA_HOR_CENTER); // server full
 
			} else if (sel->info.use_password) {
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_PASSWORD, TC_FROMSTRING, SA_HOR_CENTER); // password warning
 
			}
 
		}
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		this->field = widget;
 
		switch (widget) {
 
			case NGWW_CANCEL: // Cancel button
 
			case WID_NG_CANCEL: // Cancel button
 
				DeleteWindowById(WC_NETWORK_WINDOW, 0);
 
				break;
 

	
 
			case NGWW_CONN_BTN: // 'Connection' droplist
 
				ShowDropDownMenu(this, _lan_internet_types_dropdown, _settings_client.network.lan_internet, NGWW_CONN_BTN, 0, 0); // do it for widget NSSW_CONN_BTN
 
			case WID_NG_CONN_BTN: // 'Connection' droplist
 
				ShowDropDownMenu(this, _lan_internet_types_dropdown, _settings_client.network.lan_internet, WID_NG_CONN_BTN, 0, 0); // do it for widget WID_NSS_CONN_BTN
 
				break;
 

	
 
			case NGWW_NAME:    // Sort by name
 
			case NGWW_CLIENTS: // Sort by connected clients
 
			case NGWW_MAPSIZE: // Sort by map size
 
			case NGWW_DATE:    // Sort by date
 
			case NGWW_YEARS:   // Sort by years
 
			case NGWW_INFO:    // Connectivity (green dot)
 
				if (this->servers.SortType() == widget - NGWW_NAME) {
 
			case WID_NG_NAME:    // Sort by name
 
			case WID_NG_CLIENTS: // Sort by connected clients
 
			case WID_NG_MAPSIZE: // Sort by map size
 
			case WID_NG_DATE:    // Sort by date
 
			case WID_NG_YEARS:   // Sort by years
 
			case WID_NG_INFO:    // Connectivity (green dot)
 
				if (this->servers.SortType() == widget - WID_NG_NAME) {
 
					this->servers.ToggleSortOrder();
 
					if (this->list_pos != SLP_INVALID) this->list_pos = this->servers.Length() - this->list_pos - 1;
 
				} else {
 
					this->servers.SetSortType(widget - NGWW_NAME);
 
					this->servers.SetSortType(widget - WID_NG_NAME);
 
					this->servers.ForceResort();
 
					this->SortNetworkGameList();
 
				}
 
				this->ScrollToSelectedServer();
 
				this->SetDirty();
 
				break;
 

	
 
			case NGWW_MATRIX: { // Matrix to show networkgames
 
				uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, NGWW_MATRIX);
 
			case WID_NG_MATRIX: { // Matrix to show networkgames
 
				uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NG_MATRIX);
 
				this->server = (id_v < this->servers.Length()) ? this->servers[id_v] : NULL;
 
				this->list_pos = (server == NULL) ? SLP_INVALID : id_v;
 
				this->SetDirty();
 

	
 
				/* FIXME the disabling should go into some InvalidateData, which is called instead of the SetDirty */
 
				if (click_count > 1 && !this->IsWidgetDisabled(NGWW_JOIN)) this->OnClick(pt, NGWW_JOIN, 1);
 
				if (click_count > 1 && !this->IsWidgetDisabled(WID_NG_JOIN)) this->OnClick(pt, WID_NG_JOIN, 1);
 
				break;
 
			}
 

	
 
			case NGWW_LASTJOINED: {
 
			case WID_NG_LASTJOINED: {
 
				if (this->last_joined != NULL) {
 
					this->server = this->last_joined;
 

	
 
					/* search the position of the newly selected server */
 
					for (uint i = 0; i < this->servers.Length(); i++) {
 
						if (this->servers[i] == this->server) {
 
							this->list_pos = i;
 
							break;
 
						}
 
					}
 
					this->ScrollToSelectedServer();
 
					this->SetDirty();
 

	
 
					/* FIXME the disabling should go into some InvalidateData, which is called instead of the SetDirty */
 
					if (click_count > 1 && !this->IsWidgetDisabled(NGWW_JOIN)) this->OnClick(pt, NGWW_JOIN, 1);
 
					if (click_count > 1 && !this->IsWidgetDisabled(WID_NG_JOIN)) this->OnClick(pt, WID_NG_JOIN, 1);
 
				}
 
				break;
 
			}
 

	
 
			case NGWW_FIND: // Find server automatically
 
			case WID_NG_FIND: // Find server automatically
 
				switch (_settings_client.network.lan_internet) {
 
					case 0: NetworkUDPSearchGame(); break;
 
					case 1: NetworkUDPQueryMasterServer(); break;
 
				}
 
				break;
 

	
 
			case NGWW_ADD: // Add a server
 
			case WID_NG_ADD: // Add a server
 
				SetDParamStr(0, _settings_client.network.connect_to_ip);
 
				ShowQueryString(
 
					STR_JUST_RAW_STRING,
 
					STR_NETWORK_SERVER_LIST_ENTER_IP,
 
					NETWORK_HOSTNAME_LENGTH,  // maximum number of characters including '\0'
 
					this, CS_ALPHANUMERAL, QSF_ACCEPT_UNCHANGED);
 
				break;
 

	
 
			case NGWW_START: // Start server
 
			case WID_NG_START: // Start server
 
				ShowNetworkStartServerWindow();
 
				break;
 

	
 
			case NGWW_JOIN: // Join Game
 
			case WID_NG_JOIN: // Join Game
 
				if (this->server != NULL) {
 
					snprintf(_settings_client.network.last_host, sizeof(_settings_client.network.last_host), "%s", this->server->address.GetHostname());
 
					_settings_client.network.last_port = this->server->address.GetPort();
 
					ShowNetworkLobbyWindow(this->server);
 
				}
 
				break;
 

	
 
			case NGWW_REFRESH: // Refresh
 
			case WID_NG_REFRESH: // Refresh
 
				if (this->server != NULL) NetworkUDPQueryServer(this->server->address);
 
				break;
 

	
 
			case NGWW_NEWGRF: // NewGRF Settings
 
			case WID_NG_NEWGRF: // NewGRF Settings
 
				if (this->server != NULL) ShowNewGRFSettings(false, false, false, &this->server->info.grfconfig);
 
				break;
 

	
 
			case NGWW_NEWGRF_MISSING: // Find missing content online
 
			case WID_NG_NEWGRF_MISSING: // Find missing content online
 
				if (this->server != NULL) ShowMissingContentWindow(this->server->info.grfconfig);
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnDropdownSelect(int widget, int index)
 
	{
 
		switch (widget) {
 
			case NGWW_CONN_BTN:
 
			case WID_NG_CONN_BTN:
 
				_settings_client.network.lan_internet = index;
 
				break;
 

	
 
			default:
 
				NOT_REACHED();
 
		}
 

	
 
		this->SetDirty();
 
	}
 

	
 
	virtual void OnMouseLoop()
 
	{
 
		if (this->field == NGWW_CLIENT) this->HandleEditBox(NGWW_CLIENT);
 
		if (this->field == WID_NG_CLIENT) this->HandleEditBox(WID_NG_CLIENT);
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		if (data == 1) {
 
			this->server = NULL;
 
			this->list_pos = SLP_INVALID;
 
@@ -823,150 +823,150 @@ public:
 
			}
 

	
 
			this->server = this->servers[this->list_pos];
 

	
 
			/* scroll to the new server if it is outside the current range */
 
			this->ScrollToSelectedServer();
 

	
 
			/* redraw window */
 
			this->SetDirty();
 
			return ES_HANDLED;
 
		}
 

	
 
		if (this->field != NGWW_CLIENT) {
 
		if (this->field != WID_NG_CLIENT) {
 
			if (this->server != NULL) {
 
				if (keycode == WKC_DELETE) { // Press 'delete' to remove servers
 
					NetworkGameListRemoveItem(this->server);
 
					if (this->server == this->last_joined) this->last_joined = NULL;
 
					this->server = NULL;
 
					this->list_pos = SLP_INVALID;
 
				}
 
			}
 
			return state;
 
		}
 

	
 
		if (this->HandleEditBoxKey(NGWW_CLIENT, key, keycode, state) == HEBR_CONFIRM) return state;
 
		if (this->HandleEditBoxKey(WID_NG_CLIENT, key, keycode, state) == HEBR_CONFIRM) return state;
 

	
 
		/* The name is only allowed when it starts with a letter! */
 
		if (!StrEmpty(this->edit_str_buf) && this->edit_str_buf[0] != ' ') {
 
			strecpy(_settings_client.network.client_name, this->edit_str_buf, lastof(_settings_client.network.client_name));
 
		} else {
 
			strecpy(_settings_client.network.client_name, "Player", lastof(_settings_client.network.client_name));
 
		}
 
		return state;
 
	}
 

	
 
	virtual void OnQueryTextFinished(char *str)
 
	{
 
		if (!StrEmpty(str)) NetworkAddServer(str);
 
	}
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, NGWW_MATRIX);
 
		this->GetWidget<NWidgetCore>(NGWW_MATRIX)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
		this->vscroll->SetCapacityFromWidget(this, WID_NG_MATRIX);
 
		this->GetWidget<NWidgetCore>(WID_NG_MATRIX)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 

	
 
	virtual void OnTick()
 
	{
 
		NetworkGameListRequery();
 
	}
 
};
 

	
 
Listing NetworkGameWindow::last_sorting = {false, 5};
 
GUIGameServerList::SortFunction * const NetworkGameWindow::sorter_funcs[] = {
 
	&NGameNameSorter,
 
	&NGameClientSorter,
 
	&NGameMapSizeSorter,
 
	&NGameDateSorter,
 
	&NGameYearsSorter,
 
	&NGameAllowedSorter
 
};
 

	
 
static NWidgetBase *MakeResizableHeader(int *biggest_index)
 
{
 
	*biggest_index = max<int>(*biggest_index, NGWW_INFO);
 
	*biggest_index = max<int>(*biggest_index, WID_NG_INFO);
 
	return new NWidgetServerListHeader();
 
}
 

	
 
static const NWidgetPart _nested_network_game_widgets[] = {
 
	/* TOP */
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE),
 
		NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_NETWORK_SERVER_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, NGWW_MAIN),
 
	NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NG_MAIN),
 
		NWidget(NWID_VERTICAL), SetPIP(10, 7, 0),
 
			NWidget(NWID_HORIZONTAL), SetPIP(10, 7, 10),
 
				NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, NGWW_CONNECTION), SetDataTip(STR_NETWORK_SERVER_LIST_CONNECTION, STR_NULL),
 
				NWidget(WWT_DROPDOWN, COLOUR_LIGHT_BLUE, NGWW_CONN_BTN),
 
				NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NG_CONNECTION), SetDataTip(STR_NETWORK_SERVER_LIST_CONNECTION, STR_NULL),
 
				NWidget(WWT_DROPDOWN, COLOUR_LIGHT_BLUE, WID_NG_CONN_BTN),
 
										SetDataTip(STR_BLACK_STRING, STR_NETWORK_SERVER_LIST_CONNECTION_TOOLTIP),
 
				NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
 
				NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, NGWW_CLIENT_LABEL), SetDataTip(STR_NETWORK_SERVER_LIST_PLAYER_NAME, STR_NULL),
 
				NWidget(WWT_EDITBOX, COLOUR_LIGHT_BLUE, NGWW_CLIENT), SetMinimalSize(151, 12),
 
				NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NG_CLIENT_LABEL), SetDataTip(STR_NETWORK_SERVER_LIST_PLAYER_NAME, STR_NULL),
 
				NWidget(WWT_EDITBOX, COLOUR_LIGHT_BLUE, WID_NG_CLIENT), SetMinimalSize(151, 12),
 
										SetDataTip(STR_NETWORK_SERVER_LIST_PLAYER_NAME_OSKTITLE, STR_NETWORK_SERVER_LIST_ENTER_NAME_TOOLTIP),
 
			EndContainer(),
 
			NWidget(NWID_HORIZONTAL), SetPIP(10, 7, 10),
 
				/* LEFT SIDE */
 
				NWidget(NWID_VERTICAL),
 
					NWidget(NWID_HORIZONTAL),
 
						NWidget(NWID_VERTICAL),
 
							NWidgetFunction(MakeResizableHeader),
 
							NWidget(WWT_MATRIX, COLOUR_LIGHT_BLUE, NGWW_MATRIX), SetResize(1, 1), SetFill(1, 0),
 
												SetDataTip(0, STR_NETWORK_SERVER_LIST_CLICK_GAME_TO_SELECT), SetScrollbar(NGWW_SCROLLBAR),
 
							NWidget(WWT_MATRIX, COLOUR_LIGHT_BLUE, WID_NG_MATRIX), SetResize(1, 1), SetFill(1, 0),
 
												SetDataTip(0, STR_NETWORK_SERVER_LIST_CLICK_GAME_TO_SELECT), SetScrollbar(WID_NG_SCROLLBAR),
 
						EndContainer(),
 
						NWidget(NWID_VSCROLLBAR, COLOUR_LIGHT_BLUE, NGWW_SCROLLBAR),
 
						NWidget(NWID_VSCROLLBAR, COLOUR_LIGHT_BLUE, WID_NG_SCROLLBAR),
 
					EndContainer(),
 
					NWidget(NWID_SPACER), SetMinimalSize(0, 7), SetResize(1, 0), SetFill(1, 1),
 
					NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, NGWW_LASTJOINED_LABEL), SetFill(1, 0),
 
					NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NG_LASTJOINED_LABEL), SetFill(1, 0),
 
										SetDataTip(STR_NETWORK_SERVER_LIST_LAST_JOINED_SERVER, STR_NULL), SetResize(1, 0),
 
					NWidget(NWID_HORIZONTAL),
 
						NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, NGWW_LASTJOINED), SetFill(1, 0), SetResize(1, 0),
 
						NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NG_LASTJOINED), SetFill(1, 0), SetResize(1, 0),
 
											SetDataTip(0x0, STR_NETWORK_SERVER_LIST_CLICK_TO_SELECT_LAST),
 
						EndContainer(),
 
						NWidget(WWT_EMPTY, INVALID_COLOUR, NGWW_LASTJOINED_SPACER), SetFill(0, 0),
 
						NWidget(WWT_EMPTY, INVALID_COLOUR, WID_NG_LASTJOINED_SPACER), SetFill(0, 0),
 
					EndContainer(),
 
				EndContainer(),
 
				/* RIGHT SIDE */
 
				NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, NGWW_DETAILS),
 
				NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NG_DETAILS),
 
					NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPIP(5, 5, 5),
 
						NWidget(WWT_EMPTY, INVALID_COLOUR, NGWW_DETAILS_SPACER), SetMinimalSize(140, 155), SetResize(0, 1), SetFill(1, 1), // Make sure it's at least this wide
 
						NWidget(WWT_EMPTY, INVALID_COLOUR, WID_NG_DETAILS_SPACER), SetMinimalSize(140, 155), SetResize(0, 1), SetFill(1, 1), // Make sure it's at least this wide
 
						NWidget(NWID_HORIZONTAL, NC_NONE), SetPIP(5, 5, 5),
 
							NWidget(NWID_SELECTION, INVALID_COLOUR, NGWW_NEWGRF_MISSING_SEL),
 
								NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NGWW_NEWGRF_MISSING), SetFill(1, 0), SetDataTip(STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON, STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP),
 
							NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NG_NEWGRF_MISSING_SEL),
 
								NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_NEWGRF_MISSING), SetFill(1, 0), SetDataTip(STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON, STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP),
 
								NWidget(NWID_SPACER), SetFill(1, 0),
 
							EndContainer(),
 
						EndContainer(),
 
						NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(5, 5, 5),
 
							NWidget(NWID_SPACER), SetFill(1, 0),
 
							NWidget(NWID_SELECTION, INVALID_COLOUR, NGWW_NEWGRF_SEL),
 
								NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NGWW_NEWGRF), SetFill(1, 0), SetDataTip(STR_INTRO_NEWGRF_SETTINGS, STR_NULL),
 
							NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NG_NEWGRF_SEL),
 
								NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_NEWGRF), SetFill(1, 0), SetDataTip(STR_INTRO_NEWGRF_SETTINGS, STR_NULL),
 
								NWidget(NWID_SPACER), SetFill(1, 0),
 
							EndContainer(),
 
						EndContainer(),
 
						NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(5, 5, 5),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NGWW_JOIN), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_JOIN_GAME, STR_NULL),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NGWW_REFRESH), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_REFRESH, STR_NETWORK_SERVER_LIST_REFRESH_TOOLTIP),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_JOIN), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_JOIN_GAME, STR_NULL),
 
							NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_REFRESH), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_REFRESH, STR_NETWORK_SERVER_LIST_REFRESH_TOOLTIP),
 
						EndContainer(),
 
					EndContainer(),
 
				EndContainer(),
 
			EndContainer(),
 
			/* BOTTOM */
 
			NWidget(NWID_HORIZONTAL),
 
				NWidget(NWID_VERTICAL),
 
					NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(10, 7, 4),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NGWW_FIND), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_FIND_SERVER, STR_NETWORK_SERVER_LIST_FIND_SERVER_TOOLTIP),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NGWW_ADD), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_ADD_SERVER, STR_NETWORK_SERVER_LIST_ADD_SERVER_TOOLTIP),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NGWW_START), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_START_SERVER, STR_NETWORK_SERVER_LIST_START_SERVER_TOOLTIP),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NGWW_CANCEL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_FIND), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_FIND_SERVER, STR_NETWORK_SERVER_LIST_FIND_SERVER_TOOLTIP),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_ADD), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_ADD_SERVER, STR_NETWORK_SERVER_LIST_ADD_SERVER_TOOLTIP),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_START), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_START_SERVER, STR_NETWORK_SERVER_LIST_START_SERVER_TOOLTIP),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_CANCEL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
 
					EndContainer(),
 
					NWidget(NWID_SPACER), SetMinimalSize(0, 6), SetResize(1, 0), SetFill(1, 0),
 
				EndContainer(),
 
				NWidget(NWID_VERTICAL),
 
					NWidget(NWID_SPACER), SetFill(0, 1),
 
					NWidget(WWT_RESIZEBOX, COLOUR_LIGHT_BLUE),
 
				EndContainer(),
 
			EndContainer(),
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
 
@@ -997,319 +997,319 @@ void ShowNetworkGameWindow()
 
struct NetworkStartServerWindow : public QueryStringBaseWindow {
 
	byte field;                  ///< Selected text-field
 
	byte widget_id;              ///< The widget that has the pop-up input menu
 

	
 
	NetworkStartServerWindow(const WindowDesc *desc) : QueryStringBaseWindow(NETWORK_NAME_LENGTH)
 
	{
 
		this->InitNested(desc, 0);
 

	
 
		ttd_strlcpy(this->edit_str_buf, _settings_client.network.server_name, this->edit_str_size);
 

	
 
		this->afilter = CS_ALPHANUMERAL;
 
		InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, 160);
 
		this->SetFocusedWidget(NSSW_GAMENAME);
 
		this->SetFocusedWidget(WID_NSS_GAMENAME);
 

	
 
		this->field = NSSW_GAMENAME;
 
		this->field = WID_NSS_GAMENAME;
 
	}
 

	
 
	virtual void SetStringParameters(int widget) const
 
	{
 
		switch (widget) {
 
			case NSSW_CONNTYPE_BTN:
 
			case WID_NSS_CONNTYPE_BTN:
 
				SetDParam(0, _connection_types_dropdown[_settings_client.network.server_advertise]);
 
				break;
 

	
 
			case NSSW_CLIENTS_TXT:
 
			case WID_NSS_CLIENTS_TXT:
 
				SetDParam(0, _settings_client.network.max_clients);
 
				break;
 

	
 
			case NSSW_COMPANIES_TXT:
 
			case WID_NSS_COMPANIES_TXT:
 
				SetDParam(0, _settings_client.network.max_companies);
 
				break;
 

	
 
			case NSSW_SPECTATORS_TXT:
 
			case WID_NSS_SPECTATORS_TXT:
 
				SetDParam(0, _settings_client.network.max_spectators);
 
				break;
 

	
 
			case NSSW_LANGUAGE_BTN:
 
			case WID_NSS_LANGUAGE_BTN:
 
				SetDParam(0, STR_NETWORK_LANG_ANY + _settings_client.network.server_lang);
 
				break;
 
		}
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		switch (widget) {
 
			case NSSW_CONNTYPE_BTN:
 
			case WID_NSS_CONNTYPE_BTN:
 
				*size = maxdim(GetStringBoundingBox(_connection_types_dropdown[0]), GetStringBoundingBox(_connection_types_dropdown[1]));
 
				size->width += padding.width;
 
				size->height += padding.height;
 
				break;
 
		}
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		switch (widget) {
 
			case NSSW_SETPWD:
 
			case WID_NSS_SETPWD:
 
				/* if password is set, draw red '*' next to 'Set password' button */
 
				if (!StrEmpty(_settings_client.network.server_password)) DrawString(r.right + WD_FRAMERECT_LEFT, this->width - WD_FRAMERECT_RIGHT, r.top, "*", TC_RED);
 
		}
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		/* draw basic widgets */
 
		this->DrawWidgets();
 

	
 
		/* editbox to set game name */
 
		this->DrawEditBox(NSSW_GAMENAME);
 
		this->DrawEditBox(WID_NSS_GAMENAME);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		this->field = widget;
 
		switch (widget) {
 
			case NSSW_CANCEL: // Cancel button
 
			case WID_NSS_CANCEL: // Cancel button
 
				ShowNetworkGameWindow();
 
				break;
 

	
 
			case NSSW_SETPWD: // Set password button
 
				this->widget_id = NSSW_SETPWD;
 
			case WID_NSS_SETPWD: // Set password button
 
				this->widget_id = WID_NSS_SETPWD;
 
				SetDParamStr(0, _settings_client.network.server_password);
 
				ShowQueryString(STR_JUST_RAW_STRING, STR_NETWORK_START_SERVER_SET_PASSWORD, 20, this, CS_ALPHANUMERAL, QSF_NONE);
 
				break;
 

	
 
			case NSSW_CONNTYPE_BTN: // Connection type
 
				ShowDropDownMenu(this, _connection_types_dropdown, _settings_client.network.server_advertise, NSSW_CONNTYPE_BTN, 0, 0); // do it for widget NSSW_CONNTYPE_BTN
 
			case WID_NSS_CONNTYPE_BTN: // Connection type
 
				ShowDropDownMenu(this, _connection_types_dropdown, _settings_client.network.server_advertise, WID_NSS_CONNTYPE_BTN, 0, 0); // do it for widget WID_NSS_CONNTYPE_BTN
 
				break;
 

	
 
			case NSSW_CLIENTS_BTND:    case NSSW_CLIENTS_BTNU:    // Click on up/down button for number of clients
 
			case NSSW_COMPANIES_BTND:  case NSSW_COMPANIES_BTNU:  // Click on up/down button for number of companies
 
			case NSSW_SPECTATORS_BTND: case NSSW_SPECTATORS_BTNU: // Click on up/down button for number of spectators
 
			case WID_NSS_CLIENTS_BTND:    case WID_NSS_CLIENTS_BTNU:    // Click on up/down button for number of clients
 
			case WID_NSS_COMPANIES_BTND:  case WID_NSS_COMPANIES_BTNU:  // Click on up/down button for number of companies
 
			case WID_NSS_SPECTATORS_BTND: case WID_NSS_SPECTATORS_BTNU: // Click on up/down button for number of spectators
 
				/* Don't allow too fast scrolling */
 
				if ((this->flags & WF_TIMEOUT) && this->timeout_timer <= 1) {
 
					this->HandleButtonClick(widget);
 
					this->SetDirty();
 
					switch (widget) {
 
						default: NOT_REACHED();
 
						case NSSW_CLIENTS_BTND: case NSSW_CLIENTS_BTNU:
 
							_settings_client.network.max_clients    = Clamp(_settings_client.network.max_clients    + widget - NSSW_CLIENTS_TXT,    2, MAX_CLIENTS);
 
						case WID_NSS_CLIENTS_BTND: case WID_NSS_CLIENTS_BTNU:
 
							_settings_client.network.max_clients    = Clamp(_settings_client.network.max_clients    + widget - WID_NSS_CLIENTS_TXT,    2, MAX_CLIENTS);
 
							break;
 
						case NSSW_COMPANIES_BTND: case NSSW_COMPANIES_BTNU:
 
							_settings_client.network.max_companies  = Clamp(_settings_client.network.max_companies  + widget - NSSW_COMPANIES_TXT,  1, MAX_COMPANIES);
 
						case WID_NSS_COMPANIES_BTND: case WID_NSS_COMPANIES_BTNU:
 
							_settings_client.network.max_companies  = Clamp(_settings_client.network.max_companies  + widget - WID_NSS_COMPANIES_TXT,  1, MAX_COMPANIES);
 
							break;
 
						case NSSW_SPECTATORS_BTND: case NSSW_SPECTATORS_BTNU:
 
							_settings_client.network.max_spectators = Clamp(_settings_client.network.max_spectators + widget - NSSW_SPECTATORS_TXT, 0, MAX_CLIENTS);
 
						case WID_NSS_SPECTATORS_BTND: case WID_NSS_SPECTATORS_BTNU:
 
							_settings_client.network.max_spectators = Clamp(_settings_client.network.max_spectators + widget - WID_NSS_SPECTATORS_TXT, 0, MAX_CLIENTS);
 
							break;
 
					}
 
				}
 
				_left_button_clicked = false;
 
				break;
 

	
 
			case NSSW_CLIENTS_TXT:    // Click on number of clients
 
				this->widget_id = NSSW_CLIENTS_TXT;
 
			case WID_NSS_CLIENTS_TXT:    // Click on number of clients
 
				this->widget_id = WID_NSS_CLIENTS_TXT;
 
				SetDParam(0, _settings_client.network.max_clients);
 
				ShowQueryString(STR_JUST_INT, STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS,    4, this, CS_NUMERAL, QSF_NONE);
 
				break;
 

	
 
			case NSSW_COMPANIES_TXT:  // Click on number of companies
 
				this->widget_id = NSSW_COMPANIES_TXT;
 
			case WID_NSS_COMPANIES_TXT:  // Click on number of companies
 
				this->widget_id = WID_NSS_COMPANIES_TXT;
 
				SetDParam(0, _settings_client.network.max_companies);
 
				ShowQueryString(STR_JUST_INT, STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES,  3, this, CS_NUMERAL, QSF_NONE);
 
				break;
 

	
 
			case NSSW_SPECTATORS_TXT: // Click on number of spectators
 
				this->widget_id = NSSW_SPECTATORS_TXT;
 
			case WID_NSS_SPECTATORS_TXT: // Click on number of spectators
 
				this->widget_id = WID_NSS_SPECTATORS_TXT;
 
				SetDParam(0, _settings_client.network.max_spectators);
 
				ShowQueryString(STR_JUST_INT, STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS, 4, this, CS_NUMERAL, QSF_NONE);
 
				break;
 

	
 
			case NSSW_LANGUAGE_BTN: { // Language
 
			case WID_NSS_LANGUAGE_BTN: { // Language
 
				uint sel = 0;
 
				for (uint i = 0; i < lengthof(_language_dropdown) - 1; i++) {
 
					if (_language_dropdown[i] == STR_NETWORK_LANG_ANY + _settings_client.network.server_lang) {
 
						sel = i;
 
						break;
 
					}
 
				}
 
				ShowDropDownMenu(this, _language_dropdown, sel, NSSW_LANGUAGE_BTN, 0, 0);
 
				ShowDropDownMenu(this, _language_dropdown, sel, WID_NSS_LANGUAGE_BTN, 0, 0);
 
				break;
 
			}
 

	
 
			case NSSW_GENERATE_GAME: // Start game
 
			case WID_NSS_GENERATE_GAME: // Start game
 
				_is_network_server = true;
 
				if (_ctrl_pressed) {
 
					StartNewGameWithoutGUI(GENERATE_NEW_SEED);
 
				} else {
 
					ShowGenerateLandscape();
 
				}
 
				break;
 

	
 
			case NSSW_LOAD_GAME:
 
			case WID_NSS_LOAD_GAME:
 
				_is_network_server = true;
 
				ShowSaveLoadDialog(SLD_LOAD_GAME);
 
				break;
 

	
 
			case NSSW_PLAY_SCENARIO:
 
			case WID_NSS_PLAY_SCENARIO:
 
				_is_network_server = true;
 
				ShowSaveLoadDialog(SLD_LOAD_SCENARIO);
 
				break;
 

	
 
			case NSSW_PLAY_HEIGHTMAP:
 
			case WID_NSS_PLAY_HEIGHTMAP:
 
				_is_network_server = true;
 
				ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP);
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnDropdownSelect(int widget, int index)
 
	{
 
		switch (widget) {
 
			case NSSW_CONNTYPE_BTN:
 
			case WID_NSS_CONNTYPE_BTN:
 
				_settings_client.network.server_advertise = (index != 0);
 
				break;
 
			case NSSW_LANGUAGE_BTN:
 
			case WID_NSS_LANGUAGE_BTN:
 
				_settings_client.network.server_lang = _language_dropdown[index] - STR_NETWORK_LANG_ANY;
 
				break;
 
			default:
 
				NOT_REACHED();
 
		}
 

	
 
		this->SetDirty();
 
	}
 

	
 
	virtual void OnMouseLoop()
 
	{
 
		if (this->field == NSSW_GAMENAME) this->HandleEditBox(NSSW_GAMENAME);
 
		if (this->field == WID_NSS_GAMENAME) this->HandleEditBox(WID_NSS_GAMENAME);
 
	}
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		EventState state = ES_NOT_HANDLED;
 
		if (this->field == NSSW_GAMENAME) {
 
			if (this->HandleEditBoxKey(NSSW_GAMENAME, key, keycode, state) == HEBR_CONFIRM) return state;
 
		if (this->field == WID_NSS_GAMENAME) {
 
			if (this->HandleEditBoxKey(WID_NSS_GAMENAME, key, keycode, state) == HEBR_CONFIRM) return state;
 

	
 
			strecpy(_settings_client.network.server_name, this->text.buf, lastof(_settings_client.network.server_name));
 
		}
 

	
 
		return state;
 
	}
 

	
 
	virtual void OnTimeout()
 
	{
 
		static const int raise_widgets[] = {NSSW_CLIENTS_BTND, NSSW_CLIENTS_BTNU, NSSW_COMPANIES_BTND, NSSW_COMPANIES_BTNU, NSSW_SPECTATORS_BTND, NSSW_SPECTATORS_BTNU, WIDGET_LIST_END};
 
		static const int raise_widgets[] = {WID_NSS_CLIENTS_BTND, WID_NSS_CLIENTS_BTNU, WID_NSS_COMPANIES_BTND, WID_NSS_COMPANIES_BTNU, WID_NSS_SPECTATORS_BTND, WID_NSS_SPECTATORS_BTNU, WIDGET_LIST_END};
 
		for (const int *widget = raise_widgets; *widget != WIDGET_LIST_END; widget++) {
 
			if (this->IsWidgetLowered(*widget)) {
 
				this->RaiseWidget(*widget);
 
				this->SetWidgetDirty(*widget);
 
			}
 
		}
 
	}
 

	
 
	virtual void OnQueryTextFinished(char *str)
 
	{
 
		if (str == NULL) return;
 

	
 
		if (this->widget_id == NSSW_SETPWD) {
 
		if (this->widget_id == WID_NSS_SETPWD) {
 
			strecpy(_settings_client.network.server_password, str, lastof(_settings_client.network.server_password));
 
		} else {
 
			int32 value = atoi(str);
 
			this->SetWidgetDirty(this->widget_id);
 
			switch (this->widget_id) {
 
				default: NOT_REACHED();
 
				case NSSW_CLIENTS_TXT:    _settings_client.network.max_clients    = Clamp(value, 2, MAX_CLIENTS); break;
 
				case NSSW_COMPANIES_TXT:  _settings_client.network.max_companies  = Clamp(value, 1, MAX_COMPANIES); break;
 
				case NSSW_SPECTATORS_TXT: _settings_client.network.max_spectators = Clamp(value, 0, MAX_CLIENTS); break;
 
				case WID_NSS_CLIENTS_TXT:    _settings_client.network.max_clients    = Clamp(value, 2, MAX_CLIENTS); break;
 
				case WID_NSS_COMPANIES_TXT:  _settings_client.network.max_companies  = Clamp(value, 1, MAX_COMPANIES); break;
 
				case WID_NSS_SPECTATORS_TXT: _settings_client.network.max_spectators = Clamp(value, 0, MAX_CLIENTS); break;
 
			}
 
		}
 

	
 
		this->SetDirty();
 
	}
 
};
 

	
 
static const NWidgetPart _nested_network_start_server_window_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE),
 
		NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_NETWORK_START_SERVER_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, NSSW_BACKGROUND),
 
	NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NSS_BACKGROUND),
 
		NWidget(NWID_VERTICAL), SetPIP(10, 6, 10),
 
			NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(10, 6, 10),
 
				NWidget(NWID_VERTICAL), SetPIP(0, 1, 0),
 
					/* Game name widgets */
 
					NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, NSSW_GAMENAME_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_NEW_GAME_NAME, STR_NULL),
 
					NWidget(WWT_EDITBOX, COLOUR_LIGHT_BLUE, NSSW_GAMENAME), SetMinimalSize(10, 12), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_NEW_GAME_NAME_OSKTITLE, STR_NETWORK_START_SERVER_NEW_GAME_NAME_TOOLTIP),
 
					NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NSS_GAMENAME_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_NEW_GAME_NAME, STR_NULL),
 
					NWidget(WWT_EDITBOX, COLOUR_LIGHT_BLUE, WID_NSS_GAMENAME), SetMinimalSize(10, 12), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_NEW_GAME_NAME_OSKTITLE, STR_NETWORK_START_SERVER_NEW_GAME_NAME_TOOLTIP),
 
				EndContainer(),
 
			EndContainer(),
 

	
 
			NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(10, 6, 10),
 
				NWidget(NWID_VERTICAL), SetPIP(0, 1, 0),
 
					NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, NSSW_CONNTYPE_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_CONNECTION, STR_NULL),
 
					NWidget(WWT_DROPDOWN, COLOUR_LIGHT_BLUE, NSSW_CONNTYPE_BTN), SetFill(1, 0), SetDataTip(STR_BLACK_STRING, STR_NETWORK_SERVER_LIST_CONNECTION_TOOLTIP),
 
					NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NSS_CONNTYPE_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_CONNECTION, STR_NULL),
 
					NWidget(WWT_DROPDOWN, COLOUR_LIGHT_BLUE, WID_NSS_CONNTYPE_BTN), SetFill(1, 0), SetDataTip(STR_BLACK_STRING, STR_NETWORK_SERVER_LIST_CONNECTION_TOOLTIP),
 
				EndContainer(),
 
				NWidget(NWID_VERTICAL), SetPIP(0, 1, 0),
 
					NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, NSSW_LANGUAGE_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_LANGUAGE_SPOKEN, STR_NULL),
 
					NWidget(WWT_DROPDOWN, COLOUR_LIGHT_BLUE, NSSW_LANGUAGE_BTN), SetFill(1, 0), SetDataTip(STR_BLACK_STRING, STR_NETWORK_START_SERVER_LANGUAGE_TOOLTIP),
 
					NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NSS_LANGUAGE_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_LANGUAGE_SPOKEN, STR_NULL),
 
					NWidget(WWT_DROPDOWN, COLOUR_LIGHT_BLUE, WID_NSS_LANGUAGE_BTN), SetFill(1, 0), SetDataTip(STR_BLACK_STRING, STR_NETWORK_START_SERVER_LANGUAGE_TOOLTIP),
 
				EndContainer(),
 
				NWidget(NWID_VERTICAL), SetPIP(0, 1, 0),
 
					NWidget(NWID_SPACER), SetFill(1, 1),
 
					NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NSSW_SETPWD), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_SET_PASSWORD, STR_NETWORK_START_SERVER_PASSWORD_TOOLTIP),
 
					NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NSS_SETPWD), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_SET_PASSWORD, STR_NETWORK_START_SERVER_PASSWORD_TOOLTIP),
 
				EndContainer(),
 
			EndContainer(),
 

	
 
			NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(10, 6, 10),
 
				NWidget(NWID_VERTICAL), SetPIP(0, 1, 0),
 
					NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, NSSW_CLIENTS_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS, STR_NULL),
 
					NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NSS_CLIENTS_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS, STR_NULL),
 
					NWidget(NWID_HORIZONTAL),
 
						NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, NSSW_CLIENTS_BTND), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_DOWN, STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS_TOOLTIP),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, NSSW_CLIENTS_TXT), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_CLIENTS_SELECT, STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS_TOOLTIP),
 
						NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, NSSW_CLIENTS_BTNU), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_UP, STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS_TOOLTIP),
 
						NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, WID_NSS_CLIENTS_BTND), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_DOWN, STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS_TOOLTIP),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_NSS_CLIENTS_TXT), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_CLIENTS_SELECT, STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS_TOOLTIP),
 
						NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, WID_NSS_CLIENTS_BTNU), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_UP, STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS_TOOLTIP),
 
					EndContainer(),
 
				EndContainer(),
 

	
 
				NWidget(NWID_VERTICAL), SetPIP(0, 1, 0),
 
					NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, NSSW_COMPANIES_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES, STR_NULL),
 
					NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NSS_COMPANIES_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES, STR_NULL),
 
					NWidget(NWID_HORIZONTAL),
 
						NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, NSSW_COMPANIES_BTND), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_DOWN, STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES_TOOLTIP),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, NSSW_COMPANIES_TXT), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_COMPANIES_SELECT, STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES_TOOLTIP),
 
						NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, NSSW_COMPANIES_BTNU), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_UP, STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES_TOOLTIP),
 
						NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, WID_NSS_COMPANIES_BTND), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_DOWN, STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES_TOOLTIP),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_NSS_COMPANIES_TXT), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_COMPANIES_SELECT, STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES_TOOLTIP),
 
						NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, WID_NSS_COMPANIES_BTNU), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_UP, STR_NETWORK_START_SERVER_NUMBER_OF_COMPANIES_TOOLTIP),
 
					EndContainer(),
 
				EndContainer(),
 

	
 
				NWidget(NWID_VERTICAL), SetPIP(0, 1, 0),
 
					NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, NSSW_SPECTATORS_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS, STR_NULL),
 
					NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NSS_SPECTATORS_LABEL), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS, STR_NULL),
 
					NWidget(NWID_HORIZONTAL),
 
						NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, NSSW_SPECTATORS_BTND), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_DOWN, STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS_TOOLTIP),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, NSSW_SPECTATORS_TXT), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_SPECTATORS_SELECT, STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS_TOOLTIP),
 
						NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, NSSW_SPECTATORS_BTNU), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_UP, STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS_TOOLTIP),
 
						NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, WID_NSS_SPECTATORS_BTND), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_DOWN, STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS_TOOLTIP),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_NSS_SPECTATORS_TXT), SetFill(1, 0), SetDataTip(STR_NETWORK_START_SERVER_SPECTATORS_SELECT, STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS_TOOLTIP),
 
						NWidget(WWT_IMGBTN, COLOUR_LIGHT_BLUE, WID_NSS_SPECTATORS_BTNU), SetMinimalSize(12, 12), SetFill(0, 1), SetDataTip(SPR_ARROW_UP, STR_NETWORK_START_SERVER_NUMBER_OF_SPECTATORS_TOOLTIP),
 
					EndContainer(),
 
				EndContainer(),
 
			EndContainer(),
 

	
 
			/* 'generate game' and 'load game' buttons */
 
			NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(10, 6, 10),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NSSW_GENERATE_GAME), SetDataTip(STR_INTRO_NEW_GAME, STR_INTRO_TOOLTIP_NEW_GAME), SetFill(1, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NSSW_LOAD_GAME), SetDataTip(STR_INTRO_LOAD_GAME, STR_INTRO_TOOLTIP_LOAD_GAME), SetFill(1, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NSS_GENERATE_GAME), SetDataTip(STR_INTRO_NEW_GAME, STR_INTRO_TOOLTIP_NEW_GAME), SetFill(1, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NSS_LOAD_GAME), SetDataTip(STR_INTRO_LOAD_GAME, STR_INTRO_TOOLTIP_LOAD_GAME), SetFill(1, 0),
 
			EndContainer(),
 

	
 
			/* 'play scenario' and 'play heightmap' buttons */
 
			NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(10, 6, 10),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NSSW_PLAY_SCENARIO), SetDataTip(STR_INTRO_PLAY_SCENARIO, STR_INTRO_TOOLTIP_PLAY_SCENARIO), SetFill(1, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NSSW_PLAY_HEIGHTMAP), SetDataTip(STR_INTRO_PLAY_HEIGHTMAP, STR_INTRO_TOOLTIP_PLAY_HEIGHTMAP), SetFill(1, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NSS_PLAY_SCENARIO), SetDataTip(STR_INTRO_PLAY_SCENARIO, STR_INTRO_TOOLTIP_PLAY_SCENARIO), SetFill(1, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NSS_PLAY_HEIGHTMAP), SetDataTip(STR_INTRO_PLAY_HEIGHTMAP, STR_INTRO_TOOLTIP_PLAY_HEIGHTMAP), SetFill(1, 0),
 
			EndContainer(),
 

	
 
			NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(10, 0, 10),
 
				NWidget(NWID_SPACER), SetFill(1, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NSSW_CANCEL), SetDataTip(STR_BUTTON_CANCEL, STR_NULL), SetMinimalSize(128, 12),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NSS_CANCEL), SetDataTip(STR_BUTTON_CANCEL, STR_NULL), SetMinimalSize(128, 12),
 
				NWidget(NWID_SPACER), SetFill(1, 0),
 
			EndContainer(),
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
 
static const WindowDesc _network_start_server_window_desc(
 
	WDP_CENTER, 0, 0,
 
	WC_NETWORK_WINDOW, WC_NONE,
 
	WDF_UNCLICK_BUTTONS,
 
	_nested_network_start_server_window_widgets, lengthof(_nested_network_start_server_window_widgets)
 
);
 
@@ -1322,91 +1322,91 @@ static void ShowNetworkStartServerWindow
 
}
 

	
 
struct NetworkLobbyWindow : public Window {
 
	CompanyID company;       ///< Select company
 
	NetworkGameList *server; ///< Selected server
 
	NetworkCompanyInfo company_info[MAX_COMPANIES];
 
	Scrollbar *vscroll;
 

	
 
	NetworkLobbyWindow(const WindowDesc *desc, NetworkGameList *ngl) :
 
			Window(), company(INVALID_COMPANY), server(ngl)
 
	{
 
		this->CreateNestedTree(desc);
 
		this->vscroll = this->GetScrollbar(NLWW_SCROLLBAR);
 
		this->vscroll = this->GetScrollbar(WID_NL_SCROLLBAR);
 
		this->FinishInitNested(desc, 0);
 
		this->OnResize();
 
	}
 

	
 
	CompanyID NetworkLobbyFindCompanyIndex(byte pos) const
 
	{
 
		/* Scroll through all this->company_info and get the 'pos' item that is not empty */
 
		for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
 
			if (!StrEmpty(this->company_info[i].company_name)) {
 
				if (pos-- == 0) return i;
 
			}
 
		}
 

	
 
		return COMPANY_FIRST;
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		switch (widget) {
 
			case NLWW_HEADER:
 
			case WID_NL_HEADER:
 
				size->height = WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM;
 
				break;
 

	
 
			case NLWW_MATRIX:
 
			case WID_NL_MATRIX:
 
				resize->height = WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM;
 
				size->height = 10 * resize->height;
 
				break;
 

	
 
			case NLWW_DETAILS:
 
			case WID_NL_DETAILS:
 
				size->height = 30 + 11 * FONT_HEIGHT_NORMAL;
 
				break;
 
		}
 
	}
 

	
 
	virtual void SetStringParameters(int widget) const
 
	{
 
		switch (widget) {
 
			case NLWW_TEXT:
 
			case WID_NL_TEXT:
 
				SetDParamStr(0, this->server->info.server_name);
 
				break;
 
		}
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		switch (widget) {
 
			case NLWW_DETAILS:
 
			case WID_NL_DETAILS:
 
				this->DrawDetails(r);
 
				break;
 

	
 
			case NLWW_MATRIX:
 
			case WID_NL_MATRIX:
 
				this->DrawMatrix(r);
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		const NetworkGameInfo *gi = &this->server->info;
 

	
 
		/* Join button is disabled when no company is selected and for AI companies*/
 
		this->SetWidgetDisabledState(NLWW_JOIN, this->company == INVALID_COMPANY || GetLobbyCompanyInfo(this->company)->ai);
 
		this->SetWidgetDisabledState(WID_NL_JOIN, this->company == INVALID_COMPANY || GetLobbyCompanyInfo(this->company)->ai);
 
		/* Cannot start new company if there are too many */
 
		this->SetWidgetDisabledState(NLWW_NEW, gi->companies_on >= gi->companies_max);
 
		this->SetWidgetDisabledState(WID_NL_NEW, gi->companies_on >= gi->companies_max);
 
		/* Cannot spectate if there are too many spectators */
 
		this->SetWidgetDisabledState(NLWW_SPECTATE, gi->spectators_on >= gi->spectators_max);
 
		this->SetWidgetDisabledState(WID_NL_SPECTATE, gi->spectators_on >= gi->spectators_max);
 

	
 
		this->vscroll->SetCount(gi->companies_on);
 

	
 
		/* Draw window widgets */
 
		this->DrawWidgets();
 
	}
 

	
 
	void DrawMatrix(const Rect &r) const
 
	{
 
		bool rtl = _current_text_dir == TD_RTL;
 
		uint left = r.left + WD_FRAMERECT_LEFT;
 
		uint right = r.right - WD_FRAMERECT_RIGHT;
 
@@ -1504,99 +1504,99 @@ struct NetworkLobbyWindow : public Windo
 
		SetDParam(3, this->company_info[this->company].num_station[NETWORK_VEH_SHIP]);
 
		SetDParam(4, this->company_info[this->company].num_station[NETWORK_VEH_PLANE]);
 
		DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_GAME_LOBBY_STATIONS); // stations
 
		y += FONT_HEIGHT_NORMAL;
 

	
 
		SetDParamStr(0, this->company_info[this->company].clients);
 
		DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_GAME_LOBBY_PLAYERS); // players
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		switch (widget) {
 
			case NLWW_CANCEL:   // Cancel button
 
			case WID_NL_CANCEL:   // Cancel button
 
				ShowNetworkGameWindow();
 
				break;
 

	
 
			case NLWW_MATRIX: { // Company list
 
				uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, NLWW_MATRIX);
 
			case WID_NL_MATRIX: { // Company list
 
				uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NL_MATRIX);
 
				this->company = (id_v >= this->server->info.companies_on) ? INVALID_COMPANY : NetworkLobbyFindCompanyIndex(id_v);
 
				this->SetDirty();
 

	
 
				/* FIXME the disabling should go into some InvalidateData, which is called instead of the SetDirty */
 
				if (click_count > 1 && !this->IsWidgetDisabled(NLWW_JOIN)) this->OnClick(pt, NLWW_JOIN, 1);
 
				if (click_count > 1 && !this->IsWidgetDisabled(WID_NL_JOIN)) this->OnClick(pt, WID_NL_JOIN, 1);
 
				break;
 
			}
 

	
 
			case NLWW_JOIN:     // Join company
 
			case WID_NL_JOIN:     // Join company
 
				/* Button can be clicked only when it is enabled */
 
				NetworkClientConnectGame(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port), this->company);
 
				break;
 

	
 
			case NLWW_NEW:      // New company
 
			case WID_NL_NEW:      // New company
 
				NetworkClientConnectGame(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port), COMPANY_NEW_COMPANY);
 
				break;
 

	
 
			case NLWW_SPECTATE: // Spectate game
 
			case WID_NL_SPECTATE: // Spectate game
 
				NetworkClientConnectGame(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port), COMPANY_SPECTATOR);
 
				break;
 

	
 
			case NLWW_REFRESH:  // Refresh
 
			case WID_NL_REFRESH:  // Refresh
 
				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
 
				/* Clear the information so removed companies don't remain */
 
				memset(this->company_info, 0, sizeof(this->company_info));
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, NLWW_MATRIX);
 
		this->GetWidget<NWidgetCore>(NLWW_MATRIX)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
		this->vscroll->SetCapacityFromWidget(this, WID_NL_MATRIX);
 
		this->GetWidget<NWidgetCore>(WID_NL_MATRIX)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 
};
 

	
 
static const NWidgetPart _nested_network_lobby_window_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE),
 
		NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_NETWORK_GAME_LOBBY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, NLWW_BACKGROUND),
 
		NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, NLWW_TEXT), SetDataTip(STR_NETWORK_GAME_LOBBY_PREPARE_TO_JOIN, STR_NULL), SetResize(1, 0), SetPadding(10, 10, 0, 10),
 
	NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NL_BACKGROUND),
 
		NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NL_TEXT), SetDataTip(STR_NETWORK_GAME_LOBBY_PREPARE_TO_JOIN, STR_NULL), SetResize(1, 0), SetPadding(10, 10, 0, 10),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 3),
 
		NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 10),
 
			/* Company list. */
 
			NWidget(NWID_VERTICAL),
 
				NWidget(WWT_PANEL, COLOUR_WHITE, NLWW_HEADER), SetMinimalSize(146, 0), SetResize(1, 0), SetFill(1, 0), EndContainer(),
 
				NWidget(WWT_MATRIX, COLOUR_LIGHT_BLUE, NLWW_MATRIX), SetMinimalSize(146, 0), SetResize(1, 1), SetFill(1, 1), SetDataTip(0, STR_NETWORK_GAME_LOBBY_COMPANY_LIST_TOOLTIP), SetScrollbar(NLWW_SCROLLBAR),
 
				NWidget(WWT_PANEL, COLOUR_WHITE, WID_NL_HEADER), SetMinimalSize(146, 0), SetResize(1, 0), SetFill(1, 0), EndContainer(),
 
				NWidget(WWT_MATRIX, COLOUR_LIGHT_BLUE, WID_NL_MATRIX), SetMinimalSize(146, 0), SetResize(1, 1), SetFill(1, 1), SetDataTip(0, STR_NETWORK_GAME_LOBBY_COMPANY_LIST_TOOLTIP), SetScrollbar(WID_NL_SCROLLBAR),
 
			EndContainer(),
 
			NWidget(NWID_VSCROLLBAR, COLOUR_LIGHT_BLUE, NLWW_SCROLLBAR),
 
			NWidget(NWID_VSCROLLBAR, COLOUR_LIGHT_BLUE, WID_NL_SCROLLBAR),
 
			NWidget(NWID_SPACER), SetMinimalSize(5, 0), SetResize(0, 1),
 
			/* Company info. */
 
			NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, NLWW_DETAILS), SetMinimalSize(232, 0), SetResize(1, 1), SetFill(1, 1), EndContainer(),
 
			NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NL_DETAILS), SetMinimalSize(232, 0), SetResize(1, 1), SetFill(1, 1), EndContainer(),
 
		EndContainer(),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 9),
 
		/* Buttons. */
 
		NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(10, 3, 10),
 
			NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPIP(0, 3, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NLWW_JOIN), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_GAME_LOBBY_JOIN_COMPANY, STR_NETWORK_GAME_LOBBY_JOIN_COMPANY_TOOLTIP),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NLWW_NEW), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_GAME_LOBBY_NEW_COMPANY, STR_NETWORK_GAME_LOBBY_NEW_COMPANY_TOOLTIP),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NL_JOIN), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_GAME_LOBBY_JOIN_COMPANY, STR_NETWORK_GAME_LOBBY_JOIN_COMPANY_TOOLTIP),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NL_NEW), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_GAME_LOBBY_NEW_COMPANY, STR_NETWORK_GAME_LOBBY_NEW_COMPANY_TOOLTIP),
 
			EndContainer(),
 
			NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPIP(0, 3, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NLWW_SPECTATE), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_GAME_LOBBY_SPECTATE_GAME, STR_NETWORK_GAME_LOBBY_SPECTATE_GAME_TOOLTIP),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NLWW_REFRESH), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_REFRESH, STR_NETWORK_SERVER_LIST_REFRESH_TOOLTIP),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NL_SPECTATE), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_GAME_LOBBY_SPECTATE_GAME, STR_NETWORK_GAME_LOBBY_SPECTATE_GAME_TOOLTIP),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NL_REFRESH), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_REFRESH, STR_NETWORK_SERVER_LIST_REFRESH_TOOLTIP),
 
			EndContainer(),
 
			NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPIP(0, 3, 0),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NLWW_CANCEL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
 
				NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NL_CANCEL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
 
				NWidget(NWID_SPACER), SetFill(1, 1),
 
			EndContainer(),
 
		EndContainer(),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 8),
 
	EndContainer(),
 
};
 

	
 
static const WindowDesc _network_lobby_window_desc(
 
	WDP_CENTER, 0, 0,
 
	WC_NETWORK_WINDOW, WC_NONE,
 
	WDF_UNCLICK_BUTTONS,
 
	_nested_network_lobby_window_widgets, lengthof(_nested_network_lobby_window_widgets)
 
@@ -1631,25 +1631,25 @@ NetworkCompanyInfo *GetLobbyCompanyInfo(
 
 *  and also makes able to give money to them, kick them (if server)
 
 *  and stuff like that. */
 

	
 
extern void DrawCompanyIcon(CompanyID cid, int x, int y);
 

	
 
/**
 
 * Prototype for ClientList actions.
 
 * @param ci The information about the current client.
 
 */
 
typedef void ClientList_Action_Proc(const NetworkClientInfo *ci);
 

	
 
static const NWidgetPart _nested_client_list_popup_widgets[] = {
 
	NWidget(WWT_PANEL, COLOUR_GREY, CLPW_PANEL), EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_CLP_PANEL), EndContainer(),
 
};
 

	
 
static const WindowDesc _client_list_popup_desc(
 
	WDP_AUTO, 0, 0,
 
	WC_CLIENT_LIST_POPUP, WC_CLIENT_LIST,
 
	0,
 
	_nested_client_list_popup_widgets, lengthof(_nested_client_list_popup_widgets)
 
);
 

	
 
/* Here we start to define the options out of the menu */
 
static void ClientList_Kick(const NetworkClientInfo *ci)
 
{
 
@@ -1807,25 +1807,25 @@ static void PopupClientList(ClientID cli
 

	
 
	if (NetworkClientInfo::GetByClientID(client_id) == NULL) return;
 

	
 
	new NetworkClientListPopupWindow(&_client_list_popup_desc, x, y, client_id);
 
}
 

	
 
static const NWidgetPart _nested_client_list_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_NETWORK_COMPANY_LIST_CLIENT_LIST, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, CLW_PANEL), SetMinimalSize(250, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM), SetResize(1, 1), EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_CL_PANEL), SetMinimalSize(250, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM), SetResize(1, 1), EndContainer(),
 
};
 

	
 
static const WindowDesc _client_list_desc(
 
	WDP_AUTO, 0, 0,
 
	WC_CLIENT_LIST, WC_NONE,
 
	0,
 
	_nested_client_list_widgets, lengthof(_nested_client_list_widgets)
 
);
 

	
 
/**
 
 * Main handle for clientlist
 
 */
 
@@ -1848,60 +1848,60 @@ struct NetworkClientListWindow : Window 
 
	bool CheckClientListHeight()
 
	{
 
		int num = 0;
 
		const NetworkClientInfo *ci;
 

	
 
		/* Should be replaced with a loop through all clients */
 
		FOR_ALL_CLIENT_INFOS(ci) {
 
			if (ci->client_playas != COMPANY_INACTIVE_CLIENT) num++;
 
		}
 

	
 
		num *= FONT_HEIGHT_NORMAL;
 

	
 
		int diff = (num + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM) - (this->GetWidget<NWidgetBase>(CLW_PANEL)->current_y);
 
		int diff = (num + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM) - (this->GetWidget<NWidgetBase>(WID_CL_PANEL)->current_y);
 
		/* If height is changed */
 
		if (diff != 0) {
 
			ResizeWindow(this, 0, diff);
 
			return false;
 
		}
 
		return true;
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		if (widget != CLW_PANEL) return;
 
		if (widget != WID_CL_PANEL) return;
 

	
 
		this->server_client_width = max(GetStringBoundingBox(STR_NETWORK_SERVER).width, GetStringBoundingBox(STR_NETWORK_CLIENT).width) + WD_FRAMERECT_RIGHT;
 
		this->company_icon_width = GetSpriteSize(SPR_COMPANY_ICON).width + WD_FRAMERECT_LEFT;
 

	
 
		uint width = 100; // Default width
 
		const NetworkClientInfo *ci;
 
		FOR_ALL_CLIENT_INFOS(ci) {
 
			width = max(width, GetStringBoundingBox(ci->client_name).width);
 
		}
 

	
 
		size->width = WD_FRAMERECT_LEFT + this->server_client_width + this->company_icon_width + width + WD_FRAMERECT_RIGHT;
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		/* Check if we need to reset the height */
 
		if (!this->CheckClientListHeight()) return;
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		if (widget != CLW_PANEL) return;
 
		if (widget != WID_CL_PANEL) return;
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 
		int icon_y_offset = 1 + (FONT_HEIGHT_NORMAL - 10) / 2;
 
		uint y = r.top + WD_FRAMERECT_TOP;
 
		uint left = r.left + WD_FRAMERECT_LEFT;
 
		uint right = r.right - WD_FRAMERECT_RIGHT;
 
		uint type_icon_width = this->server_client_width + this->company_icon_width;
 

	
 

	
 
		uint type_left  = rtl ? right - this->server_client_width : left;
 
		uint type_right = rtl ? right : left + this->server_client_width - 1;
 
		uint icon_left  = rtl ? right - type_icon_width + WD_FRAMERECT_LEFT : left + this->server_client_width;
 
@@ -1951,27 +1951,27 @@ struct NetworkClientListWindow : Window 
 
	}
 

	
 
	virtual void OnMouseOver(Point pt, int widget)
 
	{
 
		/* -1 means we left the current window */
 
		if (pt.y == -1) {
 
			this->selected_item = -1;
 
			this->SetDirty();
 
			return;
 
		}
 

	
 
		/* Find the new selected item (if any) */
 
		pt.y -= this->GetWidget<NWidgetBase>(CLW_PANEL)->pos_y;
 
		pt.y -= this->GetWidget<NWidgetBase>(WID_CL_PANEL)->pos_y;
 
		int item = -1;
 
		if (IsInsideMM(pt.y, WD_FRAMERECT_TOP, this->GetWidget<NWidgetBase>(CLW_PANEL)->current_y - WD_FRAMERECT_BOTTOM)) {
 
		if (IsInsideMM(pt.y, WD_FRAMERECT_TOP, this->GetWidget<NWidgetBase>(WID_CL_PANEL)->current_y - WD_FRAMERECT_BOTTOM)) {
 
			item = (pt.y - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL;
 
		}
 

	
 
		/* It did not change.. no update! */
 
		if (item == this->selected_item) return;
 
		this->selected_item = item;
 

	
 
		/* Repaint */
 
		this->SetDirty();
 
	}
 
};
 

	
 
@@ -1987,25 +1987,25 @@ uint32 _network_join_bytes_total;       
 

	
 
struct NetworkJoinStatusWindow : Window {
 
	NetworkPasswordType password_type;
 

	
 
	NetworkJoinStatusWindow(const WindowDesc *desc) : Window()
 
	{
 
		this->parent = FindWindowById(WC_NETWORK_WINDOW, 0);
 
		this->InitNested(desc, 0);
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		if (widget != NJSW_BACKGROUND) return;
 
		if (widget != WID_NJS_BACKGROUND) return;
 

	
 
		uint8 progress; // used for progress bar
 
		DrawString(r.left + 2, r.right - 2, r.top + 20, STR_NETWORK_CONNECTING_1 + _network_join_status, TC_FROMSTRING, SA_HOR_CENTER);
 
		switch (_network_join_status) {
 
			case NETWORK_JOIN_STATUS_CONNECTING: case NETWORK_JOIN_STATUS_AUTHORIZING:
 
			case NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO:
 
				progress = 10; // first two stages 10%
 
				break;
 
			case NETWORK_JOIN_STATUS_WAITING:
 
				SetDParam(0, _network_join_waiting);
 
				DrawString(r.left + 2, r.right - 2, r.top + 20 + FONT_HEIGHT_NORMAL, STR_NETWORK_CONNECTING_WAITING, TC_FROMSTRING, SA_HOR_CENTER);
 
				progress = 15; // third stage is 15%
 
@@ -2020,25 +2020,25 @@ struct NetworkJoinStatusWindow : Window 
 
				}
 
				/* FALL THROUGH */
 
			default: // Waiting is 15%, so the resting receivement of map is maximum 70%
 
				progress = 15 + _network_join_bytes * (100 - 15) / _network_join_bytes_total;
 
		}
 

	
 
		/* Draw nice progress bar :) */
 
		DrawFrameRect(r.left + 20, r.top + 5, (int)((this->width - 20) * progress / 100), r.top + 15, COLOUR_MAUVE, FR_NONE);
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		if (widget != NJSW_BACKGROUND) return;
 
		if (widget != WID_NJS_BACKGROUND) return;
 

	
 
		size->height = 25 + 2 * FONT_HEIGHT_NORMAL;
 

	
 
		/* Account for the statuses */
 
		uint width = 0;
 
		for (uint i = 0; i < NETWORK_JOIN_STATUS_END; i++) {
 
			width = max(width, GetStringBoundingBox(STR_NETWORK_CONNECTING_1 + i).width);
 
		}
 

	
 
		/* For the number of waiting (other) players */
 
		SetDParam(0, 255);
 
		width = max(width, GetStringBoundingBox(STR_NETWORK_CONNECTING_WAITING).width);
 
@@ -2046,25 +2046,25 @@ struct NetworkJoinStatusWindow : Window 
 
		/* Account for downloading ~ 10 MiB */
 
		SetDParam(0, 10000000);
 
		SetDParam(1, 10000000);
 
		width = max(width, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_1).width);
 
		width = max(width, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_2).width);
 

	
 
		/* Give a bit more clearing for the widest strings than strictly needed */
 
		size->width = width + WD_FRAMERECT_LEFT + WD_FRAMERECT_BOTTOM + 10;
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		if (widget == NJSW_CANCELOK) { // Disconnect button
 
		if (widget == WID_NJS_CANCELOK) { // Disconnect button
 
			NetworkDisconnect();
 
			SwitchToMode(SM_MENU);
 
			ShowNetworkGameWindow();
 
		}
 
	}
 

	
 
	virtual void OnQueryTextFinished(char *str)
 
	{
 
		if (StrEmpty(str)) {
 
			NetworkDisconnect();
 
			ShowNetworkGameWindow();
 
			return;
 
@@ -2072,28 +2072,28 @@ struct NetworkJoinStatusWindow : Window 
 

	
 
		switch (this->password_type) {
 
			case NETWORK_GAME_PASSWORD:    MyClient::SendGamePassword   (str); break;
 
			case NETWORK_COMPANY_PASSWORD: MyClient::SendCompanyPassword(str); break;
 
			default: NOT_REACHED();
 
		}
 
	}
 
};
 

	
 
static const NWidgetPart _nested_network_join_status_window_widgets[] = {
 
	NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_NETWORK_CONNECTING_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
	NWidget(WWT_PANEL, COLOUR_GREY),
 
		NWidget(WWT_EMPTY, COLOUR_GREY, NJSW_BACKGROUND),
 
		NWidget(WWT_EMPTY, COLOUR_GREY, WID_NJS_BACKGROUND),
 
		NWidget(NWID_HORIZONTAL),
 
			NWidget(NWID_SPACER), SetMinimalSize(75, 0), SetFill(1, 0),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, NJSW_CANCELOK), SetMinimalSize(101, 12), SetDataTip(STR_NETWORK_CONNECTION_DISCONNECT, STR_NULL),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NJS_CANCELOK), SetMinimalSize(101, 12), SetDataTip(STR_NETWORK_CONNECTION_DISCONNECT, STR_NULL),
 
			NWidget(NWID_SPACER), SetMinimalSize(75, 0), SetFill(1, 0),
 
		EndContainer(),
 
		NWidget(NWID_SPACER), SetMinimalSize(0, 4),
 
	EndContainer(),
 
};
 

	
 
static const WindowDesc _network_join_status_window_desc(
 
	WDP_CENTER, 0, 0,
 
	WC_NETWORK_STATUS_WINDOW, WC_NONE,
 
	WDF_MODAL,
 
	_nested_network_join_status_window_widgets, lengthof(_nested_network_join_status_window_widgets)
 
);
 
@@ -2118,109 +2118,109 @@ void ShowNetworkNeedPassword(NetworkPass
 
	}
 
	ShowQueryString(STR_EMPTY, caption, NETWORK_PASSWORD_LENGTH, w, CS_ALPHANUMERAL, QSF_NONE);
 
}
 

	
 
struct NetworkCompanyPasswordWindow : public QueryStringBaseWindow {
 
	NetworkCompanyPasswordWindow(const WindowDesc *desc, Window *parent) : QueryStringBaseWindow(lengthof(_settings_client.network.default_company_pass))
 
	{
 
		this->InitNested(desc, 0);
 

	
 
		this->parent = parent;
 
		this->afilter = CS_ALPHANUMERAL;
 
		InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size);
 
		this->SetFocusedWidget(NCPWW_PASSWORD);
 
		this->SetFocusedWidget(WID_NCP_PASSWORD);
 
	}
 

	
 
	void OnOk()
 
	{
 
		if (this->IsWidgetLowered(NCPWW_SAVE_AS_DEFAULT_PASSWORD)) {
 
		if (this->IsWidgetLowered(WID_NCP_SAVE_AS_DEFAULT_PASSWORD)) {
 
			snprintf(_settings_client.network.default_company_pass, lengthof(_settings_client.network.default_company_pass), "%s", this->edit_str_buf);
 
		}
 

	
 
		NetworkChangeCompanyPassword(_local_company, this->edit_str_buf);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		this->DrawWidgets();
 
		this->DrawEditBox(NCPWW_PASSWORD);
 
		this->DrawEditBox(WID_NCP_PASSWORD);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		switch (widget) {
 
			case NCPWW_OK:
 
			case WID_NCP_OK:
 
				this->OnOk();
 
				/* FALL THROUGH */
 

	
 
			case NCPWW_CANCEL:
 
			case WID_NCP_CANCEL:
 
				delete this;
 
				break;
 

	
 
			case NCPWW_SAVE_AS_DEFAULT_PASSWORD:
 
				this->ToggleWidgetLoweredState(NCPWW_SAVE_AS_DEFAULT_PASSWORD);
 
			case WID_NCP_SAVE_AS_DEFAULT_PASSWORD:
 
				this->ToggleWidgetLoweredState(WID_NCP_SAVE_AS_DEFAULT_PASSWORD);
 
				this->SetDirty();
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnMouseLoop()
 
	{
 
		this->HandleEditBox(4);
 
	}
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		EventState state = ES_NOT_HANDLED;
 
		switch (this->HandleEditBoxKey(NCPWW_PASSWORD, key, keycode, state)) {
 
		switch (this->HandleEditBoxKey(WID_NCP_PASSWORD, key, keycode, state)) {
 
			default: break;
 

	
 
			case HEBR_CONFIRM:
 
				this->OnOk();
 
				/* FALL THROUGH */
 

	
 
			case HEBR_CANCEL:
 
				delete this;
 
				break;
 
		}
 
		return state;
 
	}
 

	
 
	virtual void OnOpenOSKWindow(int wid)
 
	{
 
		ShowOnScreenKeyboard(this, wid, NCPWW_CANCEL, NCPWW_OK);
 
		ShowOnScreenKeyboard(this, wid, WID_NCP_CANCEL, WID_NCP_OK);
 
	}
 
};
 

	
 
static const NWidgetPart _nested_network_company_password_window_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_COMPANY_PASSWORD_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, NCPWW_BACKGROUND),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_NCP_BACKGROUND),
 
		NWidget(NWID_VERTICAL), SetPIP(5, 5, 5),
 
			NWidget(NWID_HORIZONTAL), SetPIP(5, 5, 5),
 
				NWidget(WWT_TEXT, COLOUR_GREY, NCPWW_LABEL), SetDataTip(STR_COMPANY_VIEW_PASSWORD, STR_NULL),
 
				NWidget(WWT_EDITBOX, COLOUR_GREY, NCPWW_PASSWORD), SetMinimalSize(194, 12), SetDataTip(STR_COMPANY_VIEW_SET_PASSWORD, STR_NULL),
 
				NWidget(WWT_TEXT, COLOUR_GREY, WID_NCP_LABEL), SetDataTip(STR_COMPANY_VIEW_PASSWORD, STR_NULL),
 
				NWidget(WWT_EDITBOX, COLOUR_GREY, WID_NCP_PASSWORD), SetMinimalSize(194, 12), SetDataTip(STR_COMPANY_VIEW_SET_PASSWORD, STR_NULL),
 
			EndContainer(),
 
			NWidget(NWID_HORIZONTAL), SetPIP(5, 0, 5),
 
				NWidget(NWID_SPACER), SetFill(1, 0),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, NCPWW_SAVE_AS_DEFAULT_PASSWORD), SetMinimalSize(194, 12),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_NCP_SAVE_AS_DEFAULT_PASSWORD), SetMinimalSize(194, 12),
 
											SetDataTip(STR_COMPANY_PASSWORD_MAKE_DEFAULT, STR_COMPANY_PASSWORD_MAKE_DEFAULT_TOOLTIP),
 
			EndContainer(),
 
		EndContainer(),
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, NCPWW_CANCEL), SetFill(1, 0), SetDataTip(STR_BUTTON_CANCEL, STR_COMPANY_PASSWORD_CANCEL),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, NCPWW_OK), SetFill(1, 0), SetDataTip(STR_BUTTON_OK, STR_COMPANY_PASSWORD_OK),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NCP_CANCEL), SetFill(1, 0), SetDataTip(STR_BUTTON_CANCEL, STR_COMPANY_PASSWORD_CANCEL),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NCP_OK), SetFill(1, 0), SetDataTip(STR_BUTTON_OK, STR_COMPANY_PASSWORD_OK),
 
	EndContainer(),
 
};
 

	
 
static const WindowDesc _network_company_password_window_desc(
 
	WDP_AUTO, 0, 0,
 
	WC_COMPANY_PASSWORD_WINDOW, WC_NONE,
 
	WDF_UNCLICK_BUTTONS,
 
	_nested_network_company_password_window_widgets, lengthof(_nested_network_company_password_window_widgets)
 
);
 

	
 
void ShowNetworkCompanyPasswordWindow(Window *parent)
 
{
src/widgets/music_widget.h
Show inline comments
 
@@ -5,49 +5,49 @@
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file music_widget.h Types related to the music widgets. */
 

	
 
#ifndef WIDGETS_MUSIC_WIDGET_H
 
#define WIDGETS_MUSIC_WIDGET_H
 

	
 
/** Widgets of the WC_MUSIC_TRACK_SELECTION. */
 
enum MusicTrackSelectionWidgets {
 
	MTSW_LIST_LEFT,
 
	MTSW_PLAYLIST,
 
	MTSW_LIST_RIGHT,
 
	MTSW_ALL,
 
	MTSW_OLD,
 
	MTSW_NEW,
 
	MTSW_EZY,
 
	MTSW_CUSTOM1,
 
	MTSW_CUSTOM2,
 
	MTSW_CLEAR,
 
	WID_MTS_LIST_LEFT,  ///< Left button.
 
	WID_MTS_PLAYLIST,   ///< Playlist.
 
	WID_MTS_LIST_RIGHT, ///< Right button.
 
	WID_MTS_ALL,        ///< All button.
 
	WID_MTS_OLD,        ///< Old button.
 
	WID_MTS_NEW,        ///< New button.
 
	WID_MTS_EZY,        ///< Ezy button.
 
	WID_MTS_CUSTOM1,    ///< Custom1 button.
 
	WID_MTS_CUSTOM2,    ///< Custom2 button.
 
	WID_MTS_CLEAR,      ///< Clear button.
 
};
 

	
 
/** Widgets of the WC_MUSIC_WINDOW. */
 
enum MusicWidgets {
 
	MW_PREV,
 
	MW_NEXT,
 
	MW_STOP,
 
	MW_PLAY,
 
	MW_SLIDERS,
 
	MW_MUSIC_VOL,
 
	MW_EFFECT_VOL,
 
	MW_BACKGROUND,
 
	MW_TRACK,
 
	MW_TRACK_NR,
 
	MW_TRACK_TITLE,
 
	MW_TRACK_NAME,
 
	MW_SHUFFLE,
 
	MW_PROGRAMME,
 
	MW_ALL,
 
	MW_OLD,
 
	MW_NEW,
 
	MW_EZY,
 
	MW_CUSTOM1,
 
	MW_CUSTOM2,
 
	WID_M_PREV,        ///< Previous button.
 
	WID_M_NEXT,        ///< Next button.
 
	WID_M_STOP,        ///< Stop button.
 
	WID_M_PLAY,        ///< Play button.
 
	WID_M_SLIDERS,     ///< Sliders.
 
	WID_M_MUSIC_VOL,   ///< Music volume.
 
	WID_M_EFFECT_VOL,  ///< Effect volume.
 
	WID_M_BACKGROUND,  ///< Background of the window.
 
	WID_M_TRACK,       ///< Track playing.
 
	WID_M_TRACK_NR,    ///< Track number.
 
	WID_M_TRACK_TITLE, ///< Track title.
 
	WID_M_TRACK_NAME,  ///< Track name.
 
	WID_M_SHUFFLE,     ///< Shuffle button.
 
	WID_M_PROGRAMME,   ///< Program button.
 
	WID_M_ALL,         ///< All button.
 
	WID_M_OLD,         ///< Old button.
 
	WID_M_NEW,         ///< New button.
 
	WID_M_EZY,         ///< Ezy button.
 
	WID_M_CUSTOM1,     ///< Custom1 button.
 
	WID_M_CUSTOM2,     ///< Custom2 button.
 
};
 

	
 
#endif /* WIDGETS_MUSIC_WIDGET_H */
src/widgets/network_chat_widget.h
Show inline comments
 
@@ -5,21 +5,21 @@
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file network_chat_widget.h Types related to the network chat widgets. */
 

	
 
#ifndef WIDGETS_NETWORK_CHAT_WIDGET_H
 
#define WIDGETS_NETWORK_CHAT_WIDGET_H
 

	
 
/** Widgets of the WC_SEND_NETWORK_MSG. */
 
enum NetWorkChatWidgets {
 
	NWCW_CLOSE,
 
	NWCW_BACKGROUND,
 
	NWCW_DESTINATION,
 
	NWCW_TEXTBOX,
 
	NWCW_SENDBUTTON,
 
	WID_NC_CLOSE,       ///< Close button.
 
	WID_NC_BACKGROUND,  ///< Background of the window.
 
	WID_NC_DESTINATION, ///< Destination.
 
	WID_NC_TEXTBOX,     ///< Textbox.
 
	WID_NC_SENDBUTTON,  ///< Send button.
 
};
 

	
 

	
 
#endif /* WIDGETS_NETWORK_CHAT_WIDGET_H */
src/widgets/network_content_widget.h
Show inline comments
 
@@ -4,44 +4,44 @@
 
 * This file is part of OpenTTD.
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file network_content_widget.h Types related to the network content widgets. */
 

	
 
#ifndef WIDGETS_NETWORK_CONTENT_WIDGET_H
 
#define WIDGETS_NETWORK_CONTENT_WIDGET_H
 

	
 
/** Widgets of the WC_NETWORK_STATUS_WINDOW (WC_NETWORK_STATUS_WINDOW is also used in NetworkJoinStatusWidgets). */
 
enum NetworkContentDownloadStatusWindowWidgets {
 
	NCDSWW_BACKGROUND, ///< Background
 
	NCDSWW_CANCELOK,   ///< (Optional) Cancel/OK button
 
enum NetworkContentDownloadStatusWidgets {
 
	WID_NCDS_BACKGROUND, ///< Background of the window.
 
	WID_NCDS_CANCELOK,   ///< (Optional) Cancel/OK button.
 
};
 

	
 
/** Widgets of the WC_NETWORK_WINDOW (WC_NETWORK_WINDOW is also used in NetworkGameWindowWidgets, NetworkStartServerWidgets, and NetworkLobbyWindowWidgets). */
 
enum NetworkContentListWindowWidgets {
 
	NCLWW_BACKGROUND,    ///< Resize button
 
enum NetworkContentListWidgets {
 
	WID_NCL_BACKGROUND,     ///< Resize button.
 

	
 
	NCLWW_FILTER_CAPT,   ///< Caption for the filter editbox
 
	NCLWW_FILTER,        ///< Filter editbox
 
	WID_NCL_FILTER_CAPT,    ///< Caption for the filter editbox.
 
	WID_NCL_FILTER,         ///< Filter editbox.
 

	
 
	NCLWW_CHECKBOX,      ///< Button above checkboxes
 
	NCLWW_TYPE,          ///< 'Type' button
 
	NCLWW_NAME,          ///< 'Name' button
 
	WID_NCL_CHECKBOX,       ///< Button above checkboxes.
 
	WID_NCL_TYPE,           ///< 'Type' button.
 
	WID_NCL_NAME,           ///< 'Name' button.
 

	
 
	NCLWW_MATRIX,        ///< Panel with list of content
 
	NCLWW_SCROLLBAR,     ///< Scrollbar of matrix
 
	WID_NCL_MATRIX,         ///< Panel with list of content.
 
	WID_NCL_SCROLLBAR,      ///< Scrollbar of matrix.
 

	
 
	NCLWW_DETAILS,       ///< Panel with content details
 
	WID_NCL_DETAILS,        ///< Panel with content details.
 

	
 
	NCLWW_SELECT_ALL,    ///< 'Select all' button
 
	NCLWW_SELECT_UPDATE, ///< 'Select updates' button
 
	NCLWW_UNSELECT,      ///< 'Unselect all' button
 
	NCLWW_OPEN_URL,      ///< 'Open url' button
 
	NCLWW_CANCEL,        ///< 'Cancel' button
 
	NCLWW_DOWNLOAD,      ///< 'Download' button
 
	WID_NCL_SELECT_ALL,     ///< 'Select all' button.
 
	WID_NCL_SELECT_UPDATE,  ///< 'Select updates' button.
 
	WID_NCL_UNSELECT,       ///< 'Unselect all' button.
 
	WID_NCL_OPEN_URL,       ///< 'Open url' button.
 
	WID_NCL_CANCEL,         ///< 'Cancel' button.
 
	WID_NCL_DOWNLOAD,       ///< 'Download' button.
 

	
 
	NCLWW_SEL_ALL_UPDATE, ///< #NWID_SELECTION widget for select all/update buttons.
 
	WID_NCL_SEL_ALL_UPDATE, ///< #NWID_SELECTION widget for select all/update buttons..
 
};
 

	
 
#endif /* WIDGETS_NETWORK_CONTENT_WIDGET_H */
src/widgets/network_widget.h
Show inline comments
 
@@ -3,126 +3,125 @@
 
/*
 
 * This file is part of OpenTTD.
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file network_widget.h Types related to the network widgets. */
 

	
 
#ifndef WIDGETS_NETWORK_WIDGET_H
 
#define WIDGETS_NETWORK_WIDGET_H
 

	
 
/** Widgets of the WC_NETWORK_WINDOW (WC_NETWORK_WINDOW is also used in NetworkContentListWindowWidgets, NetworkStartServerWidgets, and NetworkLobbyWindowWidgets). */
 
enum NetworkGameWindowWidgets {
 
	NGWW_MAIN,          ///< Main panel
 
/** Widgets of the WC_NETWORK_WINDOW (WC_NETWORK_WINDOW is also used in NetworkContentListWidgets, NetworkStartServerWidgets, and NetworkLobbyWidgets). */
 
enum NetworkGameWidgets {
 
	WID_NG_MAIN,               ///< Main panel.
 

	
 
	NGWW_CONNECTION,    ///< Label in front of connection droplist
 
	NGWW_CONN_BTN,      ///< 'Connection' droplist button
 
	NGWW_CLIENT_LABEL,  ///< Label in front of client name edit box
 
	NGWW_CLIENT,        ///< Panel with editbox to set client name
 
	WID_NG_CONNECTION,         ///< Label in front of connection droplist.
 
	WID_NG_CONN_BTN,           ///< 'Connection' droplist button.
 
	WID_NG_CLIENT_LABEL,       ///< Label in front of client name edit box.
 
	WID_NG_CLIENT,             ///< Panel with editbox to set client name.
 

	
 
	NGWW_HEADER,        ///< Header container of the matrix
 
	NGWW_NAME,          ///< 'Name' button
 
	NGWW_CLIENTS,       ///< 'Clients' button
 
	NGWW_MAPSIZE,       ///< 'Map size' button
 
	NGWW_DATE,          ///< 'Date' button
 
	NGWW_YEARS,         ///< 'Years' button
 
	NGWW_INFO,          ///< Third button in the game list panel
 
	WID_NG_HEADER,             ///< Header container of the matrix.
 
	WID_NG_NAME,               ///< 'Name' button.
 
	WID_NG_CLIENTS,            ///< 'Clients' button.
 
	WID_NG_MAPSIZE,            ///< 'Map size' button.
 
	WID_NG_DATE,               ///< 'Date' button.
 
	WID_NG_YEARS,              ///< 'Years' button.
 
	WID_NG_INFO,               ///< Third button in the game list panel.
 

	
 
	NGWW_MATRIX,        ///< Panel with list of games
 
	NGWW_SCROLLBAR,     ///< Scrollbar of matrix
 
	WID_NG_MATRIX,             ///< Panel with list of games.
 
	WID_NG_SCROLLBAR,          ///< Scrollbar of matrix.
 

	
 
	NGWW_LASTJOINED_LABEL, ///< Label "Last joined server:"
 
	NGWW_LASTJOINED,    ///< Info about the last joined server
 
	NGWW_LASTJOINED_SPACER, ///< Spacer after last joined server panel
 
	WID_NG_LASTJOINED_LABEL,   ///< Label "Last joined server:".
 
	WID_NG_LASTJOINED,         ///< Info about the last joined server.
 
	WID_NG_LASTJOINED_SPACER,  ///< Spacer after last joined server panel.
 

	
 
	NGWW_DETAILS,       ///< Panel with game details
 
	NGWW_DETAILS_SPACER, ///< Spacer for game actual details
 
	NGWW_JOIN,          ///< 'Join game' button
 
	NGWW_REFRESH,       ///< 'Refresh server' button
 
	NGWW_NEWGRF,        ///< 'NewGRF Settings' button
 
	NGWW_NEWGRF_SEL,    ///< Selection 'widget' to hide the NewGRF settings
 
	NGWW_NEWGRF_MISSING,     ///< 'Find missing NewGRF online' button
 
	NGWW_NEWGRF_MISSING_SEL, ///< Selection widget for the above button
 
	WID_NG_DETAILS,            ///< Panel with game details.
 
	WID_NG_DETAILS_SPACER,     ///< Spacer for game actual details.
 
	WID_NG_JOIN,               ///< 'Join game' button.
 
	WID_NG_REFRESH,            ///< 'Refresh server' button.
 
	WID_NG_NEWGRF,             ///< 'NewGRF Settings' button.
 
	WID_NG_NEWGRF_SEL,         ///< Selection 'widget' to hide the NewGRF settings.
 
	WID_NG_NEWGRF_MISSING,     ///< 'Find missing NewGRF online' button.
 
	WID_NG_NEWGRF_MISSING_SEL, ///< Selection widget for the above button.
 

	
 
	NGWW_FIND,          ///< 'Find server' button
 
	NGWW_ADD,           ///< 'Add server' button
 
	NGWW_START,         ///< 'Start server' button
 
	NGWW_CANCEL,        ///< 'Cancel' button
 
	WID_NG_FIND,               ///< 'Find server' button.
 
	WID_NG_ADD,                ///< 'Add server' button.
 
	WID_NG_START,              ///< 'Start server' button.
 
	WID_NG_CANCEL,             ///< 'Cancel' button.
 
};
 

	
 
/** Widgets of the WC_NETWORK_WINDOW (WC_NETWORK_WINDOW is also used in NetworkContentListWindowWidgets, NetworkGameWindowWidgets, and NetworkLobbyWindowWidgets). */
 
/** Widgets of the WC_NETWORK_WINDOW (WC_NETWORK_WINDOW is also used in NetworkContentListWidgets, NetworkGameWidgets, and NetworkLobbyWidgets). */
 
enum NetworkStartServerWidgets {
 
	NSSW_BACKGROUND,
 
	NSSW_GAMENAME_LABEL,
 
	NSSW_GAMENAME,          ///< Background for editbox to set game name
 
	NSSW_SETPWD,            ///< 'Set password' button
 
	NSSW_CONNTYPE_LABEL,
 
	NSSW_CONNTYPE_BTN,      ///< 'Connection type' droplist button
 
	NSSW_CLIENTS_LABEL,
 
	NSSW_CLIENTS_BTND,      ///< 'Max clients' downarrow
 
	NSSW_CLIENTS_TXT,       ///< 'Max clients' text
 
	NSSW_CLIENTS_BTNU,      ///< 'Max clients' uparrow
 
	NSSW_COMPANIES_LABEL,
 
	NSSW_COMPANIES_BTND,    ///< 'Max companies' downarrow
 
	NSSW_COMPANIES_TXT,     ///< 'Max companies' text
 
	NSSW_COMPANIES_BTNU,    ///< 'Max companies' uparrow
 
	NSSW_SPECTATORS_LABEL,
 
	NSSW_SPECTATORS_BTND,   ///< 'Max spectators' downarrow
 
	NSSW_SPECTATORS_TXT,    ///< 'Max spectators' text
 
	NSSW_SPECTATORS_BTNU,   ///< 'Max spectators' uparrow
 
	WID_NSS_BACKGROUND,        ///< Background of the window.
 
	WID_NSS_GAMENAME_LABEL,    ///< Label for the game name.
 
	WID_NSS_GAMENAME,          ///< Background for editbox to set game name.
 
	WID_NSS_SETPWD,            ///< 'Set password' button.
 
	WID_NSS_CONNTYPE_LABEL,    ///< Label for 'connection type'.
 
	WID_NSS_CONNTYPE_BTN,      ///< 'Connection type' droplist button.
 
	WID_NSS_CLIENTS_LABEL,     ///< Label for 'max clients'.
 
	WID_NSS_CLIENTS_BTND,      ///< 'Max clients' downarrow.
 
	WID_NSS_CLIENTS_TXT,       ///< 'Max clients' text.
 
	WID_NSS_CLIENTS_BTNU,      ///< 'Max clients' uparrow.
 
	WID_NSS_COMPANIES_LABEL,   ///< Label for 'max companies'.
 
	WID_NSS_COMPANIES_BTND,    ///< 'Max companies' downarrow.
 
	WID_NSS_COMPANIES_TXT,     ///< 'Max companies' text.
 
	WID_NSS_COMPANIES_BTNU,    ///< 'Max companies' uparrow.
 
	WID_NSS_SPECTATORS_LABEL,  ///< Label for 'max spectators'.
 
	WID_NSS_SPECTATORS_BTND,   ///< 'Max spectators' downarrow.
 
	WID_NSS_SPECTATORS_TXT,    ///< 'Max spectators' text.
 
	WID_NSS_SPECTATORS_BTNU,   ///< 'Max spectators' uparrow.
 

	
 
	NSSW_LANGUAGE_LABEL,
 
	NSSW_LANGUAGE_BTN,      ///< 'Language spoken' droplist button
 
	WID_NSS_LANGUAGE_LABEL,    ///< Label for 'language spoken'.
 
	WID_NSS_LANGUAGE_BTN,      ///< 'Language spoken' droplist button.
 

	
 
	NSSW_GENERATE_GAME,     ///< New game button
 
	NSSW_LOAD_GAME,         ///< Load game button
 
	NSSW_PLAY_SCENARIO,     ///< Play scenario button
 
	NSSW_PLAY_HEIGHTMAP,    ///< Play heightmap button
 
	WID_NSS_GENERATE_GAME,     ///< New game button.
 
	WID_NSS_LOAD_GAME,         ///< Load game button.
 
	WID_NSS_PLAY_SCENARIO,     ///< Play scenario button.
 
	WID_NSS_PLAY_HEIGHTMAP,    ///< Play heightmap button.
 

	
 
	NSSW_CANCEL,            ///< 'Cancel' button
 
	WID_NSS_CANCEL,            ///< 'Cancel' button.
 
};
 

	
 
/** Widgets of the WC_NETWORK_WINDOW (WC_NETWORK_WINDOW is also used in NetworkContentListWindowWidgets, NetworkGameWindowWidgets, and NetworkStartServerWidgets). */
 
enum NetworkLobbyWindowWidgets {
 
	NLWW_BACKGROUND, ///< Background panel
 
	NLWW_TEXT,       ///< Heading text
 
	NLWW_HEADER,     ///< Header above list of companies
 
	NLWW_MATRIX,     ///< List of companies
 
	NLWW_SCROLLBAR,  ///< Scroll bar
 
	NLWW_DETAILS,    ///< Company details
 
	NLWW_JOIN,       ///< 'Join company' button
 
	NLWW_NEW,        ///< 'New company' button
 
	NLWW_SPECTATE,   ///< 'Spectate game' button
 
	NLWW_REFRESH,    ///< 'Refresh server' button
 
	NLWW_CANCEL,     ///< 'Cancel' button
 
/** Widgets of the WC_NETWORK_WINDOW (WC_NETWORK_WINDOW is also used in NetworkContentListWidgets, NetworkGameWidgets, and NetworkStartServerWidgets). */
 
enum NetworkLobbyWidgets {
 
	WID_NL_BACKGROUND, ///< Background of the window.
 
	WID_NL_TEXT,       ///< Heading text.
 
	WID_NL_HEADER,     ///< Header above list of companies.
 
	WID_NL_MATRIX,     ///< List of companies.
 
	WID_NL_SCROLLBAR,  ///< Scroll bar.
 
	WID_NL_DETAILS,    ///< Company details.
 
	WID_NL_JOIN,       ///< 'Join company' button.
 
	WID_NL_NEW,        ///< 'New company' button.
 
	WID_NL_SPECTATE,   ///< 'Spectate game' button.
 
	WID_NL_REFRESH,    ///< 'Refresh server' button.
 
	WID_NL_CANCEL,     ///< 'Cancel' button.
 
};
 

	
 
/** Widgets of the WC_CLIENT_LIST. */
 
enum ClientListWidgets {
 
	CLW_PANEL,
 
	WID_CL_PANEL, ///< Panel of the window.
 
};
 

	
 
/** Widgets of the WC_CLIENT_LIST_POPUP. */
 
enum ClientListPopupWidgets {
 
	CLPW_PANEL,
 
	WID_CLP_PANEL, ///< Panel of the window.
 
};
 

	
 
/** Widgets of the WC_NETWORK_STATUS_WINDOW (WC_NETWORK_STATUS_WINDOW is also used in NetworkContentDownloadStatusWindowWidgets). */
 
/** Widgets of the WC_NETWORK_STATUS_WINDOW (WC_NETWORK_STATUS_WINDOW is also used in NetworkContentDownloadStatusWidgets). */
 
enum NetworkJoinStatusWidgets {
 
	NJSW_BACKGROUND, ///< Background
 
	NJSW_CANCELOK,   ///< Cancel/OK button
 
	WID_NJS_BACKGROUND, ///< Background of the window.
 
	WID_NJS_CANCELOK,   ///< Cancel / OK button.
 
};
 

	
 
/** Widgets of the WC_COMPANY_PASSWORD_WINDOW. */
 
enum NetworkCompanyPasswordWindowWidgets {
 
	NCPWW_BACKGROUND,               ///< The background of the interface
 
	NCPWW_LABEL,                    ///< Label in front of the password field
 
	NCPWW_PASSWORD,                 ///< Input field for the password
 
	NCPWW_SAVE_AS_DEFAULT_PASSWORD, ///< Toggle 'button' for saving the current password as default password
 
	NCPWW_CANCEL,                   ///< Close the window without changing anything
 
	NCPWW_OK,                       ///< Safe the password etc.
 
enum NetworkCompanyPasswordWidgets {
 
	WID_NCP_BACKGROUND,               ///< Background of the window.
 
	WID_NCP_LABEL,                    ///< Label in front of the password field.
 
	WID_NCP_PASSWORD,                 ///< Input field for the password.
 
	WID_NCP_SAVE_AS_DEFAULT_PASSWORD, ///< Toggle 'button' for saving the current password as default password.
 
	WID_NCP_CANCEL,                   ///< Close the window without changing anything.
 
	WID_NCP_OK,                       ///< Safe the password etc.
 
};
 

	
 

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