20 #define GETTEXT_DOMAIN "wesnoth-lib"
37 #define LOG_LS LOG_STREAM(info, log_loadscreen)
38 #define ERR_LS LOG_STREAM(err, log_loadscreen)
39 #define WRN_LS LOG_STREAM(warn, log_loadscreen)
42 #define DBG_DP LOG_STREAM(debug, log_display)
44 static const std::map<loading_stage, std::string>
stage_names {
70 namespace { std::chrono::steady_clock::time_point last_spin; }
83 , progress_stage_label_(nullptr)
88 , current_visible_stage_()
91 for(
const auto& [stage, description] :
stage_names) {
107 animation_ = find_widget<drawing>(
"animation",
false,
true);
137 auto now = std::chrono::steady_clock::now();
138 auto elapsed = now - last_spin;
166 LOG_LS <<
"Executing loading screen worker function.";
182 DBG_DP <<
"loading_screen::layout";
189 WRN_LS <<
"Stage missing description.";
197 using namespace std::chrono;
198 const auto now = steady_clock::now();
211 LOG_LS <<
"Loading screen destroyed.";
218 LOG_LS <<
"Directly executing loading function.";
221 LOG_LS <<
"Creating new loading screen.";
void set_variable(const std::string &key, wfl::variant &&value)
static void progress(loading_stage stage=loading_stage::none)
Report what is being loaded to the loading screen.
virtual void layout() override
Called by draw_manager to assign concrete layout.
std::atomic< loading_stage > current_stage_
static loading_screen * singleton_
label * progress_stage_label_
static void raise()
Raise the loading screen to the top of the draw stack.
stage_map visible_stages_
static void display(std::function< void()> f)
std::vector< std::function< void()> > load_funcs_
std::unique_ptr< cursor::setter > cursor_setter_
stage_map::const_iterator current_visible_stage_
virtual void process() override
Inherited from events::pump_monitor.
utils::optional< decltype(std::chrono::steady_clock::now())> animation_start_
loading_screen(std::function< void()> f)
static void spin()
Indicate to the player that loading is progressing.
virtual void post_show() override
Actions to be taken after the window has been shown.
virtual void pre_show() override
Actions to be taken before showing the window.
Abstract base class for all modal dialogs.
canvas & get_drawing_canvas()
void set_enter_disabled(const bool enter_disabled)
Disable the enter key.
void close()
Requests to close the window.
virtual void layout() override
Lays out the window.
void set_escape_disabled(const bool escape_disabled)
Disable the escape key.
static lg::log_domain log_loadscreen("loadscreen")
static const std::map< loading_stage, std::string > stage_names
static lg::log_domain log_display("display")
loading_stage
Loading screen stage IDs.
Standard logging facilities (interface).
std::chrono::milliseconds get_frame_length()
Returns the length of one display frame, in milliseconds.
void raise_drawable(top_level_drawable *tld)
Raise a TLD to the top of the drawing stack.
void pump_and_draw()
pump() then immediately draw()
REGISTER_DIALOG(editor_edit_unit)
bool headless()
The game is running headless.