sceNp: implement sceNpBasicAbortGui

This commit is contained in:
Megamouse 2024-02-03 10:30:11 +01:00
parent e13a671f86
commit 8bc3a39586
7 changed files with 84 additions and 5 deletions

View file

@ -2,7 +2,11 @@
#include <QHBoxLayout>
#include <QPushButton>
#include <QMessageBox>
#include <QTimer>
#include "sendmessage_dialog_frame.h"
#include "Emu/IdManager.h"
#include "Emu/System.h"
#include "util/logs.hpp"
@ -91,6 +95,31 @@ error_code sendmessage_dialog_frame::Exec(message_data& msg_data, std::set<std::
}
}
auto& nps = g_fxo->get<np_state>();
QTimer timer;
connect(&timer, &QTimer::timeout, this, [this, &nps, &timer]()
{
bool abort = Emu.IsStopped();
if (!abort && nps.abort_gui_flag.exchange(false))
{
sendmessage_dlg_log.warning("Aborted by sceNp!");
abort = true;
}
if (abort)
{
if (m_dialog)
{
m_dialog->close();
}
timer.stop();
}
});
timer.start(10ms);
m_dialog->exec();
m_rpcn->remove_friend_cb(sendmessage_friend_callback, this);