1
0
mirror of synced 2024-11-28 09:30:51 +01:00

ux: Properly evaluate pattern changes when already evaluating

This commit is contained in:
WerWolv 2021-09-21 23:17:50 +02:00
parent 9dd555f111
commit 471ba80b4d
2 changed files with 11 additions and 2 deletions

View File

@ -30,6 +30,7 @@ namespace hex {
int m_selectedPatternFile = 0;
bool m_runAutomatically = false;
bool m_evaluatorRunning = false;
bool m_hasUnevaluatedChanges = false;
TextEditor m_textEditor;
std::vector<std::pair<pl::LogConsole::Level, std::string>> m_console;

View File

@ -246,13 +246,21 @@ namespace hex {
if (this->m_evaluatorRunning)
ImGui::TextSpinner("hex.view.pattern.evaluating"_lang);
else
ImGui::Checkbox("hex.view.pattern.auto"_lang, &this->m_runAutomatically);
if (ImGui::Checkbox("hex.view.pattern.auto"_lang, &this->m_runAutomatically)) {
if (this->m_runAutomatically)
this->m_hasUnevaluatedChanges = true;
}
if (this->m_textEditor.IsTextChanged()) {
if (this->m_runAutomatically)
this->parsePattern(this->m_textEditor.GetText().data());
this->m_hasUnevaluatedChanges = true;
}
if (this->m_hasUnevaluatedChanges && !this->m_evaluatorRunning) {
this->m_hasUnevaluatedChanges = false;
ProjectFile::markDirty();
this->parsePattern(this->m_textEditor.GetText().data());
}
}