* win32: fixed bugs when saving files while working with ROMs in archives
This commit is contained in:
parent
c6e621bd58
commit
c61bc9d104
|
@ -27,6 +27,7 @@
|
||||||
#include "tracer.h"
|
#include "tracer.h"
|
||||||
#include "cdlogger.h"
|
#include "cdlogger.h"
|
||||||
#include "main.h" //for GetRomName()
|
#include "main.h" //for GetRomName()
|
||||||
|
#include "utils/xstring.h"
|
||||||
|
|
||||||
#define INESPRIV
|
#define INESPRIV
|
||||||
#include "../../ines.h"
|
#include "../../ines.h"
|
||||||
|
@ -127,7 +128,7 @@ BOOL CALLBACK CDLoggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||||
{
|
{
|
||||||
char nameo[2048];
|
char nameo[2048];
|
||||||
strcpy(nameo, GetRomPath());
|
strcpy(nameo, GetRomPath());
|
||||||
strcat(nameo, GetRomName());
|
strcat(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||||
strcat(nameo, ".cdl");
|
strcat(nameo, ".cdl");
|
||||||
LoadCDLog(nameo);
|
LoadCDLog(nameo);
|
||||||
}
|
}
|
||||||
|
@ -280,7 +281,7 @@ void SaveCDLogFileAs()
|
||||||
strcpy(nameo, loadedcdfile);
|
strcpy(nameo, loadedcdfile);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
strcpy(nameo, GetRomName());
|
strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||||
strcat(nameo, ".cdl");
|
strcat(nameo, ".cdl");
|
||||||
}
|
}
|
||||||
ofn.lpstrDefExt = "cdl";
|
ofn.lpstrDefExt = "cdl";
|
||||||
|
@ -300,7 +301,7 @@ void SaveCDLogFile()
|
||||||
{
|
{
|
||||||
char nameo[2048];
|
char nameo[2048];
|
||||||
strcpy(nameo, GetRomPath());
|
strcpy(nameo, GetRomPath());
|
||||||
strcat(nameo, GetRomName());
|
strcat(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||||
strcat(nameo, ".cdl");
|
strcat(nameo, ".cdl");
|
||||||
RenameCDLog(nameo);
|
RenameCDLog(nameo);
|
||||||
}
|
}
|
||||||
|
@ -398,7 +399,7 @@ void SaveStrippedROM(int invert)
|
||||||
ofn.lStructSize=sizeof(ofn);
|
ofn.lStructSize=sizeof(ofn);
|
||||||
ofn.hInstance=fceu_hInstance;
|
ofn.hInstance=fceu_hInstance;
|
||||||
ofn.lpstrTitle="Save Stripped File As...";
|
ofn.lpstrTitle="Save Stripped File As...";
|
||||||
strcpy(sromfilename, GetRomName());
|
strcpy(sromfilename, mass_replace(GetRomName(), "|", ".").c_str());
|
||||||
if (GameInfo->type==GIT_NSF) {
|
if (GameInfo->type==GIT_NSF) {
|
||||||
ofn.lpstrFilter=NSFfilter;
|
ofn.lpstrFilter=NSFfilter;
|
||||||
ofn.lpstrDefExt = "nsf";
|
ofn.lpstrDefExt = "nsf";
|
||||||
|
@ -506,7 +507,7 @@ void CDLoggerROMChanged()
|
||||||
// try to load respective CDL file
|
// try to load respective CDL file
|
||||||
char nameo[2048];
|
char nameo[2048];
|
||||||
strcpy(nameo, GetRomPath());
|
strcpy(nameo, GetRomPath());
|
||||||
strcat(nameo, GetRomName());
|
strcat(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||||
strcat(nameo, ".cdl");
|
strcat(nameo, ".cdl");
|
||||||
|
|
||||||
FILE *FP;
|
FILE *FP;
|
||||||
|
|
|
@ -21,44 +21,43 @@ void WindowBoundsCheckNoResize(int &windowPosX, int &windowPosY, long windowRigh
|
||||||
if (windowRight < 59) {
|
if (windowRight < 59) {
|
||||||
windowPosX = 0;
|
windowPosX = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (windowPosY < -18) {
|
if (windowPosY < -18) {
|
||||||
windowPosY = -18;
|
windowPosY = -18;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check if a filename/path has an extension. Extensions can be up to 4 characters.
|
|
||||||
// Extension strings must begin with a . or they won't work right.
|
// Check if a filename/path has the given extension. The extension is expected to be at the very end of the filename
|
||||||
void AddExtensionIfMissing(char * name,unsigned int maxsize,const char * extension) {
|
void AddExtensionIfMissing(char * name, unsigned int maxsize, const char * extension)
|
||||||
//if user did not add an extension, add it for them
|
{
|
||||||
|
|
||||||
std::string tempName = name;
|
std::string tempName = name;
|
||||||
|
|
||||||
//Non-null terminated lengths of both strings, +1 for null termination
|
// Non-null terminated lengths of both strings, +1 for null termination
|
||||||
if ((strlen(name) + strlen(extension) + 1) <= maxsize) {
|
if ((strlen(name) + strlen(extension) + 1) <= maxsize)
|
||||||
unsigned int x = tempName.find_last_of(".");
|
{
|
||||||
|
unsigned int x = tempName.rfind(extension);
|
||||||
|
|
||||||
//If the extension(".????") is longer then 5 characters, it's probably part of the filename. If x == -1, wasn't found
|
// x == -1 means the extension string wasn't found
|
||||||
if ((x < (tempName.size() - 6)) || (x == -1)) {
|
// if the extension was found in the middle of the string, this doesn't count as extension
|
||||||
//If everything above passed, append the extension, and update the string
|
if ((x == -1) || ((x + strlen(extension)) < tempName.size()))
|
||||||
|
{
|
||||||
tempName.append(extension);
|
tempName.append(extension);
|
||||||
strcpy(name, tempName.c_str());
|
strcpy(name, tempName.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overloaded operator of above, which deals with native std::string variants.
|
// Overloaded operator of above, which deals with native std::string variants.
|
||||||
void AddExtensionIfMissing(std::string &name,const char * extension) {
|
void AddExtensionIfMissing(std::string &name, const char * extension)
|
||||||
//if user did not add an extension, add it for them
|
{
|
||||||
|
unsigned int x = name.rfind(extension);
|
||||||
|
|
||||||
unsigned int x = name.find_last_of(".");
|
if ((x == -1) || ((x + strlen(extension)) < name.size()))
|
||||||
|
|
||||||
//If the extension(".????") is longer then 5 characters, it's probably part of the filename. If x == -1, wasn't found
|
|
||||||
if ((x < (name.size() - 6)) || (x == -1))
|
|
||||||
name.append(extension);
|
name.append(extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetPath(std::string filename)
|
std::string GetPath(std::string filename)
|
||||||
{
|
{
|
||||||
return filename.substr(0,filename.find_last_of("/\\") + 1);
|
return filename.substr(0, filename.find_last_of("/\\") + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsRelativePath(char* name)
|
bool IsRelativePath(char* name)
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "help.h"
|
#include "help.h"
|
||||||
#include "Win32InputBox.h"
|
#include "Win32InputBox.h"
|
||||||
|
#include "utils/xstring.h"
|
||||||
|
|
||||||
extern Name* lastBankNames;
|
extern Name* lastBankNames;
|
||||||
extern Name* loadedBankNames;
|
extern Name* loadedBankNames;
|
||||||
|
@ -309,7 +310,7 @@ void SaveRomAs()
|
||||||
ofn.hInstance=fceu_hInstance;
|
ofn.hInstance=fceu_hInstance;
|
||||||
ofn.lpstrTitle="Save Nes ROM as...";
|
ofn.lpstrTitle="Save Nes ROM as...";
|
||||||
ofn.lpstrFilter=filter;
|
ofn.lpstrFilter=filter;
|
||||||
strcpy(nameo,GetRomName());
|
strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||||
ofn.lpstrFile=nameo;
|
ofn.lpstrFile=nameo;
|
||||||
ofn.lpstrDefExt="nes";
|
ofn.lpstrDefExt="nes";
|
||||||
ofn.nMaxFile=256;
|
ofn.nMaxFile=256;
|
||||||
|
@ -767,7 +768,7 @@ void dumpToFile(const char* buffer, unsigned int size)
|
||||||
ofn.hInstance=fceu_hInstance;
|
ofn.hInstance=fceu_hInstance;
|
||||||
ofn.lpstrTitle="Save to file ...";
|
ofn.lpstrTitle="Save to file ...";
|
||||||
ofn.lpstrFilter="Binary File (*.BIN)\0*.bin\0All Files (*.*)\0*.*\0\0";
|
ofn.lpstrFilter="Binary File (*.BIN)\0*.bin\0All Files (*.*)\0*.*\0\0";
|
||||||
strcpy(name,GetRomName());
|
strcpy(name, mass_replace(GetRomName(), "|", ".").c_str());
|
||||||
ofn.lpstrFile=name;
|
ofn.lpstrFile=name;
|
||||||
ofn.lpstrDefExt="bin";
|
ofn.lpstrDefExt="bin";
|
||||||
ofn.nMaxFile=256;
|
ofn.nMaxFile=256;
|
||||||
|
|
|
@ -416,9 +416,9 @@ static void SaveMemWatch()
|
||||||
ofn.lpstrDefExt="txt";
|
ofn.lpstrDefExt="txt";
|
||||||
char nameo[2048];
|
char nameo[2048];
|
||||||
if (!memwLastFilename[0])
|
if (!memwLastFilename[0])
|
||||||
strcpy(nameo,GetRomName());
|
strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||||
else
|
else
|
||||||
strcpy(nameo,memwLastFilename);
|
strcpy(nameo, memwLastFilename);
|
||||||
ofn.lpstrFile=nameo;
|
ofn.lpstrFile=nameo;
|
||||||
ofn.lpstrDefExt="txt";
|
ofn.lpstrDefExt="txt";
|
||||||
ofn.nMaxFile=256;
|
ofn.nMaxFile=256;
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "cdlogger.h" //needed for TextHookerLoadTable
|
#include "cdlogger.h" //needed for TextHookerLoadTable
|
||||||
#include "fceu.h"
|
#include "fceu.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "utils/xstring.h"
|
||||||
|
|
||||||
char *textToTrans; // buffer to hold the text that needs translating
|
char *textToTrans; // buffer to hold the text that needs translating
|
||||||
char *transText; //holds the translated text
|
char *transText; //holds the translated text
|
||||||
|
@ -691,7 +692,7 @@ int TextHookerSaveTableFile(){
|
||||||
ofn.hInstance=fceu_hInstance;
|
ofn.hInstance=fceu_hInstance;
|
||||||
ofn.lpstrTitle="Load Table File...";
|
ofn.lpstrTitle="Load Table File...";
|
||||||
ofn.lpstrFilter=filter;
|
ofn.lpstrFilter=filter;
|
||||||
strcpy(nameo,GetRomName());
|
strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||||
ofn.lpstrFile=nameo;
|
ofn.lpstrFile=nameo;
|
||||||
ofn.lpstrDefExt="tht";
|
ofn.lpstrDefExt="tht";
|
||||||
ofn.nMaxFile=256;
|
ofn.nMaxFile=256;
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "tracer.h"
|
#include "tracer.h"
|
||||||
#include "memview.h"
|
#include "memview.h"
|
||||||
#include "main.h" //for GetRomName()
|
#include "main.h" //for GetRomName()
|
||||||
|
#include "utils/xstring.h"
|
||||||
|
|
||||||
//Used to determine the current hotkey mapping for the pause key in order to display on the dialog
|
//Used to determine the current hotkey mapping for the pause key in order to display on the dialog
|
||||||
#include "mapinput.h"
|
#include "mapinput.h"
|
||||||
|
@ -170,9 +171,12 @@ BOOL CALLBACK TracerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
EndDialog(hwndDlg,0);
|
EndDialog(hwndDlg,0);
|
||||||
break;
|
break;
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch(HIWORD(wParam)) {
|
switch(HIWORD(wParam))
|
||||||
|
{
|
||||||
case BN_CLICKED:
|
case BN_CLICKED:
|
||||||
switch(LOWORD(wParam)) {
|
{
|
||||||
|
switch(LOWORD(wParam))
|
||||||
|
{
|
||||||
case IDC_BTN_START_STOP_LOGGING:
|
case IDC_BTN_START_STOP_LOGGING:
|
||||||
if(logging)EndLoggingSequence();
|
if(logging)EndLoggingSequence();
|
||||||
else BeginLoggingSequence();
|
else BeginLoggingSequence();
|
||||||
|
@ -259,6 +263,7 @@ BOOL CALLBACK TracerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_MOVING:
|
case WM_MOVING:
|
||||||
|
@ -726,12 +731,13 @@ void ShowLogDirDialog(void){
|
||||||
ofn.hInstance=fceu_hInstance;
|
ofn.hInstance=fceu_hInstance;
|
||||||
ofn.lpstrTitle="Log Trace As...";
|
ofn.lpstrTitle="Log Trace As...";
|
||||||
ofn.lpstrFilter=filter;
|
ofn.lpstrFilter=filter;
|
||||||
strcpy(nameo,GetRomName());
|
strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||||
ofn.lpstrFile=nameo;
|
ofn.lpstrFile=nameo;
|
||||||
ofn.nMaxFile=256;
|
ofn.nMaxFile=256;
|
||||||
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
|
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
|
||||||
ofn.hwndOwner = hTracer;
|
ofn.hwndOwner = hTracer;
|
||||||
if(GetSaveFileName(&ofn)){
|
if(GetSaveFileName(&ofn))
|
||||||
|
{
|
||||||
if (ofn.nFilterIndex == 1)
|
if (ofn.nFilterIndex == 1)
|
||||||
AddExtensionIfMissing(nameo, sizeof(nameo), ".log");
|
AddExtensionIfMissing(nameo, sizeof(nameo), ".log");
|
||||||
else if (ofn.nFilterIndex == 2)
|
else if (ofn.nFilterIndex == 2)
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "../../wave.h"
|
#include "../../wave.h"
|
||||||
#include "main.h" //For GetRomName()
|
#include "main.h" //For GetRomName()
|
||||||
|
#include "utils/xstring.h"
|
||||||
|
|
||||||
int CloseWave()
|
int CloseWave()
|
||||||
{
|
{
|
||||||
|
@ -44,7 +45,7 @@ bool CreateSoundSave()
|
||||||
ofn.hInstance=fceu_hInstance;
|
ofn.hInstance=fceu_hInstance;
|
||||||
ofn.lpstrTitle="Log Sound As...";
|
ofn.lpstrTitle="Log Sound As...";
|
||||||
ofn.lpstrFilter=filter;
|
ofn.lpstrFilter=filter;
|
||||||
strcpy(nameo,GetRomName());
|
strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||||
ofn.lpstrFile=nameo;
|
ofn.lpstrFile=nameo;
|
||||||
ofn.lpstrDefExt="wav";
|
ofn.lpstrDefExt="wav";
|
||||||
ofn.nMaxFile=256;
|
ofn.nMaxFile=256;
|
||||||
|
|
|
@ -1187,7 +1187,7 @@ void DumpSubtitles(HWND hWnd)
|
||||||
ofn.hwndOwner = hWnd;
|
ofn.hwndOwner = hWnd;
|
||||||
ofn.lpstrTitle="Save Subtitles as...";
|
ofn.lpstrTitle="Save Subtitles as...";
|
||||||
ofn.lpstrFilter = filter;
|
ofn.lpstrFilter = filter;
|
||||||
strcpy(nameo,GetRomName());
|
strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||||
ofn.lpstrFile = nameo;
|
ofn.lpstrFile = nameo;
|
||||||
ofn.nMaxFile = 256;
|
ofn.nMaxFile = 256;
|
||||||
ofn.Flags = OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
|
ofn.Flags = OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
|
||||||
|
@ -2671,7 +2671,7 @@ void FCEUD_AviRecordTo(void)
|
||||||
}
|
}
|
||||||
//else construct it from the ROM name.
|
//else construct it from the ROM name.
|
||||||
else
|
else
|
||||||
tempFilename = GetRomName();
|
tempFilename = mass_replace(GetRomName(), "|", ".").c_str();
|
||||||
|
|
||||||
aviFilename = aviDirectory + tempFilename; //concate avi directory and movie filename
|
aviFilename = aviDirectory + tempFilename; //concate avi directory and movie filename
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue