mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 21:30:19 -06:00
CheatSearch: Update Current Values at end of frame
At the end of each frame automatically update the Current Value for visible table rows in the selected and visible CheatSearchWidget (if any). Also update all Current Values in all CheatSearchWidgets when the State changes to Paused. Only updating visible table rows serves to minimize the performance cost of this feature. If the user scrolls to an un-updated cell it will promptly be updated by either the next VIEndFieldEvent or the State transitioning to Paused.
This commit is contained in:
@ -19,8 +19,10 @@
|
||||
#include "DolphinQt/CheatSearchWidget.h"
|
||||
#include "DolphinQt/Config/ARCodeWidget.h"
|
||||
#include "DolphinQt/Config/GeckoCodeWidget.h"
|
||||
#include "DolphinQt/QtUtils/PartiallyClosableTabWidget.h"
|
||||
#include "DolphinQt/Settings.h"
|
||||
#include "QtUtils/PartiallyClosableTabWidget.h"
|
||||
|
||||
#include "VideoCommon/VideoEvents.h"
|
||||
|
||||
CheatsManager::CheatsManager(QWidget* parent) : QDialog(parent)
|
||||
{
|
||||
@ -48,6 +50,49 @@ CheatsManager::~CheatsManager()
|
||||
void CheatsManager::OnStateChanged(Core::State state)
|
||||
{
|
||||
RefreshCodeTabs(state, false);
|
||||
if (state == Core::State::Paused)
|
||||
UpdateAllCheatSearchWidgetCurrentValues();
|
||||
}
|
||||
|
||||
void CheatsManager::OnFrameEnd()
|
||||
{
|
||||
if (!isVisible())
|
||||
return;
|
||||
|
||||
auto* const selected_cheat_search_widget =
|
||||
qobject_cast<CheatSearchWidget*>(m_tab_widget->currentWidget());
|
||||
if (selected_cheat_search_widget != nullptr)
|
||||
selected_cheat_search_widget->UpdateTableVisibleCurrentValues();
|
||||
}
|
||||
|
||||
void CheatsManager::UpdateAllCheatSearchWidgetCurrentValues()
|
||||
{
|
||||
for (int i = 0; i < m_tab_widget->count(); ++i)
|
||||
{
|
||||
auto* const cheat_search_widget = qobject_cast<CheatSearchWidget*>(m_tab_widget->widget(i));
|
||||
if (cheat_search_widget != nullptr)
|
||||
cheat_search_widget->UpdateTableAllCurrentValues();
|
||||
}
|
||||
}
|
||||
|
||||
void CheatsManager::RegisterAfterFrameEventCallback()
|
||||
{
|
||||
m_VI_end_field_event = VIEndFieldEvent::Register([this] { OnFrameEnd(); }, "CheatsManager");
|
||||
}
|
||||
|
||||
void CheatsManager::RemoveAfterFrameEventCallback()
|
||||
{
|
||||
m_VI_end_field_event.reset();
|
||||
}
|
||||
|
||||
void CheatsManager::hideEvent(QHideEvent* event)
|
||||
{
|
||||
RemoveAfterFrameEventCallback();
|
||||
}
|
||||
|
||||
void CheatsManager::showEvent(QShowEvent* event)
|
||||
{
|
||||
RegisterAfterFrameEventCallback();
|
||||
}
|
||||
|
||||
void CheatsManager::RefreshCodeTabs(Core::State state, bool force)
|
||||
|
Reference in New Issue
Block a user