Prevent the game from displaying until story screen has finished

Should fix #6867 and #3421.
This commit is contained in:
Tommy 2022-07-16 01:22:59 +12:00
parent 0d8612bb4f
commit 2ad0a2f297
4 changed files with 20 additions and 0 deletions

View file

@ -2546,6 +2546,11 @@ void display::render()
// It is not responsible for halos and floating labels.
//DBG_DP << "display::render" << endl;
// No need to render if we aren't going to draw anything.
if(prevent_draw_) {
return;
}
// render to the offscreen buffer
auto target_setter = draw::set_render_target(front_);
draw();
@ -2569,6 +2574,10 @@ bool display::expose(const SDL_Rect& region)
// Note: clipping region is set by draw_manager,
// and will be contained by <region>.
if(prevent_draw_) {
return false;
}
// Blit from the pre-rendered front buffer.
// TODO: draw_manager - API to get src region in output space
rect src_region = region;

View file

@ -563,6 +563,15 @@ public:
/** Checks if location @a loc or one of the adjacent tiles is visible on screen. */
bool tile_nearly_on_screen(const map_location &loc) const;
// TODO: draw_manager - this isn't really the correct solution
/** Prevent the game display from drawing.
* Used while story screen is showing to prevent flicker. */
void set_prevent_draw(bool pd) { prevent_draw_ = pd; }
private:
bool prevent_draw_ = false;
public:
/** Screen fade */
void fade_to(const color_t& color, int duration);
void set_fade(const color_t& color);

View file

@ -242,6 +242,7 @@ void play_controller::init(const config& level)
map_start_ = map_location(level.child_or_empty("display").child_or_empty("location"));
if(start_faded_) {
gui_->set_fade({0,0,0,255});
gui_->set_prevent_draw(true);
}
// Ensure the loading screen doesn't end up underneath the game display

View file

@ -130,6 +130,7 @@ void playsingle_controller::init_gui()
}
// Fade in
gui_->set_prevent_draw(false);
if(!gui_->video().any_fake()) {
gui_->fade_to({0,0,0,0}, 500);
} else {