1
0
mirror of synced 2024-11-12 02:00:52 +01:00

feat: Adapt content store view for new API contents (#1268)

This commit is contained in:
iTrooz 2023-09-02 18:36:34 +02:00 committed by GitHub
parent f725d763d1
commit fc1ad592cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 3 deletions

View File

@ -24,6 +24,7 @@ namespace hex::plugin::builtin {
struct StoreEntry {
std::string name;
std::string description;
std::vector<std::string> authors;
std::string fileName;
std::string link;
std::string hash;

View File

@ -962,6 +962,7 @@
"hex.builtin.view.store.reload": "Reload",
"hex.builtin.view.store.remove": "Remove",
"hex.builtin.view.store.row.description": "Description",
"hex.builtin.view.store.row.authors": "Authors",
"hex.builtin.view.store.row.name": "Name",
"hex.builtin.view.store.tab.constants": "Constants",
"hex.builtin.view.store.tab.encodings": "Encodings",

View File

@ -55,10 +55,11 @@ namespace hex::plugin::builtin {
void ViewStore::drawTab(hex::plugin::builtin::StoreCategory &category) {
if (ImGui::BeginTabItem(LangEntry(category.unlocalizedName))) {
if (ImGui::BeginTable("##pattern_language", 3, ImGuiTableFlags_ScrollY | ImGuiTableFlags_Borders | ImGuiTableFlags_SizingStretchSame | ImGuiTableFlags_RowBg)) {
if (ImGui::BeginTable("##pattern_language", 4, ImGuiTableFlags_ScrollY | ImGuiTableFlags_Borders | ImGuiTableFlags_SizingStretchSame | ImGuiTableFlags_RowBg)) {
ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableSetupColumn("hex.builtin.view.store.row.name"_lang, ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("hex.builtin.view.store.row.description"_lang, ImGuiTableColumnFlags_None);
ImGui::TableSetupColumn("hex.builtin.view.store.row.authors"_lang, ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableHeadersRow();
@ -70,6 +71,16 @@ namespace hex::plugin::builtin {
ImGui::TextUnformatted(entry.name.c_str());
ImGui::TableNextColumn();
ImGui::TextUnformatted(entry.description.c_str());
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(500);
ImGui::TextUnformatted(entry.description.c_str());
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
ImGui::TableNextColumn();
// the space makes a padding in the UI
ImGui::Text("%s ", wolv::util::combineStrings(entry.authors, ", ").c_str());
ImGui::TableNextColumn();
const auto buttonSize = ImVec2(100_scaled, ImGui::GetTextLineHeightWithSpacing());
@ -196,10 +207,10 @@ namespace hex::plugin::builtin {
for (auto &entry : storeJson[category.requestName]) {
// Check if entry is valid
if (entry.contains("name") && entry.contains("desc") && entry.contains("file") && entry.contains("url") && entry.contains("hash") && entry.contains("folder")) {
if (entry.contains("name") && entry.contains("desc") && entry.contains("authors") && entry.contains("file") && entry.contains("url") && entry.contains("hash") && entry.contains("folder")) {
// Parse entry
StoreEntry storeEntry = { entry["name"], entry["desc"], entry["file"], entry["url"], entry["hash"], entry["folder"], false, false, false };
StoreEntry storeEntry = { entry["name"], entry["desc"], entry["authors"], entry["file"], entry["url"], entry["hash"], entry["folder"], false, false, false };
// Check if file is installed already or has an update available
for (const auto &folder : fs::getDefaultPaths(category.path)) {