mirror of
https://github.com/XorTroll/uLaunch
synced 2024-11-22 03:43:04 +00:00
Fix duplicate entries and moving homebrew to folder
This commit is contained in:
parent
d1b70f8171
commit
8feb63193e
5 changed files with 55 additions and 84 deletions
|
@ -26,6 +26,23 @@ namespace cfg {
|
|||
std::string name;
|
||||
std::string author;
|
||||
std::string version;
|
||||
|
||||
inline bool Equals(const TitleRecord &other) {
|
||||
if(this->title_type == other.title_type) {
|
||||
switch(static_cast<TitleType>(this->title_type)) {
|
||||
case TitleType::Installed: {
|
||||
return this->app_id == other.app_id;
|
||||
}
|
||||
case TitleType::Homebrew: {
|
||||
return std::strcmp(this->nro_target.nro_path, other.nro_target.nro_path) == 0;
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
struct TitleFolder {
|
||||
|
|
|
@ -455,66 +455,34 @@ namespace cfg {
|
|||
bool title_found = false;
|
||||
TitleRecord record_copy = {};
|
||||
std::string recjson;
|
||||
const auto type = static_cast<TitleType>(record.title_type);
|
||||
|
||||
// Search in root first
|
||||
if(type == TitleType::Installed) {
|
||||
auto find = STL_FIND_IF(list.root.titles, tit, (tit.title_type == record.title_type) && (tit.app_id == record.app_id));
|
||||
if(STL_FOUND(list.root.titles, find)) {
|
||||
// It is already on root...?
|
||||
if(folder.empty()) {
|
||||
return true;
|
||||
}
|
||||
recjson = STL_UNWRAP(find).json_name;
|
||||
|
||||
list.root.titles.erase(find);
|
||||
title_found = true;
|
||||
auto find = STL_FIND_IF(list.root.titles, tit, record.Equals(tit));
|
||||
if(STL_FOUND(list.root.titles, find)) {
|
||||
// It is already on root...?
|
||||
if(folder.empty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
auto find = STL_FIND_IF(list.root.titles, tit, (tit.title_type == record.title_type) && (tit.nro_target.nro_path == record.nro_target.nro_path));
|
||||
if(STL_FOUND(list.root.titles, find)) {
|
||||
// It is already on root...?
|
||||
if(folder.empty()) {
|
||||
return true;
|
||||
}
|
||||
recjson = STL_UNWRAP(find).json_name;
|
||||
recjson = STL_UNWRAP(find).json_name;
|
||||
|
||||
list.root.titles.erase(find);
|
||||
title_found = true;
|
||||
}
|
||||
list.root.titles.erase(find);
|
||||
title_found = true;
|
||||
}
|
||||
|
||||
// If not found yet, search on all dirs if the title is present
|
||||
if(!title_found) {
|
||||
for(auto &fld: list.folders) {
|
||||
if(type == TitleType::Installed) {
|
||||
auto find = STL_FIND_IF(fld.titles, tit, (tit.title_type == record.title_type) && (tit.app_id == record.app_id));
|
||||
if(STL_FOUND(fld.titles, find)) {
|
||||
// It is already on that folder...?
|
||||
if(fld.name == folder) {
|
||||
return true;
|
||||
}
|
||||
recjson = STL_UNWRAP(find).json_name;
|
||||
|
||||
fld.titles.erase(find);
|
||||
title_found = true;
|
||||
break;
|
||||
auto find = STL_FIND_IF(fld.titles, tit, record.Equals(tit));
|
||||
if(STL_FOUND(fld.titles, find)) {
|
||||
// It is already on that folder...?
|
||||
if(fld.name == folder) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
auto find = STL_FIND_IF(fld.titles, tit, (tit.title_type == record.title_type) && (tit.nro_target.nro_path == record.nro_target.nro_path));
|
||||
if(STL_FOUND(fld.titles, find)) {
|
||||
// It is already on that folder...?
|
||||
if(fld.name == folder) {
|
||||
return true;
|
||||
}
|
||||
recjson = STL_UNWRAP(find).json_name;
|
||||
recjson = STL_UNWRAP(find).json_name;
|
||||
|
||||
fld.titles.erase(find);
|
||||
title_found = true;
|
||||
break;
|
||||
}
|
||||
fld.titles.erase(find);
|
||||
title_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -573,45 +541,23 @@ namespace cfg {
|
|||
auto title_found = false;
|
||||
TitleRecord record_copy = {};
|
||||
std::string recjson;
|
||||
const auto type = static_cast<TitleType>(record.title_type);
|
||||
|
||||
// Search in root first
|
||||
if(type == TitleType::Installed) {
|
||||
auto find = STL_FIND_IF(list.root.titles, tit, (tit.title_type == record.title_type) && (tit.app_id == record.app_id));
|
||||
if(STL_FOUND(list.root.titles, find)) {
|
||||
if(!STL_UNWRAP(find).json_name.empty()) {
|
||||
title_found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
auto find = STL_FIND_IF(list.root.titles, tit, (tit.title_type == record.title_type) && (tit.nro_target.nro_path == record.nro_target.nro_path));
|
||||
if(STL_FOUND(list.root.titles, find)) {
|
||||
if(!STL_UNWRAP(find).json_name.empty()) {
|
||||
title_found = true;
|
||||
}
|
||||
auto find = STL_FIND_IF(list.root.titles, tit, record.Equals(tit));
|
||||
if(STL_FOUND(list.root.titles, find)) {
|
||||
if(!STL_UNWRAP(find).json_name.empty()) {
|
||||
title_found = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If not found yet, search on all dirs if the title is present
|
||||
if(!title_found) {
|
||||
for(auto &fld: list.folders) {
|
||||
if(type == TitleType::Installed) {
|
||||
auto find = STL_FIND_IF(fld.titles, tit, (tit.title_type == record.title_type) && (tit.app_id == record.app_id));
|
||||
if(STL_FOUND(fld.titles, find)) {
|
||||
if(!STL_UNWRAP(find).json_name.empty()) {
|
||||
title_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
auto find = STL_FIND_IF(fld.titles, tit, (tit.title_type == record.title_type) && (tit.nro_target.nro_path == record.nro_target.nro_path));
|
||||
if(STL_FOUND(fld.titles, find)) {
|
||||
if(!STL_UNWRAP(find).json_name.empty()) {
|
||||
title_found = true;
|
||||
break;
|
||||
}
|
||||
auto find = STL_FIND_IF(fld.titles, tit, record.Equals(tit));
|
||||
if(STL_FOUND(fld.titles, find)) {
|
||||
if(!STL_UNWRAP(find).json_name.empty()) {
|
||||
title_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
"menu_rename_folder_conf": "Would you like to rename this folder?",
|
||||
"swkbd_rename_folder_guide": "Enter new folder name",
|
||||
"hb_mode_entries_add": "Would you like to add all selected entries to the main menu?",
|
||||
"hb_mode_entries_added": "New entries were added to the main menu.",
|
||||
"hb_mode_entries_added": "The selected entries were added to the main menu.",
|
||||
"hb_mode_entries_some_added": "Some selected entries were added in the main menu, but others already had been added.",
|
||||
"menu_move_to_folder": "Would you like to move all selected entries inside a new folder or an already existing one?",
|
||||
"menu_move_new_folder": "New folder",
|
||||
"menu_move_existing_folder": "Existing folder",
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
"swkbd_rename_folder_guide": "新しいフォルダー名を入力してください",
|
||||
"hb_mode_entries_add": "選択したすべてのエントリをメインメニューに追加しますか?",
|
||||
"hb_mode_entries_added": "新しいエントリがメインメニューに追加されました。",
|
||||
"hb_mode_entries_some_added": "Some selected entries were added in the main menu, but others already had been added.",
|
||||
"menu_move_to_folder": "選択したすべてのエントリを新しいフォルダまたは既存のフォルダ内に移動しますか?",
|
||||
"menu_move_new_folder": "新しいフォルダ",
|
||||
"menu_move_existing_folder": "既存のフォルダ",
|
||||
|
|
|
@ -316,7 +316,7 @@ namespace ui {
|
|||
if(hbidx < 0) {
|
||||
hbidx = 0;
|
||||
}
|
||||
auto any = false;
|
||||
auto all_added = true;
|
||||
for(u32 i = 0; i < g_HomebrewRecordList.size(); i++) {
|
||||
auto &hb = g_HomebrewRecordList[i];
|
||||
auto idx = i + 1;
|
||||
|
@ -324,14 +324,19 @@ namespace ui {
|
|||
if(!cfg::ExistsRecord(g_EntryList, hb)) {
|
||||
cfg::SaveRecord(hb);
|
||||
g_EntryList.root.titles.insert(g_EntryList.root.titles.begin() + hbidx, hb);
|
||||
any = true;
|
||||
hbidx++;
|
||||
}
|
||||
else {
|
||||
all_added = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(any) {
|
||||
if(all_added) {
|
||||
g_MenuApplication->ShowNotification(GetLanguageString("hb_mode_entries_added"));
|
||||
}
|
||||
else {
|
||||
g_MenuApplication->ShowNotification(GetLanguageString("hb_mode_entries_some_added"));
|
||||
}
|
||||
this->StopMultiselect();
|
||||
}
|
||||
else if(sopt == 1) {
|
||||
|
@ -871,6 +876,7 @@ namespace ui {
|
|||
for(u32 i = 0; i < basesz; i++) {
|
||||
auto &title = g_EntryList.root.titles[i - rmvd];
|
||||
if(this->itemsMenu->IsItemMultiselected(basefsz + i)) {
|
||||
g_MenuApplication->CreateShowDialog("A", "Moving title '" + title.name + "' to folder '" + folder + "'...", { "K" }, true);
|
||||
if(cfg::MoveRecordTo(g_EntryList, title, folder)) {
|
||||
rmvd++;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue