Changeset - r18001:8d1b53a88f0a
[Not reviewed]
master
0 6 0
rubidium - 13 years ago 2011-08-24 12:18:53
rubidium@openttd.org
(svn r22820) -Codechange: perform a full (re)draw cycle in the first draw during progress instead of waiting 200ms
6 files changed with 32 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/gfx.cpp
Show inline comments
 
@@ -1561,7 +1561,7 @@ void DrawDirtyBlocks()
 
		_modal_progress_work_mutex->EndCritical();
 

	
 
		/* Wait a while and update _realtime_tick so we are given the rights */
 
		CSleep(MODAL_PROGRESS_REDRAW_TIMEOUT);
 
		if (!IsFirstModalProgressLoop()) CSleep(MODAL_PROGRESS_REDRAW_TIMEOUT);
 
		_realtime_tick += MODAL_PROGRESS_REDRAW_TIMEOUT;
 
		_modal_progress_paint_mutex->BeginCritical();
 
		_modal_progress_work_mutex->BeginCritical();
src/lang/english.txt
Show inline comments
 
@@ -2527,6 +2527,7 @@ STR_NEWGRF_INVALID_INDUSTRYTYPE         
 
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}
 
STR_NEWGRF_SCAN_ARCHIVES                                        :Scanning for archives
 

	
 
# Sign list window
 
STR_SIGN_LIST_CAPTION                                           :{WHITE}Sign List - {COMMA} Sign{P "" s}
src/newgrf_config.cpp
Show inline comments
 
@@ -629,14 +629,7 @@ static int CDECL GRFSorter(GRFConfig * c
 
 */
 
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);
 

	
 
@@ -694,12 +687,19 @@ void DoScanNewGRFFiles(void *callback)
 
 */
 
void ScanNewGRFFiles(NewGRFScanCallback *callback)
 
{
 
	/* First set the modal progress. This ensures that it will eventually let go of the paint mutex. */
 
	SetModalProgress(true);
 
	/* Only then can we really start, especially by marking the whole screen dirty. Get those other windows hidden!. */
 
	MarkWholeScreenDirty();
 

	
 
	if (!_video_driver->HasGUI() || !ThreadObject::New(&DoScanNewGRFFiles, callback, NULL)) {
 
		_modal_progress_work_mutex->EndCritical();
 
		_modal_progress_paint_mutex->EndCritical();
 
		DoScanNewGRFFiles(callback);
 
		_modal_progress_paint_mutex->BeginCritical();
 
		_modal_progress_work_mutex->BeginCritical();
 
	} else {
 
		UpdateNewGRFScanStatus(0, NULL);
 
	}
 
}
 

	
src/newgrf_gui.cpp
Show inline comments
 
@@ -1787,7 +1787,13 @@ struct ScanProgressWindow : public Windo
 
	void UpdateNewGRFScanStatus(uint num, const char *name)
 
	{
 
		free(this->last_name);
 
		this->last_name = strdup(name);
 
		if (name == NULL) {
 
			char buf[256];
 
			GetString(buf, STR_NEWGRF_SCAN_ARCHIVES, lastof(buf));
 
			this->last_name = strdup(buf);
 
		} else {
 
			this->last_name = strdup(name);
 
		}
 
		this->scanned = num;
 
		if (num > _settings_client.gui.last_newgrf_count) _settings_client.gui.last_newgrf_count = num;
 

	
src/progress.cpp
Show inline comments
 
@@ -15,6 +15,7 @@
 

	
 
/** Are we in a modal progress or not? */
 
bool _in_modal_progress = false;
 
bool _first_in_modal_loop = false;
 
/** Rights for the performing work. */
 
ThreadMutex *_modal_progress_work_mutex = ThreadMutex::New();
 
/** Rights for the painting. */
 
@@ -22,9 +23,23 @@ ThreadMutex *_modal_progress_paint_mutex
 

	
 
/**
 
 * Set the modal progress state.
 
 * @note Makes IsFirstModalProgressLoop return true for the next call.
 
 * @param state The new state; are we modal or not?
 
 */
 
void SetModalProgress(bool state)
 
{
 
	_in_modal_progress = state;
 
	_first_in_modal_loop = true;
 
}
 

	
 
/**
 
 * Check whether this is the first modal progress loop.
 
 * @note Set by SetModalProgress, unset by calling this method.
 
 * @return True if this is the first loop.
 
 */
 
bool IsFirstModalProgressLoop()
 
{
 
	bool ret = _first_in_modal_loop;
 
	_first_in_modal_loop = false;
 
	return ret;
 
}
src/progress.h
Show inline comments
 
@@ -26,10 +26,7 @@ static inline bool HasModalProgress()
 
	return _in_modal_progress;
 
}
 

	
 
/**
 
 * Set the modal progress state.
 
 * @param state The new state; are we modal or not?
 
 */
 
bool IsFirstModalProgressLoop();
 
void SetModalProgress(bool state);
 

	
 
extern class ThreadMutex *_modal_progress_work_mutex;
0 comments (0 inline, 0 general)