Changeset - r17978:c07585e51a28
[Not reviewed]
master
0 6 0
rubidium - 13 years ago 2011-08-21 12:53:13
rubidium@openttd.org
(svn r22797) -Add: progress bar for scanning NewGRFs
6 files changed with 141 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -2476,96 +2476,101 @@ STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE  
 
STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED                        :Too many NewGRFs are loaded
 
STR_NEWGRF_ERROR_STATIC_GRF_CAUSES_DESYNC                       :Loading {2:RAW_STRING} as static NewGRF with {4:RAW_STRING} could cause desyncs
 
STR_NEWGRF_ERROR_UNEXPECTED_SPRITE                              :Unexpected sprite
 
STR_NEWGRF_ERROR_UNKNOWN_PROPERTY                               :Unknown Action 0 property
 
STR_NEWGRF_ERROR_INVALID_ID                                     :Attempt to use invalid ID
 
STR_NEWGRF_ERROR_CORRUPT_SPRITE                                 :{YELLOW}{RAW_STRING} contains a corrupt sprite. All corrupt sprites will be shown as a red question mark (?)
 
STR_NEWGRF_ERROR_MULTIPLE_ACTION_8                              :Contains multiple Action 8 entries
 
STR_NEWGRF_ERROR_READ_BOUNDS                                    :Read past end of pseudo-sprite
 
STR_NEWGRF_ERROR_MISSING_SPRITES                                :{WHITE}The currently used base graphics set is missing a number of sprites.{}Please update the base graphics set
 
STR_NEWGRF_ERROR_GRM_FAILED                                     :Requested GRF resources not available
 
STR_NEWGRF_ERROR_FORCEFULLY_DISABLED                            :{2:RAW_STRING} was disabled by {4:RAW_STRING}
 
STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT                          :Invalid/unknown sprite layout format
 

	
 
# NewGRF related 'general' warnings
 
STR_NEWGRF_POPUP_CAUTION_CAPTION                                :{WHITE}Caution!
 
STR_NEWGRF_CONFIRMATION_TEXT                                    :{YELLOW}You are about to make changes to a running game. This can crash OpenTTD or break the game state. Do not file bug reports about these issues.{}Are you absolutely sure about this?
 

	
 
STR_NEWGRF_DUPLICATE_GRFID                                      :{WHITE}Can't add file: duplicate GRF ID
 
STR_NEWGRF_COMPATIBLE_LOADED                                    :{ORANGE}Matching file not found (compatible GRF loaded)
 

	
 
STR_NEWGRF_COMPATIBLE_LOAD_WARNING                              :{WHITE}Compatible GRF(s) loaded for missing files
 
STR_NEWGRF_DISABLED_WARNING                                     :{WHITE}Missing GRF file(s) have been disabled
 
STR_NEWGRF_UNPAUSE_WARNING_TITLE                                :{YELLOW}Missing GRF file(s)
 
STR_NEWGRF_UNPAUSE_WARNING                                      :{WHITE}Unpausing can crash OpenTTD. Do not file bug reports for subsequent crashes.{}Do you really want to unpause?
 

	
 
# NewGRF status
 
STR_NEWGRF_LIST_NONE                                            :None
 
STR_NEWGRF_LIST_ALL_FOUND                                       :All files present
 
STR_NEWGRF_LIST_COMPATIBLE                                      :{YELLOW}Found compatible files
 
STR_NEWGRF_LIST_MISSING                                         :{RED}Missing files
 

	
 
# NewGRF 'it's broken' warnings
 
STR_NEWGRF_BROKEN                                               :{WHITE}Behaviour of NewGRF '{0:RAW_STRING}' is likely to cause desyncs and/or crashes
 
STR_NEWGRF_BROKEN_POWERED_WAGON                                 :{WHITE}It changed powered-wagon state for '{1:ENGINE}' when not inside a depot
 
STR_NEWGRF_BROKEN_VEHICLE_LENGTH                                :{WHITE}It changed vehicle length for '{1:ENGINE}' when not inside a depot
 
STR_BROKEN_VEHICLE_LENGTH                                       :{WHITE}Train '{VEHICLE}' belonging to '{COMPANY}' has invalid length. It is probably caused by problems with NewGRFs. Game may desync or crash
 

	
 
STR_NEWGRF_BUGGY                                                :{WHITE}NewGRF '{0:RAW_STRING}' provides incorrect information
 
STR_NEWGRF_BUGGY_ARTICULATED_CARGO                              :{WHITE}Cargo/refit information for '{1:ENGINE}' differs from purchase list after construction. This might cause autorenew/-replace to fail refitting correctly
 
STR_NEWGRF_BUGGY_ENDLESS_PRODUCTION_CALLBACK                    :{WHITE}'{1:STRING}' caused an endless loop in the production callback
 

	
 
# 'User removed essential NewGRFs'-placeholders for stuff without specs
 
STR_NEWGRF_INVALID_CARGO                                        :<invalid cargo>
 
STR_NEWGRF_INVALID_CARGO_ABBREV                                 :??
 
STR_NEWGRF_INVALID_CARGO_QUANTITY                               :{COMMA} of <invalid cargo>
 
STR_NEWGRF_INVALID_ENGINE                                       :<invalid vehicle model>
 
STR_NEWGRF_INVALID_INDUSTRYTYPE                                 :<invalid industry>
 

	
 
# NewGRF scanning window
 
STR_NEWGRF_SCAN_CAPTION                                         :{WHITE}Scanning NewGRFs
 
STR_NEWGRF_SCAN_MESSAGE                                         :{BLACK}Scanning NewGRFs. Depending on the amount this can take a while...
 
STR_NEWGRF_SCAN_STATUS                                          :{BLACK}{NUM} NewGRF{P "" s} scanned out of an estimated {NUM} NewGRF{P "" s}
 

	
 
# Sign list window
 
STR_SIGN_LIST_CAPTION                                           :{WHITE}Sign List - {COMMA} Sign{P "" s}
 
STR_SIGN_LIST_MATCH_CASE                                        :{BLACK}Match case
 
STR_SIGN_LIST_CLEAR                                             :{BLACK}Clear filter
 
STR_SIGN_LIST_MATCH_CASE_TOOLTIP                                :{BLACK}Toggle matching case when comparing sign names against the filter string
 
STR_SIGN_LIST_CLEAR_TOOLTIP                                     :{BLACK}Clear filter string
 

	
 
# Sign window
 
STR_EDIT_SIGN_CAPTION                                           :{WHITE}Edit sign text
 
STR_EDIT_SIGN_NEXT_SIGN_TOOLTIP                                 :{BLACK}Go to next sign
 
STR_EDIT_SIGN_PREVIOUS_SIGN_TOOLTIP                             :{BLACK}Go to previous sign
 

	
 
STR_EDIT_SIGN_SIGN_OSKTITLE                                     :{BLACK}Enter a name for the sign
 

	
 
# Town directory window
 
STR_TOWN_DIRECTORY_CAPTION                                      :{WHITE}Towns
 
STR_TOWN_DIRECTORY_NONE                                         :{ORANGE}- None -
 
STR_TOWN_DIRECTORY_TOWN                                         :{ORANGE}{TOWN}{BLACK} ({COMMA})
 
STR_TOWN_DIRECTORY_LIST_TOOLTIP                                 :{BLACK}Town names - click on name to centre main view on town. Ctrl+Click opens a new viewport on town location
 
STR_TOWN_POPULATION                                             :{BLACK}World population: {COMMA}
 

	
 
# Town view window
 
STR_TOWN_VIEW_TOWN_CAPTION                                      :{WHITE}{TOWN}
 
STR_TOWN_VIEW_CITY_CAPTION                                      :{WHITE}{TOWN} (City)
 
STR_TOWN_VIEW_POPULATION_HOUSES                                 :{BLACK}Population: {ORANGE}{COMMA}{BLACK}  Houses: {ORANGE}{COMMA}
 
STR_TOWN_VIEW_PASSENGERS_LAST_MONTH_MAX                         :{BLACK}Passengers last month: {ORANGE}{COMMA}{BLACK}  max: {ORANGE}{COMMA}
 
STR_TOWN_VIEW_MAIL_LAST_MONTH_MAX                               :{BLACK}Mail last month: {ORANGE}{COMMA}{BLACK}  max: {ORANGE}{COMMA}
 
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH                              :{BLACK}Cargo needed for town growth:
 
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED                     :{ORANGE}{STRING}{BLACK} required
 
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_WINTER              :{ORANGE}{STRING}{BLACK} required in winter
 
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_LAST_MONTH                   :{ORANGE}{CARGO}{BLACK} delivered last month
 
STR_TOWN_VIEW_NOISE_IN_TOWN                                     :{BLACK}Noise limit in town: {ORANGE}{COMMA}{BLACK}  max: {ORANGE}{COMMA}
 
STR_TOWN_VIEW_CENTER_TOOLTIP                                    :{BLACK}Centre the main view on town location. Ctrl+Click opens a new viewport on town location
 
STR_TOWN_VIEW_LOCAL_AUTHORITY_BUTTON                            :{BLACK}Local authority
 
STR_TOWN_VIEW_LOCAL_AUTHORITY_TOOLTIP                           :{BLACK}Show information on local authority
 
STR_TOWN_VIEW_RENAME_TOOLTIP                                    :{BLACK}Change town name
 

	
 
STR_TOWN_VIEW_EXPAND_BUTTON                                     :{BLACK}Expand
 
STR_TOWN_VIEW_EXPAND_TOOLTIP                                    :{BLACK}Increase size of town
 
STR_TOWN_VIEW_DELETE_BUTTON                                     :{BLACK}Delete
 
STR_TOWN_VIEW_DELETE_TOOLTIP                                    :{BLACK}Delete this town completely
 

	
 
STR_TOWN_VIEW_RENAME_TOWN_BUTTON                                :Rename Town
 

	
 
# Town local authority window
 
STR_LOCAL_AUTHORITY_CAPTION                                     :{WHITE}{TOWN} local authority
 
STR_LOCAL_AUTHORITY_COMPANY_RATINGS                             :{BLACK}Transport company ratings:
 
STR_LOCAL_AUTHORITY_COMPANY_RATING                              :{YELLOW}{COMPANY} {COMPANYNUM}: {ORANGE}{STRING}
src/newgrf_config.cpp
Show inline comments
 
@@ -498,142 +498,146 @@ compatible_grf:
 
			 * in any case and set the name and info when it is not set already.
 
			 * When the GCF_COPY flag is set, it is certain that the filename is
 
			 * already a local one, so there is no need to replace it. */
 
			if (!HasBit(c->flags, GCF_COPY)) {
 
				free(c->filename);
 
				c->filename = strdup(f->filename);
 
				memcpy(c->ident.md5sum, f->ident.md5sum, sizeof(c->ident.md5sum));
 
				c->name->Release();
 
				c->name = f->name;
 
				c->name->AddRef();
 
				c->info->Release();
 
				c->info = f->name;
 
				c->info->AddRef();
 
				c->error = NULL;
 
				c->version = f->version;
 
				c->min_loadable_version = f->min_loadable_version;
 
				c->num_valid_params = f->num_valid_params;
 
				c->has_param_defaults = f->has_param_defaults;
 
				for (uint i = 0; i < f->param_info.Length(); i++) {
 
					if (f->param_info[i] == NULL) {
 
						*c->param_info.Append() = NULL;
 
					} else {
 
						*c->param_info.Append() = new GRFParameterInfo(*f->param_info[i]);
 
					}
 
				}
 
			}
 
		}
 
	}
 

	
 
	return res;
 
}
 

	
 
/** Helper for scanning for files with GRF as extension */
 
class GRFFileScanner : FileScanner {
 
	uint next_update; ///< The next (realtime tick) we do update the screen.
 
	uint num_scanned; ///< The number of GRFs we have scanned.
 

	
 
public:
 
	GRFFileScanner() : next_update(_realtime_tick), num_scanned(0)
 
	{
 
	}
 

	
 
	/* virtual */ bool AddFile(const char *filename, size_t basepath_length);
 

	
 
	/** Do the scan for GRFs. */
 
	static uint DoScan()
 
	{
 
		GRFFileScanner fs;
 
		return fs.Scan(".grf", DATA_DIR);
 
		int ret = fs.Scan(".grf", DATA_DIR);
 
		/* The number scanned and the number returned may not be the same;
 
		 * duplicate NewGRFs and base sets are ignored in the return value. */
 
		_settings_client.gui.last_newgrf_count = fs.num_scanned;
 
		return ret;
 
	}
 
};
 

	
 
bool GRFFileScanner::AddFile(const char *filename, size_t basepath_length)
 
{
 
	GRFConfig *c = new GRFConfig(filename + basepath_length);
 

	
 
	bool added = true;
 
	if (FillGRFDetails(c, false)) {
 
		if (_all_grfs == NULL) {
 
			_all_grfs = c;
 
		} else {
 
			/* Insert file into list at a position determined by its
 
			 * name, so the list is sorted as we go along */
 
			GRFConfig **pd, *d;
 
			bool stop = false;
 
			for (pd = &_all_grfs; (d = *pd) != NULL; pd = &d->next) {
 
				if (c->ident.grfid == d->ident.grfid && memcmp(c->ident.md5sum, d->ident.md5sum, sizeof(c->ident.md5sum)) == 0) added = false;
 
				/* Because there can be multiple grfs with the same name, make sure we checked all grfs with the same name,
 
				 *  before inserting the entry. So insert a new grf at the end of all grfs with the same name, instead of
 
				 *  just after the first with the same name. Avoids doubles in the list. */
 
				if (strcasecmp(c->GetName(), d->GetName()) <= 0) {
 
					stop = true;
 
				} else if (stop) {
 
					break;
 
				}
 
			}
 
			if (added) {
 
				c->next = d;
 
				*pd = c;
 
			}
 
		}
 
	} else {
 
		added = false;
 
	}
 

	
 
	this->num_scanned++;
 
	if (this->next_update <= _realtime_tick) {
 
		_modal_progress_work_mutex->EndCritical();
 
		_modal_progress_paint_mutex->BeginCritical();
 

	
 
		const char *name = NULL;
 
		if (c->name != NULL) name = GetGRFStringFromGRFText(c->name->text);
 
		if (name == NULL) name = c->filename;
 
		DEBUG(grf, 0, "Scanning %i: %s", this->num_scanned, name);
 
		UpdateNewGRFScanStatus(this->num_scanned, name);
 

	
 
		_modal_progress_work_mutex->BeginCritical();
 
		_modal_progress_paint_mutex->EndCritical();
 

	
 
		this->next_update = _realtime_tick + 200;
 
	}
 

	
 
	if (!added) {
 
		/* File couldn't be opened, or is either not a NewGRF or is a
 
		 * 'system' NewGRF or it's already known, so forget about it. */
 
		delete c;
 
	}
 

	
 
	return added;
 
}
 

	
 
/**
 
 * Simple sorter for GRFS
 
 * @param p1 the first GRFConfig *
 
 * @param p2 the second GRFConfig *
 
 * @return the same strcmp would return for the name of the NewGRF.
 
 */
 
static int CDECL GRFSorter(GRFConfig * const *p1, GRFConfig * const *p2)
 
{
 
	const GRFConfig *c1 = *p1;
 
	const GRFConfig *c2 = *p2;
 

	
 
	return strcasecmp(c1->GetName(), c2->GetName());
 
}
 

	
 
/**
 
 * Really perform the scan for all NewGRFs.
 
 * @param callback The callback to call after the scanning is complete.
 
 */
 
void DoScanNewGRFFiles(void *callback)
 
{
 
	/* First set the modal progress. This ensures that it will eventually let go of the paint mutex. */
 
	SetModalProgress(true);
 
	_modal_progress_paint_mutex->BeginCritical();
 

	
 
	/* Only then can we really start, especially by marking the whole screen dirty. Get those other windows hidden!. */
 
	MarkWholeScreenDirty();
 
	_modal_progress_work_mutex->BeginCritical();
 
	_modal_progress_paint_mutex->EndCritical();
 

	
 
	ClearGRFConfigList(&_all_grfs);
 

	
 
	TarScanner::DoScan();
src/newgrf_config.h
Show inline comments
 
@@ -173,49 +173,51 @@ struct GRFConfig : ZeroedMemoryAllocator
 
	void SetParameterDefaults();
 
	void SetSuitablePalette();
 
};
 

	
 
/** Method to find GRFs using FindGRFConfig */
 
enum FindGRFConfigMode {
 
	FGCM_EXACT,       ///< Only find Grfs matching md5sum
 
	FGCM_COMPATIBLE,  ///< Find best compatible Grf wrt. desired_version
 
	FGCM_NEWEST,      ///< Find newest Grf
 
	FGCM_NEWEST_VALID,///< Find newest Grf, ignoring Grfs with GCF_INVALID set
 
	FGCM_ANY,         ///< Use first found
 
};
 

	
 
extern GRFConfig *_all_grfs;          ///< First item in list of all scanned NewGRFs
 
extern GRFConfig *_grfconfig;         ///< First item in list of current GRF set up
 
extern GRFConfig *_grfconfig_newgame; ///< First item in list of default GRF set up
 
extern GRFConfig *_grfconfig_static;  ///< First item in list of static GRF set up
 

	
 
/** Callback for NewGRF scanning. */
 
struct NewGRFScanCallback {
 
	/** Make sure the right destructor gets called. */
 
	virtual ~NewGRFScanCallback() {}
 
	/** Called whenever the NewGRF scan completed. */
 
	virtual void OnNewGRFsScanned() = 0;
 
};
 

	
 
void ScanNewGRFFiles(NewGRFScanCallback *callback);
 
void CheckForMissingSprites();
 
const GRFConfig *FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8 *md5sum = NULL, uint32 desired_version = 0);
 
GRFConfig *GetGRFConfig(uint32 grfid, uint32 mask = 0xFFFFFFFF);
 
GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only);
 
void AppendStaticGRFConfigs(GRFConfig **dst);
 
void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el);
 
void ClearGRFConfigList(GRFConfig **config);
 
void ResetGRFConfig(bool defaults);
 
GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig);
 
bool FillGRFDetails(GRFConfig *config, bool is_static);
 
char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last);
 

	
 
/* In newgrf_gui.cpp */
 
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config);
 

	
 
#ifdef ENABLE_NETWORK
 
/** For communication about GRFs over the network */
 
#define UNKNOWN_GRF_NAME_PLACEHOLDER "<Unknown>"
 
GRFTextWrapper *FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create);
 
#endif /* ENABLE_NETWORK */
 

	
 
void UpdateNewGRFScanStatus(uint num, const char *name);
 

	
 
#endif /* NEWGRF_CONFIG_H */
src/newgrf_gui.cpp
Show inline comments
 
@@ -1642,48 +1642,167 @@ static const WindowDesc _newgrf_desc(
 
/**
 
 * Callback function for the newgrf 'apply changes' confirmation window
 
 * @param w Window which is calling this callback
 
 * @param confirmed boolean value, true when yes was clicked, false otherwise
 
 */
 
static void NewGRFConfirmationCallback(Window *w, bool confirmed)
 
{
 
	if (confirmed) {
 
		DeleteWindowByClass(WC_GRF_PARAMETERS);
 
		NewGRFWindow *nw = dynamic_cast<NewGRFWindow*>(w);
 

	
 
		GamelogStartAction(GLAT_GRF);
 
		GamelogGRFUpdate(_grfconfig, nw->actives); // log GRF changes
 
		CopyGRFConfigList(nw->orig_list, nw->actives, false);
 
		ReloadNewGRFData();
 
		GamelogStopAction();
 

	
 
		/* Show new, updated list */
 
		GRFConfig *c;
 
		int i = 0;
 
		for (c = nw->actives; c != NULL && c != nw->active_sel; c = c->next, i++) {}
 
		CopyGRFConfigList(&nw->actives, *nw->orig_list, false);
 
		for (c = nw->actives; c != NULL && i > 0; c = c->next, i--) {}
 
		nw->active_sel = c;
 
		nw->avails.ForceRebuild();
 

	
 
		w->InvalidateData();
 

	
 
		ReInitAllWindows();
 
		DeleteWindowByClass(WC_BUILD_OBJECT);
 
	}
 
}
 

	
 

	
 

	
 
/**
 
 * Setup the NewGRF gui
 
 * @param editable allow the user to make changes to the grfconfig in the window
 
 * @param show_params show information about what parameters are set for the grf files
 
 * @param exec_changes if changes are made to the list (editable is true), apply these
 
 *        changes immediately or only update the list
 
 * @param config pointer to a linked-list of grfconfig's that will be shown
 
 */
 
void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config)
 
{
 
	DeleteWindowByClass(WC_GAME_OPTIONS);
 
	new NewGRFWindow(&_newgrf_desc, editable, show_params, exec_changes, config);
 
}
 

	
 
/** The widgets for the scan progress. */
 
enum ScanProgressWindowWidgets {
 
	SPWW_PROGRESS_BAR,  ///< Simple progress bar.
 
	GPWW_PROGRESS_TEXT, ///< Text explaining what is happening.
 
};
 

	
 
/** Widgets for the progress window. */
 
static const NWidgetPart _nested_scan_progress_widgets[] = {
 
	NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_NEWGRF_SCAN_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
	NWidget(WWT_PANEL, COLOUR_GREY),
 
		NWidget(NWID_HORIZONTAL), SetPIP(20, 0, 20),
 
			NWidget(NWID_VERTICAL), SetPIP(11, 8, 11),
 
				NWidget(WWT_LABEL, INVALID_COLOUR), SetDataTip(STR_NEWGRF_SCAN_MESSAGE, STR_NULL), SetFill(1, 0),
 
				NWidget(WWT_EMPTY, INVALID_COLOUR, SPWW_PROGRESS_BAR), SetFill(1, 0),
 
				NWidget(WWT_EMPTY, INVALID_COLOUR, GPWW_PROGRESS_TEXT), SetFill(1, 0),
 
			EndContainer(),
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
 
/** Description of the widgets and other settings of the window. */
 
static const WindowDesc _scan_progress_desc(
 
	WDP_CENTER, 0, 0,
 
	WC_MODAL_PROGRESS, WC_NONE,
 
	WDF_UNCLICK_BUTTONS,
 
	_nested_scan_progress_widgets, lengthof(_nested_scan_progress_widgets)
 
);
 

	
 
/** Window for showing the progress of NewGRF scanning. */
 
struct ScanProgressWindow : public Window {
 
	char *last_name; ///< The name of the last 'seen' NewGRF.
 
	int scanned;     ///< The number of NewGRFs that we have seen.
 

	
 
	/** Create the window. */
 
	ScanProgressWindow() : Window(), last_name(NULL), scanned(0)
 
	{
 
		this->InitNested(&_scan_progress_desc);
 
	}
 

	
 
	/** Free the last name buffer. */
 
	~ScanProgressWindow()
 
	{
 
		free(last_name);
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		switch (widget) {
 
			case SPWW_PROGRESS_BAR: {
 
				SetDParam(0, 100);
 
				*size = GetStringBoundingBox(STR_GENERATION_PROGRESS);
 
				/* We need some spacing for the 'border' */
 
				size->height += 8;
 
				size->width += 8;
 
				break;
 
			}
 

	
 
			case GPWW_PROGRESS_TEXT:
 
				SetDParam(0, 9999);
 
				SetDParam(1, 9999);
 
				/* We really don't know the width. We could determine it by scanning the NewGRFs,
 
				 * but this is the status window for scanning them... */
 
				size->width = max(400U, GetStringBoundingBox(STR_NEWGRF_SCAN_STATUS).width);
 
				size->height = FONT_HEIGHT_NORMAL * 2 + WD_PAR_VSEP_NORMAL;
 
				break;
 
		}
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		switch (widget) {
 
			case SPWW_PROGRESS_BAR: {
 
				/* Draw the % complete with a bar and a text */
 
				DrawFrameRect(r.left, r.top, r.right, r.bottom, COLOUR_GREY, FR_BORDERONLY);
 
				uint percent = scanned * 100 / max(1U, _settings_client.gui.last_newgrf_count);
 
				DrawFrameRect(r.left + 1, r.top + 1, (int)((r.right - r.left - 2) * percent / 100) + r.left + 1, r.bottom - 1, COLOUR_MAUVE, FR_NONE);
 
				SetDParam(0, percent);
 
				DrawString(r.left, r.right, r.top + 5, STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_HOR_CENTER);
 
				break;
 
			}
 

	
 
			case GPWW_PROGRESS_TEXT:
 
				SetDParam(0, this->scanned);
 
				SetDParam(1, _settings_client.gui.last_newgrf_count);
 
				DrawString(r.left, r.right, r.top, STR_NEWGRF_SCAN_STATUS, TC_FROMSTRING, SA_HOR_CENTER);
 

	
 
				DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL, this->last_name == NULL ? "" : this->last_name, TC_BLACK, SA_HOR_CENTER);
 
				break;
 
		}
 
	}
 

	
 
	/**
 
	 * Update the NewGRF scan status.
 
	 * @param num  The number of NewGRFs scanned so far.
 
	 * @param name The name of the last scanned NewGRF.
 
	 */
 
	void UpdateNewGRFScanStatus(uint num, const char *name)
 
	{
 
		free(this->last_name);
 
		this->last_name = strdup(name);
 
		this->scanned = num;
 
		if (num > _settings_client.gui.last_newgrf_count) _settings_client.gui.last_newgrf_count = num;
 

	
 
		this->SetDirty();
 
	}
 
};
 

	
 
/**
 
 * Update the NewGRF scan status.
 
 * @param num  The number of NewGRFs scanned so far.
 
 * @param name The name of the last scanned NewGRF.
 
 */
 
void UpdateNewGRFScanStatus(uint num, const char *name)
 
{
 
	ScanProgressWindow *w  = dynamic_cast<ScanProgressWindow *>(FindWindowByClass(WC_MODAL_PROGRESS));
 
	if (w == NULL) w = new ScanProgressWindow();
 
	w->UpdateNewGRFScanStatus(num, name);
 
}
src/settings_type.h
Show inline comments
 
@@ -65,96 +65,97 @@ struct GUISettings {
 
	bool   autoscroll;                       ///< scroll when moving mouse to the edge
 
	byte   errmsg_duration;                  ///< duration of error message
 
	byte   hover_delay;                      ///< time required to activate a hover event, in seconds
 
	bool   link_terraform_toolbar;           ///< display terraform toolbar when displaying rail, road, water and airport toolbars
 
	uint8  smallmap_land_colour;             ///< colour used for land and heightmap at the smallmap
 
	bool   reverse_scroll;                   ///< right-Click-Scrolling scrolls in the opposite direction
 
	bool   smooth_scroll;                    ///< smooth scroll viewports
 
	bool   measure_tooltip;                  ///< show a permanent tooltip when dragging tools
 
	byte   liveries;                         ///< options for displaying company liveries, 0=none, 1=self, 2=all
 
	bool   prefer_teamchat;                  ///< choose the chat message target with <ENTER>, true=all clients, false=your team
 
	uint8  advanced_vehicle_list;            ///< use the "advanced" vehicle list
 
	uint8  loading_indicators;               ///< show loading indicators
 
	uint8  default_rail_type;                ///< the default rail type for the rail GUI
 
	uint8  toolbar_pos;                      ///< position of toolbars, 0=left, 1=center, 2=right
 
	uint8  statusbar_pos;                    ///< position of statusbar, 0=left, 1=center, 2=right
 
	uint8  window_snap_radius;               ///< windows snap at each other if closer than this
 
	uint8  window_soft_limit;                ///< soft limit of maximum number of non-stickied non-vital windows (0 = no limit)
 
	bool   disable_unsuitable_building;      ///< disable infrastructure building when no suitable vehicles are available
 
	byte   autosave;                         ///< how often should we do autosaves?
 
	bool   threaded_saves;                   ///< should we do threaded saves?
 
	bool   keep_all_autosave;                ///< name the autosave in a different way
 
	bool   autosave_on_exit;                 ///< save an autosave when you quit the game, but do not ask "Do you really want to quit?"
 
	uint8  date_format_in_default_names;     ///< should the default savegame/screenshot name use long dates (31th Dec 2008), short dates (31-12-2008) or ISO dates (2008-12-31)
 
	byte   max_num_autosaves;                ///< controls how many autosavegames are made before the game starts to overwrite (names them 0 to max_num_autosaves - 1)
 
	bool   population_in_label;              ///< show the population of a town in his label?
 
	uint8  right_mouse_btn_emulation;        ///< should we emulate right mouse clicking?
 
	uint8  scrollwheel_scrolling;            ///< scrolling using the scroll wheel?
 
	uint8  scrollwheel_multiplier;           ///< how much 'wheel' per incoming event from the OS?
 
	bool   timetable_arrival_departure;      ///< show arrivals and departures in vehicle timetables
 
	bool   left_mouse_btn_scrolling;         ///< left mouse button scroll
 
	bool   pause_on_newgame;                 ///< whether to start new games paused or not
 
	bool   enable_signal_gui;                ///< show the signal GUI when the signal button is pressed
 
	Year   coloured_news_year;               ///< when does newspaper become coloured?
 
	bool   timetable_in_ticks;               ///< whether to show the timetable in ticks rather than days
 
	bool   quick_goto;                       ///< Allow quick access to 'goto button' in vehicle orders window
 
	bool   auto_euro;                        ///< automatically switch to euro in 2002
 
	byte   drag_signals_density;             ///< many signals density
 
	Year   semaphore_build_before;           ///< build semaphore signals automatically before this year
 
	byte   news_message_timeout;             ///< how much longer than the news message "age" should we keep the message in the history
 
	bool   show_track_reservation;           ///< highlight reserved tracks.
 
	uint8  default_signal_type;              ///< the signal type to build by default.
 
	uint8  cycle_signal_types;               ///< what signal types to cycle with the build signal tool.
 
	byte   station_numtracks;                ///< the number of platforms to default on for rail stations
 
	byte   station_platlength;               ///< the platform length, in tiles, for rail stations
 
	bool   station_dragdrop;                 ///< whether drag and drop is enabled for stations
 
	bool   station_show_coverage;            ///< whether to highlight coverage area
 
	bool   persistent_buildingtools;         ///< keep the building tools active after usage
 
	bool   expenses_layout;                  ///< layout of expenses window
 
	uint32 last_newgrf_count;                ///< the numbers of NewGRFs we found during the last scan
 

	
 
	uint16 console_backlog_timeout;          ///< the minimum amount of time items should be in the console backlog before they will be removed in ~3 seconds granularity.
 
	uint16 console_backlog_length;           ///< the minimum amount of items in the console backlog before items will be removed.
 
#ifdef ENABLE_NETWORK
 
	uint16 network_chat_box_width;           ///< width of the chat box in pixels
 
	uint8  network_chat_box_height;          ///< height of the chat box in lines
 
	uint16 network_chat_timeout;             ///< timeout of chat messages in seconds
 
#endif
 

	
 
	uint8  developer;                        ///< print non-fatal warnings in console (>= 1), copy debug output to console (== 2)
 
	bool   show_date_in_logs;                ///< whether to show dates in console logs
 
	bool   newgrf_developer_tools;           ///< activate NewGRF developer tools and allow modifying NewGRFs in an existing game
 
	bool   ai_developer_tools;               ///< activate AI developer tools
 
	bool   scenario_developer;               ///< activate scenario developer: allow modifying NewGRFs in an existing game
 
	bool   newgrf_show_old_versions;         ///< whether to show old versions in the NewGRF list
 
	uint8  newgrf_default_palette;           ///< default palette to use for NewGRFs without action 14 palette information
 

	
 
	/**
 
	 * Returns true when the user has sufficient privileges to edit newgrfs on a running game
 
	 * @return whether the user has sufficient privileges to edit newgrfs in an existing game
 
	 */
 
	bool UserIsAllowedToChangeNewGRFs() const
 
	{
 
		return this->scenario_developer || this->newgrf_developer_tools;
 
	}
 
};
 

	
 
/** Settings related to music. */
 
struct MusicSettings {
 
	byte playlist;     ///< The playlist (number) to play
 
	byte music_vol;    ///< The requested music volume
 
	byte effect_vol;   ///< The requested effects volume
 
	byte custom_1[33]; ///< The order of the first custom playlist
 
	byte custom_2[33]; ///< The order of the second custom playlist
 
	bool playing;      ///< Whether music is playing
 
	bool shuffle;      ///< Whether to shuffle the music
 
};
 

	
 
/** Settings related to currency/unit systems. */
 
struct LocaleSettings {
 
	byte   currency;                         ///< currency we currently use
 
	byte   units;                            ///< unit system we show everything
 
	char  *digit_group_separator;            ///< thousand separator for non-currencies
 
	char  *digit_group_separator_currency;   ///< thousand separator for currencies
 
	char  *digit_decimal_separator;          ///< decimal separator
 
};
 

	
 
/** All settings related to the network. */
src/table/settings.ini
Show inline comments
 
@@ -2334,96 +2334,104 @@ type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_MULTISTRING
 
def      = 2
 
min      = 0
 
max      = 2
 
interval = 1
 
str      = STR_CONFIG_SETTING_CYCLE_SIGNAL_TYPES
 
strval   = STR_CONFIG_SETTING_CYCLE_SIGNAL_NORMAL
 

	
 
[SDTC_VAR]
 
var      = gui.station_numtracks
 
type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = 1
 
min      = 1
 
max      = 7
 

	
 
[SDTC_VAR]
 
var      = gui.station_platlength
 
type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = 5
 
min      = 1
 
max      = 7
 

	
 
[SDTC_BOOL]
 
var      = gui.station_dragdrop
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = true
 

	
 
[SDTC_BOOL]
 
var      = gui.station_show_coverage
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = false
 

	
 
[SDTC_BOOL]
 
var      = gui.persistent_buildingtools
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = true
 
str      = STR_CONFIG_SETTING_PERSISTENT_BUILDINGTOOLS
 

	
 
[SDTC_BOOL]
 
var      = gui.expenses_layout
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = false
 
str      = STR_CONFIG_SETTING_EXPENSES_LAYOUT
 
proc     = RedrawScreen
 

	
 
[SDTC_VAR]
 
var      = gui.last_newgrf_count
 
type     = SLE_UINT32
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = 100
 
min      = 0
 
max      = UINT32_MAX
 

	
 

	
 
; For the dedicated build we'll enable dates in logs by default.
 
[SDTC_BOOL]
 
ifdef    = DEDICATED
 
var      = gui.show_date_in_logs
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = true
 

	
 
[SDTC_BOOL]
 
ifndef   = DEDICATED
 
var      = gui.show_date_in_logs
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = false
 

	
 
[SDTC_VAR]
 
var      = gui.developer
 
type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = 1
 
min      = 0
 
max      = 2
 

	
 
[SDTC_BOOL]
 
var      = gui.newgrf_developer_tools
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = false
 
proc     = InvalidateNewGRFChangeWindows
 

	
 
[SDTC_BOOL]
 
var      = gui.ai_developer_tools
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = false
 

	
 
[SDTC_BOOL]
 
var      = gui.scenario_developer
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = false
 
proc     = InvalidateNewGRFChangeWindows
 

	
 
[SDTC_BOOL]
 
var      = gui.newgrf_show_old_versions
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = false
 

	
 
[SDTC_VAR]
 
var      = gui.newgrf_default_palette
 
type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
0 comments (0 inline, 0 general)