mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 11:36:13 +00:00
cellMsgDialog code moved
This commit is contained in:
parent
21e254d05f
commit
56ba26ab24
9 changed files with 263 additions and 158 deletions
|
@ -3,11 +3,6 @@
|
|||
#include "Emu/System.h"
|
||||
#include "Emu/SysCalls/Modules.h"
|
||||
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/gauge.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/button.h>
|
||||
#include "Utilities/rMsgBox.h"
|
||||
#include "Emu/SysCalls/lv2/sys_time.h"
|
||||
#include "cellSysutil.h"
|
||||
|
@ -24,20 +19,53 @@ enum MsgDialogState
|
|||
};
|
||||
|
||||
std::atomic<MsgDialogState> g_msg_dialog_state(msgDialogNone);
|
||||
wxDialog* g_msg_dialog = nullptr;
|
||||
wxGauge* m_gauge1 = nullptr;
|
||||
wxGauge* m_gauge2 = nullptr;
|
||||
wxStaticText* m_text1 = nullptr;
|
||||
wxStaticText* m_text2 = nullptr;
|
||||
u64 m_wait_until;
|
||||
u64 g_msg_dialog_wait_until;
|
||||
u32 g_msg_dialog_progress_bar_count;
|
||||
|
||||
MsgDialogCreateCb MsgDialogCreate = nullptr;
|
||||
MsgDialogDestroyCb MsgDialogDestroy = nullptr;
|
||||
MsgDialogProgressBarSetMsgCb MsgDialogProgressBarSetMsg = nullptr;
|
||||
MsgDialogProgressBarResetCb MsgDialogProgressBarReset = nullptr;
|
||||
MsgDialogProgressBarIncCb MsgDialogProgressBarInc = nullptr;
|
||||
|
||||
void SetMsgDialogCreateCallback(MsgDialogCreateCb cb)
|
||||
{
|
||||
MsgDialogCreate = cb;
|
||||
}
|
||||
|
||||
void SetMsgDialogDestroyCallback(MsgDialogDestroyCb cb)
|
||||
{
|
||||
MsgDialogDestroy = cb;
|
||||
}
|
||||
|
||||
void SetMsgDialogProgressBarSetMsgCallback(MsgDialogProgressBarSetMsgCb cb)
|
||||
{
|
||||
MsgDialogProgressBarSetMsg = cb;
|
||||
}
|
||||
|
||||
void SetMsgDialogProgressBarResetCallback(MsgDialogProgressBarResetCb cb)
|
||||
{
|
||||
MsgDialogProgressBarReset = cb;
|
||||
}
|
||||
|
||||
void SetMsgDialogProgressBarIncCallback(MsgDialogProgressBarIncCb cb)
|
||||
{
|
||||
MsgDialogProgressBarInc = cb;
|
||||
}
|
||||
|
||||
void MsgDialogClose()
|
||||
{
|
||||
g_msg_dialog_state = msgDialogClose;
|
||||
g_msg_dialog_wait_until = get_system_time();
|
||||
}
|
||||
|
||||
int cellMsgDialogOpen2(u32 type, mem_list_ptr_t<u8> msgString, mem_func_ptr_t<CellMsgDialogCallback> callback, u32 userData, u32 extParam)
|
||||
{
|
||||
cellSysutil->Warning("cellMsgDialogOpen2(type=0x%x, msgString_addr=0x%x, callback_addr=0x%x, userData=0x%x, extParam=0x%x)",
|
||||
type, msgString.GetAddr(), callback.GetAddr(), userData, extParam);
|
||||
|
||||
//type |= CELL_MSGDIALOG_TYPE_PROGRESSBAR_SINGLE;
|
||||
//type |= CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO;
|
||||
//type |= CELL_MSGDIALOG_TYPE_PROGRESSBAR_SINGLE | CELL_MSGDIALOG_TYPE_BG_INVISIBLE;
|
||||
//type |= CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO | CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR_NO;
|
||||
|
||||
MsgDialogState old = msgDialogNone;
|
||||
if (!g_msg_dialog_state.compare_exchange_strong(old, msgDialogOpen))
|
||||
|
@ -45,6 +73,15 @@ int cellMsgDialogOpen2(u32 type, mem_list_ptr_t<u8> msgString, mem_func_ptr_t<Ce
|
|||
return CELL_SYSUTIL_ERROR_BUSY;
|
||||
}
|
||||
|
||||
g_msg_dialog_wait_until = get_system_time() + 31536000000000ull; // some big value
|
||||
|
||||
switch (type & CELL_MSGDIALOG_TYPE_PROGRESSBAR)
|
||||
{
|
||||
case CELL_MSGDIALOG_TYPE_PROGRESSBAR_DOUBLE: g_msg_dialog_progress_bar_count = 2; break;
|
||||
case CELL_MSGDIALOG_TYPE_PROGRESSBAR_SINGLE: g_msg_dialog_progress_bar_count = 1; break;
|
||||
default: g_msg_dialog_progress_bar_count = 0; break; // ???
|
||||
}
|
||||
|
||||
thread t("MsgDialog thread", [=]()
|
||||
{
|
||||
switch (type & CELL_MSGDIALOG_TYPE_SE_TYPE)
|
||||
|
@ -59,124 +96,12 @@ int cellMsgDialogOpen2(u32 type, mem_list_ptr_t<u8> msgString, mem_func_ptr_t<Ce
|
|||
case CELL_MSGDIALOG_TYPE_SE_MUTE_ON: break;
|
||||
}
|
||||
|
||||
switch (type & CELL_MSGDIALOG_TYPE_BG) // TODO
|
||||
{
|
||||
case CELL_MSGDIALOG_TYPE_BG_INVISIBLE: break;
|
||||
case CELL_MSGDIALOG_TYPE_BG_VISIBLE: break;
|
||||
}
|
||||
|
||||
switch (type & CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR) // TODO
|
||||
{
|
||||
case CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR_NO: break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
u64 status = CELL_MSGDIALOG_BUTTON_NONE;
|
||||
|
||||
volatile bool m_signal = false;
|
||||
CallAfter([&]()
|
||||
{
|
||||
wxWindow* parent = nullptr; // TODO: align it better
|
||||
|
||||
m_gauge1 = nullptr;
|
||||
m_gauge2 = nullptr;
|
||||
m_text1 = nullptr;
|
||||
m_text2 = nullptr;
|
||||
wxButton* m_button_ok = nullptr;
|
||||
wxButton* m_button_yes = nullptr;
|
||||
wxButton* m_button_no = nullptr;
|
||||
|
||||
g_msg_dialog = new wxDialog(parent, wxID_ANY, type & CELL_MSGDIALOG_TYPE_SE_TYPE ? "" : "Error", wxDefaultPosition, wxDefaultSize);
|
||||
|
||||
g_msg_dialog->SetExtraStyle(g_msg_dialog->GetExtraStyle() | wxWS_EX_TRANSIENT);
|
||||
|
||||
wxSizer* sizer1 = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
wxStaticText* m_text = new wxStaticText(g_msg_dialog, wxID_ANY, wxString(msgString.GetString(), wxConvUTF8));
|
||||
sizer1->Add(m_text, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 16);
|
||||
|
||||
switch (type & CELL_MSGDIALOG_TYPE_PROGRESSBAR)
|
||||
{
|
||||
case CELL_MSGDIALOG_TYPE_PROGRESSBAR_DOUBLE:
|
||||
m_gauge2 = new wxGauge(g_msg_dialog, wxID_ANY, 100, wxDefaultPosition, wxSize(300, -1), wxGA_HORIZONTAL | wxGA_SMOOTH);
|
||||
m_text2 = new wxStaticText(g_msg_dialog, wxID_ANY, "");
|
||||
m_text2->SetAutoLayout(true);
|
||||
|
||||
case CELL_MSGDIALOG_TYPE_PROGRESSBAR_SINGLE:
|
||||
m_gauge1 = new wxGauge(g_msg_dialog, wxID_ANY, 100, wxDefaultPosition, wxSize(300, -1), wxGA_HORIZONTAL | wxGA_SMOOTH);
|
||||
m_text1 = new wxStaticText(g_msg_dialog, wxID_ANY, "");
|
||||
m_text1->SetAutoLayout(true);
|
||||
|
||||
case CELL_MSGDIALOG_TYPE_PROGRESSBAR_NONE:
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_gauge1)
|
||||
{
|
||||
sizer1->Add(m_text1, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 8);
|
||||
sizer1->Add(m_gauge1, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, 16);
|
||||
m_gauge1->SetValue(0);
|
||||
}
|
||||
if (m_gauge2)
|
||||
{
|
||||
sizer1->Add(m_text2, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 8);
|
||||
sizer1->Add(m_gauge2, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, 16);
|
||||
m_gauge2->SetValue(0);
|
||||
}
|
||||
|
||||
wxBoxSizer* buttons = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
switch (type & CELL_MSGDIALOG_TYPE_BUTTON_TYPE)
|
||||
{
|
||||
case CELL_MSGDIALOG_TYPE_BUTTON_TYPE_NONE:
|
||||
break;
|
||||
|
||||
case CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO:
|
||||
m_button_yes = new wxButton(g_msg_dialog, wxID_YES);
|
||||
buttons->Add(m_button_yes, 0, wxALIGN_CENTER_HORIZONTAL | wxRIGHT, 8);
|
||||
m_button_no = new wxButton(g_msg_dialog, wxID_NO);
|
||||
buttons->Add(m_button_no, 0, wxALIGN_CENTER_HORIZONTAL, 16);
|
||||
|
||||
sizer1->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 16);
|
||||
break;
|
||||
|
||||
case CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK:
|
||||
m_button_ok = new wxButton(g_msg_dialog, wxID_OK);
|
||||
buttons->Add(m_button_ok, 0, wxALIGN_CENTER_HORIZONTAL, 16);
|
||||
|
||||
sizer1->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 16);
|
||||
break;
|
||||
}
|
||||
|
||||
sizer1->AddSpacer(16);
|
||||
|
||||
g_msg_dialog->SetSizerAndFit(sizer1);
|
||||
g_msg_dialog->Centre(wxBOTH);
|
||||
g_msg_dialog->Show();
|
||||
g_msg_dialog->Enable();
|
||||
|
||||
g_msg_dialog->Bind(wxEVT_BUTTON, [&](wxCommandEvent& event)
|
||||
{
|
||||
status = (event.GetId() == wxID_NO) ? CELL_MSGDIALOG_BUTTON_NO : CELL_MSGDIALOG_BUTTON_YES /* OK */;
|
||||
g_msg_dialog->Hide();
|
||||
m_wait_until = get_system_time();
|
||||
g_msg_dialog_state = msgDialogClose;
|
||||
});
|
||||
|
||||
|
||||
g_msg_dialog->Bind(wxEVT_CLOSE_WINDOW, [&](wxCloseEvent& event)
|
||||
{
|
||||
if (type & CELL_MSGDIALOG_TYPE_DISABLE_CANCEL)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
status = CELL_MSGDIALOG_BUTTON_ESCAPE;
|
||||
g_msg_dialog->Hide();
|
||||
m_wait_until = get_system_time();
|
||||
g_msg_dialog_state = msgDialogClose;
|
||||
}
|
||||
});
|
||||
MsgDialogCreate(type, (char*)msgString.GetPtr(), status);
|
||||
|
||||
m_signal = true;
|
||||
});
|
||||
|
@ -186,7 +111,7 @@ int cellMsgDialogOpen2(u32 type, mem_list_ptr_t<u8> msgString, mem_func_ptr_t<Ce
|
|||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
|
||||
while (g_msg_dialog_state == msgDialogOpen || get_system_time() < m_wait_until)
|
||||
while (g_msg_dialog_state == msgDialogOpen || (s64)(get_system_time() - g_msg_dialog_wait_until) < 0)
|
||||
{
|
||||
if (Emu.IsStopped())
|
||||
{
|
||||
|
@ -201,8 +126,7 @@ int cellMsgDialogOpen2(u32 type, mem_list_ptr_t<u8> msgString, mem_func_ptr_t<Ce
|
|||
|
||||
CallAfter([&]()
|
||||
{
|
||||
delete g_msg_dialog;
|
||||
g_msg_dialog = nullptr;
|
||||
MsgDialogDestroy();
|
||||
});
|
||||
|
||||
g_msg_dialog_state = msgDialogNone;
|
||||
|
@ -329,7 +253,7 @@ int cellMsgDialogClose(float delay)
|
|||
}
|
||||
|
||||
if (delay < 0.0f) delay = 0.0f;
|
||||
m_wait_until = get_system_time() + (u64)(delay * 1000);
|
||||
g_msg_dialog_wait_until = get_system_time() + (u64)(delay * 1000);
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
@ -350,7 +274,7 @@ int cellMsgDialogAbort()
|
|||
}
|
||||
}
|
||||
|
||||
m_wait_until = get_system_time();
|
||||
g_msg_dialog_wait_until = get_system_time();
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
@ -364,7 +288,7 @@ int cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, mem_list_ptr_t<u8> msgS
|
|||
return CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED;
|
||||
}
|
||||
|
||||
if (progressBarIndex >= (m_gauge1 ? 1u : 0u) + (m_gauge2 ? 1u : 0u))
|
||||
if (progressBarIndex >= g_msg_dialog_progress_bar_count)
|
||||
{
|
||||
return CELL_MSGDIALOG_ERROR_PARAM;
|
||||
}
|
||||
|
@ -373,13 +297,7 @@ int cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, mem_list_ptr_t<u8> msgS
|
|||
|
||||
CallAfter([text, progressBarIndex]()
|
||||
{
|
||||
if (g_msg_dialog && !Emu.IsStopped())
|
||||
{
|
||||
if (progressBarIndex == 0 && m_text1) m_text1->SetLabelText(fmt::FromUTF8(text));
|
||||
if (progressBarIndex == 1 && m_text2) m_text2->SetLabelText(fmt::FromUTF8(text));
|
||||
g_msg_dialog->Layout();
|
||||
g_msg_dialog->Fit();
|
||||
}
|
||||
MsgDialogProgressBarSetMsg(progressBarIndex, text.c_str());
|
||||
});
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -393,18 +311,14 @@ int cellMsgDialogProgressBarReset(u32 progressBarIndex)
|
|||
return CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED;
|
||||
}
|
||||
|
||||
if (progressBarIndex >= (m_gauge1 ? 1u : 0u) + (m_gauge2 ? 1u : 0u))
|
||||
if (progressBarIndex >= g_msg_dialog_progress_bar_count)
|
||||
{
|
||||
return CELL_MSGDIALOG_ERROR_PARAM;
|
||||
}
|
||||
|
||||
CallAfter([=]()
|
||||
{
|
||||
if (g_msg_dialog)
|
||||
{
|
||||
if (progressBarIndex == 0 && m_gauge1) m_gauge1->SetValue(0);
|
||||
if (progressBarIndex == 1 && m_gauge2) m_gauge2->SetValue(0);
|
||||
}
|
||||
MsgDialogProgressBarReset(progressBarIndex);
|
||||
});
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -418,18 +332,14 @@ int cellMsgDialogProgressBarInc(u32 progressBarIndex, u32 delta)
|
|||
return CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED;
|
||||
}
|
||||
|
||||
if (progressBarIndex >= (m_gauge1 ? 1u : 0u) + (m_gauge2 ? 1u : 0u))
|
||||
if (progressBarIndex >= g_msg_dialog_progress_bar_count)
|
||||
{
|
||||
return CELL_MSGDIALOG_ERROR_PARAM;
|
||||
}
|
||||
|
||||
CallAfter([=]()
|
||||
{
|
||||
if (g_msg_dialog)
|
||||
{
|
||||
if (progressBarIndex == 0 && m_gauge1) m_gauge1->SetValue(m_gauge1->GetValue() + delta);
|
||||
if (progressBarIndex == 1 && m_gauge2) m_gauge2->SetValue(m_gauge2->GetValue() + delta);
|
||||
}
|
||||
MsgDialogProgressBarInc(progressBarIndex, delta);
|
||||
});
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
|
@ -88,4 +88,18 @@ int cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, mem_list_ptr_t<u8> msgS
|
|||
int cellMsgDialogProgressBarReset(u32 progressBarIndex);
|
||||
int cellMsgDialogProgressBarInc(u32 progressBarIndex, u32 delta);
|
||||
int cellMsgDialogClose(float delay);
|
||||
int cellMsgDialogAbort();
|
||||
int cellMsgDialogAbort();
|
||||
|
||||
typedef void(*MsgDialogCreateCb)(u32 type, const char* msg, u64& status);
|
||||
typedef void(*MsgDialogDestroyCb)();
|
||||
typedef void(*MsgDialogProgressBarSetMsgCb)(u32 progressBarIndex, const char* msg);
|
||||
typedef void(*MsgDialogProgressBarResetCb)(u32 progressBarIndex);
|
||||
typedef void(*MsgDialogProgressBarIncCb)(u32 progressBarIndex, u32 delta);
|
||||
|
||||
void SetMsgDialogCreateCallback(MsgDialogCreateCb cb);
|
||||
void SetMsgDialogDestroyCallback(MsgDialogDestroyCb cb);
|
||||
void SetMsgDialogProgressBarSetMsgCallback(MsgDialogProgressBarSetMsgCb cb);
|
||||
void SetMsgDialogProgressBarResetCallback(MsgDialogProgressBarResetCb cb);
|
||||
void SetMsgDialogProgressBarIncCallback(MsgDialogProgressBarIncCb cb);
|
||||
|
||||
void MsgDialogClose();
|
||||
|
|
163
rpcs3/Gui/MsgDialog.cpp
Normal file
163
rpcs3/Gui/MsgDialog.cpp
Normal file
|
@ -0,0 +1,163 @@
|
|||
#include "stdafx_gui.h"
|
||||
#include "Emu/Memory/Memory.h"
|
||||
|
||||
#include "Emu/SysCalls/lv2/sys_time.h"
|
||||
#include "Emu/SysCalls/Modules/cellMsgDialog.h"
|
||||
#include "MsgDialog.h"
|
||||
|
||||
wxDialog* m_dialog = nullptr;
|
||||
wxGauge* m_gauge1 = nullptr;
|
||||
wxGauge* m_gauge2 = nullptr;
|
||||
wxStaticText* m_text1 = nullptr;
|
||||
wxStaticText* m_text2 = nullptr;
|
||||
|
||||
void MsgDialogCreate(u32 type, const char* msg, u64& status)
|
||||
{
|
||||
wxWindow* parent = nullptr; // TODO: align it better
|
||||
|
||||
m_gauge1 = nullptr;
|
||||
m_gauge2 = nullptr;
|
||||
m_text1 = nullptr;
|
||||
m_text2 = nullptr;
|
||||
wxButton* m_button_ok = nullptr;
|
||||
wxButton* m_button_yes = nullptr;
|
||||
wxButton* m_button_no = nullptr;
|
||||
|
||||
m_dialog = new wxDialog(parent, wxID_ANY, type & CELL_MSGDIALOG_TYPE_SE_TYPE ? "" : "Error", wxDefaultPosition, wxDefaultSize);
|
||||
|
||||
m_dialog->SetExtraStyle(m_dialog->GetExtraStyle() | wxWS_EX_TRANSIENT);
|
||||
m_dialog->SetTransparent(127 + (type & CELL_MSGDIALOG_TYPE_BG) * (128 / CELL_MSGDIALOG_TYPE_BG_INVISIBLE));
|
||||
|
||||
wxSizer* sizer1 = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
wxStaticText* m_text = new wxStaticText(m_dialog, wxID_ANY, wxString(msg, wxConvUTF8));
|
||||
sizer1->Add(m_text, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 16);
|
||||
|
||||
switch (type & CELL_MSGDIALOG_TYPE_PROGRESSBAR)
|
||||
{
|
||||
case CELL_MSGDIALOG_TYPE_PROGRESSBAR_DOUBLE:
|
||||
m_gauge2 = new wxGauge(m_dialog, wxID_ANY, 100, wxDefaultPosition, wxSize(300, -1), wxGA_HORIZONTAL | wxGA_SMOOTH);
|
||||
m_text2 = new wxStaticText(m_dialog, wxID_ANY, "");
|
||||
m_text2->SetAutoLayout(true);
|
||||
|
||||
case CELL_MSGDIALOG_TYPE_PROGRESSBAR_SINGLE:
|
||||
m_gauge1 = new wxGauge(m_dialog, wxID_ANY, 100, wxDefaultPosition, wxSize(300, -1), wxGA_HORIZONTAL | wxGA_SMOOTH);
|
||||
m_text1 = new wxStaticText(m_dialog, wxID_ANY, "");
|
||||
m_text1->SetAutoLayout(true);
|
||||
|
||||
default: // ???
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_gauge1)
|
||||
{
|
||||
sizer1->Add(m_text1, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 8);
|
||||
sizer1->Add(m_gauge1, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, 16);
|
||||
m_gauge1->SetValue(0);
|
||||
}
|
||||
if (m_gauge2)
|
||||
{
|
||||
sizer1->Add(m_text2, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 8);
|
||||
sizer1->Add(m_gauge2, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, 16);
|
||||
m_gauge2->SetValue(0);
|
||||
}
|
||||
|
||||
wxBoxSizer* buttons = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
switch (type & CELL_MSGDIALOG_TYPE_BUTTON_TYPE)
|
||||
{
|
||||
case CELL_MSGDIALOG_TYPE_BUTTON_TYPE_NONE:
|
||||
break;
|
||||
|
||||
case CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO:
|
||||
m_button_yes = new wxButton(m_dialog, wxID_YES);
|
||||
buttons->Add(m_button_yes, 0, wxALIGN_CENTER_HORIZONTAL | wxRIGHT, 8);
|
||||
m_button_no = new wxButton(m_dialog, wxID_NO);
|
||||
buttons->Add(m_button_no, 0, wxALIGN_CENTER_HORIZONTAL, 16);
|
||||
if ((type & CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR) == CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR_NO)
|
||||
{
|
||||
m_button_no->SetFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_button_yes->SetFocus();
|
||||
}
|
||||
|
||||
sizer1->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 16);
|
||||
break;
|
||||
|
||||
case CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK:
|
||||
m_button_ok = new wxButton(m_dialog, wxID_OK);
|
||||
buttons->Add(m_button_ok, 0, wxALIGN_CENTER_HORIZONTAL, 16);
|
||||
if ((type & CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR) == CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR_OK)
|
||||
{
|
||||
m_button_ok->SetFocus();
|
||||
}
|
||||
|
||||
sizer1->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 16);
|
||||
break;
|
||||
}
|
||||
|
||||
sizer1->AddSpacer(16);
|
||||
|
||||
m_dialog->SetSizerAndFit(sizer1);
|
||||
m_dialog->Centre(wxBOTH);
|
||||
m_dialog->Show();
|
||||
m_dialog->Enable();
|
||||
|
||||
m_dialog->Bind(wxEVT_BUTTON, [&](wxCommandEvent& event)
|
||||
{
|
||||
status = (event.GetId() == wxID_NO) ? CELL_MSGDIALOG_BUTTON_NO : CELL_MSGDIALOG_BUTTON_YES /* OK */;
|
||||
m_dialog->Hide();
|
||||
MsgDialogClose();
|
||||
});
|
||||
|
||||
|
||||
m_dialog->Bind(wxEVT_CLOSE_WINDOW, [&](wxCloseEvent& event)
|
||||
{
|
||||
if (type & CELL_MSGDIALOG_TYPE_DISABLE_CANCEL)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
status = CELL_MSGDIALOG_BUTTON_ESCAPE;
|
||||
m_dialog->Hide();
|
||||
MsgDialogClose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void MsgDialogDestroy()
|
||||
{
|
||||
delete m_dialog;
|
||||
m_dialog = nullptr;
|
||||
}
|
||||
|
||||
void MsgDialogProgressBarSetMsg(u32 index, const char* msg)
|
||||
{
|
||||
if (m_dialog)
|
||||
{
|
||||
if (index == 0 && m_text1) m_text1->SetLabelText(wxString(msg, wxConvUTF8));
|
||||
if (index == 1 && m_text2) m_text2->SetLabelText(wxString(msg, wxConvUTF8));
|
||||
m_dialog->Layout();
|
||||
m_dialog->Fit();
|
||||
}
|
||||
}
|
||||
|
||||
void MsgDialogProgressBarReset(u32 index)
|
||||
{
|
||||
if (m_dialog)
|
||||
{
|
||||
if (index == 0 && m_gauge1) m_gauge1->SetValue(0);
|
||||
if (index == 1 && m_gauge2) m_gauge2->SetValue(0);
|
||||
}
|
||||
}
|
||||
|
||||
void MsgDialogProgressBarInc(u32 index, u32 delta)
|
||||
{
|
||||
if (m_dialog)
|
||||
{
|
||||
if (index == 0 && m_gauge1) m_gauge1->SetValue(m_gauge1->GetValue() + delta);
|
||||
if (index == 1 && m_gauge2) m_gauge2->SetValue(m_gauge2->GetValue() + delta);
|
||||
}
|
||||
}
|
7
rpcs3/Gui/MsgDialog.h
Normal file
7
rpcs3/Gui/MsgDialog.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
void MsgDialogCreate(u32 type, const char* msg, u64& status);
|
||||
void MsgDialogDestroy();
|
||||
void MsgDialogProgressBarSetMsg(u32 index, const char* msg);
|
||||
void MsgDialogProgressBarReset(u32 index);
|
||||
void MsgDialogProgressBarInc(u32 index, u32 delta);
|
|
@ -413,9 +413,6 @@
|
|||
<ClInclude Include="Loader\TRP.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ClassDiagram.cd" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{C4A10229-4712-4BD2-B63E-50D93C67A038}</ProjectGuid>
|
||||
<RootNamespace>emucore</RootNamespace>
|
||||
|
|
|
@ -1190,7 +1190,4 @@
|
|||
<Filter>Loader</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ClassDiagram.cd" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,4 +1,5 @@
|
|||
#include "stdafx_gui.h"
|
||||
#include "Emu/Memory/Memory.h"
|
||||
#include "Emu/System.h"
|
||||
#include "rpcs3.h"
|
||||
#include "Ini.h"
|
||||
|
@ -20,6 +21,9 @@
|
|||
#include "Emu/Io/XInput/XInputPadHandler.h"
|
||||
#endif
|
||||
|
||||
#include "Emu/SysCalls/Modules/cellMsgDialog.h"
|
||||
#include "Gui/MsgDialog.h"
|
||||
|
||||
#include "Gui/GLGSFrame.h"
|
||||
#include <wx/stdpaths.h>
|
||||
|
||||
|
@ -113,6 +117,11 @@ bool Rpcs3App::OnInit()
|
|||
{
|
||||
return new GLGSFrame();
|
||||
});
|
||||
SetMsgDialogCreateCallback(MsgDialogCreate);
|
||||
SetMsgDialogDestroyCallback(MsgDialogDestroy);
|
||||
SetMsgDialogProgressBarSetMsgCallback(MsgDialogProgressBarSetMsg);
|
||||
SetMsgDialogProgressBarResetCallback(MsgDialogProgressBarReset);
|
||||
SetMsgDialogProgressBarIncCallback(MsgDialogProgressBarInc);
|
||||
|
||||
TheApp = this;
|
||||
SetAppName(_PRGNAME_);
|
||||
|
|
|
@ -175,6 +175,7 @@
|
|||
<ClCompile Include="Gui\KernelExplorer.cpp" />
|
||||
<ClCompile Include="Gui\MainFrame.cpp" />
|
||||
<ClCompile Include="Gui\MemoryViewer.cpp" />
|
||||
<ClCompile Include="Gui\MsgDialog.cpp" />
|
||||
<ClCompile Include="Gui\PADManager.cpp" />
|
||||
<ClCompile Include="Gui\RSXDebugger.cpp" />
|
||||
<ClCompile Include="Gui\SaveDataUtility.cpp" />
|
||||
|
@ -212,6 +213,7 @@
|
|||
<ClInclude Include="Gui\KernelExplorer.h" />
|
||||
<ClInclude Include="Gui\MainFrame.h" />
|
||||
<ClInclude Include="Gui\MemoryViewer.h" />
|
||||
<ClInclude Include="Gui\MsgDialog.h" />
|
||||
<ClInclude Include="Gui\RegisterEditor.h" />
|
||||
<ClInclude Include="Gui\RSXDebugger.h" />
|
||||
<ClInclude Include="Gui\SaveDataUtility.h" />
|
||||
|
|
|
@ -87,6 +87,9 @@
|
|||
<ClCompile Include="Emu\Cell\PPUProgramCompiler.cpp">
|
||||
<Filter>Gui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Gui\MsgDialog.cpp">
|
||||
<Filter>Gui</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="rpcs3.rc" />
|
||||
|
@ -176,5 +179,8 @@
|
|||
<ClInclude Include="Emu\Cell\PPUProgramCompiler.h">
|
||||
<Filter>Gui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Gui\MsgDialog.h">
|
||||
<Filter>Gui</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Add table
Reference in a new issue