Fix themes, add album, improve other stuff...

This commit is contained in:
XorTroll 2019-11-17 14:59:56 +01:00
parent 2b0306b710
commit 1744f71532
17 changed files with 144 additions and 127 deletions

View file

@ -35,7 +35,8 @@ namespace am
TryLogUser,
RegisterUserPassword,
ChangeUserPassword,
RemoveUserPassword
RemoveUserPassword,
OpenAlbum,
};
struct QDaemonStatus

View file

@ -49,18 +49,6 @@ namespace cfg
std::string author;
};
struct UIConfig
{
u8 suspended_final_alpha;
};
struct SoundConfig
{
bool loop;
bool fade_in;
bool fade_out;
};
struct Theme
{
std::string base_name;
@ -68,13 +56,6 @@ namespace cfg
ThemeManifest manifest;
};
struct ProcessedTheme
{
Theme base;
UIConfig ui;
SoundConfig sound;
};
struct RecordInformation
{
NacpStruct nacp;
@ -91,7 +72,7 @@ namespace cfg
JSON default_lang;
};
static constexpr u32 CurrentThemeFormatVersion = 0;
static constexpr u32 CurrentThemeFormatVersion = 1;
#define CFG_THEME_DEFAULT "romfs:/default"
#define CFG_LANG_DEFAULT "romfs:/LangDefault.json"
@ -105,9 +86,12 @@ namespace cfg
Theme LoadTheme(std::string base_name);
std::vector<Theme> LoadThemes();
std::string ThemeResource(Theme &base, std::string resource_base);
std::string ProcessedThemeResource(ProcessedTheme &base, std::string resource_base);
ProcessedTheme ProcessTheme(Theme &base);
std::string GetAssetByTheme(Theme &base, std::string resource_base);
inline bool ThemeIsDefault(Theme &base)
{
return base.base_name.empty();
}
std::string GetLanguageJSONPath(std::string lang);
std::string GetLanguageString(JSON &lang, JSON &def, std::string name);

View file

@ -151,7 +151,7 @@ namespace cfg
Theme theme = {};
theme.base_name = base_name;
auto themedir = std::string(Q_THEMES_PATH) + "/" + base_name;
if(base_name.empty()) themedir = CFG_THEME_DEFAULT;
if(base_name.empty() || !fs::ExistsDirectory(themedir)) themedir = CFG_THEME_DEFAULT;
auto metajson = themedir + "/theme/Manifest.json";
auto [rc, meta] = util::LoadJSONFromFile(metajson);
if(R_SUCCEEDED(rc))
@ -163,6 +163,7 @@ namespace cfg
theme.manifest.author = meta.value("author", "");
theme.path = themedir;
}
else return LoadTheme("");
return theme;
}
@ -179,7 +180,7 @@ namespace cfg
return themes;
}
std::string ThemeResource(Theme &base, std::string resource_base)
std::string GetAssetByTheme(Theme &base, std::string resource_base)
{
auto base_res = base.path + "/" + resource_base;
if(fs::ExistsFile(base_res)) return base_res;
@ -188,32 +189,6 @@ namespace cfg
return "";
}
std::string ProcessedThemeResource(ProcessedTheme &base, std::string resource_base)
{
return ThemeResource(base.base, resource_base);
}
ProcessedTheme ProcessTheme(Theme &base)
{
ProcessedTheme processed;
processed.base = base;
auto uijson = ThemeResource(base, "ui/UI.json");
auto [rc, ui] = util::LoadJSONFromFile(uijson);
if(R_SUCCEEDED(rc))
{
processed.ui.suspended_final_alpha = ui.value("suspended_final_alpha", 80);
auto bgmjson = ThemeResource(base, "sound/BGM.json");
auto [rc, bgm] = util::LoadJSONFromFile(bgmjson);
if(R_SUCCEEDED(rc))
{
processed.sound.loop = bgm.value("loop", true);
processed.sound.fade_in = bgm.value("fade_in", true);
processed.sound.fade_out = bgm.value("fade_in", true);
}
}
return processed;
}
std::string GetLanguageJSONPath(std::string lang)
{
return Q_BASE_SD_DIR "/lang/" + lang + ".json";
@ -231,6 +206,7 @@ namespace cfg
Config cfg = {};
cfg.system_title_override_enabled = false; // Due to ban risk, have it disabled by default.
cfg.viewer_usb_enabled = false; // Do not enable this by default due to conflicts with USB homebrew
cfg.theme_name = ""; // Default theme (none)
SaveConfig(cfg);
return cfg;
}
@ -245,6 +221,11 @@ namespace cfg
cfg.system_title_override_enabled = cfgjson.value("system_title_override_enabled", false);
cfg.viewer_usb_enabled = cfgjson.value("viewer_usb_enabled", false);
}
else
{
fs::DeleteFile(CFG_CONFIG_JSON);
return CreateNewAndLoadConfig();
}
return cfg;
}

View file

@ -8,9 +8,15 @@ namespace util
JSON ret = JSON::object();
if(fs::ExistsFile(path))
{
std::ifstream ifs(path);
ret = JSON::parse(ifs);
return SuccessResultWith(ret);
try
{
std::ifstream ifs(path);
ret = JSON::parse(ifs);
return SuccessResultWith(ret);
}
catch(std::exception&)
{
}
}
return MakeResultWith(RES_VALUE(Misc, InvalidJSONFile), ret);
}

View file

@ -22,6 +22,12 @@
- Serial number
- Added **controller menu applet** support to change/manage players and controllers!
- Main menu
- Added a new way to open menus without touchscreen: presenting the **quick menu**! Just hold L/R-stick, then move it while being held to select a menu, leave the stick and profit!
- General
- Custom icons in entry JSONs can now be used with normal titles too, not just homebrew.

View file

@ -34,7 +34,7 @@ CFLAGS := -g -Wall -O2 -ffunction-sections \
CFLAGS += $(INCLUDE) -D__SWITCH__ -DQ_VERSION=\"$(Q_VERSION)\"
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17
CXXFLAGS := $(CFLAGS) -fno-rtti -fexceptions -std=gnu++17
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

View file

@ -34,7 +34,7 @@ CFLAGS := -g -Wall -O2 -ffunction-sections \
CFLAGS += $(INCLUDE) -D__SWITCH__ -DQ_VERSION=\"$(Q_VERSION)\"
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17
CXXFLAGS := $(CFLAGS) -fno-rtti -fexceptions -std=gnu++17
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

View file

@ -22,7 +22,7 @@ ui::QMenuApplication::Ref qapp;
cfg::TitleList list;
std::vector<cfg::TitleRecord> homebrew;
cfg::Config config;
cfg::ProcessedTheme theme;
cfg::Theme theme;
u8 *app_buf;
namespace qmenu
@ -38,12 +38,9 @@ namespace qmenu
am::QMenu_InitializeDaemonService();
// Load menu config
// Load menu config and theme
config = cfg::EnsureConfig();
// Load theme
auto th = cfg::LoadTheme(config.theme_name);
theme = cfg::ProcessTheme(th);
theme = cfg::LoadTheme(config.theme_name);
}
void Exit()
@ -84,13 +81,16 @@ int main()
setGetLanguageCode(&lcode);
std::string syslang = (char*)&lcode;
auto lpath = cfg::GetLanguageJSONPath(syslang);
auto [_rc, defjson] = util::LoadJSONFromFile(CFG_LANG_DEFAULT);
config.default_lang = defjson;
config.main_lang = defjson;
if(fs::ExistsFile(lpath))
auto [rc1, defjson] = util::LoadJSONFromFile(CFG_LANG_DEFAULT);
if(R_SUCCEEDED(rc1))
{
auto [_rc2, ljson] = util::LoadJSONFromFile(lpath);
config.main_lang = ljson;
config.default_lang = defjson;
config.main_lang = defjson;
if(fs::ExistsFile(lpath))
{
auto [rc2, ljson] = util::LoadJSONFromFile(lpath);
if(R_SUCCEEDED(rc2)) config.main_lang = ljson;
}
}
qapp->SetInformation(smode, status);

View file

@ -8,14 +8,14 @@
#include <am/am_LibraryApplet.hpp>
extern ui::QMenuApplication::Ref qapp;
extern cfg::ProcessedTheme theme;
extern cfg::Theme theme;
extern cfg::Config config;
namespace ui
{
LanguagesMenuLayout::LanguagesMenuLayout()
{
this->SetBackgroundImage(cfg::ProcessedThemeResource(theme, "ui/Background.png"));
this->SetBackgroundImage(cfg::GetAssetByTheme(theme, "ui/Background.png"));
pu::ui::Color textclr = pu::ui::Color::FromHex(qapp->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
pu::ui::Color menufocusclr = pu::ui::Color::FromHex(qapp->GetUIConfigValue<std::string>("menu_focus_color", "#5ebcffff"));

View file

@ -14,7 +14,7 @@ extern ui::QMenuApplication::Ref qapp;
extern cfg::TitleList list;
extern std::vector<cfg::TitleRecord> homebrew;
extern cfg::Config config;
extern cfg::ProcessedTheme theme;
extern cfg::Theme theme;
namespace ui
{
@ -41,11 +41,11 @@ namespace ui
this->Add(this->bgSuspendedRaw);
// Load banners first
this->topMenuImage = pu::ui::elm::Image::New(40, 35, cfg::ProcessedThemeResource(theme, "ui/TopMenu.png"));
this->topMenuImage = pu::ui::elm::Image::New(40, 35, cfg::GetAssetByTheme(theme, "ui/TopMenu.png"));
qapp->ApplyConfigForElement("main_menu", "top_menu_bg", this->topMenuImage);
this->Add(this->topMenuImage);
this->bannerImage = pu::ui::elm::Image::New(0, 585, cfg::ProcessedThemeResource(theme, "ui/BannerInstalled.png"));
this->bannerImage = pu::ui::elm::Image::New(0, 585, cfg::GetAssetByTheme(theme, "ui/BannerInstalled.png"));
qapp->ApplyConfigForElement("main_menu", "banner_image", this->bannerImage);
this->Add(this->bannerImage);
@ -57,14 +57,14 @@ namespace ui
qapp->ApplyConfigForElement("main_menu", "logo_icon", this->logo, false); // Sorry theme makers... logo must be visible, but can be moved
this->Add(this->logo);
this->connIcon = pu::ui::elm::Image::New(80, 53, cfg::ProcessedThemeResource(theme, "ui/NoConnectionIcon.png"));
this->connIcon = pu::ui::elm::Image::New(80, 53, cfg::GetAssetByTheme(theme, "ui/NoConnectionIcon.png"));
qapp->ApplyConfigForElement("main_menu", "connection_icon", this->connIcon);
this->Add(this->connIcon);
this->users = ClickableImage::New(270, 53, ""); // On layout creation, no user is still selected...
this->users->SetOnClick(std::bind(&MenuLayout::users_Click, this));
qapp->ApplyConfigForElement("main_menu", "user_icon", this->users);
this->Add(this->users);
this->web = ClickableImage::New(340, 53, cfg::ProcessedThemeResource(theme, "ui/WebIcon.png"));
this->web = ClickableImage::New(340, 53, cfg::GetAssetByTheme(theme, "ui/WebIcon.png"));
this->web->SetOnClick(std::bind(&MenuLayout::web_Click, this));
qapp->ApplyConfigForElement("main_menu", "web_icon", this->web);
this->Add(this->web);
@ -80,15 +80,15 @@ namespace ui
this->batteryText->SetColor(textclr);
qapp->ApplyConfigForElement("main_menu", "battery_text", this->batteryText);
this->Add(this->batteryText);
this->batteryIcon = pu::ui::elm::Image::New(700, 80, cfg::ProcessedThemeResource(theme, "ui/BatteryNormalIcon.png"));
this->batteryIcon = pu::ui::elm::Image::New(700, 80, cfg::GetAssetByTheme(theme, "ui/BatteryNormalIcon.png"));
qapp->ApplyConfigForElement("main_menu", "battery_icon", this->batteryIcon);
this->Add(this->batteryIcon);
this->settings = ClickableImage::New(880, 53, cfg::ProcessedThemeResource(theme, "ui/SettingsIcon.png"));
this->settings = ClickableImage::New(880, 53, cfg::GetAssetByTheme(theme, "ui/SettingsIcon.png"));
this->settings->SetOnClick(std::bind(&MenuLayout::settings_Click, this));
qapp->ApplyConfigForElement("main_menu", "settings_icon", this->settings);
this->Add(this->settings);
this->themes = ClickableImage::New(950, 53, cfg::ProcessedThemeResource(theme, "ui/ThemesIcon.png"));
this->themes = ClickableImage::New(950, 53, cfg::GetAssetByTheme(theme, "ui/ThemesIcon.png"));
this->themes->SetOnClick(std::bind(&MenuLayout::themes_Click, this));
qapp->ApplyConfigForElement("main_menu", "themes_icon", this->themes);
this->Add(this->themes);
@ -98,7 +98,7 @@ namespace ui
qapp->ApplyConfigForElement("main_menu", "firmware_text", this->fwText);
this->Add(this->fwText);
this->menuToggle = ClickableImage::New(520, 200, cfg::ProcessedThemeResource(theme, "ui/ToggleClick.png"));
this->menuToggle = ClickableImage::New(520, 200, cfg::GetAssetByTheme(theme, "ui/ToggleClick.png"));
this->menuToggle->SetOnClick(std::bind(&MenuLayout::menuToggle_Click, this));
qapp->ApplyConfigForElement("main_menu", "menu_toggle_button", this->menuToggle);
this->Add(this->menuToggle);
@ -116,29 +116,29 @@ namespace ui
qapp->ApplyConfigForElement("main_menu", "banner_version_text", this->itemVersion);
this->Add(this->itemVersion);
this->itemsMenu = SideMenu::New(pu::ui::Color(0, 255, 120, 255), cfg::ProcessedThemeResource(theme, "ui/Cursor.png"), cfg::ProcessedThemeResource(theme, "ui/Suspended.png"), cfg::ProcessedThemeResource(theme, "ui/Multiselect.png"), menutextx, menutexty, menutextsz, textclr, 294);
this->itemsMenu = SideMenu::New(pu::ui::Color(0, 255, 120, 255), cfg::GetAssetByTheme(theme, "ui/Cursor.png"), cfg::GetAssetByTheme(theme, "ui/Suspended.png"), cfg::GetAssetByTheme(theme, "ui/Multiselect.png"), menutextx, menutexty, menutextsz, textclr, 294);
this->MoveFolder("", false);
this->itemsMenu->SetOnItemSelected(std::bind(&MenuLayout::menu_Click, this, std::placeholders::_1, std::placeholders::_2));
this->itemsMenu->SetOnSelectionChanged(std::bind(&MenuLayout::menu_OnSelected, this, std::placeholders::_1));
qapp->ApplyConfigForElement("main_menu", "items_menu", this->itemsMenu, false); // Main menu must be visible, and only Y is customizable here
this->Add(this->itemsMenu);
this->quickMenu = QuickMenu::New(cfg::ProcessedThemeResource(theme, "ui/QuickMenuMain.png"));
this->quickMenu = QuickMenu::New(cfg::GetAssetByTheme(theme, "ui/QuickMenuMain.png"));
this->quickMenu->SetEntry(QuickMenuDirection::Down, cfg::ProcessedThemeResource(theme, "ui/QuickMenuSettingsItem.png"), std::bind(&MenuLayout::settings_Click, this));
this->quickMenu->SetEntry(QuickMenuDirection::Left, cfg::ProcessedThemeResource(theme, "ui/QuickMenuWebItem.png"), std::bind(&MenuLayout::web_Click, this));
this->quickMenu->SetEntry(QuickMenuDirection::Right, cfg::ProcessedThemeResource(theme, "ui/QuickMenuThemesItem.png"), std::bind(&MenuLayout::themes_Click, this));
this->quickMenu->SetEntry(QuickMenuDirection::UpLeft, cfg::ProcessedThemeResource(theme, "ui/QuickMenuControllerItem.png"), std::bind(&MenuLayout::HandleControllerAppletOpen, this));
this->quickMenu->SetEntry(QuickMenuDirection::DownRight, cfg::ProcessedThemeResource(theme, "ui/QuickMenuHelpItem.png"), std::bind(&MenuLayout::HandleShowHelp, this));
this->quickMenu->SetEntry(QuickMenuDirection::Down, cfg::GetAssetByTheme(theme, "ui/QuickMenuSettingsItem.png"), std::bind(&MenuLayout::settings_Click, this));
this->quickMenu->SetEntry(QuickMenuDirection::Left, cfg::GetAssetByTheme(theme, "ui/QuickMenuWebItem.png"), std::bind(&MenuLayout::web_Click, this));
this->quickMenu->SetEntry(QuickMenuDirection::Right, cfg::GetAssetByTheme(theme, "ui/QuickMenuThemesItem.png"), std::bind(&MenuLayout::themes_Click, this));
this->quickMenu->SetEntry(QuickMenuDirection::UpLeft, cfg::GetAssetByTheme(theme, "ui/QuickMenuControllerItem.png"), std::bind(&MenuLayout::HandleControllerAppletOpen, this));
this->quickMenu->SetEntry(QuickMenuDirection::DownRight, cfg::GetAssetByTheme(theme, "ui/QuickMenuHelpItem.png"), std::bind(&MenuLayout::HandleShowHelp, this));
this->Add(this->quickMenu);
this->tp = std::chrono::steady_clock::now();
this->sfxTitleLaunch = pu::audio::Load(cfg::ProcessedThemeResource(theme, "sound/TitleLaunch.wav"));
this->sfxMenuToggle = pu::audio::Load(cfg::ProcessedThemeResource(theme, "sound/MenuToggle.wav"));
this->sfxTitleLaunch = pu::audio::Load(cfg::GetAssetByTheme(theme, "sound/TitleLaunch.wav"));
this->sfxMenuToggle = pu::audio::Load(cfg::GetAssetByTheme(theme, "sound/MenuToggle.wav"));
this->SetBackgroundImage(cfg::ProcessedThemeResource(theme, "ui/Background.png"));
this->SetBackgroundImage(cfg::GetAssetByTheme(theme, "ui/Background.png"));
this->SetOnInput(std::bind(&MenuLayout::OnInput, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
}
@ -479,7 +479,7 @@ namespace ui
{
this->itemAuthor->SetVisible(false);
this->itemVersion->SetVisible(false);
this->bannerImage->SetImage(cfg::ProcessedThemeResource(theme, "ui/BannerHomebrew.png"));
this->bannerImage->SetImage(cfg::GetAssetByTheme(theme, "ui/BannerHomebrew.png"));
this->itemName->SetText(cfg::GetLanguageString(config.main_lang, config.default_lang, "hbmenu_launch"));
}
else
@ -500,7 +500,7 @@ namespace ui
}
if(strlen(info.nacp.version)) this->itemVersion->SetText(info.nacp.version);
else this->itemVersion->SetText("0");
this->bannerImage->SetImage(cfg::ProcessedThemeResource(theme, "ui/BannerHomebrew.png"));
this->bannerImage->SetImage(cfg::GetAssetByTheme(theme, "ui/BannerHomebrew.png"));
}
}
else
@ -516,7 +516,7 @@ namespace ui
else
{
auto foldr = list.folders[realidx];
this->bannerImage->SetImage(cfg::ProcessedThemeResource(theme, "ui/BannerFolder.png"));
this->bannerImage->SetImage(cfg::GetAssetByTheme(theme, "ui/BannerFolder.png"));
auto sz = foldr.titles.size();
this->itemAuthor->SetText(std::to_string(sz) + " " + ((sz == 1) ? cfg::GetLanguageString(config.main_lang, config.default_lang, "folder_entry_single") : cfg::GetLanguageString(config.main_lang, config.default_lang, "folder_entry_mult")));
this->itemVersion->SetVisible(false);
@ -542,11 +542,11 @@ namespace ui
}
if(strlen(info.nacp.version)) this->itemVersion->SetText(info.nacp.version);
else this->itemVersion->SetText("0");
if((cfg::TitleType)title.title_type == cfg::TitleType::Homebrew) this->bannerImage->SetImage(cfg::ProcessedThemeResource(theme, "ui/BannerHomebrew.png"));
else this->bannerImage->SetImage(cfg::ProcessedThemeResource(theme, "ui/BannerInstalled.png"));
if((cfg::TitleType)title.title_type == cfg::TitleType::Homebrew) this->bannerImage->SetImage(cfg::GetAssetByTheme(theme, "ui/BannerHomebrew.png"));
else this->bannerImage->SetImage(cfg::GetAssetByTheme(theme, "ui/BannerInstalled.png"));
}
}
if(!this->curfolder.empty()) this->bannerImage->SetImage(cfg::ProcessedThemeResource(theme, "ui/BannerFolder.png")); // This way user always knows he's inside a folder
if(!this->curfolder.empty()) this->bannerImage->SetImage(cfg::GetAssetByTheme(theme, "ui/BannerFolder.png")); // This way user always knows he's inside a folder
}
void MenuLayout::MoveFolder(std::string name, bool fade)
@ -566,13 +566,13 @@ namespace ui
}
this->itemsMenu->ClearItems();
if(this->homebrew_mode) this->itemsMenu->AddItem(cfg::ProcessedThemeResource(theme, "ui/Hbmenu.png"));
if(this->homebrew_mode) this->itemsMenu->AddItem(cfg::GetAssetByTheme(theme, "ui/Hbmenu.png"));
else
{
if(name.empty())
{
STL_REMOVE_IF(list.folders, fldr, (fldr.titles.empty())) // Remove empty folders
for(auto folder: list.folders) this->itemsMenu->AddItem(cfg::ProcessedThemeResource(theme, "ui/Folder.png"), folder.name);
for(auto folder: list.folders) this->itemsMenu->AddItem(cfg::GetAssetByTheme(theme, "ui/Folder.png"), folder.name);
}
}
@ -614,8 +614,8 @@ namespace ui
bool hasconn = net::HasConnection();
if(this->last_hasconn != hasconn)
{
if(hasconn) this->connIcon->SetImage(cfg::ProcessedThemeResource(theme, "ui/ConnectionIcon.png"));
else this->connIcon->SetImage(cfg::ProcessedThemeResource(theme, "ui/NoConnectionIcon.png"));
if(hasconn) this->connIcon->SetImage(cfg::GetAssetByTheme(theme, "ui/ConnectionIcon.png"));
else this->connIcon->SetImage(cfg::GetAssetByTheme(theme, "ui/NoConnectionIcon.png"));
this->last_hasconn = hasconn;
}
@ -633,8 +633,8 @@ namespace ui
if(this->last_charge != ch)
{
this->last_charge = ch;
if(ch) this->batteryIcon->SetImage(cfg::ProcessedThemeResource(theme, "ui/BatteryChargingIcon.png"));
else this->batteryIcon->SetImage(cfg::ProcessedThemeResource(theme, "ui/BatteryNormalIcon.png"));
if(ch) this->batteryIcon->SetImage(cfg::GetAssetByTheme(theme, "ui/BatteryChargingIcon.png"));
else this->batteryIcon->SetImage(cfg::GetAssetByTheme(theme, "ui/BatteryNormalIcon.png"));
}
auto ctp = std::chrono::steady_clock::now();
@ -1082,7 +1082,12 @@ namespace ui
void MenuLayout::HandleShowHelp()
{
am::QMenuCommandWriter writer(am::QDaemonMessage::OpenAlbum);
writer.FinishWrite();
qapp->StopPlayBGM();
qapp->CloseWithFadeOut();
return;
}
void MenuLayout::HandleMultiselectMoveToFolder(std::string folder)

View file

@ -2,7 +2,7 @@
#include <util/util_Misc.hpp>
extern u8 *app_buf;
extern cfg::ProcessedTheme theme;
extern cfg::Theme theme;
namespace ui
{
@ -13,7 +13,7 @@ namespace ui
void QMenuApplication::OnLoad()
{
pu::ui::render::SetDefaultFont(cfg::ProcessedThemeResource(theme, "ui/Font.ttf"));
pu::ui::render::SetDefaultFont(cfg::GetAssetByTheme(theme, "ui/Font.ttf"));
if(this->IsSuspended())
{
@ -21,9 +21,9 @@ namespace ui
appletGetLastApplicationCaptureImageEx(app_buf, RawRGBAScreenBufferSize, &flag);
}
auto [_rc, jui] = util::LoadJSONFromFile(cfg::ProcessedThemeResource(theme, "ui/UI.json"));
auto [_rc, jui] = util::LoadJSONFromFile(cfg::GetAssetByTheme(theme, "ui/UI.json"));
this->uijson = jui;
auto [_rc2, jbgm] = util::LoadJSONFromFile(cfg::ProcessedThemeResource(theme, "sound/BGM.json"));
auto [_rc2, jbgm] = util::LoadJSONFromFile(cfg::GetAssetByTheme(theme, "sound/BGM.json"));
this->bgmjson = jbgm;
this->bgm_loop = this->bgmjson.value("loop", true);
this->bgm_fade_in_ms = this->bgmjson.value("fade_in_ms", 1500);
@ -33,7 +33,7 @@ namespace ui
pu::ui::Color toastbaseclr = pu::ui::Color::FromHex(GetUIConfigValue<std::string>("toast_base_color", "#282828ff"));
this->notifToast = pu::ui::extras::Toast::New("...", 20, toasttextclr, toastbaseclr);
this->bgm = pu::audio::Open(cfg::ProcessedThemeResource(theme, "sound/BGM.mp3"));
this->bgm = pu::audio::Open(cfg::GetAssetByTheme(theme, "sound/BGM.mp3"));
this->startupLayout = StartupLayout::New();
this->menuLayout = MenuLayout::New(app_buf, this->uijson.value("suspended_final_alpha", 80));

View file

@ -8,7 +8,7 @@
#include <am/am_LibraryApplet.hpp>
extern ui::QMenuApplication::Ref qapp;
extern cfg::ProcessedTheme theme;
extern cfg::Theme theme;
extern cfg::Config config;
namespace ui
@ -39,7 +39,7 @@ namespace ui
SettingsMenuLayout::SettingsMenuLayout()
{
this->SetBackgroundImage(cfg::ProcessedThemeResource(theme, "ui/Background.png"));
this->SetBackgroundImage(cfg::GetAssetByTheme(theme, "ui/Background.png"));
pu::ui::Color textclr = pu::ui::Color::FromHex(qapp->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
pu::ui::Color menufocusclr = pu::ui::Color::FromHex(qapp->GetUIConfigValue<std::string>("menu_focus_color", "#5ebcffff"));
@ -121,7 +121,7 @@ namespace ui
pu::ui::Color textclr = pu::ui::Color::FromHex(qapp->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
auto itm = pu::ui::elm::MenuItem::New(name + ": " + value_display);
itm->AddOnClick(std::bind(&SettingsMenuLayout::setting_Click, this, id));
itm->SetIcon(cfg::ProcessedThemeResource(theme, "ui/Setting" + std::string((id < 0) ? "No" : "") + "Editable.png"));
itm->SetIcon(cfg::GetAssetByTheme(theme, "ui/Setting" + std::string((id < 0) ? "No" : "") + "Editable.png"));
itm->SetColor(textclr);
this->settingsMenu->AddItem(itm);
}

View file

@ -5,14 +5,14 @@
#include <fs/fs_Stdio.hpp>
extern ui::QMenuApplication::Ref qapp;
extern cfg::ProcessedTheme theme;
extern cfg::Theme theme;
extern cfg::Config config;
namespace ui
{
StartupLayout::StartupLayout()
{
this->SetBackgroundImage(cfg::ProcessedThemeResource(theme, "ui/Background.png"));
this->SetBackgroundImage(cfg::GetAssetByTheme(theme, "ui/Background.png"));
this->loadmenu = false;
pu::ui::Color textclr = pu::ui::Color::FromHex(qapp->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));

View file

@ -5,20 +5,20 @@
#include <fs/fs_Stdio.hpp>
extern ui::QMenuApplication::Ref qapp;
extern cfg::ProcessedTheme theme;
extern cfg::Theme theme;
extern cfg::Config config;
namespace ui
{
ThemeMenuLayout::ThemeMenuLayout()
{
this->SetBackgroundImage(cfg::ProcessedThemeResource(theme, "ui/Background.png"));
this->SetBackgroundImage(cfg::GetAssetByTheme(theme, "ui/Background.png"));
pu::ui::Color textclr = pu::ui::Color::FromHex(qapp->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
pu::ui::Color menufocusclr = pu::ui::Color::FromHex(qapp->GetUIConfigValue<std::string>("menu_focus_color", "#5ebcffff"));
pu::ui::Color menubgclr = pu::ui::Color::FromHex(qapp->GetUIConfigValue<std::string>("menu_bg_color", "#0094ffff"));
this->curThemeBanner = pu::ui::elm::Image::New(0, 585, cfg::ProcessedThemeResource(theme, "ui/BannerTheme.png"));
this->curThemeBanner = pu::ui::elm::Image::New(0, 585, cfg::GetAssetByTheme(theme, "ui/BannerTheme.png"));
qapp->ApplyConfigForElement("themes_menu", "banner_image", this->curThemeBanner);
this->Add(this->curThemeBanner);
@ -56,8 +56,7 @@ namespace ui
void ThemeMenuLayout::Reload()
{
pu::ui::Color textclr = pu::ui::Color::FromHex(qapp->GetUIConfigValue<std::string>("text_color", "#e1e1e1ff"));
bool default_theme = theme.base.base_name.empty();
if(default_theme)
if(cfg::ThemeIsDefault(theme))
{
this->curThemeText->SetText(cfg::GetLanguageString(config.main_lang, config.default_lang, "theme_no_custom"));
this->curThemeName->SetVisible(false);
@ -70,14 +69,14 @@ namespace ui
{
this->curThemeText->SetText(cfg::GetLanguageString(config.main_lang, config.default_lang, "theme_current") + ":");
this->curThemeName->SetVisible(true);
this->curThemeName->SetText(theme.base.manifest.name);
this->curThemeName->SetText(theme.manifest.name);
this->curThemeAuthor->SetVisible(true);
this->curThemeAuthor->SetText(theme.base.manifest.author);
this->curThemeAuthor->SetText(theme.manifest.author);
this->curThemeVersion->SetVisible(true);
this->curThemeVersion->SetText("v" + theme.base.manifest.release);
this->curThemeVersion->SetText("v" + theme.manifest.release);
this->curThemeBanner->SetVisible(true);
this->curThemeIcon->SetVisible(true);
this->curThemeIcon->SetImage(theme.base.path + "/theme/Icon.png");
this->curThemeIcon->SetImage(theme.path + "/theme/Icon.png");
this->curThemeIcon->SetWidth(100);
this->curThemeIcon->SetHeight(100);
}
@ -121,7 +120,7 @@ namespace ui
auto idx = this->themesMenu->GetSelectedIndex();
if(idx == 0)
{
if(theme.base.base_name.empty()) qapp->ShowNotification(cfg::GetLanguageString(config.main_lang, config.default_lang, "theme_no_custom"));
if(cfg::ThemeIsDefault(theme)) qapp->ShowNotification(cfg::GetLanguageString(config.main_lang, config.default_lang, "theme_no_custom"));
else
{
auto sopt = qapp->CreateShowDialog(cfg::GetLanguageString(config.main_lang, config.default_lang, "theme_reset"), cfg::GetLanguageString(config.main_lang, config.default_lang, "theme_reset_conf"), { cfg::GetLanguageString(config.main_lang, config.default_lang, "yes"), cfg::GetLanguageString(config.main_lang, config.default_lang, "cancel") }, true);
@ -138,7 +137,7 @@ namespace ui
idx--;
auto seltheme = this->loadedThemes[idx];
auto iconpath = seltheme.path + "/theme/Icon.png";
if(seltheme.base_name == theme.base.base_name) qapp->ShowNotification(cfg::GetLanguageString(config.main_lang, config.default_lang, "theme_active_this"));
if(seltheme.base_name == theme.base_name) qapp->ShowNotification(cfg::GetLanguageString(config.main_lang, config.default_lang, "theme_active_this"));
else
{
auto sopt = qapp->CreateShowDialog(cfg::GetLanguageString(config.main_lang, config.default_lang, "theme_set"), cfg::GetLanguageString(config.main_lang, config.default_lang, "theme_set_conf"), { cfg::GetLanguageString(config.main_lang, config.default_lang, "yes"), cfg::GetLanguageString(config.main_lang, config.default_lang, "cancel") }, true, iconpath);

View file

@ -38,7 +38,7 @@ ifeq ($(Q_DEV),1)
CFLAGS += -DQ_DEV
endif
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17
CXXFLAGS := $(CFLAGS) -fno-rtti -fexceptions -std=gnu++17
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

View file

@ -2,6 +2,7 @@
#include <os/os_Titles.hpp>
#include <os/os_HomeMenu.hpp>
#include <os/os_Account.hpp>
#include <os/os_Misc.hpp>
#include <fs/fs_Stdio.hpp>
#include <am/am_Application.hpp>
#include <am/am_LibraryApplet.hpp>
@ -28,6 +29,7 @@ hb::TargetInput hbapplaunch_copy = {};
hb::TargetInput hbapplaunch_flag = {};
u64 titlelaunch_flag = 0;
WebCommonConfig webapplet_flag = {};
bool album_flag = false;
HosMutex latestqlock;
am::QMenuMessage latestqmenumsg = am::QMenuMessage::Invalid;
@ -46,7 +48,7 @@ am::QDaemonStatus CreateStatus()
if(am::ApplicationIsActive())
{
tmptype = cfg::TitleType::Installed;
if(am::ApplicationGetId() == OS_FLOG_APP_ID) tmptype = cfg::TitleType::Homebrew;
if(os::IsFlogTitle(am::ApplicationGetId())) tmptype = cfg::TitleType::Homebrew;
}
if(tmptype == cfg::TitleType::Installed) status.app_id = am::ApplicationGetId();
@ -350,6 +352,13 @@ void HandleQMenuMessage()
break;
}
case am::QDaemonMessage::OpenAlbum:
{
reader.FinishRead();
album_flag = true;
break;
}
default:
break;
}
@ -500,6 +509,8 @@ int main()
if(!am::LibraryAppletIsActive())
{
am::WebAppletStart(&webapplet_flag);
/*
svcSleepThread(500'000'000);
if(!am::LibraryAppletIsActive())
{
@ -507,10 +518,33 @@ int main()
auto status = CreateStatus();
am::QDaemon_LaunchQMenu(am::QMenuStartMode::MenuLaunchFailure, status);
}
*/
sth_done = true;
memset(&webapplet_flag, 0, sizeof(webapplet_flag));
}
}
if(album_flag)
{
if(!am::LibraryAppletIsActive())
{
u8 albumflag = 2;
am::LibraryAppletStart(AppletId_photoViewer, 0x10000, &albumflag, sizeof(albumflag));
/*
svcSleepThread(500'000'000);
if(!am::LibraryAppletIsActive())
{
// Web applet failed to launch...
auto status = CreateStatus();
am::QDaemon_LaunchQMenu(am::QMenuStartMode::MenuLaunchFailure, status);
}
*/
sth_done = true;
album_flag = false;
}
}
if(titlelaunch_flag > 0)
{
if(!am::LibraryAppletIsActive())
@ -544,6 +578,7 @@ int main()
{
case am::QHbTargetAppletId:
case AppletId_web:
case AppletId_photoViewer:
{
auto status = CreateStatus();
am::QDaemon_LaunchQMenu(am::QMenuStartMode::Menu, status);

View file

@ -34,7 +34,7 @@ CFLAGS := -g -Wall -O2 -ffunction-sections \
CFLAGS += $(INCLUDE) -D__SWITCH__ -DQ_VERSION=\"$(Q_VERSION)\"
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17
CXXFLAGS := $(CFLAGS) -fno-rtti -fexceptions -std=gnu++17
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)