1
0
mirror of synced 2024-11-24 15:50:16 +01:00

feat: Added simple data access graph to pattern editor

This commit is contained in:
WerWolv 2023-11-06 15:15:35 +01:00
parent 7efe9acefb
commit 8581ab9eb3
3 changed files with 51 additions and 1 deletions

@ -1 +1 @@
Subproject commit 6eb55561040c61782e4edcc19d794920b141e2f3
Subproject commit d70f027c015b784140b3e8be60370df3e58c4fa6

View File

@ -132,6 +132,11 @@ namespace hex::plugin::builtin {
}
};
struct AccessData {
float progress;
u32 color;
};
std::unique_ptr<pl::PatternLanguage> m_parserRuntime;
PerProvider<std::vector<std::fs::path>> m_possiblePatternFiles;
@ -179,6 +184,9 @@ namespace hex::plugin::builtin {
std::atomic<bool> m_resetDebuggerVariables;
int m_debuggerScopeIndex = 0;
std::array<AccessData, 512> m_accessHistory;
u32 m_accessHistoryIndex = 0;
private:
void drawConsole(ImVec2 size);
void drawEnvVars(ImVec2 size, std::list<EnvVar> &envVars);

View File

@ -244,6 +244,45 @@ namespace hex::plugin::builtin {
} else {
ImGui::TextSpinner("hex.builtin.view.pattern_editor.evaluating"_lang);
}
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::SameLine();
const auto padding = ImGui::GetStyle().FramePadding.y;
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2());
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2());
if (ImGui::BeginChild("##read_cursor", ImGui::GetContentRegionAvail() + ImVec2(0, padding), true)) {
const auto startPos = ImGui::GetCursorScreenPos();
const auto size = ImGui::GetContentRegionAvail();
const auto dataBaseAddress = runtime.getInternals().evaluator->getDataBaseAddress();
const auto dataSize = runtime.getInternals().evaluator->getDataSize();
const auto insertPos = [&, this](u64 address, u32 color) {
const auto progress = (address - dataBaseAddress) / float(dataSize);
this->m_accessHistory[this->m_accessHistoryIndex] = { progress, color };
this->m_accessHistoryIndex = (this->m_accessHistoryIndex + 1) % this->m_accessHistory.size();
};
insertPos(runtime.getLastReadAddress(), ImGui::GetCustomColorU32(ImGuiCustomCol_ToolbarBlue));
insertPos(runtime.getLastWriteAddress(), ImGui::GetCustomColorU32(ImGuiCustomCol_ToolbarRed));
insertPos(runtime.getLastPatternPlaceAddress(), ImGui::GetCustomColorU32(ImGuiCustomCol_ToolbarGreen));
auto drawList = ImGui::GetWindowDrawList();
for (const auto &[progress, color] : this->m_accessHistory) {
if (progress <= 0) continue;
const auto linePos = startPos + ImVec2(size.x * progress, 0);
drawList->AddLine(linePos, linePos + ImVec2(0, size.y), color, 2_scaled);
}
}
ImGui::EndChild();
ImGui::PopStyleVar(2);
} else {
if (ImGui::Checkbox("hex.builtin.view.pattern_editor.auto"_lang, &this->m_runAutomatically)) {
if (this->m_runAutomatically)
@ -942,6 +981,9 @@ namespace hex::plugin::builtin {
this->m_sectionWindowDrawer.clear();
this->m_consoleEditor.SetText("");
this->m_accessHistory = {};
this->m_accessHistoryIndex = 0;
EventManager::post<EventHighlightingChanged>();
TaskManager::createTask("hex.builtin.view.pattern_editor.evaluating", TaskManager::NoProgress, [this, code, provider](auto &task) {