Merge pull request #6024 from ligfx/coreonstatechangedcallback
Qt: use Settings::EmulationStateChanged
This commit is contained in:
commit
0d07821935
|
@ -98,11 +98,12 @@ static Common::Flag s_is_booting;
|
||||||
static void* s_window_handle = nullptr;
|
static void* s_window_handle = nullptr;
|
||||||
static std::string s_state_filename;
|
static std::string s_state_filename;
|
||||||
static std::thread s_emu_thread;
|
static std::thread s_emu_thread;
|
||||||
static StoppedCallbackFunc s_on_stopped_callback;
|
static StateChangedCallbackFunc s_on_state_changed_callback;
|
||||||
|
|
||||||
static std::thread s_cpu_thread;
|
static std::thread s_cpu_thread;
|
||||||
static bool s_request_refresh_info = false;
|
static bool s_request_refresh_info = false;
|
||||||
static bool s_is_throttler_temp_disabled = false;
|
static bool s_is_throttler_temp_disabled = false;
|
||||||
|
static bool s_frame_step = false;
|
||||||
|
|
||||||
struct HostJob
|
struct HostJob
|
||||||
{
|
{
|
||||||
|
@ -454,14 +455,16 @@ static void EmuThread(std::unique_ptr<BootParameters> boot)
|
||||||
{
|
{
|
||||||
const SConfig& core_parameter = SConfig::GetInstance();
|
const SConfig& core_parameter = SConfig::GetInstance();
|
||||||
s_is_booting.Set();
|
s_is_booting.Set();
|
||||||
|
if (s_on_state_changed_callback)
|
||||||
|
s_on_state_changed_callback(State::Starting);
|
||||||
Common::ScopeGuard flag_guard{[] {
|
Common::ScopeGuard flag_guard{[] {
|
||||||
s_is_booting.Clear();
|
s_is_booting.Clear();
|
||||||
s_is_started = false;
|
s_is_started = false;
|
||||||
s_is_stopping = false;
|
s_is_stopping = false;
|
||||||
s_wants_determinism = false;
|
s_wants_determinism = false;
|
||||||
|
|
||||||
if (s_on_stopped_callback)
|
if (s_on_state_changed_callback)
|
||||||
s_on_stopped_callback();
|
s_on_state_changed_callback(State::Uninitialized);
|
||||||
|
|
||||||
INFO_LOG(CONSOLE, "Stop\t\t---- Shutdown complete ----");
|
INFO_LOG(CONSOLE, "Stop\t\t---- Shutdown complete ----");
|
||||||
}};
|
}};
|
||||||
|
@ -473,6 +476,7 @@ static void EmuThread(std::unique_ptr<BootParameters> boot)
|
||||||
|
|
||||||
// For a time this acts as the CPU thread...
|
// For a time this acts as the CPU thread...
|
||||||
DeclareAsCPUThread();
|
DeclareAsCPUThread();
|
||||||
|
s_frame_step = false;
|
||||||
|
|
||||||
Movie::Init(*boot);
|
Movie::Init(*boot);
|
||||||
Common::ScopeGuard movie_guard{Movie::Shutdown};
|
Common::ScopeGuard movie_guard{Movie::Shutdown};
|
||||||
|
@ -683,6 +687,9 @@ void SetState(State state)
|
||||||
PanicAlert("Invalid state");
|
PanicAlert("Invalid state");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s_on_state_changed_callback)
|
||||||
|
s_on_state_changed_callback(GetState());
|
||||||
}
|
}
|
||||||
|
|
||||||
State GetState()
|
State GetState()
|
||||||
|
@ -698,6 +705,9 @@ State GetState()
|
||||||
return State::Running;
|
return State::Running;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s_is_booting.IsSet())
|
||||||
|
return State::Starting;
|
||||||
|
|
||||||
return State::Uninitialized;
|
return State::Uninitialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -859,6 +869,14 @@ void Callback_VideoCopiedToXFB(bool video_update)
|
||||||
s_drawn_frame++;
|
s_drawn_frame++;
|
||||||
|
|
||||||
Movie::FrameUpdate();
|
Movie::FrameUpdate();
|
||||||
|
|
||||||
|
if (s_frame_step)
|
||||||
|
{
|
||||||
|
s_frame_step = false;
|
||||||
|
CPU::Break();
|
||||||
|
if (s_on_state_changed_callback)
|
||||||
|
s_on_state_changed_callback(Core::GetState());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateTitle()
|
void UpdateTitle()
|
||||||
|
@ -951,9 +969,9 @@ void Shutdown()
|
||||||
HostDispatchJobs();
|
HostDispatchJobs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetOnStoppedCallback(StoppedCallbackFunc callback)
|
void SetOnStateChangedCallback(StateChangedCallbackFunc callback)
|
||||||
{
|
{
|
||||||
s_on_stopped_callback = std::move(callback);
|
s_on_state_changed_callback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateWantDeterminism(bool initial)
|
void UpdateWantDeterminism(bool initial)
|
||||||
|
@ -1024,4 +1042,21 @@ void HostDispatchJobs()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: Host Thread
|
||||||
|
void DoFrameStep()
|
||||||
|
{
|
||||||
|
if (GetState() == State::Paused)
|
||||||
|
{
|
||||||
|
// if already paused, frame advance for 1 frame
|
||||||
|
s_frame_step = true;
|
||||||
|
RequestRefreshInfo();
|
||||||
|
SetState(State::Running);
|
||||||
|
}
|
||||||
|
else if (!s_frame_step)
|
||||||
|
{
|
||||||
|
// if not paused yet, pause immediately instead
|
||||||
|
SetState(State::Paused);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // Core
|
} // Core
|
||||||
|
|
|
@ -31,7 +31,8 @@ enum class State
|
||||||
Uninitialized,
|
Uninitialized,
|
||||||
Paused,
|
Paused,
|
||||||
Running,
|
Running,
|
||||||
Stopping
|
Stopping,
|
||||||
|
Starting,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool Init(std::unique_ptr<BootParameters> boot);
|
bool Init(std::unique_ptr<BootParameters> boot);
|
||||||
|
@ -84,8 +85,8 @@ void UpdateTitle();
|
||||||
void RunAsCPUThread(std::function<void()> function);
|
void RunAsCPUThread(std::function<void()> function);
|
||||||
|
|
||||||
// for calling back into UI code without introducing a dependency on it in core
|
// for calling back into UI code without introducing a dependency on it in core
|
||||||
using StoppedCallbackFunc = std::function<void()>;
|
using StateChangedCallbackFunc = std::function<void(Core::State)>;
|
||||||
void SetOnStoppedCallback(StoppedCallbackFunc callback);
|
void SetOnStateChangedCallback(StateChangedCallbackFunc callback);
|
||||||
|
|
||||||
// Run on the Host thread when the factors change. [NOT THREADSAFE]
|
// Run on the Host thread when the factors change. [NOT THREADSAFE]
|
||||||
void UpdateWantDeterminism(bool initial = false);
|
void UpdateWantDeterminism(bool initial = false);
|
||||||
|
@ -105,4 +106,6 @@ void QueueHostJob(std::function<void()> job, bool run_during_stop = false);
|
||||||
// WM_USER_JOB_DISPATCH will be sent when something is added to the queue.
|
// WM_USER_JOB_DISPATCH will be sent when something is added to the queue.
|
||||||
void HostDispatchJobs();
|
void HostDispatchJobs();
|
||||||
|
|
||||||
|
void DoFrameStep();
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -63,7 +63,6 @@
|
||||||
|
|
||||||
namespace Movie
|
namespace Movie
|
||||||
{
|
{
|
||||||
static bool s_bFrameStep = false;
|
|
||||||
static bool s_bReadOnly = true;
|
static bool s_bReadOnly = true;
|
||||||
static u32 s_rerecords = 0;
|
static u32 s_rerecords = 0;
|
||||||
static PlayMode s_playMode = MODE_NONE;
|
static PlayMode s_playMode = MODE_NONE;
|
||||||
|
@ -192,11 +191,6 @@ void FrameUpdate()
|
||||||
s_totalFrames = s_currentFrame;
|
s_totalFrames = s_currentFrame;
|
||||||
s_totalLagCount = s_currentLagCount;
|
s_totalLagCount = s_currentLagCount;
|
||||||
}
|
}
|
||||||
if (s_bFrameStep)
|
|
||||||
{
|
|
||||||
s_bFrameStep = false;
|
|
||||||
CPU::Break();
|
|
||||||
}
|
|
||||||
|
|
||||||
s_bPolled = false;
|
s_bPolled = false;
|
||||||
}
|
}
|
||||||
|
@ -215,7 +209,6 @@ void Init(const BootParameters& boot)
|
||||||
s_current_file_name.clear();
|
s_current_file_name.clear();
|
||||||
|
|
||||||
s_bPolled = false;
|
s_bPolled = false;
|
||||||
s_bFrameStep = false;
|
|
||||||
s_bSaveConfig = false;
|
s_bSaveConfig = false;
|
||||||
if (IsPlayingInput())
|
if (IsPlayingInput())
|
||||||
{
|
{
|
||||||
|
@ -274,23 +267,6 @@ void SetPolledDevice()
|
||||||
s_bPolled = true;
|
s_bPolled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Host Thread
|
|
||||||
void DoFrameStep()
|
|
||||||
{
|
|
||||||
if (Core::GetState() == Core::State::Paused)
|
|
||||||
{
|
|
||||||
// if already paused, frame advance for 1 frame
|
|
||||||
s_bFrameStep = true;
|
|
||||||
Core::RequestRefreshInfo();
|
|
||||||
Core::SetState(Core::State::Running);
|
|
||||||
}
|
|
||||||
else if (!s_bFrameStep)
|
|
||||||
{
|
|
||||||
// if not paused yet, pause immediately instead
|
|
||||||
Core::SetState(Core::State::Paused);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: Host Thread
|
// NOTE: Host Thread
|
||||||
void SetReadOnly(bool bEnabled)
|
void SetReadOnly(bool bEnabled)
|
||||||
{
|
{
|
||||||
|
|
|
@ -148,7 +148,6 @@ bool IsUsingBongo(int controller);
|
||||||
void ChangePads(bool instantly = false);
|
void ChangePads(bool instantly = false);
|
||||||
void ChangeWiiPads(bool instantly = false);
|
void ChangeWiiPads(bool instantly = false);
|
||||||
|
|
||||||
void DoFrameStep();
|
|
||||||
void SetReadOnly(bool bEnabled);
|
void SetReadOnly(bool bEnabled);
|
||||||
|
|
||||||
bool BeginRecordingInput(int controllers);
|
bool BeginRecordingInput(int controllers);
|
||||||
|
|
|
@ -392,7 +392,10 @@ int main(int argc, char* argv[])
|
||||||
UICommon::SetUserDirectory(user_directory);
|
UICommon::SetUserDirectory(user_directory);
|
||||||
UICommon::Init();
|
UICommon::Init();
|
||||||
|
|
||||||
Core::SetOnStoppedCallback([]() { s_running.Clear(); });
|
Core::SetOnStateChangedCallback([](Core::State state) {
|
||||||
|
if (state == Core::State::Uninitialized)
|
||||||
|
s_running.Clear();
|
||||||
|
});
|
||||||
platform->Init();
|
platform->Init();
|
||||||
|
|
||||||
// Shut down cleanly on SIGINT and SIGTERM
|
// Shut down cleanly on SIGINT and SIGTERM
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
|
#include "Core/Core.h"
|
||||||
#include "Core/HW/SI/SI.h"
|
#include "Core/HW/SI/SI.h"
|
||||||
#include "Core/HW/Wiimote.h"
|
#include "Core/HW/Wiimote.h"
|
||||||
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
||||||
|
@ -238,6 +239,9 @@ void ControllersWindow::CreateMainLayout()
|
||||||
|
|
||||||
void ControllersWindow::ConnectWidgets()
|
void ControllersWindow::ConnectWidgets()
|
||||||
{
|
{
|
||||||
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
|
||||||
|
[=](Core::State state) { OnEmulationStateChanged(state != Core::State::Uninitialized); });
|
||||||
|
|
||||||
connect(m_wiimote_passthrough, &QRadioButton::toggled, this,
|
connect(m_wiimote_passthrough, &QRadioButton::toggled, this,
|
||||||
&ControllersWindow::OnWiimoteModeChanged);
|
&ControllersWindow::OnWiimoteModeChanged);
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@ class ControllersWindow final : public QDialog
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ControllersWindow(QWidget* parent);
|
explicit ControllersWindow(QWidget* parent);
|
||||||
void OnEmulationStateChanged(bool running);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void OnEmulationStateChanged(bool running);
|
||||||
void OnWiimoteModeChanged(bool passthrough);
|
void OnWiimoteModeChanged(bool passthrough);
|
||||||
void OnWiimoteTypeChanged(int state);
|
void OnWiimoteTypeChanged(int state);
|
||||||
void OnGCTypeChanged(int state);
|
void OnGCTypeChanged(int state);
|
||||||
|
|
|
@ -11,9 +11,11 @@
|
||||||
|
|
||||||
#include "Core/Config/GraphicsSettings.h"
|
#include "Core/Config/GraphicsSettings.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
|
#include "Core/Core.h"
|
||||||
#include "DolphinQt2/Config/Graphics/GraphicsBool.h"
|
#include "DolphinQt2/Config/Graphics/GraphicsBool.h"
|
||||||
#include "DolphinQt2/Config/Graphics/GraphicsChoice.h"
|
#include "DolphinQt2/Config/Graphics/GraphicsChoice.h"
|
||||||
#include "DolphinQt2/Config/Graphics/GraphicsWindow.h"
|
#include "DolphinQt2/Config/Graphics/GraphicsWindow.h"
|
||||||
|
#include "DolphinQt2/Settings.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
AdvancedWidget::AdvancedWidget(GraphicsWindow* parent) : GraphicsWidget(parent)
|
AdvancedWidget::AdvancedWidget(GraphicsWindow* parent) : GraphicsWidget(parent)
|
||||||
|
@ -24,8 +26,8 @@ AdvancedWidget::AdvancedWidget(GraphicsWindow* parent) : GraphicsWidget(parent)
|
||||||
AddDescriptions();
|
AddDescriptions();
|
||||||
|
|
||||||
connect(parent, &GraphicsWindow::BackendChanged, this, &AdvancedWidget::OnBackendChanged);
|
connect(parent, &GraphicsWindow::BackendChanged, this, &AdvancedWidget::OnBackendChanged);
|
||||||
connect(parent, &GraphicsWindow::EmulationStarted, [this] { OnEmulationStateChanged(true); });
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
|
||||||
connect(parent, &GraphicsWindow::EmulationStopped, [this] { OnEmulationStateChanged(false); });
|
[=](Core::State state) { OnEmulationStateChanged(state != Core::State::Uninitialized); });
|
||||||
|
|
||||||
OnBackendChanged();
|
OnBackendChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,11 @@
|
||||||
|
|
||||||
#include "Core/Config/GraphicsSettings.h"
|
#include "Core/Config/GraphicsSettings.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
|
#include "Core/Core.h"
|
||||||
#include "DolphinQt2/Config/Graphics/GraphicsBool.h"
|
#include "DolphinQt2/Config/Graphics/GraphicsBool.h"
|
||||||
#include "DolphinQt2/Config/Graphics/GraphicsChoice.h"
|
#include "DolphinQt2/Config/Graphics/GraphicsChoice.h"
|
||||||
#include "DolphinQt2/Config/Graphics/GraphicsWindow.h"
|
#include "DolphinQt2/Config/Graphics/GraphicsWindow.h"
|
||||||
|
#include "DolphinQt2/Settings.h"
|
||||||
#include "UICommon/VideoUtils.h"
|
#include "UICommon/VideoUtils.h"
|
||||||
#include "VideoCommon/VideoBackendBase.h"
|
#include "VideoCommon/VideoBackendBase.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
@ -32,8 +34,8 @@ GeneralWidget::GeneralWidget(X11Utils::XRRConfiguration* xrr_config, GraphicsWin
|
||||||
emit BackendChanged(QString::fromStdString(SConfig::GetInstance().m_strVideoBackend));
|
emit BackendChanged(QString::fromStdString(SConfig::GetInstance().m_strVideoBackend));
|
||||||
|
|
||||||
connect(parent, &GraphicsWindow::BackendChanged, this, &GeneralWidget::OnBackendChanged);
|
connect(parent, &GraphicsWindow::BackendChanged, this, &GeneralWidget::OnBackendChanged);
|
||||||
connect(parent, &GraphicsWindow::EmulationStarted, [this] { OnEmulationStateChanged(true); });
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
|
||||||
connect(parent, &GraphicsWindow::EmulationStopped, [this] { OnEmulationStateChanged(false); });
|
[=](Core::State state) { OnEmulationStateChanged(state != Core::State::Uninitialized); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralWidget::CreateWidgets()
|
void GeneralWidget::CreateWidgets()
|
||||||
|
|
|
@ -29,9 +29,6 @@ GraphicsWindow::GraphicsWindow(X11Utils::XRRConfiguration* xrr_config, MainWindo
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
|
|
||||||
OnBackendChanged(QString::fromStdString(SConfig::GetInstance().m_strVideoBackend));
|
OnBackendChanged(QString::fromStdString(SConfig::GetInstance().m_strVideoBackend));
|
||||||
|
|
||||||
connect(parent, &MainWindow::EmulationStarted, this, &GraphicsWindow::EmulationStarted);
|
|
||||||
connect(parent, &MainWindow::EmulationStopped, this, &GraphicsWindow::EmulationStopped);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindow::CreateMainLayout()
|
void GraphicsWindow::CreateMainLayout()
|
||||||
|
|
|
@ -33,8 +33,6 @@ public:
|
||||||
bool eventFilter(QObject* object, QEvent* event) override;
|
bool eventFilter(QObject* object, QEvent* event) override;
|
||||||
signals:
|
signals:
|
||||||
void BackendChanged(const QString& backend);
|
void BackendChanged(const QString& backend);
|
||||||
void EmulationStarted();
|
|
||||||
void EmulationStopped();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CreateMainLayout();
|
void CreateMainLayout();
|
||||||
|
|
|
@ -40,15 +40,9 @@ SettingsWindow::SettingsWindow(QWidget* parent) : QDialog(parent)
|
||||||
|
|
||||||
AddTab(m_tabs, tr("General"), new GeneralPane(), "config");
|
AddTab(m_tabs, tr("General"), new GeneralPane(), "config");
|
||||||
AddTab(m_tabs, tr("Interface"), new InterfacePane(), "browse");
|
AddTab(m_tabs, tr("Interface"), new InterfacePane(), "browse");
|
||||||
auto* audio_pane = new AudioPane;
|
m_audio_pane_index = AddTab(m_tabs, tr("Audio"), new AudioPane(), "play");
|
||||||
m_audio_pane_index = AddTab(m_tabs, tr("Audio"), audio_pane, "play");
|
|
||||||
AddTab(m_tabs, tr("Paths"), new PathPane(), "browse");
|
AddTab(m_tabs, tr("Paths"), new PathPane(), "browse");
|
||||||
|
|
||||||
connect(this, &SettingsWindow::EmulationStarted,
|
|
||||||
[audio_pane] { audio_pane->OnEmulationStateChanged(true); });
|
|
||||||
connect(this, &SettingsWindow::EmulationStopped,
|
|
||||||
[audio_pane] { audio_pane->OnEmulationStateChanged(false); });
|
|
||||||
|
|
||||||
// Dialog box buttons
|
// Dialog box buttons
|
||||||
QDialogButtonBox* ok_box = new QDialogButtonBox(QDialogButtonBox::Ok);
|
QDialogButtonBox* ok_box = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||||
connect(ok_box, &QDialogButtonBox::accepted, this, &SettingsWindow::accept);
|
connect(ok_box, &QDialogButtonBox::accepted, this, &SettingsWindow::accept);
|
||||||
|
|
|
@ -15,10 +15,6 @@ public:
|
||||||
explicit SettingsWindow(QWidget* parent = nullptr);
|
explicit SettingsWindow(QWidget* parent = nullptr);
|
||||||
void SelectAudioPane();
|
void SelectAudioPane();
|
||||||
|
|
||||||
signals:
|
|
||||||
void EmulationStarted();
|
|
||||||
void EmulationStopped();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ListTabWidget* m_tabs;
|
ListTabWidget* m_tabs;
|
||||||
int m_audio_pane_index = -1;
|
int m_audio_pane_index = -1;
|
||||||
|
|
|
@ -174,11 +174,8 @@ void GameList::ShowContextMenu(const QPoint&)
|
||||||
|
|
||||||
QAction* change_disc = AddAction(menu, tr("Change &Disc"), this, &GameList::ChangeDisc);
|
QAction* change_disc = AddAction(menu, tr("Change &Disc"), this, &GameList::ChangeDisc);
|
||||||
|
|
||||||
connect(this, &GameList::EmulationStarted, change_disc,
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, change_disc,
|
||||||
[change_disc] { change_disc->setEnabled(true); });
|
[change_disc] { change_disc->setEnabled(Core::IsRunning()); });
|
||||||
connect(this, &GameList::EmulationStopped, change_disc,
|
|
||||||
[change_disc] { change_disc->setEnabled(false); });
|
|
||||||
|
|
||||||
change_disc->setEnabled(Core::IsRunning());
|
change_disc->setEnabled(Core::IsRunning());
|
||||||
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
@ -202,15 +199,13 @@ void GameList::ShowContextMenu(const QPoint&)
|
||||||
|
|
||||||
for (QAction* a : {wad_install_action, wad_uninstall_action})
|
for (QAction* a : {wad_install_action, wad_uninstall_action})
|
||||||
{
|
{
|
||||||
connect(this, &GameList::EmulationStarted, a, [a] { a->setEnabled(false); });
|
|
||||||
a->setEnabled(!Core::IsRunning());
|
a->setEnabled(!Core::IsRunning());
|
||||||
menu->addAction(a);
|
menu->addAction(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(this, &GameList::EmulationStopped, wad_install_action,
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, menu, [=](Core::State state) {
|
||||||
[wad_install_action] { wad_install_action->setEnabled(true); });
|
wad_install_action->setEnabled(state == Core::State::Uninitialized);
|
||||||
connect(this, &GameList::EmulationStopped, wad_uninstall_action, [wad_uninstall_action, game] {
|
wad_uninstall_action->setEnabled(state == Core::State::Uninitialized && game->IsInstalled());
|
||||||
wad_uninstall_action->setEnabled(game->IsInstalled());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
@ -231,10 +226,9 @@ void GameList::ShowContextMenu(const QPoint&)
|
||||||
connect(netplay_host, &QAction::triggered,
|
connect(netplay_host, &QAction::triggered,
|
||||||
[this, game] { emit NetPlayHost(game->GetUniqueID()); });
|
[this, game] { emit NetPlayHost(game->GetUniqueID()); });
|
||||||
|
|
||||||
connect(this, &GameList::EmulationStarted, netplay_host,
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, menu, [=](Core::State state) {
|
||||||
[netplay_host] { netplay_host->setEnabled(false); });
|
netplay_host->setEnabled(state == Core::State::Uninitialized);
|
||||||
connect(this, &GameList::EmulationStopped, netplay_host,
|
});
|
||||||
[netplay_host] { netplay_host->setEnabled(true); });
|
|
||||||
netplay_host->setEnabled(!Core::IsRunning());
|
netplay_host->setEnabled(!Core::IsRunning());
|
||||||
|
|
||||||
menu->addAction(netplay_host);
|
menu->addAction(netplay_host);
|
||||||
|
|
|
@ -29,8 +29,6 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void GameSelected();
|
void GameSelected();
|
||||||
void EmulationStarted();
|
|
||||||
void EmulationStopped();
|
|
||||||
void NetPlayHost(const QString& game_id);
|
void NetPlayHost(const QString& game_id);
|
||||||
void SelectionChanged(QSharedPointer<GameFile> game_file);
|
void SelectionChanged(QSharedPointer<GameFile> game_file);
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,10 @@ void MainWindow::ShutdownControllers()
|
||||||
|
|
||||||
void MainWindow::InitCoreCallbacks()
|
void MainWindow::InitCoreCallbacks()
|
||||||
{
|
{
|
||||||
Core::SetOnStoppedCallback([this] { emit EmulationStopped(); });
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [=](Core::State state) {
|
||||||
|
if (state == Core::State::Uninitialized)
|
||||||
|
OnStopComplete();
|
||||||
|
});
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
m_render_widget->installEventFilter(this);
|
m_render_widget->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
@ -151,11 +154,6 @@ void MainWindow::CreateComponents()
|
||||||
m_log_widget = new LogWidget(this);
|
m_log_widget = new LogWidget(this);
|
||||||
m_log_config_widget = new LogConfigWidget(this);
|
m_log_config_widget = new LogConfigWidget(this);
|
||||||
|
|
||||||
connect(this, &MainWindow::EmulationStarted, m_settings_window,
|
|
||||||
&SettingsWindow::EmulationStarted);
|
|
||||||
connect(this, &MainWindow::EmulationStopped, m_settings_window,
|
|
||||||
&SettingsWindow::EmulationStopped);
|
|
||||||
|
|
||||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||||
m_graphics_window = new GraphicsWindow(
|
m_graphics_window = new GraphicsWindow(
|
||||||
new X11Utils::XRRConfiguration(
|
new X11Utils::XRRConfiguration(
|
||||||
|
@ -232,17 +230,9 @@ void MainWindow::ConnectMenuBar()
|
||||||
|
|
||||||
connect(m_menu_bar, &MenuBar::ShowAboutDialog, this, &MainWindow::ShowAboutDialog);
|
connect(m_menu_bar, &MenuBar::ShowAboutDialog, this, &MainWindow::ShowAboutDialog);
|
||||||
|
|
||||||
connect(this, &MainWindow::EmulationStarted, m_menu_bar, &MenuBar::EmulationStarted);
|
|
||||||
connect(this, &MainWindow::EmulationPaused, m_menu_bar, &MenuBar::EmulationPaused);
|
|
||||||
connect(this, &MainWindow::EmulationStopped, m_menu_bar, &MenuBar::EmulationStopped);
|
|
||||||
connect(m_game_list, &GameList::SelectionChanged, m_menu_bar, &MenuBar::SelectionChanged);
|
connect(m_game_list, &GameList::SelectionChanged, m_menu_bar, &MenuBar::SelectionChanged);
|
||||||
connect(this, &MainWindow::ReadOnlyModeChanged, m_menu_bar, &MenuBar::ReadOnlyModeChanged);
|
connect(this, &MainWindow::ReadOnlyModeChanged, m_menu_bar, &MenuBar::ReadOnlyModeChanged);
|
||||||
connect(this, &MainWindow::RecordingStatusChanged, m_menu_bar, &MenuBar::RecordingStatusChanged);
|
connect(this, &MainWindow::RecordingStatusChanged, m_menu_bar, &MenuBar::RecordingStatusChanged);
|
||||||
|
|
||||||
connect(this, &MainWindow::EmulationStarted, this,
|
|
||||||
[=]() { m_controllers_window->OnEmulationStateChanged(true); });
|
|
||||||
connect(this, &MainWindow::EmulationStopped, this,
|
|
||||||
[=]() { m_controllers_window->OnEmulationStateChanged(false); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ConnectHotkeys()
|
void MainWindow::ConnectHotkeys()
|
||||||
|
@ -283,20 +273,12 @@ void MainWindow::ConnectToolBar()
|
||||||
connect(m_tool_bar, &ToolBar::SettingsPressed, this, &MainWindow::ShowSettingsWindow);
|
connect(m_tool_bar, &ToolBar::SettingsPressed, this, &MainWindow::ShowSettingsWindow);
|
||||||
connect(m_tool_bar, &ToolBar::ControllersPressed, this, &MainWindow::ShowControllersWindow);
|
connect(m_tool_bar, &ToolBar::ControllersPressed, this, &MainWindow::ShowControllersWindow);
|
||||||
connect(m_tool_bar, &ToolBar::GraphicsPressed, this, &MainWindow::ShowGraphicsWindow);
|
connect(m_tool_bar, &ToolBar::GraphicsPressed, this, &MainWindow::ShowGraphicsWindow);
|
||||||
|
|
||||||
connect(this, &MainWindow::EmulationStarted, m_tool_bar, &ToolBar::EmulationStarted);
|
|
||||||
connect(this, &MainWindow::EmulationPaused, m_tool_bar, &ToolBar::EmulationPaused);
|
|
||||||
connect(this, &MainWindow::EmulationStopped, m_tool_bar, &ToolBar::EmulationStopped);
|
|
||||||
|
|
||||||
connect(this, &MainWindow::EmulationStopped, this, &MainWindow::OnStopComplete);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ConnectGameList()
|
void MainWindow::ConnectGameList()
|
||||||
{
|
{
|
||||||
connect(m_game_list, &GameList::GameSelected, this, &MainWindow::Play);
|
connect(m_game_list, &GameList::GameSelected, this, &MainWindow::Play);
|
||||||
connect(m_game_list, &GameList::NetPlayHost, this, &MainWindow::NetPlayHost);
|
connect(m_game_list, &GameList::NetPlayHost, this, &MainWindow::NetPlayHost);
|
||||||
connect(this, &MainWindow::EmulationStarted, m_game_list, &GameList::EmulationStarted);
|
|
||||||
connect(this, &MainWindow::EmulationStopped, m_game_list, &GameList::EmulationStopped);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ConnectRenderWidget()
|
void MainWindow::ConnectRenderWidget()
|
||||||
|
@ -340,7 +322,6 @@ void MainWindow::Play()
|
||||||
if (Core::GetState() == Core::State::Paused)
|
if (Core::GetState() == Core::State::Paused)
|
||||||
{
|
{
|
||||||
Core::SetState(Core::State::Running);
|
Core::SetState(Core::State::Running);
|
||||||
emit EmulationStarted();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -367,7 +348,6 @@ void MainWindow::Play()
|
||||||
void MainWindow::Pause()
|
void MainWindow::Pause()
|
||||||
{
|
{
|
||||||
Core::SetState(Core::State::Paused);
|
Core::SetState(Core::State::Paused);
|
||||||
emit EmulationPaused();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::OnStopComplete()
|
void MainWindow::OnStopComplete()
|
||||||
|
@ -457,8 +437,7 @@ void MainWindow::Reset()
|
||||||
|
|
||||||
void MainWindow::FrameAdvance()
|
void MainWindow::FrameAdvance()
|
||||||
{
|
{
|
||||||
Movie::DoFrameStep();
|
Core::DoFrameStep();
|
||||||
EmulationPaused();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::FullScreen()
|
void MainWindow::FullScreen()
|
||||||
|
@ -503,7 +482,6 @@ void MainWindow::StartGame(std::unique_ptr<BootParameters>&& parameters)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ShowRenderWidget();
|
ShowRenderWidget();
|
||||||
emit EmulationStarted();
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// Prevents Windows from sleeping, turning off the display, or idling
|
// Prevents Windows from sleeping, turning off the display, or idling
|
||||||
|
@ -680,7 +658,6 @@ void MainWindow::NetPlayInit()
|
||||||
static_cast<void (MainWindow::*)(const QString&)>(&MainWindow::StartGame));
|
static_cast<void (MainWindow::*)(const QString&)>(&MainWindow::StartGame));
|
||||||
connect(m_netplay_dialog, &NetPlayDialog::Stop, this, &MainWindow::RequestStop);
|
connect(m_netplay_dialog, &NetPlayDialog::Stop, this, &MainWindow::RequestStop);
|
||||||
connect(m_netplay_dialog, &NetPlayDialog::rejected, this, &MainWindow::NetPlayQuit);
|
connect(m_netplay_dialog, &NetPlayDialog::rejected, this, &MainWindow::NetPlayQuit);
|
||||||
connect(this, &MainWindow::EmulationStopped, m_netplay_dialog, &NetPlayDialog::EmulationStopped);
|
|
||||||
connect(m_netplay_setup_dialog, &NetPlaySetupDialog::Join, this, &MainWindow::NetPlayJoin);
|
connect(m_netplay_setup_dialog, &NetPlaySetupDialog::Join, this, &MainWindow::NetPlayJoin);
|
||||||
connect(m_netplay_setup_dialog, &NetPlaySetupDialog::Host, this, &MainWindow::NetPlayHost);
|
connect(m_netplay_setup_dialog, &NetPlaySetupDialog::Host, this, &MainWindow::NetPlayHost);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,9 +41,6 @@ public:
|
||||||
bool eventFilter(QObject* object, QEvent* event) override;
|
bool eventFilter(QObject* object, QEvent* event) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void EmulationStarted();
|
|
||||||
void EmulationPaused();
|
|
||||||
void EmulationStopped();
|
|
||||||
void ReadOnlyModeChanged(bool read_only);
|
void ReadOnlyModeChanged(bool read_only);
|
||||||
void RecordingStatusChanged(bool recording);
|
void RecordingStatusChanged(bool recording);
|
||||||
|
|
||||||
|
|
|
@ -38,64 +38,42 @@ MenuBar::MenuBar(QWidget* parent) : QMenuBar(parent)
|
||||||
AddViewMenu();
|
AddViewMenu();
|
||||||
AddHelpMenu();
|
AddHelpMenu();
|
||||||
|
|
||||||
EmulationStopped();
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
|
||||||
|
[=](Core::State state) { OnEmulationStateChanged(state); });
|
||||||
|
OnEmulationStateChanged(Core::GetState());
|
||||||
|
|
||||||
connect(this, &MenuBar::SelectionChanged, this, &MenuBar::OnSelectionChanged);
|
connect(this, &MenuBar::SelectionChanged, this, &MenuBar::OnSelectionChanged);
|
||||||
connect(this, &MenuBar::RecordingStatusChanged, this, &MenuBar::OnRecordingStatusChanged);
|
connect(this, &MenuBar::RecordingStatusChanged, this, &MenuBar::OnRecordingStatusChanged);
|
||||||
connect(this, &MenuBar::ReadOnlyModeChanged, this, &MenuBar::OnReadOnlyModeChanged);
|
connect(this, &MenuBar::ReadOnlyModeChanged, this, &MenuBar::OnReadOnlyModeChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuBar::EmulationStarted()
|
void MenuBar::OnEmulationStateChanged(Core::State state)
|
||||||
{
|
{
|
||||||
|
bool running = state != Core::State::Uninitialized;
|
||||||
|
bool playing = running && state != Core::State::Paused;
|
||||||
|
|
||||||
// Emulation
|
// Emulation
|
||||||
m_play_action->setEnabled(false);
|
m_play_action->setEnabled(!playing);
|
||||||
m_play_action->setVisible(false);
|
m_play_action->setVisible(!playing);
|
||||||
m_pause_action->setEnabled(true);
|
m_pause_action->setEnabled(playing);
|
||||||
m_pause_action->setVisible(true);
|
m_pause_action->setVisible(playing);
|
||||||
m_stop_action->setEnabled(true);
|
m_stop_action->setEnabled(running);
|
||||||
m_reset_action->setEnabled(true);
|
m_stop_action->setVisible(running);
|
||||||
m_fullscreen_action->setEnabled(true);
|
m_reset_action->setEnabled(running);
|
||||||
m_frame_advance_action->setEnabled(true);
|
m_fullscreen_action->setEnabled(running);
|
||||||
m_screenshot_action->setEnabled(true);
|
m_frame_advance_action->setEnabled(running);
|
||||||
m_state_load_menu->setEnabled(true);
|
m_screenshot_action->setEnabled(running);
|
||||||
m_state_save_menu->setEnabled(true);
|
m_state_load_menu->setEnabled(running);
|
||||||
|
m_state_save_menu->setEnabled(running);
|
||||||
|
|
||||||
// Movie
|
// Movie
|
||||||
m_recording_read_only->setEnabled(true);
|
m_recording_read_only->setEnabled(running);
|
||||||
m_recording_play->setEnabled(false);
|
if (!running)
|
||||||
|
|
||||||
UpdateStateSlotMenu();
|
|
||||||
UpdateToolsMenu(true);
|
|
||||||
}
|
|
||||||
void MenuBar::EmulationPaused()
|
|
||||||
{
|
|
||||||
m_play_action->setEnabled(true);
|
|
||||||
m_play_action->setVisible(true);
|
|
||||||
m_pause_action->setEnabled(false);
|
|
||||||
m_pause_action->setVisible(false);
|
|
||||||
}
|
|
||||||
void MenuBar::EmulationStopped()
|
|
||||||
{
|
|
||||||
// Emulation
|
|
||||||
m_play_action->setEnabled(true);
|
|
||||||
m_play_action->setVisible(true);
|
|
||||||
m_pause_action->setEnabled(false);
|
|
||||||
m_pause_action->setVisible(false);
|
|
||||||
m_stop_action->setEnabled(false);
|
|
||||||
m_reset_action->setEnabled(false);
|
|
||||||
m_fullscreen_action->setEnabled(false);
|
|
||||||
m_frame_advance_action->setEnabled(false);
|
|
||||||
m_screenshot_action->setEnabled(false);
|
|
||||||
m_state_load_menu->setEnabled(false);
|
|
||||||
m_state_save_menu->setEnabled(false);
|
|
||||||
|
|
||||||
// Movie
|
|
||||||
m_recording_read_only->setEnabled(false);
|
|
||||||
m_recording_stop->setEnabled(false);
|
m_recording_stop->setEnabled(false);
|
||||||
m_recording_play->setEnabled(false);
|
m_recording_play->setEnabled(!running);
|
||||||
|
|
||||||
UpdateStateSlotMenu();
|
UpdateStateSlotMenu();
|
||||||
UpdateToolsMenu(false);
|
UpdateToolsMenu(running);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuBar::AddFileMenu()
|
void MenuBar::AddFileMenu()
|
||||||
|
|
|
@ -9,13 +9,18 @@
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
|
|
||||||
|
#include "DolphinQt2/GameList/GameFile.h"
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
enum class State;
|
||||||
|
}
|
||||||
|
|
||||||
namespace DiscIO
|
namespace DiscIO
|
||||||
{
|
{
|
||||||
enum class Region;
|
enum class Region;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "DolphinQt2/GameList/GameFile.h"
|
|
||||||
|
|
||||||
class MenuBar final : public QMenuBar
|
class MenuBar final : public QMenuBar
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -23,9 +28,6 @@ class MenuBar final : public QMenuBar
|
||||||
public:
|
public:
|
||||||
explicit MenuBar(QWidget* parent = nullptr);
|
explicit MenuBar(QWidget* parent = nullptr);
|
||||||
|
|
||||||
void EmulationStarted();
|
|
||||||
void EmulationPaused();
|
|
||||||
void EmulationStopped();
|
|
||||||
void UpdateStateSlotMenu();
|
void UpdateStateSlotMenu();
|
||||||
void UpdateToolsMenu(bool emulation_started);
|
void UpdateToolsMenu(bool emulation_started);
|
||||||
|
|
||||||
|
@ -88,6 +90,8 @@ signals:
|
||||||
void ReadOnlyModeChanged(bool read_only);
|
void ReadOnlyModeChanged(bool read_only);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void OnEmulationStateChanged(Core::State state);
|
||||||
|
|
||||||
void AddFileMenu();
|
void AddFileMenu();
|
||||||
|
|
||||||
void AddEmulationMenu();
|
void AddEmulationMenu();
|
||||||
|
|
|
@ -188,8 +188,8 @@ void NetPlayDialog::ConnectWidgets()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(this, &NetPlayDialog::EmulationStopped, this, [this] {
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [=](Core::State state) {
|
||||||
if (isVisible())
|
if (state == Core::State::Uninitialized && isVisible())
|
||||||
GameStatusChanged(false);
|
GameStatusChanged(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,6 @@ public:
|
||||||
void SetMD5Result(int pid, const std::string& result) override;
|
void SetMD5Result(int pid, const std::string& result) override;
|
||||||
void AbortMD5() override;
|
void AbortMD5() override;
|
||||||
signals:
|
signals:
|
||||||
void EmulationStopped();
|
|
||||||
void Boot(const QString& filename);
|
void Boot(const QString& filename);
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,16 @@
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
|
#include "Core/Core.h"
|
||||||
#include "DolphinQt2/GameList/GameListModel.h"
|
#include "DolphinQt2/GameList/GameListModel.h"
|
||||||
#include "DolphinQt2/Settings.h"
|
#include "DolphinQt2/Settings.h"
|
||||||
#include "InputCommon/InputConfig.h"
|
#include "InputCommon/InputConfig.h"
|
||||||
|
|
||||||
Settings::Settings() = default;
|
Settings::Settings()
|
||||||
|
{
|
||||||
|
Core::SetOnStateChangedCallback(
|
||||||
|
[this](Core::State new_state) { emit EmulationStateChanged(new_state); });
|
||||||
|
}
|
||||||
|
|
||||||
Settings& Settings::Instance()
|
Settings& Settings::Instance()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,6 +12,11 @@
|
||||||
#include "Core/NetPlayClient.h"
|
#include "Core/NetPlayClient.h"
|
||||||
#include "Core/NetPlayServer.h"
|
#include "Core/NetPlayServer.h"
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
enum class State;
|
||||||
|
}
|
||||||
|
|
||||||
namespace DiscIO
|
namespace DiscIO
|
||||||
{
|
{
|
||||||
enum class Language;
|
enum class Language;
|
||||||
|
@ -76,6 +81,7 @@ public:
|
||||||
GameListModel* GetGameListModel() const;
|
GameListModel* GetGameListModel() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void EmulationStateChanged(Core::State new_state);
|
||||||
void ThemeChanged();
|
void ThemeChanged();
|
||||||
void PathAdded(const QString&);
|
void PathAdded(const QString&);
|
||||||
void PathRemoved(const QString&);
|
void PathRemoved(const QString&);
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "AudioCommon/AudioCommon.h"
|
#include "AudioCommon/AudioCommon.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
|
#include "Core/Core.h"
|
||||||
#include "DolphinQt2/Config/SettingsWindow.h"
|
#include "DolphinQt2/Config/SettingsWindow.h"
|
||||||
#include "DolphinQt2/Settings.h"
|
#include "DolphinQt2/Settings.h"
|
||||||
|
|
||||||
|
@ -28,6 +29,8 @@ AudioPane::AudioPane()
|
||||||
ConnectWidgets();
|
ConnectWidgets();
|
||||||
|
|
||||||
connect(&Settings::Instance(), &Settings::VolumeChanged, this, &AudioPane::OnVolumeChanged);
|
connect(&Settings::Instance(), &Settings::VolumeChanged, this, &AudioPane::OnVolumeChanged);
|
||||||
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
|
||||||
|
[=](Core::State state) { OnEmulationStateChanged(state != Core::State::Uninitialized); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioPane::CreateWidgets()
|
void AudioPane::CreateWidgets()
|
||||||
|
|
|
@ -21,8 +21,6 @@ class AudioPane final : public QWidget
|
||||||
public:
|
public:
|
||||||
explicit AudioPane();
|
explicit AudioPane();
|
||||||
|
|
||||||
void OnEmulationStateChanged(bool running);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CreateWidgets();
|
void CreateWidgets();
|
||||||
void ConnectWidgets();
|
void ConnectWidgets();
|
||||||
|
@ -30,6 +28,7 @@ private:
|
||||||
void LoadSettings();
|
void LoadSettings();
|
||||||
void SaveSettings();
|
void SaveSettings();
|
||||||
|
|
||||||
|
void OnEmulationStateChanged(bool running);
|
||||||
void OnBackendChanged();
|
void OnBackendChanged();
|
||||||
void OnVolumeChanged(int volume);
|
void OnVolumeChanged(int volume);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
|
#include "Core/Core.h"
|
||||||
#include "DolphinQt2/QtUtils/ActionHelper.h"
|
#include "DolphinQt2/QtUtils/ActionHelper.h"
|
||||||
#include "DolphinQt2/Resources.h"
|
#include "DolphinQt2/Resources.h"
|
||||||
#include "DolphinQt2/Settings.h"
|
#include "DolphinQt2/Settings.h"
|
||||||
|
@ -22,40 +23,24 @@ ToolBar::ToolBar(QWidget* parent) : QToolBar(parent)
|
||||||
connect(&Settings::Instance(), &Settings::ThemeChanged, this, &ToolBar::UpdateIcons);
|
connect(&Settings::Instance(), &Settings::ThemeChanged, this, &ToolBar::UpdateIcons);
|
||||||
UpdateIcons();
|
UpdateIcons();
|
||||||
|
|
||||||
EmulationStopped();
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
|
||||||
|
[this](Core::State state) { OnEmulationStateChanged(state); });
|
||||||
|
OnEmulationStateChanged(Core::GetState());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolBar::EmulationStarted()
|
void ToolBar::OnEmulationStateChanged(Core::State state)
|
||||||
{
|
{
|
||||||
m_play_action->setEnabled(false);
|
bool running = state != Core::State::Uninitialized;
|
||||||
m_play_action->setVisible(false);
|
m_stop_action->setEnabled(running);
|
||||||
m_pause_action->setEnabled(true);
|
m_stop_action->setVisible(running);
|
||||||
m_pause_action->setVisible(true);
|
m_fullscreen_action->setEnabled(running);
|
||||||
m_stop_action->setEnabled(true);
|
m_screenshot_action->setEnabled(running);
|
||||||
m_stop_action->setVisible(true);
|
|
||||||
m_fullscreen_action->setEnabled(true);
|
|
||||||
m_screenshot_action->setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolBar::EmulationPaused()
|
bool playing = running && state != Core::State::Paused;
|
||||||
{
|
m_play_action->setEnabled(!playing);
|
||||||
m_play_action->setEnabled(true);
|
m_play_action->setVisible(!playing);
|
||||||
m_play_action->setVisible(true);
|
m_pause_action->setEnabled(playing);
|
||||||
m_pause_action->setEnabled(false);
|
m_pause_action->setVisible(playing);
|
||||||
m_pause_action->setVisible(false);
|
|
||||||
m_stop_action->setEnabled(true);
|
|
||||||
m_stop_action->setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolBar::EmulationStopped()
|
|
||||||
{
|
|
||||||
m_play_action->setEnabled(true);
|
|
||||||
m_play_action->setVisible(true);
|
|
||||||
m_pause_action->setEnabled(false);
|
|
||||||
m_pause_action->setVisible(false);
|
|
||||||
m_stop_action->setEnabled(false);
|
|
||||||
m_fullscreen_action->setEnabled(false);
|
|
||||||
m_screenshot_action->setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolBar::MakeActions()
|
void ToolBar::MakeActions()
|
||||||
|
|
|
@ -8,6 +8,11 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
enum class State;
|
||||||
|
}
|
||||||
|
|
||||||
class ToolBar final : public QToolBar
|
class ToolBar final : public QToolBar
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -15,11 +20,6 @@ class ToolBar final : public QToolBar
|
||||||
public:
|
public:
|
||||||
explicit ToolBar(QWidget* parent = nullptr);
|
explicit ToolBar(QWidget* parent = nullptr);
|
||||||
|
|
||||||
public slots:
|
|
||||||
void EmulationStarted();
|
|
||||||
void EmulationPaused();
|
|
||||||
void EmulationStopped();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void OpenPressed();
|
void OpenPressed();
|
||||||
void PlayPressed();
|
void PlayPressed();
|
||||||
|
@ -33,6 +33,8 @@ signals:
|
||||||
void GraphicsPressed();
|
void GraphicsPressed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void OnEmulationStateChanged(Core::State state);
|
||||||
|
|
||||||
void MakeActions();
|
void MakeActions();
|
||||||
void UpdateIcons();
|
void UpdateIcons();
|
||||||
|
|
||||||
|
|
|
@ -530,7 +530,8 @@ void CFrame::InitializeCoreCallbacks()
|
||||||
});
|
});
|
||||||
|
|
||||||
// Warning: this gets called from the EmuThread
|
// Warning: this gets called from the EmuThread
|
||||||
Core::SetOnStoppedCallback([this] {
|
Core::SetOnStateChangedCallback([this](Core::State state) {
|
||||||
|
if (state == Core::State::Uninitialized)
|
||||||
AddPendingEvent(wxCommandEvent{wxEVT_HOST_COMMAND, IDM_STOPPED});
|
AddPendingEvent(wxCommandEvent{wxEVT_HOST_COMMAND, IDM_STOPPED});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -446,7 +446,7 @@ void CFrame::OnFrameStep(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
bool wasPaused = Core::GetState() == Core::State::Paused;
|
bool wasPaused = Core::GetState() == Core::State::Paused;
|
||||||
|
|
||||||
Movie::DoFrameStep();
|
Core::DoFrameStep();
|
||||||
|
|
||||||
bool isPaused = Core::GetState() == Core::State::Paused;
|
bool isPaused = Core::GetState() == Core::State::Paused;
|
||||||
if (isPaused && !wasPaused) // don't update on unpause, otherwise the status would be wrong when
|
if (isPaused && !wasPaused) // don't update on unpause, otherwise the status would be wrong when
|
||||||
|
|
|
@ -179,7 +179,7 @@ void Init()
|
||||||
if (s_handle != nullptr)
|
if (s_handle != nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Core::GetState() != Core::State::Uninitialized)
|
if (Core::GetState() != Core::State::Uninitialized && Core::GetState() != Core::State::Starting)
|
||||||
{
|
{
|
||||||
if ((CoreTiming::GetTicks() - s_last_init) < SystemTimers::GetTicksPerSecond())
|
if ((CoreTiming::GetTicks() - s_last_init) < SystemTimers::GetTicksPerSecond())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -195,7 +195,7 @@ void Init()
|
||||||
if (s_fd)
|
if (s_fd)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Core::GetState() != Core::State::Uninitialized)
|
if (Core::GetState() != Core::State::Uninitialized && Core::GetState() != Core::State::Starting)
|
||||||
{
|
{
|
||||||
if ((CoreTiming::GetTicks() - s_last_init) < SystemTimers::GetTicksPerSecond())
|
if ((CoreTiming::GetTicks() - s_last_init) < SystemTimers::GetTicksPerSecond())
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue