1
0
mirror of synced 2024-09-23 19:18:24 +02:00

fix: Task names not displaying correctly anymore

This commit is contained in:
WerWolv 2024-07-27 14:09:52 +02:00
parent ce26fe1db7
commit d8e1284946
32 changed files with 79 additions and 78 deletions

View File

@ -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<wolv::type::StaticString>
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<wolv::type::StaticString String>
[[nodiscard]] consteval Lang operator""_lang() {
return Lang(Lang::hash(String.value.data()));
return Lang(Lang::hash(String.value.data()), String.value.data());
}

View File

@ -22,7 +22,7 @@ namespace hex {
class Task {
public:
Task() = default;
Task(UnlocalizedString unlocalizedName, u64 maxValue, bool background, std::function<void(Task &)> function);
Task(Lang name, u64 maxValue, bool background, std::function<void(Task &)> 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<u64> m_currValue = 0, m_maxValue = 0;
std::function<void()> m_interruptCallback;
std::function<void(Task &)> 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<void(Task &)> function);
static TaskHolder createTask(Lang name, u64 maxValue, std::function<void(Task &)> 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<void(Task &)> function);
static TaskHolder createBackgroundTask(Lang name, std::function<void(Task &)> 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<void(Task &)> function);
static TaskHolder createTask(Lang name, u64 maxValue, bool background, std::function<void(Task &)> function);
};
}

View File

@ -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);

View File

@ -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);

View File

@ -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();
}
}

View File

@ -63,8 +63,8 @@ namespace hex {
}
Task::Task(UnlocalizedString unlocalizedName, u64 maxValue, bool background, std::function<void(Task &)> 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<void(Task &)> 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<void(Task&)> function) {
TaskHolder TaskManager::createTask(Lang name, u64 maxValue, bool background, std::function<void(Task&)> 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<void(Task &)> function) {
TaskHolder TaskManager::createTask(Lang name, u64 maxValue, std::function<void(Task &)> function) {
log::debug("Creating task {}", name);
return createTask(std::move(name), maxValue, false, std::move(function));
}
TaskHolder TaskManager::createBackgroundTask(std::string name, std::function<void(Task &)> function) {
TaskHolder TaskManager::createBackgroundTask(Lang name, std::function<void(Task &)> function) {
log::debug("Creating background task {}", name);
return createTask(std::move(name), 0, true, std::move(function));
}

View File

@ -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());
}
}

View File

@ -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();

View File

@ -59,7 +59,7 @@ namespace hex::plugin::builtin {
ContentRegistry::Settings::write<std::string>("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;
}

View File

@ -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] {

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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()) {

View File

@ -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();
};

View File

@ -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();

View File

@ -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();

View File

@ -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());

View File

@ -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();
});
}

View File

@ -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();
});

View File

@ -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 &region) {
task.update(progress);

View File

@ -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<hex::fs::ItemFilter>{ {"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();

View File

@ -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();

View File

@ -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) {

View File

@ -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<u8>(data.begin(), data.end()), "file", path.filename()).wait();
});
@ -667,7 +667,7 @@ namespace hex::plugin::builtin {
auto allowNetworking = ContentRegistry::Settings::read<bool>("hex.builtin.setting.general", "hex.builtin.setting.general.network_interface", false)
&& ContentRegistry::Settings::read<int>("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())));

View File

@ -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();

View File

@ -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;

View File

@ -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();
});
}

View File

@ -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());
}
}
}

View File

@ -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<i16>(wavePattern.get());
sampledData = sampleData(waveData, 300_scaled * 4);

View File

@ -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);

View File

@ -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<YaraRule::Result> results;
for (const auto &[fileName, filePath] : *m_rulePaths) {
YaraRule rule(filePath);