Optimizando memory viewer para que no cree un dump de una linea no visible
This commit is contained in:
@@ -24,27 +24,32 @@ void MemoryViewer::render()
|
|||||||
ImGui::SliderInt("##memory_view_width", &width, 1, 32, "%d", ImGuiSliderFlags_AlwaysClamp);
|
ImGui::SliderInt("##memory_view_width", &width, 1, 32, "%d", ImGuiSliderFlags_AlwaysClamp);
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
|
auto total_lines = (std::size(this->machine_state->memory) + width - 1) / width;
|
||||||
|
ImGuiListClipper clipper;
|
||||||
|
clipper.Begin(total_lines);
|
||||||
|
|
||||||
auto dump_lines = this->get_memory_dump();
|
ImGui::BeginChild("##memory_view");
|
||||||
for (auto dump_line : dump_lines)
|
while (clipper.Step())
|
||||||
{
|
{
|
||||||
ImGui::TextUnformatted(dump_line.c_str());
|
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
||||||
|
{
|
||||||
|
ImGui::TextUnformatted(get_memory_line(i).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> MemoryViewer::get_memory_dump() const
|
std::string MemoryViewer::get_memory_line(int line) const
|
||||||
{
|
{
|
||||||
auto& memory = this->machine_state->memory;
|
auto& memory = this->machine_state->memory;
|
||||||
|
|
||||||
const auto size = std::size(memory);
|
const auto size = std::size(memory);
|
||||||
|
const auto i = line * this->width;
|
||||||
|
|
||||||
std::vector<std::string> dump_lines;
|
|
||||||
|
|
||||||
for (auto i = 0; i < size; i += this->width)
|
|
||||||
{
|
|
||||||
std::stringstream text_builder;
|
std::stringstream text_builder;
|
||||||
|
|
||||||
text_builder << "0x";
|
text_builder << "0x";
|
||||||
text_builder << std::hex
|
text_builder << std::hex
|
||||||
<< std::setw(4)
|
<< std::setw(4)
|
||||||
@@ -92,8 +97,5 @@ std::vector<std::string> MemoryViewer::get_memory_dump() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dump_lines.push_back(text_builder.str());
|
return text_builder.str();
|
||||||
}
|
|
||||||
|
|
||||||
return dump_lines;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
void render();
|
void render();
|
||||||
std::vector<std::string> get_memory_dump() const;
|
std::string get_memory_line(int line) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user