mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 02:19:41 +00:00
(svn r22820) -Codechange: perform a full (re)draw cycle in the first draw during progress instead of waiting 200ms
This commit is contained in:
parent
38ad276acc
commit
70179db81e
@ -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();
|
||||
|
@ -2527,6 +2527,7 @@ STR_NEWGRF_INVALID_INDUSTRYTYPE :<invalid indust
|
||||
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}
|
||||
|
@ -629,14 +629,7 @@ static int CDECL GRFSorter(GRFConfig * const *p1, GRFConfig * const *p2)
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1787,7 +1787,13 @@ struct ScanProgressWindow : public Window {
|
||||
void UpdateNewGRFScanStatus(uint num, const char *name)
|
||||
{
|
||||
free(this->last_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;
|
||||
|
||||
|
@ -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 = ThreadMutex::New();
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user