gui: Display child apps as nodes under their parent app trees

This commit is contained in:
Joel16 2021-08-24 01:11:44 -04:00
parent 351c2142cf
commit 7f228744a8
3 changed files with 89 additions and 22 deletions

View File

@ -25,10 +25,20 @@ struct AppInfoFolder {
int index = 0;
};
// Info for an app that belongs to a parent folder.
struct AppInfoChild {
int pageId = 0;
int pageNo = 0;
int pos = 0;
char title[128];
char titleId[16];
};
struct AppEntries {
std::vector<AppInfoIcon> icons;
std::vector<AppInfoPage> pages;
std::vector<AppInfoFolder> folders;
std::vector<AppInfoChild> child_apps;
};
extern int sort_mode;

View File

@ -17,6 +17,7 @@ namespace AppList {
entries->icons.clear();
entries->pages.clear();
entries->folders.clear();
entries->child_apps.clear();
sqlite3 *db;
int ret = sqlite3_open_v2(path, &db, SQLITE_OPEN_READWRITE, nullptr);
@ -36,6 +37,7 @@ namespace AppList {
while ((ret = sqlite3_step(stmt)) == SQLITE_ROW) {
AppInfoIcon icon;
AppInfoChild child;
icon.pageId = std::stoi(reinterpret_cast<const char*>(sqlite3_column_text(stmt, 0)));
icon.pageNo = sqlite3_column_int(stmt, 1);
icon.pos = sqlite3_column_int(stmt, 2);
@ -44,7 +46,15 @@ namespace AppList {
sceClibSnprintf(icon.reserved01, 16, "%s", sqlite3_column_text(stmt, 5));
sceClibSnprintf(icon.reserved02, 128, "%s", sqlite3_column_text(stmt, 6));
icon.folder = (std::stoi(reinterpret_cast<const char*>(sqlite3_column_text(stmt, 7)))) == 7? true : false;
if (icon.pageNo < 0) {
child.pageId = icon.pageId;
child.pageNo = icon.pageNo;
child.pos = icon.pos;
sceClibStrncpy(child.title, icon.title, 128);
sceClibStrncpy(child.titleId, icon.titleId, 16);
}
entries->icons.push_back(icon);
entries->child_apps.push_back(child);
}
if (ret != SQLITE_DONE) {

View File

@ -284,32 +284,79 @@ namespace GUI {
ImGui::TableSetupColumn("");
ImGui::TableSetupColumn("Title");
ImGui::TableSetupColumn("Page ID");
ImGui::TableSetupColumn("Page Number");
ImGui::TableSetupColumn("Position");
ImGui::TableSetupColumn("Page No");
ImGui::TableSetupColumn("Pos");
ImGui::TableHeadersRow();
for (int i = 0; i < entries.icons.size(); i++) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Image(reinterpret_cast<ImTextureID>(entries.icons[i].folder? icons[Folder].id : icons[App].id), ImVec2(20, 20));
ImGui::TableNextColumn();
std::string title = std::to_string(i) + ") ";
title.append(entries.icons[i].title);
ImGui::Selectable(title.c_str(), false, ImGuiSelectableFlags_SpanAllColumns);
ImGui::TableNextColumn();
ImGui::Text("%d", entries.icons[i].pageId);
ImGui::TableNextColumn();
if (entries.icons[i].pageNo < 0)
ImGui::Text("Inside folder");
else
ImGui::Text("%d", entries.icons[i].pageNo);
if (entries.icons[i].folder) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Image(reinterpret_cast<ImTextureID>(icons[Folder].id), ImVec2(20, 20));
ImGui::TableNextColumn();
std::string title = std::to_string(i) + ") ";
title.append(entries.icons[i].title);
bool open = ImGui::TreeNodeEx(title.c_str(), ImGuiTreeNodeFlags_SpanFullWidth);
ImGui::TableNextColumn();
ImGui::Text("%d", entries.icons[i].pos);
ImGui::TableNextColumn();
ImGui::Text("%d", entries.icons[i].pageId);
ImGui::TableNextColumn();
ImGui::Text("%d", entries.icons[i].pageNo);
ImGui::TableNextColumn();
ImGui::Text("%d", entries.icons[i].pos);
if (open) {
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_Bullet | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_SpanFullWidth;
int reserved01 = std::stoi(std::string(entries.icons[i].reserved01));
for (int j = 0; j < entries.child_apps.size(); j++) {
if (entries.child_apps[j].pageNo == reserved01) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
//ImGui::Image(reinterpret_cast<ImTextureID>(icons[App].id), ImVec2(20, 20));
ImGui::TableNextColumn();
std::string title = std::to_string(j) + ") ";
title.append(entries.child_apps[j].title);
ImGui::TreeNodeEx(title.c_str(), flags);
ImGui::TableNextColumn();
ImGui::Text("%d", entries.child_apps[j].pageId);
ImGui::TableNextColumn();
ImGui::Text("-");
ImGui::TableNextColumn();
ImGui::Text("%d", entries.child_apps[j].pos);
}
}
ImGui::TreePop();
}
}
else if (entries.icons[i].pageNo >= 0) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::Image(reinterpret_cast<ImTextureID>(icons[App].id), ImVec2(20, 20));
ImGui::TableNextColumn();
std::string title = std::to_string(i) + ") ";
title.append(entries.icons[i].title);
ImGui::Selectable(title.c_str(), false, ImGuiSelectableFlags_SpanAllColumns);
ImGui::TableNextColumn();
ImGui::Text("%d", entries.icons[i].pageId);
ImGui::TableNextColumn();
ImGui::Text("%d", entries.icons[i].pageNo);
ImGui::TableNextColumn();
ImGui::Text("%d", entries.icons[i].pos);
}
}
ImGui::EndTable();