GUI2/Loading Screen: renamed singleton member

This commit is contained in:
Charles Dang 2019-08-20 00:56:48 +11:00
parent 63f0f04535
commit e761acbaa4
2 changed files with 9 additions and 9 deletions

View file

@ -71,7 +71,7 @@ namespace dialogs
{
REGISTER_DIALOG(loading_screen)
loading_screen* loading_screen::current_load = nullptr;
loading_screen* loading_screen::singleton_ = nullptr;
loading_screen::loading_screen(std::function<void()> f)
: animation_counter_(0)
@ -98,7 +98,7 @@ loading_screen::loading_screen(std::function<void()> f)
}
current_visible_stage_ = visible_stages_.end();
current_load = this;
singleton_ = this;
}
void loading_screen::pre_show(window& window)
@ -140,8 +140,8 @@ void loading_screen::post_show(window& /*window*/)
void loading_screen::progress(loading_stage stage)
{
if(current_load && stage != loading_stage::none) {
current_load->current_stage_.store(stage, std::memory_order_release);
if(singleton_ && stage != loading_stage::none) {
singleton_->current_stage_.store(stage, std::memory_order_release);
}
}
@ -197,14 +197,14 @@ loading_screen::~loading_screen()
#endif
}
current_load = nullptr;
singleton_ = nullptr;
}
void loading_screen::display(std::function<void()> f)
{
const bool use_loadingscreen_animation = !preferences::disable_loadingscreen_animation();
if(current_load || CVideo::get_singleton().faked()) {
if(singleton_ || CVideo::get_singleton().faked()) {
f();
} else if(use_loadingscreen_animation) {
loading_screen(f).show();

View file

@ -76,7 +76,7 @@ public:
~loading_screen();
static void display(std::function<void()> f);
static bool displaying() { return current_load != nullptr; }
static bool displaying() { return singleton_ != nullptr; }
static void progress(loading_stage stage = loading_stage::none);
@ -99,6 +99,8 @@ private:
/** Callback to handle drawing the progress animation. */
void draw_callback();
static loading_screen* singleton_;
int animation_counter_;
std::function<void()> load_func_;
std::future<void> worker_result_;
@ -109,8 +111,6 @@ private:
label* progress_stage_label_;
label* animation_label_;
static loading_screen* current_load;
std::atomic<loading_stage> current_stage_;
using stage_map = std::map<loading_stage, t_string>;