* 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 "cdlogger.h"
|
||||
#include "main.h" //for GetRomName()
|
||||
#include "utils/xstring.h"
|
||||
|
||||
#define INESPRIV
|
||||
#include "../../ines.h"
|
||||
|
@ -127,7 +128,7 @@ BOOL CALLBACK CDLoggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
|||
{
|
||||
char nameo[2048];
|
||||
strcpy(nameo, GetRomPath());
|
||||
strcat(nameo, GetRomName());
|
||||
strcat(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||
strcat(nameo, ".cdl");
|
||||
LoadCDLog(nameo);
|
||||
}
|
||||
|
@ -280,7 +281,7 @@ void SaveCDLogFileAs()
|
|||
strcpy(nameo, loadedcdfile);
|
||||
} else
|
||||
{
|
||||
strcpy(nameo, GetRomName());
|
||||
strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||
strcat(nameo, ".cdl");
|
||||
}
|
||||
ofn.lpstrDefExt = "cdl";
|
||||
|
@ -300,7 +301,7 @@ void SaveCDLogFile()
|
|||
{
|
||||
char nameo[2048];
|
||||
strcpy(nameo, GetRomPath());
|
||||
strcat(nameo, GetRomName());
|
||||
strcat(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||
strcat(nameo, ".cdl");
|
||||
RenameCDLog(nameo);
|
||||
}
|
||||
|
@ -398,7 +399,7 @@ void SaveStrippedROM(int invert)
|
|||
ofn.lStructSize=sizeof(ofn);
|
||||
ofn.hInstance=fceu_hInstance;
|
||||
ofn.lpstrTitle="Save Stripped File As...";
|
||||
strcpy(sromfilename, GetRomName());
|
||||
strcpy(sromfilename, mass_replace(GetRomName(), "|", ".").c_str());
|
||||
if (GameInfo->type==GIT_NSF) {
|
||||
ofn.lpstrFilter=NSFfilter;
|
||||
ofn.lpstrDefExt = "nsf";
|
||||
|
@ -506,7 +507,7 @@ void CDLoggerROMChanged()
|
|||
// try to load respective CDL file
|
||||
char nameo[2048];
|
||||
strcpy(nameo, GetRomPath());
|
||||
strcat(nameo, GetRomName());
|
||||
strcat(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||
strcat(nameo, ".cdl");
|
||||
|
||||
FILE *FP;
|
||||
|
|
|
@ -21,44 +21,43 @@ void WindowBoundsCheckNoResize(int &windowPosX, int &windowPosY, long windowRigh
|
|||
if (windowRight < 59) {
|
||||
windowPosX = 0;
|
||||
}
|
||||
|
||||
if (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.
|
||||
void AddExtensionIfMissing(char * name,unsigned int maxsize,const char * extension) {
|
||||
//if user did not add an extension, add it for them
|
||||
|
||||
|
||||
// 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)
|
||||
{
|
||||
std::string tempName = name;
|
||||
|
||||
//Non-null terminated lengths of both strings, +1 for null termination
|
||||
if ((strlen(name) + strlen(extension) + 1) <= maxsize) {
|
||||
unsigned int x = tempName.find_last_of(".");
|
||||
// Non-null terminated lengths of both strings, +1 for null termination
|
||||
if ((strlen(name) + strlen(extension) + 1) <= maxsize)
|
||||
{
|
||||
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
|
||||
if ((x < (tempName.size() - 6)) || (x == -1)) {
|
||||
//If everything above passed, append the extension, and update the string
|
||||
// x == -1 means the extension string wasn't found
|
||||
// if the extension was found in the middle of the string, this doesn't count as extension
|
||||
if ((x == -1) || ((x + strlen(extension)) < tempName.size()))
|
||||
{
|
||||
tempName.append(extension);
|
||||
strcpy(name, tempName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Overloaded operator of above, which deals with native std::string variants.
|
||||
void AddExtensionIfMissing(std::string &name,const char * extension) {
|
||||
//if user did not add an extension, add it for them
|
||||
void AddExtensionIfMissing(std::string &name, const char * extension)
|
||||
{
|
||||
unsigned int x = name.rfind(extension);
|
||||
|
||||
unsigned int x = name.find_last_of(".");
|
||||
|
||||
//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))
|
||||
if ((x == -1) || ((x + strlen(extension)) < name.size()))
|
||||
name.append(extension);
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "string.h"
|
||||
#include "help.h"
|
||||
#include "Win32InputBox.h"
|
||||
#include "utils/xstring.h"
|
||||
|
||||
extern Name* lastBankNames;
|
||||
extern Name* loadedBankNames;
|
||||
|
@ -309,7 +310,7 @@ void SaveRomAs()
|
|||
ofn.hInstance=fceu_hInstance;
|
||||
ofn.lpstrTitle="Save Nes ROM as...";
|
||||
ofn.lpstrFilter=filter;
|
||||
strcpy(nameo,GetRomName());
|
||||
strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||
ofn.lpstrFile=nameo;
|
||||
ofn.lpstrDefExt="nes";
|
||||
ofn.nMaxFile=256;
|
||||
|
@ -767,7 +768,7 @@ void dumpToFile(const char* buffer, unsigned int size)
|
|||
ofn.hInstance=fceu_hInstance;
|
||||
ofn.lpstrTitle="Save to file ...";
|
||||
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.lpstrDefExt="bin";
|
||||
ofn.nMaxFile=256;
|
||||
|
|
|
@ -416,9 +416,9 @@ static void SaveMemWatch()
|
|||
ofn.lpstrDefExt="txt";
|
||||
char nameo[2048];
|
||||
if (!memwLastFilename[0])
|
||||
strcpy(nameo,GetRomName());
|
||||
strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||
else
|
||||
strcpy(nameo,memwLastFilename);
|
||||
strcpy(nameo, memwLastFilename);
|
||||
ofn.lpstrFile=nameo;
|
||||
ofn.lpstrDefExt="txt";
|
||||
ofn.nMaxFile=256;
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "cdlogger.h" //needed for TextHookerLoadTable
|
||||
#include "fceu.h"
|
||||
#include "main.h"
|
||||
#include "utils/xstring.h"
|
||||
|
||||
char *textToTrans; // buffer to hold the text that needs translating
|
||||
char *transText; //holds the translated text
|
||||
|
@ -691,7 +692,7 @@ int TextHookerSaveTableFile(){
|
|||
ofn.hInstance=fceu_hInstance;
|
||||
ofn.lpstrTitle="Load Table File...";
|
||||
ofn.lpstrFilter=filter;
|
||||
strcpy(nameo,GetRomName());
|
||||
strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||
ofn.lpstrFile=nameo;
|
||||
ofn.lpstrDefExt="tht";
|
||||
ofn.nMaxFile=256;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "tracer.h"
|
||||
#include "memview.h"
|
||||
#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
|
||||
#include "mapinput.h"
|
||||
|
@ -170,9 +171,12 @@ BOOL CALLBACK TracerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
EndDialog(hwndDlg,0);
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
switch(HIWORD(wParam)) {
|
||||
switch(HIWORD(wParam))
|
||||
{
|
||||
case BN_CLICKED:
|
||||
switch(LOWORD(wParam)) {
|
||||
{
|
||||
switch(LOWORD(wParam))
|
||||
{
|
||||
case IDC_BTN_START_STOP_LOGGING:
|
||||
if(logging)EndLoggingSequence();
|
||||
else BeginLoggingSequence();
|
||||
|
@ -259,6 +263,7 @@ BOOL CALLBACK TracerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_MOVING:
|
||||
|
@ -726,12 +731,13 @@ void ShowLogDirDialog(void){
|
|||
ofn.hInstance=fceu_hInstance;
|
||||
ofn.lpstrTitle="Log Trace As...";
|
||||
ofn.lpstrFilter=filter;
|
||||
strcpy(nameo,GetRomName());
|
||||
strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||
ofn.lpstrFile=nameo;
|
||||
ofn.nMaxFile=256;
|
||||
ofn.Flags=OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
|
||||
ofn.hwndOwner = hTracer;
|
||||
if(GetSaveFileName(&ofn)){
|
||||
if(GetSaveFileName(&ofn))
|
||||
{
|
||||
if (ofn.nFilterIndex == 1)
|
||||
AddExtensionIfMissing(nameo, sizeof(nameo), ".log");
|
||||
else if (ofn.nFilterIndex == 2)
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "common.h"
|
||||
#include "../../wave.h"
|
||||
#include "main.h" //For GetRomName()
|
||||
#include "utils/xstring.h"
|
||||
|
||||
int CloseWave()
|
||||
{
|
||||
|
@ -44,7 +45,7 @@ bool CreateSoundSave()
|
|||
ofn.hInstance=fceu_hInstance;
|
||||
ofn.lpstrTitle="Log Sound As...";
|
||||
ofn.lpstrFilter=filter;
|
||||
strcpy(nameo,GetRomName());
|
||||
strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||
ofn.lpstrFile=nameo;
|
||||
ofn.lpstrDefExt="wav";
|
||||
ofn.nMaxFile=256;
|
||||
|
|
|
@ -1187,7 +1187,7 @@ void DumpSubtitles(HWND hWnd)
|
|||
ofn.hwndOwner = hWnd;
|
||||
ofn.lpstrTitle="Save Subtitles as...";
|
||||
ofn.lpstrFilter = filter;
|
||||
strcpy(nameo,GetRomName());
|
||||
strcpy(nameo, mass_replace(GetRomName(), "|", ".").c_str());
|
||||
ofn.lpstrFile = nameo;
|
||||
ofn.nMaxFile = 256;
|
||||
ofn.Flags = OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
|
||||
|
@ -2671,7 +2671,7 @@ void FCEUD_AviRecordTo(void)
|
|||
}
|
||||
//else construct it from the ROM name.
|
||||
else
|
||||
tempFilename = GetRomName();
|
||||
tempFilename = mass_replace(GetRomName(), "|", ".").c_str();
|
||||
|
||||
aviFilename = aviDirectory + tempFilename; //concate avi directory and movie filename
|
||||
|
||||
|
|
Loading…
Reference in New Issue