Files

136 lines
3.6 KiB
C++
Raw Permalink Normal View History

2024-04-08 07:45:33 +02:00
#include "ui_about_simple.hpp"
2024-11-22 09:54:34 +01:00
#include <string_view>
2024-11-14 21:52:43 +08:00
#define ROLL_SPEED_FRAME_PER_LINE 60
// cuz frame rate of pp screen is probably 60, scroll per sec
2024-04-08 07:45:33 +02:00
namespace ui {
// Information: a line starting with a '#' will be yellow coloured
2025-01-07 14:56:08 +01:00
constexpr std::string_view mayhem_information_list[] = {
"#****** Mayhem Community ******",
" ",
" https://discord.mayhem.app",
" ",
"#**** List of contributors ****",
2024-04-08 07:45:33 +02:00
" ",
"#Mayhem-Firmware:",
"jboone,eried,furrtek,",
"NotherNgineer,gullradriel,",
"jLynx,kallanreed,Brumi-2021,",
2025-01-07 14:56:08 +01:00
"htotoo,zxkmm,bernd-herzog,",
"ArjanOnwezen,euquiq,u-foka,",
"iNetro,heurist1,dqs105,",
"teixeluis,jwetzell,",
"jimilinuxguy,gregoryfenton,",
"notpike,strijar,BehleZebub,",
2025-01-07 14:56:08 +01:00
"arneluehrs,mcules,rascafr,",
"joyel24,ImDroided,zigad,",
"johnelder,klockee,nnesetto,",
"LupusE,argilo,dc2dc,formtapez,",
"RocketGod-git,mrmookie,",
"ITAxReal,F33RNI,F4GEV,",
"rusty-labs,mjwaxios,andrej-mk,",
"RedFox-Fr,nemanjan00,",
"MichalLeonBorsuk,",
2025-01-07 14:56:08 +01:00
"MatiasFernandez,Giorgiofox",
2025-06-13 18:34:20 +02:00
"TommasoVentafridda",
2024-04-08 07:45:33 +02:00
" ",
"#Havoc:",
"jboone,furrtek,eried,argilo,",
"mrmookie,Giorgiofox,ImDroided,",
"mjwaxios,F4GEV,OpCode1300,",
"ZeroChaos-,RndmNmbr,",
"silascutler,troussos,z4ziggy,",
"clem-42,dhoetger,NickBouwhuis,",
"xmycroftx,Maescool,KimIV,",
"joakar,leres,brianlechthaler,",
"N0vaPixel",
2024-04-08 07:45:33 +02:00
" ",
"#PortaPack:",
"jboone,mossmann,martinling,",
"argilo,eried,ZeroChaos-,",
"RndmNmbr",
2024-04-08 07:45:33 +02:00
" ",
"#HackRF:",
"mossmann,jboone,dominicgs,",
"martinling,bvernoux,miek,",
"bgamari,schneider42,straithe,",
"grvvy,willcode,hessu,yhetti,",
"Sec42,ckuethe",
" "};
2024-04-08 07:45:33 +02:00
AboutView::AboutView(NavigationView& nav) {
add_children({&menu_view,
&button_ok});
button_ok.on_select = [&nav](Button&) {
nav.pop();
};
menu_view.on_left = [this]() {
button_ok.focus();
};
menu_view.on_right = [this]() {
button_ok.focus();
};
2025-01-07 14:56:08 +01:00
for (auto& authors_line : mayhem_information_list) {
2024-04-08 07:45:33 +02:00
// if it's starting with #, it's a title and we have to substract the '#' and paint yellow
if (authors_line.size() > 0) {
if (authors_line[0] == '#') {
menu_view.add_item(
2024-11-22 09:54:34 +01:00
{(std::string)authors_line.substr(1, authors_line.size() - 1),
2024-05-27 21:02:52 +02:00
ui::Theme::getInstance()->fg_yellow->foreground,
2024-04-08 07:45:33 +02:00
nullptr,
nullptr});
} else {
menu_view.add_item(
2024-11-22 09:54:34 +01:00
{(std::string)authors_line,
2024-05-27 21:02:52 +02:00
Theme::getInstance()->bg_darkest->foreground,
2024-04-08 07:45:33 +02:00
nullptr,
nullptr});
}
}
}
}
2024-11-14 21:52:43 +08:00
void AboutView::on_frame_sync() {
if (interacted) return;
if (frame_sync_count++ % ROLL_SPEED_FRAME_PER_LINE == 0) {
const auto current = menu_view.highlighted_index();
const auto count = menu_view.item_count();
if (current < count - 1) {
menu_view.set_highlighted(current + 1);
} else {
menu_view.set_highlighted(0);
}
}
}
2024-04-08 07:45:33 +02:00
void AboutView::focus() {
2024-11-14 21:52:43 +08:00
button_ok.focus();
2025-01-07 14:56:08 +01:00
menu_view.set_highlighted(3); // contributors block starting line
2024-11-14 21:52:43 +08:00
}
bool AboutView::on_touch(const TouchEvent) {
interacted = true;
return false;
}
bool AboutView::on_key(const KeyEvent) {
interacted = true;
return false;
}
bool AboutView::on_encoder(const EncoderEvent) {
interacted = true;
2024-04-08 07:45:33 +02:00
menu_view.focus();
2024-11-14 21:52:43 +08:00
return false;
2024-04-08 07:45:33 +02:00
}
} /* namespace ui */