diff --git a/LICENSE_ThirdParty.md b/LICENSE_ThirdParty.md index 8a33cd7..732bbcd 100644 --- a/LICENSE_ThirdParty.md +++ b/LICENSE_ThirdParty.md @@ -920,6 +920,25 @@ OTHER DEALINGS IN THE FONT SOFTWARE. See the License for the specific language governing permissions and limitations under the License. +# tiny file dialogs +Copyright (c) 2014 - 2023 Guillaume Vareille http://ysengrin.com + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. + # toml++ MIT License diff --git a/data/localization/English.toml b/data/localization/English.toml index 3fecfcb..475e1ac 100644 --- a/data/localization/English.toml +++ b/data/localization/English.toml @@ -19,7 +19,7 @@ ARCHIVE_DIALOG_PROCESSING = "Processing..." ARCHIVE_DIALOG_PROGRESS_SUMMARY = "Currently processing item {} from {}..." ARCHIVE_DIALOG_NO_ARCHIVE = "There is currently no opened archive." ARCHIVE_DIALOG_FILE_MENU = "File" -SDL2_INITIALIZATION_ERROR = "Couldn't initialize SDL2!\n\"{}\"" +SDL2_INITIALIZATION_ERROR = "Couldn’t initialize SDL2!\n\"{}\"" MESSAGEBOX_TITLE_ERROR = "Error" MESSAGEBOX_TITLE_WARNING = "Warning" MESSAGEBOX_TITLE_INFORMATION = "Information" @@ -30,14 +30,14 @@ MESSAGEBOX_BUTTON_CANCEL = "Cancel" HITMAN_DIALOG_LOADING_ORIGINAL_RECORDS = "Loading the original records..." HITMAN_DIALOG_ERROR_UNKNOWN_FORMAT_IN_ARCHIVE = "Found an unknown format inside the archive!" HITMAN_DIALOG_ERROR_CORRUPTED_ORIGINAL_RECORDS_CACHE = "Original records cache corrupted for current archive! Trying to rebuild..." -HITMAN_DIALOG_WARNING_IMPORT_LOADING_DATA = "Couldn't load the input data, skipping the import!" -HITMAN_DIALOG_WARNING_IMPORT_DECODING_DATA = "Couldn't decode the input data, skipping the import!" -HITMAN_DIALOG_WARNING_IMPORT_CREATING_NATIVE_DATA = "Couldn't create the native data, skipping the import!" -HITMAN_DIALOG_WARNING_IMPORT_ENCODING_NATIVE_DATA = "Couldn't encode the native data, skipping the import!" -HITMAN_DIALOG_WARNING_IMPORT_TRANCODING_DATA = "Couldn't transcode the data due to error \"{}\", skipping the import!" +HITMAN_DIALOG_WARNING_IMPORT_LOADING_DATA = "Couldn’t load the input data, skipping the import!" +HITMAN_DIALOG_WARNING_IMPORT_DECODING_DATA = "Couldn’t decode the input data, skipping the import!" +HITMAN_DIALOG_WARNING_IMPORT_CREATING_NATIVE_DATA = "Couldn’t create the native data, skipping the import!" +HITMAN_DIALOG_WARNING_IMPORT_ENCODING_NATIVE_DATA = "Couldn’t encode the native data, skipping the import!" +HITMAN_DIALOG_WARNING_IMPORT_TRANCODING_DATA = "Couldn’t transcode the data due to error \"{}\", skipping the import!" HITMAN_DIALOG_WARNING_MISSING_FILE = "Skipping the file \"{}\" which is not present in the archive!" -HITMAN_1_DIALOG_ERROR_MISSING_BIN = "Couldn't find the necessary *.bin file!" -HITMAN_23_DIALOG_ERROR_MISSING_SCENES = "Couldn't find the necessary Scenes directory!" +HITMAN_1_DIALOG_ERROR_MISSING_BIN = "Couldn’t find the necessary *.bin file!" +HITMAN_23_DIALOG_ERROR_MISSING_SCENES = "Couldn’t find the necessary Scenes directory!" SETTINGS_DIALOG_TITLE = "Settings" SETTINGS_DIALOG_COMMON_GROUP = "Common" SETTINGS_DIALOG_HITMAN_RESET_RECORDS_CACHE = "Reset original records cache" diff --git a/src/Core/Application.cpp b/src/Core/Application.cpp index 80a22ed..d532de9 100644 --- a/src/Core/Application.cpp +++ b/src/Core/Application.cpp @@ -24,7 +24,7 @@ namespace std::shared_ptr s_SelectedDialog; OrderedSet> s_Dialogs; -String8CI s_OpenFilters; +std::vector> s_OpenFilters; } @@ -93,11 +93,9 @@ void InitializeOpenFilters() if (!s_OpenFilters.empty()) return; - auto hitmanFilters = Hitman1Dialog::GetOpenFilter(); - ranges::copy(Hitman23Dialog::GetOpenFilter(), std::back_inserter(hitmanFilters)); - ranges::copy(Hitman4Dialog::GetOpenFilter(), std::back_inserter(hitmanFilters)); - - s_OpenFilters = MakeFileDialogFilter(hitmanFilters); + s_OpenFilters = Hitman1Dialog::GetOpenFilter(); + ranges::copy(Hitman23Dialog::GetOpenFilter(), std::back_inserter(s_OpenFilters)); + ranges::copy(Hitman4Dialog::GetOpenFilter(), std::back_inserter(s_OpenFilters)); } namespace App { @@ -314,7 +312,7 @@ ExitStatus App::Application::run() { { InitializeOpenFilters(); - auto [archivePath, archiveType] = OpenFileDialog(s_OpenFilters); + const auto archivePath = OpenFileDialog(s_OpenFilters); auto alreadyOpened = false; for (const auto& dialog : s_Dialogs) @@ -327,68 +325,41 @@ ExitStatus App::Application::run() { } // TODO - some error messages/warnings wouldn't hurt... - if (!alreadyOpened && !archivePath.empty() && archiveType != 0) + if (!alreadyOpened && !archivePath.empty()) { - switch (archiveType) - { - case 1: - { - - const auto* originalSelectedDialog = s_SelectedDialog.get(); - - for (const auto& filter : Hitman1Dialog::GetOpenFilter() | ranges::views::values) - { - if (archivePath.path().extension() != StringViewWCI(filter.path().extension())) - continue; - - s_SelectedDialog = *s_Dialogs.insert(std::make_shared()).first; - s_SelectedDialog->Load(archivePath); - break; - } - - if (s_SelectedDialog.get() != originalSelectedDialog) - break; + const auto* originalSelectedDialog = s_SelectedDialog.get(); - for (const auto& filter : Hitman23Dialog::GetOpenFilter() | ranges::views::values) - { - if (archivePath.path().extension() != StringViewWCI(filter.path().extension())) - continue; - - s_SelectedDialog = *s_Dialogs.insert(std::make_shared()).first; - s_SelectedDialog->Load(archivePath); - break; - } - - if (s_SelectedDialog.get() != originalSelectedDialog) - break; - - for (const auto& filter : Hitman4Dialog::GetOpenFilter() | ranges::views::values) - { - if (archivePath.path().extension() != StringViewWCI(filter.path().extension())) - continue; + for (const auto& filter : Hitman1Dialog::GetOpenFilter() | ranges::views::keys) + { + if (archivePath.path().extension() != StringViewWCI(filter.path().extension())) + continue; - s_SelectedDialog = *s_Dialogs.insert(std::make_shared()).first; - s_SelectedDialog->Load(archivePath); - break; - } + s_SelectedDialog = *s_Dialogs.insert(std::make_shared()).first; + s_SelectedDialog->Load(archivePath); + break; + } - break; - } - case 2: - { - s_SelectedDialog = *s_Dialogs.insert(std::make_unique()).first; - s_SelectedDialog->Load(archivePath); - break; - } - case 3: + if (s_SelectedDialog.get() == originalSelectedDialog) + { + for (const auto& filter : Hitman23Dialog::GetOpenFilter() | ranges::views::keys) { - s_SelectedDialog = *s_Dialogs.insert(std::make_unique()).first; + if (archivePath.path().extension() != StringViewWCI(filter.path().extension())) + continue; + + s_SelectedDialog = *s_Dialogs.insert(std::make_shared()).first; s_SelectedDialog->Load(archivePath); break; } - case 4: + } + + if (s_SelectedDialog.get() == originalSelectedDialog) + { + for (const auto& filter : Hitman4Dialog::GetOpenFilter() | ranges::views::keys) { - s_SelectedDialog = *s_Dialogs.insert(std::make_unique()).first; + if (archivePath.path().extension() != StringViewWCI(filter.path().extension())) + continue; + + s_SelectedDialog = *s_Dialogs.insert(std::make_shared()).first; s_SelectedDialog->Load(archivePath); break; } @@ -435,7 +406,7 @@ ExitStatus App::Application::run() { { assert(s_SelectedDialog); - const auto [archivePath, archiveType] = SaveFileDialog(MakeFileDialogFilter(s_SelectedDialog->GetSaveFilter())); + const auto archivePath = SaveFileDialog(s_SelectedDialog->GetSaveFilter()); s_SelectedDialog->Save(archivePath, true); } diff --git a/src/G1AT/ArchiveDialog.hpp b/src/G1AT/ArchiveDialog.hpp index f4da02c..a336854 100644 --- a/src/G1AT/ArchiveDialog.hpp +++ b/src/G1AT/ArchiveDialog.hpp @@ -71,7 +71,7 @@ class ArchiveDialog virtual bool IsExportAllowed() const = 0; virtual bool IsImportAllowed() const = 0; - virtual const std::vector>& GetSaveFilter() const = 0; + virtual const std::vector>& GetSaveFilter() const = 0; bool IsAllowed() const; bool IsInProgress() const; diff --git a/src/G1AT/Hitman1Dialog.cpp b/src/G1AT/Hitman1Dialog.cpp index 5bd0e5a..38e1733 100644 --- a/src/G1AT/Hitman1Dialog.cpp +++ b/src/G1AT/Hitman1Dialog.cpp @@ -186,24 +186,24 @@ int32_t Hitman1Dialog::DrawDialog() return DrawHitmanDialog(); } -const std::vector>& Hitman1Dialog::GetOpenFilter() +const std::vector>& Hitman1Dialog::GetOpenFilter() { - static std::vector> filters; + static std::vector> filters; if (!filters.empty()) return filters; - filters.emplace_back("FILE_DIALOG_FILTER_HITMAN1_SPEECH", "*.idx"); + filters.emplace_back("*.idx", "FILE_DIALOG_FILTER_HITMAN1_SPEECH"); return filters; } -const std::vector>& Hitman1Dialog::GetSaveFilter() const +const std::vector>& Hitman1Dialog::GetSaveFilter() const { - static std::vector> filters; + static std::vector> filters; if (!filters.empty()) return filters; - filters.emplace_back("FILE_DIALOG_FILTER_HITMAN1_SPEECH", "*.idx"); + filters.emplace_back("*.idx", "FILE_DIALOG_FILTER_HITMAN1_SPEECH"); return filters; } diff --git a/src/G1AT/Hitman1Dialog.hpp b/src/G1AT/Hitman1Dialog.hpp index 5aef427..8f4c8a8 100644 --- a/src/G1AT/Hitman1Dialog.hpp +++ b/src/G1AT/Hitman1Dialog.hpp @@ -21,9 +21,9 @@ class Hitman1Dialog final : public HitmanDialog int32_t DrawDialog() override; - static const std::vector>& GetOpenFilter(); + static const std::vector>& GetOpenFilter(); - const std::vector>& GetSaveFilter() const override; + const std::vector>& GetSaveFilter() const override; std::vector indexToKey; diff --git a/src/G1AT/Hitman23Dialog.cpp b/src/G1AT/Hitman23Dialog.cpp index 971e1aa..a0abc54 100644 --- a/src/G1AT/Hitman23Dialog.cpp +++ b/src/G1AT/Hitman23Dialog.cpp @@ -417,24 +417,24 @@ int32_t Hitman23Dialog::DrawDialog() return DrawHitmanDialog(); } -const std::vector>& Hitman23Dialog::GetOpenFilter() +const std::vector>& Hitman23Dialog::GetOpenFilter() { - static std::vector> filters; + static std::vector> filters; if (!filters.empty()) return filters; - filters.emplace_back("FILE_DIALOG_FILTER_HITMAN23_STREAMS", "streams.wav"); + filters.emplace_back("streams.wav", "FILE_DIALOG_FILTER_HITMAN23_STREAMS"); return filters; } -const std::vector>& Hitman23Dialog::GetSaveFilter() const +const std::vector>& Hitman23Dialog::GetSaveFilter() const { - static std::vector> filters; + static std::vector> filters; if (!filters.empty()) return filters; - filters.emplace_back("FILE_DIALOG_FILTER_HITMAN23_STREAMS", "streams.wav"); + filters.emplace_back("streams.wav", "FILE_DIALOG_FILTER_HITMAN23_STREAMS"); return filters; } diff --git a/src/G1AT/Hitman23Dialog.hpp b/src/G1AT/Hitman23Dialog.hpp index 91664dc..8248055 100644 --- a/src/G1AT/Hitman23Dialog.hpp +++ b/src/G1AT/Hitman23Dialog.hpp @@ -116,9 +116,9 @@ class Hitman23Dialog final : public HitmanDialog int32_t DrawDialog() override; - static const std::vector>& GetOpenFilter(); + static const std::vector>& GetOpenFilter(); - const std::vector>& GetSaveFilter() const override; + const std::vector>& GetSaveFilter() const override; std::vector whdFiles; std::vector wavFiles; diff --git a/src/G1AT/Hitman4Dialog.cpp b/src/G1AT/Hitman4Dialog.cpp index 57f5107..7bee38b 100644 --- a/src/G1AT/Hitman4Dialog.cpp +++ b/src/G1AT/Hitman4Dialog.cpp @@ -947,24 +947,24 @@ bool Hitman4Dialog::IsImportAllowed() const return G1AT_DEBUG_BUILD == 1; } -const std::vector>& Hitman4Dialog::GetOpenFilter() +const std::vector>& Hitman4Dialog::GetOpenFilter() { - static std::vector> filters; + static std::vector> filters; if (!filters.empty()) return filters; - filters.emplace_back("FILE_DIALOG_FILTER_HITMAN4_STREAMS", "pc_*.str"); + filters.emplace_back("pc_*.str", "FILE_DIALOG_FILTER_HITMAN4_STREAMS"); return filters; } -const std::vector>& Hitman4Dialog::GetSaveFilter() const +const std::vector>& Hitman4Dialog::GetSaveFilter() const { - static std::vector> filters; + static std::vector> filters; if (!filters.empty()) return filters; - filters.emplace_back("FILE_DIALOG_FILTER_HITMAN4_STREAMS", "pc_*.str"); + filters.emplace_back("pc_*.str", "FILE_DIALOG_FILTER_HITMAN4_STREAMS"); return filters; } diff --git a/src/G1AT/Hitman4Dialog.hpp b/src/G1AT/Hitman4Dialog.hpp index 0d3c276..4ce6cf9 100644 --- a/src/G1AT/Hitman4Dialog.hpp +++ b/src/G1AT/Hitman4Dialog.hpp @@ -263,9 +263,9 @@ class Hitman4Dialog final : public HitmanDialog bool IsExportAllowed() const override; bool IsImportAllowed() const override; - static const std::vector>& GetOpenFilter(); + static const std::vector>& GetOpenFilter(); - const std::vector>& GetSaveFilter() const override; + const std::vector>& GetSaveFilter() const override; std::vector whdFiles; std::vector wavFiles; diff --git a/src/G1AT/Utils.cpp b/src/G1AT/Utils.cpp index 003ec7f..c27e827 100644 --- a/src/G1AT/Utils.cpp +++ b/src/G1AT/Utils.cpp @@ -12,9 +12,6 @@ #include "Options.hpp" -#include -#include - std::vector ReadWholeBinaryFile(const StringView8CI &acpPath) { const auto path = acpPath.path(); @@ -59,85 +56,36 @@ float GetAlignedItemWidth(const int64_t acItemsCount) String8CI BrowseDirectoryDialog() { - BROWSEINFOA bi; - ZeroMemory(&bi, sizeof(bi)); - bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; - - const auto pidl = SHBrowseForFolderA(&bi); - if (!pidl) - return ""; - - String8CI path; - path.resize(UINT16_MAX, L'\0'); - SHGetPathFromIDListA(pidl, path.data()); + if (const auto* directoryPath = tinyfd_selectFolderDialog(nullptr, nullptr)) + return {directoryPath, std::strlen(directoryPath)}; - IMalloc *imalloc = nullptr; - if (SUCCEEDED(SHGetMalloc(&imalloc))) - { - imalloc->Free(pidl); - imalloc->Release(); - } - - path.resize(strlen(path.c_str())); - return path; + return {}; } -std::pair OpenFileDialog(const StringView8CI &filters, const StringView8CI &defaultFileName) +String8CI OpenFileDialog(const std::vector> &filters, const StringView8CI &defaultFileName) { - OPENFILENAMEA ofn; - ZeroMemory(&ofn, sizeof(ofn)); - - String8CI fileName{ defaultFileName }; - fileName.resize(UINT16_MAX, '\0'); - - // Initialize OPENFILENAME - ofn.lStructSize = sizeof(ofn); - ofn.lpstrFile = fileName.data(); - ofn.nMaxFile = static_cast(fileName.size()); - ofn.lpstrFilter = filters.c_str(); - ofn.nFilterIndex = 0; - ofn.lpstrFileTitle = nullptr; - ofn.nMaxFileTitle = 0; - ofn.Flags = OFN_LONGNAMES | OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; - - if (!GetOpenFileNameA(&ofn)) - return {{}, 0}; + std::vector filtersTransformed; + filtersTransformed.reserve(filters.size()); + for (const auto &filter : filters | ranges::views::keys) + filtersTransformed.emplace_back(filter.c_str()); - fileName.resize(strlen(fileName.c_str())); + if (const auto* filePath = tinyfd_openFileDialog(nullptr, defaultFileName.c_str(), static_cast(filtersTransformed.size()), filtersTransformed.data(), g_LocalizationManager.Localize("FILE_DIALOG_FILTER_ALL_SUPPORTED").c_str(), 0)) + return {filePath, std::strlen(filePath)}; - if (fileName.native().rfind('.') == String8CI::npos) - return {{}, 0}; - - return {fileName, ofn.nFilterIndex}; + return {}; } -std::pair SaveFileDialog(const StringView8CI &filters, const StringView8CI &defaultFileName) +String8CI SaveFileDialog(const std::vector> &filters, const StringView8CI &defaultFileName) { - OPENFILENAMEA ofn; - ZeroMemory(&ofn, sizeof(ofn)); - - String8CI fileName{ defaultFileName }; - fileName.resize(UINT16_MAX, '\0'); - - // Initialize OPENFILENAME - ofn.lStructSize = sizeof(ofn); - ofn.lpstrFile = fileName.data(); - ofn.nMaxFile = static_cast(fileName.size()); - ofn.lpstrFilter = filters.c_str(); - ofn.nFilterIndex = 0; - ofn.lpstrFileTitle = nullptr; - ofn.nMaxFileTitle = 0; - ofn.Flags = OFN_LONGNAMES | OFN_EXPLORER | OFN_OVERWRITEPROMPT; - - if (!GetSaveFileNameA(&ofn)) - return {}; + std::vector filtersTransformed; + filtersTransformed.reserve(filters.size()); + for (const auto &filter : filters | ranges::views::keys) + filtersTransformed.emplace_back(filter.c_str()); - fileName.resize(strlen(fileName.c_str())); + if (const auto* filePath = tinyfd_saveFileDialog(nullptr, defaultFileName.c_str(), static_cast(filtersTransformed.size()), filtersTransformed.data(), g_LocalizationManager.Localize("FILE_DIALOG_FILTER_ALL_SUPPORTED").c_str())) + return {filePath, std::strlen(filePath)}; - if (fileName.native().rfind('.') == String8CI::npos) - return {{}, 0}; - - return {fileName, ofn.nFilterIndex}; + return {}; } std::vector GetAllFilesInDirectory(const StringView8CI &directory, const StringView8CI &extension, bool recursive) @@ -193,7 +141,8 @@ int32_t DisplayInformation(const StringView8 &message, const StringView8 &title, if (!yesNo && options.common.disableWarnings) return -1; - return DisplayMessage(message, title, yesNo, SDL_MESSAGEBOX_INFORMATION); + const auto result = tinyfd_messageBox(title.c_str(), message.c_str(), yesNo ? "yesnocancel" : "ok", "info", yesNo ? 0 : 1); + return result == 0 ? -1 : (result == 2 ? 0 : 1); } int32_t DisplayWarning(const StringView8 &message, const StringView8 &title, bool yesNo, const Options &options) @@ -201,37 +150,14 @@ int32_t DisplayWarning(const StringView8 &message, const StringView8 &title, boo if (!yesNo && options.common.disableWarnings) return -1; - return DisplayMessage(message, title, yesNo, SDL_MESSAGEBOX_WARNING); + const auto result = tinyfd_messageBox(title.c_str(), message.c_str(), yesNo ? "yesnocancel" : "ok", "warning", yesNo ? 0 : 1); + return result == 0 ? -1 : (result == 2 ? 0 : 1); } int32_t DisplayError(const StringView8 &message, const StringView8 &title, bool yesNo) { - return DisplayMessage(message, title, yesNo, SDL_MESSAGEBOX_ERROR); -} - -int32_t DisplayMessage(const StringView8 &message, const StringView8 &title, bool yesNo, const uint32_t messageFlags) -{ - static std::array yesNoButtonDatas{SDL_MessageBoxButtonData{SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, -1, g_LocalizationManager.Localize("MESSAGEBOX_BUTTON_CANCEL").c_str()}, - SDL_MessageBoxButtonData{SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 0, g_LocalizationManager.Localize("MESSAGEBOX_BUTTON_NO").c_str()}, - SDL_MessageBoxButtonData{0, 1, g_LocalizationManager.Localize("MESSAGEBOX_BUTTON_YES").c_str()}}; - static SDL_MessageBoxButtonData okButtonData{SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT | SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, -1, g_LocalizationManager.Localize("MESSAGEBOX_BUTTON_OK").c_str()}; - static SDL_MessageBoxColorScheme colorScheme{ - { - SDL_MessageBoxColor{static_cast(0.94f * 0.06f * 255), static_cast(0.94f * 0.06f * 255), static_cast(0.94f * 0.06f * 255)}, - SDL_MessageBoxColor{static_cast(1.00f * 1.00f * 255), static_cast(1.00f * 1.00f * 255), static_cast(1.00f * 1.00f * 255)}, - SDL_MessageBoxColor{static_cast(0.50f * 0.43f * 255), static_cast(0.50f * 0.43f * 255), static_cast(0.50f * 0.50f * 255)}, - SDL_MessageBoxColor{static_cast(0.40f * 0.26f * 255), static_cast(0.40f * 0.59f * 255), static_cast(0.40f * 0.98f * 255)}, - SDL_MessageBoxColor{static_cast(1.00f * 0.06f * 255), static_cast(1.00f * 0.53f * 255), static_cast(1.00f * 0.98f * 255)} - }}; - - int32_t outButton = -1; - SDL_MessageBoxData data{messageFlags, nullptr, title.c_str(), message.c_str(), yesNo ? 3 : 1, yesNo ? yesNoButtonDatas.data() : &okButtonData, &colorScheme}; - if (const auto err = SDL_ShowMessageBox(&data, &outButton)) - { - [[maybe_unused]] const String8 errorMessage = SDL_GetError(); - SDL_ClearError(); - } - return outButton; + const auto result = tinyfd_messageBox(title.c_str(), message.c_str(), yesNo ? "yesnocancel" : "ok", "error", yesNo ? 0 : 1); + return result == 0 ? -1 : (result == 2 ? 0 : 1); } std::vector GetPathStems(StringView8CI pathView) @@ -261,36 +187,3 @@ std::vector GetPathStems(StringView8CI pathView) return pathStems; } - -String8CI MakeFileDialogFilter(const std::vector> &filters) -{ - if (filters.empty()) - return {}; - - String8CI allFiltersFilter; - String8CI allFiltersDisplay; - for (const auto& filter : filters | ranges::views::values) - { - if (!allFiltersFilter.empty()) - allFiltersFilter += ";"; - - allFiltersFilter += filter; - - if (!allFiltersDisplay.empty()) - allFiltersDisplay += "/"; - - allFiltersDisplay += filter; - } - - String8CI result; - - if (filters.size() > 1) - result = Format("{0} ({1})?{2}?", g_LocalizationManager.Localize("FILE_DIALOG_FILTER_ALL_SUPPORTED"), allFiltersDisplay, allFiltersFilter); - - for (const auto& [identifier, filter] : filters) - result += Format("{0} ({1})?{1}?", g_LocalizationManager.Localize(identifier), filter); - - ranges::replace(result, '?', '\0'); - - return result; -} diff --git a/src/G1AT/Utils.hpp b/src/G1AT/Utils.hpp index edcdace..0acf46b 100644 --- a/src/G1AT/Utils.hpp +++ b/src/G1AT/Utils.hpp @@ -16,9 +16,9 @@ float GetAlignedItemWidth(int64_t acItemsCount); String8CI BrowseDirectoryDialog(); -std::pair OpenFileDialog(const StringView8CI &filters, const StringView8CI &defaultFileName = ""); +String8CI OpenFileDialog(const std::vector> &filters, const StringView8CI &defaultFileName = ""); -std::pair SaveFileDialog(const StringView8CI &filters, const StringView8CI &defaultFileName = ""); +String8CI SaveFileDialog(const std::vector> &filters, const StringView8CI &defaultFileName = ""); std::vector GetAllFilesInDirectory(const StringView8CI &directory, const StringView8CI &extension, bool recursive); @@ -26,8 +26,6 @@ StringView8CI GetProgramPath(); StringView8CI GetUserPath(); -int32_t DisplayMessage(const StringView8 &message, const StringView8 &title = g_LocalizationManager.Localize("MESSAGEBOX_TITLE_INFORMATION"), bool yesNo = false, const uint32_t messageFlags = SDL_MESSAGEBOX_INFORMATION); - int32_t DisplayInformation(const StringView8 &message, const StringView8 &title = g_LocalizationManager.Localize("MESSAGEBOX_TITLE_INFORMATION"), bool yesNo = false, const Options &options = Options::Get()); int32_t DisplayWarning(const StringView8 &message, const StringView8 &title = g_LocalizationManager.Localize("MESSAGEBOX_TITLE_WARNING"), bool yesNo = false, const Options &options = Options::Get()); @@ -35,5 +33,3 @@ int32_t DisplayWarning(const StringView8 &message, const StringView8 &title = g_ int32_t DisplayError(const StringView8 &message, const StringView8 &title = g_LocalizationManager.Localize("MESSAGEBOX_TITLE_ERROR"), bool yesNo = false); std::vector GetPathStems(StringView8CI pathView); - -String8CI MakeFileDialogFilter(const std::vector>& filters); diff --git a/src/Precompiled.h b/src/Precompiled.h index 4eaeb9c..3654640 100644 --- a/src/Precompiled.h +++ b/src/Precompiled.h @@ -10,6 +10,7 @@ #include #include +#include #include #include diff --git a/xmake.lua b/xmake.lua index 574f0ed..2e368a0 100644 --- a/xmake.lua +++ b/xmake.lua @@ -118,7 +118,7 @@ target("imgui-backends") target_end() target("Glacier1AudioTool") - set_version("1.2.1") + set_version("1.2.2") set_kind("binary") set_rundir("$(projectdir)")