mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
Streamline view creation, save all view states when quitting
This commit is contained in:
@@ -9,7 +9,7 @@ using namespace std::literals::string_literals;
|
||||
|
||||
namespace hex {
|
||||
|
||||
ViewStrings::ViewStrings(prv::Provider* &dataProvider) : View(), m_dataProvider(dataProvider) {
|
||||
ViewStrings::ViewStrings(prv::Provider* &dataProvider) : View("Strings"), m_dataProvider(dataProvider) {
|
||||
View::subscribeEvent(Events::DataChanged, [this](const void*){
|
||||
this->m_foundStrings.clear();
|
||||
});
|
||||
@@ -24,15 +24,11 @@ namespace hex {
|
||||
}
|
||||
|
||||
void ViewStrings::createView() {
|
||||
if (!this->m_windowOpen)
|
||||
return;
|
||||
|
||||
if (this->m_shouldInvalidate) {
|
||||
this->m_shouldInvalidate = false;
|
||||
|
||||
this->m_foundStrings.clear();
|
||||
|
||||
|
||||
std::vector<u8> buffer(1024, 0x00);
|
||||
u32 foundCharacters = 0;
|
||||
for (u64 offset = 0; offset < this->m_dataProvider->getSize(); offset += buffer.size()) {
|
||||
@@ -62,7 +58,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
|
||||
if (ImGui::Begin("Strings", &this->m_windowOpen, ImGuiWindowFlags_NoCollapse)) {
|
||||
if (ImGui::Begin("Strings", &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
|
||||
if (this->m_dataProvider != nullptr && this->m_dataProvider->isReadable()) {
|
||||
if (ImGui::InputInt("Minimum length", &this->m_minimumLength, 1, 0))
|
||||
this->m_shouldInvalidate = true;
|
||||
@@ -147,10 +143,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
void ViewStrings::createMenu() {
|
||||
if (ImGui::BeginMenu("View")) {
|
||||
ImGui::MenuItem("Strings View", "", &this->m_windowOpen);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user