story_viewer: Hide the game display when shown mid-scenario

Prevents some buggy behaviour similar to #3421.
This commit is contained in:
Tommy 2022-07-16 12:44:54 +12:00
parent 91983c8c87
commit 269f0c4f5b
3 changed files with 15 additions and 0 deletions

View file

@ -567,6 +567,7 @@ public:
/** Prevent the game display from drawing.
* Used while story screen is showing to prevent flicker. */
void set_prevent_draw(bool pd) { prevent_draw_ = pd; }
bool get_prevent_draw() { return prevent_draw_; }
private:
bool prevent_draw_ = false;

View file

@ -17,6 +17,7 @@
#include "gui/dialogs/story_viewer.hpp"
#include "display.hpp"
#include "formula/variant.hpp"
#include "gui/auxiliary/find_widget.hpp"
#include "sdl/point.hpp"
@ -91,9 +92,19 @@ void story_viewer::pre_show(window& window)
connect_signal_mouse_left_click(find_widget<button>(&window, "back", false),
std::bind(&story_viewer::nav_button_callback, this, DIR_BACKWARDS));
// Tell the game display not to draw
game_was_already_hidden_ = display::get_singleton()->get_prevent_draw();
display::get_singleton()->set_prevent_draw(true);
display_part();
}
void story_viewer::post_show(window& /*window*/)
{
// Bring the game display back again, if appropriate
display::get_singleton()->set_prevent_draw(game_was_already_hidden_);
}
void story_viewer::update_current_part_ptr()
{
current_part_ = controller_.get_part(part_index_);

View file

@ -54,6 +54,7 @@ private:
virtual const std::string& window_id() const override;
virtual void pre_show(window& window) override;
virtual void post_show(window& window) override;
void clear_image_timer();
@ -97,6 +98,8 @@ private:
};
FADE_STATE fade_state_;
bool game_was_already_hidden_;
};
} // namespace dialogs