add 12 hour clock (#113)

This commit is contained in:
therealbungus
2025-04-08 06:04:22 -05:00
committed by GitHub
parent 134aadad5a
commit 14abcc50b5
4 changed files with 22 additions and 1 deletions

View File

@@ -604,6 +604,10 @@ auto App::GetTextScrollSpeed() -> long {
return g_app->m_text_scroll_speed.Get();
}
auto App::Get12HourTimeEnable() -> bool {
return g_app->m_12hour_time.Get();
}
void App::SetNxlinkEnable(bool enable) {
if (App::GetNxlinkEnable() != enable) {
g_app->m_nxlink_enabled.Set(enable);
@@ -746,6 +750,10 @@ void App::SetThemeMusicEnable(bool enable) {
PlaySoundEffect(SoundEffect::SoundEffect_Music);
}
void App::Set12HourTimeEnable(bool enable) {
g_app->m_12hour_time.Set(enable);
}
void App::SetMtpEnable(bool enable) {
if (App::GetMtpEnable() != enable) {
g_app->m_mtp_enabled.Set(enable);

View File

@@ -253,6 +253,10 @@ MainMenu::MainMenu() {
options->Add(std::make_shared<SidebarEntryBool>("Music"_i18n, App::GetThemeMusicEnable(), [this](bool& enable){
App::SetThemeMusicEnable(enable);
}, "Enabled"_i18n, "Disabled"_i18n));
options->Add(std::make_shared<SidebarEntryBool>("12 Hour Time"_i18n, App::Get12HourTimeEnable(), [this](bool& enable){
App::Set12HourTimeEnable(enable);
}, "Enabled"_i18n, "Disabled"_i18n));
}));
options->Add(std::make_shared<SidebarEntryCallback>("Network"_i18n, [this](){

View File

@@ -46,7 +46,13 @@ void MenuBase::Draw(NVGcontext* vg, Theme* theme) {
// draw("version %s", APP_VERSION);
draw(ThemeEntryID_TEXT, "%u\uFE6A", m_battery_percetange);
draw(ThemeEntryID_TEXT, "%02u:%02u:%02u", m_tm.tm_hour, m_tm.tm_min, m_tm.tm_sec);
if (App::Get12HourTimeEnable()) {
draw(ThemeEntryID_TEXT, "%02u:%02u:%02u %s", (m_tm.tm_hour == 0 || m_tm.tm_hour == 12) ? 12 : m_tm.tm_hour % 12, m_tm.tm_min, m_tm.tm_sec, (m_tm.tm_hour < 12) ? "AM" : "PM");
} else {
draw(ThemeEntryID_TEXT, "%02u:%02u:%02u", m_tm.tm_hour, m_tm.tm_min, m_tm.tm_sec);
}
if (m_ip) {
draw(ThemeEntryID_TEXT, "%u.%u.%u.%u", m_ip&0xFF, (m_ip>>8)&0xFF, (m_ip>>16)&0xFF, (m_ip>>24)&0xFF);
} else {