Improved the Directories configuration dialog.
This commit is contained in:
parent
2a4e33a08c
commit
5595d2c17b
|
@ -44,3 +44,4 @@ extern int eoptions;
|
|||
#define EO_FORCEISCALE 16384
|
||||
#define EO_NOFOURSCORE 32768
|
||||
|
||||
bool directoryExists(const char* dirname);
|
|
@ -31,7 +31,7 @@
|
|||
#include "tracer.h"
|
||||
#include "memview.h"
|
||||
#include "cheat.h"
|
||||
#include <assert.h>
|
||||
#include "gui.h"
|
||||
|
||||
// ################################## Start of SP CODE ###########################
|
||||
|
||||
|
@ -57,42 +57,6 @@ HWND hDebug;
|
|||
static HFONT hFont,hNewFont;
|
||||
static SCROLLINFO si;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Centers a window relative to its parent window.
|
||||
*
|
||||
* @param hwndDlg Handle of the window to center.
|
||||
**/
|
||||
void CenterWindow(HWND hwndDlg)
|
||||
{
|
||||
//TODO: This function should probably moved into the generic Win32 window file
|
||||
//move the window relative to its parent
|
||||
HWND hwndParent = GetParent(hwndDlg);
|
||||
RECT rect;
|
||||
RECT rectP;
|
||||
|
||||
GetWindowRect(hwndDlg, &rect);
|
||||
GetWindowRect(hwndParent, &rectP);
|
||||
|
||||
unsigned int width = rect.right - rect.left;
|
||||
unsigned height = rect.bottom - rect.top;
|
||||
|
||||
unsigned x = ((rectP.right-rectP.left) - width) / 2 + rectP.left;
|
||||
unsigned y = ((rectP.bottom-rectP.top) - height) / 2 + rectP.top;
|
||||
|
||||
unsigned screenwidth = GetSystemMetrics(SM_CXSCREEN);
|
||||
unsigned screenheight = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
//make sure that the dialog box never moves outside of the screen
|
||||
if(x < 0) x = 0;
|
||||
if(y < 0) y = 0;
|
||||
if(x + width > screenwidth) x = screenwidth - width;
|
||||
if(y + height > screenheight) y = screenheight - height;
|
||||
|
||||
MoveWindow(hwndDlg, x, y, width, height, FALSE);
|
||||
}
|
||||
|
||||
#define START_OFFSET_HANDLE 200
|
||||
#define END_OFFSET_HANDLE 201
|
||||
#define READ_BREAKPOINT_HANDLE 102
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "common.h"
|
||||
#include "main.h"
|
||||
#include "window.h"
|
||||
#include "gui.h"
|
||||
|
||||
/**
|
||||
* Processes information from the Directories selection dialog after
|
||||
|
@ -10,8 +11,6 @@
|
|||
**/
|
||||
void CloseDirectoriesDialog(HWND hwndDlg)
|
||||
{
|
||||
int x;
|
||||
|
||||
// Update the information from the screenshot naming checkbox
|
||||
if(IsDlgButtonChecked(hwndDlg, CHECK_SCREENSHOT_NAMES) == BST_CHECKED)
|
||||
{
|
||||
|
@ -26,38 +25,60 @@ void CloseDirectoriesDialog(HWND hwndDlg)
|
|||
|
||||
// Read the information from the edit fields and update the
|
||||
// necessary variables.
|
||||
for(x = 0; x < NUMBER_OF_DIRECTORIES; x++)
|
||||
for(unsigned int curr_dir = 0; curr_dir < NUMBER_OF_DIRECTORIES; curr_dir++)
|
||||
{
|
||||
LONG len;
|
||||
len = SendDlgItemMessage(hwndDlg, EDIT_CHEATS + x, WM_GETTEXTLENGTH, 0, 0);
|
||||
len = SendDlgItemMessage(hwndDlg, EDIT_CHEATS + curr_dir, WM_GETTEXTLENGTH, 0, 0);
|
||||
|
||||
if(len <= 0)
|
||||
{
|
||||
if(directory_names[x])
|
||||
if(directory_names[curr_dir])
|
||||
{
|
||||
free(directory_names[x]);
|
||||
free(directory_names[curr_dir]);
|
||||
}
|
||||
|
||||
directory_names[x] = 0;
|
||||
directory_names[curr_dir] = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
len++; // Add 1 for null character.
|
||||
|
||||
if( !(directory_names[x] = (char*)malloc(len))) //mbg merge 7/17/06 added cast
|
||||
if( !(directory_names[curr_dir] = (char*)malloc(len))) //mbg merge 7/17/06 added cast
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!GetDlgItemText(hwndDlg, EDIT_CHEATS + x, directory_names[x], len))
|
||||
if(!GetDlgItemText(hwndDlg, EDIT_CHEATS + curr_dir, directory_names[curr_dir], len))
|
||||
{
|
||||
free(directory_names[x]);
|
||||
directory_names[x]=0;
|
||||
free(directory_names[curr_dir]);
|
||||
directory_names[curr_dir] = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!directoryExists(directory_names[curr_dir]))
|
||||
{
|
||||
const char* mask = "Error: Directory %s does not exist. Create this directory?";
|
||||
|
||||
char* buffer = (char*)malloc(strlen(mask) + strlen(directory_names[curr_dir]) + 1);
|
||||
|
||||
sprintf(buffer, mask, directory_names[curr_dir]);
|
||||
|
||||
if ( MessageBox(hwndDlg, buffer, "FCE Ultra", MB_ICONERROR | MB_YESNO) == IDYES )
|
||||
{
|
||||
if (!CreateDirectory(directory_names[curr_dir], 0))
|
||||
{
|
||||
MessageBox(hwndDlg, "Error: Couldn't create directory. Please choose a different directory.", "FCE Ultra", MB_ICONERROR | MB_OK);
|
||||
free(buffer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
initDirectories();
|
||||
CreateDirs(); // Create needed directories.
|
||||
SetDirs(); // Set the directories in the core.
|
||||
|
||||
|
@ -69,18 +90,14 @@ void CloseDirectoriesDialog(HWND hwndDlg)
|
|||
**/
|
||||
static BOOL CALLBACK DirConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
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++)
|
||||
for(unsigned int curr_dir = 0; curr_dir < NUMBER_OF_DIRECTORIES; curr_dir++)
|
||||
{
|
||||
SetDlgItemText(hwndDlg, EDIT_CHEATS + x, directory_names[x]);
|
||||
SetDlgItemText(hwndDlg, EDIT_CHEATS + curr_dir, directory_names[curr_dir]);
|
||||
}
|
||||
|
||||
// Check the screenshot naming checkbox if necessary
|
||||
|
@ -88,6 +105,9 @@ static BOOL CALLBACK DirConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
|
|||
{
|
||||
CheckDlgButton(hwndDlg, CHECK_SCREENSHOT_NAMES, BST_CHECKED);
|
||||
}
|
||||
|
||||
CenterWindowOnScreen(hwndDlg);
|
||||
|
||||
break;
|
||||
|
||||
case WM_CLOSE:
|
||||
|
@ -124,6 +144,9 @@ static BOOL CALLBACK DirConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
|
|||
case CLOSE_BUTTON:
|
||||
CloseDirectoriesDialog(hwndDlg);
|
||||
break;
|
||||
case BTN_CANCEL:
|
||||
EndDialog(hwndDlg, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,63 @@
|
|||
#include <commctrl.h>
|
||||
#include <shlobj.h> // For directories configuration dialog.
|
||||
|
||||
/**
|
||||
* Centers a window relative to its parent window.
|
||||
*
|
||||
* @param hwndDlg Handle of the window to center.
|
||||
**/
|
||||
void CenterWindow(HWND hwndDlg)
|
||||
{
|
||||
//TODO: This function should probably moved into the generic Win32 window file
|
||||
//move the window relative to its parent
|
||||
HWND hwndParent = GetParent(hwndDlg);
|
||||
RECT rect;
|
||||
RECT rectP;
|
||||
|
||||
GetWindowRect(hwndDlg, &rect);
|
||||
GetWindowRect(hwndParent, &rectP);
|
||||
|
||||
unsigned int width = rect.right - rect.left;
|
||||
unsigned height = rect.bottom - rect.top;
|
||||
|
||||
unsigned x = ((rectP.right-rectP.left) - width) / 2 + rectP.left;
|
||||
unsigned y = ((rectP.bottom-rectP.top) - height) / 2 + rectP.top;
|
||||
|
||||
unsigned int screenwidth = GetSystemMetrics(SM_CXSCREEN);
|
||||
unsigned int screenheight = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
//make sure that the dialog box never moves outside of the screen
|
||||
if(x < 0) x = 0;
|
||||
if(y < 0) y = 0;
|
||||
if(x + width > screenwidth) x = screenwidth - width;
|
||||
if(y + height > screenheight) y = screenheight - height;
|
||||
|
||||
MoveWindow(hwndDlg, x, y, width, height, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Centers a window on the screen.
|
||||
*
|
||||
* @param hwnd The window handle.
|
||||
**/
|
||||
void CenterWindowOnScreen(HWND hwnd)
|
||||
{
|
||||
RECT rect;
|
||||
|
||||
GetWindowRect(hwnd, &rect);
|
||||
|
||||
unsigned int screenwidth = GetSystemMetrics(SM_CXSCREEN);
|
||||
unsigned int screenheight = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
unsigned int width = rect.right - rect.left;
|
||||
unsigned height = rect.bottom - rect.top;
|
||||
|
||||
unsigned x = (screenwidth - width) / 2;
|
||||
unsigned y = (screenheight - height) / 2;
|
||||
|
||||
MoveWindow(hwnd, x, y, width, height, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the state of the mouse cursor.
|
||||
*
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
void ShowCursorAbs(int set_visible);
|
||||
int BrowseForFolder(HWND hParent, const char *htext, char *buf);
|
||||
int BrowseForFolder(HWND hParent, const char *htext, char *buf);
|
||||
void CenterWindow(HWND hwndDlg);
|
||||
void CenterWindowOnScreen(HWND hwnd);
|
||||
|
|
|
@ -96,5 +96,6 @@ void DoPriority();
|
|||
void RemoveDirs();
|
||||
void CreateDirs();
|
||||
void SetDirs();
|
||||
void initDirectories();
|
||||
|
||||
#endif
|
Binary file not shown.
|
@ -7,6 +7,7 @@
|
|||
#define BUTTON_CLOSE 1
|
||||
#define BTN_CLOSE 1
|
||||
#define GUI_BOT_VALUES 2
|
||||
#define BTN_CANCEL 2
|
||||
#define MENU_OPEN_FILE 100
|
||||
#define EDIT_CHEATS 100
|
||||
#define MENU_CLOSE_FILE 101
|
||||
|
|
|
@ -784,6 +784,10 @@
|
|||
RelativePath="..\src\drivers\win\cheat.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\drivers\win\common.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\drivers\win\common.h"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue