api: Moved menu item adding to a new registry-type API
This commit is contained in:
parent
6c6fe8ad5c
commit
714d421334
@ -232,6 +232,11 @@ namespace hex {
|
||||
DrawCallback callback;
|
||||
};
|
||||
|
||||
struct MenuItem {
|
||||
std::string unlocalizedName;
|
||||
DrawCallback callback;
|
||||
};
|
||||
|
||||
struct SidebarItem {
|
||||
std::string icon;
|
||||
DrawCallback callback;
|
||||
@ -242,6 +247,8 @@ namespace hex {
|
||||
u32 getDockSpaceId();
|
||||
|
||||
void registerMainMenuItem(const std::string &unlocalizedName, const impl::DrawCallback &function = []{});
|
||||
void addMenuItem(const std::string &unlocalizedMainMenuName, u32 priority, const impl::DrawCallback &function);
|
||||
|
||||
void addWelcomeScreenEntry(const impl::DrawCallback &function);
|
||||
void addFooterItem(const impl::DrawCallback &function);
|
||||
void addToolbarItem(const impl::DrawCallback &function);
|
||||
@ -250,6 +257,8 @@ namespace hex {
|
||||
void addLayout(const std::string &unlocalizedName, const impl::LayoutFunction &function);
|
||||
|
||||
std::vector<impl::MainMenuItem>& getMainMenuItems();
|
||||
std::multimap<u32, impl::MenuItem>& getMenuItems();
|
||||
|
||||
std::vector<impl::DrawCallback>& getWelcomeScreenEntries();
|
||||
std::vector<impl::DrawCallback>& getFooterItems();
|
||||
std::vector<impl::DrawCallback>& getToolbarItems();
|
||||
|
@ -78,6 +78,7 @@ namespace hex {
|
||||
static ImGuiID dockSpaceId;
|
||||
|
||||
static std::vector<ContentRegistry::Interface::impl::MainMenuItem> mainMenuItems;
|
||||
static std::multimap<u32, ContentRegistry::Interface::impl::MenuItem> menuItems;
|
||||
static std::vector<ContentRegistry::Interface::impl::DrawCallback> welcomeScreenEntries;
|
||||
static std::vector<ContentRegistry::Interface::impl::DrawCallback> footerItems;
|
||||
static std::vector<ContentRegistry::Interface::impl::DrawCallback> toolbarItems;
|
||||
|
@ -32,7 +32,6 @@ namespace hex {
|
||||
|
||||
virtual void drawContent() = 0;
|
||||
virtual void drawAlwaysVisible() { }
|
||||
virtual void drawMenu();
|
||||
virtual bool isAvailable() const;
|
||||
virtual bool shouldProcess() const { return this->isAvailable() && this->getWindowOpenState(); }
|
||||
|
||||
|
@ -300,6 +300,12 @@ namespace hex {
|
||||
getMainMenuItems().push_back({ unlocalizedName, function });
|
||||
}
|
||||
|
||||
void ContentRegistry::Interface::addMenuItem(const std::string &unlocalizedMainMenuName, u32 priority, const impl::DrawCallback &function) {
|
||||
log::info("Added new menu item to menu {} with priority {}", unlocalizedMainMenuName, priority);
|
||||
|
||||
getMenuItems().insert({ priority, { unlocalizedMainMenuName, function }});
|
||||
}
|
||||
|
||||
void ContentRegistry::Interface::addWelcomeScreenEntry(const ContentRegistry::Interface::impl::DrawCallback &function) {
|
||||
getWelcomeScreenEntries().push_back(function);
|
||||
}
|
||||
@ -323,9 +329,12 @@ namespace hex {
|
||||
}
|
||||
|
||||
|
||||
std::vector<ContentRegistry::Interface::impl::MainMenuItem> &ContentRegistry::Interface::getMainMenuItems() {
|
||||
std::vector<ContentRegistry::Interface::impl::MainMenuItem>& ContentRegistry::Interface::getMainMenuItems() {
|
||||
return SharedData::mainMenuItems;
|
||||
}
|
||||
std::multimap<u32, ContentRegistry::Interface::impl::MenuItem>& ContentRegistry::Interface::getMenuItems() {
|
||||
return SharedData::menuItems;
|
||||
}
|
||||
|
||||
std::vector<ContentRegistry::Interface::impl::DrawCallback>& ContentRegistry::Interface::getWelcomeScreenEntries() {
|
||||
return SharedData::welcomeScreenEntries;
|
||||
|
@ -28,6 +28,8 @@ namespace hex {
|
||||
ImGuiID SharedData::dockSpaceId;
|
||||
|
||||
std::vector<ContentRegistry::Interface::impl::MainMenuItem> SharedData::mainMenuItems;
|
||||
std::multimap<u32, ContentRegistry::Interface::impl::MenuItem> SharedData::menuItems;
|
||||
|
||||
std::vector<ContentRegistry::Interface::impl::DrawCallback> SharedData::welcomeScreenEntries;
|
||||
std::vector<ContentRegistry::Interface::impl::DrawCallback> SharedData::footerItems;
|
||||
std::vector<ContentRegistry::Interface::impl::SidebarItem> SharedData::sidebarItems;
|
||||
|
@ -12,8 +12,6 @@ namespace hex {
|
||||
|
||||
View::View(std::string unlocalizedName) : m_unlocalizedViewName(unlocalizedName) { }
|
||||
|
||||
void View::drawMenu() { }
|
||||
|
||||
bool View::isAvailable() const {
|
||||
return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->isAvailable();
|
||||
}
|
||||
|
@ -197,6 +197,8 @@ namespace hex::init {
|
||||
SharedData::welcomeScreenEntries.clear();
|
||||
SharedData::footerItems.clear();
|
||||
SharedData::toolbarItems.clear();
|
||||
SharedData::mainMenuItems.clear();
|
||||
SharedData::menuItems.clear();
|
||||
|
||||
SharedData::globalShortcuts.clear();
|
||||
SharedData::runningTasks.clear();
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <csignal>
|
||||
#include <iostream>
|
||||
#include <numeric>
|
||||
#include <set>
|
||||
#include <thread>
|
||||
#include <assert.h>
|
||||
|
||||
@ -437,8 +438,16 @@ namespace hex {
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &[name, view] : ContentRegistry::Views::getEntries()) {
|
||||
view->drawMenu();
|
||||
std::set<std::string> encounteredMenus;
|
||||
for (auto &[priority, menuItem] : ContentRegistry::Interface::getMenuItems()) {
|
||||
if (ImGui::BeginMenu(LangEntry(menuItem.unlocalizedName))) {
|
||||
auto [iter, inserted] = encounteredMenus.insert(menuItem.unlocalizedName);
|
||||
if (!inserted)
|
||||
ImGui::Separator();
|
||||
|
||||
menuItem.callback();
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
this->drawTitleBar();
|
||||
|
@ -15,7 +15,6 @@ namespace hex::plugin::builtin {
|
||||
~ViewBookmarks() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
};
|
||||
|
||||
}
|
@ -17,7 +17,7 @@ namespace hex::plugin::builtin {
|
||||
~ViewCommandPalette() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
|
||||
[[nodiscard]] bool isAvailable() const override { return true; }
|
||||
[[nodiscard]] bool shouldProcess() const override { return true; }
|
||||
|
||||
|
@ -26,7 +26,6 @@ namespace hex::plugin::builtin {
|
||||
~ViewConstants() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
|
||||
private:
|
||||
void reloadConstants();
|
||||
|
@ -18,7 +18,6 @@ namespace hex::plugin::builtin {
|
||||
~ViewDataInspector() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
|
||||
private:
|
||||
struct InspectorCacheEntry {
|
||||
|
@ -20,7 +20,6 @@ namespace hex::plugin::builtin {
|
||||
~ViewDataProcessor() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
|
||||
private:
|
||||
std::list<dp::Node*> m_endNodes;
|
||||
|
@ -19,7 +19,6 @@ namespace hex::plugin::builtin {
|
||||
~ViewDiff() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
|
||||
private:
|
||||
void drawDiffLine(const std::array<int, 2> &providerIds, u64 row) const;
|
||||
|
@ -27,7 +27,6 @@ namespace hex::plugin::builtin {
|
||||
~ViewDisassembler() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
|
||||
private:
|
||||
bool m_disassembling = false;
|
||||
|
@ -16,7 +16,6 @@ namespace hex::plugin::builtin {
|
||||
~ViewHashes() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
|
||||
private:
|
||||
enum class HashFunctions { Crc8, Crc16, Crc32, Md5, Sha1, Sha224, Sha256, Sha384, Sha512 };
|
||||
|
@ -19,9 +19,8 @@ namespace hex::plugin::builtin {
|
||||
~ViewHelp() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
bool isAvailable() const override { return true; }
|
||||
|
||||
bool isAvailable() const override { return true; }
|
||||
bool hasViewMenuItemEntry() const override { return false; }
|
||||
|
||||
ImVec2 getMinSize() const override {
|
||||
|
@ -25,7 +25,6 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void drawContent() override;
|
||||
void drawAlwaysVisible() override;
|
||||
void drawMenu() override;
|
||||
|
||||
private:
|
||||
MemoryEditor m_memoryEditor;
|
||||
@ -68,6 +67,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void registerEvents();
|
||||
void registerShortcuts();
|
||||
void registerMenuItems();
|
||||
};
|
||||
|
||||
}
|
@ -18,7 +18,6 @@ namespace hex::plugin::builtin {
|
||||
~ViewInformation() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
|
||||
private:
|
||||
bool m_dataValid = false;
|
||||
|
@ -17,7 +17,6 @@ namespace hex::plugin::builtin {
|
||||
~ViewPatches() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
|
||||
private:
|
||||
u64 m_selectedPatch;
|
||||
|
@ -25,7 +25,6 @@ namespace hex::plugin::builtin {
|
||||
~ViewPatternData() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
|
||||
private:
|
||||
std::vector<pl::PatternData*> m_sortedPatternData;
|
||||
|
@ -20,7 +20,6 @@ namespace hex::plugin::builtin {
|
||||
ViewPatternEditor();
|
||||
~ViewPatternEditor() override;
|
||||
|
||||
void drawMenu() override;
|
||||
void drawAlwaysVisible() override;
|
||||
void drawContent() override;
|
||||
|
||||
|
@ -13,9 +13,8 @@ namespace hex::plugin::builtin {
|
||||
~ViewSettings() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
[[nodiscard]] bool isAvailable() const override { return true; }
|
||||
|
||||
[[nodiscard]] bool isAvailable() const override { return true; }
|
||||
[[nodiscard]] bool hasViewMenuItemEntry() const override { return false; }
|
||||
|
||||
[[nodiscard]] ImVec2 getMinSize() const override { return { 500, 300 }; }
|
||||
|
@ -33,7 +33,6 @@ namespace hex::plugin::builtin {
|
||||
~ViewStore() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
|
||||
[[nodiscard]] bool isAvailable() const override { return true; }
|
||||
[[nodiscard]] bool hasViewMenuItemEntry() const override { return false; }
|
||||
|
@ -20,7 +20,6 @@ namespace hex::plugin::builtin {
|
||||
~ViewStrings() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
|
||||
private:
|
||||
bool m_searching = false;
|
||||
|
@ -18,7 +18,6 @@ namespace hex::plugin::builtin {
|
||||
~ViewTools() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
|
||||
};
|
||||
|
||||
|
@ -13,7 +13,6 @@ namespace hex::plugin::builtin {
|
||||
~ViewYara() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
|
||||
private:
|
||||
struct YaraMatch {
|
||||
|
@ -183,8 +183,4 @@ namespace hex::plugin::builtin {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ViewBookmarks::drawMenu() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -74,10 +74,6 @@ namespace hex::plugin::builtin {
|
||||
|
||||
}
|
||||
|
||||
void ViewCommandPalette::drawMenu() {
|
||||
|
||||
}
|
||||
|
||||
std::vector<ViewCommandPalette::CommandResult> ViewCommandPalette::getCommandResults(const std::string &input) {
|
||||
constexpr auto MatchCommand = [](const std::string &currCommand, const std::string &commandToMatch) -> std::pair<MatchType, std::string_view> {
|
||||
if (currCommand.empty()) {
|
||||
|
@ -153,8 +153,4 @@ namespace hex::plugin::builtin {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ViewConstants::drawMenu() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -120,8 +120,4 @@ namespace hex::plugin::builtin {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ViewDataInspector::drawMenu() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -369,10 +369,6 @@ namespace hex::plugin::builtin {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ViewDataProcessor::drawMenu() {
|
||||
|
||||
}
|
||||
|
||||
std::string ViewDataProcessor::saveNodes() {
|
||||
using json = nlohmann::json;
|
||||
json output;
|
||||
|
@ -229,8 +229,4 @@ namespace hex::plugin::builtin {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ViewDiff::drawMenu() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -317,8 +317,4 @@ namespace hex::plugin::builtin {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ViewDisassembler::drawMenu() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -300,8 +300,4 @@ namespace hex::plugin::builtin {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ViewHashes::drawMenu() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,19 @@
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
ViewHelp::ViewHelp() : View("hex.builtin.view.help.about.name") {
|
||||
|
||||
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.help", 1000, [&, this] {
|
||||
if (ImGui::MenuItem("hex.builtin.view.help.about.name"_lang, "")) {
|
||||
View::doLater([] { ImGui::OpenPopup(View::toWindowName("hex.builtin.view.help.about.name").c_str()); });
|
||||
this->m_aboutWindowOpen = true;
|
||||
this->getWindowOpenState() = true;
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.help.documentation"_lang, "")) {
|
||||
hex::openWebpage("https://imhex.werwolv.net/docs");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
ViewHelp::~ViewHelp() {
|
||||
@ -171,18 +184,4 @@ namespace hex::plugin::builtin {
|
||||
this->drawAboutPopup();
|
||||
}
|
||||
|
||||
void ViewHelp::drawMenu() {
|
||||
if (ImGui::BeginMenu("hex.builtin.menu.help"_lang)) {
|
||||
if (ImGui::MenuItem("hex.builtin.view.help.about.name"_lang, "")) {
|
||||
View::doLater([] { ImGui::OpenPopup(View::toWindowName("hex.builtin.view.help.about.name").c_str()); });
|
||||
this->m_aboutWindowOpen = true;
|
||||
this->getWindowOpenState() = true;
|
||||
}
|
||||
if (ImGui::MenuItem("hex.builtin.view.help.documentation"_lang, "")) {
|
||||
hex::openWebpage("https://imhex.werwolv.net/docs");
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -156,6 +156,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
registerEvents();
|
||||
registerShortcuts();
|
||||
registerMenuItems();
|
||||
}
|
||||
|
||||
ViewHexEditor::~ViewHexEditor() {
|
||||
@ -359,275 +360,6 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
}
|
||||
|
||||
void ViewHexEditor::drawMenu() {
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
bool providerValid = ImHexApi::Provider::isValid();
|
||||
|
||||
if (ImGui::BeginMenu("hex.builtin.menu.file"_lang)) {
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.open_file"_lang, "CTRL + O")) {
|
||||
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, { }, [](const auto &path) {
|
||||
EventManager::post<RequestOpenFile>(path);
|
||||
});
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("hex.builtin.view.hexeditor.menu.file.open_recent"_lang, !SharedData::recentFilePaths.empty())) {
|
||||
for (auto &path : SharedData::recentFilePaths) {
|
||||
if (ImGui::MenuItem(fs::path(path).filename().string().c_str())) {
|
||||
EventManager::post<RequestOpenFile>(path);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.clear_recent"_lang)) {
|
||||
SharedData::recentFilePaths.clear();
|
||||
ContentRegistry::Settings::write(
|
||||
"hex.builtin.setting.imhex",
|
||||
"hex.builtin.setting.imhex.recent_files",
|
||||
std::vector<std::string>{});
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("hex.builtin.view.hexeditor.menu.file.open_other"_lang)) {
|
||||
|
||||
for (const auto &unlocalizedProviderName : ContentRegistry::Provider::getEntries()) {
|
||||
if (ImGui::MenuItem(LangEntry(unlocalizedProviderName))) {
|
||||
EventManager::post<RequestCreateProvider>(unlocalizedProviderName, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.save"_lang, "CTRL + S", false, providerValid && provider->isWritable())) {
|
||||
save();
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.save_as"_lang, "CTRL + SHIFT + S", false, providerValid && provider->isWritable())) {
|
||||
saveAs();
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.close"_lang, "", false, providerValid)) {
|
||||
EventManager::post<EventFileUnloaded>();
|
||||
ImHexApi::Provider::remove(ImHexApi::Provider::get());
|
||||
providerValid = false;
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.quit"_lang, "", false)) {
|
||||
ImHexApi::Common::closeImHex();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.open_project"_lang, "")) {
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.menu.file.open_project"_lang, DialogMode::Open, { { "Project File", "hexproj" } }, [](const auto &path) {
|
||||
ProjectFile::load(path);
|
||||
});
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.save_project"_lang, "", false, providerValid && provider->isWritable())) {
|
||||
if (ProjectFile::getProjectFilePath() == "") {
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.save_project"_lang, DialogMode::Save, { { "Project File", "hexproj" } }, [](const auto &path) {
|
||||
if (path.extension() == ".hexproj") {
|
||||
ProjectFile::store(path);
|
||||
}
|
||||
else {
|
||||
ProjectFile::store(path.string() + ".hexproj");
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
ProjectFile::store();
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.load_encoding_file"_lang)) {
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.load_enconding_file"_lang, DialogMode::Open, { { "Thingy Table File", "tbl" } }, [this](const auto &path) {
|
||||
this->m_currEncodingFile = EncodingFile(EncodingFile::Type::Thingy, path);
|
||||
});
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::BeginMenu("hex.builtin.view.hexeditor.menu.file.import"_lang)) {
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.import.base64"_lang)) {
|
||||
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.menu.file.import.base64"_lang, DialogMode::Open, { }, [this](const auto &path) {
|
||||
File file(path, File::Mode::Read);
|
||||
if (!file.isValid()) {
|
||||
View::showErrorPopup("hex.builtin.view.hexeditor.error.open"_lang);
|
||||
return;
|
||||
}
|
||||
|
||||
auto base64 = file.readBytes();
|
||||
|
||||
if (!base64.empty()) {
|
||||
this->m_dataToSave = crypt::decode64(base64);
|
||||
|
||||
if (this->m_dataToSave.empty())
|
||||
View::showErrorPopup("hex.builtin.view.hexeditor.base64.import_error"_lang);
|
||||
else
|
||||
ImGui::OpenPopup("hex.builtin.view.hexeditor.save_data"_lang);
|
||||
this->getWindowOpenState() = true;
|
||||
} else View::showErrorPopup("hex.builtin.view.hexeditor.file_open_error"_lang);
|
||||
});
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.import.ips"_lang, nullptr, false, !this->m_processingImportExport)) {
|
||||
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, { }, [this](const auto &path) {
|
||||
this->m_processingImportExport = true;
|
||||
std::thread([this, path] {
|
||||
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.hexeditor.processing", 0);
|
||||
|
||||
auto patchData = File(path, File::Mode::Read).readBytes();
|
||||
auto patch = hex::loadIPSPatch(patchData);
|
||||
|
||||
task.setMaxValue(patch.size());
|
||||
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
|
||||
u64 progress = 0;
|
||||
for (auto &[address, value] : patch) {
|
||||
provider->addPatch(address, &value, 1);
|
||||
progress++;
|
||||
task.update(progress);
|
||||
}
|
||||
|
||||
provider->createUndoPoint();
|
||||
this->m_processingImportExport = false;
|
||||
}).detach();
|
||||
|
||||
this->getWindowOpenState() = true;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.import.ips32"_lang, nullptr, false, !this->m_processingImportExport)) {
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, { }, [this](const auto &path) {
|
||||
this->m_processingImportExport = true;
|
||||
std::thread([this, path] {
|
||||
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.hexeditor.processing", 0);
|
||||
|
||||
auto patchData = File(path, File::Mode::Read).readBytes();
|
||||
auto patch = hex::loadIPS32Patch(patchData);
|
||||
|
||||
task.setMaxValue(patch.size());
|
||||
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
|
||||
u64 progress = 0;
|
||||
for (auto &[address, value] : patch) {
|
||||
provider->addPatch(address, &value, 1);
|
||||
progress++;
|
||||
task.update(progress);
|
||||
}
|
||||
|
||||
provider->createUndoPoint();
|
||||
this->m_processingImportExport = false;
|
||||
}).detach();
|
||||
|
||||
this->getWindowOpenState() = true;
|
||||
});
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.import.script"_lang)) {
|
||||
this->m_loaderScriptFilePath.clear();
|
||||
this->m_loaderScriptScriptPath.clear();
|
||||
View::doLater([]{ ImGui::OpenPopup("hex.builtin.view.hexeditor.script.title"_lang); });
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("hex.builtin.view.hexeditor.menu.file.export"_lang, providerValid && provider->isWritable())) {
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.export.ips"_lang, nullptr, false, !this->m_processingImportExport)) {
|
||||
Patches patches = provider->getPatches();
|
||||
if (!patches.contains(0x00454F45) && patches.contains(0x00454F46)) {
|
||||
u8 value = 0;
|
||||
provider->read(0x00454F45, &value, sizeof(u8));
|
||||
patches[0x00454F45] = value;
|
||||
}
|
||||
|
||||
this->m_processingImportExport = true;
|
||||
std::thread([this, patches]{
|
||||
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.hexeditor.processing", 0);
|
||||
|
||||
this->m_dataToSave = generateIPSPatch(patches);
|
||||
this->m_processingImportExport = false;
|
||||
|
||||
View::doLater([this]{
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.menu.file.export.title"_lang, DialogMode::Save, { }, [this](const auto &path) {
|
||||
auto file = File(path, File::Mode::Create);
|
||||
if (!file.isValid()) {
|
||||
View::showErrorPopup("hex.builtin.view.hexeditor.error.create"_lang);
|
||||
return;
|
||||
}
|
||||
|
||||
file.write(this->m_dataToSave);
|
||||
});
|
||||
});
|
||||
}).detach();
|
||||
}
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.export.ips32"_lang, nullptr, false, !this->m_processingImportExport)) {
|
||||
Patches patches = provider->getPatches();
|
||||
if (!patches.contains(0x00454F45) && patches.contains(0x45454F46)) {
|
||||
u8 value = 0;
|
||||
provider->read(0x45454F45, &value, sizeof(u8));
|
||||
patches[0x45454F45] = value;
|
||||
}
|
||||
|
||||
this->m_processingImportExport = true;
|
||||
std::thread([this, patches]{
|
||||
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.hexeditor.processing", 0);
|
||||
|
||||
this->m_dataToSave = generateIPS32Patch(patches);
|
||||
this->m_processingImportExport = false;
|
||||
|
||||
View::doLater([this]{
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.menu.file.export.title"_lang, DialogMode::Save, { }, [this](const auto &path) {
|
||||
auto file = File(path, File::Mode::Create);
|
||||
if (!file.isValid()) {
|
||||
View::showErrorPopup("hex.builtin.view.hexeditor.error.create"_lang);
|
||||
return;
|
||||
}
|
||||
|
||||
file.write(this->m_dataToSave);
|
||||
});
|
||||
});
|
||||
}).detach();
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.search"_lang, "CTRL + F")) {
|
||||
this->getWindowOpenState() = true;
|
||||
ImGui::OpenPopupInWindow(View::toWindowName("hex.builtin.view.hexeditor.name").c_str(), "hex.builtin.view.hexeditor.menu.file.search"_lang);
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.goto"_lang, "CTRL + G")) {
|
||||
this->getWindowOpenState() = true;
|
||||
ImGui::OpenPopupInWindow(View::toWindowName("hex.builtin.view.hexeditor.name").c_str(), "hex.builtin.view.hexeditor.menu.file.goto"_lang);
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("hex.builtin.menu.edit"_lang)) {
|
||||
this->drawEditPopup();
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewHexEditor::openFile(const fs::path &path) {
|
||||
hex::prv::Provider *provider = nullptr;
|
||||
EventManager::post<RequestCreateProvider>("hex.builtin.provider.file", &provider);
|
||||
@ -1225,4 +957,288 @@ namespace hex::plugin::builtin {
|
||||
|
||||
}
|
||||
|
||||
void ViewHexEditor::registerMenuItems() {
|
||||
|
||||
/* Basic operations */
|
||||
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.file", 1000, [&]{
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
bool providerValid = ImHexApi::Provider::isValid();
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.open_file"_lang, "CTRL + O")) {
|
||||
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, { }, [](const auto &path) {
|
||||
EventManager::post<RequestOpenFile>(path);
|
||||
});
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("hex.builtin.view.hexeditor.menu.file.open_recent"_lang, !SharedData::recentFilePaths.empty())) {
|
||||
for (auto &path : SharedData::recentFilePaths) {
|
||||
if (ImGui::MenuItem(fs::path(path).filename().string().c_str())) {
|
||||
EventManager::post<RequestOpenFile>(path);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.clear_recent"_lang)) {
|
||||
SharedData::recentFilePaths.clear();
|
||||
ContentRegistry::Settings::write(
|
||||
"hex.builtin.setting.imhex",
|
||||
"hex.builtin.setting.imhex.recent_files",
|
||||
std::vector<std::string>{});
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("hex.builtin.view.hexeditor.menu.file.open_other"_lang)) {
|
||||
|
||||
for (const auto &unlocalizedProviderName : ContentRegistry::Provider::getEntries()) {
|
||||
if (ImGui::MenuItem(LangEntry(unlocalizedProviderName))) {
|
||||
EventManager::post<RequestCreateProvider>(unlocalizedProviderName, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.save"_lang, "CTRL + S", false, providerValid && provider->isWritable())) {
|
||||
save();
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.save_as"_lang, "CTRL + SHIFT + S", false, providerValid && provider->isWritable())) {
|
||||
saveAs();
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.close"_lang, "", false, providerValid)) {
|
||||
EventManager::post<EventFileUnloaded>();
|
||||
ImHexApi::Provider::remove(ImHexApi::Provider::get());
|
||||
providerValid = false;
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.quit"_lang, "", false)) {
|
||||
ImHexApi::Common::closeImHex();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/* Metadata save/load */
|
||||
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.file", 1100, [&, this] {
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
bool providerValid = ImHexApi::Provider::isValid();
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.open_project"_lang, "")) {
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.menu.file.open_project"_lang, DialogMode::Open, { { "Project File", "hexproj" } }, [](const auto &path) {
|
||||
ProjectFile::load(path);
|
||||
});
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.save_project"_lang, "", false, providerValid && provider->isWritable())) {
|
||||
if (ProjectFile::getProjectFilePath() == "") {
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.save_project"_lang, DialogMode::Save, { { "Project File", "hexproj" } }, [](const auto &path) {
|
||||
if (path.extension() == ".hexproj") {
|
||||
ProjectFile::store(path);
|
||||
}
|
||||
else {
|
||||
ProjectFile::store(path.string() + ".hexproj");
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
ProjectFile::store();
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.load_encoding_file"_lang)) {
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.load_enconding_file"_lang, DialogMode::Open, { { "Thingy Table File", "tbl" } }, [this](const auto &path) {
|
||||
this->m_currEncodingFile = EncodingFile(EncodingFile::Type::Thingy, path);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/* Import / Export */
|
||||
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.file", 1200, [&, this] {
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
bool providerValid = ImHexApi::Provider::isValid();
|
||||
|
||||
/* Import */
|
||||
if (ImGui::BeginMenu("hex.builtin.view.hexeditor.menu.file.import"_lang)) {
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.import.base64"_lang)) {
|
||||
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.menu.file.import.base64"_lang, DialogMode::Open, { }, [this](const auto &path) {
|
||||
File file(path, File::Mode::Read);
|
||||
if (!file.isValid()) {
|
||||
View::showErrorPopup("hex.builtin.view.hexeditor.error.open"_lang);
|
||||
return;
|
||||
}
|
||||
|
||||
auto base64 = file.readBytes();
|
||||
|
||||
if (!base64.empty()) {
|
||||
this->m_dataToSave = crypt::decode64(base64);
|
||||
|
||||
if (this->m_dataToSave.empty())
|
||||
View::showErrorPopup("hex.builtin.view.hexeditor.base64.import_error"_lang);
|
||||
else
|
||||
ImGui::OpenPopup("hex.builtin.view.hexeditor.save_data"_lang);
|
||||
this->getWindowOpenState() = true;
|
||||
} else View::showErrorPopup("hex.builtin.view.hexeditor.file_open_error"_lang);
|
||||
});
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.import.ips"_lang, nullptr, false, !this->m_processingImportExport)) {
|
||||
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, { }, [this](const auto &path) {
|
||||
this->m_processingImportExport = true;
|
||||
std::thread([this, path] {
|
||||
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.hexeditor.processing", 0);
|
||||
|
||||
auto patchData = File(path, File::Mode::Read).readBytes();
|
||||
auto patch = hex::loadIPSPatch(patchData);
|
||||
|
||||
task.setMaxValue(patch.size());
|
||||
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
|
||||
u64 progress = 0;
|
||||
for (auto &[address, value] : patch) {
|
||||
provider->addPatch(address, &value, 1);
|
||||
progress++;
|
||||
task.update(progress);
|
||||
}
|
||||
|
||||
provider->createUndoPoint();
|
||||
this->m_processingImportExport = false;
|
||||
}).detach();
|
||||
|
||||
this->getWindowOpenState() = true;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.import.ips32"_lang, nullptr, false, !this->m_processingImportExport)) {
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, { }, [this](const auto &path) {
|
||||
this->m_processingImportExport = true;
|
||||
std::thread([this, path] {
|
||||
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.hexeditor.processing", 0);
|
||||
|
||||
auto patchData = File(path, File::Mode::Read).readBytes();
|
||||
auto patch = hex::loadIPS32Patch(patchData);
|
||||
|
||||
task.setMaxValue(patch.size());
|
||||
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
|
||||
u64 progress = 0;
|
||||
for (auto &[address, value] : patch) {
|
||||
provider->addPatch(address, &value, 1);
|
||||
progress++;
|
||||
task.update(progress);
|
||||
}
|
||||
|
||||
provider->createUndoPoint();
|
||||
this->m_processingImportExport = false;
|
||||
}).detach();
|
||||
|
||||
this->getWindowOpenState() = true;
|
||||
});
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.import.script"_lang)) {
|
||||
this->m_loaderScriptFilePath.clear();
|
||||
this->m_loaderScriptScriptPath.clear();
|
||||
View::doLater([]{ ImGui::OpenPopup("hex.builtin.view.hexeditor.script.title"_lang); });
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
|
||||
/* Export */
|
||||
if (ImGui::BeginMenu("hex.builtin.view.hexeditor.menu.file.export"_lang, providerValid && provider->isWritable())) {
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.export.ips"_lang, nullptr, false, !this->m_processingImportExport)) {
|
||||
Patches patches = provider->getPatches();
|
||||
if (!patches.contains(0x00454F45) && patches.contains(0x00454F46)) {
|
||||
u8 value = 0;
|
||||
provider->read(0x00454F45, &value, sizeof(u8));
|
||||
patches[0x00454F45] = value;
|
||||
}
|
||||
|
||||
this->m_processingImportExport = true;
|
||||
std::thread([this, patches]{
|
||||
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.hexeditor.processing", 0);
|
||||
|
||||
this->m_dataToSave = generateIPSPatch(patches);
|
||||
this->m_processingImportExport = false;
|
||||
|
||||
View::doLater([this]{
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.menu.file.export.title"_lang, DialogMode::Save, { }, [this](const auto &path) {
|
||||
auto file = File(path, File::Mode::Create);
|
||||
if (!file.isValid()) {
|
||||
View::showErrorPopup("hex.builtin.view.hexeditor.error.create"_lang);
|
||||
return;
|
||||
}
|
||||
|
||||
file.write(this->m_dataToSave);
|
||||
});
|
||||
});
|
||||
}).detach();
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.export.ips32"_lang, nullptr, false, !this->m_processingImportExport)) {
|
||||
Patches patches = provider->getPatches();
|
||||
if (!patches.contains(0x00454F45) && patches.contains(0x45454F46)) {
|
||||
u8 value = 0;
|
||||
provider->read(0x45454F45, &value, sizeof(u8));
|
||||
patches[0x45454F45] = value;
|
||||
}
|
||||
|
||||
this->m_processingImportExport = true;
|
||||
std::thread([this, patches]{
|
||||
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.hexeditor.processing", 0);
|
||||
|
||||
this->m_dataToSave = generateIPS32Patch(patches);
|
||||
this->m_processingImportExport = false;
|
||||
|
||||
View::doLater([this]{
|
||||
hex::openFileBrowser("hex.builtin.view.hexeditor.menu.file.export.title"_lang, DialogMode::Save, { }, [this](const auto &path) {
|
||||
auto file = File(path, File::Mode::Create);
|
||||
if (!file.isValid()) {
|
||||
View::showErrorPopup("hex.builtin.view.hexeditor.error.create"_lang);
|
||||
return;
|
||||
}
|
||||
|
||||
file.write(this->m_dataToSave);
|
||||
});
|
||||
});
|
||||
}).detach();
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/* Search / Goto */
|
||||
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.file", 1300, [&, this] {
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.search"_lang, "CTRL + F")) {
|
||||
this->getWindowOpenState() = true;
|
||||
ImGui::OpenPopupInWindow(View::toWindowName("hex.builtin.view.hexeditor.name").c_str(), "hex.builtin.view.hexeditor.menu.file.search"_lang);
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.goto"_lang, "CTRL + G")) {
|
||||
this->getWindowOpenState() = true;
|
||||
ImGui::OpenPopupInWindow(View::toWindowName("hex.builtin.view.hexeditor.name").c_str(), "hex.builtin.view.hexeditor.menu.file.goto"_lang);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/* Edit menu */
|
||||
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.edit", 1000, [&, this] {
|
||||
this->drawEditPopup();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -233,8 +233,4 @@ namespace hex::plugin::builtin {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ViewInformation::drawMenu() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -98,8 +98,4 @@ namespace hex::plugin::builtin {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ViewPatches::drawMenu() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -69,8 +69,4 @@ namespace hex::plugin::builtin {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ViewPatternData::drawMenu() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -194,25 +194,8 @@ namespace hex::plugin::builtin {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ViewPatternEditor::~ViewPatternEditor() {
|
||||
delete this->m_evaluatorRuntime;
|
||||
delete this->m_parserRuntime;
|
||||
|
||||
EventManager::unsubscribe<EventProjectFileStore>(this);
|
||||
EventManager::unsubscribe<EventProjectFileLoad>(this);
|
||||
EventManager::unsubscribe<RequestSetPatternLanguageCode>(this);
|
||||
EventManager::unsubscribe<EventFileLoaded>(this);
|
||||
EventManager::unsubscribe<RequestChangeTheme>(this);
|
||||
EventManager::unsubscribe<EventFileUnloaded>(this);
|
||||
}
|
||||
|
||||
void ViewPatternEditor::drawMenu() {
|
||||
if (ImGui::BeginMenu("hex.builtin.menu.file"_lang)) {
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.file", 2000, [&, this] {
|
||||
if (ImGui::MenuItem("hex.builtin.view.pattern_editor.menu.file.load_pattern"_lang)) {
|
||||
|
||||
this->m_selectedPatternFile = 0;
|
||||
@ -238,9 +221,19 @@ namespace hex::plugin::builtin {
|
||||
file.write(this->m_textEditor.GetText());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ViewPatternEditor::~ViewPatternEditor() {
|
||||
delete this->m_evaluatorRuntime;
|
||||
delete this->m_parserRuntime;
|
||||
|
||||
EventManager::unsubscribe<EventProjectFileStore>(this);
|
||||
EventManager::unsubscribe<EventProjectFileLoad>(this);
|
||||
EventManager::unsubscribe<RequestSetPatternLanguageCode>(this);
|
||||
EventManager::unsubscribe<EventFileLoaded>(this);
|
||||
EventManager::unsubscribe<RequestChangeTheme>(this);
|
||||
EventManager::unsubscribe<EventFileUnloaded>(this);
|
||||
}
|
||||
|
||||
void ViewPatternEditor::drawContent() {
|
||||
|
@ -13,6 +13,13 @@ namespace hex::plugin::builtin {
|
||||
this->getWindowOpenState() = true;
|
||||
}
|
||||
});
|
||||
|
||||
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.help", 2000, [&, this] {
|
||||
if (ImGui::MenuItem("hex.builtin.view.settings.name"_lang)) {
|
||||
View::doLater([]{ ImGui::OpenPopup(View::toWindowName("hex.builtin.view.settings.name").c_str()); });
|
||||
this->getWindowOpenState() = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ViewSettings::~ViewSettings() {
|
||||
@ -45,18 +52,4 @@ namespace hex::plugin::builtin {
|
||||
|
||||
}
|
||||
|
||||
void ViewSettings::drawMenu() {
|
||||
if (ImGui::BeginMenu("hex.builtin.menu.help"_lang)) {
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::MenuItem("hex.builtin.view.settings.name"_lang)) {
|
||||
View::doLater([]{ ImGui::OpenPopup(View::toWindowName("hex.builtin.view.settings.name").c_str()); });
|
||||
this->getWindowOpenState() = true;
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -24,6 +24,13 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ViewStore::ViewStore() : View("hex.builtin.view.store.name") {
|
||||
this->refresh();
|
||||
|
||||
ContentRegistry::Interface::addMenuItem("hex.builtin.menu.help", 3000, [&, this] {
|
||||
if (ImGui::MenuItem("hex.builtin.view.store.name"_lang)) {
|
||||
View::doLater([]{ ImGui::OpenPopup(View::toWindowName("hex.builtin.view.store.name").c_str()); });
|
||||
this->getWindowOpenState() = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ViewStore::~ViewStore() { }
|
||||
@ -234,18 +241,6 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
}
|
||||
|
||||
void ViewStore::drawMenu() {
|
||||
if (ImGui::BeginMenu("hex.builtin.menu.help"_lang)) {
|
||||
if (ImGui::MenuItem("hex.builtin.view.store.name"_lang)) {
|
||||
View::doLater([]{ ImGui::OpenPopup(View::toWindowName("hex.builtin.view.store.name").c_str()); });
|
||||
this->getWindowOpenState() = true;
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ViewStore::download(ImHexPath pathType, const std::string &fileName, const std::string &url, bool update) {
|
||||
if (!update) {
|
||||
this->m_downloadPath = hex::getPath(pathType).back() / fs::path(fileName);
|
||||
|
@ -242,8 +242,4 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
}
|
||||
|
||||
void ViewStrings::drawMenu() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -19,8 +19,4 @@ namespace hex::plugin::builtin {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ViewTools::drawMenu() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -129,10 +129,6 @@ namespace hex::plugin::builtin {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ViewYara::drawMenu() {
|
||||
|
||||
}
|
||||
|
||||
void ViewYara::reloadRules() {
|
||||
this->m_rules.clear();
|
||||
|
||||
|
@ -18,7 +18,6 @@ namespace hex::plugin::windows {
|
||||
~ViewTTYConsole() override;
|
||||
|
||||
void drawContent() override;
|
||||
void drawMenu() override;
|
||||
|
||||
private:
|
||||
std::vector<std::pair<std::string, std::string>> m_comPorts;
|
||||
|
@ -157,10 +157,6 @@ namespace hex::plugin::windows {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ViewTTYConsole::drawMenu() {
|
||||
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> ViewTTYConsole::getAvailablePorts() {
|
||||
std::vector<std::pair<std::string, std::string>> result;
|
||||
std::vector<char> buffer(0xFFF, 0x00);
|
||||
|
Loading…
Reference in New Issue
Block a user