feat: Added basic UI for the new pl section system

This commit is contained in:
WerWolv
2022-11-07 00:04:47 +01:00
parent 901b8f0424
commit 5bbc2fd94c
27 changed files with 301 additions and 186 deletions

View File

@@ -15,8 +15,8 @@ namespace hex::plugin::builtin {
void drawContent() override;
private:
static bool importBookmarks(prv::Provider *provider, const nlohmann::json &json);
static bool exportBookmarks(prv::Provider *provider, nlohmann::json &json);
static bool importBookmarks(hex::prv::Provider *provider, const nlohmann::json &json);
static bool exportBookmarks(hex::prv::Provider *provider, nlohmann::json &json);
void registerMenuItems();
private:

View File

@@ -14,7 +14,7 @@ namespace hex::plugin::builtin {
class ViewHexEditor : public View {
public:
ViewHexEditor();
~ViewHexEditor();
~ViewHexEditor() override;
void drawContent() override;
@@ -44,23 +44,23 @@ namespace hex::plugin::builtin {
}
bool isSelectionValid() {
return this->m_hexEditor->isSelectionValid();
return this->m_hexEditor.isSelectionValid();
}
Region getSelection() {
return this->m_hexEditor->getSelection();
return this->m_hexEditor.getSelection();
}
void setSelection(const Region &region) {
this->m_hexEditor->setSelection(region);
this->m_hexEditor.setSelection(region);
}
void setSelection(u128 start, u128 end) {
this->m_hexEditor->setSelection(start, end);
this->m_hexEditor.setSelection(start, end);
}
void jumpToSelection() {
this->m_hexEditor->jumpToSelection();
this->m_hexEditor.jumpToSelection();
}
private:
@@ -70,13 +70,10 @@ namespace hex::plugin::builtin {
void registerEvents();
void registerMenuItems();
std::unique_ptr<HexEditor> m_hexEditor;
HexEditor m_hexEditor;
bool m_shouldOpenPopup = false;
std::unique_ptr<Popup> m_currPopup;
std::optional<u64> *m_selectionStart, *m_selectionEnd;
float *m_scrollPosition;
};
}

View File

@@ -4,6 +4,7 @@
#include <hex/ui/view.hpp>
#include <content/helpers/pattern_drawer.hpp>
#include <hex/providers/provider.hpp>
#include <vector>
#include <tuple>
@@ -18,7 +19,7 @@ namespace hex::plugin::builtin {
void drawContent() override;
private:
std::map<prv::Provider *, std::vector<pl::ptrn::Pattern*>> m_sortedPatterns;
std::map<hex::prv::Provider *, std::vector<pl::ptrn::Pattern*>> m_sortedPatterns;
hex::PatternDrawer m_patternDrawer;
};

View File

@@ -4,7 +4,10 @@
#include <pl/pattern_language.hpp>
#include <pl/core/errors/error.hpp>
#include <hex/providers/provider.hpp>
#include <content/helpers/provider_extra_data.hpp>
#include <content/helpers/hex_editor.hpp>
#include <content/providers/memory_file_provider.hpp>
#include <cstring>
#include <filesystem>
@@ -60,10 +63,14 @@ namespace hex::plugin::builtin {
bool m_syncPatternSourceCode = false;
bool m_autoLoadPatterns = true;
std::unique_ptr<MemoryFileProvider> m_sectionProvider = nullptr;
HexEditor m_hexEditor;
private:
void drawConsole(ImVec2 size, const std::vector<std::pair<pl::core::LogConsole::Level, std::string>> &console);
void drawEnvVars(ImVec2 size, std::list<PlData::EnvVar> &envVars);
void drawVariableSettings(ImVec2 size, std::map<std::string, PlData::PatternVariable> &patternVariables);
void drawSectionSelector(ImVec2 size, std::map<u64, pl::api::Section> &sections);
void drawPatternTooltip(pl::ptrn::Pattern *pattern);