mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-10 06:40:49 +00:00
Core: SetOnStoppedCallback -> SetOnStateChangedCallback
This commit is contained in:
parent
22a9a08b24
commit
8e805dcbf4
@ -98,7 +98,7 @@ 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;
|
||||||
@ -455,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 ----");
|
||||||
}};
|
}};
|
||||||
@ -685,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()
|
||||||
@ -869,6 +874,8 @@ void Callback_VideoCopiedToXFB(bool video_update)
|
|||||||
{
|
{
|
||||||
s_frame_step = false;
|
s_frame_step = false;
|
||||||
CPU::Break();
|
CPU::Break();
|
||||||
|
if (s_on_state_changed_callback)
|
||||||
|
s_on_state_changed_callback(Core::GetState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -962,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)
|
||||||
|
@ -85,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);
|
||||||
|
@ -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
|
||||||
|
@ -121,7 +121,10 @@ void MainWindow::ShutdownControllers()
|
|||||||
|
|
||||||
void MainWindow::InitCoreCallbacks()
|
void MainWindow::InitCoreCallbacks()
|
||||||
{
|
{
|
||||||
Core::SetOnStoppedCallback([this] { emit EmulationStopped(); });
|
Core::SetOnStateChangedCallback([=](Core::State state) {
|
||||||
|
if (state == Core::State::Uninitialized)
|
||||||
|
emit EmulationStopped();
|
||||||
|
});
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
m_render_widget->installEventFilter(this);
|
m_render_widget->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
@ -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});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user