Skip to content

Commit

Permalink
QForegroundViewer -> uViewer, many other changes
Browse files Browse the repository at this point in the history
  • Loading branch information
XorTroll committed Nov 22, 2019
1 parent 8210c85 commit b1de9bd
Show file tree
Hide file tree
Showing 70 changed files with 98,968 additions and 577 deletions.
10 changes: 8 additions & 2 deletions Common/Include/cfg/cfg_Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,16 @@ namespace cfg
ThemeManifest manifest;
};

struct RecordStrings
{
std::string name;
std::string author;
std::string version;
};

struct RecordInformation
{
NacpStruct nacp;
RecordStrings strings;
std::string icon_path;
};

Expand All @@ -82,7 +89,6 @@ namespace cfg
std::vector<TitleRecord> QueryAllHomebrew(std::string base = "sdmc:/switch");
std::string GetRecordIconPath(TitleRecord record);
RecordInformation GetRecordInformation(TitleRecord record);
NacpLanguageEntry *GetRecordInformationLanguageEntry(RecordInformation &info);

Theme LoadTheme(std::string base_name);
std::vector<Theme> LoadThemes();
Expand Down
57 changes: 30 additions & 27 deletions Common/Source/cfg/cfg_Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ namespace cfg
return icon;
}

static void ProcessStringsFromNACP(RecordStrings &strs, NacpStruct *nacp)
{
NacpLanguageEntry *lent = NULL;
nacpGetLanguageEntry(nacp, &lent);
if(lent == NULL)
{
for(u32 i = 0; i < 16; i++)
{
lent = &nacp->lang[i];
if(strlen(lent->name) && strlen(lent->author)) break;
lent = NULL;
}
}
if(lent != NULL)
{
strs.name = lent->name;
strs.author = lent->author;
strs.version = nacp->version;
}
}

RecordInformation GetRecordInformation(TitleRecord record)
{
RecordInformation info = {};
Expand All @@ -99,8 +120,12 @@ namespace cfg
{
if(ahdr.nacp.size > 0)
{
NacpStruct nacp = {};

fseek(f, hdr.size + ahdr.nacp.offset, SEEK_SET);
fread(&info.nacp, 1, ahdr.nacp.size, f);
fread(&nacp, 1, ahdr.nacp.size, f);

ProcessStringsFromNACP(info.strings, &nacp);
}
}
}
Expand All @@ -112,36 +137,14 @@ namespace cfg
{
NsApplicationControlData cdata = {};
nsGetApplicationControlData(1, record.app_id, &cdata, sizeof(cdata), NULL);
memcpy(&info.nacp, &cdata.nacp, sizeof(cdata.nacp));
ProcessStringsFromNACP(info.strings, &cdata.nacp);
}
if(!record.name.empty())
{
for(u32 i = 0; i < 0x10; i++) strcpy(info.nacp.lang[i].name, record.name.c_str());
}
if(!record.author.empty())
{
for(u32 i = 0; i < 0x10; i++) strcpy(info.nacp.lang[i].author, record.author.c_str());
}
if(!record.version.empty()) strcpy(info.nacp.version, record.version.c_str());
if(!record.name.empty()) info.strings.name = record.name;
if(!record.author.empty()) info.strings.author = record.author;
if(!record.version.empty()) info.strings.version = record.version;
return info;
}

NacpLanguageEntry *GetRecordInformationLanguageEntry(RecordInformation &info)
{
NacpLanguageEntry *lent = NULL;
nacpGetLanguageEntry(&info.nacp, &lent);
if(lent == NULL)
{
for(u32 i = 0; i < 16; i++)
{
lent = &info.nacp.lang[i];
if(strlen(lent->name) && strlen(lent->author)) break;
lent = NULL;
}
}
return lent;
}

Theme LoadTheme(std::string base_name)
{
Theme theme = {};
Expand Down
17 changes: 17 additions & 0 deletions Common/Source/os/os_HomeMenu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <os/os_HomeMenu.hpp>

namespace os
{
Result PushSystemAppletMessage(SystemAppletMessage msg)
{
AppletStorage st;
auto rc = appletCreateStorage(&st, sizeof(msg));
if(R_SUCCEEDED(rc))
{
rc = appletStorageWrite(&st, 0, &msg, sizeof(msg));
if(R_SUCCEEDED(rc)) appletPushToGeneralChannel(&st);
appletStorageClose(&st);
}
return rc;
}
}
2 changes: 1 addition & 1 deletion LibraryAppletQMenu/RomFs/LangDefault.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"set_enable_conf": "Do you want to enable it?",
"set_disable_conf": "Do you want to disable it?",
"set_changed_reboot": "Done. A reboot is required (the option won't be used until then)",
"set_viewer_info": "You must enable this if you want to use the PC foreground viewer (QForegroundViewer). It is not necessary otherwise.",
"set_viewer_info": "You must enable this if you want to use the PC foreground viewer (uViewer). It is not necessary otherwise.",
"set_flog_info": "This must be enabled to be able to launch homebrew directly as applications. Note that this might involve BAN RISK.",
"startup_welcome_info": "Welcome! Please select an account to use.",
"startup_control_info": "Hold the L or R-stick in order to open menus easily from main menu.",
Expand Down
46 changes: 20 additions & 26 deletions LibraryAppletQMenu/Source/ui/ui_MenuLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,19 +490,16 @@ namespace ui
realidx--;
auto hb = homebrew[realidx];
auto info = cfg::GetRecordInformation(hb);
auto lent = cfg::GetRecordInformationLanguageEntry(info);
if(lent != NULL)
{
this->itemName->SetText(lent->name);
this->itemAuthor->SetText(lent->author);
}
else
{
this->itemName->SetText(cfg::GetLanguageString(config.main_lang, config.default_lang, "unknown"));
this->itemAuthor->SetText(cfg::GetLanguageString(config.main_lang, config.default_lang, "unknown"));
}
if(strlen(info.nacp.version)) this->itemVersion->SetText(info.nacp.version);
else this->itemVersion->SetText("0");

if(info.strings.name.empty()) this->itemName->SetText(cfg::GetLanguageString(config.main_lang, config.default_lang, "unknown"));
else this->itemName->SetText(info.strings.name);

if(info.strings.author.empty()) this->itemAuthor->SetText(cfg::GetLanguageString(config.main_lang, config.default_lang, "unknown"));
else this->itemAuthor->SetText(info.strings.author);

if(info.strings.version.empty()) this->itemVersion->SetText("0");
else this->itemVersion->SetText(info.strings.version);

this->bannerImage->SetImage(cfg::GetAssetByTheme(theme, "ui/BannerHomebrew.png"));
}
}
Expand Down Expand Up @@ -532,19 +529,16 @@ namespace ui
{
auto title = folder.titles[titleidx];
auto info = cfg::GetRecordInformation(title);
auto lent = cfg::GetRecordInformationLanguageEntry(info);
if(lent != NULL)
{
this->itemName->SetText(lent->name);
this->itemAuthor->SetText(lent->author);
}
else
{
this->itemName->SetText(cfg::GetLanguageString(config.main_lang, config.default_lang, "unknown"));
this->itemAuthor->SetText(cfg::GetLanguageString(config.main_lang, config.default_lang, "unknown"));
}
if(strlen(info.nacp.version)) this->itemVersion->SetText(info.nacp.version);
else this->itemVersion->SetText("0");

if(info.strings.name.empty()) this->itemName->SetText(cfg::GetLanguageString(config.main_lang, config.default_lang, "unknown"));
else this->itemName->SetText(info.strings.name);

if(info.strings.author.empty()) this->itemAuthor->SetText(cfg::GetLanguageString(config.main_lang, config.default_lang, "unknown"));
else this->itemAuthor->SetText(info.strings.author);

if(info.strings.version.empty()) this->itemVersion->SetText("0");
else this->itemVersion->SetText(info.strings.version);

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"));
}
Expand Down
2 changes: 1 addition & 1 deletion LibraryAppletQMenu/Source/ui/ui_QuickMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace ui
x += (SubItemsSize - texw) / 2;
y += (SubItemsSize - texh) / 2;

if(direction == dir) SDL_SetTextureColorMod(tex, 200, 200, 255);
if(direction == dir) SDL_SetTextureColorMod(tex, 150, 150, 200);
else SDL_SetTextureColorMod(tex, 255, 255, 255);

Drawer->RenderTexture(tex, x, y, { fgalpha, texw, texh, -1 });
Expand Down
25 changes: 0 additions & 25 deletions QForegroundViewer/QForegroundViewer.sln

This file was deleted.

120 changes: 0 additions & 120 deletions QForegroundViewer/QForegroundViewer/ScreenshotForm.resx

This file was deleted.

Loading

0 comments on commit b1de9bd

Please sign in to comment.