-
-
Notifications
You must be signed in to change notification settings - Fork 990
/
loadscreen.hpp
86 lines (65 loc) · 1.88 KB
/
loadscreen.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
Copyright (C) 2016 by the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#pragma once
#include "gui/dialogs/dialog.hpp"
#include "gui/widgets/label.hpp"
#include <boost/function.hpp>
#include <boost/scoped_ptr.hpp>
#include <map>
#include <atomic>
class CVideo;
namespace boost
{
class thread;
}
namespace cursor
{
struct setter;
}
namespace gui2
{
class twindow;
class tloadscreen : public tdialog
{
public:
tloadscreen(boost::function<void()> f);
~tloadscreen();
static void display(CVideo& video, boost::function<void()> f);
static bool displaying() { return current_load != nullptr; }
static void progress(const char* stage_name = nullptr);
/**
* Hides the window.
*
* The hiding also destroys the window. It is save to call the function
* when the window is not shown.
*/
void close();
private:
twindow* window_;
size_t timer_id_;
int animation_counter_;
boost::function<void()> work_;
boost::scoped_ptr<boost::thread> worker_;
boost::scoped_ptr<cursor::setter> cursor_setter_;
twindow* build_window(CVideo& video) const;
virtual const std::string& window_id() const;
void timer_callback(twindow& window);
/** Inherited from tdialog. */
void pre_show(twindow& window);
/** Inherited from tdialog. */
void post_show(twindow& window);
tlabel* progress_stage_label_;
tlabel* animation_label_;
static tloadscreen* current_load;
std::atomic<const char*> current_stage_;
std::map<std::string,std::string>::const_iterator current_visible_stage_;
};
} // namespace gui2