HbTarget changes, improve themes menu

This commit is contained in:
XorTroll 2019-10-31 20:09:34 +01:00
parent 9f9521c665
commit 078b40acae
11 changed files with 98 additions and 33 deletions

View file

@ -5,19 +5,6 @@ namespace am
AppletHolder applet_holder;
AppletId applet_lastid;
// Grabbed from libnx's source
static u32 WebApplet_GetLaVersion()
{
u32 ver = 0;
u32 hosver = hosversionGet();
if(hosver >= MAKEHOSVERSION(8,0,0)) ver = 0x80000;
else if(hosver >= MAKEHOSVERSION(6,0,0)) ver = 0x60000;
else if(hosver >= MAKEHOSVERSION(5,0,0)) ver = 0x50000;
else if(hosver >= MAKEHOSVERSION(3,0,0)) ver = 0x30000;
else ver = 0x20000;
return ver;
}
bool LibraryAppletIsActive()
{
if(applet_holder.StateChangedEvent.revent == INVALID_HANDLE) return false;
@ -64,7 +51,7 @@ namespace am
Result WebAppletStart(WebCommonConfig *web)
{
return LibraryAppletStart(AppletId_web, WebApplet_GetLaVersion(), &web->arg, sizeof(web->arg));
return LibraryAppletStart(AppletId_web, web->version, &web->arg, sizeof(web->arg));
}
AppletId LibraryAppletGetId()

View file

@ -57,6 +57,7 @@ namespace cfg
rec.title_type = (u32)TitleType::Homebrew;
strcpy(rec.nro_target.nro_path, path.c_str());
nros.push_back(rec);
CacheHomebrew(path); // Always cache when querying.
}
}
})
@ -633,7 +634,7 @@ namespace cfg
std::string folder = entry.value("folder", "");
rec.sub_folder = folder;
rec.icon = entry.value("icon", "");
if(cache) CacheHomebrew(rec.nro_target.nro_path);
// Homebrew is cache'd when querying it, so no caching here.
if(folder.empty()) list.root.titles.push_back(rec);
else
{

View file

@ -4,8 +4,8 @@
#include <stdio.h>
const char g_noticeText[] =
"uLaunch's HbTarget impl (wrapper of nx-hbloader)\0"
"Do you mean to tell me that you're thinking seriously of building that way, when and if you are an architect?";
"uLaunch's HbTarget impl v" Q_VERSION " (custom wrapper of nx-hbloader)\0"
"There is only one true CFW in the scene."; // Biggest truth
static char g_argv[2048];
static char g_nextArgv[2048];
@ -48,6 +48,19 @@ void __libnx_initheap(void)
fake_heap_end = &g_innerheap[sizeof g_innerheap];
}
static Result readSetting(const char* key, void* buf, size_t size)
{
Result rc;
u64 actual_size;
const char* const section_name = "hbloader";
rc = setsysGetSettingsItemValueSize(section_name, key, &actual_size);
if (R_SUCCEEDED(rc) && actual_size != size)
rc = MAKERESULT(Module_Libnx, LibnxError_BadInput);
if (R_SUCCEEDED(rc))
rc = setsysGetSettingsItemValue(section_name, key, buf, size);
return rc;
}
void __appInit(void)
{
Result rc;
@ -62,6 +75,8 @@ void __appInit(void)
rc = setsysGetFirmwareVersion(&fw);
if (R_SUCCEEDED(rc))
hosversionSet(MAKEHOSVERSION(fw.major, fw.minor, fw.micro));
readSetting("applet_heap_size", &g_appletHeapSize, sizeof(g_appletHeapSize));
readSetting("applet_heap_reservation_size", &g_appletHeapReservationSize, sizeof(g_appletHeapReservationSize));
setsysExit();
}
@ -445,13 +460,12 @@ static void InnerTarget(const char *path, const char *argv)
memcpy(g_savedTls, (u8*)armGetTls() + 0x100, 0x100);
strcpy(g_basePath, path);
strcpy(g_baseArgv, argv);
getIsApplication();
getIsAutomaticGameplayRecording();
smExit(); // Close SM as we don't need it anymore.
setupHbHeap();
getOwnProcessHandle();
loadNro();
}

View file

@ -19,7 +19,7 @@ include $(DEVKITPRO)/libnx/switch_rules
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := ../Common/Source ../Common/Source/am ../Common/Source/cfg ../Common/Source/db ../Common/Source/fs ../Common/Source/hb ../Common/Source/os ../Common/Source/util Source Source/ui
SOURCES := ../Common/Source ../Common/Source/am ../Common/Source/hb Source
DATA := data
INCLUDES := ../Common/Include Include
EXEFS_SRC := exefs_src
@ -27,7 +27,7 @@ EXEFS_SRC := exefs_src
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE -Wl,-wrap,apmInitialize -Wl,-wrap,apmSetPerformanceConfiguration -Wl,-wrap,apmExit
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE -Wl,-wrap,apmInitialize -Wl,-wrap,apmSetPerformanceConfiguration -Wl,-wrap,apmExit -Wl,-wrap,exit
CFLAGS := -g -Wall -O2 -ffunction-sections \
$(ARCH) $(DEFINES)

View file

@ -17,6 +17,12 @@ namespace ui
private:
pu::ui::elm::TextBlock::Ref noThemesText;
pu::ui::elm::Menu::Ref themesMenu;
pu::ui::elm::TextBlock::Ref curThemeText;
pu::ui::elm::TextBlock::Ref curThemeName;
pu::ui::elm::TextBlock::Ref curThemeAuthor;
pu::ui::elm::TextBlock::Ref curThemeVersion;
pu::ui::elm::Image::Ref curThemeIcon;
pu::ui::elm::Image::Ref curThemeBanner;
std::vector<cfg::Theme> loadedThemes;
};
}

View file

@ -35,9 +35,6 @@ namespace qmenu
am::QMenu_InitializeDaemonService();
// Query all homebrew (is this too slow...?)
homebrew = cfg::QueryAllHomebrew();
// Load menu config
config = cfg::EnsureConfig();

View file

@ -98,16 +98,16 @@ namespace ui
this->Add(this->menuToggle);
this->itemName = pu::ui::elm::TextBlock::New(40, 610, "", 30);
this->itemAuthor = pu::ui::elm::TextBlock::New(45, 650, "", 20);
this->itemVersion = pu::ui::elm::TextBlock::New(45, 675, "", 20);
this->itemName->SetColor(textclr);
qapp->ApplyConfigForElement("main_menu", "banner_name_text", this->itemName);
this->Add(this->itemName);
this->itemAuthor = pu::ui::elm::TextBlock::New(45, 650, "", 20);
this->itemAuthor->SetColor(textclr);
qapp->ApplyConfigForElement("main_menu", "banner_author_text", this->itemAuthor);
this->Add(this->itemAuthor);
this->itemVersion = pu::ui::elm::TextBlock::New(45, 675, "", 20);
this->itemVersion->SetColor(textclr);
qapp->ApplyConfigForElement("main_menu", "banner_version_text", this->itemVersion);
this->Add(this->itemName);
this->Add(this->itemAuthor);
this->Add(this->itemVersion);
this->itemsMenu = SideMenu::New(pu::ui::Color(0, 255, 120, 255), cfg::ProcessedThemeResource(theme, "ui/Cursor.png"), 294);
@ -383,6 +383,11 @@ namespace ui
{
if(fade) qapp->FadeOut();
if(this->homebrew_mode)
{
if(homebrew.empty()) homebrew = cfg::QueryAllHomebrew();
}
auto itm_list = homebrew;
if(!this->homebrew_mode)
{

View file

@ -18,6 +18,10 @@ namespace ui
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"));
qapp->ApplyConfigForElement("themes_menu", "banner_image", this->curThemeBanner);
this->Add(this->curThemeBanner);
this->noThemesText = pu::ui::elm::TextBlock::New(0, 0, "You don't seem to have any themes. Go download some!");
this->noThemesText->SetColor(textclr);
this->noThemesText->SetHorizontalAlign(pu::ui::elm::HorizontalAlign::Center);
@ -26,14 +30,63 @@ namespace ui
this->themesMenu = pu::ui::elm::Menu::New(200, 160, 880, menubgclr, 100, 4);
this->themesMenu->SetOnFocusColor(menufocusclr);
qapp->ApplyConfigForElement("themes_menu", "themes_menu_item", this->themesMenu);
this->Add(this->themesMenu);
this->curThemeText = pu::ui::elm::TextBlock::New(20, 540, "Current theme:", 30);
this->curThemeText->SetColor(textclr);
qapp->ApplyConfigForElement("themes_menu", "current_theme_text", this->curThemeText);
this->Add(this->curThemeText);
this->curThemeName = pu::ui::elm::TextBlock::New(40, 610, "", 30);
this->curThemeName->SetColor(textclr);
qapp->ApplyConfigForElement("themes_menu", "current_theme_name_text", this->curThemeName);
this->Add(this->curThemeName);
this->curThemeAuthor = pu::ui::elm::TextBlock::New(45, 650, "", 20);
this->curThemeAuthor->SetColor(textclr);
qapp->ApplyConfigForElement("themes_menu", "current_theme_author_text", this->curThemeAuthor);
this->Add(this->curThemeAuthor);
this->curThemeVersion = pu::ui::elm::TextBlock::New(45, 675, "", 20);
this->curThemeVersion->SetColor(textclr);
qapp->ApplyConfigForElement("themes_menu", "current_theme_version_text", this->curThemeVersion);
this->Add(this->curThemeVersion);
this->curThemeIcon = pu::ui::elm::Image::New(1000, 605, "");
this->curThemeIcon->SetWidth(100);
this->curThemeIcon->SetHeight(100);
qapp->ApplyConfigForElement("themes_menu", "current_theme_icon", this->curThemeIcon);
this->Add(this->curThemeIcon);
this->SetOnInput(std::bind(&ThemeMenuLayout::OnInput, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
}
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)
{
this->curThemeText->SetText("You don't currently have a custom theme.");
this->curThemeName->SetVisible(false);
this->curThemeAuthor->SetVisible(false);
this->curThemeVersion->SetVisible(false);
this->curThemeBanner->SetVisible(false);
this->curThemeIcon->SetVisible(false);
}
else
{
this->curThemeText->SetText("Current theme:");
this->curThemeName->SetVisible(true);
this->curThemeName->SetText(theme.base.manifest.name);
this->curThemeAuthor->SetVisible(true);
this->curThemeAuthor->SetText(theme.base.manifest.author);
this->curThemeVersion->SetVisible(true);
this->curThemeVersion->SetText(theme.base.manifest.release);
this->curThemeBanner->SetVisible(true);
this->curThemeIcon->SetVisible(true);
this->curThemeIcon->SetImage(theme.base.path + "/theme/Icon.png");
this->curThemeIcon->SetWidth(100);
this->curThemeIcon->SetHeight(100);
}
this->themesMenu->ClearItems();
this->loadedThemes.clear();
this->loadedThemes = cfg::LoadThemes();

View file

@ -17,7 +17,7 @@ extern "C"
#ifdef Q_DEV
size_t __nx_heap_size = 0x3000000; // Dev 48MB (still lower than official qlaunch) for debug console
#else
size_t __nx_heap_size = 0x800000;// 8MB - while official qlaunch uses 56MB! That's 48 extra MB for other applets
size_t __nx_heap_size = 0x800000; // 8MB - while official qlaunch uses 56MB! That's 48 extra MB for other applets
#endif
}

View file

@ -19,7 +19,7 @@ include $(DEVKITPRO)/libnx/switch_rules
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := ../Common/Source ../Common/Source/am ../Common/Source/cfg ../Common/Source/db ../Common/Source/fs ../Common/Source/hb ../Common/Source/os ../Common/Source/util Source Source/ui
SOURCES := ../Common/Source ../Common/Source/am ../Common/Source/hb Source
DATA := data
INCLUDES := ../Common/Include Include
EXEFS_SRC := exefs_src
@ -27,7 +27,7 @@ EXEFS_SRC := exefs_src
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE -Wl,-wrap,apmInitialize -Wl,-wrap,apmSetPerformanceConfiguration -Wl,-wrap,apmExit
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE -Wl,-wrap,apmInitialize -Wl,-wrap,apmSetPerformanceConfiguration -Wl,-wrap,apmExit -Wl,-wrap,exit
CFLAGS := -g -Wall -O2 -ffunction-sections \
$(ARCH) $(DEFINES)

View file

@ -123,9 +123,11 @@ Can be customized via files in `/ui`.
Element customization: consists on menus and items within them, with customizable `visible`, `x` and `y` properties. If `visible` is false, custom X and Y will be ignored.
- `main_menu`: items are `top_menu_bg`, `logo_icon`, `connection_icon`, `user_icon`, `web_icon`, `time_text`, `battery_text`, `battery_icon`, `settings_icon`, `themes_icon`, `firmware_text`, `menu_toggle_button`, `banner_image`, `banner_name_text`, `banner_author_text`, `banner_version_text` and `items_menu`.
- Main menu (`main_menu`): items are `top_menu_bg`, `logo_icon`, `connection_icon`, `user_icon`, `web_icon`, `time_text`, `battery_text`, `battery_icon`, `settings_icon`, `themes_icon`, `firmware_text`, `menu_toggle_button`, `banner_image`, `banner_name_text`, `banner_author_text`, `banner_version_text` and `items_menu`.
- `startup_menu`: only item is `info_text`.
- Startup/user selection menu (`startup_menu`): only item is `info_text`.
- Theme menu (`themes_menu`): `banner_image`, `themes_menu_item`, `current_theme_text`, `current_theme_name_text`, `current_theme_author_text`, `current_theme_version_text` and `current_theme_icon`.
Notes: `logo_icon` and `items_menu` items can't be hidden ("visible" property is ignored) and in `items_menu`'s case only Y can be customized ("x" is also ignored)