From 515d4e99876aa299884717a0d5d46e72e2c55c62 Mon Sep 17 00:00:00 2001 From: p989 Date: Sun, 28 Jun 2009 18:44:00 +0000 Subject: [PATCH] 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 --- desmume/src/NDSSystem.cpp | 12 + desmume/src/NDSSystem.h | 4 + desmume/src/saves.cpp | 22 +- desmume/src/windows/DeSmuME_2005.vcproj | 8 + desmume/src/windows/DeSmuME_2008.vcproj | 8 + desmume/src/windows/hotkey.cpp | 39 +- desmume/src/windows/main.cpp | 105 ++++- desmume/src/windows/pathsettings.cpp | 559 ++++++++++++++++++++++++ desmume/src/windows/pathsettings.h | 89 ++++ desmume/src/windows/resource.h | 11 + desmume/src/windows/resources.rc | Bin 678860 -> 681388 bytes 11 files changed, 843 insertions(+), 14 deletions(-) create mode 100644 desmume/src/windows/pathsettings.cpp create mode 100644 desmume/src/windows/pathsettings.h diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 0b8c36a0c..39c63509f 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -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); diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index f803b06fc..08a4c4166 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -35,6 +35,10 @@ #include +#ifdef WIN32 +#include "pathsettings.h" +#endif + struct turbo { bool Right; bool Left; diff --git a/desmume/src/saves.cpp b/desmume/src/saves.cpp index 2c1e4946d..90b011c10 100644 --- a/desmume/src/saves.cpp +++ b/desmume/src/saves.cpp @@ -460,7 +460,12 @@ void scan_savestates() for( i = 1; i <= NB_STATES; i++ ) { - strncpy(filename, pathFilenameToROMwithoutExt, MAX_PATH); + #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]; - strncpy(filename, pathFilenameToROMwithoutExt, 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]; - strncpy(filename, pathFilenameToROMwithoutExt, 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)) diff --git a/desmume/src/windows/DeSmuME_2005.vcproj b/desmume/src/windows/DeSmuME_2005.vcproj index bb5f8009d..3f05ead4b 100644 --- a/desmume/src/windows/DeSmuME_2005.vcproj +++ b/desmume/src/windows/DeSmuME_2005.vcproj @@ -1006,6 +1006,14 @@ RelativePath="..\OGLRender.h" > + + + + diff --git a/desmume/src/windows/DeSmuME_2008.vcproj b/desmume/src/windows/DeSmuME_2008.vcproj index 3f33a1da2..52395a9f3 100644 --- a/desmume/src/windows/DeSmuME_2008.vcproj +++ b/desmume/src/windows/DeSmuME_2008.vcproj @@ -805,6 +805,10 @@ RelativePath=".\palView.cpp" > + + @@ -931,6 +935,10 @@ RelativePath=".\palView.h" > + + diff --git a/desmume/src/windows/hotkey.cpp b/desmume/src/windows/hotkey.cpp index 2ef95b513..1d7cb60f2 100644 --- a/desmume/src/windows/hotkey.cpp +++ b/desmume/src/windows/hotkey.cpp @@ -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); } } } diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 5497ced87..0487bbd8b 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -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; diff --git a/desmume/src/windows/pathsettings.cpp b/desmume/src/windows/pathsettings.cpp new file mode 100644 index 000000000..4ae96e9e7 --- /dev/null +++ b/desmume/src/windows/pathsettings.cpp @@ -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 +#include +#include +#include +#include +#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;j1%2lUYQo_lW75ya)(@44rk@8|pdem>uG-)HJp z-qj^jmQ-F!O3AO3=uXKBR_4&0`9p9VF2ZSaY${HicPK8FRBbHn)i5o~vNQrmFzk`{ z;%1FfoLQ-qUAD|ph4R}?j$xo(w)(x=*$DOE1>+rnW@Coob;*N$rIvC$*QbPVs@kIB zops60+_%eF@?{a5ziwBe5Q82ZIIQ^C^0C^j>G&Rem0b8SEva~BSaM^BOKq&{f++M- zTs>Zhzx@#8HUI(eiUT2Kf!I>#Tj zHsQff<8tw}vs{u{I6-!fp38LL5-h?D**RKUB*DCpfLWT&(tHM{>H8#{r`>7#x&Spi zyjk`rFE~a?#wo=yq9dNeVUW1f6ZVsBvx_O06WcqaO7`TD%I@9Vjgbw~(YwPc2M4(N zTh#~(9hyXu97{m)va?Vx-d5n$RmF}IU$p(r2A6}-FAlc}ppXFiH+yS$Jt!}0jV$@N z$l_(;<+5FR{(2QgEdg>jIwZs_4@>Y@zqAj%4psKWI0L3wM%S9b{L~O;UvZ0;&r%is zh$(#~apFF~RR|OF2X&U&!l9BqI6u(v9`&)ZqoDNS?ujpMff=_+gf%YLd z3OzZR8EZOfP|#rFl0t&0?E)!AudXhY;WMAs&>n#S7|KC4){I=u7B$)WA1X^dZ@{0o zGFh$e<2YQF;wwEqkmJ_ol0)nIMoD^)~1lR6cD{mxP6dEdxd>R@J LYbMcR8>{^Td!prI delta 59 zcmZ2;TJy|y&4w1n7N!>F7M3lnE<%$H>;)!&(Bj*EONdoOwLQ#{6^Pk@m>q~YfS7Z8 Jm?Kx13IKKI6E6S&