diff --git a/src/drivers/win/config.cpp b/src/drivers/win/config.cpp index afc98949..8d5521a1 100644 --- a/src/drivers/win/config.cpp +++ b/src/drivers/win/config.cpp @@ -64,13 +64,13 @@ static CFGSTRUCT fceuconfig[] = { ACS(gfsdir), - NACS("odcheats",DOvers[0]), - NACS("odmisc",DOvers[1]), - NACS("odnonvol",DOvers[2]), - NACS("odstates",DOvers[3]), - NACS("odsnaps",DOvers[4]), - NACS("odbase",DOvers[5]), - NACS("odbase",DOvers[6]), + NACS("odcheats",directory_names[0]), + NACS("odmisc",directory_names[1]), + NACS("odnonvol",directory_names[2]), + NACS("odstates",directory_names[3]), + NACS("odsnaps",directory_names[4]), + NACS("odbase",directory_names[5]), + NACS("odbase",directory_names[6]), AC(winspecial), AC(winsizemulx), diff --git a/src/drivers/win/main.cpp b/src/drivers/win/main.cpp index d03576c6..12046359 100644 --- a/src/drivers/win/main.cpp +++ b/src/drivers/win/main.cpp @@ -73,9 +73,18 @@ HINSTANCE fceu_hInstance; HRESULT ddrval; -// cheats, misc, nonvol, states, snaps, ..., base -static char *DOvers[6]={0,0,0,0,0,0}; -static const char *defaultds[5]={"cheats","sav","fcs","snaps","movie"}; +/** +* Contains the names of the overridden standard directories +* in the order cheats, misc, nonvol, states, snaps, ..., base +**/ +static char *directory_names[6] = {0, 0, 0, 0, 0, 0}; + +/** +* Contains the names of the default directories. +**/ +static const char *default_directory_names[5] = {"cheats", "sav", "fcs", "snaps", "movie"}; + +#define NUMBER_OF_DIRECTORIES sizeof(directory_names) / sizeof(*directory_names) static char TempArray[2048]; @@ -100,12 +109,12 @@ void SetDirs(void) for(x=0; x < sizeof(jlist) / sizeof(*jlist); x++) { - FCEUI_SetDirOverride(jlist[x], DOvers[x]); + FCEUI_SetDirOverride(jlist[x], directory_names[x]); } - if(DOvers[5]) + if(directory_names[5]) { - FCEUI_SetBaseDirectory(DOvers[5]); + FCEUI_SetBaseDirectory(directory_names[5]); } else { @@ -118,9 +127,9 @@ void RemoveDirs(void) int x; for(x=0;x<5;x++) - if(!DOvers[x]) + if(!directory_names[x]) { - sprintf(TempArray,"%s\\%s",DOvers[5]?DOvers[5]:BaseDirectory,defaultds[x]); + sprintf(TempArray,"%s\\%s",directory_names[5]?directory_names[5]:BaseDirectory,default_directory_names[x]); RemoveDirectory(TempArray); } } @@ -132,11 +141,11 @@ void CreateDirs(void) { int x; - for(x = 0; x < sizeof(defaultds) / sizeof(*defaultds); x++) + for(x = 0; x < sizeof(default_directory_names) / sizeof(*default_directory_names); x++) { - if(!DOvers[x]) + if(!directory_names[x]) { - sprintf(TempArray, "%s\\%s", DOvers[5] ? DOvers[5] : BaseDirectory, defaultds[x]); + sprintf(TempArray, "%s\\%s", directory_names[5] ? directory_names[5] : BaseDirectory, default_directory_names[x]); CreateDirectory(TempArray,0); } } diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index 328573b9..9f723845 100644 Binary files a/src/drivers/win/res.rc and b/src/drivers/win/res.rc differ diff --git a/src/drivers/win/resource.h b/src/drivers/win/resource.h index 97befb8b..d26207ed 100644 --- a/src/drivers/win/resource.h +++ b/src/drivers/win/resource.h @@ -3,8 +3,10 @@ // Used by res.rc // #define GUI_BOT_CLOSE 1 +#define CLOSE_BUTTON 1 #define GUI_BOT_VALUES 2 #define MENU_OPEN_FILE 100 +#define EDIT_CHEATS 100 #define MENU_CLOSE_FILE 101 #define IDI_ICON1 101 #define IDI_ICON2 102 @@ -18,17 +20,20 @@ #define MENU_STOP_AVI 152 #define MENU_EXIT 153 #define MENU_RESET 200 +#define BUTTON_CHEATS 200 #define MENU_POWER 201 #define MENU_EJECT_DISK 202 #define MENU_SWITCH_DISK 203 #define MENU_INSERT_COIN 204 #define MENU_HIDE_MENU 300 +#define CHECK_SCREENSHOT_NAMES 300 #define MENU_RUN_IN_BACKGROUND 301 #define MENU_BACKGROUND_INPUT 302 #define MENU_SHOW_STATUS_ICON 303 #define MENU_ENABLE_REWIND 304 #define MENU_GAME_GENIE 310 #define MENU_PAL 311 +#define MENU_DIRECTORIES 320 #define GUI_BOT_A_1 1000 #define GUI_BOT_B_1 1001 #define GUI_BOT_SELECT_1 1002 @@ -165,7 +170,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 103 -#define _APS_NEXT_COMMAND_VALUE 40037 +#define _APS_NEXT_COMMAND_VALUE 40038 #define _APS_NEXT_CONTROL_VALUE 1117 #define _APS_NEXT_SYMED_VALUE 101 #endif diff --git a/src/drivers/win/window.cpp b/src/drivers/win/window.cpp index 06888f97..ed22741a 100644 --- a/src/drivers/win/window.cpp +++ b/src/drivers/win/window.cpp @@ -845,7 +845,12 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) UpdateCheckedMenuItems(); break; case 40002: CreateBasicBot();break; // case 40028: DoMemmo(0); break; //mbg merge 7/18/06 removed as part of old debugger - case 320:ConfigDirectories();break; + + case MENU_DIRECTORIES: + // Directories menu was selected + ConfigDirectories(); + break; + case 327:ConfigGUI();break; case 321:ConfigInput(hWnd);break; case 322:ConfigTiming();break; @@ -1519,79 +1524,142 @@ static int BrowseForFolder(HWND hParent, char *htext, char *buf) return(ret); } -static BOOL CALLBACK DirConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +/** +* Processes information from the Directories selection dialog after +* the dialog was closed. +* +* @param hwndDlg Handle of the dialog window. +**/ +void CloseDirectoriesDialog(HWND hwndDlg) { - int x; + int x; - switch(uMsg){ - case WM_INITDIALOG: - SetDlgItemText(hwndDlg,65508,"The settings in the \"Individual Directory Overrides\" group will override the settings in the \"Base Directory Override\" group. To delete an override, delete the text from the text edit control. Note that the directory the configuration file is in cannot be overridden"); - for(x=0;x<6;x++) - SetDlgItemText(hwndDlg,100+x,DOvers[x]); - if(eoptions&EO_SNAPNAME) - CheckDlgButton(hwndDlg,300,BST_CHECKED); - break; - case WM_CLOSE: - case WM_QUIT: goto gornk; - case WM_COMMAND: - if(!(wParam>>16)) - { - if((wParam&0xFFFF)>=200 && (wParam&0xFFFF)<=205) - { - static char *helpert[6]={"Cheats","Miscellaneous","Nonvolatile Game Data","Save States","Screen Snapshots","Base Directory"}; - char name[MAX_PATH]; + // Update the information from the screenshot naming checkbox + if(IsDlgButtonChecked(hwndDlg, CHECK_SCREENSHOT_NAMES) == BST_CHECKED) + { + eoptions |= EO_SNAPNAME; + } + else + { + eoptions &= ~EO_SNAPNAME; + } - if(BrowseForFolder(hwndDlg,helpert[((wParam&0xFFFF)-200)],name)) - SetDlgItemText(hwndDlg,100+((wParam&0xFFFF)-200),name); - } - else switch(wParam&0xFFFF) - { - case 1: - gornk: + RemoveDirs(); // Remove empty directories. - if(IsDlgButtonChecked(hwndDlg,300)==BST_CHECKED) - eoptions|=EO_SNAPNAME; - else - eoptions&=~EO_SNAPNAME; + // Read the information from the edit fields and update the + // necessary variables. + for(x = 0; x < NUMBER_OF_DIRECTORIES; x++) + { + LONG len; + len = SendDlgItemMessage(hwndDlg, EDIT_CHEATS + x, WM_GETTEXTLENGTH, 0, 0); - RemoveDirs(); // Remove empty directories. + if(len <= 0) + { + if(directory_names[x]) + { + free(directory_names[x]); + } - for(x=0;x<6;x++) - { - LONG len; - len=SendDlgItemMessage(hwndDlg,100+x,WM_GETTEXTLENGTH,0,0); - if(len<=0) - { - if(DOvers[x]) free(DOvers[x]); - DOvers[x]=0; - continue; - } - len++; // Add 1 for null character. - if(!(DOvers[x]=(char*)malloc(len))) //mbg merge 7/17/06 added cast - continue; - if(!GetDlgItemText(hwndDlg,100+x,DOvers[x],len)) - { - free(DOvers[x]); - DOvers[x]=0; - continue; - } + directory_names[x] = 0; + continue; + } - } + len++; // Add 1 for null character. - CreateDirs(); // Create needed directories. - SetDirs(); // Set the directories in the core. - EndDialog(hwndDlg,0); - break; - } - } - } - return 0; + if( !(directory_names[x] = (char*)malloc(len))) //mbg merge 7/17/06 added cast + { + continue; + } + + if(!GetDlgItemText(hwndDlg, EDIT_CHEATS + x, directory_names[x], len)) + { + free(directory_names[x]); + directory_names[x]=0; + continue; + } + + } + + CreateDirs(); // Create needed directories. + SetDirs(); // Set the directories in the core. + + EndDialog(hwndDlg, 0); } - -static void ConfigDirectories(void) +/** +* Callback function for the directories configuration dialog. +**/ +static BOOL CALLBACK DirConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - DialogBox(fceu_hInstance,"DIRCONFIG",hAppWnd,DirConCallB); + int x; + + switch(uMsg) + { + case WM_INITDIALOG: + + SetDlgItemText(hwndDlg,65508,"The settings in the \"Individual Directory Overrides\" group will override the settings in the \"Base Directory Override\" group. To delete an override, delete the text from the text edit control. Note that the directory the configuration file is in cannot be overridden"); + + // Initialize the directories textboxes + for(x = 0; x < NUMBER_OF_DIRECTORIES; x++) + { + SetDlgItemText(hwndDlg, EDIT_CHEATS + x, directory_names[x]); + } + + // Check the screenshot naming checkbox if necessary + if(eoptions & EO_SNAPNAME) + { + CheckDlgButton(hwndDlg, CHECK_SCREENSHOT_NAMES, BST_CHECKED); + } + break; + + case WM_CLOSE: + case WM_QUIT: + CloseDirectoriesDialog(hwndDlg); + break; + + case WM_COMMAND: + if( !(wParam >> 16) ) + { + if( (wParam & 0xFFFF) >= BUTTON_CHEATS && (wParam & 0xFFFF) <= BUTTON_CHEATS + NUMBER_OF_DIRECTORIES) + { + // If a directory selection button was pressed, ask the + // user for a directory. + + static char *helpert[6] = { + "Cheats", + "Miscellaneous", + "Nonvolatile Game Data", + "Save States", + "Screen Snapshots", + "Base Directory" + }; + + char name[MAX_PATH]; + + if(BrowseForFolder(hwndDlg, helpert[ ( (wParam & 0xFFFF) - BUTTON_CHEATS)], name)) + { + SetDlgItemText(hwndDlg, EDIT_CHEATS + ((wParam & 0xFFFF) - BUTTON_CHEATS), name); + } + } + else switch(wParam & 0xFFFF) + { + case CLOSE_BUTTON: + CloseDirectoriesDialog(hwndDlg); + break; + } + } + + } + + return 0; +} + +/** +* Shows the dialog for configuring the standard directories. +**/ +void ConfigDirectories(void) +{ + DialogBox(fceu_hInstance, "DIRCONFIG", hAppWnd, DirConCallB); } static int ReplayDialogReadOnlyStatus = 0;