20 #define GETTEXT_DOMAIN "wesnoth-lib"
38 #define LOG_LS LOG_STREAM(info, log_loadscreen)
39 #define ERR_LS LOG_STREAM(err, log_loadscreen)
40 #define WRN_LS LOG_STREAM(warn, log_loadscreen)
43 #define DBG_DP LOG_STREAM(debug, log_display)
45 static const std::map<loading_stage, std::string>
stage_names {
71 namespace { std::chrono::steady_clock::time_point last_spin; }
81 , load_funcs_{std::move(
f)}
84 , progress_stage_label_(nullptr)
89 , current_visible_stage_()
92 for(
const auto& [stage, description] :
stage_names) {
108 animation_ = find_widget<drawing>(
"animation",
false,
true);
138 auto now = std::chrono::steady_clock::now();
139 auto elapsed = now - last_spin;
167 LOG_LS <<
"Executing loading screen worker function.";
183 DBG_DP <<
"loading_screen::layout";
190 WRN_LS <<
"Stage missing description.";
198 using namespace std::chrono;
199 const auto now = steady_clock::now();
212 LOG_LS <<
"Loading screen destroyed.";
219 LOG_LS <<
"Directly executing loading function.";
222 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_
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.
static void display(const std::function< void()> &f)
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.