mirror of https://github.com/OpenTTD/OpenTTD
(svn r22790) -Codechange: add callback for when NewGRF scanning is complete
parent
e99aec39ef
commit
d7593d8815
|
@ -594,8 +594,11 @@ static int CDECL GRFSorter(GRFConfig * const *p1, GRFConfig * const *p2)
|
||||||
return strcasecmp(c1->GetName(), c2->GetName());
|
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);
|
ClearGRFConfigList(&_all_grfs);
|
||||||
|
|
||||||
|
@ -636,6 +639,7 @@ void ScanNewGRFFiles()
|
||||||
/* Yes... these are the NewGRF windows */
|
/* Yes... these are the NewGRF windows */
|
||||||
InvalidateWindowClassesData(WC_SAVELOAD);
|
InvalidateWindowClassesData(WC_SAVELOAD);
|
||||||
InvalidateWindowData(WC_GAME_OPTIONS, 0, GOID_NEWGRF_RESCANNED);
|
InvalidateWindowData(WC_GAME_OPTIONS, 0, GOID_NEWGRF_RESCANNED);
|
||||||
|
if (callback != NULL) callback->OnNewGRFsScanned();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,15 @@ extern GRFConfig *_grfconfig; ///< First item in list of current GRF set
|
||||||
extern GRFConfig *_grfconfig_newgame; ///< First item in list of default 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
|
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();
|
void CheckForMissingSprites();
|
||||||
const GRFConfig *FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8 *md5sum = NULL, uint32 desired_version = 0);
|
const GRFConfig *FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8 *md5sum = NULL, uint32 desired_version = 0);
|
||||||
GRFConfig *GetGRFConfig(uint32 grfid, uint32 mask = 0xFFFFFFFF);
|
GRFConfig *GetGRFConfig(uint32 grfid, uint32 mask = 0xFFFFFFFF);
|
||||||
|
|
Loading…
Reference in New Issue