Add: make modal windows update more smooth
Basically, modal windows had their own thread-locking for what drawing was possible. This is a bit nonsense now we have a game-thread. And it makes much more sense to do things like NewGRFScan and GenerateWorld in the game-thread, and not in a thread next to the game-thread. This commit changes that: it removes the threads for NewGRFScan and GenerateWorld, and just runs the code in the game-thread. On regular intervals it allows the draw-thread to do a tick, which gives a much smoother look and feel. It does slow down NewGRFScan and GenerateWorld ever so slightly as it spends more time on drawing. But the slowdown is not measureable on my machines (with 700+ NewGRFs / 4kx4k map and a Debug build). Running without a game-thread means NewGRFScan and GenerateWorld are now blocking.
This commit is contained in:

committed by
Patric Stout

parent
098d5b2239
commit
970fedd78c
@@ -14,33 +14,12 @@
|
||||
|
||||
/** Are we in a modal progress or not? */
|
||||
bool _in_modal_progress = false;
|
||||
bool _first_in_modal_loop = false;
|
||||
/** Threading usable for modal progress? */
|
||||
bool _use_threaded_modal_progress = true;
|
||||
/** Rights for the performing work. */
|
||||
std::mutex _modal_progress_work_mutex;
|
||||
/** Rights for the painting. */
|
||||
std::mutex _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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user