rsx/overlays: Introduce 'native' HUD UI and implement some common dialogs (#4011)

This commit is contained in:
kd-11 2018-01-17 19:14:00 +03:00 committed by GitHub
parent 34c49c77b2
commit 71f69d1d48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 3682 additions and 213 deletions

View file

@ -2,6 +2,7 @@
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "Emu/Cell/PPUModule.h"
#include "Emu/RSX/GSRender.h"
#include "cellSysutil.h"
#include "cellMsgDialog.h"
@ -60,13 +61,6 @@ s32 cellMsgDialogOpen2(u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDialog
default: return CELL_MSGDIALOG_ERROR_PARAM;
}
const auto dlg = fxm::import<MsgDialogBase>(Emu.GetCallbacks().get_msg_dialog);
if (!dlg)
{
return CELL_SYSUTIL_ERROR_BUSY;
}
if (_type.se_mute_on)
{
// TODO
@ -81,6 +75,33 @@ s32 cellMsgDialogOpen2(u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDialog
cellSysutil.error(msgString.get_ptr());
}
if (auto rsxthr = fxm::get<GSRender>())
{
if (auto dlg = rsxthr->shell_open_message_dialog())
{
dlg->show(msgString.get_ptr(), _type, [callback, userData](s32 status)
{
if (callback)
{
sysutil_register_cb([=](ppu_thread& ppu) -> s32
{
callback(ppu, status, userData);
return CELL_OK;
});
}
});
return CELL_OK;
}
}
const auto dlg = fxm::import<MsgDialogBase>(Emu.GetCallbacks().get_msg_dialog);
if (!dlg)
{
return CELL_SYSUTIL_ERROR_BUSY;
}
dlg->type = _type;
dlg->on_close = [callback, userData, wptr = std::weak_ptr<MsgDialogBase>(dlg)](s32 status)
@ -213,6 +234,33 @@ s32 cellMsgDialogClose(f32 delay)
{
cellSysutil.warning("cellMsgDialogClose(delay=%f)", delay);
extern u64 get_system_time();
const u64 wait_until = get_system_time() + static_cast<s64>(std::max<float>(delay, 0.0f) * 1000);
if (auto rsxthr = fxm::get<GSRender>())
{
if (auto dlg = rsxthr->shell_get_current_dialog())
{
thread_ctrl::spawn("cellMsgDialogClose() Thread", [=]
{
while (get_system_time() < wait_until)
{
if (Emu.IsStopped())
return;
if (rsxthr->shell_get_current_dialog() != dlg)
return;
std::this_thread::sleep_for(1ms);
}
dlg->close();
});
return CELL_OK;
}
}
const auto dlg = fxm::get<MsgDialogBase>();
if (!dlg)
@ -220,10 +268,6 @@ s32 cellMsgDialogClose(f32 delay)
return CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED;
}
extern u64 get_system_time();
const u64 wait_until = get_system_time() + static_cast<s64>(std::max<float>(delay, 0.0f) * 1000);
thread_ctrl::spawn("cellMsgDialogClose() Thread", [=]()
{
while (dlg->state == MsgDialogState::Open && get_system_time() < wait_until)
@ -243,6 +287,14 @@ s32 cellMsgDialogAbort()
{
cellSysutil.warning("cellMsgDialogAbort()");
if (auto rsxthr = fxm::get<GSRender>())
{
if (rsxthr->shell_close_dialog())
{
return CELL_OK;
}
}
const auto dlg = fxm::get<MsgDialogBase>();
if (!dlg)
@ -263,6 +315,15 @@ s32 cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, vm::cptr<char> msgStrin
{
cellSysutil.warning("cellMsgDialogProgressBarSetMsg(progressBarIndex=%d, msgString=%s)", progressBarIndex, msgString);
if (auto rsxthr = fxm::get<GSRender>())
{
if (auto dlg2 = rsxthr->shell_get_current_dialog())
{
if (auto casted = dynamic_cast<rsx::overlays::message_dialog*>(dlg2))
return casted->progress_bar_set_message(progressBarIndex, msgString.get_ptr());
}
}
const auto dlg = fxm::get<MsgDialogBase>();
if (!dlg)
@ -287,6 +348,15 @@ s32 cellMsgDialogProgressBarReset(u32 progressBarIndex)
{
cellSysutil.warning("cellMsgDialogProgressBarReset(progressBarIndex=%d)", progressBarIndex);
if (auto rsxthr = fxm::get<GSRender>())
{
if (auto dlg2 = rsxthr->shell_get_current_dialog())
{
if (auto casted = dynamic_cast<rsx::overlays::message_dialog*>(dlg2))
return casted->progress_bar_reset(progressBarIndex);
}
}
const auto dlg = fxm::get<MsgDialogBase>();
if (!dlg)
@ -311,6 +381,15 @@ s32 cellMsgDialogProgressBarInc(u32 progressBarIndex, u32 delta)
{
cellSysutil.warning("cellMsgDialogProgressBarInc(progressBarIndex=%d, delta=%d)", progressBarIndex, delta);
if (auto rsxthr = fxm::get<GSRender>())
{
if (auto dlg2 = rsxthr->shell_get_current_dialog())
{
if (auto casted = dynamic_cast<rsx::overlays::message_dialog*>(dlg2))
return casted->progress_bar_increment(progressBarIndex, (f32)delta);
}
}
const auto dlg = fxm::get<MsgDialogBase>();
if (!dlg)