summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinWX/Frame.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2014-06-24 16:41:12 -0400
committerLioncash <mathew1800@gmail.com>2014-06-28 16:55:15 -0400
commit3df00cd3f57ef12ab0d4078045b88585a69c2072 (patch)
tree1a504b6344f3e264acd74236f730fd2574a57a83 /Source/Core/DolphinWX/Frame.cpp
parent91da03122022e8c91a0328c1716ea8f1f2935074 (diff)
Fix dragging and dropping savestates in the render window
Diffstat (limited to 'Source/Core/DolphinWX/Frame.cpp')
-rw-r--r--Source/Core/DolphinWX/Frame.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp
index 64cb5a2568..5284eefd57 100644
--- a/Source/Core/DolphinWX/Frame.cpp
+++ b/Source/Core/DolphinWX/Frame.cpp
@@ -15,6 +15,7 @@
#endif
#include <cstddef>
+#include <fstream>
#include <string>
#include <utility>
#include <vector>
@@ -152,6 +153,7 @@ void CRenderFrame::OnDropFiles(wxDropFilesEvent& event)
return;
wxFileName file = event.GetFiles()[0];
+ const std::string filepath = WxStrToStr(file.GetFullPath());
if (file.GetExt() == "dtm")
{
@@ -165,19 +167,37 @@ void CRenderFrame::OnDropFiles(wxDropFilesEvent& event)
main_frame->GetMenuBar()->FindItem(IDM_RECORDREADONLY)->Check(true);
}
- if (Movie::PlayInput(WxStrToStr(file.GetFullPath())))
+ if (Movie::PlayInput(filepath))
main_frame->BootGame("");
}
else if (!Core::IsRunning())
{
- main_frame->BootGame(WxStrToStr(file.GetFullPath()));
+ main_frame->BootGame(filepath);
+ }
+ else if (IsValidSavestateDropped(filepath) && Core::IsRunning())
+ {
+ State::LoadAs(filepath);
}
else
{
- DVDInterface::ChangeDisc(WxStrToStr(file.GetFullPath()));
+ DVDInterface::ChangeDisc(filepath);
}
}
+bool CRenderFrame::IsValidSavestateDropped(const std::string& filepath)
+{
+ const int game_id_length = 6;
+ std::ifstream file(filepath, std::ios::in | std::ios::binary);
+
+ if (!file)
+ return false;
+
+ std::string internal_game_id(game_id_length, ' ');
+ file.read(&internal_game_id[0], game_id_length);
+
+ return internal_game_id == SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID();
+}
+
#ifdef _WIN32
WXLRESULT CRenderFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{