diff options
author | rubidium <rubidium@openttd.org> | 2011-08-24 12:18:53 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2011-08-24 12:18:53 +0000 |
commit | 70179db81e5a7fff78b558de9f39521c44a16886 (patch) | |
tree | a5c98947d09effd5e5005211b82c18769e4845b3 | |
parent | 38ad276acc6f108162c4255b837d4c450b91f23d (diff) | |
download | openttd-70179db81e5a7fff78b558de9f39521c44a16886.tar.xz |
(svn r22820) -Codechange: perform a full (re)draw cycle in the first draw during progress instead of waiting 200ms
-rw-r--r-- | src/gfx.cpp | 2 | ||||
-rw-r--r-- | src/lang/english.txt | 1 | ||||
-rw-r--r-- | src/newgrf_config.cpp | 14 | ||||
-rw-r--r-- | src/newgrf_gui.cpp | 8 | ||||
-rw-r--r-- | src/progress.cpp | 15 | ||||
-rw-r--r-- | src/progress.h | 5 |
6 files changed, 32 insertions, 13 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp index 88943534c..c5fbcac2f 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -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(); diff --git a/src/lang/english.txt b/src/lang/english.txt index fdf5a5b84..80601c1aa 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -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} diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index 69bcf6f7a..ad73f5b3d 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -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); } } diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 8fcc38c7c..ca1d13f33 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -1787,7 +1787,13 @@ struct ScanProgressWindow : public Window { 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; diff --git a/src/progress.cpp b/src/progress.cpp index ac34afd07..208f681a6 100644 --- a/src/progress.cpp +++ b/src/progress.cpp @@ -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; } diff --git a/src/progress.h b/src/progress.h index 85a27de72..eec369b23 100644 --- a/src/progress.h +++ b/src/progress.h @@ -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; |