Changeset - r17971:2adf1b724154
[Not reviewed]
master
0 2 0
rubidium - 13 years ago 2011-08-21 12:49:51
rubidium@openttd.org
(svn r22790) -Codechange: add callback for when NewGRF scanning is complete
2 files changed with 15 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/newgrf_config.cpp
Show inline comments
 
@@ -591,14 +591,17 @@ static int CDECL GRFSorter(GRFConfig * c
 
	const GRFConfig *c1 = *p1;
 
	const GRFConfig *c2 = *p2;
 

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

	
 
/** Scan for all NewGRFs. */
 
void ScanNewGRFFiles()
 
/**
 
 * Scan for all NewGRFs.
 
 * @param callback The callback to call after the scanning is complete.
 
 */
 
void ScanNewGRFFiles(NewGRFScanCallback *callback)
 
{
 
	ClearGRFConfigList(&_all_grfs);
 

	
 
	TarScanner::DoScan();
 

	
 
	DEBUG(grf, 1, "Scanning for NewGRFs");
 
@@ -633,12 +636,13 @@ void ScanNewGRFFiles()
 
#endif
 
	}
 

	
 
	/* Yes... these are the NewGRF windows */
 
	InvalidateWindowClassesData(WC_SAVELOAD);
 
	InvalidateWindowData(WC_GAME_OPTIONS, 0, GOID_NEWGRF_RESCANNED);
 
	if (callback != NULL) callback->OnNewGRFsScanned();
 
}
 

	
 

	
 
/**
 
 * Find a NewGRF in the scanned list.
 
 * @param grfid GRFID to look for,
src/newgrf_config.h
Show inline comments
 
@@ -185,13 +185,21 @@ enum FindGRFConfigMode {
 

	
 
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
 

	
 
void ScanNewGRFFiles();
 
/** 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 = NULL);
 
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);
0 comments (0 inline, 0 general)