Skip to content

Commit

Permalink
Add Batch Extraction
Browse files Browse the repository at this point in the history
Users can now select multiple entries and extract the chosen selected once, instead of one at a time.
Additionally it is possible to select all by using the CTRL+A keyboard shortcut.
  • Loading branch information
julianxhokaxhiu committed Sep 18, 2020
1 parent 973e68b commit 188f094
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 80 deletions.
Binary file modified src/FF7SND.APS
Binary file not shown.
71 changes: 35 additions & 36 deletions src/FF7SND.rc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Microsoft Developer Studio generated resource script.
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

Expand All @@ -13,15 +13,12 @@
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
// Inglese (Stati Uniti) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
Expand All @@ -44,18 +41,14 @@ BEGIN
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "Final Fantasy VII Sound Player\0"
VALUE "CompanyName", "\0"
VALUE "FileDescription", "Final Fantasy VII Sound Player\0"
VALUE "FileVersion", "1.0\0"
VALUE "InternalName", "FF7SND\0"
VALUE "LegalCopyright", "by Qhimm - 2000\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "FF7SND.EXE\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "Final Fantasy VII Sound Player\0"
VALUE "ProductVersion", "1.0\0"
VALUE "SpecialBuild", "\0"
VALUE "Comments", "Final Fantasy VII Sound Player"
VALUE "FileDescription", "Final Fantasy VII Sound Player"
VALUE "FileVersion", "1.0"
VALUE "InternalName", "FF7SND"
VALUE "LegalCopyright", "by Qhimm - 2000"
VALUE "OriginalFilename", "FF7SND.EXE"
VALUE "ProductName", "Final Fantasy VII Sound Player"
VALUE "ProductVersion", "1.0"
END
END
BLOCK "VarFileInfo"
Expand All @@ -64,16 +57,14 @@ BEGIN
END
END

#endif // !_MAC


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
GUIDELINES DESIGNINFO
BEGIN
IDD_FF7SND_DIALOG, DIALOG
BEGIN
Expand All @@ -92,19 +83,17 @@ END
//

IDD_FF7SND_DIALOG DIALOGEX 0, 0, 196, 194
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Final Fantasy VII Sound Player"
FONT 8, "MS Sans Serif"
FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN
PUSHBUTTON "Exit",IDCANCEL,139,145,50,14
PUSHBUTTON "Open",ID_LOAD,7,7,50,14
CHECKBOX "Play",ID_PLAY,7,145,50,14,BS_PUSHLIKE
CHECKBOX "Extract",ID_EXTRACT,61,145,50,14,BS_PUSHLIKE
LISTBOX IDC_CLIPS,7,37,182,103,LBS_OWNERDRAWFIXED |
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
CTEXT "FF7SND 1.0 - by Qhimm - 2000\nThe sound files are copyright of SquareSoft, Inc.",
IDC_STATIC,7,170,182,17,WS_DISABLED
LISTBOX IDC_CLIPS,7,37,182,103,LBS_OWNERDRAWFIXED | LBS_NOINTEGRALHEIGHT | LBS_EXTENDEDSEL | WS_VSCROLL | WS_TABSTOP
CTEXT "FF7SND 1.0 - by Qhimm - 2000\nThe sound files are copyright of SquareSoft, Inc.",IDC_STATIC,7,170,182,17,WS_DISABLED
LTEXT " Clip ID",IDC_STATIC,7,27,66,8
LTEXT "Sampl. freq.",IDC_STATIC,134,27,40,8
LTEXT "Clip size",IDC_STATIC,89,27,36,8
Expand All @@ -118,38 +107,48 @@ END

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "Gast.ico"
#endif // English (U.S.) resources
IDR_MAINFRAME ICON "Gast.ico"


/////////////////////////////////////////////////////////////////////////////
//
// AFX_DIALOG_LAYOUT
//

IDD_FF7SND_DIALOG AFX_DIALOG_LAYOUT
BEGIN
0
END

#endif // Inglese (Stati Uniti) resources
/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
// Swedish resources
// Svedese (Svezia) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_SVE)
#ifdef _WIN32
LANGUAGE LANG_SWEDISH, SUBLANG_DEFAULT
LANGUAGE LANG_SWEDISH, SUBLANG_SWEDISH
#pragma code_page(1252)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE DISCARDABLE
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE DISCARDABLE
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END

3 TEXTINCLUDE DISCARDABLE
3 TEXTINCLUDE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
Expand All @@ -169,7 +168,7 @@ END

#endif // APSTUDIO_INVOKED

#endif // Swedish resources
#endif // Svedese (Svezia) resources
/////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 3 additions & 1 deletion src/FF7SND.vcxproj.user
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<PropertyGroup>
<RESOURCE_FILE>FF7SND.rc</RESOURCE_FILE>
</PropertyGroup>
</Project>
105 changes: 65 additions & 40 deletions src/FF7SNDDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,49 +314,74 @@ void CFF7SNDDlg::OnPlay()

void CFF7SNDDlg::OnExtract()
{
// TODO: Add your control notification handler code here
int c = m_Clips.GetCurSel();

CFileDialog dlgFile(FALSE,
"dat",
CFolderPickerDialog dlgFolder(
"",
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
"Wave files (*.wav)|*.wav|All files (*.*)|*.*|",
this);
0,
this
);

dlgFile.m_ofn.lpstrInitialDir = FF7Dir;
if (IDCANCEL == dlgFile.DoModal()) return;

strcpy(FF7Dir, dlgFile.GetPathName());
FF7Dir[strlen(FF7Dir)-dlgFile.GetFileName().GetLength()-1] = 0;
dlgFolder.m_ofn.lpstrInitialDir = FF7Dir;
if (IDCANCEL == dlgFolder.DoModal()) return;

CFile fileIn, fileOut;
fileIn.Open(szDat, CFile::modeRead | CFile::shareDenyNone);
fileOut.Open(dlgFile.GetPathName(), CFile::modeWrite | CFile::modeCreate | CFile::shareDenyWrite);
for (int idx = 0; idx < m_Clips.GetCount(); idx++)
{
if (m_Clips.GetSel(idx) > 0)
{
char outPath[MAX_PATH]{ 0 };

CT2A chosenPath(dlgFolder.GetPathName());

sprintf(outPath, "%s/%d.wav", chosenPath.m_psz, idx);

CFile fileIn, fileOut;
fileIn.Open(szDat, CFile::modeRead | CFile::shareDenyNone);
fileOut.Open(outPath, CFile::modeWrite | CFile::modeCreate | CFile::shareDenyWrite);

FF7SNDHEADER* hdr = (FF7SNDHEADER*)(hdrmem + hdroff[idx]);
ULONG temp = MAKEFOURCC('R', 'I', 'F', 'F');
fileOut.Write(&temp, 4);
temp = hdr->length + 36 + (hdr->wfex.cbSize == 0 ? 0 : (4 + hdr->wNumCoef * 4));
fileOut.Write(&temp, 4);
temp = MAKEFOURCC('W', 'A', 'V', 'E');
fileOut.Write(&temp, 4);
temp = MAKEFOURCC('f', 'm', 't', ' ');
fileOut.Write(&temp, 4);
temp = 18 + (hdr->wfex.cbSize == 0 ? 0 : (4 + hdr->wNumCoef * 4));
fileOut.Write(&temp, 4);
fileOut.Write(&hdr->wfex, 18 + (hdr->wfex.cbSize == 0 ? 0 : (4 + hdr->wNumCoef * 4)));
temp = MAKEFOURCC('d', 'a', 't', 'a');
fileOut.Write(&temp, 4);
temp = hdr->length;
fileOut.Write(&temp, 4);

char* buf = (char*)malloc(hdr->length);
fileIn.Seek(hdr->offset, CFile::begin);
fileIn.Read(buf, hdr->length);
fileOut.Write(buf, hdr->length);
free(buf);

fileIn.Close();
fileOut.Close();
}
}

FF7SNDHEADER *hdr = (FF7SNDHEADER*)(hdrmem+hdroff[c]);
ULONG temp = MAKEFOURCC('R','I','F','F');
fileOut.Write(&temp,4);
temp = hdr->length + 36 + (hdr->wfex.cbSize == 0 ? 0 : (4+hdr->wNumCoef * 4));
fileOut.Write(&temp,4);
temp = MAKEFOURCC('W','A','V','E');
fileOut.Write(&temp,4);
temp = MAKEFOURCC('f','m','t',' ');
fileOut.Write(&temp,4);
temp = 18 + (hdr->wfex.cbSize == 0 ? 0 : (4+hdr->wNumCoef*4));
fileOut.Write(&temp,4);
fileOut.Write(&hdr->wfex, 18 + (hdr->wfex.cbSize == 0 ? 0 : (4+hdr->wNumCoef*4)));
temp = MAKEFOURCC('d','a','t','a');
fileOut.Write(&temp,4);
temp = hdr->length;
fileOut.Write(&temp,4);

char *buf = (char*)malloc(hdr->length);
fileIn.Seek(hdr->offset, CFile::begin);
fileIn.Read(buf, hdr->length);
fileOut.Write(buf, hdr->length);
free(buf);
MessageBox("All files extracted successfully.", "", MB_ICONINFORMATION);
}

fileIn.Close();
fileOut.Close();
BOOL CFF7SNDDlg::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN)
{
if ((::GetKeyState(VK_CONTROL) & 0x8000) != 0)
{
switch (pMsg->wParam)
{
case 'A':
m_Clips.SelItemRange(TRUE, 0, m_Clips.GetCount() - 1);
break;
}
}
}

return CDialog::PreTranslateMessage(pMsg);
}
9 changes: 6 additions & 3 deletions src/FF7SNDDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class CFF7SNDDlg : public CDialog
// Construction
public:
int nHeaders;
char szDat[MAX_PATH];
char FF7Dir[MAX_PATH];
char szDat[MAX_PATH]{ 0 };
char FF7Dir[MAX_PATH]{ 0 };
CFF7SNDDlg(CWnd* pParent = NULL); // standard constructor
~CFF7SNDDlg();

Expand All @@ -66,11 +66,14 @@ class CFF7SNDDlg : public CDialog

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFF7SNDDlg)
protected:
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);

protected:
HICON m_hIcon;

Expand Down

0 comments on commit 188f094

Please sign in to comment.