Skip to content

Commit

Permalink
gui:recording: Revert addition of Screenshot As, will contribute as s…
Browse files Browse the repository at this point in the history
…eparate PR

Along with changing the .bmp file naming scheme.
  • Loading branch information
xTVaser authored and lightningterror committed Apr 20, 2019
1 parent c12c6ed commit 64104ca
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 65 deletions.
10 changes: 7 additions & 3 deletions pcsx2/Recording/InputRecordingFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ bool InputRecordingFile::UpdatePadData(unsigned long frame, const PadData& key)
return true;
}

// TODO - see if we can get the actual game name, not just the ISO name
// Verify header of recording file
bool InputRecordingFile::readHeaderAndCheck()
{
Expand All @@ -225,16 +224,21 @@ bool InputRecordingFile::readHeaderAndCheck()
if (fread(&UndoCount, 4, 1, recordingFile) != 1) return false;
if (fread(&savestate.fromSavestate, sizeof(bool), 1, recordingFile) != 1) return false;
if (savestate.fromSavestate) {
// TODO - check to see if the file is there, if it AINT, return false, throw an error, ETC (SAY WHAT FILE WE ARE LOOKING FOR)
FILE* ssFileCheck = wxFopen(filename + "_SaveState.p2s", "r");
if (ssFileCheck = NULL) {
recordingConLog(wxString::Format("[REC]: Could not locate savestate file at location - %s\n", filename + "_SaveState.p2s"));
return false;
}
fclose(ssFileCheck);
StateCopy_LoadFromFile(filename + "_SaveState.p2s");
}
else {
sApp.SysExecute();
}

// Check for current verison
// TODO - more specific log if fails for this reason
if (header.version != 1) {
recordingConLog(wxString::Format("[REC]: Input recording file is not a supported version - %d\n", header.version));
return false;
}
return true;
Expand Down
5 changes: 0 additions & 5 deletions pcsx2/gui/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ enum MenuIdentifiers
MenuId_Capture_Video_Stop,
MenuId_Capture_Screenshot,
MenuId_Capture_Screenshot_Screenshot,
MenuId_Capture_Screenshot_Screenshot_As,

#ifndef DISABLE_RECORDING
// Recording Subsection
Expand All @@ -198,10 +197,6 @@ enum MenuIdentifiers
MenuId_Recording_VirtualPad_Port0,
MenuId_Recording_VirtualPad_Port1,
MenuId_Recording_Conversions,
MenuId_Recording_ConvertV2ToV3,
MenuId_Recording_ConvertV1_XToV2,
MenuId_Recording_ConvertV1ToV2,
MenuId_Recording_ConvertLegacy,
#endif

};
Expand Down
2 changes: 0 additions & 2 deletions pcsx2/gui/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ void MainEmuFrame::ConnectMenus()
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Capture_Video_Record_Click, this, MenuId_Capture_Video_Record);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Capture_Video_Stop_Click, this, MenuId_Capture_Video_Stop);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Capture_Screenshot_Screenshot_Click, this, MenuId_Capture_Screenshot_Screenshot);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Capture_Screenshot_Screenshot_As_Click, this, MenuId_Capture_Screenshot_Screenshot_As);

#ifndef DISABLE_RECORDING
// Recording
Expand Down Expand Up @@ -566,7 +565,6 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title)

m_menuCapture.Append(MenuId_Capture_Screenshot, _("Screenshot"), &m_submenuScreenshot);
m_submenuScreenshot.Append(MenuId_Capture_Screenshot_Screenshot, _("Screenshot"));
m_submenuScreenshot.Append(MenuId_Capture_Screenshot_Screenshot_As, _("Screenshot As..."));

// ------------------------------------------------------------------------

Expand Down
1 change: 0 additions & 1 deletion pcsx2/gui/MainFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ class MainEmuFrame : public wxFrame,
void Menu_Capture_Video_Stop_Click(wxCommandEvent &event);
void VideoCaptureUpdate();
void Menu_Capture_Screenshot_Screenshot_Click(wxCommandEvent &event);
void Menu_Capture_Screenshot_Screenshot_As_Click(wxCommandEvent &event);

#ifndef DISABLE_RECORDING
void Menu_Recording_New_Click(wxCommandEvent &event);
Expand Down
17 changes: 0 additions & 17 deletions pcsx2/gui/MainMenuClicks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,23 +759,6 @@ void MainEmuFrame::Menu_Capture_Screenshot_Screenshot_Click(wxCommandEvent & eve
GSmakeSnapshot(g_Conf->Folders.Snapshots.ToAscii());
}

void MainEmuFrame::Menu_Capture_Screenshot_Screenshot_As_Click(wxCommandEvent &event)
{
if (!CoreThread.IsOpen())
return;

wxFileDialog fileDialog(this, "Select a file", g_Conf->Folders.Snapshots.ToAscii(), wxEmptyString, "PNG files (*.png)|*.png", wxFD_SAVE | wxFD_OVERWRITE_PROMPT);

if (fileDialog.ShowModal() == wxID_OK)
{
wxString path = fileDialog.GetPath();
// GS Code expects a .bmp path, despite PNG compression being hardcoded.
// Swap extensions so UX isn't confusing and avoid changing too much GS code that I'm not familiar with
path = wxString::Format("%s.bmp", path.substr(0, path.size() - 4));
GSmakeSnapshot(path);
}
}

#ifndef DISABLE_RECORDING
void MainEmuFrame::Menu_Recording_New_Click(wxCommandEvent &event)
{
Expand Down
12 changes: 2 additions & 10 deletions plugins/GSdx/GS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,17 +740,9 @@ EXPORT_C_(uint32) GSmakeSnapshot(char* path)
{
std::string s{path};

if (!s.empty())
if (!s.empty() && s[s.length() - 1] != DIRECTORY_SEPARATOR)
{
// Facilitates Save As.. Feature
if (s.substr(s.size() - 4, 4) == ".bmp")
{
return s_gs->MakeSnapshot(s);
}
else if (s[s.length() - 1] != DIRECTORY_SEPARATOR)
{
s = s + DIRECTORY_SEPARATOR;
}
s = s + DIRECTORY_SEPARATOR;
}

return s_gs->MakeSnapshot(s + "gsdx");
Expand Down
46 changes: 19 additions & 27 deletions plugins/GSdx/Renderers/Common/GSRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,37 +499,29 @@ void GSRenderer::VSync(int field)

bool GSRenderer::MakeSnapshot(const std::string& path)
{
if(m_snapshot.empty())
if (m_snapshot.empty())
{
// Facilitates Save As.. Feature
if (path.substr(path.size() - 4, 4) == ".bmp")
time_t cur_time = time(nullptr);
static time_t prev_snap;
// The variable 'n' is used for labelling the screenshots when multiple screenshots are taken in
// a single second, we'll start using this variable for naming when a second screenshot request is detected
// at the same time as the first one. Hence, we're initially setting this counter to 2 to imply that
// the captured image is the 2nd image captured at this specific time.
static int n = 2;
char local_time[16];

if (strftime(local_time, sizeof(local_time), "%Y%m%d%H%M%S", localtime(&cur_time)))
{
m_snapshot = path.substr(0, path.size() - 4);
}
else
{
time_t cur_time = time(nullptr);
static time_t prev_snap;
// The variable 'n' is used for labelling the screenshots when multiple screenshots are taken in
// a single second, we'll start using this variable for naming when a second screenshot request is detected
// at the same time as the first one. Hence, we're initially setting this counter to 2 to imply that
// the captured image is the 2nd image captured at this specific time.
static int n = 2;
char local_time[16];

if (strftime(local_time, sizeof(local_time), "%Y%m%d%H%M%S", localtime(&cur_time)))
if (cur_time == prev_snap)
{
if (cur_time == prev_snap)
{
m_snapshot = format("%s_%s_(%d)", path.c_str(), local_time, n++);
}
else
{
n = 2;
m_snapshot = format("%s_%s", path.c_str(), local_time);
}
prev_snap = cur_time;
m_snapshot = format("%s_%s_(%d)", path.c_str(), local_time, n++);
}
else
{
n = 2;
m_snapshot = format("%s_%s", path.c_str(), local_time);
}
prev_snap = cur_time;
}
}

Expand Down

0 comments on commit 64104ca

Please sign in to comment.