rework and integrate path settings
This commit is contained in:
parent
3c5ad7c896
commit
68cf6f1e5e
|
@ -46,6 +46,10 @@
|
|||
#include "./windows/disView.h"
|
||||
#endif
|
||||
|
||||
#include "path.h"
|
||||
|
||||
PathInfo path;
|
||||
|
||||
//this doesnt work anyway. why take a speed hit for public releases?
|
||||
// Luigi__: I don't agree. We should start include wifi emulation in public releases
|
||||
// because it already allows games to not hang during wifi operations
|
||||
|
@ -65,8 +69,7 @@ std::string InputDisplayString;
|
|||
|
||||
static BOOL LidClosed = FALSE;
|
||||
static u8 countLid = 0;
|
||||
char pathToROM[MAX_PATH];
|
||||
char pathFilenameToROMwithoutExt[MAX_PATH];
|
||||
|
||||
|
||||
GameInfo gameInfo;
|
||||
|
||||
|
@ -738,55 +741,18 @@ int NDS_LoadROM( const char *filename, const char *logicalFilename)
|
|||
u8 *data;
|
||||
char *noext;
|
||||
char buf[MAX_PATH];
|
||||
char extROM[MAX_PATH];
|
||||
char extROM2[5];
|
||||
|
||||
if (filename == NULL)
|
||||
return -1;
|
||||
|
||||
memset(pathToROM, 0, MAX_PATH);
|
||||
memset(pathFilenameToROMwithoutExt, 0, MAX_PATH);
|
||||
memset(extROM, 0, MAX_PATH);
|
||||
memset(extROM2, 0, 5);
|
||||
|
||||
noext = strdup(filename);
|
||||
reader = ROMReaderInit(&noext);
|
||||
|
||||
if(logicalFilename)
|
||||
{
|
||||
for (int t = strlen(logicalFilename); t>0; t--)
|
||||
if ( (logicalFilename[t] == '\\') || (logicalFilename[t] == '/') )
|
||||
{
|
||||
strncpy(pathToROM, logicalFilename, t+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int t = strlen(filename); t>0; t--)
|
||||
if ( (filename[t] == '\\') || (filename[t] == '/') )
|
||||
{
|
||||
strncpy(pathToROM, filename, t+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int t = strlen(filename); t>0; t--)
|
||||
if ( (filename[t] == '\\') || (filename[t] == '/') || (filename[t] == '.') )
|
||||
{
|
||||
if (filename[t] != '.') return -1;
|
||||
strncpy(pathFilenameToROMwithoutExt, filename, t);
|
||||
strncpy(extROM, filename+t, strlen(filename) - t);
|
||||
if (t>4)
|
||||
strncpy(extROM2, filename+(t-3), 3);
|
||||
break;
|
||||
}
|
||||
|
||||
if(!strcasecmp(extROM, ".zip"))
|
||||
path.init(filename);
|
||||
if(!strcasecmp(path.extension().c_str(), "zip")) type = ROM_NDS;
|
||||
else if ( !strcasecmp(path.extension().c_str(), "nds"))
|
||||
type = ROM_NDS;
|
||||
else if ( !strcasecmp(extROM, ".nds"))
|
||||
type = ROM_NDS;
|
||||
else if ( !strcasecmp(extROM, ".gba") && !strcasecmp(extROM2, ".ds"))
|
||||
else if ( path.isdsgba())
|
||||
type = ROM_DSGBA;
|
||||
else
|
||||
type = ROM_NDS;
|
||||
|
@ -860,11 +826,7 @@ int NDS_LoadROM( const char *filename, const char *logicalFilename)
|
|||
|
||||
memset(buf, 0, MAX_PATH);
|
||||
|
||||
#ifdef WIN32
|
||||
GetFullPathNoExt(BATTERY, buf, MAX_PATH);
|
||||
#else
|
||||
strcpy(buf, pathFilenameToROMwithoutExt);
|
||||
#endif
|
||||
path.getpathnoext(path.BATTERY, buf);
|
||||
|
||||
strcat(buf, ".dsv"); // DeSmuME memory card :)
|
||||
|
||||
|
@ -872,11 +834,7 @@ int NDS_LoadROM( const char *filename, const char *logicalFilename)
|
|||
|
||||
memset(buf, 0, MAX_PATH);
|
||||
|
||||
#ifdef WIN32
|
||||
GetFullPathNoExt(CHEATS, buf, MAX_PATH);
|
||||
#else
|
||||
strcpy(buf, pathFilenameToROMwithoutExt);
|
||||
#endif
|
||||
path.getpathnoext(path.CHEATS, buf);
|
||||
|
||||
strcat(buf, ".dct"); // DeSmuME cheat :)
|
||||
cheatsInit(buf);
|
||||
|
|
|
@ -100,8 +100,6 @@ int NDS_WritePNG(const char *fname);
|
|||
|
||||
extern volatile BOOL execute;
|
||||
extern BOOL click;
|
||||
extern char pathToROM[MAX_PATH];
|
||||
extern char pathFilenameToROMwithoutExt[MAX_PATH];
|
||||
|
||||
/*
|
||||
* The firmware language values
|
||||
|
@ -285,7 +283,6 @@ struct GameInfo
|
|||
};
|
||||
|
||||
extern GameInfo gameInfo;
|
||||
|
||||
void NDS_setTouchPos(u16 x, u16 y);
|
||||
void NDS_releaseTouch(void);
|
||||
void NDS_setPad(bool R,bool L,bool D,bool U,bool T,bool S,bool B,bool A,bool Y,bool X,bool W,bool E,bool G, bool F);
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include "../fs.h"
|
||||
#include "MMU.h"
|
||||
#include "NDSSystem.h"
|
||||
#include "../path.h"
|
||||
|
||||
typedef struct {
|
||||
int level,parent,filesInDir;
|
||||
|
@ -510,7 +511,7 @@ static BOOL cflash_init()
|
|||
|
||||
if (CFlash_Mode == ADDON_CFLASH_MODE_RomPath)
|
||||
{
|
||||
sFlashPath = pathToROM;
|
||||
sFlashPath = path.pathToRoms;
|
||||
INFO("Using CFlash directory of rom: %s\n", sFlashPath.c_str());
|
||||
}
|
||||
else if(CFlash_Mode == ADDON_CFLASH_MODE_Path)
|
||||
|
|
|
@ -119,46 +119,4 @@ u32 strlen_ws(char *buf) // length without last spaces
|
|||
if (buf[i]!=32) return (i-1); // space
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string RomName = ""; //Stores the name of the Rom currently loaded in memory
|
||||
|
||||
/***
|
||||
* Author: adelikat
|
||||
* Date Added: May 8, 2009
|
||||
* Description: Sets the Global variable RomName
|
||||
* Known Usage:
|
||||
* LoadRom
|
||||
**/
|
||||
void SetRomName(const char *filename)
|
||||
{
|
||||
std::string str = filename;
|
||||
|
||||
//Truncate the path from filename
|
||||
int x = str.find_last_of("/\\");
|
||||
if (x > 0)
|
||||
str = str.substr(x+1);
|
||||
RomName = str;
|
||||
}
|
||||
|
||||
/***
|
||||
* Author: adelikat
|
||||
* Date Added: May 8, 2009
|
||||
* Description: Returns the Global variable RomName
|
||||
* Known Usage:
|
||||
* included in main.h
|
||||
* ramwatch.cpp - SaveStrings
|
||||
**/
|
||||
|
||||
const char *GetRomName()
|
||||
{
|
||||
return RomName.c_str();
|
||||
}
|
||||
|
||||
std::string GetRomNameWithoutExtension()
|
||||
{
|
||||
int x = RomName.find_last_of(".");
|
||||
if (x > 0)
|
||||
return RomName.substr(0,x);
|
||||
else return RomName;
|
||||
}
|
||||
}
|
|
@ -29,11 +29,6 @@
|
|||
#include <string>
|
||||
|
||||
extern u8 gba_header_data_0x04[156];
|
||||
const char* GetRomName(); //adelikat: return the name of the Rom currently loaded
|
||||
std::string GetRomNameWithoutExtension();
|
||||
void SetRomName(const char *filename);
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include <winsock2.h>
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "version.h"
|
||||
#include "GPU_osd.h"
|
||||
#include "memorystream.h"
|
||||
#include "path.h"
|
||||
|
||||
using namespace std;
|
||||
bool freshMovie = false; //True when a movie loads, false when movie is altered. Used to determine if a movie has been altered since opening
|
||||
|
@ -553,7 +554,7 @@ void _CDECL_ FCEUI_SaveMovie(const char *fname, std::wstring author, int flag, s
|
|||
if(author != L"") currMovieData.comments.push_back(L"author " + author);
|
||||
currMovieData.romChecksum = gameInfo.crc;
|
||||
currMovieData.romSerial = gameInfo.ROMserial;
|
||||
currMovieData.romFilename = GetRomName();
|
||||
currMovieData.romFilename = path.GetRomName();
|
||||
|
||||
NDS_Reset();
|
||||
|
||||
|
|
|
@ -0,0 +1,354 @@
|
|||
#include <string>
|
||||
|
||||
#ifdef WIN32
|
||||
#include "resource.h"
|
||||
#else
|
||||
#include <glib.h>
|
||||
#endif
|
||||
#include "time.h"
|
||||
#include "utils/xstring.h"
|
||||
|
||||
class PathInfo
|
||||
{
|
||||
public:
|
||||
|
||||
std::string path;
|
||||
std::string RomName;
|
||||
|
||||
#define MAX_FORMAT 20
|
||||
#define SECTION "PathSettings"
|
||||
|
||||
#define ROMKEY "Roms"
|
||||
#define BATTERYKEY "Battery"
|
||||
#define STATEKEY "States"
|
||||
#define SCREENSHOTKEY "Screenshots"
|
||||
#define AVIKEY "AviFiles"
|
||||
#define CHEATKEY "Cheats"
|
||||
#define SOUNDKEY "SoundSamples"
|
||||
#define FIRMWAREKEY "Firmware"
|
||||
#define FORMATKEY "format"
|
||||
#define DEFAULTFORMATKEY "defaultFormat"
|
||||
#define NEEDSSAVINGKEY "needsSaving"
|
||||
#define LASTVISITKEY "lastVisit"
|
||||
#define LUAKEY "Lua"
|
||||
char screenshotFormat[MAX_FORMAT];
|
||||
bool savelastromvisit;
|
||||
|
||||
enum KnownPath
|
||||
{
|
||||
FIRSTKNOWNPATH = 0,
|
||||
ROMS = 0,
|
||||
BATTERY,
|
||||
STATES,
|
||||
SCREENSHOTS,
|
||||
AVI_FILES,
|
||||
CHEATS,
|
||||
SOUNDS,
|
||||
FIRMWARE,
|
||||
MODULE,
|
||||
MAXKNOWNPATH = MODULE
|
||||
};
|
||||
|
||||
char pathToRoms[MAX_PATH];
|
||||
char pathToBattery[MAX_PATH];
|
||||
char pathToStates[MAX_PATH];
|
||||
char pathToScreenshots[MAX_PATH];
|
||||
char pathToAviFiles[MAX_PATH];
|
||||
char pathToCheats[MAX_PATH];
|
||||
char pathToSounds[MAX_PATH];
|
||||
char pathToFirmware[MAX_PATH];
|
||||
char pathToModule[MAX_PATH];
|
||||
char pathToLua[MAX_PATH];
|
||||
|
||||
void init(const char * filename) {
|
||||
|
||||
path = std::string(filename);
|
||||
|
||||
//extract the internal part of the logical rom name
|
||||
std::vector<std::string> parts = tokenize_str(filename,"|");
|
||||
SetRomName(parts[parts.size()-1].c_str());
|
||||
LoadModulePath();
|
||||
#ifndef WIN32
|
||||
|
||||
ReadPathSettings();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void LoadModulePath()
|
||||
{
|
||||
#ifdef WIN32
|
||||
char *p;
|
||||
ZeroMemory(pathToModule, sizeof(pathToModule));
|
||||
GetModuleFileName(NULL, pathToModule, sizeof(pathToModule));
|
||||
p = pathToModule + lstrlen(pathToModule);
|
||||
while (p >= pathToModule && *p != '\\') p--;
|
||||
if (++p >= pathToModule) *p = 0;
|
||||
#else
|
||||
// strcpy(pathToModule, g_get_home_dir());
|
||||
const char *homedir = getenv ("HOME");
|
||||
strcpy(pathToModule, homedir);
|
||||
#endif
|
||||
}
|
||||
|
||||
enum Action
|
||||
{
|
||||
GET,
|
||||
SET
|
||||
};
|
||||
|
||||
void GetDefaultPath(char *pathToDefault, const char *key, int maxCount)
|
||||
{
|
||||
strncpy(pathToDefault, pathToModule, maxCount);
|
||||
}
|
||||
|
||||
void ReadKey(char *pathToRead, const char *key)
|
||||
{
|
||||
#ifdef WIN32
|
||||
GetPrivateProfileString(SECTION, key, key, pathToRead, MAX_PATH, IniName);
|
||||
if(strcmp(pathToRead, key) == 0)
|
||||
#endif
|
||||
//since the variables are all intialized in this file they all use MAX_PATH
|
||||
GetDefaultPath(pathToRead, key, MAX_PATH);
|
||||
}
|
||||
|
||||
void ReadPathSettings()
|
||||
{
|
||||
if( ( strcmp(pathToModule, "") == 0) || !pathToModule)
|
||||
LoadModulePath();
|
||||
|
||||
ReadKey(pathToRoms, ROMKEY);
|
||||
ReadKey(pathToBattery, BATTERYKEY);
|
||||
ReadKey(pathToStates, STATEKEY);
|
||||
ReadKey(pathToScreenshots, SCREENSHOTKEY);
|
||||
ReadKey(pathToAviFiles, AVIKEY);
|
||||
ReadKey(pathToCheats, CHEATKEY);
|
||||
ReadKey(pathToSounds, SOUNDKEY);
|
||||
ReadKey(pathToFirmware, FIRMWAREKEY);
|
||||
ReadKey(pathToLua, LUAKEY);
|
||||
#ifdef WIN32
|
||||
GetPrivateProfileString(SECTION, FORMATKEY, "%f_%s_%r", screenshotFormat, MAX_FORMAT, IniName);
|
||||
savelastromvisit = GetPrivateProfileInt(SECTION, LASTVISITKEY, TRUE, IniName);
|
||||
currentimageformat = (ImageFormat)GetPrivateProfileInt(SECTION, DEFAULTFORMATKEY, PNG, IniName);
|
||||
#endif
|
||||
/*
|
||||
needsSaving = GetPrivateProfileInt(SECTION, NEEDSSAVINGKEY, TRUE, IniName);
|
||||
if(needsSaving)
|
||||
{
|
||||
needsSaving = FALSE;
|
||||
WritePathSettings();
|
||||
}*/
|
||||
}
|
||||
|
||||
void SwitchPath(Action action, KnownPath path, char * buffer)
|
||||
{
|
||||
char *pathToCopy = 0;
|
||||
switch(path)
|
||||
{
|
||||
case ROMS:
|
||||
pathToCopy = pathToRoms;
|
||||
break;
|
||||
case BATTERY:
|
||||
pathToCopy = pathToBattery;
|
||||
break;
|
||||
case STATES:
|
||||
pathToCopy = pathToStates;
|
||||
break;
|
||||
case SCREENSHOTS:
|
||||
pathToCopy = pathToScreenshots;
|
||||
break;
|
||||
case AVI_FILES:
|
||||
pathToCopy = pathToAviFiles;
|
||||
break;
|
||||
case CHEATS:
|
||||
pathToCopy = pathToCheats;
|
||||
break;
|
||||
case SOUNDS:
|
||||
pathToCopy = pathToSounds;
|
||||
break;
|
||||
case FIRMWARE:
|
||||
pathToCopy = pathToFirmware;
|
||||
break;
|
||||
case MODULE:
|
||||
pathToCopy = pathToModule;
|
||||
break;
|
||||
}
|
||||
|
||||
if(action == GET)
|
||||
{
|
||||
strncpy(buffer, pathToCopy, MAX_PATH);
|
||||
int len = strlen(buffer)-1;
|
||||
#ifdef WIN32
|
||||
if(buffer[len] != '\\')
|
||||
strcat(buffer, "\\");
|
||||
#else
|
||||
if(buffer[len] != '/')
|
||||
strcat(buffer, "/");
|
||||
#endif
|
||||
|
||||
}
|
||||
else if(action == SET)
|
||||
{
|
||||
int len = strlen(buffer)-1;
|
||||
if(buffer[len] == '\\')
|
||||
buffer[len] = '\0';
|
||||
|
||||
strncpy(pathToCopy, buffer, MAX_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
void getpath(KnownPath path, char *buffer)
|
||||
{
|
||||
SwitchPath(GET, path, buffer);
|
||||
}
|
||||
|
||||
void setpath(KnownPath path, char *buffer)
|
||||
{
|
||||
SwitchPath(SET, path, buffer);
|
||||
}
|
||||
|
||||
void getfilename(char *buffer, int maxCount)
|
||||
{
|
||||
strcpy(buffer,noextension().c_str());
|
||||
}
|
||||
|
||||
void getpathnoext(KnownPath path, char *buffer)
|
||||
{
|
||||
getpath(path, buffer);
|
||||
strcat(buffer, GetRomNameWithoutExtension().c_str());
|
||||
}
|
||||
|
||||
std::string extension() {
|
||||
|
||||
for(int i = int(path.size()) - 1; i >= 0; --i)
|
||||
{
|
||||
if (path[i] == '.') {
|
||||
return path.substr(i+1);
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
std::string noextension() {
|
||||
|
||||
for(int i = int(path.size()) - 1; i >= 0; --i)
|
||||
{
|
||||
if (path[i] == '.') {
|
||||
return path.substr(0, i);
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
void formatname(char *output)
|
||||
{
|
||||
char file[MAX_PATH];
|
||||
time_t now = time(NULL);
|
||||
tm *time_struct = localtime(&now);
|
||||
srand(now);
|
||||
|
||||
for(int i = 0; i < MAX_FORMAT;i++)
|
||||
{
|
||||
char *c = &screenshotFormat[i];
|
||||
char tmp[MAX_PATH];
|
||||
|
||||
if(*c == '%')
|
||||
{
|
||||
c = &screenshotFormat[++i];
|
||||
switch(*c)
|
||||
{
|
||||
case 'f':
|
||||
|
||||
strcat(tmp, GetRomNameWithoutExtension().c_str());
|
||||
break;
|
||||
case 'D':
|
||||
strftime(tmp, MAX_PATH, "%d", time_struct);
|
||||
break;
|
||||
case 'M':
|
||||
strftime(tmp, MAX_PATH, "%m", time_struct);
|
||||
break;
|
||||
case 'Y':
|
||||
strftime(tmp, MAX_PATH, "%Y", time_struct);
|
||||
break;
|
||||
case 'h':
|
||||
strftime(tmp, MAX_PATH, "%H", time_struct);
|
||||
break;
|
||||
case 'm':
|
||||
strftime(tmp, MAX_PATH, "%M", time_struct);
|
||||
break;
|
||||
case 's':
|
||||
strftime(tmp, MAX_PATH, "%S", time_struct);
|
||||
break;
|
||||
case 'r':
|
||||
sprintf(tmp, "%d", rand() % RAND_MAX);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int j;
|
||||
for(j=i;j<MAX_FORMAT-i;j++)
|
||||
if(screenshotFormat[j] != '%')
|
||||
tmp[j-i]=screenshotFormat[j];
|
||||
else
|
||||
break;
|
||||
tmp[j-i]='\0';
|
||||
}
|
||||
strcat(file, tmp);
|
||||
}
|
||||
strncpy(output, file, MAX_PATH);
|
||||
}
|
||||
|
||||
enum ImageFormat
|
||||
{
|
||||
#ifdef WIN32
|
||||
PNG = IDC_PNG,
|
||||
BMP = IDC_BMP
|
||||
#else
|
||||
PNG,
|
||||
BMP
|
||||
#endif
|
||||
};
|
||||
|
||||
ImageFormat currentimageformat;
|
||||
|
||||
ImageFormat imageformat() {
|
||||
return currentimageformat;
|
||||
}
|
||||
|
||||
void SetRomName(const char *filename)
|
||||
{
|
||||
std::string str = filename;
|
||||
|
||||
//Truncate the path from filename
|
||||
int x = str.find_last_of("/\\");
|
||||
if (x > 0)
|
||||
str = str.substr(x+1);
|
||||
RomName = str;
|
||||
}
|
||||
|
||||
const char *GetRomName()
|
||||
{
|
||||
return RomName.c_str();
|
||||
}
|
||||
|
||||
std::string GetRomNameWithoutExtension()
|
||||
{
|
||||
int x = RomName.find_last_of(".");
|
||||
if (x > 0)
|
||||
return RomName.substr(0,x);
|
||||
else return RomName;
|
||||
}
|
||||
|
||||
bool isdsgba() {
|
||||
std::string str = path;
|
||||
int x = str.find_last_of(".");
|
||||
if (x > 0)
|
||||
str = str.substr(x-2);
|
||||
if(!strcmp(str.c_str(), "ds.gba"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
extern PathInfo path;
|
|
@ -40,6 +40,8 @@
|
|||
#include "gfx3d.h"
|
||||
#include "movie.h"
|
||||
|
||||
#include "path.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "windows/main.h"
|
||||
#endif
|
||||
|
@ -460,11 +462,7 @@ void scan_savestates()
|
|||
|
||||
for( i = 1; i <= NB_STATES; i++ )
|
||||
{
|
||||
#ifdef WIN32
|
||||
GetFullPathNoExt(STATES, filename, MAX_PATH);
|
||||
#else
|
||||
strncpy(filename, pathFilenameToROMwithoutExt, MAX_PATH);
|
||||
#endif
|
||||
path.getpathnoext(path.STATES, filename);
|
||||
|
||||
if (strlen(filename) + strlen(".dst") + strlen("-2147483648") /* = biggest string for i */ >MAX_PATH) return ;
|
||||
sprintf(filename+strlen(filename), ".ds%d", i);
|
||||
|
@ -483,11 +481,7 @@ void savestate_slot(int num)
|
|||
|
||||
lastSaveState = num; //Set last savestate used
|
||||
|
||||
#ifdef WIN32
|
||||
GetFullPathNoExt(STATES, filename, MAX_PATH);
|
||||
#else
|
||||
strncpy(filename, pathFilenameToROMwithoutExt, MAX_PATH);
|
||||
#endif
|
||||
path.getpathnoext(path.STATES, filename);
|
||||
|
||||
if (strlen(filename) + strlen(".dsx") + strlen("-2147483648") /* = biggest string for num */ >MAX_PATH) return ;
|
||||
sprintf(filename+strlen(filename), ".ds%d", num);
|
||||
|
@ -515,11 +509,7 @@ void loadstate_slot(int num)
|
|||
|
||||
lastSaveState = num; //Set last savestate used
|
||||
|
||||
#ifdef WIN32
|
||||
GetFullPathNoExt(STATES, filename, MAX_PATH);
|
||||
#else
|
||||
strncpy(filename, pathFilenameToROMwithoutExt, MAX_PATH);
|
||||
#endif
|
||||
path.getpathnoext(path.STATES, filename);
|
||||
|
||||
if (strlen(filename) + strlen(".dsx") + strlen("-2147483648") /* = biggest string for num */ >MAX_PATH) return ;
|
||||
sprintf(filename+strlen(filename), ".ds%d", num);
|
||||
|
|
|
@ -1131,6 +1131,10 @@
|
|||
RelativePath="..\OGLRender.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\path.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\rasterize.h"
|
||||
>
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "../GPU.h"
|
||||
#include "pathsettings.h"
|
||||
#include "GPU_osd.h"
|
||||
#include "path.h"
|
||||
|
||||
extern LRESULT OpenFile(); //adelikat: Made this an extern here instead of main.h Seemed icky not to limit the scope of this function
|
||||
|
||||
|
@ -93,24 +94,23 @@ void HK_PrintScreen(int param)
|
|||
ofn.Flags = OFN_OVERWRITEPROMPT;
|
||||
|
||||
ZeroMemory(filename, sizeof(filename));
|
||||
// GetPathFor(SCREENSHOTS, filename, MAX_PATH);
|
||||
path.getpath(path.SCREENSHOTS, filename);
|
||||
|
||||
char file[MAX_PATH];
|
||||
ZeroMemory(file, sizeof(file));
|
||||
FormatName(file, MAX_PATH);
|
||||
path.formatname(file);
|
||||
strcat(filename, file);
|
||||
int len = strlen(filename);
|
||||
if(len > MAX_PATH - 4)
|
||||
filename[MAX_PATH - 4] = '\0';
|
||||
|
||||
ImageFormat format = GetImageFormatType();
|
||||
if(format == PNG)
|
||||
if(path.imageformat() == path.PNG)
|
||||
{
|
||||
strcat(filename, ".png");
|
||||
ofn.lpstrDefExt = "png";
|
||||
ofn.nFilterIndex = 1;
|
||||
}
|
||||
else if(format == BMP)
|
||||
else if(path.imageformat() == path.BMP)
|
||||
{
|
||||
strcat(filename, ".bmp");
|
||||
ofn.lpstrDefExt = "bmp";
|
||||
|
|
|
@ -86,6 +86,7 @@
|
|||
#include "utils/xstring.h"
|
||||
#include "directx/ddraw.h"
|
||||
#include "video.h"
|
||||
#include "path.h"
|
||||
|
||||
#include "aggdraw.h"
|
||||
#include "agg2d.h"
|
||||
|
@ -1111,10 +1112,6 @@ static BOOL LoadROM(const char * filename, const char * logicalName)
|
|||
NDS_Pause();
|
||||
//if (strcmp(filename,"")!=0) INFO("Attempting to load ROM: %s\n",filename);
|
||||
|
||||
//extract the internal part of the logical rom name
|
||||
std::vector<std::string> parts = tokenize_str(logicalName,"|");
|
||||
SetRomName(parts[parts.size()-1].c_str());
|
||||
|
||||
if (NDS_LoadROM(filename, logicalName) > 0)
|
||||
{
|
||||
INFO("Loading %s was successful\n",logicalName);
|
||||
|
@ -1985,11 +1982,11 @@ void AviRecordTo()
|
|||
|
||||
char folder[MAX_PATH];
|
||||
ZeroMemory(folder, sizeof(folder));
|
||||
GetPathFor(AVI_FILES, folder, MAX_PATH);
|
||||
path.getpath(path.AVI_FILES, folder);
|
||||
|
||||
char file[MAX_PATH];
|
||||
ZeroMemory(file, sizeof(file));
|
||||
FormatName(file, MAX_PATH);
|
||||
path.formatname(file);
|
||||
|
||||
strcat(folder, file);
|
||||
int len = strlen(folder);
|
||||
|
@ -2169,7 +2166,7 @@ LRESULT OpenFile()
|
|||
|
||||
char buffer[MAX_PATH];
|
||||
ZeroMemory(buffer, sizeof(buffer));
|
||||
GetPathFor(ROMS, buffer, MAX_PATH);
|
||||
path.getpath(path.ROMS, buffer);
|
||||
ofn.lpstrInitialDir = buffer;
|
||||
|
||||
|
||||
|
@ -2178,7 +2175,7 @@ LRESULT OpenFile()
|
|||
return 0;
|
||||
}
|
||||
else {
|
||||
if(SavePathForRomVisit())
|
||||
if(path.savelastromvisit)
|
||||
{
|
||||
char *lchr, buffer[MAX_PATH];
|
||||
ZeroMemory(buffer, sizeof(buffer));
|
||||
|
@ -2186,7 +2183,7 @@ LRESULT OpenFile()
|
|||
lchr = strrchr(filename, '\\');
|
||||
strncpy(buffer, filename, strlen(filename) - strlen(lchr));
|
||||
|
||||
SetPathFor(ROMS, buffer);
|
||||
path.setpath(path.ROMS, buffer);
|
||||
WritePathSettings();
|
||||
}
|
||||
}
|
||||
|
@ -2512,7 +2509,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
|
||||
case WM_CREATE:
|
||||
{
|
||||
ReadPathSettings();
|
||||
path.ReadPathSettings();
|
||||
pausedByMinimize = FALSE;
|
||||
UpdateScreenRects();
|
||||
return 0;
|
||||
|
@ -2780,25 +2777,25 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
{
|
||||
char buffer[MAX_PATH];
|
||||
ZeroMemory(buffer, sizeof(buffer));
|
||||
GetPathFor(SCREENSHOTS, buffer, MAX_PATH);
|
||||
path.getpath(path.SCREENSHOTS, buffer);
|
||||
|
||||
char file[MAX_PATH];
|
||||
ZeroMemory(file, sizeof(file));
|
||||
FormatName(file, MAX_PATH);
|
||||
path.formatname(file);
|
||||
|
||||
strcat(buffer, file);
|
||||
if( strlen(buffer) > (MAX_PATH - 4))
|
||||
buffer[MAX_PATH - 4] = '\0';
|
||||
|
||||
switch(GetImageFormatType())
|
||||
switch(path.imageformat())
|
||||
{
|
||||
case PNG:
|
||||
case path.PNG:
|
||||
{
|
||||
strcat(buffer, ".png");
|
||||
NDS_WritePNG(buffer);
|
||||
}
|
||||
break;
|
||||
case BMP:
|
||||
case path.BMP:
|
||||
{
|
||||
strcat(buffer, ".bmp");
|
||||
NDS_WriteBMP(buffer);
|
||||
|
@ -2862,7 +2859,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
|
||||
char buffer[MAX_PATH];
|
||||
ZeroMemory(buffer, sizeof(buffer));
|
||||
GetPathFor(STATES, buffer, MAX_PATH);
|
||||
path.getpath(path.STATES, buffer);
|
||||
ofn.lpstrInitialDir = buffer;
|
||||
|
||||
if(!GetOpenFileName(&ofn))
|
||||
|
@ -2892,7 +2889,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
|
||||
char buffer[MAX_PATH];
|
||||
ZeroMemory(buffer, sizeof(buffer));
|
||||
GetPathFor(STATES, buffer, MAX_PATH);
|
||||
path.getpath(path.STATES, buffer);
|
||||
ofn.lpstrInitialDir = buffer;
|
||||
|
||||
if(!GetSaveFileName(&ofn))
|
||||
|
@ -2963,7 +2960,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
|
||||
char buffer[MAX_PATH];
|
||||
ZeroMemory(buffer, sizeof(buffer));
|
||||
GetPathFor(BATTERY, buffer, MAX_PATH);
|
||||
path.getpath(path.BATTERY, buffer);
|
||||
ofn.lpstrInitialDir = buffer;
|
||||
|
||||
if(!GetOpenFileName(&ofn))
|
||||
|
@ -3734,7 +3731,7 @@ LRESULT CALLBACK EmulationSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, L
|
|||
|
||||
char buffer[MAX_PATH];
|
||||
ZeroMemory(buffer, sizeof(buffer));
|
||||
GetPathFor(FIRMWARE, buffer, MAX_PATH);
|
||||
path.getpath(path.FIRMWARE, buffer);
|
||||
ofn.lpstrInitialDir = buffer;
|
||||
|
||||
if(GetOpenFileName(&ofn))
|
||||
|
@ -3839,7 +3836,7 @@ LRESULT CALLBACK MicrophoneSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
|
|||
|
||||
char buffer[MAX_PATH];
|
||||
ZeroMemory(buffer, sizeof(buffer));
|
||||
GetPathFor(SOUNDS, buffer, MAX_PATH);
|
||||
path.getpath(path.SOUNDS, buffer);
|
||||
ofn.lpstrInitialDir = buffer;
|
||||
|
||||
if(GetOpenFileName(&ofn))
|
||||
|
|
|
@ -17,76 +17,96 @@
|
|||
along with DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* notes: will not save paths for current session if IDCANCEL is sent it
|
||||
will only change paths for that session
|
||||
|
||||
the only way paths will be saved is if IDOK is sent
|
||||
|
||||
the default paths are saved on first load
|
||||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "common.h"
|
||||
#include <windowsx.h>
|
||||
#include <shlobj.h>
|
||||
#include <commctrl.h>
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include "main.h"
|
||||
#include "NDSSystem.h"
|
||||
#include "pathSettings.h"
|
||||
#include "../debug.h"
|
||||
#include "common.h"
|
||||
#include "path.h"
|
||||
#include "pathsettings.h"
|
||||
|
||||
/*macros to forward messages
|
||||
the dialog procedure was getting long and confusing for me
|
||||
*/
|
||||
#define HANDLE_DLGMSG(hwnd, message, fn) \
|
||||
case (message): return (SetDlgMsgResult(hDlg, uMsg, \
|
||||
HANDLE_##message( (hwnd), (wParam), (lParam), (fn) ) ) )
|
||||
|
||||
|
||||
/*variable declaration*/
|
||||
|
||||
char pathToRoms[MAX_PATH];
|
||||
char pathToBattery[MAX_PATH];
|
||||
char pathToStates[MAX_PATH];
|
||||
char pathToScreenshots[MAX_PATH];
|
||||
char pathToAviFiles[MAX_PATH];
|
||||
char pathToCheats[MAX_PATH];
|
||||
char pathToSounds[MAX_PATH];
|
||||
char pathToFirmware[MAX_PATH];
|
||||
char pathToModule[MAX_PATH];
|
||||
char pathToLua[MAX_PATH];
|
||||
char screenshotFormat[MAX_FORMAT];
|
||||
|
||||
char *currentSelection = 0;
|
||||
char *currentKey = 0;
|
||||
|
||||
BOOL romsLastVisit = FALSE;
|
||||
BOOL needsSaving = FALSE;
|
||||
|
||||
ImageFormat defaultFormat = PNG;
|
||||
|
||||
/* end variable declaration*/
|
||||
|
||||
/*private functions*/
|
||||
|
||||
void ReadKey(char *pathToRead, const char *key)
|
||||
void WritePathSettings()
|
||||
{
|
||||
ZeroMemory(pathToRead, sizeof(pathToRead));
|
||||
GetPrivateProfileString(SECTION, key, key, pathToRead, MAX_PATH, IniName);
|
||||
if(strcmp(pathToRead, key) == 0)
|
||||
//since the variables are all intialized in this file they all use MAX_PATH
|
||||
GetDefaultPath(pathToRead, key, MAX_PATH);
|
||||
WritePrivateProfileString(SECTION, ROMKEY, path.pathToRoms, IniName);
|
||||
WritePrivateProfileString(SECTION, BATTERYKEY, path.pathToBattery, IniName);
|
||||
WritePrivateProfileString(SECTION, STATEKEY, path.pathToStates, IniName);
|
||||
WritePrivateProfileString(SECTION, SCREENSHOTKEY, path.pathToScreenshots, IniName);
|
||||
WritePrivateProfileString(SECTION, AVIKEY, path.pathToAviFiles, IniName);
|
||||
WritePrivateProfileString(SECTION, CHEATKEY, path.pathToCheats, IniName);
|
||||
WritePrivateProfileString(SECTION, SOUNDKEY, path.pathToSounds, IniName);
|
||||
WritePrivateProfileString(SECTION, FIRMWAREKEY, path.pathToFirmware, IniName);
|
||||
WritePrivateProfileString(SECTION, LUAKEY, path.pathToLua, IniName);
|
||||
|
||||
WritePrivateProfileString(SECTION, FORMATKEY, path.screenshotFormat, IniName);
|
||||
|
||||
WritePrivateProfileInt(SECTION, LASTVISITKEY, path.savelastromvisit, IniName);
|
||||
// WritePrivateProfileInt(SECTION, DEFAULTFORMATKEY, defaultFormat, IniName);
|
||||
// WritePrivateProfileInt(SECTION, NEEDSSAVINGKEY, needsSaving, IniName);
|
||||
}
|
||||
|
||||
int InitialFolder(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
|
||||
BOOL PathSettings_OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam)
|
||||
{
|
||||
if(uMsg == BFFM_INITIALIZED)
|
||||
{
|
||||
SendMessage(hwnd, BFFM_SETSELECTION, (WPARAM)TRUE, lpData);
|
||||
}
|
||||
return 0;
|
||||
HWND hwnd = GetDlgItem(hDlg, IDC_PATHLIST);
|
||||
/* ComboBox_AddString(hwnd, ROMKEY);
|
||||
ComboBox_AddString(hwnd, BATTERYKEY);
|
||||
ComboBox_AddString(hwnd, STATEKEY);
|
||||
ComboBox_AddString(hwnd, SCREENSHOTKEY);
|
||||
ComboBox_AddString(hwnd, AVIKEY);
|
||||
ComboBox_AddString(hwnd, CHEATKEY);
|
||||
ComboBox_AddString(hwnd, SOUNDKEY);
|
||||
ComboBox_AddString(hwnd, FIRMWAREKEY);
|
||||
|
||||
ComboBox_SetCurSel(hwnd, 0);*/
|
||||
// PathSettings_OnSelChange(hDlg, NULL);
|
||||
|
||||
CheckDlgButton(hDlg, IDC_USELASTVISIT, (path.savelastromvisit) ? BST_CHECKED : BST_UNCHECKED);
|
||||
CheckRadioButton(hDlg, IDC_PNG, IDC_BMP, (int)path.imageformat());
|
||||
|
||||
// IDC_FORMATEDIT setup
|
||||
SetDlgItemText(hDlg, IDC_FORMATEDIT, path.screenshotFormat);
|
||||
|
||||
hwnd = GetDlgItem(hDlg, IDC_FORMATEDIT);
|
||||
Edit_LimitText(hwnd, MAX_FORMAT);
|
||||
|
||||
HWND toolTip = CreateWindowEx(NULL,
|
||||
TOOLTIPS_CLASS, NULL,
|
||||
TTS_ALWAYSTIP,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
hDlg, NULL,
|
||||
hAppInst, NULL);
|
||||
SendMessage(toolTip, TTM_SETMAXTIPWIDTH, NULL, (LPARAM)330);
|
||||
|
||||
SetWindowPos(toolTip, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
||||
|
||||
SetDlgItemText(hDlg, IDC_ROMPATHEDIT, path.pathToRoms);
|
||||
SetDlgItemText(hDlg, IDC_SAVERAMPATHEDIT, path.pathToBattery);
|
||||
SetDlgItemText(hDlg, IDC_STATEPATHEDIT, path.pathToStates);
|
||||
SetDlgItemText(hDlg, IDC_SCREENSHOTPATHEDIT, path.pathToScreenshots);
|
||||
SetDlgItemText(hDlg, IDC_AVIPATHEDIT, path.pathToAviFiles);
|
||||
SetDlgItemText(hDlg, IDC_CHEATPATHEDIT, path.pathToCheats);
|
||||
SetDlgItemText(hDlg, IDC_LUAPATHEDIT, path.pathToLua);
|
||||
|
||||
TOOLINFO ti;
|
||||
ZeroMemory(&ti, sizeof(ti));
|
||||
ti.cbSize = sizeof(ti);
|
||||
ti.hwnd = hDlg;
|
||||
ti.hinst = hAppInst;
|
||||
ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
|
||||
ti.uId = (UINT_PTR)hwnd;
|
||||
ti.lpszText = "The format a screenshot should be saved in.\r\n%f\t\t\tFilename\r\n%D\t\t\tDay:Two Digit\r\n%M\t\t\tMonth:Two Digit\r\n%Y\t\t\tYear:Four Digit\r\n%h\t\t\tHour:Two Digit\r\n%m\t\t\tMinute: Two Digit\r\n%s\t\t\tSecond: Two Digit\r\n%r\t\tRandom: Min:0 Max:RAND_MAX";
|
||||
GetClientRect(hwnd, &ti.rect);
|
||||
SendMessage(toolTip, TTM_ADDTOOL, NULL, (LPARAM)&ti);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL BrowseForPath(char *pathToBrowse)
|
||||
|
@ -125,318 +145,6 @@ BOOL BrowseForPath(char *pathToBrowse)
|
|||
return changed;
|
||||
}
|
||||
|
||||
void LoadModulePath()
|
||||
{
|
||||
//stolen from common.cpp GetINIPath
|
||||
char *p;
|
||||
ZeroMemory(pathToModule, sizeof(pathToModule));
|
||||
GetModuleFileName(NULL, pathToModule, sizeof(pathToModule));
|
||||
p = pathToModule + lstrlen(pathToModule);
|
||||
while (p >= pathToModule && *p != '\\') p--;
|
||||
if (++p >= pathToModule) *p = 0;
|
||||
}
|
||||
|
||||
void SwitchPath(Action action, KnownPath path, char * buffer, int maxCount)
|
||||
{
|
||||
char *pathToCopy = 0;
|
||||
switch(path)
|
||||
{
|
||||
case ROMS:
|
||||
pathToCopy = pathToRoms;
|
||||
break;
|
||||
case BATTERY:
|
||||
pathToCopy = pathToBattery;
|
||||
break;
|
||||
case STATES:
|
||||
pathToCopy = pathToStates;
|
||||
break;
|
||||
case SCREENSHOTS:
|
||||
pathToCopy = pathToScreenshots;
|
||||
break;
|
||||
case AVI_FILES:
|
||||
pathToCopy = pathToAviFiles;
|
||||
break;
|
||||
case CHEATS:
|
||||
pathToCopy = pathToCheats;
|
||||
break;
|
||||
case SOUNDS:
|
||||
pathToCopy = pathToSounds;
|
||||
break;
|
||||
case FIRMWARE:
|
||||
pathToCopy = pathToFirmware;
|
||||
break;
|
||||
case MODULE:
|
||||
pathToCopy = pathToModule;
|
||||
break;
|
||||
}
|
||||
|
||||
if(action == GET)
|
||||
{
|
||||
strncpy(buffer, pathToCopy, maxCount);
|
||||
int len = strlen(buffer)-1;
|
||||
if(buffer[len] != '\\')
|
||||
strcat(buffer, "\\");
|
||||
}
|
||||
else if(action == SET)
|
||||
{
|
||||
int len = strlen(buffer)-1;
|
||||
if(buffer[len] == '\\')
|
||||
buffer[len] = '\0';
|
||||
|
||||
strncpy(pathToCopy, buffer, MAX_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
/* end private functions */
|
||||
|
||||
/* public functions */
|
||||
|
||||
//returns "filename"
|
||||
void GetFilename(char *buffer, int maxCount)
|
||||
{
|
||||
strcpy(buffer,GetRomNameWithoutExtension().c_str());
|
||||
}
|
||||
|
||||
void GetFullPathNoExt(KnownPath path, char *buffer, int maxCount)
|
||||
{
|
||||
GetPathFor(path, buffer, maxCount);
|
||||
char filename[MAX_PATH];
|
||||
ZeroMemory(filename, sizeof(filename));
|
||||
GetFilename(filename, MAX_PATH);
|
||||
strcat(buffer, filename);
|
||||
}
|
||||
|
||||
void GetPathFor(KnownPath path, char *buffer, int maxCount)
|
||||
{
|
||||
SwitchPath(GET, path, buffer, maxCount);
|
||||
}
|
||||
|
||||
void SetPathFor(KnownPath path, char *buffer)
|
||||
{
|
||||
SwitchPath(SET, path, buffer, 0);
|
||||
}
|
||||
|
||||
void GetDefaultPath(char *pathToDefault, const char *key, int maxCount)
|
||||
{
|
||||
strncpy(pathToDefault, pathToModule, maxCount);
|
||||
// strcat(pathToDefault, key);
|
||||
|
||||
// if(GetFileAttributes(pathToDefault) == INVALID_FILE_ATTRIBUTES)
|
||||
// CreateDirectory(pathToDefault, NULL);
|
||||
}
|
||||
|
||||
void WritePathSettings()
|
||||
{
|
||||
WritePrivateProfileString(SECTION, ROMKEY, pathToRoms, IniName);
|
||||
WritePrivateProfileString(SECTION, BATTERYKEY, pathToBattery, IniName);
|
||||
WritePrivateProfileString(SECTION, STATEKEY, pathToStates, IniName);
|
||||
WritePrivateProfileString(SECTION, SCREENSHOTKEY, pathToScreenshots, IniName);
|
||||
WritePrivateProfileString(SECTION, AVIKEY, pathToAviFiles, IniName);
|
||||
WritePrivateProfileString(SECTION, CHEATKEY, pathToCheats, IniName);
|
||||
WritePrivateProfileString(SECTION, SOUNDKEY, pathToSounds, IniName);
|
||||
WritePrivateProfileString(SECTION, FIRMWAREKEY, pathToFirmware, IniName);
|
||||
WritePrivateProfileString(SECTION, LUAKEY, pathToLua, IniName);
|
||||
|
||||
WritePrivateProfileString(SECTION, FORMATKEY, screenshotFormat, IniName);
|
||||
|
||||
WritePrivateProfileInt(SECTION, LASTVISITKEY, romsLastVisit, IniName);
|
||||
WritePrivateProfileInt(SECTION, DEFAULTFORMATKEY, defaultFormat, IniName);
|
||||
WritePrivateProfileInt(SECTION, NEEDSSAVINGKEY, needsSaving, IniName);
|
||||
}
|
||||
|
||||
void ReadPathSettings()
|
||||
{
|
||||
if( ( strcmp(pathToModule, "") == 0) || !pathToModule)
|
||||
LoadModulePath();
|
||||
|
||||
ReadKey(pathToRoms, ROMKEY);
|
||||
ReadKey(pathToBattery, BATTERYKEY);
|
||||
ReadKey(pathToStates, STATEKEY);
|
||||
ReadKey(pathToScreenshots, SCREENSHOTKEY);
|
||||
ReadKey(pathToAviFiles, AVIKEY);
|
||||
ReadKey(pathToCheats, CHEATKEY);
|
||||
ReadKey(pathToSounds, SOUNDKEY);
|
||||
ReadKey(pathToFirmware, FIRMWAREKEY);
|
||||
ReadKey(pathToLua, LUAKEY);
|
||||
|
||||
GetPrivateProfileString(SECTION, FORMATKEY, "%f_%s_%r", screenshotFormat, MAX_FORMAT, IniName);
|
||||
|
||||
romsLastVisit = GetPrivateProfileInt(SECTION, LASTVISITKEY, TRUE, IniName);
|
||||
defaultFormat = (ImageFormat)GetPrivateProfileInt(SECTION, DEFAULTFORMATKEY, PNG, IniName);
|
||||
|
||||
needsSaving = GetPrivateProfileInt(SECTION, NEEDSSAVINGKEY, TRUE, IniName);
|
||||
if(needsSaving)
|
||||
{
|
||||
needsSaving = FALSE;
|
||||
WritePathSettings();
|
||||
}
|
||||
}
|
||||
|
||||
ImageFormat GetImageFormatType()
|
||||
{
|
||||
return defaultFormat;
|
||||
}
|
||||
|
||||
void FormatName(char *output, int maxCount)
|
||||
{
|
||||
char file[MAX_PATH];
|
||||
ZeroMemory(file, sizeof(file));
|
||||
time_t now = time(NULL);
|
||||
tm *time_struct = localtime(&now);
|
||||
srand(now);
|
||||
|
||||
for(int i = 0; i < MAX_FORMAT;i++)
|
||||
{
|
||||
char *c = &screenshotFormat[i];
|
||||
char tmp[MAX_PATH];
|
||||
ZeroMemory(tmp, sizeof(tmp));
|
||||
|
||||
if(*c == '%')
|
||||
{
|
||||
c = &screenshotFormat[++i];
|
||||
switch(*c)
|
||||
{
|
||||
case 'f':
|
||||
GetFilename(tmp, MAX_PATH);
|
||||
break;
|
||||
case 'D':
|
||||
strftime(tmp, MAX_PATH, "%d", time_struct);
|
||||
break;
|
||||
case 'M':
|
||||
strftime(tmp, MAX_PATH, "%m", time_struct);
|
||||
break;
|
||||
case 'Y':
|
||||
strftime(tmp, MAX_PATH, "%Y", time_struct);
|
||||
break;
|
||||
case 'h':
|
||||
strftime(tmp, MAX_PATH, "%H", time_struct);
|
||||
break;
|
||||
case 'm':
|
||||
strftime(tmp, MAX_PATH, "%M", time_struct);
|
||||
break;
|
||||
case 's':
|
||||
strftime(tmp, MAX_PATH, "%S", time_struct);
|
||||
break;
|
||||
case 'r':
|
||||
sprintf(tmp, "%d", rand() % RAND_MAX);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int j;
|
||||
for(j=i;j<MAX_FORMAT-i;j++)
|
||||
if(screenshotFormat[j] != '%')
|
||||
tmp[j-i]=screenshotFormat[j];
|
||||
else
|
||||
break;
|
||||
tmp[j-i]='\0';
|
||||
}
|
||||
strcat(file, tmp);
|
||||
}
|
||||
strncpy(output, file, maxCount);
|
||||
}
|
||||
|
||||
BOOL SavePathForRomVisit()
|
||||
{
|
||||
return romsLastVisit;
|
||||
}
|
||||
/* end public functions
|
||||
|
||||
/*class functions*/
|
||||
|
||||
void HideControls(HWND hDlg)
|
||||
{/*
|
||||
HWND h = GetDlgItem(hDlg, IDC_USELASTVISIT);
|
||||
ShowWindow(h, SW_HIDE);
|
||||
|
||||
h = GetDlgItem(hDlg, IDC_SAVEAS);
|
||||
ShowWindow(h, SW_HIDE);
|
||||
|
||||
h = GetDlgItem(hDlg, IDC_PNG);
|
||||
ShowWindow(h, SW_HIDE);
|
||||
|
||||
h = GetDlgItem(hDlg, IDC_BMP);
|
||||
ShowWindow(h, SW_HIDE);
|
||||
|
||||
h = GetDlgItem(hDlg, IDC_FORMATSTATIC);
|
||||
ShowWindow(h, SW_HIDE);
|
||||
|
||||
h = GetDlgItem(hDlg, IDC_FORMATEDIT);
|
||||
ShowWindow(h, SW_HIDE);*/
|
||||
}
|
||||
|
||||
void PathSettings_OnSelChange(HWND hDlg, HWND hwndCtl)
|
||||
{
|
||||
/* HideControls(hDlg);
|
||||
|
||||
switch(ComboBox_GetCurSel(hwndCtl))
|
||||
{
|
||||
case ROMS:
|
||||
{
|
||||
currentSelection = pathToRoms;
|
||||
currentKey = ROMKEY;
|
||||
HWND h = GetDlgItem(hDlg, IDC_USELASTVISIT);
|
||||
ShowWindow(h, SW_SHOWNA);
|
||||
}
|
||||
break;
|
||||
case BATTERY:
|
||||
currentSelection = pathToBattery;
|
||||
currentKey = BATTERYKEY;
|
||||
break;
|
||||
case STATES:
|
||||
currentSelection = pathToStates;
|
||||
currentKey = STATEKEY;
|
||||
break;
|
||||
case SCREENSHOTS:
|
||||
{
|
||||
currentSelection = pathToScreenshots;
|
||||
currentKey = SCREENSHOTKEY;
|
||||
|
||||
HWND h = GetDlgItem(hDlg, IDC_SAVEAS);
|
||||
ShowWindow(h, SW_SHOWNA);
|
||||
|
||||
h = GetDlgItem(hDlg, IDC_PNG);
|
||||
ShowWindow(h, SW_SHOWNA);
|
||||
|
||||
h = GetDlgItem(hDlg, IDC_BMP);
|
||||
ShowWindow(h, SW_SHOWNA);
|
||||
|
||||
h = GetDlgItem(hDlg, IDC_FORMATSTATIC);
|
||||
ShowWindow(h, SW_SHOWNA);
|
||||
|
||||
h = GetDlgItem(hDlg, IDC_FORMATEDIT);
|
||||
ShowWindow(h, SW_SHOWNA);
|
||||
}
|
||||
break;
|
||||
case AVI_FILES:
|
||||
{
|
||||
currentSelection = pathToAviFiles;
|
||||
currentKey = AVIKEY;
|
||||
|
||||
HWND h = GetDlgItem(hDlg, IDC_FORMATSTATIC);
|
||||
ShowWindow(h, SW_SHOWNA);
|
||||
|
||||
h = GetDlgItem(hDlg, IDC_FORMATEDIT);
|
||||
ShowWindow(h, SW_SHOWNA);
|
||||
}
|
||||
break;
|
||||
case CHEATS:
|
||||
currentSelection = pathToCheats;
|
||||
currentKey = CHEATKEY;
|
||||
break;
|
||||
case SOUNDS:
|
||||
currentSelection = pathToSounds;
|
||||
currentKey = SOUNDKEY;
|
||||
break;
|
||||
case FIRMWARE:
|
||||
currentSelection = pathToFirmware;
|
||||
currentKey = FIRMWAREKEY;
|
||||
break;
|
||||
}
|
||||
SetDlgItemText(hDlg, IDC_PATHEDIT, currentSelection);*/
|
||||
|
||||
}
|
||||
|
||||
void PathSettings_OnCommand(HWND hDlg, int id, HWND hwndCtl, UINT codeNotify)
|
||||
{
|
||||
|
@ -444,44 +152,44 @@ void PathSettings_OnCommand(HWND hDlg, int id, HWND hwndCtl, UINT codeNotify)
|
|||
{
|
||||
case IDC_BROWSEROMS:
|
||||
{
|
||||
if(BrowseForPath(pathToRoms))
|
||||
SetDlgItemText(hDlg, IDC_ROMPATHEDIT, pathToRoms);
|
||||
if(BrowseForPath(path.pathToRoms))
|
||||
SetDlgItemText(hDlg, IDC_ROMPATHEDIT, path.pathToRoms);
|
||||
}
|
||||
break;
|
||||
case IDC_BROWSESRAM:
|
||||
{
|
||||
if(BrowseForPath(pathToBattery))
|
||||
SetDlgItemText(hDlg, IDC_SAVERAMPATHEDIT, pathToBattery);
|
||||
if(BrowseForPath(path.pathToBattery))
|
||||
SetDlgItemText(hDlg, IDC_SAVERAMPATHEDIT, path.pathToBattery);
|
||||
}
|
||||
break;
|
||||
case IDC_BROWSESTATES:
|
||||
{
|
||||
if(BrowseForPath(pathToStates))
|
||||
SetDlgItemText(hDlg, IDC_STATEPATHEDIT, pathToStates);
|
||||
if(BrowseForPath(path.pathToStates))
|
||||
SetDlgItemText(hDlg, IDC_STATEPATHEDIT, path.pathToStates);
|
||||
}
|
||||
break;
|
||||
case IDC_BROWSESCREENSHOTS:
|
||||
{
|
||||
if(BrowseForPath(pathToScreenshots))
|
||||
SetDlgItemText(hDlg, IDC_SCREENSHOTPATHEDIT, pathToScreenshots);
|
||||
if(BrowseForPath(path.pathToScreenshots))
|
||||
SetDlgItemText(hDlg, IDC_SCREENSHOTPATHEDIT, path.pathToScreenshots);
|
||||
}
|
||||
break;
|
||||
case IDC_BROWSEAVI:
|
||||
{
|
||||
if(BrowseForPath(pathToAviFiles))
|
||||
SetDlgItemText(hDlg, IDC_AVIPATHEDIT, pathToAviFiles);
|
||||
if(BrowseForPath(path.pathToAviFiles))
|
||||
SetDlgItemText(hDlg, IDC_AVIPATHEDIT, path.pathToAviFiles);
|
||||
}
|
||||
break;
|
||||
case IDC_BROWSECHEATS:
|
||||
{
|
||||
if(BrowseForPath(pathToCheats))
|
||||
SetDlgItemText(hDlg, IDC_CHEATPATHEDIT, pathToCheats);
|
||||
if(BrowseForPath(path.pathToCheats))
|
||||
SetDlgItemText(hDlg, IDC_CHEATPATHEDIT, path.pathToCheats);
|
||||
}
|
||||
break;
|
||||
case IDC_BROWSELUA:
|
||||
{
|
||||
if(BrowseForPath(pathToLua))
|
||||
SetDlgItemText(hDlg, IDC_LUAPATHEDIT, pathToLua);
|
||||
if(BrowseForPath(path.pathToLua))
|
||||
SetDlgItemText(hDlg, IDC_LUAPATHEDIT, path.pathToLua);
|
||||
}
|
||||
break;
|
||||
case IDC_PATHDEFAULTS:
|
||||
|
@ -492,23 +200,23 @@ void PathSettings_OnCommand(HWND hDlg, int id, HWND hwndCtl, UINT codeNotify)
|
|||
break;
|
||||
case IDC_PNG:
|
||||
CheckRadioButton(hDlg, IDC_PNG, IDC_BMP, IDC_PNG);
|
||||
defaultFormat = PNG;
|
||||
path.currentimageformat = path.PNG;
|
||||
break;
|
||||
case IDC_BMP:
|
||||
CheckRadioButton(hDlg, IDC_PNG, IDC_BMP, IDC_BMP);
|
||||
defaultFormat = BMP;
|
||||
path.currentimageformat = path.BMP;
|
||||
break;
|
||||
case IDC_USELASTVISIT:
|
||||
{
|
||||
romsLastVisit = !romsLastVisit;
|
||||
CheckDlgButton(hDlg, IDC_USELASTVISIT, (romsLastVisit) ? BST_CHECKED : BST_UNCHECKED);
|
||||
path.savelastromvisit = !path.savelastromvisit;
|
||||
CheckDlgButton(hDlg, IDC_USELASTVISIT, (path.savelastromvisit) ? BST_CHECKED : BST_UNCHECKED);
|
||||
}
|
||||
break;
|
||||
case IDC_PATHLIST:
|
||||
{
|
||||
if(codeNotify == CBN_SELCHANGE)
|
||||
{
|
||||
PathSettings_OnSelChange(hDlg, hwndCtl);
|
||||
// PathSettings_OnSelChange(hDlg, hwndCtl);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -519,88 +227,30 @@ void PathSettings_OnCommand(HWND hDlg, int id, HWND hwndCtl, UINT codeNotify)
|
|||
{
|
||||
char buffer[MAX_FORMAT];
|
||||
GetDlgItemText(hDlg, IDC_FORMATEDIT, buffer, MAX_FORMAT);
|
||||
strncpy(screenshotFormat, buffer, MAX_FORMAT);
|
||||
strncpy(path.screenshotFormat, buffer, MAX_FORMAT);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDOK:
|
||||
|
||||
GetDlgItemText(hDlg, IDC_ROMPATHEDIT, pathToRoms, MAX_PATH);
|
||||
GetDlgItemText(hDlg, IDC_SAVERAMPATHEDIT, pathToBattery, MAX_PATH);
|
||||
GetDlgItemText(hDlg, IDC_STATEPATHEDIT, pathToStates, MAX_PATH);
|
||||
GetDlgItemText(hDlg, IDC_SCREENSHOTPATHEDIT, pathToScreenshots, MAX_PATH);
|
||||
GetDlgItemText(hDlg, IDC_AVIPATHEDIT, pathToAviFiles, MAX_PATH);
|
||||
GetDlgItemText(hDlg, IDC_CHEATPATHEDIT, pathToCheats, MAX_PATH);
|
||||
GetDlgItemText(hDlg, IDC_LUAPATHEDIT, pathToLua, MAX_PATH);
|
||||
GetDlgItemText(hDlg, IDC_ROMPATHEDIT, path.pathToRoms, MAX_PATH);
|
||||
GetDlgItemText(hDlg, IDC_SAVERAMPATHEDIT, path.pathToBattery, MAX_PATH);
|
||||
GetDlgItemText(hDlg, IDC_STATEPATHEDIT, path.pathToStates, MAX_PATH);
|
||||
GetDlgItemText(hDlg, IDC_SCREENSHOTPATHEDIT, path.pathToScreenshots, MAX_PATH);
|
||||
GetDlgItemText(hDlg, IDC_AVIPATHEDIT, path.pathToAviFiles, MAX_PATH);
|
||||
GetDlgItemText(hDlg, IDC_CHEATPATHEDIT, path.pathToCheats, MAX_PATH);
|
||||
GetDlgItemText(hDlg, IDC_LUAPATHEDIT, path.pathToLua, MAX_PATH);
|
||||
|
||||
WritePathSettings();
|
||||
EndDialog(hDlg, 0);
|
||||
break;
|
||||
case IDCANCEL:
|
||||
ReadPathSettings();
|
||||
path.ReadPathSettings();
|
||||
EndDialog(hDlg, 0);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
BOOL PathSettings_OnInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam)
|
||||
{
|
||||
HWND hwnd = GetDlgItem(hDlg, IDC_PATHLIST);
|
||||
/* ComboBox_AddString(hwnd, ROMKEY);
|
||||
ComboBox_AddString(hwnd, BATTERYKEY);
|
||||
ComboBox_AddString(hwnd, STATEKEY);
|
||||
ComboBox_AddString(hwnd, SCREENSHOTKEY);
|
||||
ComboBox_AddString(hwnd, AVIKEY);
|
||||
ComboBox_AddString(hwnd, CHEATKEY);
|
||||
ComboBox_AddString(hwnd, SOUNDKEY);
|
||||
ComboBox_AddString(hwnd, FIRMWAREKEY);
|
||||
|
||||
ComboBox_SetCurSel(hwnd, 0);*/
|
||||
PathSettings_OnSelChange(hDlg, NULL);
|
||||
|
||||
CheckDlgButton(hDlg, IDC_USELASTVISIT, (romsLastVisit) ? BST_CHECKED : BST_UNCHECKED);
|
||||
CheckRadioButton(hDlg, IDC_PNG, IDC_BMP, (int)GetImageFormatType());
|
||||
|
||||
// IDC_FORMATEDIT setup
|
||||
SetDlgItemText(hDlg, IDC_FORMATEDIT, screenshotFormat);
|
||||
|
||||
hwnd = GetDlgItem(hDlg, IDC_FORMATEDIT);
|
||||
Edit_LimitText(hwnd, MAX_FORMAT);
|
||||
|
||||
HWND toolTip = CreateWindowEx(NULL,
|
||||
TOOLTIPS_CLASS, NULL,
|
||||
TTS_ALWAYSTIP,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
hDlg, NULL,
|
||||
hAppInst, NULL);
|
||||
SendMessage(toolTip, TTM_SETMAXTIPWIDTH, NULL, (LPARAM)330);
|
||||
|
||||
SetWindowPos(toolTip, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
||||
|
||||
SetDlgItemText(hDlg, IDC_ROMPATHEDIT, pathToRoms);
|
||||
SetDlgItemText(hDlg, IDC_SAVERAMPATHEDIT, pathToBattery);
|
||||
SetDlgItemText(hDlg, IDC_STATEPATHEDIT, pathToStates);
|
||||
SetDlgItemText(hDlg, IDC_SCREENSHOTPATHEDIT, pathToScreenshots);
|
||||
SetDlgItemText(hDlg, IDC_AVIPATHEDIT, pathToAviFiles);
|
||||
SetDlgItemText(hDlg, IDC_CHEATPATHEDIT, pathToCheats);
|
||||
SetDlgItemText(hDlg, IDC_LUAPATHEDIT, pathToLua);
|
||||
|
||||
TOOLINFO ti;
|
||||
ZeroMemory(&ti, sizeof(ti));
|
||||
ti.cbSize = sizeof(ti);
|
||||
ti.hwnd = hDlg;
|
||||
ti.hinst = hAppInst;
|
||||
ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
|
||||
ti.uId = (UINT_PTR)hwnd;
|
||||
ti.lpszText = "The format a screenshot should be saved in.\r\n%f\t\t\tFilename\r\n%D\t\t\tDay:Two Digit\r\n%M\t\t\tMonth:Two Digit\r\n%Y\t\t\tYear:Four Digit\r\n%h\t\t\tHour:Two Digit\r\n%m\t\t\tMinute: Two Digit\r\n%s\t\t\tSecond: Two Digit\r\n%r\t\tRandom: Min:0 Max:RAND_MAX";
|
||||
GetClientRect(hwnd, &ti.rect);
|
||||
SendMessage(toolTip, TTM_ADDTOOL, NULL, (LPARAM)&ti);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK PathSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(uMsg)
|
||||
|
@ -609,7 +259,4 @@ LRESULT CALLBACK PathSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
|
|||
HANDLE_DLGMSG(hDlg, WM_COMMAND, PathSettings_OnCommand);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -21,70 +21,9 @@
|
|||
#ifndef _PATHSETTINGS_H_
|
||||
#define _PATHSETTINGS_H_
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
|
||||
|
||||
#define SECTION "PathSettings"
|
||||
|
||||
#define ROMKEY "Roms"
|
||||
#define BATTERYKEY "Battery"
|
||||
#define STATEKEY "States"
|
||||
#define SCREENSHOTKEY "Screenshots"
|
||||
#define AVIKEY "AviFiles"
|
||||
#define CHEATKEY "Cheats"
|
||||
#define SOUNDKEY "SoundSamples"
|
||||
#define FIRMWAREKEY "Firmware"
|
||||
#define FORMATKEY "format"
|
||||
#define DEFAULTFORMATKEY "defaultFormat"
|
||||
#define NEEDSSAVINGKEY "needsSaving"
|
||||
#define LASTVISITKEY "lastVisit"
|
||||
#define LUAKEY "Lua"
|
||||
|
||||
#define MAX_FORMAT 20
|
||||
|
||||
|
||||
enum KnownPath
|
||||
{
|
||||
FIRSTKNOWNPATH = 0,
|
||||
ROMS = 0,
|
||||
BATTERY,
|
||||
STATES,
|
||||
SCREENSHOTS,
|
||||
AVI_FILES,
|
||||
CHEATS,
|
||||
SOUNDS,
|
||||
FIRMWARE,
|
||||
MODULE,
|
||||
MAXKNOWNPATH = MODULE
|
||||
};
|
||||
|
||||
enum ImageFormat
|
||||
{
|
||||
PNG = IDC_PNG,
|
||||
BMP = IDC_BMP
|
||||
};
|
||||
|
||||
enum Action
|
||||
{
|
||||
GET,
|
||||
SET
|
||||
};
|
||||
|
||||
void GetFilename(char *buffer, int maxCount);
|
||||
void GetFullPathNoExt(KnownPath path, char *buffer, int maxCount);
|
||||
void GetPathFor(KnownPath path, char *buffer, int maxCount);
|
||||
void GetDefaultPath(char *buffer,const char *key, int maxCount);
|
||||
void WritePathSettings();
|
||||
void ReadPathSettings();
|
||||
|
||||
void SetPathFor(KnownPath path, char *buffer);
|
||||
void FormatName(char *output, int maxCount);
|
||||
|
||||
ImageFormat GetImageFormatType();
|
||||
|
||||
BOOL SavePathForRomVisit();
|
||||
|
||||
LRESULT CALLBACK PathSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <string>
|
||||
#include "path.h"
|
||||
|
||||
HWND RamWatchHWnd = NULL;
|
||||
|
||||
|
@ -451,7 +452,7 @@ int Change_File_S(char *Dest, char *Dir, char *Titre, char *Filter, char *Ext, H
|
|||
|
||||
bool Save_Watches()
|
||||
{
|
||||
Rom_Name = GetRomName();
|
||||
Rom_Name = path.GetRomName();
|
||||
strncpy(Str_Tmp,Rom_Name.c_str(),512);
|
||||
strcat(Str_Tmp,".wch");
|
||||
if(Change_File_S(Str_Tmp, Gens_Path, "Save Watches", "GENs Watchlist\0*.wch\0All Files\0*.*\0\0", "wch", RamWatchHWnd))
|
||||
|
@ -585,7 +586,7 @@ static int Change_File_L(char *Dest, char *Dir, char *Titre, char *Filter, char
|
|||
|
||||
bool Load_Watches(bool clear)
|
||||
{
|
||||
Rom_Name = GetRomName();
|
||||
Rom_Name = path.GetRomName();
|
||||
strncpy(Str_Tmp,Rom_Name.c_str(),512);
|
||||
strcat(Str_Tmp,".wch");
|
||||
if(Change_File_L(Str_Tmp, Watch_Dir, "Load Watches", "GENs Watchlist\0*.wch\0All Files\0*.*\0\0", "wch", RamWatchHWnd))
|
||||
|
|
Loading…
Reference in New Issue