mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:57:44 +00:00
CatDog: Simplify animation frame logic and fix minor bugs
Moved all images into a Vector instead of storing every animation frame in its own member variable. This greatly simplifies the bitmap selection logic and removes redundant if() checks. Also fixes minor state bugs. For example, CatDog woudld go to sleep immediately after actively moving for > 5 seconds. Also fixes arbitrary hardcoded values for mouse offset movement tresholds as well as inconsistent movement increments. This allows clicking anywhere on the CatDog window without moving CatDog. In addition to removing many member variables, the API interface is also cleaned up a bit to expose less CatDog internals. Nobody likes exposed CatDog internals ;). Variables and function are also renamed where necessary to (hopefully) improve readability.
This commit is contained in:
parent
213d82f39b
commit
e80f0b23e3
4 changed files with 173 additions and 229 deletions
|
@ -53,7 +53,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->show();
|
||||
window->set_always_on_top();
|
||||
catdog_widget->start_timer(250, Core::TimerShouldFireWhenNotVisible::Yes);
|
||||
catdog_widget->start_the_timer(); // timer for "mouse sleep detection"
|
||||
|
||||
auto advice_window = TRY(GUI::Window::try_create());
|
||||
advice_window->set_title("CatDog Advice");
|
||||
|
@ -68,7 +67,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
advice_widget->layout()->set_spacing(0);
|
||||
|
||||
auto advice_timer = TRY(Core::Timer::try_create());
|
||||
advice_timer->set_interval(15000);
|
||||
advice_timer->set_interval(15'000);
|
||||
advice_timer->set_single_shot(true);
|
||||
advice_timer->on_timeout = [&] {
|
||||
window->move_to_front();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue