2022-01-05 16:10:18 +00:00
|
|
|
#include "../irda_app.h"
|
2021-06-25 13:52:27 +00:00
|
|
|
#include "assets_icons.h"
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 09:20:41 +00:00
|
|
|
#include <dolphin/dolphin.h>
|
2021-06-25 13:52:27 +00:00
|
|
|
#include "gui/modules/button_menu.h"
|
|
|
|
#include "gui/modules/button_panel.h"
|
2022-01-05 16:10:18 +00:00
|
|
|
#include "../view/irda_app_brut_view.h"
|
2021-06-25 13:52:27 +00:00
|
|
|
#include "gui/view.h"
|
2022-01-05 16:10:18 +00:00
|
|
|
#include "irda/irda_app_event.h"
|
|
|
|
#include "irda/irda_app_view_manager.h"
|
|
|
|
#include "irda/scene/irda_app_scene.h"
|
2021-06-25 13:52:27 +00:00
|
|
|
|
|
|
|
void IrdaAppSceneUniversalCommon::irda_app_item_callback(void* context, uint32_t index) {
|
|
|
|
IrdaApp* app = static_cast<IrdaApp*>(context);
|
|
|
|
IrdaAppEvent event;
|
|
|
|
|
|
|
|
event.type = IrdaAppEvent::Type::ButtonPanelPressed;
|
|
|
|
event.payload.menu_index = index;
|
|
|
|
|
|
|
|
app->get_view_manager()->send_event(&event);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool irda_popup_brut_input_callback(InputEvent* event, void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
furi_assert(event);
|
|
|
|
auto app = static_cast<IrdaApp*>(context);
|
|
|
|
bool consumed = false;
|
|
|
|
|
|
|
|
if((event->type == InputTypeShort) && (event->key == InputKeyBack)) {
|
|
|
|
consumed = true;
|
|
|
|
IrdaAppEvent irda_event;
|
|
|
|
|
2021-07-22 00:07:00 +00:00
|
|
|
irda_event.type = IrdaAppEvent::Type::Back;
|
2021-06-25 13:52:27 +00:00
|
|
|
app->get_view_manager()->send_event(&irda_event);
|
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void IrdaAppSceneUniversalCommon::remove_popup(IrdaApp* app) {
|
|
|
|
auto button_panel = app->get_view_manager()->get_button_panel();
|
|
|
|
button_panel_set_popup_draw_callback(button_panel, NULL, NULL);
|
|
|
|
button_panel_set_popup_input_callback(button_panel, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IrdaAppSceneUniversalCommon::show_popup(IrdaApp* app, int record_amount) {
|
|
|
|
auto button_panel = app->get_view_manager()->get_button_panel();
|
|
|
|
auto popup_brut = app->get_view_manager()->get_popup_brut();
|
|
|
|
popup_brut_set_progress_max(popup_brut, record_amount);
|
|
|
|
button_panel_set_popup_draw_callback(button_panel, popup_brut_draw_callback, popup_brut);
|
|
|
|
button_panel_set_popup_input_callback(button_panel, irda_popup_brut_input_callback, app);
|
|
|
|
}
|
|
|
|
|
2021-08-11 17:51:06 +00:00
|
|
|
bool IrdaAppSceneUniversalCommon::progress_popup(IrdaApp* app) {
|
|
|
|
bool result = popup_brut_increase_progress(app->get_view_manager()->get_popup_brut());
|
2021-06-25 13:52:27 +00:00
|
|
|
auto button_panel = app->get_view_manager()->get_button_panel();
|
|
|
|
with_view_model_cpp(button_panel_get_view(button_panel), void*, model, { return true; });
|
2021-08-11 17:51:06 +00:00
|
|
|
return result;
|
2021-06-25 13:52:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool IrdaAppSceneUniversalCommon::on_event(IrdaApp* app, IrdaAppEvent* event) {
|
|
|
|
bool consumed = false;
|
|
|
|
|
2021-07-22 00:07:00 +00:00
|
|
|
if(brute_force_started) {
|
|
|
|
if(event->type == IrdaAppEvent::Type::Tick) {
|
2021-07-08 18:20:13 +00:00
|
|
|
auto view_manager = app->get_view_manager();
|
|
|
|
IrdaAppEvent tick_event = {.type = IrdaAppEvent::Type::Tick};
|
|
|
|
view_manager->send_event(&tick_event);
|
2021-08-11 17:51:06 +00:00
|
|
|
bool result = brute_force.send_next_bruteforce();
|
|
|
|
if(result) {
|
|
|
|
result = progress_popup(app);
|
|
|
|
}
|
|
|
|
if(!result) {
|
2021-06-25 13:52:27 +00:00
|
|
|
brute_force.stop_bruteforce();
|
|
|
|
brute_force_started = false;
|
|
|
|
remove_popup(app);
|
|
|
|
}
|
2021-07-22 00:07:00 +00:00
|
|
|
consumed = true;
|
|
|
|
} else if(event->type == IrdaAppEvent::Type::Back) {
|
|
|
|
brute_force_started = false;
|
|
|
|
brute_force.stop_bruteforce();
|
|
|
|
remove_popup(app);
|
|
|
|
consumed = true;
|
2021-06-25 13:52:27 +00:00
|
|
|
}
|
2021-07-22 00:07:00 +00:00
|
|
|
} else {
|
|
|
|
if(event->type == IrdaAppEvent::Type::ButtonPanelPressed) {
|
|
|
|
int record_amount = 0;
|
|
|
|
if(brute_force.start_bruteforce(event->payload.menu_index, record_amount)) {
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 09:20:41 +00:00
|
|
|
DOLPHIN_DEED(DolphinDeedIrBruteForce);
|
2021-06-25 13:52:27 +00:00
|
|
|
brute_force_started = true;
|
|
|
|
show_popup(app, record_amount);
|
2021-07-22 00:07:00 +00:00
|
|
|
} else {
|
|
|
|
app->switch_to_previous_scene();
|
2021-06-25 13:52:27 +00:00
|
|
|
}
|
2021-07-22 00:07:00 +00:00
|
|
|
consumed = true;
|
|
|
|
} else if(event->type == IrdaAppEvent::Type::Back) {
|
2021-06-25 13:52:27 +00:00
|
|
|
app->switch_to_previous_scene();
|
2021-07-22 00:07:00 +00:00
|
|
|
consumed = true;
|
2021-06-25 13:52:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void IrdaAppSceneUniversalCommon::on_exit(IrdaApp* app) {
|
|
|
|
IrdaAppViewManager* view_manager = app->get_view_manager();
|
|
|
|
ButtonPanel* button_panel = view_manager->get_button_panel();
|
2022-01-21 17:32:03 +00:00
|
|
|
button_panel_reset(button_panel);
|
2021-06-25 13:52:27 +00:00
|
|
|
}
|