-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathlauncher.cpp
91 lines (75 loc) · 1.76 KB
/
launcher.cpp
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
87
88
89
90
91
/**
* @file launcher.cpp
* @author Forairaaaaa
* @brief
* @version 0.1
* @date 2023-11-04
*
* @copyright Copyright (c) 2023
*
*/
#include "launcher.h"
#include "lgfx/v1/lgfx_fonts.hpp"
#include "spdlog/spdlog.h"
#include "../../hal/hal.h"
#include <LovyanGFX.hpp>
#include "../assets/theme/theme.h"
#include "../assets/icons/icons.h"
using namespace MOONCAKE::APPS;
void Launcher::onCreate()
{
spdlog::info("{} onCreate", getAppName());
// Enable bg running
setAllowBgRunning(true);
// Auto start
startApp();
_create_menu();
}
void Launcher::onResume()
{
spdlog::info("{} onResume", getAppName());
// Load resources
HAL::LoadLauncherFont24();
// HAL::LoadTextFont24();
HAL::GetCanvas()->setTextScroll(false);
_update_clock(true);
}
void Launcher::onRunning()
{
_update_clock();
_update_menu();
}
void Launcher::onRunningBG()
{
// If only launcher running still
if (mcAppGetFramework()->getAppManager().getCreatedAppNum() == 1)
{
spdlog::info("back to launcher");
// Back to business
mcAppGetFramework()->startApp(this);
// Play app close anim
HAL::LoadLauncherFont24();
_update_clock(true);
_play_app_anim(false);
}
}
void Launcher::onPause()
{
// Play app open anim
_play_app_anim(true);
}
void Launcher::onDestroy()
{
spdlog::info("{} onDestroy", getAppName());
_destroy_menu();
}
void Launcher::_update_clock(bool updateNow)
{
if ((HAL::Millis() - _data.clock_update_count) > _data.clock_update_interval || updateNow)
{
// Update clock
strftime(_data.string_buffer, 10, "%H:%M", HAL::GetLocalTime());
_data.clock = _data.string_buffer;
_data.clock_update_count = HAL::Millis();
}
}