Skip to content

Commit

Permalink
testing loadingscreen animation
Browse files Browse the repository at this point in the history
this adds a simple animation to the gui2 loadingscreen. It not very good
yet, it more about testing whether animations are possible.
  • Loading branch information
gfgtdf committed Mar 30, 2016
1 parent 91130a3 commit e1777a1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
22 changes: 22 additions & 0 deletions data/gui/window/loadscreen.cfg
Expand Up @@ -115,6 +115,28 @@

[/row]

[row]
grow_factor = 0

[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "center"
vertical_alignment = "center"
horizontal_grow = "true"

[label]
text_alignment = "center"
definition = "default_large"
id = "test_animation"
label = "...................."
[/label]

[/column]

[/row]

[row]
grow_factor = 1

Expand Down
11 changes: 10 additions & 1 deletion src/gui/dialogs/loadscreen.cpp
Expand Up @@ -33,6 +33,7 @@ REGISTER_DIALOG(loadscreen)
tloadscreen::tloadscreen(boost::function<void()> f)
: window_(NULL)
, timer_id_(0)
, animation_counter_(0)
, work_(f)
, worker_()
, cursor_setter_()
Expand Down Expand Up @@ -78,6 +79,8 @@ void tloadscreen::pre_show(twindow& window)
timer_id_ = add_timer(100, boost::bind(&tloadscreen::timer_callback, this, boost::ref(window)), true);
cursor_setter_.reset(new cursor::setter(cursor::WAIT));
progress_stage_label_ = &find_widget<tlabel>(&window, "status", false);
animation_label_ = &find_widget<tlabel>(&window, "test_animation", false);

}

void tloadscreen::post_show(twindow& /*window*/)
Expand Down Expand Up @@ -109,7 +112,13 @@ void tloadscreen::timer_callback(twindow& window)
{
current_visible_stage_ = current_stage_;
progress_stage_label_->set_label(current_visible_stage_);

}
++animation_counter_;
if (animation_counter_ % 2 == 0) {
int animation_state = (animation_counter_ / 2) % 20;
std::string s(20, ' ');
s[animation_state] = '.';
animation_label_->set_label(s);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/gui/dialogs/loadscreen.hpp
Expand Up @@ -58,6 +58,7 @@ class tloadscreen : public tdialog
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_;
Expand All @@ -75,6 +76,7 @@ class tloadscreen : public tdialog
void post_show(twindow& window);

tlabel* progress_stage_label_;
tlabel* animation_label_;
static tloadscreen* current_load;

//Note we cannot use std::strings here unless we we explicitly use mutexes.
Expand Down

0 comments on commit e1777a1

Please sign in to comment.