Skip to content

Commit 943c847

Browse files
committed
Memory Observer improvements:
• proper TextFlags in input box • remove button in address tables • new position for "fixed-point values" checkbox • new buttons for (un)freeze/all • smaller buttons for read and write breakpoints • validate sequence size to prevent error
1 parent dec9cd9 commit 943c847

File tree

1 file changed

+56
-11
lines changed

1 file changed

+56
-11
lines changed

src/gui/widgets/memory_observer.cc

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ void PCSX::Widgets::MemoryObserver::draw(const char* title) {
9595
ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV;
9696

9797
if (ImGui::BeginTabItem(_("Plain search"))) {
98-
bool gotEnter = ImGui::InputText(_("Pattern"), &m_plainSearchString, ImGuiInputTextFlags_EnterReturnsTrue);
98+
bool gotEnter = ImGui::InputText(
99+
_("Pattern"), &m_plainSearchString,
100+
ImGuiInputTextFlags_EnterReturnsTrue |
101+
(m_plainHex ? ImGuiInputTextFlags_CharsHexadecimal : ImGuiInputTextFlags_CharsDecimal));
99102
ImGui::Checkbox(_("Hex"), &m_plainHex);
100103
auto needleSize = 0;
101104
std::string needle;
@@ -166,9 +169,10 @@ void PCSX::Widgets::MemoryObserver::draw(const char* title) {
166169
if (!valid) {
167170
ImGui::EndDisabled();
168171
}
169-
if (ImGui::BeginTable(_("Found values"), 2, tableFlags)) {
172+
if (ImGui::BeginTable(_("Found values"), 3, tableFlags)) {
170173
ImGui::TableSetupColumn(_("Address"));
171174
ImGui::TableSetupColumn(_("Access"));
175+
ImGui::TableSetupColumn(_("Remove"));
172176
ImGui::TableHeadersRow();
173177

174178
ImGuiListClipper clipper;
@@ -187,6 +191,13 @@ void PCSX::Widgets::MemoryObserver::draw(const char* title) {
187191
g_system->m_eventBus->signal(
188192
PCSX::Events::GUI::JumpToMemory{editorAddress, static_cast<unsigned>(needleSize)});
189193
}
194+
ImGui::TableSetColumnIndex(2);
195+
auto removeButtonName = fmt::format(f_("╳##{}"), row);
196+
if (ImGui::Button(removeButtonName.c_str())) {
197+
m_plainAddresses.erase(m_plainAddresses.begin() + row);
198+
clipper.Begin(m_plainAddresses.size());
199+
break;
200+
}
190201
}
191202
}
192203
ImGui::EndTable();
@@ -286,6 +297,12 @@ void PCSX::Widgets::MemoryObserver::draw(const char* title) {
286297
}
287298

288299
ImGui::Checkbox(_("Hex"), &m_hex);
300+
301+
if (!m_hex && stride > 1) {
302+
ImGui::SameLine();
303+
ImGui::Checkbox(_("Display as fixed-point values"), &m_fixedPoint);
304+
}
305+
289306
ImGui::InputScalar(_("Value"), ImGuiDataType_S64, &m_value, NULL, NULL, m_hex ? "%x" : "%i",
290307
m_hex ? ImGuiInputTextFlags_CharsHexadecimal : ImGuiInputTextFlags_CharsDecimal);
291308
m_value = getValueAsSelectedType(m_value);
@@ -320,17 +337,34 @@ void PCSX::Widgets::MemoryObserver::draw(const char* title) {
320337
ImGui::EndCombo();
321338
}
322339

323-
if (!m_hex && stride > 1) {
324-
ImGui::Checkbox(_("Display as fixed-point values"), &m_fixedPoint);
340+
ImGui::Separator();
341+
if (ImGui::Button(_("Freeze all"))) {
342+
for (auto& addressValuePair : m_addressValuePairs) {
343+
addressValuePair.frozen = true;
344+
addressValuePair.frozenValue = getValueAsSelectedType(getMemValue(
345+
addressValuePair.address, memData, memSize, memBase, getStrideFromValueType(m_scanValueType)));
346+
}
347+
}
348+
ImGui::SameLine();
349+
if (ImGui::Button(_("Unfreeze all"))) {
350+
for (auto& addressValuePair : m_addressValuePairs) {
351+
addressValuePair.frozen = false;
352+
}
353+
}
354+
ImGui::SameLine();
355+
if (ImGui::Button(_("Remove all frozen addresses"))) {
356+
m_addressValuePairs.erase(std::remove_if(m_addressValuePairs.begin(), m_addressValuePairs.end(),
357+
[](const AddressValuePair& pair) { return pair.frozen; }),
358+
m_addressValuePairs.end());
325359
}
326360

327361
if (ImGui::BeginTable(_("Found values"), 6, tableFlags)) {
328362
ImGui::TableSetupColumn(_("Address"));
329363
ImGui::TableSetupColumn(_("Current value"));
330364
ImGui::TableSetupColumn(_("Scanned value"));
331365
ImGui::TableSetupColumn(_("Access"));
332-
ImGui::TableSetupColumn(_("Read breakpoint"));
333-
ImGui::TableSetupColumn(_("Write breakpoint"));
366+
ImGui::TableSetupColumn(_("Add breakpoint"));
367+
ImGui::TableSetupColumn(_("Remove"));
334368
ImGui::TableHeadersRow();
335369

336370
bool as_uint = (m_scanValueType == ScanValueType::Uint);
@@ -376,17 +410,24 @@ void PCSX::Widgets::MemoryObserver::draw(const char* title) {
376410
g_system->m_eventBus->signal(PCSX::Events::GUI::JumpToMemory{editorAddress, stride});
377411
}
378412
ImGui::TableSetColumnIndex(4);
379-
auto addReadBreakpointButtonName = fmt::format(f_("Add read breakpoint##{}"), row);
413+
auto addReadBreakpointButtonName = fmt::format(f_("Read##{}"), row);
380414
if (ImGui::Button(addReadBreakpointButtonName.c_str())) {
381415
g_emulator->m_debug->addBreakpoint(currentAddress, Debug::BreakpointType::Read, stride,
382416
_("Memory Observer"));
383417
}
384-
ImGui::TableSetColumnIndex(5);
385-
auto addWriteBreakpointButtonName = fmt::format(f_("Add write breakpoint##{}"), row);
418+
ImGui::SameLine();
419+
auto addWriteBreakpointButtonName = fmt::format(f_("Write##{}"), row);
386420
if (ImGui::Button(addWriteBreakpointButtonName.c_str())) {
387421
g_emulator->m_debug->addBreakpoint(currentAddress, Debug::BreakpointType::Write, stride,
388422
_("Memory Observer"));
389423
}
424+
ImGui::TableSetColumnIndex(5);
425+
auto removeButtonName = fmt::format(f_("╳##{}"), row);
426+
if (ImGui::Button(removeButtonName.c_str())) {
427+
m_addressValuePairs.erase(m_addressValuePairs.begin() + row);
428+
clipper.Begin(m_addressValuePairs.size());
429+
break;
430+
}
390431
}
391432
}
392433
ImGui::EndTable();
@@ -399,9 +440,13 @@ void PCSX::Widgets::MemoryObserver::draw(const char* title) {
399440
if (m_useSIMD) {
400441
ImGui::TextUnformatted(_("Sequence size: "));
401442
ImGui::SameLine();
402-
ImGui::RadioButton(_("8 bytes (fast)"), &m_sequenceSize, 8);
443+
if (ImGui::RadioButton(_("8 bytes (fast)"), &m_sequenceSize, 8) && strlen(m_sequence) > 8) {
444+
m_sequence[8] = '\0';
445+
}
403446
ImGui::SameLine();
404-
ImGui::RadioButton(_("16 bytes (fast)"), &m_sequenceSize, 16);
447+
if (ImGui::RadioButton(_("16 bytes (fast)"), &m_sequenceSize, 16) && strlen(m_sequence) > 16) {
448+
m_sequence[16] = '\0';
449+
}
405450
ImGui::SameLine();
406451
ImGui::RadioButton(_("Arbitrary"), &m_sequenceSize, 255);
407452
}

0 commit comments

Comments
 (0)