Changeset - r18608:c74fda8acdb0
[Not reviewed]
master
0 4 0
yexo - 13 years ago 2011-12-09 21:49:52
yexo@openttd.org
(svn r23465) -Feature [FS#4827]: add 'find missing content online' button to 'load savegame' and 'find network game' windows
4 files changed with 55 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/fios_gui.cpp
Show inline comments
 
@@ -79,12 +79,13 @@ enum SaveLoadWindowWidgets {
 
	SLWW_DELETE_SELECTION,     ///< same in here
 
	SLWW_SAVE_GAME,            ///< not to mention in here too
 
	SLWW_CONTENT_DOWNLOAD_SEL, ///< Selection 'stack' to 'hide' the content download
 
	SLWW_DETAILS,              ///< Panel with game details
 
	SLWW_NEWGRF_INFO,          ///< Button to open NewGgrf configuration
 
	SLWW_LOAD_BUTTON,          ///< Button to load game/scenario
 
	SLWW_MISSING_NEWGRFS,      ///< Button to find missing NewGRFs online
 
};
 

	
 
/** Load game/scenario with optional content download */
 
static const NWidgetPart _nested_load_dialog_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
@@ -111,12 +112,13 @@ static const NWidgetPart _nested_load_di
 
							SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
 
				EndContainer(),
 
			EndContainer(),
 
		EndContainer(),
 
		NWidget(WWT_PANEL, COLOUR_GREY),
 
			NWidget(WWT_EMPTY, INVALID_COLOUR, SLWW_DETAILS), SetResize(1, 1), SetFill(1, 1),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_MISSING_NEWGRFS), SetDataTip(STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON, STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
 
			NWidget(NWID_HORIZONTAL),
 
				NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
 
					NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_NEWGRF_INFO), SetDataTip(STR_INTRO_NEWGRF_SETTINGS, STR_NULL), SetFill(1, 0), SetResize(1, 0),
 
					NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLWW_LOAD_BUTTON), SetDataTip(STR_SAVELOAD_LOAD_BUTTON, STR_SAVELOAD_LOAD_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
 
				EndContainer(),
 
				NWidget(WWT_RESIZEBOX, COLOUR_GREY),
 
@@ -551,12 +553,22 @@ public:
 
			case SLWW_NEWGRF_INFO:
 
				if (_load_check_data.HasNewGrfs()) {
 
					ShowNewGRFSettings(false, false, false, &_load_check_data.grfconfig);
 
				}
 
				break;
 

	
 
			case SLWW_MISSING_NEWGRFS:
 
				if (!_network_available) {
 
					ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
 
				} else {
 
#if defined(ENABLE_NETWORK)
 
					ShowMissingContentWindow(_load_check_data.grfconfig);
 
#endif
 
				}
 
				break;
 

	
 
			case SLWW_DRIVES_DIRECTORIES_LIST: { // Click the listbox
 
				int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, SLWW_DRIVES_DIRECTORIES_LIST, WD_FRAMERECT_TOP);
 
				if (y == INT_MAX) return;
 

	
 
				const FiosItem *file = _fios_items.Get(y);
 

	
 
@@ -696,12 +708,14 @@ public:
 
				if (!gui_scope) break;
 
				if (_saveload_mode == SLD_LOAD_GAME || _saveload_mode == SLD_LOAD_SCENARIO) {
 
					this->SetWidgetDisabledState(SLWW_LOAD_BUTTON,
 
							this->selected == NULL || _load_check_data.HasErrors() || !(_load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs()));
 
					this->SetWidgetDisabledState(SLWW_NEWGRF_INFO,
 
							!_load_check_data.HasNewGrfs());
 
					this->SetWidgetDisabledState(SLWW_MISSING_NEWGRFS,
 
							!_load_check_data.HasNewGrfs() || _load_check_data.grf_compatibility == GLC_ALL_GOOD);
 
				}
 
				break;
 
			case 2:
 
				/* _fios_items changed */
 
				this->vscroll->SetCount(_fios_items.Length());
 
				this->selected = NULL;
src/network/network_content.h
Show inline comments
 
@@ -148,11 +148,13 @@ public:
 
};
 

	
 
extern ClientNetworkContentSocketHandler _network_content_client;
 

	
 
void ShowNetworkContentListWindow(ContentVector *cv = NULL, ContentType type = CONTENT_TYPE_END);
 

	
 
void ShowMissingContentWindow(const struct GRFConfig *list);
 

	
 
#else
 
static inline void ShowNetworkContentListWindow() {}
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif /* NETWORK_CONTENT_H */
src/network/network_gui.cpp
Show inline comments
 
@@ -16,12 +16,13 @@
 
#include "../fios.h"
 
#include "network_client.h"
 
#include "network_gui.h"
 
#include "network_gamelist.h"
 
#include "network.h"
 
#include "network_base.h"
 
#include "network_content.h"
 
#include "../gui.h"
 
#include "network_udp.h"
 
#include "../window_func.h"
 
#include "../gfx_func.h"
 
#include "../widgets/dropdown_func.h"
 
#include "../querystring_gui.h"
 
@@ -102,12 +103,14 @@ enum NetworkGameWindowWidgets {
 
	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
 

	
 
	NGWW_FIND,          ///< 'Find server' button
 
	NGWW_ADD,           ///< 'Add server' button
 
	NGWW_START,         ///< 'Start server' button
 
	NGWW_CANCEL,        ///< 'Cancel' button
 
};
 
@@ -600,12 +603,13 @@ public:
 
				!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->DrawWidgets();
 
		/* Edit box to set client name */
 
		this->DrawEditBox(NGWW_CLIENT);
 
	}
 

	
 
@@ -773,12 +777,16 @@ public:
 
				if (this->server != NULL) NetworkUDPQueryServer(this->server->address);
 
				break;
 

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

	
 
			case NGWW_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) {
 
@@ -957,12 +965,18 @@ static const NWidgetPart _nested_network
 
					EndContainer(),
 
				EndContainer(),
 
				/* RIGHT SIDE */
 
				NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, NGWW_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(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_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_SPACER), SetFill(1, 0),
 
							EndContainer(),
src/newgrf_gui.cpp
Show inline comments
 
@@ -1193,26 +1193,13 @@ struct NewGRFWindow : public QueryString
 
				if (!_network_available) {
 
					ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
 
				} else {
 
#if defined(ENABLE_NETWORK)
 
					this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window
 

	
 
					/* Only show the things in the current list, or everything when nothing's selected */
 
					ContentVector cv;
 
					for (const GRFConfig *c = this->actives; c != NULL; c = c->next) {
 
						if (c->status != GCS_NOT_FOUND && !HasBit(c->flags, GCF_COMPATIBLE)) continue;
 

	
 
						ContentInfo *ci = new ContentInfo();
 
						ci->type = CONTENT_TYPE_NEWGRF;
 
						ci->state = ContentInfo::DOES_NOT_EXIST;
 
						ttd_strlcpy(ci->name, c->GetName(), lengthof(ci->name));
 
						ci->unique_id = BSWAP32(c->ident.grfid);
 
						memcpy(ci->md5sum, HasBit(c->flags, GCF_COMPATIBLE) ? c->original_md5sum : c->ident.md5sum, sizeof(ci->md5sum));
 
						*cv.Append() = ci;
 
					}
 
					ShowNetworkContentListWindow(cv.Length() == 0 ? NULL : &cv, CONTENT_TYPE_NEWGRF);
 
					ShowMissingContentWindow(this->actives);
 
#endif
 
				}
 
				break;
 

	
 
			case SNGRFS_RESCAN_FILES:
 
			case SNGRFS_RESCAN_FILES2:
 
@@ -1503,12 +1490,36 @@ private:
 
		}
 

	
 
		this->vscroll2->SetCount(this->avails.Length()); // Update the scrollbar
 
	}
 
};
 

	
 
#if defined(ENABLE_NETWORK)
 
/**
 
 * Show the content list window with all missing grfs from the given list.
 
 * @param list The list of grfs to check for missings / not exactly matching ones.
 
 */
 
void ShowMissingContentWindow(const GRFConfig *list)
 
{
 
	/* Only show the things in the current list, or everything when nothing's selected */
 
	ContentVector cv;
 
	for (const GRFConfig *c = list; c != NULL; c = c->next) {
 
		if (c->status != GCS_NOT_FOUND && !HasBit(c->flags, GCF_COMPATIBLE)) continue;
 

	
 
		ContentInfo *ci = new ContentInfo();
 
		ci->type = CONTENT_TYPE_NEWGRF;
 
		ci->state = ContentInfo::DOES_NOT_EXIST;
 
		ttd_strlcpy(ci->name, c->GetName(), lengthof(ci->name));
 
		ci->unique_id = BSWAP32(c->ident.grfid);
 
		memcpy(ci->md5sum, HasBit(c->flags, GCF_COMPATIBLE) ? c->original_md5sum : c->ident.md5sum, sizeof(ci->md5sum));
 
		*cv.Append() = ci;
 
	}
 
	ShowNetworkContentListWindow(cv.Length() == 0 ? NULL : &cv, CONTENT_TYPE_NEWGRF);
 
}
 
#endif
 

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

	
 
NewGRFWindow::GUIGRFConfigList::SortFunction * const NewGRFWindow::sorter_funcs[] = {
 
	&NameSorter,
 
};
0 comments (0 inline, 0 general)