From d8e1284946a216311c6f4f7e4bd843a61293a527 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 27 Jul 2024 14:09:52 +0200 Subject: [PATCH] fix: Task names not displaying correctly anymore --- .../include/hex/api/localization_manager.hpp | 8 ++++--- lib/libimhex/include/hex/api/task_manager.hpp | 12 +++++----- lib/libimhex/include/hex/ui/widgets.hpp | 2 +- lib/libimhex/source/api/imhex_api.cpp | 2 +- .../source/api/localization_manager.cpp | 9 ++++--- lib/libimhex/source/api/task_manager.cpp | 24 +++++++++---------- .../include/content/helpers/diagrams.hpp | 6 ++--- .../content/popups/popup_docs_question.hpp | 2 +- plugins/builtin/source/content/init_tasks.cpp | 4 ++-- .../source/content/main_menu_items.cpp | 18 +++++++------- .../hex_editor/popup_hex_editor_find.cpp | 2 +- plugins/builtin/source/content/recent.cpp | 2 +- .../source/content/settings_entries.cpp | 2 +- .../content/tools/file_tool_combiner.cpp | 2 +- .../content/tools/file_tool_shredder.cpp | 2 +- .../content/tools/file_tool_splitter.cpp | 2 +- plugins/builtin/source/content/ui_items.cpp | 6 ++--- .../source/content/views/view_bookmarks.cpp | 4 ++-- .../content/views/view_data_inspector.cpp | 2 +- .../content/views/view_data_processor.cpp | 2 +- .../source/content/views/view_find.cpp | 4 ++-- .../source/content/views/view_hex_editor.cpp | 4 ++-- .../content/views/view_pattern_editor.cpp | 12 +++++----- .../source/content/views/view_store.cpp | 2 +- .../builtin/source/content/welcome_screen.cpp | 4 ++-- .../source/content/views/view_diff.cpp | 2 +- .../content/views/view_disassembler.cpp | 2 +- .../source/plugin_script_loader.cpp | 6 ++--- plugins/ui/source/ui/hex_editor.cpp | 2 +- .../source/content/pl_visualizers/sound.cpp | 2 +- .../windows/source/views/view_tty_console.cpp | 2 +- .../source/content/views/view_yara.cpp | 2 +- 32 files changed, 79 insertions(+), 78 deletions(-) diff --git a/lib/libimhex/include/hex/api/localization_manager.hpp b/lib/libimhex/include/hex/api/localization_manager.hpp index 104e444e5..26cceba1c 100644 --- a/lib/libimhex/include/hex/api/localization_manager.hpp +++ b/lib/libimhex/include/hex/api/localization_manager.hpp @@ -44,6 +44,7 @@ namespace hex { class Lang { public: + Lang() = default; explicit Lang(const char *unlocalizedString); explicit Lang(const std::string &unlocalizedString); explicit Lang(const UnlocalizedString &unlocalizedString); @@ -53,7 +54,7 @@ namespace hex { [[nodiscard]] operator std::string_view() const; [[nodiscard]] operator const char *() const; - const std::string &get() const; + const char* get() const; constexpr static size_t hash(std::string_view string){ constexpr u64 p = 131; @@ -70,13 +71,14 @@ namespace hex { } private: - constexpr explicit Lang(std::size_t hash) : m_entryHash(hash) {} + constexpr explicit Lang(std::size_t hash, const char *unlocalizedString) : m_entryHash(hash), m_unlocalizedString(unlocalizedString) {} template friend consteval Lang operator""_lang(); private: std::size_t m_entryHash; + const char *m_unlocalizedString = nullptr; }; [[nodiscard]] std::string operator+(const std::string &&left, const Lang &&right); @@ -89,7 +91,7 @@ namespace hex { template [[nodiscard]] consteval Lang operator""_lang() { - return Lang(Lang::hash(String.value.data())); + return Lang(Lang::hash(String.value.data()), String.value.data()); } diff --git a/lib/libimhex/include/hex/api/task_manager.hpp b/lib/libimhex/include/hex/api/task_manager.hpp index 1a22ae847..040d91d7c 100644 --- a/lib/libimhex/include/hex/api/task_manager.hpp +++ b/lib/libimhex/include/hex/api/task_manager.hpp @@ -22,7 +22,7 @@ namespace hex { class Task { public: Task() = default; - Task(UnlocalizedString unlocalizedName, u64 maxValue, bool background, std::function function); + Task(Lang name, u64 maxValue, bool background, std::function function); Task(const Task&) = delete; Task(Task &&other) noexcept; @@ -65,7 +65,7 @@ namespace hex { void clearException(); [[nodiscard]] std::string getExceptionMessage() const; - [[nodiscard]] const UnlocalizedString &getUnlocalizedName(); + [[nodiscard]] const Lang &getName(); [[nodiscard]] u64 getValue() const; [[nodiscard]] u64 getMaxValue() const; @@ -77,7 +77,7 @@ namespace hex { private: mutable std::mutex m_mutex; - UnlocalizedString m_unlocalizedName; + Lang m_name; std::atomic m_currValue = 0, m_maxValue = 0; std::function m_interruptCallback; std::function m_function; @@ -135,7 +135,7 @@ namespace hex { * @param function Function to be executed * @return A TaskHolder holding a weak reference to the task */ - static TaskHolder createTask(std::string name, u64 maxValue, std::function function); + static TaskHolder createTask(Lang name, u64 maxValue, std::function function); /** * @brief Creates a new asynchronous task that does not get displayed in the Task Manager @@ -143,7 +143,7 @@ namespace hex { * @param function Function to be executed * @return A TaskHolder holding a weak reference to the task */ - static TaskHolder createBackgroundTask(std::string name, std::function function); + static TaskHolder createBackgroundTask(Lang name, std::function function); /** * @brief Creates a new synchronous task that will execute the given function at the start of the next frame @@ -190,7 +190,7 @@ namespace hex { static void runDeferredCalls(); private: - static TaskHolder createTask(std::string name, u64 maxValue, bool background, std::function function); + static TaskHolder createTask(Lang name, u64 maxValue, bool background, std::function function); }; } \ No newline at end of file diff --git a/lib/libimhex/include/hex/ui/widgets.hpp b/lib/libimhex/include/hex/ui/widgets.hpp index 6ef8f967e..5b8043f05 100644 --- a/lib/libimhex/include/hex/ui/widgets.hpp +++ b/lib/libimhex/include/hex/ui/widgets.hpp @@ -35,7 +35,7 @@ namespace hex::ui { m_filteredEntries.clear(); m_filteredEntries.reserve(entries.size()); - m_updateTask = TaskManager::createBackgroundTask("Searching", [this, &entries, searchBuffer = m_searchBuffer](Task&) { + m_updateTask = TaskManager::createBackgroundTask("Searching"_lang, [this, &entries, searchBuffer = m_searchBuffer](Task&) { for (auto &entry : entries) { if (searchBuffer.empty() || m_comparator(searchBuffer, entry)) m_filteredEntries.push_back(&entry); diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index 4d48152c2..563cb8aed 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -450,7 +450,7 @@ namespace hex { // Do the destruction of the provider in the background once all tasks have finished TaskManager::runWhenTasksFinished([providerToRemove] { EventProviderDeleted::post(providerToRemove); - TaskManager::createBackgroundTask("Closing Provider", [providerToRemove](Task &) { + TaskManager::createBackgroundTask("Closing Provider"_lang, [providerToRemove](Task &) { eraseMutex.lock(); auto provider = std::move((*s_providersToRemove)[providerToRemove]); s_providersToRemove->erase(providerToRemove); diff --git a/lib/libimhex/source/api/localization_manager.cpp b/lib/libimhex/source/api/localization_manager.cpp index 4d58d4ff7..3d2a41aa6 100644 --- a/lib/libimhex/source/api/localization_manager.cpp +++ b/lib/libimhex/source/api/localization_manager.cpp @@ -123,18 +123,17 @@ namespace hex { } Lang::operator const char *() const { - return get().c_str(); + return get(); } - const std::string &Lang::get() const { + const char *Lang::get() const { const auto &lang = *LocalizationManager::s_currStrings; auto it = lang.find(m_entryHash); if (it == lang.end()) { - static const std::string invalidString = "[ !!! INVALID LANGUAGE STRING !!! ]"; - return invalidString; + return m_unlocalizedString == nullptr ? "[ !!! INVALID LANGUAGE STRING !!! ]" : m_unlocalizedString; } else { - return it->second; + return it->second.c_str(); } } diff --git a/lib/libimhex/source/api/task_manager.cpp b/lib/libimhex/source/api/task_manager.cpp index 25b4e10bb..655ccf2d4 100644 --- a/lib/libimhex/source/api/task_manager.cpp +++ b/lib/libimhex/source/api/task_manager.cpp @@ -63,8 +63,8 @@ namespace hex { } - Task::Task(UnlocalizedString unlocalizedName, u64 maxValue, bool background, std::function function) - : m_unlocalizedName(std::move(unlocalizedName)), m_maxValue(maxValue), m_function(std::move(function)), m_background(background) { } + Task::Task(Lang name, u64 maxValue, bool background, std::function function) + : m_name(std::move(name)), m_maxValue(maxValue), m_function(std::move(function)), m_background(background) { } Task::Task(hex::Task &&other) noexcept { { @@ -72,7 +72,7 @@ namespace hex { std::scoped_lock otherLock(other.m_mutex); m_function = std::move(other.m_function); - m_unlocalizedName = std::move(other.m_unlocalizedName); + m_name = std::move(other.m_name); } m_maxValue = u64(other.m_maxValue); @@ -159,8 +159,8 @@ namespace hex { return m_exceptionMessage; } - const UnlocalizedString &Task::getUnlocalizedName() { - return m_unlocalizedName; + const Lang &Task::getName() { + return m_name; } u64 Task::getValue() const { @@ -275,22 +275,22 @@ namespace hex { try { // Set the thread name to the name of the task - TaskManager::setCurrentThreadName(Lang(task->m_unlocalizedName)); + TaskManager::setCurrentThreadName(task->m_name); // Execute the task task->m_function(*task); - log::debug("Task '{}' finished", task->m_unlocalizedName.get()); + log::debug("Task '{}' finished", task->m_name.get()); } catch (const Task::TaskInterruptor &) { // Handle the task being interrupted by user request task->interruption(); } catch (const std::exception &e) { - log::error("Exception in task '{}': {}", task->m_unlocalizedName.get(), e.what()); + log::error("Exception in task '{}': {}", task->m_name.get(), e.what()); // Handle the task throwing an uncaught exception task->exception(e.what()); } catch (...) { - log::error("Exception in task '{}'", task->m_unlocalizedName.get()); + log::error("Exception in task '{}'", task->m_name.get()); // Handle the task throwing an uncaught exception of unknown type task->exception("Unknown Exception"); @@ -327,7 +327,7 @@ namespace hex { s_tasksFinishedCallbacks.clear(); } - TaskHolder TaskManager::createTask(std::string name, u64 maxValue, bool background, std::function function) { + TaskHolder TaskManager::createTask(Lang name, u64 maxValue, bool background, std::function function) { std::scoped_lock lock(s_queueMutex); // Construct new task @@ -344,12 +344,12 @@ namespace hex { } - TaskHolder TaskManager::createTask(std::string name, u64 maxValue, std::function function) { + TaskHolder TaskManager::createTask(Lang name, u64 maxValue, std::function function) { log::debug("Creating task {}", name); return createTask(std::move(name), maxValue, false, std::move(function)); } - TaskHolder TaskManager::createBackgroundTask(std::string name, std::function function) { + TaskHolder TaskManager::createBackgroundTask(Lang name, std::function function) { log::debug("Creating background task {}", name); return createTask(std::move(name), 0, true, std::move(function)); } diff --git a/plugins/builtin/include/content/helpers/diagrams.hpp b/plugins/builtin/include/content/helpers/diagrams.hpp index 0b9dd1382..820c47799 100644 --- a/plugins/builtin/include/content/helpers/diagrams.hpp +++ b/plugins/builtin/include/content/helpers/diagrams.hpp @@ -806,7 +806,7 @@ namespace hex { const auto max = ImPlot::PlotToPixels(xMax, yMin); const auto mousePos = ImPlot::PixelsToPlot(ImGui::GetMousePos()); if (ImGui::IsMouseHoveringRect(min, max)) { - ImPlot::Annotation(xMin + (xMax - xMin) / 2, mousePos.y, annotation.color, ImVec2(), false, "%s", Lang(annotation.unlocalizedName).get().c_str()); + ImPlot::Annotation(xMin + (xMax - xMin) / 2, mousePos.y, annotation.color, ImVec2(), false, "%s", Lang(annotation.unlocalizedName).get()); if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) { ImHexApi::HexEditor::setSelection(annotation.region); @@ -818,9 +818,9 @@ namespace hex { for (const auto &tag : m_tags) { if (tag.axis == ImAxis_X1) - ImPlot::TagX(tag.value, ImGui::GetStyleColorVec4(tag.color), "%s", Lang(tag.unlocalizedName).get().c_str()); + ImPlot::TagX(tag.value, ImGui::GetStyleColorVec4(tag.color), "%s", Lang(tag.unlocalizedName).get()); else if (tag.axis == ImAxis_Y1) - ImPlot::TagY(tag.value, ImGui::GetStyleColorVec4(tag.color), "%s", Lang(tag.unlocalizedName).get().c_str()); + ImPlot::TagY(tag.value, ImGui::GetStyleColorVec4(tag.color), "%s", Lang(tag.unlocalizedName).get()); } } diff --git a/plugins/builtin/include/content/popups/popup_docs_question.hpp b/plugins/builtin/include/content/popups/popup_docs_question.hpp index 970664df7..e2c7f6c3a 100644 --- a/plugins/builtin/include/content/popups/popup_docs_question.hpp +++ b/plugins/builtin/include/content/popups/popup_docs_question.hpp @@ -85,7 +85,7 @@ namespace hex::plugin::builtin { private: void executeQuery() { - m_requestTask = TaskManager::createBackgroundTask("Query Docs", [this, input = m_inputBuffer](Task &) { + m_requestTask = TaskManager::createBackgroundTask("Query Docs"_lang, [this, input = m_inputBuffer](Task &) { m_noAnswer = false; for (auto space : { "xj7sbzGbHH260vbpZOu1", "WZzDdGjxmgMSIE3xly6o" }) { m_answer.clear(); diff --git a/plugins/builtin/source/content/init_tasks.cpp b/plugins/builtin/source/content/init_tasks.cpp index 55524504a..e7fb02884 100644 --- a/plugins/builtin/source/content/init_tasks.cpp +++ b/plugins/builtin/source/content/init_tasks.cpp @@ -59,7 +59,7 @@ namespace hex::plugin::builtin { ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.uuid", uuid); } - TaskManager::createBackgroundTask("Sending statistics...", [uuid, versionString](auto&) { + TaskManager::createBackgroundTask("Sending statistics..."_lang, [uuid, versionString](auto&) { // To avoid potentially flooding our database with lots of dead users // from people just visiting the website, don't send telemetry data from // the web version @@ -94,7 +94,7 @@ namespace hex::plugin::builtin { } bool checkForUpdates() { - TaskManager::createBackgroundTask("Checking for updates", [](auto&) { checkForUpdatesSync(); }); + TaskManager::createBackgroundTask("Checking for updates"_lang, [](auto&) { checkForUpdatesSync(); }); return true; } diff --git a/plugins/builtin/source/content/main_menu_items.cpp b/plugins/builtin/source/content/main_menu_items.cpp index d917e31e1..5ffaf2cd2 100644 --- a/plugins/builtin/source/content/main_menu_items.cpp +++ b/plugins/builtin/source/content/main_menu_items.cpp @@ -76,7 +76,7 @@ namespace hex::plugin::builtin { void importIPSPatch() { fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) { - TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [path](auto &task) { + TaskManager::createTask("hex.ui.common.processing"_lang, TaskManager::NoProgress, [path](auto &task) { auto patchData = wolv::io::File(path, wolv::io::File::Mode::Read).readVector(); auto patch = Patches::fromIPSPatch(patchData); if (!patch.has_value()) { @@ -100,7 +100,7 @@ namespace hex::plugin::builtin { void importIPS32Patch() { fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) { - TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [path](auto &task) { + TaskManager::createTask("hex.ui.common.processing"_lang, TaskManager::NoProgress, [path](auto &task) { auto patchData = wolv::io::File(path, wolv::io::File::Mode::Read).readVector(); auto patch = Patches::fromIPS32Patch(patchData); if (!patch.has_value()) { @@ -124,7 +124,7 @@ namespace hex::plugin::builtin { void importModifiedFile() { fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) { - TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [path](auto &task) { + TaskManager::createTask("hex.ui.common.processing"_lang, TaskManager::NoProgress, [path](auto &task) { auto provider = ImHexApi::Provider::get(); auto patchData = wolv::io::File(path, wolv::io::File::Mode::Read).readVector(); @@ -163,7 +163,7 @@ namespace hex::plugin::builtin { void exportBase64() { fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) { - TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [path](auto &) { + TaskManager::createTask("hex.ui.common.processing"_lang, TaskManager::NoProgress, [path](auto &) { wolv::io::File outputFile(path, wolv::io::File::Mode::Create); if (!outputFile.isValid()) { TaskManager::doLater([] { @@ -186,7 +186,7 @@ namespace hex::plugin::builtin { void exportSelectionToFile() { fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) { - TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [path](auto &task) { + TaskManager::createTask("hex.ui.common.processing"_lang, TaskManager::NoProgress, [path](auto &task) { wolv::io::File outputFile(path, wolv::io::File::Mode::Create); if (!outputFile.isValid()) { TaskManager::doLater([] { @@ -214,7 +214,7 @@ namespace hex::plugin::builtin { for (const auto &formatter : ContentRegistry::DataFormatter::impl::getExportMenuEntries()) { if (ImGui::MenuItem(Lang(formatter.unlocalizedName), nullptr, false, ImHexApi::Provider::get()->getActualSize() > 0)) { fs::openFileBrowser(fs::DialogMode::Save, {}, [&formatter](const auto &path) { - TaskManager::createTask("Exporting data", TaskManager::NoProgress, [&formatter, path](auto&){ + TaskManager::createTask("Exporting data"_lang, TaskManager::NoProgress, [&formatter, path](auto&){ auto provider = ImHexApi::Provider::get(); auto selection = ImHexApi::HexEditor::getSelection() .value_or( @@ -241,7 +241,7 @@ namespace hex::plugin::builtin { } void exportReport() { - TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [](auto &) { + TaskManager::createTask("hex.ui.common.processing"_lang, TaskManager::NoProgress, [](auto &) { std::string data; for (const auto &provider : ImHexApi::Provider::getProviders()) { @@ -285,7 +285,7 @@ namespace hex::plugin::builtin { patches->get().at(0x00454F45) = value; } - TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [patches](auto &) { + TaskManager::createTask("hex.ui.common.processing"_lang, TaskManager::NoProgress, [patches](auto &) { auto data = patches->toIPSPatch(); TaskManager::doLater([data] { @@ -324,7 +324,7 @@ namespace hex::plugin::builtin { patches->get().at(0x45454F45) = value; } - TaskManager::createTask("hex.ui.common.processing", TaskManager::NoProgress, [patches](auto &) { + TaskManager::createTask("hex.ui.common.processing"_lang, TaskManager::NoProgress, [patches](auto &) { auto data = patches->toIPS32Patch(); TaskManager::doLater([data] { diff --git a/plugins/builtin/source/content/popups/hex_editor/popup_hex_editor_find.cpp b/plugins/builtin/source/content/popups/hex_editor/popup_hex_editor_find.cpp index d1ec72730..c096800dd 100644 --- a/plugins/builtin/source/content/popups/hex_editor/popup_hex_editor_find.cpp +++ b/plugins/builtin/source/content/popups/hex_editor/popup_hex_editor_find.cpp @@ -87,7 +87,7 @@ namespace hex::plugin::builtin { this->processInputString(); if (!m_searchTask.isRunning() && !m_searchByteSequence.empty()) { - m_searchTask = TaskManager::createTask("hex.ui.common.processing", + m_searchTask = TaskManager::createTask("hex.ui.common.processing"_lang, ImHexApi::Provider::get()->getActualSize(), doSearch); } diff --git a/plugins/builtin/source/content/recent.cpp b/plugins/builtin/source/content/recent.cpp index be8a337cb..8fbbad834 100644 --- a/plugins/builtin/source/content/recent.cpp +++ b/plugins/builtin/source/content/recent.cpp @@ -149,7 +149,7 @@ namespace hex::plugin::builtin::recent { } void updateRecentEntries() { - TaskManager::createBackgroundTask("Updating recent files", [](auto&) { + TaskManager::createBackgroundTask("Updating recent files"_lang, [](auto&) { if (s_recentEntriesUpdating) return; diff --git a/plugins/builtin/source/content/settings_entries.cpp b/plugins/builtin/source/content/settings_entries.cpp index 47500811a..187005d70 100644 --- a/plugins/builtin/source/content/settings_entries.cpp +++ b/plugins/builtin/source/content/settings_entries.cpp @@ -544,7 +544,7 @@ namespace hex::plugin::builtin { auto max = ImGui::GetItemRectMax(); auto iconSize = ImGui::CalcTextSize(menuItem->icon.glyph.c_str()); - auto text = Lang(unlocalizedName).get(); + std::string text = Lang(unlocalizedName); if (text.ends_with("...")) text = text.substr(0, text.size() - 3); diff --git a/plugins/builtin/source/content/tools/file_tool_combiner.cpp b/plugins/builtin/source/content/tools/file_tool_combiner.cpp index 523d6865d..519cec3e2 100644 --- a/plugins/builtin/source/content/tools/file_tool_combiner.cpp +++ b/plugins/builtin/source/content/tools/file_tool_combiner.cpp @@ -110,7 +110,7 @@ namespace hex::plugin::builtin { ImGuiExt::TextSpinner("hex.builtin.tools.file_tools.combiner.combining"_lang); } else { if (ImGui::Button("hex.builtin.tools.file_tools.combiner.combine"_lang)) { - combinerTask = TaskManager::createTask("hex.builtin.tools.file_tools.combiner.combining", 0, [](auto &task) { + combinerTask = TaskManager::createTask("hex.builtin.tools.file_tools.combiner.combining"_lang, 0, [](auto &task) { wolv::io::File output(outputPath, wolv::io::File::Mode::Create); if (!output.isValid()) { diff --git a/plugins/builtin/source/content/tools/file_tool_shredder.cpp b/plugins/builtin/source/content/tools/file_tool_shredder.cpp index c9a49d17b..18173ef84 100644 --- a/plugins/builtin/source/content/tools/file_tool_shredder.cpp +++ b/plugins/builtin/source/content/tools/file_tool_shredder.cpp @@ -48,7 +48,7 @@ namespace hex::plugin::builtin { ImGui::BeginDisabled(selectedFile.empty()); { if (ImGui::Button("hex.builtin.tools.file_tools.shredder.shred"_lang)) { - shredderTask = TaskManager::createTask("hex.builtin.tools.file_tools.shredder.shredding", 0, [](auto &task) { + shredderTask = TaskManager::createTask("hex.builtin.tools.file_tools.shredder.shredding"_lang, 0, [](auto &task) { ON_SCOPE_EXIT { selectedFile.clear(); }; diff --git a/plugins/builtin/source/content/tools/file_tool_splitter.cpp b/plugins/builtin/source/content/tools/file_tool_splitter.cpp index a52961cee..b52f41ae3 100644 --- a/plugins/builtin/source/content/tools/file_tool_splitter.cpp +++ b/plugins/builtin/source/content/tools/file_tool_splitter.cpp @@ -93,7 +93,7 @@ namespace hex::plugin::builtin { ImGuiExt::TextSpinner("hex.builtin.tools.file_tools.splitter.picker.splitting"_lang); } else { if (ImGui::Button("hex.builtin.tools.file_tools.splitter.picker.split"_lang)) { - splitterTask = TaskManager::createTask("hex.builtin.tools.file_tools.splitter.picker.splitting", 0, [](auto &task) { + splitterTask = TaskManager::createTask("hex.builtin.tools.file_tools.splitter.picker.splitting"_lang, 0, [](auto &task) { ON_SCOPE_EXIT { selectedFile.clear(); baseOutputPath.clear(); diff --git a/plugins/builtin/source/content/ui_items.cpp b/plugins/builtin/source/content/ui_items.cpp index e29b58abc..aa147d55c 100644 --- a/plugins/builtin/source/content/ui_items.cpp +++ b/plugins/builtin/source/content/ui_items.cpp @@ -42,7 +42,7 @@ namespace hex::plugin::builtin { // Task exception toast for (const auto &task : TaskManager::getRunningTasks()) { if (task->hadException()) { - ui::ToastError::open(hex::format("hex.builtin.popup.error.task_exception"_lang, Lang(task->getUnlocalizedName()), task->getExceptionMessage())); + ui::ToastError::open(hex::format("hex.builtin.popup.error.task_exception"_lang, task->getName(), task->getExceptionMessage())); task->clearException(); break; } @@ -268,7 +268,7 @@ namespace hex::plugin::builtin { else progressString = hex::format("[ {}/{} ({:.1f}%) ] ", frontTask->getValue(), frontTask->getMaxValue(), std::min(progress, 1.0F) * 100.0F); - ImGuiExt::InfoTooltip(hex::format("{}{}", progressString, Lang(frontTask->getUnlocalizedName())).c_str()); + ImGuiExt::InfoTooltip(hex::format("{}{}", progressString, frontTask->getName()).c_str()); if (ImGui::BeginPopupContextItem("RestTasks", ImGuiPopupFlags_MouseButtonLeft)) { for (const auto &task : tasks) { @@ -276,7 +276,7 @@ namespace hex::plugin::builtin { continue; ImGui::PushID(&task); - ImGuiExt::TextFormatted("{}", Lang(task->getUnlocalizedName())); + ImGuiExt::TextFormatted("{}", task->getName()); ImGui::SameLine(); ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical); ImGui::SameLine(); diff --git a/plugins/builtin/source/content/views/view_bookmarks.cpp b/plugins/builtin/source/content/views/view_bookmarks.cpp index 818a8508b..a3ae11e95 100644 --- a/plugins/builtin/source/content/views/view_bookmarks.cpp +++ b/plugins/builtin/source/content/views/view_bookmarks.cpp @@ -363,7 +363,7 @@ namespace hex::plugin::builtin { // Draw jump to region button if (ImGuiExt::DimmedIconButton(ICON_VS_DEBUG_STEP_BACK, ImGui::GetStyleColorVec4(ImGuiCol_Text))) ImHexApi::HexEditor::setSelection(region); - ImGui::SetItemTooltip("%s", "hex.builtin.view.bookmarks.tooltip.jump_to"_lang.get().c_str()); + ImGui::SetItemTooltip("%s", "hex.builtin.view.bookmarks.tooltip.jump_to"_lang.get()); ImGui::SameLine(0, 1_scaled); @@ -383,7 +383,7 @@ namespace hex::plugin::builtin { } }); } - ImGui::SetItemTooltip("%s", "hex.builtin.view.bookmarks.tooltip.open_in_view"_lang.get().c_str()); + ImGui::SetItemTooltip("%s", "hex.builtin.view.bookmarks.tooltip.open_in_view"_lang.get()); } ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2()); diff --git a/plugins/builtin/source/content/views/view_data_inspector.cpp b/plugins/builtin/source/content/views/view_data_inspector.cpp index 8707aa09a..d7622614e 100644 --- a/plugins/builtin/source/content/views/view_data_inspector.cpp +++ b/plugins/builtin/source/content/views/view_data_inspector.cpp @@ -57,7 +57,7 @@ namespace hex::plugin::builtin { } void ViewDataInspector::updateInspectorRows() { - m_updateTask = TaskManager::createBackgroundTask("Update Inspector", [this](auto &) { + m_updateTask = TaskManager::createBackgroundTask("Update Inspector"_lang, [this](auto &) { this->updateInspectorRowsTask(); }); } diff --git a/plugins/builtin/source/content/views/view_data_processor.cpp b/plugins/builtin/source/content/views/view_data_processor.cpp index afb4bef08..9b60d49c3 100644 --- a/plugins/builtin/source/content/views/view_data_processor.cpp +++ b/plugins/builtin/source/content/views/view_data_processor.cpp @@ -528,7 +528,7 @@ namespace hex::plugin::builtin { // Reset any potential node errors workspace.currNodeError.reset(); - m_evaluationTask = TaskManager::createTask("Evaluating Nodes...", 0, [this, workspace = &workspace](Task& task) { + m_evaluationTask = TaskManager::createTask("Evaluating Nodes..."_lang, 0, [this, workspace = &workspace](Task& task) { task.setInterruptCallback([]{ dp::Node::interrupt(); }); diff --git a/plugins/builtin/source/content/views/view_find.cpp b/plugins/builtin/source/content/views/view_find.cpp index 8abb226ae..042924760 100644 --- a/plugins/builtin/source/content/views/view_find.cpp +++ b/plugins/builtin/source/content/views/view_find.cpp @@ -508,7 +508,7 @@ namespace hex::plugin::builtin { m_occurrenceTree->clear(); EventHighlightingChanged::post(); - m_searchTask = TaskManager::createTask("hex.builtin.view.find.searching", searchRegion.getSize(), [this, settings = m_searchSettings, searchRegion](auto &task) { + m_searchTask = TaskManager::createTask("hex.builtin.view.find.searching"_lang, searchRegion.getSize(), [this, settings = m_searchSettings, searchRegion](auto &task) { auto provider = ImHexApi::Provider::get(); switch (settings.mode) { @@ -924,7 +924,7 @@ namespace hex::plugin::builtin { m_filterTask.interrupt(); if (!m_currFilter->empty()) { - m_filterTask = TaskManager::createTask("Filtering", currOccurrences.size(), [this, provider, &currOccurrences](Task &task) { + m_filterTask = TaskManager::createTask("Filtering"_lang, currOccurrences.size(), [this, provider, &currOccurrences](Task &task) { u64 progress = 0; std::erase_if(currOccurrences, [this, provider, &task, &progress](const auto ®ion) { task.update(progress); diff --git a/plugins/builtin/source/content/views/view_hex_editor.cpp b/plugins/builtin/source/content/views/view_hex_editor.cpp index bdeb22e80..eb81f3cf3 100644 --- a/plugins/builtin/source/content/views/view_hex_editor.cpp +++ b/plugins/builtin/source/content/views/view_hex_editor.cpp @@ -654,7 +654,7 @@ namespace hex::plugin::builtin { return; fs::openFileBrowser(fs::DialogMode::Save, {}, [provider](const auto &path) { - PopupBlockingTask::open(TaskManager::createTask("Saving...", TaskManager::NoProgress, [=](Task &){ + PopupBlockingTask::open(TaskManager::createTask("Saving..."_lang, TaskManager::NoProgress, [=](Task &){ provider->saveAs(path); })); }); @@ -1055,7 +1055,7 @@ namespace hex::plugin::builtin { ui::PopupFileChooser::open(basePaths, paths, std::vector{ {"Thingy Table File", "tbl"} }, false, [this](const auto &path) { - TaskManager::createTask("Loading encoding file", 0, [this, path](auto&) { + TaskManager::createTask("Loading encoding file"_lang, 0, [this, path](auto&) { auto encoding = EncodingFile(EncodingFile::Type::Thingy, path); ImHexApi::Provider::markDirty(); diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index 0bf342f61..58989e660 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -558,7 +558,7 @@ namespace hex::plugin::builtin { auto code = m_textEditor.GetText(); EventPatternEditorChanged::post(code); - TaskManager::createBackgroundTask("Pattern Parsing", [this, code, provider](auto &){ + TaskManager::createBackgroundTask("Pattern Parsing"_lang, [this, code, provider](auto &){ this->parsePattern(code, provider); if (m_runAutomatically) @@ -1157,7 +1157,7 @@ namespace hex::plugin::builtin { patternDrawer->draw(patterns, &runtime, 150_scaled); }; } - ImGui::SetItemTooltip("%s", "hex.builtin.view.pattern_editor.sections.view"_lang.get().c_str()); + ImGui::SetItemTooltip("%s", "hex.builtin.view.pattern_editor.sections.view"_lang.get()); ImGui::SameLine(); @@ -1172,7 +1172,7 @@ namespace hex::plugin::builtin { file.writeVector(runtime.getSection(id)); }); } - ImGui::SetItemTooltip("%s", (const char*)"hex.builtin.view.pattern_editor.sections.export"_lang.get().c_str()); + ImGui::SetItemTooltip("%s", (const char*)"hex.builtin.view.pattern_editor.sections.export"_lang.get()); ImGui::PopID(); } @@ -1330,7 +1330,7 @@ namespace hex::plugin::builtin { if (m_shouldAnalyze) { m_shouldAnalyze = false; - m_analysisTask = TaskManager::createBackgroundTask("Analyzing file content", [this, provider](const Task &task) { + m_analysisTask = TaskManager::createBackgroundTask("Analyzing file content"_lang, [this, provider](const Task &task) { if (!m_autoLoadPatterns) return; @@ -1584,7 +1584,7 @@ namespace hex::plugin::builtin { m_textEditor.SetText(code); m_sourceCode.set(provider, code); - TaskManager::createBackgroundTask("Parse pattern", [this, code, provider](auto&) { this->parsePattern(code, provider); }); + TaskManager::createBackgroundTask("Parse pattern"_lang, [this, code, provider](auto&) { this->parsePattern(code, provider); }); } } @@ -1649,7 +1649,7 @@ namespace hex::plugin::builtin { EventHighlightingChanged::post(); - TaskManager::createTask("hex.builtin.view.pattern_editor.evaluating", TaskManager::NoProgress, [this, code, provider](auto &task) { + TaskManager::createTask("hex.builtin.view.pattern_editor.evaluating"_lang, TaskManager::NoProgress, [this, code, provider](auto &task) { auto lock = std::scoped_lock(ContentRegistry::PatternLanguage::getRuntimeLock()); auto &runtime = ContentRegistry::PatternLanguage::getRuntime(); diff --git a/plugins/builtin/source/content/views/view_store.cpp b/plugins/builtin/source/content/views/view_store.cpp index 9ac24791a..b9b628021 100644 --- a/plugins/builtin/source/content/views/view_store.cpp +++ b/plugins/builtin/source/content/views/view_store.cpp @@ -197,7 +197,7 @@ namespace hex::plugin::builtin { ImGui::SameLine(ImGui::GetWindowWidth() - ImGui::GetCursorPosX() - 25_scaled); ImGui::BeginDisabled(m_updateAllTask.isRunning() || m_updateCount == 0); if (ImGuiExt::IconButton(ICON_VS_CLOUD_DOWNLOAD, ImGui::GetStyleColorVec4(ImGuiCol_Text))) { - m_updateAllTask = TaskManager::createTask("Update All...", m_updateCount, [this](auto &task) { + m_updateAllTask = TaskManager::createTask("Update All..."_lang, m_updateCount, [this](auto &task) { for (auto &category : m_categories) { for (auto &entry : category.entries) { if (entry.hasUpdate) { diff --git a/plugins/builtin/source/content/welcome_screen.cpp b/plugins/builtin/source/content/welcome_screen.cpp index 14087d65c..a3e9b7585 100644 --- a/plugins/builtin/source/content/welcome_screen.cpp +++ b/plugins/builtin/source/content/welcome_screen.cpp @@ -96,7 +96,7 @@ namespace hex::plugin::builtin { } } - TaskManager::createBackgroundTask("Upload Crash report", [path = m_logFilePath, data](auto&){ + TaskManager::createBackgroundTask("Upload Crash report"_lang, [path = m_logFilePath, data](auto&){ HttpRequest request("POST", ImHexApiURL + std::string("/crash_upload")); request.uploadFile(std::vector(data.begin(), data.end()), "file", path.filename()).wait(); }); @@ -667,7 +667,7 @@ namespace hex::plugin::builtin { auto allowNetworking = ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.network_interface", false) && ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.server_contact", 0) != 0; if (!s_infoBannerTexture.isValid() && allowNetworking) { - TaskManager::createBackgroundTask("Load banner", [](auto&) { + TaskManager::createBackgroundTask("Load banner"_lang, [](auto&) { HttpRequest request("GET", ImHexApiURL + hex::format("/info/{}/image", hex::toLower(ImHexApi::System::getOSName()))); diff --git a/plugins/diffing/source/content/views/view_diff.cpp b/plugins/diffing/source/content/views/view_diff.cpp index 903a7e24a..d1da77700 100644 --- a/plugins/diffing/source/content/views/view_diff.cpp +++ b/plugins/diffing/source/content/views/view_diff.cpp @@ -93,7 +93,7 @@ namespace hex::plugin::diffing { void ViewDiff::analyze(prv::Provider *providerA, prv::Provider *providerB) { auto commonSize = std::max(providerA->getActualSize(), providerB->getActualSize()); - m_diffTask = TaskManager::createTask("Diffing...", commonSize, [this, providerA, providerB](Task &) { + m_diffTask = TaskManager::createTask("Diffing..."_lang, commonSize, [this, providerA, providerB](Task &) { auto differences = m_algorithm->analyze(providerA, providerB); auto providers = ImHexApi::Provider::getProviders(); diff --git a/plugins/disassembler/source/content/views/view_disassembler.cpp b/plugins/disassembler/source/content/views/view_disassembler.cpp index fe6b080d3..19904b202 100644 --- a/plugins/disassembler/source/content/views/view_disassembler.cpp +++ b/plugins/disassembler/source/content/views/view_disassembler.cpp @@ -26,7 +26,7 @@ namespace hex::plugin::disasm { void ViewDisassembler::disassemble() { m_disassembly.clear(); - m_disassemblerTask = TaskManager::createTask("hex.disassembler.view.disassembler.disassembling", m_codeRegion.getSize(), [this](auto &task) { + m_disassemblerTask = TaskManager::createTask("hex.disassembler.view.disassembler.disassembling"_lang, m_codeRegion.getSize(), [this](auto &task) { csh capstoneHandle; cs_insn *instructions = nullptr; diff --git a/plugins/script_loader/source/plugin_script_loader.cpp b/plugins/script_loader/source/plugin_script_loader.cpp index cab70ae17..c0c31a648 100644 --- a/plugins/script_loader/source/plugin_script_loader.cpp +++ b/plugins/script_loader/source/plugin_script_loader.cpp @@ -91,7 +91,7 @@ namespace { if (menuJustOpened) { menuJustOpened = false; if (!updaterTask.isRunning()) { - updaterTask = TaskManager::createBackgroundTask("Updating Scripts...", [] (auto&) { + updaterTask = TaskManager::createBackgroundTask("Updating Scripts..."_lang, [] (auto&) { scripts = loadAllScripts(); }); } @@ -109,7 +109,7 @@ namespace { continue; if (ImGui::MenuItem(name.c_str(), loader->getTypeName().c_str())) { - runnerTask = TaskManager::createTask("Running script...", TaskManager::NoProgress, [entryPoint](auto&) { + runnerTask = TaskManager::createTask("Running script..."_lang, TaskManager::NoProgress, [entryPoint](auto&) { entryPoint(); }); } @@ -123,7 +123,7 @@ namespace { return !runnerTask.isRunning(); }); - updaterTask = TaskManager::createBackgroundTask("Updating Scripts...", [] (auto&) { + updaterTask = TaskManager::createBackgroundTask("Updating Scripts..."_lang, [] (auto&) { scripts = loadAllScripts(); }); } diff --git a/plugins/ui/source/ui/hex_editor.cpp b/plugins/ui/source/ui/hex_editor.cpp index a9583913d..498453855 100644 --- a/plugins/ui/source/ui/hex_editor.cpp +++ b/plugins/ui/source/ui/hex_editor.cpp @@ -1081,7 +1081,7 @@ namespace hex::ui { ? hex::format("{}", m_provider->getActualSize()) : hex::toByteString(m_provider->getActualSize()) ); - ImGui::SetItemTooltip("%s", "hex.ui.hex_editor.data_size"_lang.get().c_str()); + ImGui::SetItemTooltip("%s", "hex.ui.hex_editor.data_size"_lang.get()); } } } diff --git a/plugins/visualizers/source/content/pl_visualizers/sound.cpp b/plugins/visualizers/source/content/pl_visualizers/sound.cpp index be4ca10d7..23c373bab 100644 --- a/plugins/visualizers/source/content/pl_visualizers/sound.cpp +++ b/plugins/visualizers/source/content/pl_visualizers/sound.cpp @@ -32,7 +32,7 @@ namespace hex::plugin::visualizers { if (shouldReset) { waveData.clear(); - resetTask = TaskManager::createTask("Visualizing...", TaskManager::NoProgress, [=](Task &) { + resetTask = TaskManager::createTask("Visualizing..."_lang, TaskManager::NoProgress, [=](Task &) { ma_device_stop(&audioDevice); waveData = patternToArray(wavePattern.get()); sampledData = sampleData(waveData, 300_scaled * 4); diff --git a/plugins/windows/source/views/view_tty_console.cpp b/plugins/windows/source/views/view_tty_console.cpp index c8f56f8fe..3995153ba 100644 --- a/plugins/windows/source/views/view_tty_console.cpp +++ b/plugins/windows/source/views/view_tty_console.cpp @@ -299,7 +299,7 @@ namespace hex::plugin::windows { if (m_transmitting) return; - TaskManager::createBackgroundTask("Transmitting data", [&, this](auto&) { + TaskManager::createBackgroundTask("Transmitting data"_lang, [&, this](auto&) { OVERLAPPED overlapped = { }; overlapped.hEvent = ::CreateEvent(nullptr, true, false, nullptr); diff --git a/plugins/yara_rules/source/content/views/view_yara.cpp b/plugins/yara_rules/source/content/views/view_yara.cpp index 2d21ebfdb..996145604 100644 --- a/plugins/yara_rules/source/content/views/view_yara.cpp +++ b/plugins/yara_rules/source/content/views/view_yara.cpp @@ -247,7 +247,7 @@ namespace hex::plugin::yara { if (provider == nullptr) return; - m_matcherTask = TaskManager::createTask("hex.yara_rules.view.yara.matching", 0, [this, provider](auto &task) { + m_matcherTask = TaskManager::createTask("hex.yara_rules.view.yara.matching"_lang, 0, [this, provider](auto &task) { std::vector results; for (const auto &[fileName, filePath] : *m_rulePaths) { YaraRule rule(filePath);