win32: applied hicoder's path settings dialog patch. the default path behavior has changed from putting/looking for files where the rom is to putting/looking for files where the exe is

This commit is contained in:
p989 2009-06-28 18:44:00 +00:00
parent 8074480ba4
commit 515d4e9987
11 changed files with 843 additions and 14 deletions

View File

@ -840,13 +840,25 @@ int NDS_LoadROM( const char *filename,
free(noext);
memset(buf, 0, MAX_PATH);
#ifdef WIN32
GetFullPathNoExt(BATTERY, buf, MAX_PATH);
#else
strcpy(buf, pathFilenameToROMwithoutExt);
#endif
strcat(buf, ".dsv"); // DeSmuME memory card :)
MMU_new.backupDevice.load_rom(buf);
memset(buf, 0, MAX_PATH);
#ifdef WIN32
GetFullPathNoExt(CHEATS, buf, MAX_PATH);
#else
strcpy(buf, pathFilenameToROMwithoutExt);
#endif
strcat(buf, ".dct"); // DeSmuME cheat :)
cheatsInit(buf);

View File

@ -35,6 +35,10 @@
#include <string>
#ifdef WIN32
#include "pathsettings.h"
#endif
struct turbo {
bool Right;
bool Left;

View File

@ -460,7 +460,12 @@ void scan_savestates()
for( i = 1; i <= NB_STATES; i++ )
{
#ifdef WIN32
GetFullPathNoExt(STATES, filename, MAX_PATH);
#else
strncpy(filename, pathFilenameToROMwithoutExt, MAX_PATH);
#endif
if (strlen(filename) + strlen(".dst") + strlen("-2147483648") /* = biggest string for i */ >MAX_PATH) return ;
sprintf(filename+strlen(filename), ".ds%d", i);
if( stat(filename,&sbuf) == -1 ) continue;
@ -476,7 +481,12 @@ void savestate_slot(int num)
struct stat sbuf;
char filename[MAX_PATH];
#ifdef WIN32
GetFullPathNoExt(STATES, filename, MAX_PATH);
#else
strncpy(filename, pathFilenameToROMwithoutExt, MAX_PATH);
#endif
if (strlen(filename) + strlen(".dsx") + strlen("-2147483648") /* = biggest string for num */ >MAX_PATH) return ;
sprintf(filename+strlen(filename), ".ds%d", num);
@ -500,7 +510,13 @@ void savestate_slot(int num)
void loadstate_slot(int num)
{
char filename[MAX_PATH];
#ifdef WIN32
GetFullPathNoExt(STATES, filename, MAX_PATH);
#else
strncpy(filename, pathFilenameToROMwithoutExt, MAX_PATH);
#endif
if (strlen(filename) + strlen(".dsx") + strlen("-2147483648") /* = biggest string for num */ >MAX_PATH) return ;
sprintf(filename+strlen(filename), ".ds%d", num);
if (savestate_load(filename))

View File

@ -1006,6 +1006,14 @@
RelativePath="..\OGLRender.h"
>
</File>
<File
RelativePath=".\pathsettings.cpp"
>
</File>
<File
RelativePath=".\pathsettings.h"
>
</File>
<File
RelativePath="..\rasterize.cpp"
>

View File

@ -805,6 +805,10 @@
RelativePath=".\palView.cpp"
>
</File>
<File
RelativePath=".\pathsettings.cpp"
>
</File>
<File
RelativePath=".\ram_search.cpp"
>
@ -931,6 +935,10 @@
RelativePath=".\palView.h"
>
</File>
<File
RelativePath=".\pathsettings.h"
>
</File>
<File
RelativePath=".\ram_search.h"
>

View File

@ -34,6 +34,7 @@
#include "aviout.h"
#include "spu.h"
#include "../GPU.h"
#include "pathsettings.h"
extern LRESULT OpenFile(); //adelikat: Made this an extern here instead of main.h Seemed icky not to limit the scope of this function
@ -81,32 +82,58 @@ void HK_OpenROM(int) {OpenFile();}
void HK_PrintScreen(int param)
{
OPENFILENAME ofn;
char * ptr;
char filename[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = MainWindow->getHWnd();
ofn.lpstrFilter = "png file (*.png)\0*.png\0Bmp file (*.bmp)\0*.bmp\0Any file (*.*)\0*.*\0\0";
ofn.nFilterIndex = 1;
ofn.lpstrFile = filename;
ofn.lpstrTitle = "Print Screen Save As";
ofn.nMaxFile = MAX_PATH;
ofn.lpstrDefExt = "png";
ofn.Flags = OFN_OVERWRITEPROMPT;
GetSaveFileName(&ofn);
ptr = strrchr(filename,'.');//look for the last . in the filename
char folder[MAX_PATH];
ZeroMemory(folder, sizeof(folder));
GetPathFor(SCREENSHOTS, folder, MAX_PATH);
char file[MAX_PATH];
ZeroMemory(file, sizeof(file));
FormatName(file, MAX_PATH);
strcat(folder, file);
int len = strlen(folder);
if(len > MAX_PATH - 4)
folder[MAX_PATH - 4] = '\0';
ImageFormat format = GetImageFormatType();
if(format == PNG)
{
strcat(folder, ".png");
ofn.lpstrDefExt = "png";
ofn.nFilterIndex = 1;
}
else if(format == BMP)
{
strcat(folder, ".bmp");
ofn.lpstrDefExt = "bmp";
ofn.nFilterIndex = 2;
}
ofn.lpstrFile = folder;
GetSaveFileName(&ofn);
char *ptr = strrchr(folder,'.');//look for the last . in the filename
if ( ptr != 0 ) {
if (( strcmp ( ptr, ".BMP" ) == 0 ) ||
( strcmp ( ptr, ".bmp" ) == 0 ))
{
NDS_WriteBMP(filename);
NDS_WriteBMP(folder);
}
if (( strcmp ( ptr, ".PNG" ) == 0 ) ||
( strcmp ( ptr, ".png" ) == 0 ))
{
NDS_WritePNG(filename);
NDS_WritePNG(folder);
}
}
}

View File

@ -85,6 +85,7 @@
#include "commandline.h"
#include "../lua-engine.h"
#include "7zip.h"
#include "pathsettings.h"
#include "directx/ddraw.h"
@ -2263,7 +2264,6 @@ void AviRecordTo()
NDS_Pause();
OPENFILENAME ofn;
char szChoice[MAX_PATH] = {0};
////if we are playing a movie, construct the filename from the current movie.
////else construct it from the filename.
@ -2291,16 +2291,32 @@ void AviRecordTo()
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = MainWindow->getHWnd();
ofn.lpstrFilter = "AVI Files (*.avi)\0*.avi\0\0";
ofn.lpstrFile = szChoice;
ofn.lpstrDefExt = "avi";
ofn.lpstrTitle = "Save AVI as";
char folder[MAX_PATH];
ZeroMemory(folder, sizeof(folder));
GetPathFor(AVI_FILES, folder, MAX_PATH);
char file[MAX_PATH];
ZeroMemory(file, sizeof(file));
FormatName(file, MAX_PATH);
strcat(folder, file);
int len = strlen(folder);
if(len > MAX_PATH - 4)
folder[MAX_PATH - 4] = '\0';
strcat(folder, ".avi");
ofn.lpstrFile = folder;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
if(GetSaveFileName(&ofn))
{
DRV_AviBegin(szChoice);
DRV_AviBegin(folder);
}
NDS_UnPause();
@ -2441,12 +2457,32 @@ LRESULT OpenFile()
ofn.lpstrDefExt = "nds";
ofn.Flags = OFN_NOCHANGEDIR;
char buffer[MAX_PATH];
ZeroMemory(buffer, sizeof(buffer));
GetPathFor(ROMS, buffer, MAX_PATH);
ofn.lpstrInitialDir = buffer;
const char* s_nonRomExtensions [] = {"txt", "nfo", "htm", "html", "jpg", "jpeg", "png", "bmp", "gif", "mp3", "wav", "lnk", "exe", "bat", "gmv", "gm2", "lua", "luasav", "sav", "srm", "brm", "cfg", "wch", "gs*"};
if (GetOpenFileName(&ofn) == NULL) {
NDS_UnPause();
return 0;
}
else {
if(SavePathForRomVisit())
{
char *lchr, buffer[MAX_PATH];
ZeroMemory(buffer, sizeof(buffer));
lchr = strrchr(filename, '\\');
strncpy(buffer, filename, strlen(filename) - strlen(lchr));
SetPathFor(ROMS, buffer);
WritePathSettings();
}
}
char LogicalName[1024], PhysicalName[1024];
@ -2583,7 +2619,8 @@ enum CONFIGSCREEN
CONFIGSCREEN_WIFI,
CONFIGSCREEN_SOUND,
CONFIGSCREEN_EMULATION,
CONFIGSCREEN_MICROPHONE
CONFIGSCREEN_MICROPHONE,
CONFIGSCREEN_PATHSETTINGS
};
void RunConfig(CONFIGSCREEN which)
@ -2616,6 +2653,9 @@ void RunConfig(CONFIGSCREEN which)
case CONFIGSCREEN_MICROPHONE:
DialogBox(hAppInst, MAKEINTRESOURCE(IDD_MICROPHONE), hwnd, (DLGPROC)MicrophoneSettingsDlgProc);
break;
case CONFIGSCREEN_PATHSETTINGS:
DialogBox(hAppInst, MAKEINTRESOURCE(IDD_PATHSETTINGS), hwnd, (DLGPROC)PathSettingsDlgProc);
break;
case CONFIGSCREEN_WIFI:
#ifdef EXPERIMENTAL_WIFI
if(wifiMac.netEnabled)
@ -2762,6 +2802,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
case WM_CREATE:
{
ReadPathSettings();
pausedByMinimize = FALSE;
UpdateScreenRects();
return 0;
@ -3027,7 +3068,33 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
return 0;
case IDM_QUICK_PRINTSCREEN:
{
NDS_WriteBMP("./printscreen.bmp");
char buffer[MAX_PATH];
ZeroMemory(buffer, sizeof(buffer));
GetPathFor(SCREENSHOTS, buffer, MAX_PATH);
char file[MAX_PATH];
ZeroMemory(file, sizeof(file));
FormatName(file, MAX_PATH);
strcat(buffer, file);
if( strlen(buffer) > (MAX_PATH - 4))
buffer[MAX_PATH - 4] = '\0';
switch(GetImageFormatType())
{
case PNG:
{
strcat(buffer, ".png");
NDS_WritePNG(buffer);
}
break;
case BMP:
{
strcat(buffer, ".bmp");
NDS_WriteBMP(buffer);
}
break;
}
}
return 0;
case IDM_FILE_RECORDAVI:
@ -3055,6 +3122,11 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
ofn.nMaxFile = MAX_PATH;
ofn.lpstrDefExt = "dst";
char buffer[MAX_PATH];
ZeroMemory(buffer, sizeof(buffer));
GetPathFor(STATES, buffer, MAX_PATH);
ofn.lpstrInitialDir = buffer;
if(!GetOpenFileName(&ofn))
{
NDS_UnPause();
@ -3080,6 +3152,11 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
ofn.nMaxFile = MAX_PATH;
ofn.lpstrDefExt = "dst";
char buffer[MAX_PATH];
ZeroMemory(buffer, sizeof(buffer));
GetPathFor(STATES, buffer, MAX_PATH);
ofn.lpstrInitialDir = buffer;
if(!GetSaveFileName(&ofn))
{
return 0;
@ -3156,6 +3233,11 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
ofn.nMaxFile = MAX_PATH;
ofn.lpstrDefExt = "duc";
char buffer[MAX_PATH];
ZeroMemory(buffer, sizeof(buffer));
GetPathFor(BATTERY, buffer, MAX_PATH);
ofn.lpstrInitialDir = buffer;
if(!GetOpenFileName(&ofn))
{
NDS_UnPause();
@ -3214,6 +3296,9 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
case IDM_MICROPHONESETTINGS:
RunConfig(CONFIGSCREEN_MICROPHONE);
return 0;
case IDM_PATHSETTINGS:
RunConfig(CONFIGSCREEN_PATHSETTINGS);
return 0;
case IDM_GAME_INFO:
{
@ -3918,6 +4003,11 @@ LRESULT CALLBACK EmulationSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, L
ofn.lpstrDefExt = "bin";
ofn.Flags = OFN_NOCHANGEDIR;
char buffer[MAX_PATH];
ZeroMemory(buffer, sizeof(buffer));
GetPathFor(FIRMWARE, buffer, MAX_PATH);
ofn.lpstrInitialDir = buffer;
if(GetOpenFileName(&ofn))
{
HWND cur;
@ -4018,6 +4108,11 @@ LRESULT CALLBACK MicrophoneSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
ofn.lpstrDefExt = "bin";
ofn.Flags = OFN_NOCHANGEDIR;
char buffer[MAX_PATH];
ZeroMemory(buffer, sizeof(buffer));
GetPathFor(SOUNDS, buffer, MAX_PATH);
ofn.lpstrInitialDir = buffer;
if(GetOpenFileName(&ofn))
{
HWND cur;

View File

@ -0,0 +1,559 @@
/*
Copyright (C) 2007 Hicoder
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
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 <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"
/*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 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)
{
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);
}
int InitialFolder(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
{
if(uMsg == BFFM_INITIALIZED)
{
SendMessage(hwnd, BFFM_SETSELECTION, (WPARAM)TRUE, lpData);
}
return 0;
}
BOOL BrowseForPath(char *pathToBrowse)
{
LPMALLOC shMalloc;
BOOL changed = false;
LPITEMIDLIST idList;
BROWSEINFO bi;
//stupid shell
if(SHGetMalloc( &shMalloc) != S_OK)
return FALSE;
ZeroMemory(&idList, sizeof(idList));
ZeroMemory(&bi, sizeof(bi));
char tmp[MAX_PATH];
strncpy(tmp, pathToBrowse, MAX_PATH);
bi.hwndOwner = MainWindow->getHWnd();
bi.lpszTitle = "Choose a Folder";
bi.ulFlags = BIF_NONEWFOLDERBUTTON;
/*wanted to add a callback function for the folder initialization but it crashes everytime i do
bi.lpfn = (BFFCALLBACK)InitialFolder;
bi.lParam = (LPARAM)pathToBrowse;
*/
if( (idList = SHBrowseForFolder(&bi)) )
{
changed = true;
SHGetPathFromIDList(idList, pathToBrowse);
shMalloc->Free(&idList);
}
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);
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)
{
char *lchr = strrchr(pathFilenameToROMwithoutExt, '\\');
lchr++;
strncpy(buffer, lchr, maxCount);
}
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, 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);
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)
{
switch(id)
{
case IDC_BROWSE:
{
if(BrowseForPath(currentSelection))
SetDlgItemText(hDlg, IDC_PATHEDIT, currentSelection);
}
break;
case IDC_DEFAULT:
{
GetDefaultPath(currentSelection, currentKey, MAX_PATH);
SetDlgItemText(hDlg, IDC_PATHEDIT, currentSelection);
}
break;
case IDC_PNG:
CheckRadioButton(hDlg, IDC_PNG, IDC_BMP, IDC_PNG);
defaultFormat = PNG;
break;
case IDC_BMP:
CheckRadioButton(hDlg, IDC_PNG, IDC_BMP, IDC_BMP);
defaultFormat = BMP;
break;
case IDC_USELASTVISIT:
{
romsLastVisit = !romsLastVisit;
CheckDlgButton(hDlg, IDC_USELASTVISIT, (romsLastVisit) ? BST_CHECKED : BST_UNCHECKED);
}
break;
case IDC_PATHLIST:
{
if(codeNotify == CBN_SELCHANGE)
{
PathSettings_OnSelChange(hDlg, hwndCtl);
return;
}
}
break;
case IDC_FORMATEDIT:
{
if(codeNotify == EN_KILLFOCUS)
{
char buffer[MAX_FORMAT];
GetDlgItemText(hDlg, IDC_FORMATEDIT, buffer, MAX_FORMAT);
strncpy(screenshotFormat, buffer, MAX_FORMAT);
}
}
break;
case IDOK:
WritePathSettings();
EndDialog(hDlg, 0);
break;
case IDCANCEL:
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);
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)
{
HANDLE_DLGMSG(hDlg, WM_INITDIALOG, PathSettings_OnInitDialog);
HANDLE_DLGMSG(hDlg, WM_COMMAND, PathSettings_OnCommand);
}
return FALSE;
}

View File

@ -0,0 +1,89 @@
/*
Copyright (C) 2007 Hicoder
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#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 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

View File

@ -114,6 +114,17 @@
#define IDD_ARCHIVEFILECHOOSER 316
#define IDD_LUA 317
#define IDC_NEW_LUA_SCRIPT 318
#define IDC_PATHEDIT 319
#define IDC_BROWSE 320
#define IDC_USELASTVISIT 321
#define IDC_FORMATEDIT 322
#define IDC_PATHLIST 323
#define IDC_SAVEAS 324
#define IDC_PNG 325
#define IDC_BMP 326
#define IDC_FORMATSTATIC 327
#define IDM_PATHSETTINGS 328
#define IDD_PATHSETTINGS 229
#define IDC_DES_BOX 402
#define IDC_R0 403
#define IDC_R1 404

Binary file not shown.