1
0
mirror of synced 2025-01-11 05:42:15 +01:00

impr: Added better notes to the settings tabs in the pattern editor view

This commit is contained in:
WerWolv 2024-12-23 21:26:22 +01:00
parent a29b502a33
commit 7cc99c6fc9
5 changed files with 69 additions and 55 deletions

View File

@ -295,7 +295,7 @@ namespace ImGuiExt {
bool DimmedIconToggle(const char *icon, bool *v);
bool DimmedIconToggle(const char *iconOn, const char *iconOff, bool *v);
void TextOverlay(const char *text, ImVec2 pos);
void TextOverlay(const char *text, ImVec2 pos, float maxWidth = -1);
bool BeginBox();
void EndBox();

View File

@ -1164,8 +1164,8 @@ namespace ImGuiExt {
return toggled;
}
void TextOverlay(const char *text, ImVec2 pos) {
const auto textSize = CalcTextSize(text);
void TextOverlay(const char *text, ImVec2 pos, float maxWidth) {
const auto textSize = CalcTextSize(text, nullptr, false, maxWidth);
const auto textPos = pos - textSize / 2;
const auto margin = GetStyle().FramePadding * 2;
const auto textRect = ImRect(textPos - margin, textPos + textSize + margin);
@ -1174,7 +1174,7 @@ namespace ImGuiExt {
drawList->AddRectFilled(textRect.Min, textRect.Max, GetColorU32(ImGuiCol_WindowBg) | 0xFF000000);
drawList->AddRect(textRect.Min, textRect.Max, GetColorU32(ImGuiCol_Border));
drawList->AddText(textPos, GetColorU32(ImGuiCol_Text), text);
drawList->AddText(nullptr, 0.0F, textPos, GetColorU32(ImGuiCol_Text), text, nullptr, maxWidth);
}
bool BeginBox() {

View File

@ -961,6 +961,9 @@
"hex.builtin.view.pattern_editor.menu.replace_all": "Replace All",
"hex.builtin.view.pattern_editor.name": "Pattern editor",
"hex.builtin.view.pattern_editor.no_in_out_vars": "Define some global variables with the 'in' or 'out' specifier for them to appear here.",
"hex.builtin.view.pattern_editor.no_sections": "Create additional output sections to display and decode processed data by using the std::mem::create_section function.",
"hex.builtin.view.pattern_editor.no_virtual_files": "Visualize regions of data as a virtual folder structure by adding them using the hex::core::add_virtual_file function.",
"hex.builtin.view.pattern_editor.no_env_vars": "The content of Environment Variables created here can be accessed from Pattern scripts using the std::env function.",
"hex.builtin.view.pattern_editor.no_results": "no results",
"hex.builtin.view.pattern_editor.of": "of",
"hex.builtin.view.pattern_editor.open_pattern": "Open pattern",

View File

@ -1094,6 +1094,10 @@ namespace hex::plugin::builtin {
static u32 envVarCounter = 1;
if (ImGui::BeginChild("##env_vars", size, true, ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
if (envVars.size() <= 1) {
ImGuiExt::TextOverlay("hex.builtin.view.pattern_editor.no_env_vars"_lang, ImGui::GetWindowPos() + ImGui::GetWindowSize() / 2, ImGui::GetWindowWidth() * 0.7);
}
if (ImGui::BeginTable("##env_vars_table", 4, ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_BordersInnerH)) {
ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_WidthStretch, 0.1F);
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthStretch, 0.4F);
@ -1197,8 +1201,9 @@ namespace hex::plugin::builtin {
void ViewPatternEditor::drawVariableSettings(ImVec2 size, std::map<std::string, PatternVariable> &patternVariables) {
if (ImGui::BeginChild("##settings", size, true, ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
if (patternVariables.empty()) {
ImGuiExt::TextFormattedCentered("hex.builtin.view.pattern_editor.no_in_out_vars"_lang);
} else {
ImGuiExt::TextOverlay("hex.builtin.view.pattern_editor.no_in_out_vars"_lang, ImGui::GetWindowPos() + ImGui::GetWindowSize() / 2, ImGui::GetWindowWidth() * 0.7);
}
if (ImGui::BeginTable("##in_out_vars_table", 2, ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_BordersInnerH | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_RowBg)) {
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthStretch, 0.25F);
ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch, 0.75F);
@ -1255,7 +1260,6 @@ namespace hex::plugin::builtin {
ImGui::EndTable();
}
}
}
ImGui::EndChild();
}
@ -1270,6 +1274,10 @@ namespace hex::plugin::builtin {
ImGui::TableHeadersRow();
if (sections.empty()) {
ImGuiExt::TextOverlay("hex.builtin.view.pattern_editor.no_sections"_lang, ImGui::GetWindowPos() + ImGui::GetWindowSize() / 2, ImGui::GetWindowWidth() * 0.7);
}
if (TRY_LOCK(ContentRegistry::PatternLanguage::getRuntimeLock())) {
for (auto &[id, section] : sections) {
if (section.name.empty())
@ -1364,6 +1372,10 @@ namespace hex::plugin::builtin {
virtualFilePointers.emplace_back(&file);
if (ImGui::BeginTable("Virtual File Tree", 1, ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersInnerH | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, size)) {
if (virtualFiles.empty()) {
ImGuiExt::TextOverlay("hex.builtin.view.pattern_editor.no_virtual_files"_lang, ImGui::GetWindowPos() + ImGui::GetWindowSize() / 2, ImGui::GetWindowWidth() * 0.7);
}
ImGui::TableSetupColumn("##path", ImGuiTableColumnFlags_WidthStretch);
levelId = 1;
drawVirtualFileTree(virtualFilePointers);
@ -1376,7 +1388,6 @@ namespace hex::plugin::builtin {
void ViewPatternEditor::drawDebugger(ImVec2 size) {
const auto &runtime = ContentRegistry::PatternLanguage::getRuntime();
if (ImGui::BeginChild("##debugger", size, true)) {
auto &evaluator = runtime.getInternals().evaluator;
m_breakpoints = m_textEditor.GetBreakpoints();

View File

@ -1442,7 +1442,7 @@ namespace hex::ui {
m_jumpToPattern = nullptr;
if (m_favoritesUpdateTask.isRunning()) {
ImGuiExt::TextOverlay("hex.ui.pattern_drawer.updating"_lang, ImGui::GetWindowPos() + ImGui::GetWindowSize() / 2);
ImGuiExt::TextOverlay("hex.ui.pattern_drawer.updating"_lang, ImGui::GetWindowPos() + ImGui::GetWindowSize() / 2, ImGui::GetWindowWidth() * 0.5);
}
}