2015-12-02 17:12:48 +01:00
|
|
|
#include "stdafx.h"
|
2014-08-29 00:49:26 +02:00
|
|
|
#include "stdafx_gui.h"
|
2016-02-01 22:46:27 +01:00
|
|
|
|
|
|
|
|
#include "Utilities/Timer.h"
|
2014-07-11 13:59:13 +02:00
|
|
|
#include "Emu/System.h"
|
2014-07-10 22:54:12 +02:00
|
|
|
#include "rpcs3.h"
|
2016-02-01 22:46:27 +01:00
|
|
|
|
|
|
|
|
#include "GSFrame.h"
|
2015-10-05 02:42:48 +02:00
|
|
|
|
2014-05-02 08:30:32 +02:00
|
|
|
BEGIN_EVENT_TABLE(GSFrame, wxFrame)
|
|
|
|
|
EVT_PAINT(GSFrame::OnPaint)
|
|
|
|
|
EVT_SIZE(GSFrame::OnSize)
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
2016-04-27 00:27:24 +02:00
|
|
|
GSFrame::GSFrame(const wxString& title, int w, int h)
|
2016-02-01 22:46:27 +01:00
|
|
|
: wxFrame(nullptr, wxID_ANY, "GSFrame[" + title + "]")
|
2014-05-02 08:30:32 +02:00
|
|
|
{
|
2016-05-23 12:08:34 +02:00
|
|
|
m_render = title;
|
2015-11-26 08:37:53 +01:00
|
|
|
SetIcon(wxGetApp().m_MainFrame->GetIcon());
|
2017-04-30 17:21:15 +02:00
|
|
|
SetCursor(wxCursor(wxImage(1, 1)));
|
2014-05-02 08:30:32 +02:00
|
|
|
|
2016-04-27 00:27:24 +02:00
|
|
|
SetClientSize(w, h);
|
2014-05-02 08:30:32 +02:00
|
|
|
wxGetApp().Bind(wxEVT_KEY_DOWN, &GSFrame::OnKeyDown, this);
|
|
|
|
|
Bind(wxEVT_CLOSE_WINDOW, &GSFrame::OnClose, this);
|
2015-10-13 12:44:35 +02:00
|
|
|
Bind(wxEVT_LEFT_DCLICK, &GSFrame::OnLeftDclick, this);
|
2014-05-02 08:30:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GSFrame::OnPaint(wxPaintEvent& event)
|
|
|
|
|
{
|
|
|
|
|
wxPaintDC(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GSFrame::OnClose(wxCloseEvent& event)
|
|
|
|
|
{
|
|
|
|
|
Emu.Stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GSFrame::OnKeyDown(wxKeyEvent& event)
|
|
|
|
|
{
|
|
|
|
|
switch (event.GetKeyCode())
|
|
|
|
|
{
|
|
|
|
|
case WXK_RETURN: if (event.AltDown()) { OnFullScreen(); return; } break;
|
|
|
|
|
case WXK_ESCAPE: if (IsFullScreen()) { ShowFullScreen(false); return; } break;
|
|
|
|
|
}
|
|
|
|
|
event.Skip();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GSFrame::OnFullScreen()
|
|
|
|
|
{
|
|
|
|
|
ShowFullScreen(!IsFullScreen());
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-05 02:42:48 +02:00
|
|
|
void GSFrame::close()
|
|
|
|
|
{
|
|
|
|
|
wxFrame::Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool GSFrame::shown()
|
|
|
|
|
{
|
|
|
|
|
return wxFrame::IsShown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GSFrame::hide()
|
|
|
|
|
{
|
|
|
|
|
wxFrame::Hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GSFrame::show()
|
|
|
|
|
{
|
|
|
|
|
wxFrame::Show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void* GSFrame::handle() const
|
|
|
|
|
{
|
|
|
|
|
return GetHandle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void* GSFrame::make_context()
|
|
|
|
|
{
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GSFrame::set_current(draw_context_t ctx)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GSFrame::delete_context(void* ctx)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-27 00:27:24 +02:00
|
|
|
int GSFrame::client_width()
|
2015-10-05 02:42:48 +02:00
|
|
|
{
|
2016-04-27 00:27:24 +02:00
|
|
|
return GetClientSize().GetWidth();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int GSFrame::client_height()
|
|
|
|
|
{
|
|
|
|
|
return GetClientSize().GetHeight();
|
2015-10-05 02:42:48 +02:00
|
|
|
}
|
2014-05-02 08:30:32 +02:00
|
|
|
|
2015-10-05 02:42:48 +02:00
|
|
|
void GSFrame::flip(draw_context_t)
|
2014-05-02 08:30:32 +02:00
|
|
|
{
|
2015-10-05 02:42:48 +02:00
|
|
|
++m_frames;
|
|
|
|
|
|
|
|
|
|
static Timer fps_t;
|
|
|
|
|
|
|
|
|
|
if (fps_t.GetElapsedTimeInSec() >= 0.5)
|
|
|
|
|
{
|
|
|
|
|
std::string title = fmt::format("FPS: %.2f", (double)m_frames / fps_t.GetElapsedTimeInSec());
|
|
|
|
|
|
2016-05-23 12:08:34 +02:00
|
|
|
if (!m_render.empty())
|
|
|
|
|
title += " | " + m_render;
|
|
|
|
|
|
2015-10-05 02:42:48 +02:00
|
|
|
if (!Emu.GetTitle().empty())
|
|
|
|
|
title += " | " + Emu.GetTitle();
|
|
|
|
|
|
|
|
|
|
if (!Emu.GetTitleID().empty())
|
2016-02-01 22:46:27 +01:00
|
|
|
title += " | [" + Emu.GetTitleID() + ']';
|
2015-10-05 02:42:48 +02:00
|
|
|
|
2017-01-28 01:19:39 +01:00
|
|
|
wxGetApp().CallAfter([this, title = std::move(title)]
|
|
|
|
|
{
|
|
|
|
|
SetTitle(wxString(title.c_str(), wxConvUTF8));
|
|
|
|
|
});
|
|
|
|
|
|
2015-10-05 02:42:48 +02:00
|
|
|
m_frames = 0;
|
|
|
|
|
fps_t.Start();
|
|
|
|
|
}
|
2014-05-02 08:30:32 +02:00
|
|
|
}
|