2014-08-29 20:30:21 +02:00
|
|
|
#include "stdafx_gui.h"
|
2015-04-18 19:18:23 +02:00
|
|
|
#include "rpcs3.h"
|
2015-09-26 22:46:04 +02:00
|
|
|
#include "Emu/System.h"
|
2014-08-29 20:30:21 +02:00
|
|
|
#include "Emu/Memory/Memory.h"
|
|
|
|
|
|
|
|
|
|
#include "Emu/SysCalls/lv2/sys_time.h"
|
|
|
|
|
#include "MsgDialog.h"
|
|
|
|
|
|
2015-09-26 22:46:04 +02:00
|
|
|
MsgDialogFrame::~MsgDialogFrame()
|
2014-08-29 20:30:21 +02:00
|
|
|
{
|
2015-09-26 22:46:04 +02:00
|
|
|
if (m_dialog) wxGetApp().CallAfter([dialog = m_dialog]
|
|
|
|
|
{
|
|
|
|
|
dialog->Destroy();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MsgDialogFrame::Create(const std::string& msg)
|
|
|
|
|
{
|
|
|
|
|
if (m_dialog) m_dialog->Destroy();
|
|
|
|
|
|
|
|
|
|
wxWindow* parent = wxGetApp().m_MainFrame; // TODO
|
2014-08-29 20:30:21 +02:00
|
|
|
|
|
|
|
|
m_gauge1 = nullptr;
|
|
|
|
|
m_gauge2 = nullptr;
|
|
|
|
|
m_text1 = nullptr;
|
|
|
|
|
m_text2 = nullptr;
|
2015-04-15 20:33:44 +02:00
|
|
|
m_button_ok = nullptr;
|
|
|
|
|
m_button_yes = nullptr;
|
|
|
|
|
m_button_no = nullptr;
|
2014-08-29 20:30:21 +02:00
|
|
|
|
2015-09-26 22:46:04 +02:00
|
|
|
m_dialog = new wxDialog(nullptr, wxID_ANY, type.se_normal ? "" : "Error", wxDefaultPosition, wxDefaultSize);
|
2014-08-29 20:30:21 +02:00
|
|
|
|
|
|
|
|
m_dialog->SetExtraStyle(m_dialog->GetExtraStyle() | wxWS_EX_TRANSIENT);
|
2015-09-26 22:46:04 +02:00
|
|
|
m_dialog->SetTransparent(type.bg_invisible ? 255 : 160);
|
2014-08-29 20:30:21 +02:00
|
|
|
|
2015-04-15 20:33:44 +02:00
|
|
|
m_sizer1 = new wxBoxSizer(wxVERTICAL);
|
2014-08-29 20:30:21 +02:00
|
|
|
|
2015-09-26 22:46:04 +02:00
|
|
|
m_text = new wxStaticText(m_dialog, wxID_ANY, wxString(msg.c_str(), wxConvUTF8));
|
2015-04-15 20:33:44 +02:00
|
|
|
m_sizer1->Add(m_text, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 16);
|
2014-08-29 20:30:21 +02:00
|
|
|
|
2015-09-26 22:46:04 +02:00
|
|
|
if (type.progress_bar_count >= 2)
|
2014-08-29 20:30:21 +02:00
|
|
|
{
|
2015-09-26 22:46:04 +02:00
|
|
|
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, "");
|
2014-08-29 20:30:21 +02:00
|
|
|
m_text2->SetAutoLayout(true);
|
2015-09-26 22:46:04 +02:00
|
|
|
}
|
2014-08-29 20:30:21 +02:00
|
|
|
|
2015-09-26 22:46:04 +02:00
|
|
|
if (type.progress_bar_count >= 1)
|
|
|
|
|
{
|
|
|
|
|
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, "");
|
2014-08-29 20:30:21 +02:00
|
|
|
m_text1->SetAutoLayout(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_gauge1)
|
|
|
|
|
{
|
2015-04-15 20:33:44 +02:00
|
|
|
m_sizer1->Add(m_text1, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 8);
|
|
|
|
|
m_sizer1->Add(m_gauge1, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, 16);
|
2014-08-29 20:30:21 +02:00
|
|
|
m_gauge1->SetValue(0);
|
|
|
|
|
}
|
2015-04-18 19:18:23 +02:00
|
|
|
|
2014-08-29 20:30:21 +02:00
|
|
|
if (m_gauge2)
|
|
|
|
|
{
|
2015-04-15 20:33:44 +02:00
|
|
|
m_sizer1->Add(m_text2, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 8);
|
|
|
|
|
m_sizer1->Add(m_gauge2, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, 16);
|
2014-08-29 20:30:21 +02:00
|
|
|
m_gauge2->SetValue(0);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-18 19:18:23 +02:00
|
|
|
m_buttons = new wxBoxSizer(wxHORIZONTAL);
|
2014-08-29 20:30:21 +02:00
|
|
|
|
2015-09-26 22:46:04 +02:00
|
|
|
if (type.button_type.unshifted() == CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO)
|
2014-08-29 20:30:21 +02:00
|
|
|
{
|
2015-09-26 22:46:04 +02:00
|
|
|
m_button_yes = new wxButton(m_dialog, wxID_YES);
|
2015-04-18 19:18:23 +02:00
|
|
|
m_buttons->Add(m_button_yes, 0, wxALIGN_CENTER_HORIZONTAL | wxRIGHT, 8);
|
2015-09-26 22:46:04 +02:00
|
|
|
m_button_no = new wxButton(m_dialog, wxID_NO);
|
2015-04-18 19:18:23 +02:00
|
|
|
m_buttons->Add(m_button_no, 0, wxALIGN_CENTER_HORIZONTAL, 16);
|
|
|
|
|
|
2015-09-26 22:46:04 +02:00
|
|
|
if (type.default_cursor == 1)
|
2014-08-29 20:30:21 +02:00
|
|
|
{
|
|
|
|
|
m_button_no->SetFocus();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_button_yes->SetFocus();
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-18 19:18:23 +02:00
|
|
|
m_sizer1->Add(m_buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 16);
|
|
|
|
|
}
|
2014-08-29 20:30:21 +02:00
|
|
|
|
2015-09-26 22:46:04 +02:00
|
|
|
if (type.button_type.unshifted() == CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK)
|
2015-04-18 19:18:23 +02:00
|
|
|
{
|
2015-09-26 22:46:04 +02:00
|
|
|
m_button_ok = new wxButton(m_dialog, wxID_OK);
|
2015-04-18 19:18:23 +02:00
|
|
|
m_buttons->Add(m_button_ok, 0, wxALIGN_CENTER_HORIZONTAL, 16);
|
|
|
|
|
|
2015-09-26 22:46:04 +02:00
|
|
|
if (type.default_cursor == 0)
|
2014-08-29 20:30:21 +02:00
|
|
|
{
|
|
|
|
|
m_button_ok->SetFocus();
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-18 19:18:23 +02:00
|
|
|
m_sizer1->Add(m_buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 16);
|
2014-08-29 20:30:21 +02:00
|
|
|
}
|
|
|
|
|
|
2015-04-15 20:33:44 +02:00
|
|
|
m_sizer1->AddSpacer(16);
|
2014-08-29 20:30:21 +02:00
|
|
|
|
2015-04-15 20:33:44 +02:00
|
|
|
m_dialog->SetSizerAndFit(m_sizer1);
|
2014-08-29 20:30:21 +02:00
|
|
|
m_dialog->Centre(wxBOTH);
|
|
|
|
|
m_dialog->Show();
|
|
|
|
|
m_dialog->Enable();
|
|
|
|
|
|
2015-09-26 22:46:04 +02:00
|
|
|
m_dialog->Bind(wxEVT_BUTTON, [on_close = on_close](wxCommandEvent& event)
|
2014-08-29 20:30:21 +02:00
|
|
|
{
|
2015-09-26 22:46:04 +02:00
|
|
|
on_close(event.GetId() == wxID_NO ? CELL_MSGDIALOG_BUTTON_NO : CELL_MSGDIALOG_BUTTON_YES);
|
2014-08-29 20:30:21 +02:00
|
|
|
});
|
|
|
|
|
|
2015-09-26 22:46:04 +02:00
|
|
|
m_dialog->Bind(wxEVT_CLOSE_WINDOW, [on_close = on_close, type = type](wxCloseEvent& event)
|
2014-08-29 20:30:21 +02:00
|
|
|
{
|
2015-09-26 22:46:04 +02:00
|
|
|
if (!type.disable_cancel)
|
2014-08-29 20:30:21 +02:00
|
|
|
{
|
2015-09-26 22:46:04 +02:00
|
|
|
on_close(CELL_MSGDIALOG_BUTTON_ESCAPE);
|
2014-08-29 20:30:21 +02:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-18 00:41:14 +02:00
|
|
|
void MsgDialogFrame::ProgressBarSetMsg(u32 index, const std::string& msg)
|
2014-08-29 20:30:21 +02:00
|
|
|
{
|
2015-09-18 00:41:14 +02:00
|
|
|
if (m_dialog)
|
2014-08-29 20:30:21 +02:00
|
|
|
{
|
2015-09-18 00:41:14 +02:00
|
|
|
if (index == 0 && m_text1) m_text1->SetLabelText(wxString(msg.c_str(), wxConvUTF8));
|
|
|
|
|
if (index == 1 && m_text2) m_text2->SetLabelText(wxString(msg.c_str(), wxConvUTF8));
|
|
|
|
|
m_dialog->Layout();
|
|
|
|
|
m_dialog->Fit();
|
|
|
|
|
}
|
2014-08-29 20:30:21 +02:00
|
|
|
}
|
|
|
|
|
|
2015-04-15 20:33:44 +02:00
|
|
|
void MsgDialogFrame::ProgressBarReset(u32 index)
|
2014-08-29 20:30:21 +02:00
|
|
|
{
|
2015-09-18 00:41:14 +02:00
|
|
|
if (m_dialog)
|
2014-08-29 20:30:21 +02:00
|
|
|
{
|
2015-09-18 00:41:14 +02:00
|
|
|
if (index == 0 && m_gauge1) m_gauge1->SetValue(0);
|
|
|
|
|
if (index == 1 && m_gauge2) m_gauge2->SetValue(0);
|
|
|
|
|
}
|
2014-08-29 20:30:21 +02:00
|
|
|
}
|
|
|
|
|
|
2015-04-15 20:33:44 +02:00
|
|
|
void MsgDialogFrame::ProgressBarInc(u32 index, u32 delta)
|
2014-08-29 20:30:21 +02:00
|
|
|
{
|
2015-09-18 00:41:14 +02:00
|
|
|
if (m_dialog)
|
2014-08-29 20:30:21 +02:00
|
|
|
{
|
2015-09-18 00:41:14 +02:00
|
|
|
if (index == 0 && m_gauge1) m_gauge1->SetValue(m_gauge1->GetValue() + delta);
|
|
|
|
|
if (index == 1 && m_gauge2) m_gauge2->SetValue(m_gauge2->GetValue() + delta);
|
|
|
|
|
}
|
2014-08-29 20:30:21 +02:00
|
|
|
}
|