Skip to content

Commit

Permalink
add manual file cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
spitfirex86 committed Aug 18, 2024
1 parent 74ca5d2 commit 8b16e5b
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 8 deletions.
2 changes: 2 additions & 0 deletions R2FixCfg/Resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ BEGIN
CONTROL "Force VSync",IDC_VSYNC,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_GROUP | WS_TABSTOP,144,91,55,10
LTEXT "Refresh rate",IDC_REFRATE_LABEL,144,108,42,8,NOT WS_VISIBLE
COMBOBOX IDC_REFRATE,197,106,43,46,CBS_DROPDOWNLIST | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Clean up files",IDC_CLEANUP,162,126,60,14,NOT WS_VISIBLE
END

IDD_PAD DIALOGEX 0, 0, 254, 194
Expand Down Expand Up @@ -337,6 +338,7 @@ STRINGTABLE
BEGIN
IDS_VE_OKWARN "File verification completed with warnings."
IDS_NEWLINE "\r\n"
IDS_CLEANUPWARN "This will delete *all* extra GOG files that are not necessary for the game to run.\n\nAre you sure you want to continue?"
END

#endif // English (United States) resources
Expand Down
29 changes: 27 additions & 2 deletions R2FixCfg/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ char const *a_szFilesToDelete[] = {
"glide3x.dll"
};

char const *a_szToManualDelete[] = {
"goggame.sdb",
"goglog.ini",
"gog.ico",
"support.ico",
"EULA.txt",
"webcache.zip",
"goggame-1207658940.dll",
"goggame-1207658940.info"
};


/*
* Functions
Expand Down Expand Up @@ -164,7 +175,7 @@ void fn_vWriteDegeIni( void )
WritePrivateProfileString("General", "FullScreenMode", szFullScreen, szDegePath);
}

void fn_vCleanUpGogMess( void )
void fn_vSoftCleanUp( void )
{
for ( DWORD i = 0; i < ARRAYSIZE(a_szFilesToDelete); i++ )
{
Expand All @@ -175,6 +186,20 @@ void fn_vCleanUpGogMess( void )
}
}

void fn_vManualCleanUp( void )
{
/* do regular cleanup first */
fn_vSoftCleanUp();

for ( DWORD i = 0; i < ARRAYSIZE(a_szToManualDelete); i++ )
{
char szFilePath[MAX_PATH];
sprintf_s(szFilePath, MAX_PATH, ".\\%s", a_szToManualDelete[i]);

DeleteFile(szFilePath);
}
}

void CFG_fn_vRead( void )
{
fn_vReadUbiIni();
Expand All @@ -194,7 +219,7 @@ void CFG_fn_vVerify( void )
if ( GetFileAttributes(".\\nglide_config.exe") != INVALID_FILE_ATTRIBUTES )
{
// Delete unnecessary nGlide files
fn_vCleanUpGogMess();
fn_vSoftCleanUp();
}

if ( GetFileAttributes(szUbiPath) == INVALID_FILE_ATTRIBUTES )
Expand Down
2 changes: 2 additions & 0 deletions R2FixCfg/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ extern tdeVerifyErr g_eErrorDetails;
void CFG_fn_vRead( void );
void CFG_fn_vWrite( void );
void CFG_fn_vVerify( void );

void fn_vManualCleanUp( void );
14 changes: 14 additions & 0 deletions R2FixCfg/generaldlg.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ static HWND hAdvGroup;
static HWND hVsync;
static HWND hRefRateLabel;
static HWND hRefRate;
static HWND hCleanup;

int lCbCustomIdx;
tdstDisplayMode eLastMode;
Expand Down Expand Up @@ -165,6 +166,7 @@ void fn_vToggleAdvanced( BOOL bVisible )
ShowWindow(hVsync, nCmdShow);
ShowWindow(hRefRateLabel, nCmdShow);
ShowWindow(hRefRate, nCmdShow);
ShowWindow(hCleanup, nCmdShow);
}

int fn_lAddThisModeToCB( HWND hCB, tdstDisplayMode *lpMode )
Expand Down Expand Up @@ -268,6 +270,7 @@ BOOL CALLBACK DLG_fn_bProc_General( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
hVsync = GetDlgItem(hWnd, IDC_VSYNC);
hRefRateLabel = GetDlgItem(hWnd, IDC_REFRATE_LABEL);
hRefRate = GetDlgItem(hWnd, IDC_REFRATE);
hCleanup = GetDlgItem(hWnd, IDC_CLEANUP);

fn_vUpdateStatus(hStatus, hToggle);
fn_vPopulateDisplayModes(hResolution);
Expand Down Expand Up @@ -361,6 +364,17 @@ BOOL CALLBACK DLG_fn_bProc_General( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
return TRUE;
}
break;

case IDC_CLEANUP:
{
char szPrompt[250];
LoadString(g_hInst, IDS_CLEANUPWARN, szPrompt, sizeof(szPrompt));

if ( MessageBox(hWnd, szPrompt, g_szAppName, MB_OKCANCEL | MB_ICONWARNING) == IDOK )
fn_vManualCleanUp();

return TRUE;
}
}
break;
}
Expand Down
10 changes: 5 additions & 5 deletions R2FixCfg/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
HINSTANCE g_hInst;
BOOL g_bUnsavedChanges = FALSE;

char szAppName[80];
char g_szAppName[80];

HWND hTC;
HWND hAdvanced;
Expand Down Expand Up @@ -63,7 +63,7 @@ BOOL fn_bAskSaveBeforeClose( HWND hWnd )
char szPrompt[250];
LoadString(g_hInst, IDS_ASKTOSAVE, szPrompt, sizeof(szPrompt));

int result = MessageBox(hWnd, szPrompt, szAppName, MB_YESNOCANCEL | MB_ICONASTERISK);
int result = MessageBox(hWnd, szPrompt, g_szAppName, MB_YESNOCANCEL | MB_ICONASTERISK);

switch ( result )
{
Expand Down Expand Up @@ -178,7 +178,7 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
MSG msg;
g_hInst = hInstance;

LoadRcString(IDS_APPNAME, szAppName);
LoadRcString(IDS_APPNAME, g_szAppName);

HANDLE hMutex = CreateMutex(NULL, TRUE, "Ray2FixCfgSI");

Expand All @@ -188,7 +188,7 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
if ( GetLastError() == ERROR_ALREADY_EXISTS )
{
// If another instance already exists, find the window and activate it
HWND hWndExisting = FindWindow(NULL, szAppName);
HWND hWndExisting = FindWindow(NULL, g_szAppName);
if ( hWndExisting )
{
SetForegroundWindow(hWndExisting);
Expand All @@ -206,7 +206,7 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
if ( hDlg == NULL )
return 1;

SetWindowText(hDlg, szAppName);
SetWindowText(hDlg, g_szAppName);
ShowWindow(hDlg, nCmdShow);

HACCEL hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCEL));
Expand Down
2 changes: 2 additions & 0 deletions R2FixCfg/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@

extern HINSTANCE g_hInst;
extern BOOL g_bUnsavedChanges;

extern char g_szAppName[80];
4 changes: 3 additions & 1 deletion R2FixCfg/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#define IDS_WARNING 127
#define IDS_VE_OKWARN 128
#define IDS_NEWLINE 129
#define IDS_CLEANUPWARN 130
#define IDC_MAINTOGGLE 1001
#define IDC_STATUSLINE 1002
#define IDC_TAB1 1006
Expand All @@ -51,6 +52,7 @@
#define IDC_LS 1032
#define IDC_CHECK1 1036
#define IDC_PATCHWIDE 1036
#define IDC_CLEANUP 1037
#define IDC_RS 1062
#define IDC_LSCLICK 1063
#define IDC_RSCLICK 1064
Expand All @@ -77,7 +79,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 111
#define _APS_NEXT_COMMAND_VALUE 40003
#define _APS_NEXT_CONTROL_VALUE 1037
#define _APS_NEXT_CONTROL_VALUE 1038
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

0 comments on commit 8b16e5b

Please sign in to comment.