diff options
author | rtk0c <[email protected]> | 2021-06-10 18:07:30 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2021-06-10 18:07:30 -0700 |
commit | 222cfec6ad882196d8927f73e30d905daae89556 (patch) | |
tree | 9347bb0ebf99cc79e4ee629d0edf7fd744bdeb1b /core/src/Model/Assets.cpp | |
parent | dc09ba073744292a4d4af0445e5095f424fffa22 (diff) |
Polish UI and add translations
Diffstat (limited to 'core/src/Model/Assets.cpp')
-rw-r--r-- | core/src/Model/Assets.cpp | 113 |
1 files changed, 45 insertions, 68 deletions
diff --git a/core/src/Model/Assets.cpp b/core/src/Model/Assets.cpp index 0e53537..ac3335a 100644 --- a/core/src/Model/Assets.cpp +++ b/core/src/Model/Assets.cpp @@ -81,6 +81,11 @@ void AssetList::Reload() }); } +int AssetList::GetCount() const +{ + return mPrivate->Assets.size(); +} + const SavedAsset* AssetList::FindByName(std::string_view name) const { auto iter = mPrivate->Assets.find(name); @@ -166,99 +171,46 @@ void AssetList::SetCacheSizeLimit(int limit) mPrivate->CacheSizeLimit = limit; } -void AssetList::DisplayBigIconsList(ListState& state) +void AssetList::DisplayIconsList(ListState& state) { // TODO } -void AssetList::DisplayDetailsTable(ListState& state) +void AssetList::DisplayDetailsList(ListState& state) { SetupDetailsTable("AssetDetailsTable"); for (auto& asset : mPrivate->Assets) { - DrawDetailsTableRow(state, asset); ImGui::TableNextRow(); + DrawDetailsTableRow(state, asset); } ImGui::EndTable(); } -void AssetList::OpenBigIconsPopup() -{ - ImGui::OpenPopup("Manage assets##BigIcons"); -} - -void AssetList::DisplayBigIconsPopup(PopupState& state) -{ - if (ImGui::BeginPopupModal("Manage assets##BigIcons")) { - DisplayBigIconsList(state); - DisplayPopupControls(state); - ImGui::EndPopup(); - } -} - -void AssetList::OpenDetailsPopup() -{ - ImGui::OpenPopup("Manage assets##Details"); -} - -void AssetList::DisplayDetailsPopup(PopupState& state) -{ - if (ImGui::BeginPopupModal("Manage assets##Details")) { - DisplayBigIconsList(state); - DisplayPopupControls(state); - ImGui::EndPopup(); - } -} - -void AssetList::DiscoverFilesByExtension(const std::function<void(SavedAsset)>& callback, const fs::path& containerDir, std::string_view extension) const -{ - for (auto entry : fs::directory_iterator(containerDir)) { - if (!entry.is_regular_file()) continue; - - // If the caller provided an extension to match against, and it doesn't equal to current file extension, skip - if (!extension.empty() && - entry.path().extension() != extension) - { - continue; - } - - callback(SavedAsset{ - .Name = RetrieveNameFromFile(entry.path()), - .Uuid = RetrieveUuidFromFile(entry.path()), - // TODO load payload - }); - } -} - -void AssetList::DiscoverFilesByHeader(const std::function<void(SavedAsset)>& callback, const fs::path& containerDir, const std::function<bool(std::istream&)>& validater) const -{ - // TODO -} - -void AssetList::DisplayPopupControls(PopupState& state) +void AssetList::DisplayControls(ListState& state) { auto& ps = mPrivate->PopupPrivateState; auto ls = LocaleStrings::Instance.get(); - bool openedDummy = false; + bool openedDummy = true; if (ImGui::Button(ls->Add.Get())) { - ImGui::OpenPopup("Create template"); + ImGui::OpenPopup(ls->AddDialogTitle.Get()); } - if (ImGui::BeginPopupModal("Create template", &openedDummy, ImGuiWindowFlags_AlwaysAutoResize)) { + if (ImGui::BeginPopupModal(ls->AddDialogTitle.Get(), &openedDummy, ImGuiWindowFlags_AlwaysAutoResize)) { DisplayAssetCreator(state); ImGui::EndPopup(); } ImGui::SameLine(); if (ImGui::Button(ls->Rename.Get(), state.SelectedAsset == nullptr)) { - ImGui::OpenPopup("Rename template"); + ImGui::OpenPopup(ls->RenameDialogTitle.Get()); } - if (ImGui::BeginPopupModal("Rename template")) { + if (ImGui::BeginPopupModal(ls->RenameDialogTitle.Get(), &openedDummy, ImGuiWindowFlags_AlwaysAutoResize)) { if (ImGui::InputText("New name", &ps.NewName)) { ps.Validate(*this); } - if (ImGui::Button(ls->DialogConfirm.Get(), ps.HasErrors())) { + if (ImGui::Button(ls->Confirm.Get(), ps.HasErrors())) { ImGui::CloseCurrentPopup(); auto movedAsset = Rename(state.SelectedAsset->Name, ps.NewName); @@ -268,7 +220,7 @@ void AssetList::DisplayPopupControls(PopupState& state) ps = {}; } ImGui::SameLine(); - if (ImGui::Button(ls->DialogCancel.Get())) { + if (ImGui::Button(ls->Cancel.Get())) { ImGui::CloseCurrentPopup(); } @@ -279,10 +231,10 @@ void AssetList::DisplayPopupControls(PopupState& state) ImGui::SameLine(); if (ImGui::Button(ls->Delete.Get(), state.SelectedAsset == nullptr)) { - ImGui::OpenPopup("Delete confirmation"); + ImGui::OpenPopup(ls->DeleteDialogTitle.Get()); } - if (ImGui::BeginPopupModal("Delete confirmation")) { - if (ImGui::Button(ls->DialogConfirm.Get())) { + if (ImGui::BeginPopupModal(ls->DeleteDialogTitle.Get(), &openedDummy, ImGuiWindowFlags_AlwaysAutoResize)) { + if (ImGui::Button(ls->Confirm.Get())) { ImGui::CloseCurrentPopup(); auto& assetName = state.SelectedAsset->Name; @@ -291,9 +243,34 @@ void AssetList::DisplayPopupControls(PopupState& state) state.SelectedAsset = nullptr; } ImGui::SameLine(); - if (ImGui::Button(ls->DialogCancel.Get())) { + if (ImGui::Button(ls->Cancel.Get())) { ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } } + +void AssetList::DiscoverFilesByExtension(const std::function<void(SavedAsset)>& callback, const fs::path& containerDir, std::string_view extension) const +{ + for (auto entry : fs::directory_iterator(containerDir)) { + if (!entry.is_regular_file()) continue; + + // If the caller provided an extension to match against, and it doesn't equal to current file extension, skip + if (!extension.empty() && + entry.path().extension() != extension) + { + continue; + } + + callback(SavedAsset{ + .Name = RetrieveNameFromFile(entry.path()), + .Uuid = RetrieveUuidFromFile(entry.path()), + // TODO load payload + }); + } +} + +void AssetList::DiscoverFilesByHeader(const std::function<void(SavedAsset)>& callback, const fs::path& containerDir, const std::function<bool(std::istream&)>& validater) const +{ + // TODO +} |