| Index: dxglcfg/dxglcfg.c |
| — | — | @@ -1,2894 +0,0 @@ |
| 2 | | -// DXGL
|
| 3 | | -// Copyright (C) 2011-2017 William Feely
|
| 4 | | -
|
| 5 | | -// This library is free software; you can redistribute it and/or
|
| 6 | | -// modify it under the terms of the GNU Lesser General Public
|
| 7 | | -// License as published by the Free Software Foundation; either
|
| 8 | | -// version 2.1 of the License, or (at your option) any later version.
|
| 9 | | -
|
| 10 | | -// This library is distributed in the hope that it will be useful,
|
| 11 | | -// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 | | -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 | | -// Lesser General Public License for more details.
|
| 14 | | -
|
| 15 | | -// You should have received a copy of the GNU Lesser General Public
|
| 16 | | -// License along with this library; if not, write to the Free Software
|
| 17 | | -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 18 | | -
|
| 19 | | -#define _WIN32_WINNT 0x0600
|
| 20 | | -#define _WIN32_IE 0x0300
|
| 21 | | -#define _CRT_SECURE_NO_WARNINGS
|
| 22 | | -#define _CRTDBG_MAP_ALLOC
|
| 23 | | -#include <stdlib.h>
|
| 24 | | -#include <crtdbg.h>
|
| 25 | | -#include <windows.h>
|
| 26 | | -#include <HtmlHelp.h>
|
| 27 | | -#include <CommCtrl.h>
|
| 28 | | -#include <string.h>
|
| 29 | | -#include <tchar.h>
|
| 30 | | -#include <stdio.h>
|
| 31 | | -#include <float.h>
|
| 32 | | -#include <math.h>
|
| 33 | | -#include <io.h>
|
| 34 | | -#include <Uxtheme.h>
|
| 35 | | -#include <Vsstyle.h>
|
| 36 | | -#include "resource.h"
|
| 37 | | -#include "../cfgmgr/LibSha256.h"
|
| 38 | | -#include "../cfgmgr/cfgmgr.h"
|
| 39 | | -#include <gl/GL.h>
|
| 40 | | -
|
| 41 | | -#ifndef SHGFI_ADDOVERLAYS
|
| 42 | | -#define SHGFI_ADDOVERLAYS 0x000000020
|
| 43 | | -#endif //SHGFI_ADDOVERLAYS
|
| 44 | | -
|
| 45 | | -#ifndef BCM_SETSHIELD
|
| 46 | | -#define BCM_SETSHIELD 0x160C
|
| 47 | | -#endif
|
| 48 | | -
|
| 49 | | -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
|
| 50 | | -#define GL_MAX_SAMPLES_EXT 0x8D57
|
| 51 | | -#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11
|
| 52 | | -#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12
|
| 53 | | -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
|
| 54 | | -
|
| 55 | | -DXGLCFG *cfg;
|
| 56 | | -DXGLCFG *cfgmask;
|
| 57 | | -BOOL *dirty;
|
| 58 | | -HINSTANCE hinstance;
|
| 59 | | -BOOL msaa = FALSE;
|
| 60 | | -const char *extensions_string = NULL;
|
| 61 | | -OSVERSIONINFO osver;
|
| 62 | | -TCHAR hlppath[MAX_PATH+16];
|
| 63 | | -HMODULE uxtheme = NULL;
|
| 64 | | -HTHEME hThemeDisplay = NULL;
|
| 65 | | -HTHEME(WINAPI *_OpenThemeData)(HWND hwnd, LPCWSTR pszClassList) = NULL;
|
| 66 | | -HRESULT(WINAPI *_CloseThemeData)(HTHEME hTheme) = NULL;
|
| 67 | | -HRESULT(WINAPI *_DrawThemeBackground)(HTHEME hTheme, HDC hdc, int iPartID,
|
| 68 | | - int iStateID, const RECT *pRect, const RECT *pClipRect) = NULL;
|
| 69 | | -HRESULT(WINAPI *_EnableThemeDialogTexture)(HWND hwnd, DWORD dwFlags) = NULL;
|
| 70 | | -static BOOL ExtraModes_Dropdown = FALSE;
|
| 71 | | -static BOOL ColorDepth_Dropdown = FALSE;
|
| 72 | | -static HWND hDialog = NULL;
|
| 73 | | -
|
| 74 | | -
|
| 75 | | -typedef struct
|
| 76 | | -{
|
| 77 | | - LPTSTR regkey;
|
| 78 | | - LPTSTR name;
|
| 79 | | - HICON icon;
|
| 80 | | - BOOL icon_shared;
|
| 81 | | - BOOL dirty;
|
| 82 | | - DXGLCFG cfg;
|
| 83 | | - DXGLCFG mask;
|
| 84 | | - TCHAR path[MAX_PATH];
|
| 85 | | - BOOL builtin;
|
| 86 | | -} app_setting;
|
| 87 | | -
|
| 88 | | -TCHAR exe_filter[] = _T("Program Files\0*.exe\0All Files\0*.*\0\0");
|
| 89 | | -
|
| 90 | | -app_setting *apps;
|
| 91 | | -int appcount;
|
| 92 | | -int maxapps;
|
| 93 | | -DWORD current_app;
|
| 94 | | -BOOL tristate;
|
| 95 | | -TCHAR strdefault[] = _T("(global default)");
|
| 96 | | -HWND hTab;
|
| 97 | | -HWND hTabs[6];
|
| 98 | | -int tabopen;
|
| 99 | | -
|
| 100 | | -static const TCHAR *colormodes[32] = {
|
| 101 | | - _T("None"),
|
| 102 | | - _T("8-bit"),
|
| 103 | | - _T("15-bit"),
|
| 104 | | - _T("8/15-bit"),
|
| 105 | | - _T("16-bit"),
|
| 106 | | - _T("8/16-bit"),
|
| 107 | | - _T("15/16-bit"),
|
| 108 | | - _T("8/15/16-bit"),
|
| 109 | | - _T("24-bit"),
|
| 110 | | - _T("8/24-bit"),
|
| 111 | | - _T("15/24-bit"),
|
| 112 | | - _T("8/15/24-bit"),
|
| 113 | | - _T("16/24-bit"),
|
| 114 | | - _T("8/16/24-bit"),
|
| 115 | | - _T("15/16/24-bit"),
|
| 116 | | - _T("8/15/16/24-bit"),
|
| 117 | | - _T("32-bit"),
|
| 118 | | - _T("8/32-bit"),
|
| 119 | | - _T("15/32-bit"),
|
| 120 | | - _T("8/15/32-bit"),
|
| 121 | | - _T("16/32-bit"),
|
| 122 | | - _T("8/16/32-bit"),
|
| 123 | | - _T("15/16/32-bit"),
|
| 124 | | - _T("8/15/16/32-bit"),
|
| 125 | | - _T("24/32-bit"),
|
| 126 | | - _T("8/24/32-bit"),
|
| 127 | | - _T("15/24/32-bit"),
|
| 128 | | - _T("8/15/24/32-bit"),
|
| 129 | | - _T("16/24/32-bit"),
|
| 130 | | - _T("8/16/24/32-bit"),
|
| 131 | | - _T("15/16/24/32-bit"),
|
| 132 | | - _T("8/15/16/24/32-bit")
|
| 133 | | -};
|
| 134 | | -
|
| 135 | | -static const TCHAR *colormodedropdown[5] = {
|
| 136 | | - _T("8-bit"),
|
| 137 | | - _T("15-bit"),
|
| 138 | | - _T("16-bit"),
|
| 139 | | - _T("24-bit"),
|
| 140 | | - _T("32-bit")
|
| 141 | | -};
|
| 142 | | -
|
| 143 | | -static const TCHAR *extramodes[7] = {
|
| 144 | | - _T("Common low resolutions"),
|
| 145 | | - _T("Uncommon low resolutions"),
|
| 146 | | - _T("Uncommon SD resolutions"),
|
| 147 | | - _T("High Definition resolutions"),
|
| 148 | | - _T("Ultra-HD resolutions"),
|
| 149 | | - _T("Ultra-HD above 4k"),
|
| 150 | | - _T("Very uncommon resolutions")
|
| 151 | | -};
|
| 152 | | -
|
| 153 | | -DWORD AddApp(LPCTSTR path, BOOL copyfile, BOOL admin, BOOL force, HWND hwnd)
|
| 154 | | -{
|
| 155 | | - BOOL installed = FALSE;
|
| 156 | | - BOOL dxgl_installdir = FALSE;
|
| 157 | | - BOOL old_dxgl = TRUE;
|
| 158 | | - BOOL backupped = FALSE;
|
| 159 | | - TCHAR command[MAX_PATH + 37];
|
| 160 | | - SHELLEXECUTEINFO shex;
|
| 161 | | - DWORD exitcode;
|
| 162 | | - app_ini_options inioptions;
|
| 163 | | - HMODULE hmod;
|
| 164 | | - if (copyfile)
|
| 165 | | - {
|
| 166 | | - DWORD sizeout = (MAX_PATH + 1) * sizeof(TCHAR);
|
| 167 | | - TCHAR installpath[MAX_PATH + 1];
|
| 168 | | - TCHAR srcpath[MAX_PATH + 1];
|
| 169 | | - TCHAR inipath[MAX_PATH + 1];
|
| 170 | | - TCHAR backuppath[MAX_PATH + 1];
|
| 171 | | - TCHAR destpath[MAX_PATH + 1];
|
| 172 | | - HKEY hKeyInstall;
|
| 173 | | - LONG error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\DXGL"), 0, KEY_READ, &hKeyInstall);
|
| 174 | | - if (error == ERROR_SUCCESS)
|
| 175 | | - {
|
| 176 | | - dxgl_installdir = TRUE;
|
| 177 | | - error = RegQueryValueEx(hKeyInstall, _T("InstallDir"), NULL, NULL, (LPBYTE)installpath, &sizeout);
|
| 178 | | - if (error == ERROR_SUCCESS) installed = TRUE;
|
| 179 | | - }
|
| 180 | | - if (hKeyInstall) RegCloseKey(hKeyInstall);
|
| 181 | | - if (!installed)
|
| 182 | | - {
|
| 183 | | - GetModuleFileName(NULL, installpath, MAX_PATH + 1);
|
| 184 | | - }
|
| 185 | | - if (dxgl_installdir) _tcscat(installpath, _T("\\"));
|
| 186 | | - else (_tcsrchr(installpath, _T('\\')))[1] = 0;
|
| 187 | | - _tcsncpy(srcpath, installpath, MAX_PATH + 1);
|
| 188 | | - _tcscat(srcpath, _T("ddraw.dll"));
|
| 189 | | - _tcsncpy(destpath, path, MAX_PATH + 1);
|
| 190 | | - (_tcsrchr(destpath, _T('\\')))[1] = 0;
|
| 191 | | - _tcscat(destpath, _T("ddraw.dll"));
|
| 192 | | - _tcsncpy(backuppath, path, MAX_PATH + 1);
|
| 193 | | - (_tcsrchr(backuppath, _T('\\')))[1] = 0;
|
| 194 | | - _tcscat(backuppath, _T("ddraw.dll.dxgl-backup"));
|
| 195 | | - _tcsncpy(inipath, path, MAX_PATH + 1);
|
| 196 | | - (_tcsrchr(inipath, _T('\\')))[1] = 0;
|
| 197 | | - // Check for DXGL ini file and existing ddraw.dll
|
| 198 | | - ReadAppINIOptions(inipath, &inioptions);
|
| 199 | | - error = CopyFile(srcpath, destpath, TRUE);
|
| 200 | | - error_loop:
|
| 201 | | - if (!error)
|
| 202 | | - {
|
| 203 | | - error = GetLastError();
|
| 204 | | - if (error == ERROR_FILE_EXISTS)
|
| 205 | | - {
|
| 206 | | - if (inioptions.NoOverwrite)
|
| 207 | | - {
|
| 208 | | - MessageBox(hwnd, _T("Cannot install DXGL. An INI file has \
|
| 209 | | -been placed in your game folder prohibiting overwriting the existing DirectDraw \
|
| 210 | | -library.\r\n\r\nIf you want to install DXGL, edit the dxgl.ini file in your game \
|
| 211 | | -folder and set the NoOverwite value to false.\r\n\r\n\
|
| 212 | | -A profile will still be created for your game but may not be compatible with the \
|
| 213 | | -DirectDraw library in your game folder."), _T("Error"), MB_OK | MB_ICONERROR);
|
| 214 | | - return 0; // Continue to install registry key anyway
|
| 215 | | - }
|
| 216 | | - if ((inioptions.sha256[0] != 0) && !memcmp(inioptions.sha256, inioptions.sha256comp, 64))
|
| 217 | | - // Detected original ddraw matches INI hash
|
| 218 | | - {
|
| 219 | | - error = CopyFile(destpath, backuppath, FALSE);
|
| 220 | | - if (!error)
|
| 221 | | - {
|
| 222 | | - error = GetLastError();
|
| 223 | | - if ((error == ERROR_ACCESS_DENIED) && !admin)
|
| 224 | | - {
|
| 225 | | - _tcscpy(command, _T(" install "));
|
| 226 | | - _tcscat(command, path);
|
| 227 | | - ZeroMemory(&shex, sizeof(SHELLEXECUTEINFO));
|
| 228 | | - shex.cbSize = sizeof(SHELLEXECUTEINFO);
|
| 229 | | - shex.lpVerb = _T("runas");
|
| 230 | | - shex.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| 231 | | - _tcscat(installpath, _T("\\dxglcfg.exe"));
|
| 232 | | - shex.lpFile = installpath;
|
| 233 | | - shex.lpParameters = command;
|
| 234 | | - ShellExecuteEx(&shex);
|
| 235 | | - WaitForSingleObject(shex.hProcess, INFINITE);
|
| 236 | | - GetExitCodeProcess(shex.hProcess, &exitcode);
|
| 237 | | - return exitcode;
|
| 238 | | - }
|
| 239 | | - }
|
| 240 | | - else backupped = TRUE;
|
| 241 | | - }
|
| 242 | | - error = SetErrorMode(SEM_FAILCRITICALERRORS);
|
| 243 | | - SetErrorMode(error | SEM_FAILCRITICALERRORS);
|
| 244 | | - hmod = LoadLibrary(destpath);
|
| 245 | | - SetErrorMode(error);
|
| 246 | | - if(hmod)
|
| 247 | | - {
|
| 248 | | - if(GetProcAddress(hmod,"IsDXGLDDraw") || force) old_dxgl = TRUE;
|
| 249 | | - else old_dxgl = FALSE;
|
| 250 | | - FreeLibrary(hmod);
|
| 251 | | - }
|
| 252 | | - else
|
| 253 | | - {
|
| 254 | | - if (force) old_dxgl = TRUE;
|
| 255 | | - else old_dxgl = FALSE;
|
| 256 | | - }
|
| 257 | | - if(old_dxgl)
|
| 258 | | - {
|
| 259 | | - error = CopyFile(srcpath,destpath,FALSE);
|
| 260 | | - goto error_loop;
|
| 261 | | - }
|
| 262 | | - else
|
| 263 | | - {
|
| 264 | | - // Prompt to overwrite
|
| 265 | | - if (MessageBox(hwnd, _T("A custom DirectDraw library has been detected in \
|
| 266 | | -your game folder. Would you like to replace it with DXGL?\r\n\r\n\
|
| 267 | | -Warning: Installing DXGL will remove any customizations that the existing custom DirectDraw \
|
| 268 | | -library may have."), _T("DXGL Config"), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) == IDYES)
|
| 269 | | - {
|
| 270 | | - error = CopyFile(srcpath, destpath, FALSE);
|
| 271 | | - goto error_loop;
|
| 272 | | - }
|
| 273 | | - else
|
| 274 | | - {
|
| 275 | | - if (backupped) DeleteFile(backuppath);
|
| 276 | | - }
|
| 277 | | - }
|
| 278 | | - }
|
| 279 | | - if((error == ERROR_ACCESS_DENIED) && !admin)
|
| 280 | | - {
|
| 281 | | - if(old_dxgl) _tcscpy(command,_T(" install "));
|
| 282 | | - else _tcscpy(command, _T(" forceinstall "));
|
| 283 | | - _tcscat(command,path);
|
| 284 | | - ZeroMemory(&shex,sizeof(SHELLEXECUTEINFO));
|
| 285 | | - shex.cbSize = sizeof(SHELLEXECUTEINFO);
|
| 286 | | - shex.lpVerb = _T("runas");
|
| 287 | | - shex.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| 288 | | - _tcscat(installpath,_T("\\dxglcfg.exe"));
|
| 289 | | - shex.lpFile = installpath;
|
| 290 | | - shex.lpParameters = command;
|
| 291 | | - ShellExecuteEx(&shex);
|
| 292 | | - WaitForSingleObject(shex.hProcess,INFINITE);
|
| 293 | | - GetExitCodeProcess(shex.hProcess,&exitcode);
|
| 294 | | - return exitcode;
|
| 295 | | - }
|
| 296 | | - return error;
|
| 297 | | - }
|
| 298 | | - }
|
| 299 | | - return 0;
|
| 300 | | -}
|
| 301 | | -
|
| 302 | | -DWORD DelApp(LPCTSTR path, BOOL admin, HWND hwnd)
|
| 303 | | -{
|
| 304 | | - BOOL installed = FALSE;
|
| 305 | | - TCHAR command[MAX_PATH + 32];
|
| 306 | | - BOOL old_dxgl = TRUE;
|
| 307 | | - DWORD sizeout = (MAX_PATH+1)*sizeof(TCHAR);
|
| 308 | | - TCHAR installpath[MAX_PATH+1];
|
| 309 | | - TCHAR inipath[MAX_PATH + 1];
|
| 310 | | - TCHAR backuppath[MAX_PATH + 1];
|
| 311 | | - HKEY hKeyInstall;
|
| 312 | | - HMODULE hmod;
|
| 313 | | - SHELLEXECUTEINFO shex;
|
| 314 | | - DWORD exitcode;
|
| 315 | | - HANDLE exists;
|
| 316 | | - app_ini_options inioptions;
|
| 317 | | - LONG error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\DXGL"), 0, KEY_READ, &hKeyInstall);
|
| 318 | | - if(error == ERROR_SUCCESS)
|
| 319 | | - {
|
| 320 | | - error = RegQueryValueEx(hKeyInstall,_T("InstallDir"),NULL,NULL,(LPBYTE)installpath,&sizeout);
|
| 321 | | - if(error == ERROR_SUCCESS) installed = TRUE;
|
| 322 | | - }
|
| 323 | | - if(hKeyInstall) RegCloseKey(hKeyInstall);
|
| 324 | | - if(!installed)
|
| 325 | | - {
|
| 326 | | - GetModuleFileName(NULL,installpath,MAX_PATH+1);
|
| 327 | | - }
|
| 328 | | - _tcsncpy(inipath, path, MAX_PATH + 1);
|
| 329 | | - (_tcsrchr(inipath, _T('\\')))[1] = 0;
|
| 330 | | - _tcsncpy(backuppath, path, MAX_PATH + 1);
|
| 331 | | - (_tcsrchr(backuppath, _T('\\')))[1] = 0;
|
| 332 | | - _tcscat(backuppath, _T("ddraw.dll.dxgl-backup"));
|
| 333 | | - // Check for DXGL ini file and existing ddraw.dll
|
| 334 | | - ReadAppINIOptions(inipath, &inioptions);
|
| 335 | | - if (inioptions.NoOverwrite || inioptions.NoUninstall)
|
| 336 | | - {
|
| 337 | | - MessageBox(hwnd,_T("DXGL has not been removed from your game folder. \
|
| 338 | | -An INI file has been found in your game folder prohibiting the DirectDraw \
|
| 339 | | -library in your game folder from being deleted.\r\n\r\n\
|
| 340 | | -If this is in error, you will have to manually delete ddraw.dll from your \
|
| 341 | | -game folder. If your game was distributed by Steam or a similar service \
|
| 342 | | -please verify your game files after removing the file, in case the game \
|
| 343 | | -shipped with a custom DirectDraw library."), _T("Warning"), MB_OK | MB_ICONWARNING);
|
| 344 | | - return 0; // Continue to delete registry profile.
|
| 345 | | - }
|
| 346 | | - error = SetErrorMode(SEM_FAILCRITICALERRORS);
|
| 347 | | - SetErrorMode(error | SEM_FAILCRITICALERRORS);
|
| 348 | | - hmod = LoadLibrary(path);
|
| 349 | | - SetErrorMode(error);
|
| 350 | | - if(hmod)
|
| 351 | | - {
|
| 352 | | - if(!GetProcAddress(hmod,"IsDXGLDDraw")) old_dxgl = FALSE;
|
| 353 | | - FreeLibrary(hmod);
|
| 354 | | - }
|
| 355 | | - else old_dxgl = FALSE;
|
| 356 | | - if(!old_dxgl) return 0;
|
| 357 | | - if(!DeleteFile(path))
|
| 358 | | - {
|
| 359 | | - error = GetLastError();
|
| 360 | | - if((error == ERROR_ACCESS_DENIED) && !admin)
|
| 361 | | - {
|
| 362 | | - _tcscpy(command,_T(" remove "));
|
| 363 | | - _tcscat(command,path);
|
| 364 | | - ZeroMemory(&shex,sizeof(SHELLEXECUTEINFO));
|
| 365 | | - shex.cbSize = sizeof(SHELLEXECUTEINFO);
|
| 366 | | - shex.lpVerb = _T("runas");
|
| 367 | | - shex.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| 368 | | - _tcscat(installpath,_T("\\dxglcfg.exe"));
|
| 369 | | - shex.lpFile = installpath;
|
| 370 | | - shex.lpParameters = command;
|
| 371 | | - ShellExecuteEx(&shex);
|
| 372 | | - WaitForSingleObject(shex.hProcess,INFINITE);
|
| 373 | | - GetExitCodeProcess(shex.hProcess,&exitcode);
|
| 374 | | - return exitcode;
|
| 375 | | - }
|
| 376 | | - else if (error != ERROR_FILE_NOT_FOUND) return error;
|
| 377 | | - }
|
| 378 | | - exists = CreateFile(backuppath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
| 379 | | - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
| 380 | | - if (exists == INVALID_HANDLE_VALUE) return 0;
|
| 381 | | - else
|
| 382 | | - {
|
| 383 | | - CloseHandle(exists);
|
| 384 | | - error = MoveFile(backuppath, path);
|
| 385 | | - if (!error)
|
| 386 | | - {
|
| 387 | | - error = GetLastError();
|
| 388 | | - if ((error == ERROR_ACCESS_DENIED) && !admin)
|
| 389 | | - {
|
| 390 | | - _tcscpy(command, _T(" remove "));
|
| 391 | | - _tcscat(command, path);
|
| 392 | | - ZeroMemory(&shex, sizeof(SHELLEXECUTEINFO));
|
| 393 | | - shex.cbSize = sizeof(SHELLEXECUTEINFO);
|
| 394 | | - shex.lpVerb = _T("runas");
|
| 395 | | - shex.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| 396 | | - _tcscat(installpath, _T("\\dxglcfg.exe"));
|
| 397 | | - shex.lpFile = installpath;
|
| 398 | | - shex.lpParameters = command;
|
| 399 | | - ShellExecuteEx(&shex);
|
| 400 | | - WaitForSingleObject(shex.hProcess, INFINITE);
|
| 401 | | - GetExitCodeProcess(shex.hProcess, &exitcode);
|
| 402 | | - return exitcode;
|
| 403 | | - }
|
| 404 | | - else return error;
|
| 405 | | - }
|
| 406 | | - }
|
| 407 | | - return 0;
|
| 408 | | -}
|
| 409 | | -
|
| 410 | | -void SaveChanges(HWND hWnd)
|
| 411 | | -{
|
| 412 | | - int i;
|
| 413 | | - if(apps[0].dirty) SetGlobalConfig(&apps[0].cfg);
|
| 414 | | - for(i = 1; i < appcount; i++)
|
| 415 | | - {
|
| 416 | | - if(apps[i].dirty) SetConfig(&apps[i].cfg,&apps[i].mask,apps[i].regkey);
|
| 417 | | - }
|
| 418 | | - EnableWindow(GetDlgItem(hWnd,IDC_APPLY),FALSE);
|
| 419 | | -}
|
| 420 | | -
|
| 421 | | -void FloatToAspect(float f, LPTSTR aspect)
|
| 422 | | -{
|
| 423 | | - double integer;
|
| 424 | | - double dummy;
|
| 425 | | - float fract;
|
| 426 | | - TCHAR denominator[5];
|
| 427 | | - int i;
|
| 428 | | - if (_isnan(f)) f = 0.0f; //Handle NAN condition
|
| 429 | | - if (f >= 1000.0f) // Clamp ridiculously wide aspects
|
| 430 | | - {
|
| 431 | | - _tcscpy(aspect, _T("1000:1"));
|
| 432 | | - return;
|
| 433 | | - }
|
| 434 | | - if (f < 0.001f) // Exclude ridiculously tall aspects, zero, and negative
|
| 435 | | - {
|
| 436 | | - _tcscpy(aspect, _T("Default"));
|
| 437 | | - return;
|
| 438 | | - }
|
| 439 | | - // Handle common aspects
|
| 440 | | - if (fabsf(f - 1.25f) < 0.0001f)
|
| 441 | | - {
|
| 442 | | - _tcscpy(aspect, _T("5:4"));
|
| 443 | | - return;
|
| 444 | | - }
|
| 445 | | - if (fabsf(f - 1.3333333f) < 0.0001f)
|
| 446 | | - {
|
| 447 | | - _tcscpy(aspect, _T("4:3"));
|
| 448 | | - return;
|
| 449 | | - }
|
| 450 | | - if (fabsf(f - 1.6f) < 0.0001f)
|
| 451 | | - {
|
| 452 | | - _tcscpy(aspect, _T("16:10"));
|
| 453 | | - return;
|
| 454 | | - }
|
| 455 | | - if (fabsf(f - 1.7777777) < 0.0001f)
|
| 456 | | - {
|
| 457 | | - _tcscpy(aspect, _T("16:9"));
|
| 458 | | - return;
|
| 459 | | - }
|
| 460 | | - if (fabsf(f - 1.9333333) < 0.0001f)
|
| 461 | | - {
|
| 462 | | - _tcscpy(aspect, _T("256:135"));
|
| 463 | | - return;
|
| 464 | | - }
|
| 465 | | - fract = modff(f, &integer);
|
| 466 | | - if (fract < 0.0001f) //Handle integer aspects
|
| 467 | | - {
|
| 468 | | - _itot((int)integer, aspect, 10);
|
| 469 | | - _tcscat(aspect, _T(":1"));
|
| 470 | | - return;
|
| 471 | | - }
|
| 472 | | - // Finally try from 2 to 1000
|
| 473 | | - for (i = 2; i < 1000; i++)
|
| 474 | | - {
|
| 475 | | - if (fabsf(modff(fract*i, &dummy)) < 0.0001f)
|
| 476 | | - {
|
| 477 | | - _itot((f*i) + .5f, aspect, 10);
|
| 478 | | - _itot(i, denominator, 10);
|
| 479 | | - _tcscat(aspect, _T(":"));
|
| 480 | | - _tcscat(aspect, denominator);
|
| 481 | | - return;
|
| 482 | | - }
|
| 483 | | - }
|
| 484 | | - // Cannot find a reasonable fractional aspect, so display as decimal.
|
| 485 | | -#ifdef _UNICODE
|
| 486 | | - swprintf(aspect, 31, L"%.6g", f);
|
| 487 | | -#else
|
| 488 | | - sprintf(aspect,"%.6g", f);
|
| 489 | | -#endif
|
| 490 | | -}
|
| 491 | | -
|
| 492 | | -void FloatToScale(float x, float y, LPTSTR scale)
|
| 493 | | -{
|
| 494 | | - TCHAR numberx[8];
|
| 495 | | - TCHAR numbery[8];
|
| 496 | | - if (_isnan(x)) x = 0.0f; //Handle NAN condition
|
| 497 | | - if (_isnan(y)) y = 0.0f;
|
| 498 | | - // Too low number, round to "Auto"
|
| 499 | | - if (x < 0.25f) x = 0.0f;
|
| 500 | | - if (y < 0.25f) y = 0.0f;
|
| 501 | | - // Too high number, round to 16
|
| 502 | | - if (x > 16.0f) x = 16.0f;
|
| 503 | | - if (y > 16.0f) y = 16.0f;
|
| 504 | | - // Test if either scale is zero
|
| 505 | | - if ((x == 0) || (y == 0))
|
| 506 | | - {
|
| 507 | | - _tcscpy(scale, _T("Auto"));
|
| 508 | | - return;
|
| 509 | | - }
|
| 510 | | - // Write numbers
|
| 511 | | -#ifdef _UNICODE
|
| 512 | | - swprintf(numberx, 7, L"%.4g", x);
|
| 513 | | - swprintf(numbery, 7, L"%.4g", y);
|
| 514 | | -#else
|
| 515 | | - sprintf(numberx, ".4g", x);
|
| 516 | | - sprintf(numbery, ".4g", y);
|
| 517 | | -#endif
|
| 518 | | - // Fill out string
|
| 519 | | - _tcscpy(scale, numberx);
|
| 520 | | - _tcscat(scale, _T("x"));
|
| 521 | | - if (x != y) _tcscat(scale, numbery);
|
| 522 | | -}
|
| 523 | | -
|
| 524 | | -void SetCheck(HWND hWnd, int DlgItem, BOOL value, BOOL mask, BOOL tristate)
|
| 525 | | -{
|
| 526 | | - if(tristate && !mask)
|
| 527 | | - SendDlgItemMessage(hWnd,DlgItem,BM_SETCHECK,BST_INDETERMINATE,0);
|
| 528 | | - else
|
| 529 | | - {
|
| 530 | | - if(value) SendDlgItemMessage(hWnd,DlgItem,BM_SETCHECK,BST_CHECKED,0);
|
| 531 | | - else SendDlgItemMessage(hWnd,DlgItem,BM_SETCHECK,BST_UNCHECKED,0);
|
| 532 | | - }
|
| 533 | | -}
|
| 534 | | -
|
| 535 | | -void SetCombo(HWND hWnd, int DlgItem, DWORD value, DWORD mask, BOOL tristate)
|
| 536 | | -{
|
| 537 | | - if(tristate && !mask)
|
| 538 | | - SendDlgItemMessage(hWnd,DlgItem,CB_SETCURSEL,
|
| 539 | | - SendDlgItemMessage(hWnd,DlgItem,CB_FINDSTRING,-1,(LPARAM)strdefault),0);
|
| 540 | | - else
|
| 541 | | - SendDlgItemMessage(hWnd,DlgItem,CB_SETCURSEL,value,0);
|
| 542 | | -}
|
| 543 | | -
|
| 544 | | -__inline DWORD EncodePrimaryScale(DWORD scale)
|
| 545 | | -{
|
| 546 | | - switch (scale)
|
| 547 | | - {
|
| 548 | | - case 0:
|
| 549 | | - return 2;
|
| 550 | | - case 1:
|
| 551 | | - return 0;
|
| 552 | | - case 2:
|
| 553 | | - return 1;
|
| 554 | | - default:
|
| 555 | | - return scale;
|
| 556 | | - }
|
| 557 | | -}
|
| 558 | | -
|
| 559 | | -void SetPrimaryScaleCombo(HWND hWnd, int DlgItem, DWORD value, DWORD mask, BOOL tristate)
|
| 560 | | -{
|
| 561 | | - if (tristate && !mask)
|
| 562 | | - SendDlgItemMessage(hWnd, DlgItem, CB_SETCURSEL,
|
| 563 | | - SendDlgItemMessage(hWnd, DlgItem, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 564 | | - else
|
| 565 | | - SendDlgItemMessage(hWnd, DlgItem, CB_SETCURSEL, EncodePrimaryScale(value), 0);
|
| 566 | | -}
|
| 567 | | -
|
| 568 | | -void SetAspectCombo(HWND hWnd, int DlgItem, float value, DWORD mask, BOOL tristate)
|
| 569 | | -{
|
| 570 | | - TCHAR buffer[32];
|
| 571 | | - if (tristate && !mask)
|
| 572 | | - SendDlgItemMessage(hWnd, DlgItem, CB_SETCURSEL,
|
| 573 | | - SendDlgItemMessage(hWnd, DlgItem, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 574 | | - else
|
| 575 | | - {
|
| 576 | | - FloatToAspect(value, buffer);
|
| 577 | | - SendDlgItemMessage(hWnd,DlgItem,CB_SETCURSEL,
|
| 578 | | - SendDlgItemMessage(hWnd, DlgItem, CB_FINDSTRING, -1, (LPARAM)buffer), 0);
|
| 579 | | - SetDlgItemText(hWnd, DlgItem, buffer);
|
| 580 | | - }
|
| 581 | | -}
|
| 582 | | -
|
| 583 | | -void SetPostScaleCombo(HWND hWnd, int DlgItem, float x, float y, DWORD maskx, DWORD masky, BOOL tristate)
|
| 584 | | -{
|
| 585 | | - TCHAR buffer[32];
|
| 586 | | - if (tristate && !maskx && !masky)
|
| 587 | | - SendDlgItemMessage(hWnd, DlgItem, CB_SETCURSEL,
|
| 588 | | - SendDlgItemMessage(hWnd, DlgItem, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 589 | | - else
|
| 590 | | - {
|
| 591 | | - FloatToScale(x, y, buffer);
|
| 592 | | - SendDlgItemMessage(hWnd, DlgItem, CB_SETCURSEL,
|
| 593 | | - SendDlgItemMessage(hWnd, DlgItem, CB_FINDSTRING, -1, (LPARAM)buffer), 0);
|
| 594 | | - SetDlgItemText(hWnd, DlgItem, buffer);
|
| 595 | | - }
|
| 596 | | -}
|
| 597 | | -
|
| 598 | | -void SetText(HWND hWnd, int DlgItem, TCHAR *value, TCHAR *mask, BOOL tristate)
|
| 599 | | -{
|
| 600 | | - if(tristate && (mask[0] == 0))
|
| 601 | | - SetWindowText(GetDlgItem(hWnd,DlgItem),_T(""));
|
| 602 | | - else SetWindowText(GetDlgItem(hWnd,DlgItem),value);
|
| 603 | | -}
|
| 604 | | -
|
| 605 | | -BOOL GetCheck(HWND hWnd, int DlgItem, BOOL *mask)
|
| 606 | | -{
|
| 607 | | - int check = SendDlgItemMessage(hWnd,DlgItem,BM_GETCHECK,0,0);
|
| 608 | | - switch(check)
|
| 609 | | - {
|
| 610 | | - case BST_CHECKED:
|
| 611 | | - *mask = TRUE;
|
| 612 | | - return TRUE;
|
| 613 | | - case BST_UNCHECKED:
|
| 614 | | - *mask = TRUE;
|
| 615 | | - return FALSE;
|
| 616 | | - case BST_INDETERMINATE:
|
| 617 | | - default:
|
| 618 | | - *mask = FALSE;
|
| 619 | | - return FALSE;
|
| 620 | | - }
|
| 621 | | -}
|
| 622 | | -
|
| 623 | | -DWORD GetCombo(HWND hWnd, int DlgItem, DWORD *mask)
|
| 624 | | -{
|
| 625 | | - int value = SendDlgItemMessage(hWnd,DlgItem,CB_GETCURSEL,0,0);
|
| 626 | | - if(value == SendDlgItemMessage(hWnd,DlgItem,CB_FINDSTRING,-1,(LPARAM)strdefault))
|
| 627 | | - {
|
| 628 | | - *mask = 0;
|
| 629 | | - return 0;
|
| 630 | | - }
|
| 631 | | - else
|
| 632 | | - {
|
| 633 | | - *mask = 1;
|
| 634 | | - return value;
|
| 635 | | - }
|
| 636 | | -}
|
| 637 | | -
|
| 638 | | -void GetPostScaleCombo(HWND hWnd, int DlgItem, float *x, float *y, float *maskx, float *masky)
|
| 639 | | -{
|
| 640 | | - TCHAR buffer[32];
|
| 641 | | - TCHAR *ptr;
|
| 642 | | - GetDlgItemText(hWnd, DlgItem, buffer, 31);
|
| 643 | | - buffer[31] = 0;
|
| 644 | | - if (!_tcscmp(buffer, strdefault))
|
| 645 | | - {
|
| 646 | | - *maskx = 0.0f;
|
| 647 | | - *masky = 0.0f;
|
| 648 | | - *x = 0.0f;
|
| 649 | | - *y = 0.0f;
|
| 650 | | - return;
|
| 651 | | - }
|
| 652 | | - else
|
| 653 | | - {
|
| 654 | | - *maskx = 1.0f;
|
| 655 | | - *masky = 1.0f;
|
| 656 | | - // Check for Auto
|
| 657 | | - if (!_tcsicmp(buffer, _T("Auto)")))
|
| 658 | | - {
|
| 659 | | - *x = 0.0f;
|
| 660 | | - *y = 0.0f;
|
| 661 | | - return;
|
| 662 | | - }
|
| 663 | | - else
|
| 664 | | - {
|
| 665 | | - // Check for certain characters
|
| 666 | | - ptr = _tcsstr(buffer, _T("x"));
|
| 667 | | - if (!ptr) ptr = _tcsstr(buffer, _T("X"));
|
| 668 | | - if (!ptr) ptr = _tcsstr(buffer, _T(","));
|
| 669 | | - if (!ptr) ptr = _tcsstr(buffer, _T("-"));
|
| 670 | | - if (!ptr) ptr = _tcsstr(buffer, _T(":"));
|
| 671 | | - if (ptr)
|
| 672 | | - {
|
| 673 | | - *ptr = 0;
|
| 674 | | - *x = _ttof(buffer);
|
| 675 | | - *y = _ttof(ptr + 1);
|
| 676 | | - if ((*x >= 0.25f) && (*y < 0.25f)) *y = *x;
|
| 677 | | - return;
|
| 678 | | - }
|
| 679 | | - else
|
| 680 | | - {
|
| 681 | | - *x = _ttof(buffer);
|
| 682 | | - *y = _ttof(buffer);
|
| 683 | | - return;
|
| 684 | | - }
|
| 685 | | - }
|
| 686 | | - }
|
| 687 | | -}
|
| 688 | | -
|
| 689 | | -float GetAspectCombo(HWND hWnd, int DlgItem, float *mask)
|
| 690 | | -{
|
| 691 | | - TCHAR buffer[32];
|
| 692 | | - TCHAR *ptr;
|
| 693 | | - float numerator, denominator;
|
| 694 | | - GetDlgItemText(hWnd, DlgItem, buffer, 31);
|
| 695 | | - buffer[31] = 0;
|
| 696 | | - if (!_tcscmp(buffer, strdefault))
|
| 697 | | - {
|
| 698 | | - *mask = 0.0f;
|
| 699 | | - return 0.0f;
|
| 700 | | - }
|
| 701 | | - else
|
| 702 | | - {
|
| 703 | | - *mask = 1.0f;
|
| 704 | | - if (!_tcsicmp(buffer, _T("Default"))) return 0.0f;
|
| 705 | | - else
|
| 706 | | - {
|
| 707 | | - // Check for colon
|
| 708 | | - ptr = _tcsstr(buffer, _T(":"));
|
| 709 | | - if (ptr)
|
| 710 | | - {
|
| 711 | | - *ptr = 0;
|
| 712 | | - numerator = (float)_ttof(buffer);
|
| 713 | | - denominator = (float)_ttof(ptr + 1);
|
| 714 | | - return numerator / denominator;
|
| 715 | | - }
|
| 716 | | - else return (float)_ttof(buffer);
|
| 717 | | - }
|
| 718 | | - }
|
| 719 | | -}
|
| 720 | | -
|
| 721 | | -void GetText(HWND hWnd, int DlgItem, TCHAR *str, TCHAR *mask)
|
| 722 | | -{
|
| 723 | | - GetDlgItemText(hWnd,DlgItem,str,MAX_PATH+1);
|
| 724 | | - if(str[0] == 0) mask[0] = 0;
|
| 725 | | - else mask[0] = 0xff;
|
| 726 | | -}
|
| 727 | | -
|
| 728 | | -void DrawCheck(HDC hdc, BOOL selected, BOOL checked, BOOL grayed, BOOL tristate, RECT *r)
|
| 729 | | -{
|
| 730 | | - if (grayed)
|
| 731 | | - {
|
| 732 | | - if (checked)
|
| 733 | | - {
|
| 734 | | - if (hThemeDisplay)
|
| 735 | | - {
|
| 736 | | - if (selected)
|
| 737 | | - _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_CHECKEDHOT, r, NULL);
|
| 738 | | - else _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_CHECKEDDISABLED, r, NULL);
|
| 739 | | - }
|
| 740 | | - else
|
| 741 | | - {
|
| 742 | | - if (selected)
|
| 743 | | - DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_INACTIVE | DFCS_HOT);
|
| 744 | | - else DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_INACTIVE);
|
| 745 | | - }
|
| 746 | | - }
|
| 747 | | - else if (tristate)
|
| 748 | | - {
|
| 749 | | - if (hThemeDisplay)
|
| 750 | | - {
|
| 751 | | - if (selected)
|
| 752 | | - _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_MIXEDHOT, r, NULL);
|
| 753 | | - else _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_MIXEDDISABLED, r, NULL);
|
| 754 | | - }
|
| 755 | | - else
|
| 756 | | - {
|
| 757 | | - if (selected)
|
| 758 | | - DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_INACTIVE | DFCS_HOT);
|
| 759 | | - else DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_INACTIVE);
|
| 760 | | - }
|
| 761 | | - }
|
| 762 | | - else
|
| 763 | | - {
|
| 764 | | - if (hThemeDisplay)
|
| 765 | | - {
|
| 766 | | - if (selected)
|
| 767 | | - _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_UNCHECKEDHOT, r, NULL);
|
| 768 | | - else _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_UNCHECKEDDISABLED, r, NULL);
|
| 769 | | - }
|
| 770 | | - else
|
| 771 | | - {
|
| 772 | | - if (selected)
|
| 773 | | - DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_INACTIVE | DFCS_HOT);
|
| 774 | | - else DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_INACTIVE);
|
| 775 | | - }
|
| 776 | | - }
|
| 777 | | - }
|
| 778 | | - else
|
| 779 | | - {
|
| 780 | | - if (checked)
|
| 781 | | - {
|
| 782 | | - if (hThemeDisplay)
|
| 783 | | - {
|
| 784 | | - if (selected)
|
| 785 | | - _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_CHECKEDHOT, r, NULL);
|
| 786 | | - else _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_CHECKEDNORMAL, r, NULL);
|
| 787 | | - }
|
| 788 | | - else
|
| 789 | | - {
|
| 790 | | - if (selected)
|
| 791 | | - DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_HOT);
|
| 792 | | - else DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_CHECKED);
|
| 793 | | - }
|
| 794 | | - }
|
| 795 | | - else if (tristate)
|
| 796 | | - {
|
| 797 | | - if (hThemeDisplay)
|
| 798 | | - {
|
| 799 | | - if (selected)
|
| 800 | | - _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_MIXEDHOT, r, NULL);
|
| 801 | | - else _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_MIXEDNORMAL, r, NULL);
|
| 802 | | - }
|
| 803 | | - else
|
| 804 | | - {
|
| 805 | | - if (selected)
|
| 806 | | - DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_HOT);
|
| 807 | | - else DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTON3STATE | DFCS_CHECKED);
|
| 808 | | - }
|
| 809 | | - }
|
| 810 | | - else
|
| 811 | | - {
|
| 812 | | - if (hThemeDisplay)
|
| 813 | | - {
|
| 814 | | - if (selected)
|
| 815 | | - _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_UNCHECKEDHOT, r, NULL);
|
| 816 | | - else _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_UNCHECKEDNORMAL, r, NULL);
|
| 817 | | - }
|
| 818 | | - else
|
| 819 | | - {
|
| 820 | | - if (selected)
|
| 821 | | - DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_HOT);
|
| 822 | | - else DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTONCHECK);
|
| 823 | | - }
|
| 824 | | - }
|
| 825 | | - }
|
| 826 | | -}
|
| 827 | | -
|
| 828 | | -LRESULT CALLBACK DisplayTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| 829 | | -{
|
| 830 | | - DRAWITEMSTRUCT* drawitem;
|
| 831 | | - COLORREF OldTextColor, OldBackColor;
|
| 832 | | - RECT r;
|
| 833 | | - TCHAR combotext[64];
|
| 834 | | - DWORD cursel;
|
| 835 | | - HDC hdc;
|
| 836 | | - HFONT font1, font2;
|
| 837 | | - SIZE size;
|
| 838 | | - int i;
|
| 839 | | - switch (Msg)
|
| 840 | | - {
|
| 841 | | - case WM_INITDIALOG:
|
| 842 | | - if (uxtheme) hThemeDisplay = _OpenThemeData(hWnd, L"Button");
|
| 843 | | - else hThemeDisplay = NULL;
|
| 844 | | - if (_EnableThemeDialogTexture) _EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
|
| 845 | | - return TRUE;
|
| 846 | | - case WM_MEASUREITEM:
|
| 847 | | - switch (wParam)
|
| 848 | | - {
|
| 849 | | - case IDC_COLORDEPTH:
|
| 850 | | - case IDC_EXTRAMODES:
|
| 851 | | - if (((LPMEASUREITEMSTRUCT)lParam)->itemID == -1)
|
| 852 | | - {
|
| 853 | | - hdc = GetDC(hWnd);
|
| 854 | | - font1 = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0);
|
| 855 | | - font2 = SelectObject(hdc, font1);
|
| 856 | | - GetTextExtentPoint(hdc, _T(" "), 1, &size);
|
| 857 | | - SelectObject(hdc, font2);
|
| 858 | | - ReleaseDC(hWnd, hdc);
|
| 859 | | - ((LPMEASUREITEMSTRUCT)lParam)->itemHeight = size.cy + 2;
|
| 860 | | - }
|
| 861 | | - else
|
| 862 | | - {
|
| 863 | | - ((LPMEASUREITEMSTRUCT)lParam)->itemHeight = GetSystemMetrics(SM_CYMENUCHECK);
|
| 864 | | - ((LPMEASUREITEMSTRUCT)lParam)->itemWidth = GetSystemMetrics(SM_CXMENUCHECK);
|
| 865 | | - }
|
| 866 | | - break;
|
| 867 | | - default:
|
| 868 | | - break;
|
| 869 | | - }
|
| 870 | | - case WM_DRAWITEM:
|
| 871 | | - drawitem = (DRAWITEMSTRUCT*)lParam;
|
| 872 | | - switch (wParam)
|
| 873 | | - {
|
| 874 | | - case IDC_COLORDEPTH:
|
| 875 | | - OldTextColor = GetTextColor(drawitem->hDC);
|
| 876 | | - OldBackColor = GetBkColor(drawitem->hDC);
|
| 877 | | - if ((drawitem->itemState & ODS_SELECTED) && !(drawitem->itemState & ODS_COMBOBOXEDIT))
|
| 878 | | - {
|
| 879 | | - SetTextColor(drawitem->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
| 880 | | - SetBkColor(drawitem->hDC, GetSysColor(COLOR_HIGHLIGHT));
|
| 881 | | - FillRect(drawitem->hDC, &drawitem->rcItem, (HBRUSH)(COLOR_HIGHLIGHT + 1));
|
| 882 | | - }
|
| 883 | | - else ExtTextOut(drawitem->hDC, 0, 0, ETO_OPAQUE, &drawitem->rcItem, NULL, 0, NULL);
|
| 884 | | - memcpy(&r, &drawitem->rcItem, sizeof(RECT));
|
| 885 | | - if (drawitem->itemID != -1 && !(drawitem->itemState & ODS_COMBOBOXEDIT))
|
| 886 | | - {
|
| 887 | | - r.left = r.left + 2;
|
| 888 | | - r.right = r.left + GetSystemMetrics(SM_CXMENUCHECK);
|
| 889 | | - if (drawitem->itemID == 5)
|
| 890 | | - {
|
| 891 | | - if(!cfgmask->AddColorDepths)
|
| 892 | | - DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, TRUE, FALSE, FALSE, &r);
|
| 893 | | - else DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, FALSE, FALSE, FALSE, &r);
|
| 894 | | - }
|
| 895 | | - else
|
| 896 | | - {
|
| 897 | | - if ((cfg->AddColorDepths >> drawitem->itemID) & 1)
|
| 898 | | - DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, TRUE, !cfgmask->AddColorDepths, FALSE, &r);
|
| 899 | | - else DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, FALSE, !cfgmask->AddColorDepths, FALSE, &r);
|
| 900 | | - }
|
| 901 | | - drawitem->rcItem.left += GetSystemMetrics(SM_CXMENUCHECK) + 5;
|
| 902 | | - }
|
| 903 | | - combotext[0] = 0;
|
| 904 | | - if (drawitem->itemID != -1 && !(drawitem->itemState & ODS_COMBOBOXEDIT))
|
| 905 | | - SendDlgItemMessage(hWnd, IDC_COLORDEPTH, CB_GETLBTEXT, drawitem->itemID, combotext);
|
| 906 | | - else
|
| 907 | | - {
|
| 908 | | - if(!cfgmask->AddColorDepths) _tcscpy(combotext, strdefault);
|
| 909 | | - else _tcscpy(combotext, colormodes[cfg->AddColorDepths & 31]);
|
| 910 | | - }
|
| 911 | | - DrawText(drawitem->hDC, combotext, _tcslen(combotext), &drawitem->rcItem,
|
| 912 | | - DT_LEFT | DT_SINGLELINE | DT_VCENTER);
|
| 913 | | - SetTextColor(drawitem->hDC, OldTextColor);
|
| 914 | | - SetBkColor(drawitem->hDC, OldBackColor);
|
| 915 | | - if (drawitem->itemID != -1 && !(drawitem->itemState & ODS_COMBOBOXEDIT))
|
| 916 | | - drawitem->rcItem.left -= GetSystemMetrics(SM_CXMENUCHECK) + 5;
|
| 917 | | - if (drawitem->itemState & ODS_FOCUS) DrawFocusRect(drawitem->hDC, &drawitem->rcItem);
|
| 918 | | - DefWindowProc(hWnd, Msg, wParam, lParam);
|
| 919 | | - break;
|
| 920 | | - case IDC_EXTRAMODES:
|
| 921 | | - OldTextColor = GetTextColor(drawitem->hDC);
|
| 922 | | - OldBackColor = GetBkColor(drawitem->hDC);
|
| 923 | | - if ((drawitem->itemState & ODS_SELECTED) && !(drawitem->itemState & ODS_COMBOBOXEDIT))
|
| 924 | | - {
|
| 925 | | - SetTextColor(drawitem->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
| 926 | | - SetBkColor(drawitem->hDC, GetSysColor(COLOR_HIGHLIGHT));
|
| 927 | | - FillRect(drawitem->hDC, &drawitem->rcItem, (HBRUSH)(COLOR_HIGHLIGHT + 1));
|
| 928 | | - }
|
| 929 | | - else ExtTextOut(drawitem->hDC, 0, 0, ETO_OPAQUE, &drawitem->rcItem, NULL, 0, NULL);
|
| 930 | | - memcpy(&r, &drawitem->rcItem, sizeof(RECT));
|
| 931 | | - if (drawitem->itemID != -1 && !(drawitem->itemState & ODS_COMBOBOXEDIT))
|
| 932 | | - {
|
| 933 | | - r.left = r.left + 2;
|
| 934 | | - r.right = r.left + GetSystemMetrics(SM_CXMENUCHECK);
|
| 935 | | - if (drawitem->itemID == 7)
|
| 936 | | - {
|
| 937 | | - if (!cfgmask->AddModes)
|
| 938 | | - DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, TRUE, FALSE, FALSE, &r);
|
| 939 | | - else DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, FALSE, FALSE, FALSE, &r);
|
| 940 | | - }
|
| 941 | | - else
|
| 942 | | - {
|
| 943 | | - if ((cfg->AddModes >> drawitem->itemID) & 1)
|
| 944 | | - DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, TRUE, !cfgmask->AddModes, FALSE, &r);
|
| 945 | | - else DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, FALSE, !cfgmask->AddModes, FALSE, &r);
|
| 946 | | - }
|
| 947 | | - drawitem->rcItem.left += GetSystemMetrics(SM_CXMENUCHECK) + 5;
|
| 948 | | - }
|
| 949 | | - combotext[0] = 0;
|
| 950 | | - if (drawitem->itemID != -1 && !(drawitem->itemState & ODS_COMBOBOXEDIT))
|
| 951 | | - SendDlgItemMessage(hWnd, IDC_EXTRAMODES, CB_GETLBTEXT, drawitem->itemID, combotext);
|
| 952 | | - else
|
| 953 | | - {
|
| 954 | | - if (!cfgmask->AddModes) _tcscpy(combotext, strdefault);
|
| 955 | | - else
|
| 956 | | - {
|
| 957 | | - switch (cfg->AddModes)
|
| 958 | | - {
|
| 959 | | - case 0:
|
| 960 | | - _tcscpy(combotext, _T("None"));
|
| 961 | | - break;
|
| 962 | | - case 1:
|
| 963 | | - _tcscpy(combotext, extramodes[0]);
|
| 964 | | - break;
|
| 965 | | - case 2:
|
| 966 | | - _tcscpy(combotext, extramodes[1]);
|
| 967 | | - break;
|
| 968 | | - case 4:
|
| 969 | | - _tcscpy(combotext, extramodes[2]);
|
| 970 | | - break;
|
| 971 | | - case 8:
|
| 972 | | - _tcscpy(combotext, extramodes[3]);
|
| 973 | | - break;
|
| 974 | | - case 16:
|
| 975 | | - _tcscpy(combotext, extramodes[4]);
|
| 976 | | - break;
|
| 977 | | - case 32:
|
| 978 | | - _tcscpy(combotext, extramodes[5]);
|
| 979 | | - break;
|
| 980 | | - case 64:
|
| 981 | | - _tcscpy(combotext, extramodes[6]);
|
| 982 | | - break;
|
| 983 | | - default:
|
| 984 | | - _tcscpy(combotext, _T("Multiple selections"));
|
| 985 | | - }
|
| 986 | | - }
|
| 987 | | - }
|
| 988 | | - DrawText(drawitem->hDC, combotext, _tcslen(combotext), &drawitem->rcItem,
|
| 989 | | - DT_LEFT | DT_SINGLELINE | DT_VCENTER);
|
| 990 | | - SetTextColor(drawitem->hDC, OldTextColor);
|
| 991 | | - SetBkColor(drawitem->hDC, OldBackColor);
|
| 992 | | - if (drawitem->itemID != -1 && !(drawitem->itemState & ODS_COMBOBOXEDIT))
|
| 993 | | - drawitem->rcItem.left -= GetSystemMetrics(SM_CXMENUCHECK) + 5;
|
| 994 | | - if (drawitem->itemState & ODS_FOCUS) DrawFocusRect(drawitem->hDC, &drawitem->rcItem);
|
| 995 | | - DefWindowProc(hWnd, Msg, wParam, lParam);
|
| 996 | | - break;
|
| 997 | | - default:
|
| 998 | | - break;
|
| 999 | | - }
|
| 1000 | | - case WM_THEMECHANGED:
|
| 1001 | | - if (uxtheme)
|
| 1002 | | - {
|
| 1003 | | - if (hThemeDisplay) _CloseThemeData(hThemeDisplay);
|
| 1004 | | - _OpenThemeData(hWnd, L"Button");
|
| 1005 | | - }
|
| 1006 | | - case WM_COMMAND:
|
| 1007 | | - {
|
| 1008 | | - switch (LOWORD(wParam))
|
| 1009 | | - {
|
| 1010 | | - case IDC_COLORDEPTH:
|
| 1011 | | - if (HIWORD(wParam) == CBN_SELENDOK)
|
| 1012 | | - {
|
| 1013 | | - if (ColorDepth_Dropdown)
|
| 1014 | | - {
|
| 1015 | | - cursel = SendDlgItemMessage(hWnd, IDC_COLORDEPTH, CB_GETCURSEL, 0, 0);
|
| 1016 | | - if (cursel == 5)
|
| 1017 | | - {
|
| 1018 | | - if (cfgmask->AddColorDepths) cfgmask->AddColorDepths = 0;
|
| 1019 | | - else cfgmask->AddColorDepths = 1;
|
| 1020 | | - }
|
| 1021 | | - else
|
| 1022 | | - {
|
| 1023 | | - if (!cfgmask->AddColorDepths) cfgmask->AddColorDepths = 1;
|
| 1024 | | - i = ((cfg->AddColorDepths >> cursel) & 1);
|
| 1025 | | - if (i) cfg->AddColorDepths &= ~(1 << cursel);
|
| 1026 | | - else cfg->AddColorDepths |= 1 << cursel;
|
| 1027 | | - }
|
| 1028 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1029 | | - *dirty = TRUE;
|
| 1030 | | - }
|
| 1031 | | - }
|
| 1032 | | - if (HIWORD(wParam) == CBN_DROPDOWN)
|
| 1033 | | - {
|
| 1034 | | - ColorDepth_Dropdown = TRUE;
|
| 1035 | | - }
|
| 1036 | | - if (HIWORD(wParam) == CBN_CLOSEUP)
|
| 1037 | | - {
|
| 1038 | | - ColorDepth_Dropdown = FALSE;
|
| 1039 | | - }
|
| 1040 | | - break;
|
| 1041 | | - case IDC_EXTRAMODES:
|
| 1042 | | - if (HIWORD(wParam) == CBN_SELENDOK)
|
| 1043 | | - {
|
| 1044 | | - if (ExtraModes_Dropdown)
|
| 1045 | | - {
|
| 1046 | | - cursel = SendDlgItemMessage(hWnd, IDC_EXTRAMODES, CB_GETCURSEL, 0, 0);
|
| 1047 | | - if (cursel == 7)
|
| 1048 | | - {
|
| 1049 | | - if (cfgmask->AddModes) cfgmask->AddModes = 0;
|
| 1050 | | - else cfgmask->AddModes = 1;
|
| 1051 | | - }
|
| 1052 | | - else
|
| 1053 | | - {
|
| 1054 | | - if (!cfgmask->AddModes) cfgmask->AddModes = 1;
|
| 1055 | | - i = ((cfg->AddModes >> cursel) & 1);
|
| 1056 | | - if (i) cfg->AddModes &= ~(1 << cursel);
|
| 1057 | | - else cfg->AddModes |= 1 << cursel;
|
| 1058 | | - }
|
| 1059 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1060 | | - *dirty = TRUE;
|
| 1061 | | - }
|
| 1062 | | - }
|
| 1063 | | - if (HIWORD(wParam) == CBN_DROPDOWN)
|
| 1064 | | - {
|
| 1065 | | - ExtraModes_Dropdown = TRUE;
|
| 1066 | | - }
|
| 1067 | | - if (HIWORD(wParam) == CBN_CLOSEUP)
|
| 1068 | | - {
|
| 1069 | | - ExtraModes_Dropdown = FALSE;
|
| 1070 | | - }
|
| 1071 | | - break;
|
| 1072 | | - case IDC_VIDMODE:
|
| 1073 | | - cfg->scaler = GetCombo(hWnd, IDC_VIDMODE, &cfgmask->scaler);
|
| 1074 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1075 | | - *dirty = TRUE;
|
| 1076 | | - break;
|
| 1077 | | - case IDC_SCALE:
|
| 1078 | | - cfg->scalingfilter = GetCombo(hWnd, IDC_SCALE, &cfgmask->scalingfilter);
|
| 1079 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1080 | | - *dirty = TRUE;
|
| 1081 | | - break;
|
| 1082 | | - case IDC_ASPECT:
|
| 1083 | | - if (HIWORD(wParam) == CBN_KILLFOCUS)
|
| 1084 | | - {
|
| 1085 | | - cfg->aspect = GetAspectCombo(hWnd, IDC_ASPECT, &cfgmask->aspect);
|
| 1086 | | - SetAspectCombo(hWnd, IDC_ASPECT, cfg->aspect, cfgmask->aspect, tristate);
|
| 1087 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1088 | | - *dirty = TRUE;
|
| 1089 | | - }
|
| 1090 | | - else if (HIWORD(wParam) == CBN_SELCHANGE)
|
| 1091 | | - {
|
| 1092 | | - cfg->aspect = GetAspectCombo(hWnd, IDC_ASPECT, &cfgmask->aspect);
|
| 1093 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1094 | | - *dirty = TRUE;
|
| 1095 | | - }
|
| 1096 | | - break;
|
| 1097 | | - case IDC_SORTMODES:
|
| 1098 | | - cfg->SortModes = GetCombo(hWnd, IDC_SORTMODES, &cfgmask->SortModes);
|
| 1099 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1100 | | - *dirty = TRUE;
|
| 1101 | | - break;
|
| 1102 | | - case IDC_DPISCALE:
|
| 1103 | | - cfg->DPIScale = GetCombo(hWnd, IDC_DPISCALE, &cfgmask->DPIScale);
|
| 1104 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1105 | | - *dirty = TRUE;
|
| 1106 | | - break;
|
| 1107 | | - case IDC_VSYNC:
|
| 1108 | | - cfg->vsync = GetCombo(hWnd, IDC_VSYNC, &cfgmask->vsync);
|
| 1109 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1110 | | - *dirty = TRUE;
|
| 1111 | | - break;
|
| 1112 | | - case IDC_FULLMODE:
|
| 1113 | | - cfg->fullmode = GetCombo(hWnd, IDC_FULLMODE, &cfgmask->fullmode);
|
| 1114 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1115 | | - *dirty = TRUE;
|
| 1116 | | - break;
|
| 1117 | | - case IDC_COLOR:
|
| 1118 | | - cfg->colormode = GetCheck(hWnd, IDC_COLOR, &cfgmask->colormode);
|
| 1119 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1120 | | - *dirty = TRUE;
|
| 1121 | | - break;
|
| 1122 | | - case IDC_SINGLEBUFFER:
|
| 1123 | | - cfg->SingleBufferDevice = GetCheck(hWnd, IDC_SINGLEBUFFER, &cfgmask->SingleBufferDevice);
|
| 1124 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1125 | | - *dirty = TRUE;
|
| 1126 | | - break;
|
| 1127 | | - default:
|
| 1128 | | - break;
|
| 1129 | | - }
|
| 1130 | | - }
|
| 1131 | | - default:
|
| 1132 | | - return FALSE;
|
| 1133 | | - }
|
| 1134 | | - return TRUE;
|
| 1135 | | -}
|
| 1136 | | -
|
| 1137 | | -LRESULT CALLBACK EffectsTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| 1138 | | -{
|
| 1139 | | - switch (Msg)
|
| 1140 | | - {
|
| 1141 | | - case WM_INITDIALOG:
|
| 1142 | | - if (_EnableThemeDialogTexture) _EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
|
| 1143 | | - return TRUE;
|
| 1144 | | - case WM_COMMAND:
|
| 1145 | | - switch (LOWORD(wParam))
|
| 1146 | | - {
|
| 1147 | | - case IDC_POSTSCALE:
|
| 1148 | | - cfg->postfilter = GetCombo(hWnd, IDC_POSTSCALE, &cfgmask->postfilter);
|
| 1149 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1150 | | - *dirty = TRUE;
|
| 1151 | | - break;
|
| 1152 | | - case IDC_POSTSCALESIZE:
|
| 1153 | | - if (HIWORD(wParam) == CBN_KILLFOCUS)
|
| 1154 | | - {
|
| 1155 | | - GetPostScaleCombo(hWnd, IDC_POSTSCALESIZE, &cfg->postsizex, &cfg->postsizey,
|
| 1156 | | - &cfgmask->postsizex, &cfgmask->postsizey);
|
| 1157 | | - SetPostScaleCombo(hWnd, IDC_POSTSCALESIZE, cfg->postsizex, cfg->postsizey,
|
| 1158 | | - cfgmask->postsizex, cfgmask->postsizey, tristate);
|
| 1159 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1160 | | - *dirty = TRUE;
|
| 1161 | | - }
|
| 1162 | | - else if (HIWORD(wParam) == CBN_SELCHANGE)
|
| 1163 | | - {
|
| 1164 | | - GetPostScaleCombo(hWnd, IDC_POSTSCALESIZE, &cfg->postsizex, &cfg->postsizey,
|
| 1165 | | - &cfgmask->postsizex, &cfgmask->postsizey);
|
| 1166 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1167 | | - *dirty = TRUE;
|
| 1168 | | - }
|
| 1169 | | - break;
|
| 1170 | | - case IDC_PRIMARYSCALE:
|
| 1171 | | - cfg->primaryscale = GetCombo(hWnd, IDC_PRIMARYSCALE, &cfgmask->primaryscale);
|
| 1172 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1173 | | - *dirty = TRUE;
|
| 1174 | | - break;
|
| 1175 | | - case IDC_SHADER:
|
| 1176 | | - if (HIWORD(wParam) == EN_CHANGE)
|
| 1177 | | - {
|
| 1178 | | - GetText(hWnd, IDC_SHADER, cfg->shaderfile, cfgmask->shaderfile);
|
| 1179 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1180 | | - *dirty = TRUE;
|
| 1181 | | - }
|
| 1182 | | - break;
|
| 1183 | | - default:
|
| 1184 | | - break;
|
| 1185 | | - }
|
| 1186 | | - default:
|
| 1187 | | - return FALSE;
|
| 1188 | | - }
|
| 1189 | | - return TRUE;
|
| 1190 | | -}
|
| 1191 | | -
|
| 1192 | | -LRESULT CALLBACK Tab3DCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| 1193 | | -{
|
| 1194 | | - switch (Msg)
|
| 1195 | | - {
|
| 1196 | | - case WM_INITDIALOG:
|
| 1197 | | - if (_EnableThemeDialogTexture) _EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
|
| 1198 | | - return TRUE;
|
| 1199 | | - case WM_COMMAND:
|
| 1200 | | - switch (LOWORD(wParam))
|
| 1201 | | - {
|
| 1202 | | - case IDC_TEXFILTER:
|
| 1203 | | - cfg->texfilter = GetCombo(hWnd, IDC_TEXFILTER, &cfgmask->texfilter);
|
| 1204 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1205 | | - *dirty = TRUE;
|
| 1206 | | - break;
|
| 1207 | | - case IDC_ANISO:
|
| 1208 | | - cfg->anisotropic = GetCombo(hWnd, IDC_ANISO, &cfgmask->anisotropic);
|
| 1209 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1210 | | - *dirty = TRUE;
|
| 1211 | | - break;
|
| 1212 | | - case IDC_MSAA:
|
| 1213 | | - cfg->msaa = GetCombo(hWnd, IDC_MSAA, &cfgmask->msaa);
|
| 1214 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1215 | | - *dirty = TRUE;
|
| 1216 | | - break;
|
| 1217 | | - case IDC_ASPECT3D:
|
| 1218 | | - cfg->aspect3d = GetCombo(hWnd, IDC_ASPECT3D, &cfgmask->aspect3d);
|
| 1219 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1220 | | - *dirty = TRUE;
|
| 1221 | | - break;
|
| 1222 | | - default:
|
| 1223 | | - break;
|
| 1224 | | - }
|
| 1225 | | - default:
|
| 1226 | | - return FALSE;
|
| 1227 | | - }
|
| 1228 | | - return TRUE;
|
| 1229 | | -}
|
| 1230 | | -
|
| 1231 | | -LRESULT CALLBACK AdvancedTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| 1232 | | -{
|
| 1233 | | - switch (Msg)
|
| 1234 | | - {
|
| 1235 | | - case WM_INITDIALOG:
|
| 1236 | | - if (_EnableThemeDialogTexture) _EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
|
| 1237 | | - return TRUE;
|
| 1238 | | - case WM_COMMAND:
|
| 1239 | | - switch (LOWORD(wParam))
|
| 1240 | | - {
|
| 1241 | | - case IDC_TEXTUREFORMAT:
|
| 1242 | | - cfg->TextureFormat = GetCombo(hWnd, IDC_TEXTUREFORMAT, &cfgmask->TextureFormat);
|
| 1243 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1244 | | - *dirty = TRUE;
|
| 1245 | | - break;
|
| 1246 | | - case IDC_TEXUPLOAD:
|
| 1247 | | - cfg->TexUpload = GetCombo(hWnd, IDC_TEXUPLOAD, &cfgmask->TexUpload);
|
| 1248 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1249 | | - *dirty = TRUE;
|
| 1250 | | - break;
|
| 1251 | | - default:
|
| 1252 | | - break;
|
| 1253 | | - }
|
| 1254 | | - default:
|
| 1255 | | - return FALSE;
|
| 1256 | | - }
|
| 1257 | | - return TRUE;
|
| 1258 | | -}
|
| 1259 | | -
|
| 1260 | | -void ReadDebugItem(int item, BOOL *value, BOOL *mask)
|
| 1261 | | -{
|
| 1262 | | - switch (item)
|
| 1263 | | - {
|
| 1264 | | - case 0:
|
| 1265 | | - *value = cfg->DebugNoExtFramebuffer;
|
| 1266 | | - *mask = cfgmask->DebugNoExtFramebuffer;
|
| 1267 | | - break;
|
| 1268 | | - case 1:
|
| 1269 | | - *value = cfg->DebugNoArbFramebuffer;
|
| 1270 | | - *mask = cfgmask->DebugNoArbFramebuffer;
|
| 1271 | | - break;
|
| 1272 | | - case 2:
|
| 1273 | | - *value = cfg->DebugNoES2Compatibility;
|
| 1274 | | - *mask = cfgmask->DebugNoES2Compatibility;
|
| 1275 | | - break;
|
| 1276 | | - case 3:
|
| 1277 | | - *value = cfg->DebugNoExtDirectStateAccess;
|
| 1278 | | - *mask = cfgmask->DebugNoExtDirectStateAccess;
|
| 1279 | | - break;
|
| 1280 | | - case 4:
|
| 1281 | | - *value = cfg->DebugNoArbDirectStateAccess;
|
| 1282 | | - *mask = cfgmask->DebugNoArbDirectStateAccess;
|
| 1283 | | - break;
|
| 1284 | | - case 5:
|
| 1285 | | - *value = cfg->DebugNoSamplerObjects;
|
| 1286 | | - *mask = cfgmask->DebugNoSamplerObjects;
|
| 1287 | | - break;
|
| 1288 | | - case 6:
|
| 1289 | | - *value = cfg->DebugNoGpuShader4;
|
| 1290 | | - *mask = cfgmask->DebugNoGpuShader4;
|
| 1291 | | - break;
|
| 1292 | | - case 7:
|
| 1293 | | - *value = cfg->DebugNoGLSL130;
|
| 1294 | | - *mask = cfgmask->DebugNoGLSL130;
|
| 1295 | | - break;
|
| 1296 | | - /*case 8:
|
| 1297 | | - *value = cfg->DebugDisableErrors;
|
| 1298 | | - *mask = cfgmask->DebugDisableErrors;
|
| 1299 | | - break;*/
|
| 1300 | | - default:
|
| 1301 | | - *value = FALSE;
|
| 1302 | | - *mask = FALSE;
|
| 1303 | | - break;
|
| 1304 | | - }
|
| 1305 | | -}
|
| 1306 | | -
|
| 1307 | | -void WriteDebugItem(int item, BOOL value, BOOL mask)
|
| 1308 | | -{
|
| 1309 | | - switch (item)
|
| 1310 | | - {
|
| 1311 | | - case 0:
|
| 1312 | | - cfg->DebugNoExtFramebuffer = value;
|
| 1313 | | - cfgmask->DebugNoExtFramebuffer = mask;
|
| 1314 | | - break;
|
| 1315 | | - case 1:
|
| 1316 | | - cfg->DebugNoArbFramebuffer = value;
|
| 1317 | | - cfgmask->DebugNoArbFramebuffer = mask;
|
| 1318 | | - break;
|
| 1319 | | - case 2:
|
| 1320 | | - cfg->DebugNoES2Compatibility = value;
|
| 1321 | | - cfgmask->DebugNoES2Compatibility = mask;
|
| 1322 | | - break;
|
| 1323 | | - case 3:
|
| 1324 | | - cfg->DebugNoExtDirectStateAccess = value;
|
| 1325 | | - cfgmask->DebugNoExtDirectStateAccess = mask;
|
| 1326 | | - break;
|
| 1327 | | - case 4:
|
| 1328 | | - cfg->DebugNoArbDirectStateAccess = value;
|
| 1329 | | - cfgmask->DebugNoArbDirectStateAccess = mask;
|
| 1330 | | - break;
|
| 1331 | | - case 5:
|
| 1332 | | - cfg->DebugNoSamplerObjects = value;
|
| 1333 | | - cfgmask->DebugNoSamplerObjects = mask;
|
| 1334 | | - break;
|
| 1335 | | - case 6:
|
| 1336 | | - cfg->DebugNoGpuShader4 = value;
|
| 1337 | | - cfgmask->DebugNoGpuShader4 = mask;
|
| 1338 | | - break;
|
| 1339 | | - case 7:
|
| 1340 | | - cfg->DebugNoGLSL130 = value;
|
| 1341 | | - cfgmask->DebugNoGLSL130 = mask;
|
| 1342 | | - break;
|
| 1343 | | - /*case 8:
|
| 1344 | | - cfg->DebugDisableErrors = value;
|
| 1345 | | - cfgmask->DebugDisableErrors = mask;
|
| 1346 | | - break;*/
|
| 1347 | | - default:
|
| 1348 | | - break;
|
| 1349 | | - }
|
| 1350 | | -}
|
| 1351 | | -
|
| 1352 | | -LRESULT CALLBACK DebugTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| 1353 | | -{
|
| 1354 | | - TCHAR str[64];
|
| 1355 | | - RECT r;
|
| 1356 | | - DRAWITEMSTRUCT* drawitem;
|
| 1357 | | - COLORREF OldTextColor, OldBackColor;
|
| 1358 | | - BOOL debugvalue, debugmask;
|
| 1359 | | - DWORD item;
|
| 1360 | | - switch (Msg)
|
| 1361 | | - {
|
| 1362 | | - case WM_INITDIALOG:
|
| 1363 | | - if (_EnableThemeDialogTexture) _EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
|
| 1364 | | - return TRUE;
|
| 1365 | | - case WM_MEASUREITEM:
|
| 1366 | | - switch (wParam)
|
| 1367 | | - {
|
| 1368 | | - case IDC_DEBUGLIST:
|
| 1369 | | - ((LPMEASUREITEMSTRUCT)lParam)->itemHeight = GetSystemMetrics(SM_CYMENUCHECK);
|
| 1370 | | - ((LPMEASUREITEMSTRUCT)lParam)->itemWidth = GetSystemMetrics(SM_CXMENUCHECK);
|
| 1371 | | - break;
|
| 1372 | | - default:
|
| 1373 | | - break;
|
| 1374 | | - }
|
| 1375 | | - break;
|
| 1376 | | - case WM_COMMAND:
|
| 1377 | | - switch (LOWORD(wParam))
|
| 1378 | | - {
|
| 1379 | | - case IDC_DEBUGLIST:
|
| 1380 | | - if ((HIWORD(wParam) == LBN_SELCHANGE) || (HIWORD(wParam) == LBN_DBLCLK))
|
| 1381 | | - {
|
| 1382 | | - item = SendDlgItemMessage(hWnd, IDC_DEBUGLIST, LB_GETCURSEL, 0, 0);
|
| 1383 | | - ReadDebugItem(item, &debugvalue, &debugmask);
|
| 1384 | | - if (tristate)
|
| 1385 | | - {
|
| 1386 | | - if (debugvalue && debugmask)
|
| 1387 | | - {
|
| 1388 | | - debugvalue = FALSE;
|
| 1389 | | - debugmask = FALSE;
|
| 1390 | | - }
|
| 1391 | | - else if (!debugmask)
|
| 1392 | | - {
|
| 1393 | | - debugvalue = FALSE;
|
| 1394 | | - debugmask = TRUE;
|
| 1395 | | - }
|
| 1396 | | - else
|
| 1397 | | - {
|
| 1398 | | - debugvalue = TRUE;
|
| 1399 | | - debugmask = TRUE;
|
| 1400 | | - }
|
| 1401 | | - }
|
| 1402 | | - else
|
| 1403 | | - {
|
| 1404 | | - if (debugvalue)
|
| 1405 | | - debugvalue = FALSE;
|
| 1406 | | - else debugvalue = TRUE;
|
| 1407 | | - }
|
| 1408 | | - WriteDebugItem(item, debugvalue, debugmask);
|
| 1409 | | - RedrawWindow(GetDlgItem(hWnd, IDC_DEBUGLIST), NULL, NULL, RDW_INVALIDATE);
|
| 1410 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1411 | | - *dirty = TRUE;
|
| 1412 | | - }
|
| 1413 | | - break;
|
| 1414 | | - default:
|
| 1415 | | - break;
|
| 1416 | | - }
|
| 1417 | | - case WM_DRAWITEM:
|
| 1418 | | - drawitem = (DRAWITEMSTRUCT*)lParam;
|
| 1419 | | - switch (wParam)
|
| 1420 | | - {
|
| 1421 | | - case IDC_DEBUGLIST:
|
| 1422 | | - OldTextColor = GetTextColor(drawitem->hDC);
|
| 1423 | | - OldBackColor = GetBkColor(drawitem->hDC);
|
| 1424 | | - if((drawitem->itemState & ODS_SELECTED))
|
| 1425 | | - {
|
| 1426 | | - SetTextColor(drawitem->hDC,GetSysColor(COLOR_HIGHLIGHTTEXT));
|
| 1427 | | - SetBkColor(drawitem->hDC,GetSysColor(COLOR_HIGHLIGHT));
|
| 1428 | | - FillRect(drawitem->hDC,&drawitem->rcItem,(HBRUSH)(COLOR_HIGHLIGHT+1));
|
| 1429 | | - }
|
| 1430 | | - else
|
| 1431 | | - {
|
| 1432 | | - SetTextColor(drawitem->hDC, GetSysColor(COLOR_WINDOWTEXT));
|
| 1433 | | - SetBkColor(drawitem->hDC, GetSysColor(COLOR_WINDOW));
|
| 1434 | | - FillRect(drawitem->hDC, &drawitem->rcItem, (HBRUSH)(COLOR_WINDOW + 1));
|
| 1435 | | - }
|
| 1436 | | - memcpy(&r, &drawitem->rcItem, sizeof(RECT));
|
| 1437 | | - r.left = r.left + 2;
|
| 1438 | | - r.right = r.left + GetSystemMetrics(SM_CXMENUCHECK);
|
| 1439 | | - ReadDebugItem(drawitem->itemID, &debugvalue, &debugmask);
|
| 1440 | | - DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, debugvalue, FALSE, !debugmask, &r);
|
| 1441 | | - drawitem->rcItem.left += GetSystemMetrics(SM_CXSMICON)+5;
|
| 1442 | | - SendDlgItemMessage(hWnd, IDC_DEBUGLIST, LB_GETTEXT, drawitem->itemID, (LPARAM)str);
|
| 1443 | | - DrawText(drawitem->hDC, str, _tcslen(str), &drawitem->rcItem,
|
| 1444 | | - DT_LEFT | DT_SINGLELINE | DT_VCENTER);
|
| 1445 | | - drawitem->rcItem.left -= GetSystemMetrics(SM_CXSMICON)+5;
|
| 1446 | | - if (drawitem->itemState & ODS_FOCUS) DrawFocusRect(drawitem->hDC, &drawitem->rcItem);
|
| 1447 | | - SetTextColor(drawitem->hDC,OldTextColor);
|
| 1448 | | - SetBkColor(drawitem->hDC,OldBackColor);
|
| 1449 | | - DefWindowProc(hWnd,Msg,wParam,lParam);
|
| 1450 | | - break;
|
| 1451 | | - default:
|
| 1452 | | - break;
|
| 1453 | | - }
|
| 1454 | | - break;
|
| 1455 | | - default:
|
| 1456 | | - return FALSE;
|
| 1457 | | - }
|
| 1458 | | - return TRUE;
|
| 1459 | | -}
|
| 1460 | | -
|
| 1461 | | -void ReadHacksItem(int item, BOOL *value, BOOL *mask)
|
| 1462 | | -{
|
| 1463 | | - switch (item)
|
| 1464 | | - {
|
| 1465 | | - default:
|
| 1466 | | - *value = FALSE;
|
| 1467 | | - *mask = FALSE;
|
| 1468 | | - break;
|
| 1469 | | - }
|
| 1470 | | -}
|
| 1471 | | -
|
| 1472 | | -void WriteHacksItem(int item, BOOL value, BOOL mask)
|
| 1473 | | -{
|
| 1474 | | - switch (item)
|
| 1475 | | - {
|
| 1476 | | - default:
|
| 1477 | | - break;
|
| 1478 | | - }
|
| 1479 | | -}
|
| 1480 | | -
|
| 1481 | | -LRESULT CALLBACK HacksTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| 1482 | | -{
|
| 1483 | | - TCHAR str[64];
|
| 1484 | | - RECT r;
|
| 1485 | | - DRAWITEMSTRUCT* drawitem;
|
| 1486 | | - COLORREF OldTextColor, OldBackColor;
|
| 1487 | | - BOOL hackvalue, hackmask;
|
| 1488 | | - DWORD item;
|
| 1489 | | - switch (Msg)
|
| 1490 | | - {
|
| 1491 | | - case WM_INITDIALOG:
|
| 1492 | | - if (_EnableThemeDialogTexture) _EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
|
| 1493 | | - return TRUE;
|
| 1494 | | - case WM_MEASUREITEM:
|
| 1495 | | - switch (wParam)
|
| 1496 | | - {
|
| 1497 | | - case IDC_HACKSLIST:
|
| 1498 | | - ((LPMEASUREITEMSTRUCT)lParam)->itemHeight = GetSystemMetrics(SM_CYMENUCHECK);
|
| 1499 | | - ((LPMEASUREITEMSTRUCT)lParam)->itemWidth = GetSystemMetrics(SM_CXMENUCHECK);
|
| 1500 | | - break;
|
| 1501 | | - default:
|
| 1502 | | - break;
|
| 1503 | | - }
|
| 1504 | | - break;
|
| 1505 | | - case WM_COMMAND:
|
| 1506 | | - switch (LOWORD(wParam))
|
| 1507 | | - {
|
| 1508 | | - case IDC_HACKSLIST:
|
| 1509 | | - if ((HIWORD(wParam) == LBN_SELCHANGE) || (HIWORD(wParam) == LBN_DBLCLK))
|
| 1510 | | - {
|
| 1511 | | - item = SendDlgItemMessage(hWnd, IDC_HACKSLIST, LB_GETCURSEL, 0, 0);
|
| 1512 | | - ReadHacksItem(item, &hackvalue, &hackmask);
|
| 1513 | | - if (tristate)
|
| 1514 | | - {
|
| 1515 | | - if (hackvalue && hackmask)
|
| 1516 | | - {
|
| 1517 | | - hackvalue = FALSE;
|
| 1518 | | - hackmask = FALSE;
|
| 1519 | | - }
|
| 1520 | | - else if (!hackmask)
|
| 1521 | | - {
|
| 1522 | | - hackvalue = FALSE;
|
| 1523 | | - hackmask = TRUE;
|
| 1524 | | - }
|
| 1525 | | - else
|
| 1526 | | - {
|
| 1527 | | - hackvalue = TRUE;
|
| 1528 | | - hackmask = TRUE;
|
| 1529 | | - }
|
| 1530 | | - }
|
| 1531 | | - else
|
| 1532 | | - {
|
| 1533 | | - if (hackvalue)
|
| 1534 | | - hackvalue = FALSE;
|
| 1535 | | - else hackvalue = TRUE;
|
| 1536 | | - }
|
| 1537 | | - WriteHacksItem(item, hackvalue, hackmask);
|
| 1538 | | - RedrawWindow(GetDlgItem(hWnd, IDC_HACKSLIST), NULL, NULL, RDW_INVALIDATE);
|
| 1539 | | - EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1540 | | - *dirty = TRUE;
|
| 1541 | | - }
|
| 1542 | | - break;
|
| 1543 | | - default:
|
| 1544 | | - break;
|
| 1545 | | - }
|
| 1546 | | - case WM_DRAWITEM:
|
| 1547 | | - drawitem = (DRAWITEMSTRUCT*)lParam;
|
| 1548 | | - switch (wParam)
|
| 1549 | | - {
|
| 1550 | | - case IDC_HACKSLIST:
|
| 1551 | | - OldTextColor = GetTextColor(drawitem->hDC);
|
| 1552 | | - OldBackColor = GetBkColor(drawitem->hDC);
|
| 1553 | | - if ((drawitem->itemState & ODS_SELECTED))
|
| 1554 | | - {
|
| 1555 | | - SetTextColor(drawitem->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
| 1556 | | - SetBkColor(drawitem->hDC, GetSysColor(COLOR_HIGHLIGHT));
|
| 1557 | | - FillRect(drawitem->hDC, &drawitem->rcItem, (HBRUSH)(COLOR_HIGHLIGHT + 1));
|
| 1558 | | - }
|
| 1559 | | - else
|
| 1560 | | - {
|
| 1561 | | - SetTextColor(drawitem->hDC, GetSysColor(COLOR_WINDOWTEXT));
|
| 1562 | | - SetBkColor(drawitem->hDC, GetSysColor(COLOR_WINDOW));
|
| 1563 | | - FillRect(drawitem->hDC, &drawitem->rcItem, (HBRUSH)(COLOR_WINDOW + 1));
|
| 1564 | | - }
|
| 1565 | | - memcpy(&r, &drawitem->rcItem, sizeof(RECT));
|
| 1566 | | - r.left = r.left + 2;
|
| 1567 | | - r.right = r.left + GetSystemMetrics(SM_CXMENUCHECK);
|
| 1568 | | - ReadHacksItem(drawitem->itemID, &hackvalue, &hackmask);
|
| 1569 | | - DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, hackvalue, FALSE, !hackmask, &r);
|
| 1570 | | - drawitem->rcItem.left += GetSystemMetrics(SM_CXSMICON) + 5;
|
| 1571 | | - SendDlgItemMessage(hWnd, IDC_HACKSLIST, LB_GETTEXT, drawitem->itemID, (LPARAM)str);
|
| 1572 | | - DrawText(drawitem->hDC, str, _tcslen(str), &drawitem->rcItem,
|
| 1573 | | - DT_LEFT | DT_SINGLELINE | DT_VCENTER);
|
| 1574 | | - drawitem->rcItem.left -= GetSystemMetrics(SM_CXSMICON) + 5;
|
| 1575 | | - if (drawitem->itemState & ODS_FOCUS) DrawFocusRect(drawitem->hDC, &drawitem->rcItem);
|
| 1576 | | - SetTextColor(drawitem->hDC, OldTextColor);
|
| 1577 | | - SetBkColor(drawitem->hDC, OldBackColor);
|
| 1578 | | - DefWindowProc(hWnd, Msg, wParam, lParam);
|
| 1579 | | - break;
|
| 1580 | | - default:
|
| 1581 | | - break;
|
| 1582 | | - }
|
| 1583 | | - break;
|
| 1584 | | - default:
|
| 1585 | | - return FALSE;
|
| 1586 | | - }
|
| 1587 | | - return TRUE;
|
| 1588 | | -}
|
| 1589 | | -
|
| 1590 | | -
|
| 1591 | | -LRESULT CALLBACK PathsTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| 1592 | | -{
|
| 1593 | | - switch (Msg)
|
| 1594 | | - {
|
| 1595 | | - case WM_INITDIALOG:
|
| 1596 | | - if (_EnableThemeDialogTexture) _EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
|
| 1597 | | - return TRUE;
|
| 1598 | | - default:
|
| 1599 | | - return FALSE;
|
| 1600 | | - }
|
| 1601 | | - return TRUE;
|
| 1602 | | -}
|
| 1603 | | -
|
| 1604 | | -LRESULT CALLBACK DXGLCfgCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| 1605 | | -{
|
| 1606 | | - PIXELFORMATDESCRIPTOR pfd =
|
| 1607 | | - {
|
| 1608 | | - sizeof(PIXELFORMATDESCRIPTOR),
|
| 1609 | | - 1,
|
| 1610 | | - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, //Flags
|
| 1611 | | - PFD_TYPE_RGBA, //The kind of framebuffer. RGBA or palette.
|
| 1612 | | - 0, //Colordepth of the framebuffer.
|
| 1613 | | - 0, 0, 0, 0, 0, 0,
|
| 1614 | | - 0,
|
| 1615 | | - 0,
|
| 1616 | | - 0,
|
| 1617 | | - 0, 0, 0, 0,
|
| 1618 | | - 24, //Number of bits for the depthbuffer
|
| 1619 | | - 8, //Number of bits for the stencilbuffer
|
| 1620 | | - 0, //Number of Aux buffers in the framebuffer.
|
| 1621 | | - PFD_MAIN_PLANE,
|
| 1622 | | - 0,
|
| 1623 | | - 0, 0, 0
|
| 1624 | | - };
|
| 1625 | | - GLfloat anisotropic;
|
| 1626 | | - HDC dc;
|
| 1627 | | - HGLRC rc;
|
| 1628 | | - GLint maxsamples;
|
| 1629 | | - GLint maxcoverage = 0;
|
| 1630 | | - GLint coveragemodes[64];
|
| 1631 | | - int msaamodes[32];
|
| 1632 | | - int pf;
|
| 1633 | | - int i;
|
| 1634 | | - HKEY hKeyBase;
|
| 1635 | | - HKEY hKey;
|
| 1636 | | - DWORD keysize,keysize2;
|
| 1637 | | - DEVMODE mode;
|
| 1638 | | - LPTSTR keyname;
|
| 1639 | | - LPTSTR regbuffer;
|
| 1640 | | - DWORD regbuffersize;
|
| 1641 | | - DWORD buffersize;
|
| 1642 | | - LONG error;
|
| 1643 | | - TCHAR buffer[64];
|
| 1644 | | - TCHAR subkey[MAX_PATH];
|
| 1645 | | - LPTSTR path;
|
| 1646 | | - SHFILEINFO fileinfo;
|
| 1647 | | - DWORD verinfosize;
|
| 1648 | | - LPTSTR outbuffer;
|
| 1649 | | - UINT outlen;
|
| 1650 | | - TCHAR verpath[64];
|
| 1651 | | - WORD translation[2];
|
| 1652 | | - DWORD cursel;
|
| 1653 | | - DRAWITEMSTRUCT* drawitem;
|
| 1654 | | - BOOL hasname;
|
| 1655 | | - void *verinfo;
|
| 1656 | | - COLORREF OldTextColor,OldBackColor;
|
| 1657 | | - HANDLE token = NULL;
|
| 1658 | | - TOKEN_ELEVATION elevation;
|
| 1659 | | - HWND hGLWnd;
|
| 1660 | | - OPENFILENAME filename;
|
| 1661 | | - TCHAR selectedfile[MAX_PATH + 1];
|
| 1662 | | - LPTSTR regpath;
|
| 1663 | | - LPTSTR regkey;
|
| 1664 | | - BOOL failed;
|
| 1665 | | - LPTSTR installpath;
|
| 1666 | | - DWORD err;
|
| 1667 | | - RECT r;
|
| 1668 | | - NMHDR *nm;
|
| 1669 | | - int newtab;
|
| 1670 | | - TCITEM tab;
|
| 1671 | | - switch (Msg)
|
| 1672 | | - {
|
| 1673 | | - case WM_INITDIALOG:
|
| 1674 | | - hDialog = hWnd;
|
| 1675 | | - tristate = FALSE;
|
| 1676 | | - maxapps = 128;
|
| 1677 | | - apps = (app_setting *)malloc(maxapps*sizeof(app_setting));
|
| 1678 | | - apps[0].name = (TCHAR*)malloc(7 * sizeof(TCHAR));
|
| 1679 | | - _tcscpy(apps[0].name,_T("Global"));
|
| 1680 | | - apps[0].regkey = (TCHAR*)malloc(7 * sizeof(TCHAR));
|
| 1681 | | - _tcscpy(apps[0].regkey,_T("Global"));
|
| 1682 | | - GetGlobalConfig(&apps[0].cfg, FALSE);
|
| 1683 | | - cfg = &apps[0].cfg;
|
| 1684 | | - cfgmask = &apps[0].mask;
|
| 1685 | | - dirty = &apps[0].dirty;
|
| 1686 | | - memset(&apps[0].mask,0xff,sizeof(DXGLCFG));
|
| 1687 | | - apps[0].dirty = FALSE;
|
| 1688 | | - apps[0].icon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_STAR));
|
| 1689 | | - apps[0].icon_shared = TRUE;
|
| 1690 | | - apps[0].path[0] = 0;
|
| 1691 | | - SetClassLong(hWnd,GCL_HICON,(LONG)LoadIcon(hinstance,(LPCTSTR)IDI_DXGL));
|
| 1692 | | - SetClassLong(hWnd,GCL_HICONSM,(LONG)LoadIcon(hinstance,(LPCTSTR)IDI_DXGLSM));
|
| 1693 | | - // create temporary gl context to get AA and AF settings.
|
| 1694 | | - mode.dmSize = sizeof(DEVMODE);
|
| 1695 | | - EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&mode);
|
| 1696 | | - pfd.cColorBits = (BYTE)mode.dmBitsPerPel;
|
| 1697 | | - hGLWnd = CreateWindow(_T("STATIC"),NULL,WS_CHILD,0,0,16,16,hWnd,NULL,NULL,NULL);
|
| 1698 | | - dc = GetDC(hGLWnd);
|
| 1699 | | - pf = ChoosePixelFormat(dc,&pfd);
|
| 1700 | | - SetPixelFormat(dc,pf,&pfd);
|
| 1701 | | - rc = wglCreateContext(dc);
|
| 1702 | | - wglMakeCurrent(dc,rc);
|
| 1703 | | - extensions_string = (char*)glGetString(GL_EXTENSIONS);
|
| 1704 | | - if(strstr(extensions_string,"GL_EXT_texture_filter_anisotropic"))
|
| 1705 | | - glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT,&anisotropic);
|
| 1706 | | - else anisotropic = 0;
|
| 1707 | | - if(strstr(extensions_string,"GL_EXT_framebuffer_multisample"))
|
| 1708 | | - {
|
| 1709 | | - glGetIntegerv(GL_MAX_SAMPLES_EXT,&maxsamples);
|
| 1710 | | - if(strstr(extensions_string,"GL_NV_framebuffer_multisample_coverage")) // Supports NVIDIA CSAA
|
| 1711 | | - {
|
| 1712 | | - glGetIntegerv(GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV,&maxcoverage);
|
| 1713 | | - glGetIntegerv(GL_MULTISAMPLE_COVERAGE_MODES_NV,coveragemodes);
|
| 1714 | | - if(maxcoverage) for(i = 0; i < maxcoverage; i++)
|
| 1715 | | - {
|
| 1716 | | - msaamodes[i] = coveragemodes[2*i]+(4096*coveragemodes[(2*i)+1]);
|
| 1717 | | - msaa = TRUE;
|
| 1718 | | - }
|
| 1719 | | - }
|
| 1720 | | - }
|
| 1721 | | - wglMakeCurrent(dc,NULL);
|
| 1722 | | - wglDeleteContext(rc);
|
| 1723 | | - ReleaseDC(hGLWnd,dc);
|
| 1724 | | - DestroyWindow(hGLWnd);
|
| 1725 | | - uxtheme = LoadLibrary(_T("uxtheme.dll"));
|
| 1726 | | - if (uxtheme)
|
| 1727 | | - {
|
| 1728 | | -
|
| 1729 | | - _OpenThemeData = (HTHEME(WINAPI*)(HWND,LPCWSTR))GetProcAddress(uxtheme, "OpenThemeData");
|
| 1730 | | - _CloseThemeData = (HRESULT(WINAPI*)(HTHEME))GetProcAddress(uxtheme, "CloseThemeData");
|
| 1731 | | - _DrawThemeBackground =
|
| 1732 | | - (HRESULT(WINAPI*)(HTHEME, HDC, int, int, const RECT*, const RECT*))
|
| 1733 | | - GetProcAddress(uxtheme, "DrawThemeBackground");
|
| 1734 | | - _EnableThemeDialogTexture = (HRESULT(WINAPI*)(HWND, DWORD))
|
| 1735 | | - GetProcAddress(uxtheme, "EnableThemeDialogTexture");
|
| 1736 | | - if (!(_OpenThemeData && _CloseThemeData && _DrawThemeBackground && _EnableThemeDialogTexture))
|
| 1737 | | - {
|
| 1738 | | - FreeLibrary(uxtheme);
|
| 1739 | | - uxtheme = NULL;
|
| 1740 | | - }
|
| 1741 | | - }
|
| 1742 | | - // Add tabs
|
| 1743 | | - ZeroMemory(&tab, sizeof(TCITEM));
|
| 1744 | | - tab.mask = TCIF_TEXT;
|
| 1745 | | - tab.pszText = _T("Display");
|
| 1746 | | - SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 0, (LPARAM)&tab);
|
| 1747 | | - tab.pszText = _T("Effects");
|
| 1748 | | - SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 1, (LPARAM)&tab);
|
| 1749 | | - tab.pszText = _T("3D Graphics");
|
| 1750 | | - SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 2, (LPARAM)&tab);
|
| 1751 | | - tab.pszText = _T("Advanced");
|
| 1752 | | - SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 3, (LPARAM)&tab);
|
| 1753 | | - tab.pszText = _T("Debug");
|
| 1754 | | - SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 4, (LPARAM)&tab);
|
| 1755 | | - tab.pszText = _T("Hacks");
|
| 1756 | | - SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 5, (LPARAM)&tab);
|
| 1757 | | - /*tab.pszText = _T("Graphics Tests");
|
| 1758 | | - SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 6, (LPARAM)&tab);
|
| 1759 | | - tab.pszText = _T("About");
|
| 1760 | | - SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 7, (LPARAM)&tab);*/
|
| 1761 | | - hTab = GetDlgItem(hWnd, IDC_TABS);
|
| 1762 | | - hTabs[0] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_DISPLAY), hTab, DisplayTabCallback);
|
| 1763 | | - hTabs[1] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_EFFECTS), hTab, EffectsTabCallback);
|
| 1764 | | - hTabs[2] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_3DGRAPHICS), hTab, Tab3DCallback);
|
| 1765 | | - hTabs[3] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADVANCED), hTab, AdvancedTabCallback);
|
| 1766 | | - hTabs[4] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_DEBUG), hTab, DebugTabCallback);
|
| 1767 | | - hTabs[5] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_HACKS), hTab, HacksTabCallback);
|
| 1768 | | - SendDlgItemMessage(hWnd, IDC_TABS, TCM_GETITEMRECT, 0, (LPARAM)&r);
|
| 1769 | | - SetWindowPos(hTabs[0], NULL, r.left, r.bottom + 3, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
|
| 1770 | | - ShowWindow(hTabs[1], SW_HIDE);
|
| 1771 | | - ShowWindow(hTabs[2], SW_HIDE);
|
| 1772 | | - ShowWindow(hTabs[3], SW_HIDE);
|
| 1773 | | - ShowWindow(hTabs[4], SW_HIDE);
|
| 1774 | | - ShowWindow(hTabs[5], SW_HIDE);
|
| 1775 | | - tabopen = 0;
|
| 1776 | | -
|
| 1777 | | - // Load global settings.
|
| 1778 | | - // video mode
|
| 1779 | | - _tcscpy(buffer,_T("Change desktop resolution"));
|
| 1780 | | - SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1781 | | - _tcscpy(buffer,_T("Stretch to screen"));
|
| 1782 | | - SendDlgItemMessage(hTabs[0],IDC_VIDMODE,CB_ADDSTRING,1,(LPARAM)buffer);
|
| 1783 | | - _tcscpy(buffer,_T("Aspect corrected stretch"));
|
| 1784 | | - SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_ADDSTRING, 2, (LPARAM)buffer);
|
| 1785 | | - _tcscpy(buffer,_T("Center image on screen"));
|
| 1786 | | - SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_ADDSTRING, 3, (LPARAM)buffer);
|
| 1787 | | - _tcscpy(buffer,_T("Stretch if mode not found"));
|
| 1788 | | - SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_ADDSTRING, 4, (LPARAM)buffer);
|
| 1789 | | - _tcscpy(buffer,_T("Scale if mode not found"));
|
| 1790 | | - SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_ADDSTRING, 5, (LPARAM)buffer);
|
| 1791 | | - _tcscpy(buffer,_T("Center if mode not found"));
|
| 1792 | | - SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_ADDSTRING, 6, (LPARAM)buffer);
|
| 1793 | | - _tcscpy(buffer,_T("Crop to screen"));
|
| 1794 | | - SendDlgItemMessage(hTabs[0],IDC_VIDMODE,CB_ADDSTRING,7,(LPARAM)buffer);
|
| 1795 | | - SendDlgItemMessage(hTabs[0],IDC_VIDMODE,CB_SETCURSEL,cfg->scaler,0);
|
| 1796 | | - // fullscreen window mode
|
| 1797 | | - _tcscpy(buffer, _T("Exclusive fullscreen"));
|
| 1798 | | - SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1799 | | - _tcscpy(buffer, _T("Non-exclusive fullscreen"));
|
| 1800 | | - SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_ADDSTRING, 1, (LPARAM)buffer);
|
| 1801 | | - _tcscpy(buffer, _T("Non-resizable window"));
|
| 1802 | | - SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_ADDSTRING, 2, (LPARAM)buffer);
|
| 1803 | | - _tcscpy(buffer, _T("Resizable window"));
|
| 1804 | | - SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_ADDSTRING, 3, (LPARAM)buffer);
|
| 1805 | | - _tcscpy(buffer, _T("Borderless window"));
|
| 1806 | | - SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_ADDSTRING, 4, (LPARAM)buffer);
|
| 1807 | | - _tcscpy(buffer, _T("Borderless window (scaled)"));
|
| 1808 | | - SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_ADDSTRING, 5, (LPARAM)buffer);
|
| 1809 | | - SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_SETCURSEL, cfg->fullmode, 0);
|
| 1810 | | - // colormode
|
| 1811 | | - if (cfg->colormode) SendDlgItemMessage(hTabs[0], IDC_COLOR, BM_SETCHECK, BST_CHECKED, 0);
|
| 1812 | | - else SendDlgItemMessage(hTabs[0], IDC_COLOR, BM_SETCHECK, BST_UNCHECKED, 0);
|
| 1813 | | - // single buffer
|
| 1814 | | - if(cfg->SingleBufferDevice) SendDlgItemMessage(hTabs[0], IDC_SINGLEBUFFER, BM_SETCHECK, BST_CHECKED, 0);
|
| 1815 | | - else SendDlgItemMessage(hTabs[0], IDC_SINGLEBUFFER, BM_SETCHECK, BST_UNCHECKED, 0);
|
| 1816 | | - // first scaling filter
|
| 1817 | | - _tcscpy(buffer, _T("Nearest"));
|
| 1818 | | - SendDlgItemMessage(hTabs[1], IDC_POSTSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1819 | | - _tcscpy(buffer, _T("Bilinear"));
|
| 1820 | | - SendDlgItemMessage(hTabs[1], IDC_POSTSCALE, CB_ADDSTRING, 1, (LPARAM)buffer);
|
| 1821 | | - SendDlgItemMessage(hTabs[1], IDC_POSTSCALE, CB_SETCURSEL, cfg->postfilter, 0);
|
| 1822 | | - // first scaling sizes
|
| 1823 | | - _tcscpy(buffer, _T("Auto"));
|
| 1824 | | - SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1825 | | - _tcscpy(buffer, _T("1x"));
|
| 1826 | | - SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1827 | | - _tcscpy(buffer, _T("2x1"));
|
| 1828 | | - SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1829 | | - _tcscpy(buffer, _T("2x"));
|
| 1830 | | - SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1831 | | - _tcscpy(buffer, _T("3x"));
|
| 1832 | | - SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1833 | | - _tcscpy(buffer, _T("4x"));
|
| 1834 | | - SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1835 | | - SetPostScaleCombo(hTabs[1], IDC_POSTSCALESIZE, cfg->postsizex, cfg->postsizey,
|
| 1836 | | - cfgmask->postsizex, cfgmask->postsizey, tristate);
|
| 1837 | | - // primary scaling
|
| 1838 | | - _tcscpy(buffer, _T("1x scale"));
|
| 1839 | | - SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1840 | | - _tcscpy(buffer, _T("Scale to screen"));
|
| 1841 | | - SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1842 | | - _tcscpy(buffer, _T("Maximum integer scaling"));
|
| 1843 | | - SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1844 | | - _tcscpy(buffer, _T("1.5x scale"));
|
| 1845 | | - SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1846 | | - _tcscpy(buffer, _T("2x scale"));
|
| 1847 | | - SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1848 | | - _tcscpy(buffer, _T("2.5x scale"));
|
| 1849 | | - SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1850 | | - _tcscpy(buffer, _T("3x scale"));
|
| 1851 | | - SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1852 | | - _tcscpy(buffer, _T("4x scale"));
|
| 1853 | | - SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1854 | | - _tcscpy(buffer, _T("5x scale"));
|
| 1855 | | - SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1856 | | - _tcscpy(buffer, _T("6x scale"));
|
| 1857 | | - SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1858 | | - _tcscpy(buffer, _T("7x scale"));
|
| 1859 | | - SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1860 | | - _tcscpy(buffer, _T("8x scale"));
|
| 1861 | | - SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1862 | | - _tcscpy(buffer, _T("Custom scale"));
|
| 1863 | | - SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1864 | | - SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_SETCURSEL, cfg->primaryscale, 0);
|
| 1865 | | - // scaling filter
|
| 1866 | | - _tcscpy(buffer,_T("Nearest"));
|
| 1867 | | - SendDlgItemMessage(hTabs[0], IDC_SCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1868 | | - _tcscpy(buffer,_T("Bilinear"));
|
| 1869 | | - SendDlgItemMessage(hTabs[0],IDC_SCALE,CB_ADDSTRING,1,(LPARAM)buffer);
|
| 1870 | | - SendDlgItemMessage(hTabs[0],IDC_SCALE,CB_SETCURSEL,cfg->scalingfilter,0);
|
| 1871 | | - // aspect
|
| 1872 | | - _tcscpy(buffer,_T("Default"));
|
| 1873 | | - SendDlgItemMessage(hTabs[0], IDC_ASPECT, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1874 | | - _tcscpy(buffer,_T("4:3"));
|
| 1875 | | - SendDlgItemMessage(hTabs[0], IDC_ASPECT, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1876 | | - _tcscpy(buffer,_T("16:10"));
|
| 1877 | | - SendDlgItemMessage(hTabs[0], IDC_ASPECT, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1878 | | - _tcscpy(buffer,_T("16:9"));
|
| 1879 | | - SendDlgItemMessage(hTabs[0], IDC_ASPECT, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1880 | | - _tcscpy(buffer,_T("5:4"));
|
| 1881 | | - SendDlgItemMessage(hTabs[0], IDC_ASPECT, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1882 | | - SetAspectCombo(hTabs[0], IDC_ASPECT, cfg->aspect, cfgmask->aspect, tristate);
|
| 1883 | | - // texfilter
|
| 1884 | | - _tcscpy(buffer,_T("Application default"));
|
| 1885 | | - SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1886 | | - _tcscpy(buffer,_T("Nearest"));
|
| 1887 | | - SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_ADDSTRING, 1, (LPARAM)buffer);
|
| 1888 | | - _tcscpy(buffer,_T("Bilinear"));
|
| 1889 | | - SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_ADDSTRING, 2, (LPARAM)buffer);
|
| 1890 | | - _tcscpy(buffer,_T("Nearest, nearest mipmap"));
|
| 1891 | | - SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_ADDSTRING, 3, (LPARAM)buffer);
|
| 1892 | | - _tcscpy(buffer,_T("Nearest, linear mipmap"));
|
| 1893 | | - SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_ADDSTRING, 4, (LPARAM)buffer);
|
| 1894 | | - _tcscpy(buffer,_T("Bilinear, nearest mipmap"));
|
| 1895 | | - SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_ADDSTRING, 5, (LPARAM)buffer);
|
| 1896 | | - _tcscpy(buffer,_T("Bilinear, linear mipmap"));
|
| 1897 | | - SendDlgItemMessage(hTabs[2],IDC_TEXFILTER,CB_ADDSTRING,6,(LPARAM)buffer);
|
| 1898 | | - SendDlgItemMessage(hTabs[2],IDC_TEXFILTER,CB_SETCURSEL,cfg->texfilter,0);
|
| 1899 | | - // anisotropic
|
| 1900 | | - if (anisotropic < 2)
|
| 1901 | | - {
|
| 1902 | | - _tcscpy(buffer,_T("Not supported"));
|
| 1903 | | - SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1904 | | - SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_SETCURSEL, 0, 0);
|
| 1905 | | - EnableWindow(GetDlgItem(hTabs[2], IDC_ANISO), FALSE);
|
| 1906 | | - cfg->anisotropic = 0;
|
| 1907 | | - }
|
| 1908 | | - else
|
| 1909 | | - {
|
| 1910 | | - _tcscpy(buffer,_T("Application default"));
|
| 1911 | | - SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1912 | | - _tcscpy(buffer,_T("Disabled"));
|
| 1913 | | - SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 1, (LPARAM)buffer);
|
| 1914 | | - if(anisotropic >= 2)
|
| 1915 | | - {
|
| 1916 | | - _tcscpy(buffer,_T("2x"));
|
| 1917 | | - SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 2, (LPARAM)buffer);
|
| 1918 | | - }
|
| 1919 | | - if(anisotropic >= 4)
|
| 1920 | | - {
|
| 1921 | | - _tcscpy(buffer,_T("4x"));
|
| 1922 | | - SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 4, (LPARAM)buffer);
|
| 1923 | | - }
|
| 1924 | | - if(anisotropic >= 8)
|
| 1925 | | - {
|
| 1926 | | - _tcscpy(buffer,_T("8x"));
|
| 1927 | | - SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 8, (LPARAM)buffer);
|
| 1928 | | - }
|
| 1929 | | - if(anisotropic >= 16)
|
| 1930 | | - {
|
| 1931 | | - _tcscpy(buffer,_T("16x"));
|
| 1932 | | - SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 16, (LPARAM)buffer);
|
| 1933 | | - }
|
| 1934 | | - if(anisotropic >= 32)
|
| 1935 | | - {
|
| 1936 | | - _tcscpy(buffer,_T("32x"));
|
| 1937 | | - SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 4, (LPARAM)buffer);
|
| 1938 | | - }
|
| 1939 | | - SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_SETCURSEL, cfg->anisotropic, 0);
|
| 1940 | | - }
|
| 1941 | | - // msaa
|
| 1942 | | - if(msaa)
|
| 1943 | | - {
|
| 1944 | | - _tcscpy(buffer,_T("Application default"));
|
| 1945 | | - SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1946 | | - _tcscpy(buffer,_T("Disabled"));
|
| 1947 | | - SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 1, (LPARAM)buffer);
|
| 1948 | | - if(maxcoverage)
|
| 1949 | | - {
|
| 1950 | | - for(i = 0; i < maxcoverage; i++)
|
| 1951 | | - {
|
| 1952 | | - if((msaamodes[i] & 0xfff) <= 4)
|
| 1953 | | - _sntprintf(buffer,64,_T("%dx"),msaamodes[i] & 0xfff);
|
| 1954 | | - else _sntprintf(buffer,64,_T("%dx coverage, %dx color"),(msaamodes[i] & 0xfff), (msaamodes[i] >> 12));
|
| 1955 | | - SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, msaamodes[i], (LPARAM)buffer);
|
| 1956 | | - }
|
| 1957 | | - }
|
| 1958 | | - else
|
| 1959 | | - {
|
| 1960 | | - if(maxsamples >= 2)
|
| 1961 | | - {
|
| 1962 | | - _tcscpy(buffer,_T("2x"));
|
| 1963 | | - SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 2, (LPARAM)buffer);
|
| 1964 | | - }
|
| 1965 | | - if(maxsamples >= 4)
|
| 1966 | | - {
|
| 1967 | | - _tcscpy(buffer,_T("4x"));
|
| 1968 | | - SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 4, (LPARAM)buffer);
|
| 1969 | | - }
|
| 1970 | | - if(maxsamples >= 8)
|
| 1971 | | - {
|
| 1972 | | - _tcscpy(buffer,_T("8x"));
|
| 1973 | | - SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 8, (LPARAM)buffer);
|
| 1974 | | - }
|
| 1975 | | - if(maxsamples >= 16)
|
| 1976 | | - {
|
| 1977 | | - _tcscpy(buffer,_T("16x"));
|
| 1978 | | - SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 16, (LPARAM)buffer);
|
| 1979 | | - }
|
| 1980 | | - if(maxsamples >= 32)
|
| 1981 | | - {
|
| 1982 | | - _tcscpy(buffer,_T("32x"));
|
| 1983 | | - SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 32, (LPARAM)buffer);
|
| 1984 | | - }
|
| 1985 | | - }
|
| 1986 | | - SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_SETCURSEL, cfg->msaa, 0);
|
| 1987 | | - }
|
| 1988 | | - else
|
| 1989 | | - {
|
| 1990 | | - _tcscpy(buffer,_T("Not supported"));
|
| 1991 | | - SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1992 | | - SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_SETCURSEL, 0, 0);
|
| 1993 | | - EnableWindow(GetDlgItem(hTabs[2], IDC_MSAA), FALSE);
|
| 1994 | | - cfg->msaa = 0;
|
| 1995 | | - }
|
| 1996 | | - // aspect3d
|
| 1997 | | - _tcscpy(buffer,_T("Stretch to display"));
|
| 1998 | | - SendDlgItemMessage(hTabs[2], IDC_ASPECT3D, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 1999 | | - _tcscpy(buffer,_T("Expand viewable area"));
|
| 2000 | | - SendDlgItemMessage(hTabs[2], IDC_ASPECT3D, CB_ADDSTRING, 1, (LPARAM)buffer);
|
| 2001 | | - _tcscpy(buffer,_T("Crop to display"));
|
| 2002 | | - SendDlgItemMessage(hTabs[2],IDC_ASPECT3D,CB_ADDSTRING,2,(LPARAM)buffer);
|
| 2003 | | - SendDlgItemMessage(hTabs[2],IDC_ASPECT3D,CB_SETCURSEL,cfg->aspect3d,0);
|
| 2004 | | - // sort modes
|
| 2005 | | - _tcscpy(buffer,_T("Use system order"));
|
| 2006 | | - SendDlgItemMessage(hTabs[0], IDC_SORTMODES, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| 2007 | | - _tcscpy(buffer,_T("Group by color depth"));
|
| 2008 | | - SendDlgItemMessage(hTabs[0], IDC_SORTMODES, CB_ADDSTRING, 1, (LPARAM)buffer);
|
| 2009 | | - _tcscpy(buffer,_T("Group by resolution"));
|
| 2010 | | - SendDlgItemMessage(hTabs[0],IDC_SORTMODES,CB_ADDSTRING,2,(LPARAM)buffer);
|
| 2011 | | - SendDlgItemMessage(hTabs[0],IDC_SORTMODES,CB_SETCURSEL,cfg->SortModes,0);
|
| 2012 | | - // color depths
|
| 2013 | | - for (i = 0; i < 5; i++)
|
| 2014 | | - {
|
| 2015 | | - _tcscpy(buffer, colormodedropdown[i]);
|
| 2016 | | - SendDlgItemMessage(hTabs[0], IDC_COLORDEPTH, CB_ADDSTRING, i, (LPARAM)buffer);
|
| 2017 | | - }
|
| 2018 | | - SendDlgItemMessage(hTabs[0], IDC_COLORDEPTH, CB_SETCURSEL, cfg->AddColorDepths, 0);
|
| 2019 | | - for (i = 0; i < 7; i++)
|
| 2020 | | - {
|
| 2021 | | - _tcscpy(buffer, extramodes[i]);
|
| 2022 | | - SendDlgItemMessage(hTabs[0], IDC_EXTRAMODES, CB_ADDSTRING, i, (LPARAM)buffer);
|
| 2023 | | - }
|
| 2024 | | - // Enable shader
|
| 2025 | | - if (cfg->colormode) SendDlgItemMessage(hTabs[1], IDC_USESHADER, BM_SETCHECK, BST_CHECKED, 0);
|
| 2026 | | - else SendDlgItemMessage(hTabs[1], IDC_USESHADER, BM_SETCHECK, BST_UNCHECKED, 0);
|
| 2027 | | - // shader path
|
| 2028 | | - SetText(hTabs[1],IDC_SHADER,cfg->shaderfile,cfgmask->shaderfile,FALSE);
|
| 2029 | | - // texture format
|
| 2030 | | - _tcscpy(buffer,_T("Automatic"));
|
| 2031 | | - SendDlgItemMessage(hTabs[3],IDC_TEXTUREFORMAT,CB_ADDSTRING,0,(LPARAM)buffer);
|
| 2032 | | - SendDlgItemMessage(hTabs[3],IDC_TEXTUREFORMAT,CB_SETCURSEL,cfg->TextureFormat,0);
|
| 2033 | | - // Texture upload
|
| 2034 | | - _tcscpy(buffer,_T("Automatic"));
|
| 2035 | | - SendDlgItemMessage(hTabs[3],IDC_TEXUPLOAD,CB_ADDSTRING,0,(LPARAM)buffer);
|
| 2036 | | - SendDlgItemMessage(hTabs[3],IDC_TEXUPLOAD,CB_SETCURSEL,cfg->TexUpload,0);
|
| 2037 | | - // DPI
|
| 2038 | | - _tcscpy(buffer, _T("Disabled"));
|
| 2039 | | - SendDlgItemMessage(hTabs[0],IDC_DPISCALE,CB_ADDSTRING,0,(LPARAM)buffer);
|
| 2040 | | - _tcscpy(buffer, _T("Enabled"));
|
| 2041 | | - SendDlgItemMessage(hTabs[0],IDC_DPISCALE,CB_ADDSTRING,1,(LPARAM)buffer);
|
| 2042 | | - _tcscpy(buffer, _T("Windows AppCompat"));
|
| 2043 | | - SendDlgItemMessage(hTabs[0],IDC_DPISCALE,CB_ADDSTRING,2,(LPARAM)buffer);
|
| 2044 | | - SendDlgItemMessage(hTabs[0],IDC_DPISCALE,CB_SETCURSEL,cfg->DPIScale,0);
|
| 2045 | | - // Paths
|
| 2046 | | - EnableWindow(GetDlgItem(hTabs[3], IDC_PATHLABEL), FALSE);
|
| 2047 | | - EnableWindow(GetDlgItem(hTabs[3], IDC_PROFILEPATH), FALSE);
|
| 2048 | | - // Debug
|
| 2049 | | - _tcscpy(buffer, _T("Disable EXT framebuffers"));
|
| 2050 | | - SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
|
| 2051 | | - _tcscpy(buffer, _T("Disable ARB framebuffers"));
|
| 2052 | | - SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
|
| 2053 | | - _tcscpy(buffer, _T("Disable GLES2 compatibility extension"));
|
| 2054 | | - SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
|
| 2055 | | - _tcscpy(buffer, _T("Disable EXT direct state access"));
|
| 2056 | | - SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
|
| 2057 | | - _tcscpy(buffer, _T("Disable ARB direct state access"));
|
| 2058 | | - SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
|
| 2059 | | - _tcscpy(buffer, _T("Disable sampler objects"));
|
| 2060 | | - SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
|
| 2061 | | - _tcscpy(buffer, _T("Disable EXT_gpu_shader4 extension"));
|
| 2062 | | - SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
|
| 2063 | | - _tcscpy(buffer, _T("Disable GLSL 1.30 support"));
|
| 2064 | | - SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
|
| 2065 | | - /*_tcscpy(buffer, _T("Disable OpenGL errors (OpenGL 4.6+)"));
|
| 2066 | | - SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);*/
|
| 2067 | | -
|
| 2068 | | - // Check install path
|
| 2069 | | - installpath = NULL;
|
| 2070 | | - error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\DXGL"), 0, KEY_READ, &hKey);
|
| 2071 | | - if (error == ERROR_SUCCESS)
|
| 2072 | | - {
|
| 2073 | | - if (RegQueryValueEx(hKey, _T("InstallDir"), NULL, NULL, NULL, &keysize) == ERROR_SUCCESS)
|
| 2074 | | - {
|
| 2075 | | - installpath = (LPTSTR)malloc(keysize);
|
| 2076 | | - error = RegQueryValueEx(hKey, _T("InstallDir"), NULL, NULL, installpath, &keysize);
|
| 2077 | | - if (error != ERROR_SUCCESS)
|
| 2078 | | - {
|
| 2079 | | - free(installpath);
|
| 2080 | | - installpath = NULL;
|
| 2081 | | - }
|
| 2082 | | - }
|
| 2083 | | - RegCloseKey(hKey);
|
| 2084 | | - }
|
| 2085 | | - hKey = NULL;
|
| 2086 | | - // Add installed programs
|
| 2087 | | - current_app = 1;
|
| 2088 | | - appcount = 1;
|
| 2089 | | - regbuffersize = 1024;
|
| 2090 | | - regbuffer = (LPTSTR)malloc(regbuffersize * sizeof(TCHAR));
|
| 2091 | | - RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\DXGL\\Profiles"), 0, NULL, 0, KEY_READ, NULL, &hKeyBase, NULL);
|
| 2092 | | - RegQueryInfoKey(hKeyBase, NULL, NULL, NULL, NULL, &keysize, NULL, NULL, NULL, NULL, NULL, NULL);
|
| 2093 | | - keysize++;
|
| 2094 | | - keyname = (LPTSTR)malloc(keysize * sizeof(TCHAR));
|
| 2095 | | - keysize2 = keysize;
|
| 2096 | | - i = 0;
|
| 2097 | | - while (RegEnumKeyEx(hKeyBase, i, keyname, &keysize2, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
| 2098 | | - {
|
| 2099 | | - keysize2 = keysize;
|
| 2100 | | - i++;
|
| 2101 | | - appcount++;
|
| 2102 | | - if (appcount > maxapps)
|
| 2103 | | - {
|
| 2104 | | - maxapps += 128;
|
| 2105 | | - apps = (app_setting *)realloc(apps, maxapps * sizeof(app_setting));
|
| 2106 | | - }
|
| 2107 | | - _tcscpy(subkey, keyname);
|
| 2108 | | - if (_tcsrchr(subkey, _T('-'))) *(_tcsrchr(subkey, _T('-'))) = 0;
|
| 2109 | | - error = RegOpenKeyEx(hKeyBase, keyname, 0, KEY_READ, &hKey);
|
| 2110 | | - buffersize = regbuffersize;
|
| 2111 | | - RegQueryValueEx(hKey, _T("InstallPath"), NULL, NULL, NULL, &buffersize);
|
| 2112 | | - if (buffersize > regbuffersize)
|
| 2113 | | - {
|
| 2114 | | - regbuffersize = buffersize;
|
| 2115 | | - regbuffer = (LPTSTR)realloc(regbuffer, regbuffersize);
|
| 2116 | | - }
|
| 2117 | | - buffersize = regbuffersize;
|
| 2118 | | - regbuffer[0] = 0;
|
| 2119 | | - error = RegQueryValueEx(hKey, _T("InstallPath"), NULL, NULL, (LPBYTE)regbuffer, &buffersize);
|
| 2120 | | - apps[appcount - 1].regkey = (LPTSTR)malloc((_tcslen(keyname) + 1) * sizeof(TCHAR));
|
| 2121 | | - _tcscpy(apps[appcount - 1].regkey, keyname);
|
| 2122 | | - GetConfig(&apps[appcount - 1].cfg, &apps[appcount - 1].mask, keyname);
|
| 2123 | | - apps[appcount - 1].dirty = FALSE;
|
| 2124 | | - if ((regbuffer[0] == 0) || error != ERROR_SUCCESS)
|
| 2125 | | - {
|
| 2126 | | - // Default icon
|
| 2127 | | - apps[appcount - 1].icon = LoadIcon(NULL, IDI_APPLICATION);
|
| 2128 | | - apps[appcount - 1].icon_shared = TRUE;
|
| 2129 | | - apps[appcount - 1].name = (TCHAR*)malloc((_tcslen(subkey) + 1) * sizeof(TCHAR));
|
| 2130 | | - _tcscpy(apps[appcount - 1].name, subkey);
|
| 2131 | | - break;
|
| 2132 | | - }
|
| 2133 | | - path = (LPTSTR)malloc(((_tcslen(regbuffer) + _tcslen(subkey) + 2)) * sizeof(TCHAR));
|
| 2134 | | - _tcscpy(path, regbuffer);
|
| 2135 | | - _tcscpy(apps[appcount - 1].path, path);
|
| 2136 | | - if (installpath)
|
| 2137 | | - {
|
| 2138 | | - if (!_tcsicmp(installpath, path)) apps[appcount - 1].builtin = TRUE;
|
| 2139 | | - else apps[appcount - 1].builtin = FALSE;
|
| 2140 | | - }
|
| 2141 | | - _tcscat(path, _T("\\"));
|
| 2142 | | - _tcscat(path, subkey);
|
| 2143 | | - if (GetFileAttributes(path) == INVALID_FILE_ATTRIBUTES)
|
| 2144 | | - {
|
| 2145 | | - // Default icon
|
| 2146 | | - apps[appcount - 1].icon = LoadIcon(NULL, IDI_APPLICATION);
|
| 2147 | | - apps[appcount - 1].icon_shared = TRUE;
|
| 2148 | | - apps[appcount - 1].name = (TCHAR*)malloc((_tcslen(subkey) + 1) * sizeof(TCHAR));
|
| 2149 | | - _tcscpy(apps[appcount - 1].name, subkey);
|
| 2150 | | - break;
|
| 2151 | | - }
|
| 2152 | | - // Get exe attributes
|
| 2153 | | - error = SHGetFileInfo(path, 0, &fileinfo, sizeof(SHFILEINFO), SHGFI_ICON | SHGFI_SMALLICON | SHGFI_ADDOVERLAYS);
|
| 2154 | | - apps[appcount - 1].icon = fileinfo.hIcon;
|
| 2155 | | - apps[appcount - 1].icon_shared = FALSE;
|
| 2156 | | - verinfosize = GetFileVersionInfoSize(path, NULL);
|
| 2157 | | - verinfo = malloc(verinfosize);
|
| 2158 | | - hasname = FALSE;
|
| 2159 | | - if (GetFileVersionInfo(path, 0, verinfosize, verinfo))
|
| 2160 | | - {
|
| 2161 | | - if (VerQueryValue(verinfo, _T("\\VarFileInfo\\Translation"), (LPVOID*)&outbuffer, &outlen))
|
| 2162 | | - {
|
| 2163 | | - memcpy(translation, outbuffer, 4);
|
| 2164 | | - _sntprintf(verpath, 64, _T("\\StringFileInfo\\%04x%04x\\FileDescription"), translation[0], translation[1]);
|
| 2165 | | - if (VerQueryValue(verinfo, verpath, (LPVOID*)&outbuffer, &outlen))
|
| 2166 | | - {
|
| 2167 | | - hasname = TRUE;
|
| 2168 | | - apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(outbuffer) + 1) * sizeof(TCHAR));
|
| 2169 | | - _tcscpy(apps[appcount - 1].name, outbuffer);
|
| 2170 | | - }
|
| 2171 | | - else
|
| 2172 | | - {
|
| 2173 | | - _sntprintf(verpath, 64, _T("\\StringFileInfo\\%04x%04x\\ProductName"), ((WORD*)outbuffer)[0], ((WORD*)outbuffer)[1]);
|
| 2174 | | - if (VerQueryValue(verinfo, verpath, (LPVOID*)&outbuffer, &outlen))
|
| 2175 | | - {
|
| 2176 | | - hasname = TRUE;
|
| 2177 | | - apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(outbuffer) + 1) * sizeof(TCHAR));
|
| 2178 | | - _tcscpy(apps[appcount - 1].name, outbuffer);
|
| 2179 | | - }
|
| 2180 | | - else
|
| 2181 | | - {
|
| 2182 | | - _sntprintf(verpath, 64, _T("\\StringFileInfo\\%04x%04x\\InternalName"), ((WORD*)outbuffer)[0], ((WORD*)outbuffer)[1]);
|
| 2183 | | - if (VerQueryValue(verinfo, verpath, (LPVOID*)&outbuffer, &outlen))
|
| 2184 | | - {
|
| 2185 | | - hasname = TRUE;
|
| 2186 | | - apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(outbuffer) + 1) * sizeof(TCHAR));
|
| 2187 | | - _tcscpy(apps[appcount - 1].name, outbuffer);
|
| 2188 | | - }
|
| 2189 | | - }
|
| 2190 | | - }
|
| 2191 | | - }
|
| 2192 | | - }
|
| 2193 | | - free(path);
|
| 2194 | | - if (!hasname)
|
| 2195 | | - {
|
| 2196 | | - apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(subkey) + 1) * sizeof(TCHAR));
|
| 2197 | | - _tcscpy(apps[appcount - 1].name, subkey);
|
| 2198 | | - }
|
| 2199 | | - free(verinfo);
|
| 2200 | | - RegCloseKey(hKey);
|
| 2201 | | - }
|
| 2202 | | - RegCloseKey(hKeyBase);
|
| 2203 | | - free(keyname);
|
| 2204 | | - for(i = 0; i < appcount; i++)
|
| 2205 | | - {
|
| 2206 | | - SendDlgItemMessage(hWnd,IDC_APPS,CB_ADDSTRING,0,(LPARAM)apps[i].name);
|
| 2207 | | - }
|
| 2208 | | - current_app = 0;
|
| 2209 | | - SendDlgItemMessage(hWnd,IDC_APPS,CB_SETCURSEL,0,0);
|
| 2210 | | - GetWindowRect(GetDlgItem(hWnd, IDC_APPS), &r);
|
| 2211 | | - SetWindowPos(GetDlgItem(hWnd, IDC_APPS), HWND_TOP, r.left, r.top, r.right - r.left,
|
| 2212 | | - (r.bottom - r.top) + (16 * (GetSystemMetrics(SM_CYSMICON) + 1)+(2*GetSystemMetrics(SM_CYBORDER))),
|
| 2213 | | - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
|
| 2214 | | - if(osver.dwMajorVersion >= 6)
|
| 2215 | | - {
|
| 2216 | | - if(OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY,&token))
|
| 2217 | | - {
|
| 2218 | | - if(GetTokenInformation(token,(TOKEN_INFORMATION_CLASS)TokenElevation,&elevation,sizeof(TOKEN_ELEVATION),(PDWORD)&outlen))
|
| 2219 | | - {
|
| 2220 | | - if(!elevation.TokenIsElevated)
|
| 2221 | | - {
|
| 2222 | | - SendDlgItemMessage(hWnd,IDC_ADD,BCM_SETSHIELD,0,TRUE);
|
| 2223 | | - SendDlgItemMessage(hWnd,IDC_REMOVE,BCM_SETSHIELD,0,TRUE);
|
| 2224 | | - }
|
| 2225 | | - }
|
| 2226 | | - }
|
| 2227 | | - }
|
| 2228 | | - else
|
| 2229 | | - {
|
| 2230 | | - EnableWindow(GetDlgItem(hTabs[0], IDC_DPISCALE), FALSE);
|
| 2231 | | - }
|
| 2232 | | - if(token) CloseHandle(token);
|
| 2233 | | - return TRUE;
|
| 2234 | | - case WM_MEASUREITEM:
|
| 2235 | | - switch(wParam)
|
| 2236 | | - {
|
| 2237 | | - case IDC_APPS:
|
| 2238 | | - ((LPMEASUREITEMSTRUCT)lParam)->itemHeight = GetSystemMetrics(SM_CYSMICON) + 1;
|
| 2239 | | - ((LPMEASUREITEMSTRUCT)lParam)->itemWidth = GetSystemMetrics(SM_CXSMICON)+1;
|
| 2240 | | - break;
|
| 2241 | | - default:
|
| 2242 | | - break;
|
| 2243 | | - }
|
| 2244 | | - break;
|
| 2245 | | - case WM_NOTIFY:
|
| 2246 | | - nm = (LPNMHDR)lParam;
|
| 2247 | | - if (nm->code == TCN_SELCHANGE)
|
| 2248 | | - {
|
| 2249 | | - newtab = SendDlgItemMessage(hWnd, IDC_TABS, TCM_GETCURSEL, 0, 0);
|
| 2250 | | - if (newtab != tabopen)
|
| 2251 | | - {
|
| 2252 | | - ShowWindow(hTabs[tabopen], SW_HIDE);
|
| 2253 | | - tabopen = newtab;
|
| 2254 | | - SendDlgItemMessage(hWnd, IDC_TABS, TCM_GETITEMRECT, 0, (LPARAM)&r);
|
| 2255 | | - SetWindowPos(hTabs[tabopen], NULL, r.left, r.bottom + 3, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
|
| 2256 | | - }
|
| 2257 | | - }
|
| 2258 | | - break;
|
| 2259 | | - case WM_DRAWITEM:
|
| 2260 | | - drawitem = (DRAWITEMSTRUCT*)lParam;
|
| 2261 | | - switch (wParam)
|
| 2262 | | - {
|
| 2263 | | - case IDC_APPS:
|
| 2264 | | - OldTextColor = GetTextColor(drawitem->hDC);
|
| 2265 | | - OldBackColor = GetBkColor(drawitem->hDC);
|
| 2266 | | - if((drawitem->itemState & ODS_SELECTED))
|
| 2267 | | - {
|
| 2268 | | - SetTextColor(drawitem->hDC,GetSysColor(COLOR_HIGHLIGHTTEXT));
|
| 2269 | | - SetBkColor(drawitem->hDC,GetSysColor(COLOR_HIGHLIGHT));
|
| 2270 | | - FillRect(drawitem->hDC,&drawitem->rcItem,(HBRUSH)(COLOR_HIGHLIGHT+1));
|
| 2271 | | - }
|
| 2272 | | - else
|
| 2273 | | - {
|
| 2274 | | - SetTextColor(drawitem->hDC, GetSysColor(COLOR_WINDOWTEXT));
|
| 2275 | | - SetBkColor(drawitem->hDC, GetSysColor(COLOR_WINDOW));
|
| 2276 | | - FillRect(drawitem->hDC, &drawitem->rcItem, (HBRUSH)(COLOR_WINDOW + 1));
|
| 2277 | | - }
|
| 2278 | | - DrawIconEx(drawitem->hDC,drawitem->rcItem.left+2,drawitem->rcItem.top,
|
| 2279 | | - apps[drawitem->itemID].icon,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0,NULL,DI_NORMAL);
|
| 2280 | | - drawitem->rcItem.left += GetSystemMetrics(SM_CXSMICON)+5;
|
| 2281 | | - DrawText(drawitem->hDC,apps[drawitem->itemID].name,
|
| 2282 | | - _tcslen(apps[drawitem->itemID].name),&drawitem->rcItem,
|
| 2283 | | - DT_LEFT|DT_SINGLELINE|DT_VCENTER);
|
| 2284 | | - drawitem->rcItem.left -= GetSystemMetrics(SM_CXSMICON)+5;
|
| 2285 | | - if (drawitem->itemState & ODS_FOCUS) DrawFocusRect(drawitem->hDC, &drawitem->rcItem);
|
| 2286 | | - SetTextColor(drawitem->hDC,OldTextColor);
|
| 2287 | | - SetBkColor(drawitem->hDC,OldBackColor);
|
| 2288 | | - DefWindowProc(hWnd,Msg,wParam,lParam);
|
| 2289 | | - break;
|
| 2290 | | - default:
|
| 2291 | | - break;
|
| 2292 | | - }
|
| 2293 | | - break;
|
| 2294 | | - case WM_HELP:
|
| 2295 | | - HtmlHelp(hWnd,hlppath,HH_DISPLAY_TOPIC,(DWORD_PTR)_T("configuration.htm"));
|
| 2296 | | - return TRUE;
|
| 2297 | | - break;
|
| 2298 | | - case WM_SYSCOMMAND:
|
| 2299 | | - if(LOWORD(wParam) == SC_CONTEXTHELP)
|
| 2300 | | - {
|
| 2301 | | - HtmlHelp(hWnd,hlppath,HH_DISPLAY_TOPIC,(DWORD_PTR)_T("configuration.htm"));
|
| 2302 | | - return TRUE;
|
| 2303 | | - }
|
| 2304 | | - break;
|
| 2305 | | - case WM_COMMAND:
|
| 2306 | | - switch(LOWORD(wParam))
|
| 2307 | | - {
|
| 2308 | | - case IDOK:
|
| 2309 | | - SaveChanges(hWnd);
|
| 2310 | | - EndDialog(hWnd,IDOK);
|
| 2311 | | - return TRUE;
|
| 2312 | | - case IDCANCEL:
|
| 2313 | | - EndDialog(hWnd,IDCANCEL);
|
| 2314 | | - return TRUE;
|
| 2315 | | - case IDC_APPLY:
|
| 2316 | | - SaveChanges(hWnd);
|
| 2317 | | - return TRUE;
|
| 2318 | | - case IDC_APPS:
|
| 2319 | | - if(HIWORD(wParam) == CBN_SELCHANGE)
|
| 2320 | | - {
|
| 2321 | | - cursel = SendDlgItemMessage(hWnd,IDC_APPS,CB_GETCURSEL,0,0);
|
| 2322 | | - if(cursel == current_app) break;
|
| 2323 | | - current_app = cursel;
|
| 2324 | | - cfg = &apps[current_app].cfg;
|
| 2325 | | - cfgmask = &apps[current_app].mask;
|
| 2326 | | - dirty = &apps[current_app].dirty;
|
| 2327 | | - if (current_app)
|
| 2328 | | - {
|
| 2329 | | - EnableWindow(GetDlgItem(hTabs[3], IDC_PATHLABEL), TRUE);
|
| 2330 | | - EnableWindow(GetDlgItem(hTabs[3], IDC_PROFILEPATH), TRUE);
|
| 2331 | | - SetDlgItemText(hTabs[3], IDC_PROFILEPATH, apps[current_app].path);
|
| 2332 | | - if (apps[current_app].builtin) EnableWindow(GetDlgItem(hWnd, IDC_REMOVE), FALSE);
|
| 2333 | | - else EnableWindow(GetDlgItem(hWnd, IDC_REMOVE), TRUE);
|
| 2334 | | - }
|
| 2335 | | - else
|
| 2336 | | - {
|
| 2337 | | - EnableWindow(GetDlgItem(hTabs[3], IDC_PATHLABEL), FALSE);
|
| 2338 | | - EnableWindow(GetDlgItem(hTabs[3], IDC_PROFILEPATH), FALSE);
|
| 2339 | | - SetDlgItemText(hTabs[3], IDC_PROFILEPATH, _T(""));
|
| 2340 | | - EnableWindow(GetDlgItem(hWnd, IDC_REMOVE), FALSE);
|
| 2341 | | - }
|
| 2342 | | - // Set 3-state status
|
| 2343 | | - if(current_app && !tristate)
|
| 2344 | | - {
|
| 2345 | | - tristate = TRUE;
|
| 2346 | | - // Display tab
|
| 2347 | | - SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 2348 | | - SendDlgItemMessage(hTabs[0], IDC_COLORDEPTH, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 2349 | | - SendDlgItemMessage(hTabs[0], IDC_SCALE, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 2350 | | - SendDlgItemMessage(hTabs[0], IDC_EXTRAMODES, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 2351 | | - SendDlgItemMessage(hTabs[0], IDC_ASPECT, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 2352 | | - SendDlgItemMessage(hTabs[0], IDC_SORTMODES, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 2353 | | - SendDlgItemMessage(hTabs[0], IDC_DPISCALE, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 2354 | | - SendDlgItemMessage(hTabs[0], IDC_VSYNC, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 2355 | | - SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 2356 | | - SendDlgItemMessage(hTabs[0], IDC_COLOR, BM_SETSTYLE, BS_AUTO3STATE, (LPARAM)TRUE);
|
| 2357 | | - SendDlgItemMessage(hTabs[0], IDC_SINGLEBUFFER, BM_SETSTYLE, BS_AUTO3STATE, (LPARAM)TRUE);
|
| 2358 | | - SendDlgItemMessage(hTabs[1], IDC_POSTSCALE, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 2359 | | - SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 2360 | | - SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 2361 | | - SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 2362 | | - SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 2363 | | - SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 2364 | | - SendDlgItemMessage(hTabs[2], IDC_ASPECT3D, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 2365 | | - SendDlgItemMessage(hTabs[3],IDC_TEXTUREFORMAT,CB_ADDSTRING,0,(LPARAM)strdefault);
|
| 2366 | | - SendDlgItemMessage(hTabs[3],IDC_TEXUPLOAD,CB_ADDSTRING,0,(LPARAM)strdefault);
|
| 2367 | | - }
|
| 2368 | | - else if(!current_app && tristate)
|
| 2369 | | - {
|
| 2370 | | - tristate = FALSE;
|
| 2371 | | - // Display tab
|
| 2372 | | - SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_DELETESTRING,
|
| 2373 | | - SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 2374 | | - SendDlgItemMessage(hTabs[0], IDC_COLORDEPTH, CB_DELETESTRING,
|
| 2375 | | - SendDlgItemMessage(hTabs[0], IDC_COLORDEPTH, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 2376 | | - SendDlgItemMessage(hTabs[0], IDC_SCALE, CB_DELETESTRING,
|
| 2377 | | - SendDlgItemMessage(hTabs[0], IDC_SCALE, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 2378 | | - SendDlgItemMessage(hTabs[0], IDC_EXTRAMODES, CB_DELETESTRING,
|
| 2379 | | - SendDlgItemMessage(hTabs[0], IDC_EXTRAMODES, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 2380 | | - SendDlgItemMessage(hTabs[0], IDC_ASPECT, CB_DELETESTRING,
|
| 2381 | | - SendDlgItemMessage(hTabs[0], IDC_ASPECT, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 2382 | | - SendDlgItemMessage(hTabs[0], IDC_SORTMODES, CB_DELETESTRING,
|
| 2383 | | - SendDlgItemMessage(hTabs[0], IDC_SORTMODES, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 2384 | | - SendDlgItemMessage(hTabs[0], IDC_DPISCALE, CB_DELETESTRING,
|
| 2385 | | - SendDlgItemMessage(hTabs[0], IDC_DPISCALE, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 2386 | | - SendDlgItemMessage(hTabs[0], IDC_VSYNC, CB_DELETESTRING,
|
| 2387 | | - SendDlgItemMessage(hTabs[0], IDC_VSYNC, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 2388 | | - SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_DELETESTRING,
|
| 2389 | | - SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 2390 | | - SendDlgItemMessage(hTabs[0], IDC_COLOR, BM_SETSTYLE, BS_AUTOCHECKBOX, (LPARAM)TRUE);
|
| 2391 | | - SendDlgItemMessage(hTabs[0], IDC_SINGLEBUFFER, BM_SETSTYLE, BS_AUTOCHECKBOX, (LPARAM)TRUE);
|
| 2392 | | - SendDlgItemMessage(hTabs[1], IDC_POSTSCALE, CB_DELETESTRING,
|
| 2393 | | - SendDlgItemMessage(hTabs[1], IDC_POSTSCALE, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 2394 | | - SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_DELETESTRING,
|
| 2395 | | - SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 2396 | | - SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_DELETESTRING,
|
| 2397 | | - SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 2398 | | - SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_DELETESTRING,
|
| 2399 | | - SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 2400 | | - SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_DELETESTRING,
|
| 2401 | | - SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 2402 | | - SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_DELETESTRING,
|
| 2403 | | - SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 2404 | | - SendDlgItemMessage(hTabs[2], IDC_ASPECT3D, CB_DELETESTRING,
|
| 2405 | | - SendDlgItemMessage(hTabs[2], IDC_ASPECT3D, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 2406 | | - SendDlgItemMessage(hTabs[3],IDC_TEXTUREFORMAT,CB_DELETESTRING,
|
| 2407 | | - SendDlgItemMessage(hTabs[3],IDC_ASPECT3D,CB_FINDSTRING,-1,(LPARAM)strdefault),0);
|
| 2408 | | - SendDlgItemMessage(hTabs[3],IDC_TEXUPLOAD,CB_DELETESTRING,
|
| 2409 | | - SendDlgItemMessage(hTabs[3],IDC_ASPECT3D,CB_FINDSTRING,-1,(LPARAM)strdefault),0);
|
| 2410 | | - }
|
| 2411 | | - // Read settings into controls
|
| 2412 | | - // Display tab
|
| 2413 | | - SetCombo(hTabs[0], IDC_VIDMODE, cfg->scaler, cfgmask->scaler, tristate);
|
| 2414 | | - SetCombo(hTabs[0], IDC_COLORDEPTH, 0, 0, tristate);
|
| 2415 | | - SetCombo(hTabs[0], IDC_SCALE, cfg->scalingfilter, cfgmask->scalingfilter, tristate);
|
| 2416 | | - SetCombo(hTabs[0], IDC_EXTRAMODES, 0, 0, tristate);
|
| 2417 | | - SetAspectCombo(hTabs[0], IDC_ASPECT, cfg->aspect, cfgmask->aspect, tristate);
|
| 2418 | | - SetCombo(hTabs[0], IDC_SORTMODES, cfg->SortModes, cfgmask->SortModes, tristate);
|
| 2419 | | - SetCombo(hTabs[0], IDC_DPISCALE, cfg->DPIScale, cfgmask->DPIScale, tristate);
|
| 2420 | | - SetCombo(hTabs[0], IDC_VSYNC, cfg->vsync, cfgmask->vsync, tristate);
|
| 2421 | | - SetCombo(hTabs[0], IDC_FULLMODE, cfg->fullmode, cfgmask->fullmode, tristate);
|
| 2422 | | - SetCheck(hTabs[0], IDC_COLOR, cfg->colormode, cfgmask->colormode, tristate);
|
| 2423 | | - SetCheck(hTabs[0], IDC_SINGLEBUFFER, cfg->SingleBufferDevice, cfgmask->SingleBufferDevice, tristate);
|
| 2424 | | - SetCombo(hTabs[1], IDC_POSTSCALE, cfg->postfilter, cfgmask->postfilter, tristate);
|
| 2425 | | - SetPostScaleCombo(hTabs[1], IDC_POSTSCALESIZE, cfg->postsizex, cfg->postsizey,
|
| 2426 | | - cfgmask->postsizex , cfgmask->postsizey, tristate);
|
| 2427 | | - SetCombo(hTabs[1], IDC_PRIMARYSCALE, cfg->primaryscale, cfgmask->primaryscale, tristate);
|
| 2428 | | - SetText(hTabs[1], IDC_SHADER, cfg->shaderfile, cfgmask->shaderfile, tristate);
|
| 2429 | | - SetCombo(hTabs[2], IDC_TEXFILTER, cfg->texfilter, cfgmask->texfilter, tristate);
|
| 2430 | | - SetCombo(hTabs[2], IDC_ANISO, cfg->anisotropic, cfgmask->anisotropic, tristate);
|
| 2431 | | - SetCombo(hTabs[2], IDC_MSAA, cfg->msaa, cfgmask->msaa, tristate);
|
| 2432 | | - SetCombo(hTabs[2], IDC_ASPECT3D, cfg->aspect3d, cfgmask->aspect3d, tristate);
|
| 2433 | | - SetCombo(hTabs[3],IDC_TEXTUREFORMAT,cfg->TextureFormat,cfgmask->TextureFormat,tristate);
|
| 2434 | | - SetCombo(hTabs[3],IDC_TEXUPLOAD,cfg->TexUpload,cfgmask->TexUpload,tristate);
|
| 2435 | | - RedrawWindow(GetDlgItem(hTabs[4], IDC_DEBUGLIST), NULL, NULL, RDW_INVALIDATE);
|
| 2436 | | - }
|
| 2437 | | - break;
|
| 2438 | | - case IDC_ADD:
|
| 2439 | | - selectedfile[0] = 0;
|
| 2440 | | - ZeroMemory(&filename, OPENFILENAME_SIZE_VERSION_400);
|
| 2441 | | - filename.lStructSize = OPENFILENAME_SIZE_VERSION_400;
|
| 2442 | | - filename.hwndOwner = hWnd;
|
| 2443 | | - filename.lpstrFilter = exe_filter;
|
| 2444 | | - filename.lpstrFile = selectedfile;
|
| 2445 | | - filename.nMaxFile = MAX_PATH + 1;
|
| 2446 | | - filename.lpstrInitialDir = _T("%ProgramFiles%");
|
| 2447 | | - filename.lpstrTitle = _T("Select program");
|
| 2448 | | - filename.Flags = OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
|
| 2449 | | - if (GetOpenFileName(&filename))
|
| 2450 | | - {
|
| 2451 | | - if (CheckProfileExists(filename.lpstrFile))
|
| 2452 | | - {
|
| 2453 | | - MessageBox(hWnd, _T("A profile already exists for this program."),
|
| 2454 | | - _T("Profile already exists"), MB_OK | MB_ICONWARNING);
|
| 2455 | | - break;
|
| 2456 | | - }
|
| 2457 | | - err = AddApp(filename.lpstrFile, TRUE, FALSE, FALSE, hWnd);
|
| 2458 | | - if (!err)
|
| 2459 | | - {
|
| 2460 | | - LPTSTR newkey = MakeNewConfig(filename.lpstrFile);
|
| 2461 | | - LPTSTR newkey2 = (LPTSTR)malloc((_tcslen(newkey) + 24) * sizeof(TCHAR));
|
| 2462 | | - _tcscpy(newkey2, _T("Software\\DXGL\\Profiles\\"));
|
| 2463 | | - _tcscat(newkey2, newkey);
|
| 2464 | | - appcount++;
|
| 2465 | | - if (appcount > maxapps)
|
| 2466 | | - {
|
| 2467 | | - maxapps += 128;
|
| 2468 | | - apps = (app_setting *)realloc(apps, maxapps * sizeof(app_setting));
|
| 2469 | | - }
|
| 2470 | | - RegOpenKeyEx(HKEY_CURRENT_USER, newkey2, 0, KEY_READ, &hKey);
|
| 2471 | | - RegQueryValueEx(hKey, _T("InstallPath"), NULL, NULL, NULL, &buffersize);
|
| 2472 | | - regbuffer = (LPTSTR)malloc(buffersize);
|
| 2473 | | - regbuffer[0] = 0;
|
| 2474 | | - error = RegQueryValueEx(hKey, _T("InstallPath"), NULL, NULL, (LPBYTE)regbuffer, &buffersize);
|
| 2475 | | - apps[appcount - 1].regkey = (LPTSTR)malloc((_tcslen(newkey) + 1) * sizeof(TCHAR));
|
| 2476 | | - _tcscpy(apps[appcount - 1].regkey, newkey);
|
| 2477 | | - GetConfig(&apps[appcount - 1].cfg, &apps[appcount - 1].mask, newkey);
|
| 2478 | | - apps[appcount - 1].dirty = FALSE;
|
| 2479 | | - free(newkey2);
|
| 2480 | | - if ((regbuffer[0] == 0) || error != ERROR_SUCCESS)
|
| 2481 | | - {
|
| 2482 | | - // Default icon
|
| 2483 | | - apps[appcount - 1].icon = LoadIcon(NULL, IDI_APPLICATION);
|
| 2484 | | - apps[appcount - 1].icon_shared = TRUE;
|
| 2485 | | - apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(newkey) + 1) * sizeof(TCHAR));
|
| 2486 | | - _tcscpy(apps[appcount - 1].name, newkey);
|
| 2487 | | - break;
|
| 2488 | | - }
|
| 2489 | | - if (_tcsrchr(newkey, _T('-'))) *(_tcsrchr(newkey, _T('-'))) = 0;
|
| 2490 | | - path = (LPTSTR)malloc(((_tcslen(regbuffer) + _tcslen(newkey) + 2)) * sizeof(TCHAR));
|
| 2491 | | - _tcscpy(path, regbuffer);
|
| 2492 | | - _tcscpy(apps[appcount - 1].path, path);
|
| 2493 | | - _tcscat(path, _T("\\"));
|
| 2494 | | - _tcscat(path, newkey);
|
| 2495 | | - if (GetFileAttributes(path) == INVALID_FILE_ATTRIBUTES)
|
| 2496 | | - {
|
| 2497 | | - // Default icon
|
| 2498 | | - apps[appcount - 1].icon = LoadIcon(NULL, IDI_APPLICATION);
|
| 2499 | | - apps[appcount - 1].icon_shared = TRUE;
|
| 2500 | | - apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(newkey) + 1) * sizeof(TCHAR));
|
| 2501 | | - _tcscpy(apps[appcount - 1].name, newkey);
|
| 2502 | | - break;
|
| 2503 | | - }
|
| 2504 | | - else
|
| 2505 | | - {
|
| 2506 | | - // Get exe attributes
|
| 2507 | | - error = SHGetFileInfo(path, 0, &fileinfo, sizeof(SHFILEINFO), SHGFI_ICON | SHGFI_SMALLICON | SHGFI_ADDOVERLAYS);
|
| 2508 | | - apps[appcount - 1].icon = fileinfo.hIcon;
|
| 2509 | | - apps[appcount - 1].icon_shared = FALSE;
|
| 2510 | | - verinfosize = GetFileVersionInfoSize(path, NULL);
|
| 2511 | | - verinfo = malloc(verinfosize);
|
| 2512 | | - hasname = FALSE;
|
| 2513 | | - if (GetFileVersionInfo(path, 0, verinfosize, verinfo))
|
| 2514 | | - {
|
| 2515 | | - if (VerQueryValue(verinfo, _T("\\VarFileInfo\\Translation"), (LPVOID*)&outbuffer, &outlen))
|
| 2516 | | - {
|
| 2517 | | - memcpy(translation, outbuffer, 4);
|
| 2518 | | - _sntprintf(verpath, 64, _T("\\StringFileInfo\\%04x%04x\\FileDescription"), translation[0], translation[1]);
|
| 2519 | | - if (VerQueryValue(verinfo, verpath, (LPVOID*)&outbuffer, &outlen))
|
| 2520 | | - {
|
| 2521 | | - hasname = TRUE;
|
| 2522 | | - apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(outbuffer) + 1) * sizeof(TCHAR));
|
| 2523 | | - _tcscpy(apps[appcount - 1].name, outbuffer);
|
| 2524 | | - }
|
| 2525 | | - else
|
| 2526 | | - {
|
| 2527 | | - _sntprintf(verpath, 64, _T("\\StringFileInfo\\%04x%04x\\ProductName"), ((WORD*)outbuffer)[0], ((WORD*)outbuffer)[1]);
|
| 2528 | | - if (VerQueryValue(verinfo, verpath, (LPVOID*)&outbuffer, &outlen))
|
| 2529 | | - {
|
| 2530 | | - hasname = TRUE;
|
| 2531 | | - apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(outbuffer) + 1) * sizeof(TCHAR));
|
| 2532 | | - _tcscpy(apps[appcount - 1].name, outbuffer);
|
| 2533 | | - }
|
| 2534 | | - else
|
| 2535 | | - {
|
| 2536 | | - _sntprintf(verpath, 64, _T("\\StringFileInfo\\%04x%04x\\InternalName"), ((WORD*)outbuffer)[0], ((WORD*)outbuffer)[1]);
|
| 2537 | | - if (VerQueryValue(verinfo, verpath, (LPVOID*)&outbuffer, &outlen))
|
| 2538 | | - {
|
| 2539 | | - hasname = TRUE;
|
| 2540 | | - apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(outbuffer) + 1) * sizeof(TCHAR));
|
| 2541 | | - _tcscpy(apps[appcount - 1].name, outbuffer);
|
| 2542 | | - }
|
| 2543 | | - }
|
| 2544 | | - }
|
| 2545 | | - }
|
| 2546 | | - }
|
| 2547 | | - if (!hasname)
|
| 2548 | | - {
|
| 2549 | | - apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(newkey) + 1) * sizeof(TCHAR));
|
| 2550 | | - _tcscpy(apps[appcount - 1].name, newkey);
|
| 2551 | | - }
|
| 2552 | | - free(verinfo);
|
| 2553 | | - free(path);
|
| 2554 | | - }
|
| 2555 | | - SendDlgItemMessage(hWnd, IDC_APPS, LB_SETCURSEL,
|
| 2556 | | - SendDlgItemMessage(hWnd, IDC_APPS, LB_ADDSTRING, 0, (LPARAM)apps[appcount - 1].name), 0);
|
| 2557 | | - SendMessage(hWnd, WM_COMMAND, IDC_APPS + 0x10000, 0);
|
| 2558 | | - RegCloseKey(hKey);
|
| 2559 | | - free(regbuffer);
|
| 2560 | | - }
|
| 2561 | | - }
|
| 2562 | | - break;
|
| 2563 | | - case IDC_REMOVE:
|
| 2564 | | - if(MessageBox(hWnd,_T("Do you want to delete the selected application profile and remove DXGL from its installation folder(s)?"),
|
| 2565 | | - _T("Confirmation"),MB_YESNO|MB_ICONQUESTION) != IDYES) return FALSE;
|
| 2566 | | - regpath = (LPTSTR)malloc((_tcslen(apps[current_app].regkey) + 15)*sizeof(TCHAR));
|
| 2567 | | - _tcscpy(regpath, _T("Software\\DXGL\\Profiles\\"));
|
| 2568 | | - _tcscat(regpath, apps[current_app].regkey);
|
| 2569 | | - regkey = (LPTSTR)malloc(_tcslen(apps[current_app].regkey));
|
| 2570 | | - _tcscpy(regkey, apps[current_app].regkey);
|
| 2571 | | - RegOpenKeyEx(HKEY_CURRENT_USER,regpath,0,KEY_READ,&hKey);
|
| 2572 | | - RegQueryValueEx(hKey,_T("InstallPath"),NULL,NULL,NULL,&buffersize);
|
| 2573 | | - regbuffer = (LPTSTR)malloc(buffersize);
|
| 2574 | | - regbuffer[0] = 0;
|
| 2575 | | - failed = FALSE;
|
| 2576 | | - error = RegQueryValueEx(hKey, _T("InstallPath"), NULL, NULL, (LPBYTE)regbuffer, &buffersize);
|
| 2577 | | - path = (LPTSTR)malloc(((_tcslen(regbuffer) + 12)) * sizeof(TCHAR));
|
| 2578 | | - _tcscpy(path, regbuffer);
|
| 2579 | | - _tcscat(path, _T("\\ddraw.dll"));
|
| 2580 | | - if (GetFileAttributes(path) != INVALID_FILE_ATTRIBUTES)
|
| 2581 | | - {
|
| 2582 | | - if (DelApp(path, FALSE, hWnd)) failed = TRUE;
|
| 2583 | | - }
|
| 2584 | | - free(path);
|
| 2585 | | - free(regbuffer);
|
| 2586 | | - RegCloseKey(hKey);
|
| 2587 | | - if(!failed)
|
| 2588 | | - {
|
| 2589 | | - RegDeleteKey(HKEY_CURRENT_USER,regpath);
|
| 2590 | | - if(!apps[current_app].icon_shared) DeleteObject(apps[current_app].icon);
|
| 2591 | | - if(apps[current_app].name) free(apps[current_app].name);
|
| 2592 | | - if(apps[current_app].regkey) free(apps[current_app].regkey);
|
| 2593 | | - for(i = current_app; i < appcount; i++)
|
| 2594 | | - {
|
| 2595 | | - apps[i] = apps[i+1];
|
| 2596 | | - }
|
| 2597 | | - appcount--;
|
| 2598 | | - }
|
| 2599 | | - SendDlgItemMessage(hWnd,IDC_APPS,LB_DELETESTRING,current_app,0);
|
| 2600 | | - SendDlgItemMessage(hWnd, IDC_APPS, LB_SETCURSEL, 0, 0);
|
| 2601 | | - SendMessage(hWnd, WM_COMMAND, IDC_APPS + 0x10000, 0);
|
| 2602 | | - break;
|
| 2603 | | - }
|
| 2604 | | - break;
|
| 2605 | | - }
|
| 2606 | | - return FALSE;
|
| 2607 | | -}
|
| 2608 | | -
|
| 2609 | | -void UpgradeDXGL()
|
| 2610 | | -{
|
| 2611 | | - HKEY hKeyBase;
|
| 2612 | | - HKEY hKey;
|
| 2613 | | - DWORD keysize, keysize2;
|
| 2614 | | - int i = 0;
|
| 2615 | | - LONG error;
|
| 2616 | | - LPTSTR keyname;
|
| 2617 | | - DWORD sizeout;
|
| 2618 | | - DWORD buffersize;
|
| 2619 | | - DWORD regbuffersize;
|
| 2620 | | - LPTSTR regbuffer;
|
| 2621 | | - BOOL installed = FALSE;
|
| 2622 | | - BOOL dxgl_installdir = FALSE;
|
| 2623 | | - BOOL old_dxgl = FALSE;
|
| 2624 | | - HKEY hKeyInstall;
|
| 2625 | | - TCHAR installpath[MAX_PATH + 1];
|
| 2626 | | - TCHAR srcpath[MAX_PATH + 1];
|
| 2627 | | - TCHAR destpath[MAX_PATH + 1];
|
| 2628 | | - TCHAR inipath[MAX_PATH + 1];
|
| 2629 | | - TCHAR backuppath[MAX_PATH + 1];
|
| 2630 | | - app_ini_options inioptions;
|
| 2631 | | - HMODULE hmod;
|
| 2632 | | - UpgradeConfig();
|
| 2633 | | - regbuffersize = 1024;
|
| 2634 | | - regbuffer = (LPTSTR)malloc(regbuffersize * sizeof(TCHAR));
|
| 2635 | | - RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\DXGL\\Profiles"), 0, NULL, 0, KEY_READ, NULL, &hKeyBase, NULL);
|
| 2636 | | - RegQueryInfoKey(hKeyBase, NULL, NULL, NULL, NULL, &keysize, NULL, NULL, NULL, NULL, NULL, NULL);
|
| 2637 | | - keysize++;
|
| 2638 | | - keyname = (LPTSTR)malloc(keysize * sizeof(TCHAR));
|
| 2639 | | - keysize2 = keysize;
|
| 2640 | | - error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\DXGL"), 0, KEY_READ, &hKeyInstall);
|
| 2641 | | - if (error == ERROR_SUCCESS)
|
| 2642 | | - {
|
| 2643 | | - dxgl_installdir = TRUE;
|
| 2644 | | - sizeout = (MAX_PATH + 1) * sizeof(TCHAR);
|
| 2645 | | - error = RegQueryValueEx(hKeyInstall, _T("InstallDir"), NULL, NULL, (LPBYTE)installpath, &sizeout);
|
| 2646 | | - if (error == ERROR_SUCCESS) installed = TRUE;
|
| 2647 | | - }
|
| 2648 | | - if (hKeyInstall) RegCloseKey(hKeyInstall);
|
| 2649 | | - if (!installed)
|
| 2650 | | - {
|
| 2651 | | - GetModuleFileName(NULL, installpath, MAX_PATH + 1);
|
| 2652 | | - }
|
| 2653 | | - if (dxgl_installdir) _tcscat(installpath, _T("\\"));
|
| 2654 | | - else (_tcsrchr(installpath, _T('\\')))[1] = 0;
|
| 2655 | | - _tcsncpy(srcpath, installpath, MAX_PATH + 1);
|
| 2656 | | - _tcscat(srcpath, _T("ddraw.dll"));
|
| 2657 | | - while (RegEnumKeyEx(hKeyBase, i, keyname, &keysize2, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
| 2658 | | - {
|
| 2659 | | - keysize2 = keysize;
|
| 2660 | | - i++;
|
| 2661 | | - error = RegOpenKeyEx(hKeyBase, keyname, 0, KEY_READ, &hKey);
|
| 2662 | | - buffersize = regbuffersize;
|
| 2663 | | - RegQueryValueEx(hKey, _T("InstallPath"), NULL, NULL, NULL, &buffersize);
|
| 2664 | | - if (buffersize > regbuffersize)
|
| 2665 | | - {
|
| 2666 | | - regbuffersize = buffersize;
|
| 2667 | | - regbuffer = (LPTSTR)realloc(regbuffer, regbuffersize);
|
| 2668 | | - }
|
| 2669 | | - buffersize = regbuffersize;
|
| 2670 | | - regbuffer[0] = 0;
|
| 2671 | | - error = RegQueryValueEx(hKey, _T("InstallPath"), NULL, NULL, (LPBYTE)regbuffer, &buffersize);
|
| 2672 | | - if (regbuffer[0] != 0)
|
| 2673 | | - {
|
| 2674 | | - _tcsncpy(destpath, regbuffer, MAX_PATH + 1);
|
| 2675 | | - _tcscat(destpath, _T("\\ddraw.dll"));
|
| 2676 | | - _tcsncpy(inipath, regbuffer, MAX_PATH + 1);
|
| 2677 | | - _tcscat(inipath, _T("\\"));
|
| 2678 | | - _tcsncpy(backuppath, regbuffer, MAX_PATH + 1);
|
| 2679 | | - _tcscat(backuppath, _T("\\ddraw.dll.dxgl-backup"));
|
| 2680 | | - ReadAppINIOptions(inipath, &inioptions);
|
| 2681 | | - error = CopyFile(srcpath, destpath, TRUE);
|
| 2682 | | - if (!error)
|
| 2683 | | - {
|
| 2684 | | - error = GetLastError();
|
| 2685 | | - if (error == ERROR_FILE_EXISTS)
|
| 2686 | | - {
|
| 2687 | | - if (inioptions.NoOverwrite) continue;
|
| 2688 | | - if ((inioptions.sha256[0] != 0) && !memcmp(inioptions.sha256, inioptions.sha256comp, 64))
|
| 2689 | | - // Detected original ddraw matches INI hash
|
| 2690 | | - CopyFile(srcpath, backuppath, FALSE);
|
| 2691 | | - old_dxgl = FALSE;
|
| 2692 | | - error = SetErrorMode(SEM_FAILCRITICALERRORS);
|
| 2693 | | - SetErrorMode(error | SEM_FAILCRITICALERRORS);
|
| 2694 | | - hmod = LoadLibrary(destpath);
|
| 2695 | | - SetErrorMode(error);
|
| 2696 | | - if (hmod)
|
| 2697 | | - {
|
| 2698 | | - if (GetProcAddress(hmod, "IsDXGLDDraw")) old_dxgl = TRUE;
|
| 2699 | | - FreeLibrary(hmod);
|
| 2700 | | - }
|
| 2701 | | - if (old_dxgl) CopyFile(srcpath, destpath, FALSE);
|
| 2702 | | - }
|
| 2703 | | - }
|
| 2704 | | - }
|
| 2705 | | - RegCloseKey(hKey);
|
| 2706 | | - }
|
| 2707 | | - free(regbuffer);
|
| 2708 | | - free(keyname);
|
| 2709 | | - RegCloseKey(hKeyBase);
|
| 2710 | | -}
|
| 2711 | | -
|
| 2712 | | -// '0' for keep, '1' for remove, personal settings
|
| 2713 | | -void UninstallDXGL(TCHAR uninstall)
|
| 2714 | | -{
|
| 2715 | | - HKEY hKeyBase;
|
| 2716 | | - HKEY hKey;
|
| 2717 | | - DWORD keysize, keysize2;
|
| 2718 | | - LONG error;
|
| 2719 | | - LPTSTR keyname;
|
| 2720 | | - DWORD sizeout;
|
| 2721 | | - DWORD buffersize;
|
| 2722 | | - DWORD regbuffersize;
|
| 2723 | | - LPTSTR regbuffer;
|
| 2724 | | - BOOL installed = FALSE;
|
| 2725 | | - BOOL dxgl_installdir = FALSE;
|
| 2726 | | - BOOL old_dxgl = FALSE;
|
| 2727 | | - HKEY hKeyInstall;
|
| 2728 | | - TCHAR installpath[MAX_PATH + 1];
|
| 2729 | | - TCHAR srcpath[MAX_PATH + 1];
|
| 2730 | | - TCHAR destpath[MAX_PATH + 1];
|
| 2731 | | - TCHAR inipath[MAX_PATH + 1];
|
| 2732 | | - TCHAR backuppath[MAX_PATH + 1];
|
| 2733 | | - HANDLE exists;
|
| 2734 | | - app_ini_options inioptions;
|
| 2735 | | - HMODULE hmod;
|
| 2736 | | - int i = 0;
|
| 2737 | | - UpgradeConfig(); // Just to make sure the registry format is correct
|
| 2738 | | - regbuffersize = 1024;
|
| 2739 | | - regbuffer = (LPTSTR)malloc(regbuffersize * sizeof(TCHAR));
|
| 2740 | | - error = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\DXGL\\Profiles"), 0, KEY_ALL_ACCESS, &hKeyBase);
|
| 2741 | | - if (error != ERROR_SUCCESS) return;
|
| 2742 | | - RegQueryInfoKey(hKeyBase, NULL, NULL, NULL, NULL, &keysize, NULL, NULL, NULL, NULL, NULL, NULL);
|
| 2743 | | - keysize++;
|
| 2744 | | - keyname = (LPTSTR)malloc(keysize * sizeof(TCHAR));
|
| 2745 | | - keysize2 = keysize;
|
| 2746 | | - error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\DXGL"), 0, KEY_READ, &hKeyInstall);
|
| 2747 | | - if (error == ERROR_SUCCESS)
|
| 2748 | | - {
|
| 2749 | | - dxgl_installdir = TRUE;
|
| 2750 | | - sizeout = (MAX_PATH + 1) * sizeof(TCHAR);
|
| 2751 | | - error = RegQueryValueEx(hKeyInstall, _T("InstallDir"), NULL, NULL, (LPBYTE)installpath, &sizeout);
|
| 2752 | | - if (error == ERROR_SUCCESS) installed = TRUE;
|
| 2753 | | - }
|
| 2754 | | - if (hKeyInstall) RegCloseKey(hKeyInstall);
|
| 2755 | | - if (!installed)
|
| 2756 | | - {
|
| 2757 | | - GetModuleFileName(NULL, installpath, MAX_PATH + 1);
|
| 2758 | | - }
|
| 2759 | | - if (dxgl_installdir) _tcscat(installpath, _T("\\"));
|
| 2760 | | - else (_tcsrchr(installpath, _T('\\')))[1] = 0;
|
| 2761 | | - _tcsncpy(srcpath, installpath, MAX_PATH + 1);
|
| 2762 | | - _tcscat(srcpath, _T("ddraw.dll"));
|
| 2763 | | - while (RegEnumKeyEx(hKeyBase, i, keyname, &keysize2, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
| 2764 | | - {
|
| 2765 | | - keysize2 = keysize;
|
| 2766 | | - i++;
|
| 2767 | | - error = RegOpenKeyEx(hKeyBase, keyname, 0, KEY_READ, &hKey);
|
| 2768 | | - buffersize = regbuffersize;
|
| 2769 | | - if (buffersize > regbuffersize)
|
| 2770 | | - {
|
| 2771 | | - regbuffersize = buffersize;
|
| 2772 | | - regbuffer = (LPTSTR)realloc(regbuffer, regbuffersize);
|
| 2773 | | - }
|
| 2774 | | - buffersize = regbuffersize;
|
| 2775 | | - regbuffer[0] = 0;
|
| 2776 | | - error = RegQueryValueEx(hKey, _T("InstallPath"), NULL, NULL, (LPBYTE)regbuffer, &buffersize);
|
| 2777 | | - if (regbuffer[0] != 0)
|
| 2778 | | - {
|
| 2779 | | - _tcsncpy(destpath, regbuffer, MAX_PATH + 1);
|
| 2780 | | - _tcscat(destpath, _T("\\ddraw.dll"));
|
| 2781 | | - _tcsncpy(inipath, regbuffer, MAX_PATH + 1);
|
| 2782 | | - _tcscat(inipath, _T("\\"));
|
| 2783 | | - _tcsncpy(backuppath, regbuffer, MAX_PATH + 1);
|
| 2784 | | - _tcscat(backuppath, _T("\\ddraw.dll.dxgl-backup"));
|
| 2785 | | - ReadAppINIOptions(inipath, &inioptions);
|
| 2786 | | - if (inioptions.NoOverwrite || inioptions.NoUninstall) continue;
|
| 2787 | | - if (GetFileAttributes(destpath) != INVALID_FILE_ATTRIBUTES)
|
| 2788 | | - {
|
| 2789 | | - old_dxgl = FALSE;
|
| 2790 | | - error = SetErrorMode(SEM_FAILCRITICALERRORS);
|
| 2791 | | - SetErrorMode(error | SEM_FAILCRITICALERRORS);
|
| 2792 | | - hmod = LoadLibrary(destpath);
|
| 2793 | | - SetErrorMode(error);
|
| 2794 | | - if (hmod)
|
| 2795 | | - {
|
| 2796 | | - if (GetProcAddress(hmod, "IsDXGLDDraw")) old_dxgl = TRUE;
|
| 2797 | | - FreeLibrary(hmod);
|
| 2798 | | - }
|
| 2799 | | - if (_tcscmp(srcpath, destpath))
|
| 2800 | | - {
|
| 2801 | | - if (old_dxgl)
|
| 2802 | | - {
|
| 2803 | | - DeleteFile(destpath);
|
| 2804 | | - exists = CreateFile(backuppath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
| 2805 | | - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
| 2806 | | - if (exists == INVALID_HANDLE_VALUE) continue;
|
| 2807 | | - else
|
| 2808 | | - {
|
| 2809 | | - CloseHandle(exists);
|
| 2810 | | - MoveFile(backuppath, destpath);
|
| 2811 | | - }
|
| 2812 | | - }
|
| 2813 | | - }
|
| 2814 | | - }
|
| 2815 | | - }
|
| 2816 | | - RegCloseKey(hKey);
|
| 2817 | | - }
|
| 2818 | | - free(regbuffer);
|
| 2819 | | - RegQueryInfoKey(hKeyBase, NULL, NULL, NULL, NULL, &keysize, NULL, NULL, NULL, NULL, NULL, NULL);
|
| 2820 | | - keysize++;
|
| 2821 | | - if (uninstall == '1') // Delete user settings
|
| 2822 | | - {
|
| 2823 | | - while (RegEnumKeyEx(hKeyBase, 0, keyname, &keysize2, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
| 2824 | | - {
|
| 2825 | | - keysize2 = keysize;
|
| 2826 | | - i++;
|
| 2827 | | - RegDeleteKey(hKeyBase, keyname);
|
| 2828 | | - }
|
| 2829 | | - RegCloseKey(hKeyBase);
|
| 2830 | | - RegDeleteKey(HKEY_CURRENT_USER, _T("Software\\DXGL\\Profiles"));
|
| 2831 | | - RegDeleteKey(HKEY_CURRENT_USER, _T("Software\\DXGL\\Global"));
|
| 2832 | | - RegDeleteKey(HKEY_CURRENT_USER, _T("Software\\DXGL"));
|
| 2833 | | - }
|
| 2834 | | - else RegCloseKey(hKeyBase);
|
| 2835 | | -}
|
| 2836 | | -
|
| 2837 | | -int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
|
| 2838 | | -{
|
| 2839 | | - INITCOMMONCONTROLSEX icc;
|
| 2840 | | - HMODULE comctl32;
|
| 2841 | | - BOOL(WINAPI *iccex)(LPINITCOMMONCONTROLSEX lpInitCtrls);
|
| 2842 | | - HANDLE hMutex;
|
| 2843 | | - HWND hWnd;
|
| 2844 | | - osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
| 2845 | | - GetVersionEx(&osver);
|
| 2846 | | - CoInitialize(NULL);
|
| 2847 | | - if (!_tcsnicmp(lpCmdLine, _T("upgrade"), 7))
|
| 2848 | | - {
|
| 2849 | | - UpgradeDXGL();
|
| 2850 | | - return 0;
|
| 2851 | | - }
|
| 2852 | | - if (!_tcsnicmp(lpCmdLine, _T("uninstall"), 9))
|
| 2853 | | - {
|
| 2854 | | - UninstallDXGL(lpCmdLine[10]);
|
| 2855 | | - return 0;
|
| 2856 | | - }
|
| 2857 | | - if(!_tcsnicmp(lpCmdLine,_T("install "),8))
|
| 2858 | | - {
|
| 2859 | | - return AddApp(lpCmdLine+8,TRUE,TRUE,FALSE,NULL);
|
| 2860 | | - }
|
| 2861 | | - if(!_tcsnicmp(lpCmdLine,_T("forceinstall "),13))
|
| 2862 | | - {
|
| 2863 | | - return AddApp(lpCmdLine+8,TRUE,TRUE,TRUE,NULL);
|
| 2864 | | - }
|
| 2865 | | - if(!_tcsnicmp(lpCmdLine,_T("remove "),7))
|
| 2866 | | - {
|
| 2867 | | - return DelApp(lpCmdLine+7,TRUE,NULL);
|
| 2868 | | - }
|
| 2869 | | - icc.dwSize = sizeof(icc);
|
| 2870 | | - icc.dwICC = ICC_WIN95_CLASSES;
|
| 2871 | | - comctl32 = LoadLibrary(_T("comctl32.dll"));
|
| 2872 | | - iccex = (BOOL (WINAPI *)(LPINITCOMMONCONTROLSEX))GetProcAddress(comctl32,"InitCommonControlsEx");
|
| 2873 | | - if(iccex) iccex(&icc);
|
| 2874 | | - else InitCommonControls();
|
| 2875 | | - hinstance = hInstance;
|
| 2876 | | - GetModuleFileName(NULL,hlppath,MAX_PATH);
|
| 2877 | | - GetDirFromPath(hlppath);
|
| 2878 | | - _tcscat(hlppath,_T("\\dxgl.chm"));
|
| 2879 | | - hMutex = CreateMutex(NULL, TRUE, _T("DXGLConfigMutex"));
|
| 2880 | | - if (GetLastError() == ERROR_ALREADY_EXISTS)
|
| 2881 | | - {
|
| 2882 | | - // Find DXGL Config window
|
| 2883 | | - hWnd = FindWindow(NULL, _T("DXGL Config"));
|
| 2884 | | - // Focus DXGL Config window
|
| 2885 | | - if (hWnd) SetForegroundWindow(hWnd);
|
| 2886 | | - return 0;
|
| 2887 | | - }
|
| 2888 | | - DialogBox(hInstance,MAKEINTRESOURCE(IDD_DXGLCFG),0,(DLGPROC)DXGLCfgCallback);
|
| 2889 | | - ReleaseMutex(hMutex);
|
| 2890 | | - CloseHandle(hMutex);
|
| 2891 | | -#ifdef _DEBUG
|
| 2892 | | - _CrtDumpMemoryLeaks();
|
| 2893 | | -#endif
|
| 2894 | | - return 0;
|
| 2895 | | -}
|
| Index: dxglcfg-old |
| Property changes on: dxglcfg-old |
| ___________________________________________________________________ |
| Modified: svn:ignore |
| ## -7,3 +7,4 ## |
| 2896 | 1 | *.layout |
| 2897 | 2 | dxglcfg.vcxproj.user |
| 2898 | 3 | Debug No MSVCRT |
| | 4 | +*.user |
| Index: dxglcfg/dxglcfg.cpp |
| — | — | @@ -0,0 +1,2889 @@ |
| | 2 | +// DXGL
|
| | 3 | +// Copyright (C) 2011-2017 William Feely
|
| | 4 | +
|
| | 5 | +// This library is free software; you can redistribute it and/or
|
| | 6 | +// modify it under the terms of the GNU Lesser General Public
|
| | 7 | +// License as published by the Free Software Foundation; either
|
| | 8 | +// version 2.1 of the License, or (at your option) any later version.
|
| | 9 | +
|
| | 10 | +// This library is distributed in the hope that it will be useful,
|
| | 11 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| | 12 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| | 13 | +// Lesser General Public License for more details.
|
| | 14 | +
|
| | 15 | +// You should have received a copy of the GNU Lesser General Public
|
| | 16 | +// License along with this library; if not, write to the Free Software
|
| | 17 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| | 18 | +
|
| | 19 | +#define _WIN32_WINNT 0x0600
|
| | 20 | +#define _WIN32_IE 0x0300
|
| | 21 | +#define _CRT_SECURE_NO_WARNINGS
|
| | 22 | +#define _CRTDBG_MAP_ALLOC
|
| | 23 | +#include <stdlib.h>
|
| | 24 | +#include <crtdbg.h>
|
| | 25 | +#include <windows.h>
|
| | 26 | +#include <HtmlHelp.h>
|
| | 27 | +#include <CommCtrl.h>
|
| | 28 | +#include <string.h>
|
| | 29 | +#include <tchar.h>
|
| | 30 | +#include <stdio.h>
|
| | 31 | +#include <float.h>
|
| | 32 | +#include <math.h>
|
| | 33 | +#include <io.h>
|
| | 34 | +#include <Uxtheme.h>
|
| | 35 | +#include <Vsstyle.h>
|
| | 36 | +#include "resource.h"
|
| | 37 | +#include "../cfgmgr/LibSha256.h"
|
| | 38 | +#include "../cfgmgr/cfgmgr.h"
|
| | 39 | +#include <gl/GL.h>
|
| | 40 | +#include "../ddraw/include/GL/glext.h"
|
| | 41 | +
|
| | 42 | +#ifndef SHGFI_ADDOVERLAYS
|
| | 43 | +#define SHGFI_ADDOVERLAYS 0x000000020
|
| | 44 | +#endif //SHGFI_ADDOVERLAYS
|
| | 45 | +
|
| | 46 | +#ifndef BCM_SETSHIELD
|
| | 47 | +#define BCM_SETSHIELD 0x160C
|
| | 48 | +#endif
|
| | 49 | +
|
| | 50 | +DXGLCFG *cfg;
|
| | 51 | +DXGLCFG *cfgmask;
|
| | 52 | +BOOL *dirty;
|
| | 53 | +HINSTANCE hinstance;
|
| | 54 | +BOOL msaa = FALSE;
|
| | 55 | +const char *extensions_string = NULL;
|
| | 56 | +OSVERSIONINFO osver;
|
| | 57 | +TCHAR hlppath[MAX_PATH+16];
|
| | 58 | +HMODULE uxtheme = NULL;
|
| | 59 | +HTHEME hThemeDisplay = NULL;
|
| | 60 | +HTHEME(WINAPI *_OpenThemeData)(HWND hwnd, LPCWSTR pszClassList) = NULL;
|
| | 61 | +HRESULT(WINAPI *_CloseThemeData)(HTHEME hTheme) = NULL;
|
| | 62 | +HRESULT(WINAPI *_DrawThemeBackground)(HTHEME hTheme, HDC hdc, int iPartID,
|
| | 63 | + int iStateID, const RECT *pRect, const RECT *pClipRect) = NULL;
|
| | 64 | +HRESULT(WINAPI *_EnableThemeDialogTexture)(HWND hwnd, DWORD dwFlags) = NULL;
|
| | 65 | +static BOOL ExtraModes_Dropdown = FALSE;
|
| | 66 | +static BOOL ColorDepth_Dropdown = FALSE;
|
| | 67 | +static HWND hDialog = NULL;
|
| | 68 | +
|
| | 69 | +
|
| | 70 | +typedef struct
|
| | 71 | +{
|
| | 72 | + LPTSTR regkey;
|
| | 73 | + LPTSTR name;
|
| | 74 | + HICON icon;
|
| | 75 | + BOOL icon_shared;
|
| | 76 | + BOOL dirty;
|
| | 77 | + DXGLCFG cfg;
|
| | 78 | + DXGLCFG mask;
|
| | 79 | + TCHAR path[MAX_PATH];
|
| | 80 | + BOOL builtin;
|
| | 81 | +} app_setting;
|
| | 82 | +
|
| | 83 | +TCHAR exe_filter[] = _T("Program Files\0*.exe\0All Files\0*.*\0\0");
|
| | 84 | +
|
| | 85 | +app_setting *apps;
|
| | 86 | +int appcount;
|
| | 87 | +int maxapps;
|
| | 88 | +DWORD current_app;
|
| | 89 | +BOOL tristate;
|
| | 90 | +TCHAR strdefault[] = _T("(global default)");
|
| | 91 | +HWND hTab;
|
| | 92 | +HWND hTabs[6];
|
| | 93 | +int tabopen;
|
| | 94 | +
|
| | 95 | +static const TCHAR *colormodes[32] = {
|
| | 96 | + _T("None"),
|
| | 97 | + _T("8-bit"),
|
| | 98 | + _T("15-bit"),
|
| | 99 | + _T("8/15-bit"),
|
| | 100 | + _T("16-bit"),
|
| | 101 | + _T("8/16-bit"),
|
| | 102 | + _T("15/16-bit"),
|
| | 103 | + _T("8/15/16-bit"),
|
| | 104 | + _T("24-bit"),
|
| | 105 | + _T("8/24-bit"),
|
| | 106 | + _T("15/24-bit"),
|
| | 107 | + _T("8/15/24-bit"),
|
| | 108 | + _T("16/24-bit"),
|
| | 109 | + _T("8/16/24-bit"),
|
| | 110 | + _T("15/16/24-bit"),
|
| | 111 | + _T("8/15/16/24-bit"),
|
| | 112 | + _T("32-bit"),
|
| | 113 | + _T("8/32-bit"),
|
| | 114 | + _T("15/32-bit"),
|
| | 115 | + _T("8/15/32-bit"),
|
| | 116 | + _T("16/32-bit"),
|
| | 117 | + _T("8/16/32-bit"),
|
| | 118 | + _T("15/16/32-bit"),
|
| | 119 | + _T("8/15/16/32-bit"),
|
| | 120 | + _T("24/32-bit"),
|
| | 121 | + _T("8/24/32-bit"),
|
| | 122 | + _T("15/24/32-bit"),
|
| | 123 | + _T("8/15/24/32-bit"),
|
| | 124 | + _T("16/24/32-bit"),
|
| | 125 | + _T("8/16/24/32-bit"),
|
| | 126 | + _T("15/16/24/32-bit"),
|
| | 127 | + _T("8/15/16/24/32-bit")
|
| | 128 | +};
|
| | 129 | +
|
| | 130 | +static const TCHAR *colormodedropdown[5] = {
|
| | 131 | + _T("8-bit"),
|
| | 132 | + _T("15-bit"),
|
| | 133 | + _T("16-bit"),
|
| | 134 | + _T("24-bit"),
|
| | 135 | + _T("32-bit")
|
| | 136 | +};
|
| | 137 | +
|
| | 138 | +static const TCHAR *extramodes[7] = {
|
| | 139 | + _T("Common low resolutions"),
|
| | 140 | + _T("Uncommon low resolutions"),
|
| | 141 | + _T("Uncommon SD resolutions"),
|
| | 142 | + _T("High Definition resolutions"),
|
| | 143 | + _T("Ultra-HD resolutions"),
|
| | 144 | + _T("Ultra-HD above 4k"),
|
| | 145 | + _T("Very uncommon resolutions")
|
| | 146 | +};
|
| | 147 | +
|
| | 148 | +DWORD AddApp(LPCTSTR path, BOOL copyfile, BOOL admin, BOOL force, HWND hwnd)
|
| | 149 | +{
|
| | 150 | + BOOL installed = FALSE;
|
| | 151 | + BOOL dxgl_installdir = FALSE;
|
| | 152 | + BOOL old_dxgl = TRUE;
|
| | 153 | + BOOL backupped = FALSE;
|
| | 154 | + TCHAR command[MAX_PATH + 37];
|
| | 155 | + SHELLEXECUTEINFO shex;
|
| | 156 | + DWORD exitcode;
|
| | 157 | + app_ini_options inioptions;
|
| | 158 | + HMODULE hmod;
|
| | 159 | + if (copyfile)
|
| | 160 | + {
|
| | 161 | + DWORD sizeout = (MAX_PATH + 1) * sizeof(TCHAR);
|
| | 162 | + TCHAR installpath[MAX_PATH + 1];
|
| | 163 | + TCHAR srcpath[MAX_PATH + 1];
|
| | 164 | + TCHAR inipath[MAX_PATH + 1];
|
| | 165 | + TCHAR backuppath[MAX_PATH + 1];
|
| | 166 | + TCHAR destpath[MAX_PATH + 1];
|
| | 167 | + HKEY hKeyInstall;
|
| | 168 | + LONG error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\DXGL"), 0, KEY_READ, &hKeyInstall);
|
| | 169 | + if (error == ERROR_SUCCESS)
|
| | 170 | + {
|
| | 171 | + dxgl_installdir = TRUE;
|
| | 172 | + error = RegQueryValueEx(hKeyInstall, _T("InstallDir"), NULL, NULL, (LPBYTE)installpath, &sizeout);
|
| | 173 | + if (error == ERROR_SUCCESS) installed = TRUE;
|
| | 174 | + }
|
| | 175 | + if (hKeyInstall) RegCloseKey(hKeyInstall);
|
| | 176 | + if (!installed)
|
| | 177 | + {
|
| | 178 | + GetModuleFileName(NULL, installpath, MAX_PATH + 1);
|
| | 179 | + }
|
| | 180 | + if (dxgl_installdir) _tcscat(installpath, _T("\\"));
|
| | 181 | + else (_tcsrchr(installpath, _T('\\')))[1] = 0;
|
| | 182 | + _tcsncpy(srcpath, installpath, MAX_PATH + 1);
|
| | 183 | + _tcscat(srcpath, _T("ddraw.dll"));
|
| | 184 | + _tcsncpy(destpath, path, MAX_PATH + 1);
|
| | 185 | + (_tcsrchr(destpath, _T('\\')))[1] = 0;
|
| | 186 | + _tcscat(destpath, _T("ddraw.dll"));
|
| | 187 | + _tcsncpy(backuppath, path, MAX_PATH + 1);
|
| | 188 | + (_tcsrchr(backuppath, _T('\\')))[1] = 0;
|
| | 189 | + _tcscat(backuppath, _T("ddraw.dll.dxgl-backup"));
|
| | 190 | + _tcsncpy(inipath, path, MAX_PATH + 1);
|
| | 191 | + (_tcsrchr(inipath, _T('\\')))[1] = 0;
|
| | 192 | + // Check for DXGL ini file and existing ddraw.dll
|
| | 193 | + ReadAppINIOptions(inipath, &inioptions);
|
| | 194 | + error = CopyFile(srcpath, destpath, TRUE);
|
| | 195 | + error_loop:
|
| | 196 | + if (!error)
|
| | 197 | + {
|
| | 198 | + error = GetLastError();
|
| | 199 | + if (error == ERROR_FILE_EXISTS)
|
| | 200 | + {
|
| | 201 | + if (inioptions.NoOverwrite)
|
| | 202 | + {
|
| | 203 | + MessageBox(hwnd, _T("Cannot install DXGL. An INI file has \
|
| | 204 | +been placed in your game folder prohibiting overwriting the existing DirectDraw \
|
| | 205 | +library.\r\n\r\nIf you want to install DXGL, edit the dxgl.ini file in your game \
|
| | 206 | +folder and set the NoOverwite value to false.\r\n\r\n\
|
| | 207 | +A profile will still be created for your game but may not be compatible with the \
|
| | 208 | +DirectDraw library in your game folder."), _T("Error"), MB_OK | MB_ICONERROR);
|
| | 209 | + return 0; // Continue to install registry key anyway
|
| | 210 | + }
|
| | 211 | + if ((inioptions.sha256[0] != 0) && !memcmp(inioptions.sha256, inioptions.sha256comp, 64))
|
| | 212 | + // Detected original ddraw matches INI hash
|
| | 213 | + {
|
| | 214 | + error = CopyFile(destpath, backuppath, FALSE);
|
| | 215 | + if (!error)
|
| | 216 | + {
|
| | 217 | + error = GetLastError();
|
| | 218 | + if ((error == ERROR_ACCESS_DENIED) && !admin)
|
| | 219 | + {
|
| | 220 | + _tcscpy(command, _T(" install "));
|
| | 221 | + _tcscat(command, path);
|
| | 222 | + ZeroMemory(&shex, sizeof(SHELLEXECUTEINFO));
|
| | 223 | + shex.cbSize = sizeof(SHELLEXECUTEINFO);
|
| | 224 | + shex.lpVerb = _T("runas");
|
| | 225 | + shex.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| | 226 | + _tcscat(installpath, _T("\\dxglcfg.exe"));
|
| | 227 | + shex.lpFile = installpath;
|
| | 228 | + shex.lpParameters = command;
|
| | 229 | + ShellExecuteEx(&shex);
|
| | 230 | + WaitForSingleObject(shex.hProcess, INFINITE);
|
| | 231 | + GetExitCodeProcess(shex.hProcess, &exitcode);
|
| | 232 | + return exitcode;
|
| | 233 | + }
|
| | 234 | + }
|
| | 235 | + else backupped = TRUE;
|
| | 236 | + }
|
| | 237 | + error = SetErrorMode(SEM_FAILCRITICALERRORS);
|
| | 238 | + SetErrorMode(error | SEM_FAILCRITICALERRORS);
|
| | 239 | + hmod = LoadLibrary(destpath);
|
| | 240 | + SetErrorMode(error);
|
| | 241 | + if(hmod)
|
| | 242 | + {
|
| | 243 | + if(GetProcAddress(hmod,"IsDXGLDDraw") || force) old_dxgl = TRUE;
|
| | 244 | + else old_dxgl = FALSE;
|
| | 245 | + FreeLibrary(hmod);
|
| | 246 | + }
|
| | 247 | + else
|
| | 248 | + {
|
| | 249 | + if (force) old_dxgl = TRUE;
|
| | 250 | + else old_dxgl = FALSE;
|
| | 251 | + }
|
| | 252 | + if(old_dxgl)
|
| | 253 | + {
|
| | 254 | + error = CopyFile(srcpath,destpath,FALSE);
|
| | 255 | + goto error_loop;
|
| | 256 | + }
|
| | 257 | + else
|
| | 258 | + {
|
| | 259 | + // Prompt to overwrite
|
| | 260 | + if (MessageBox(hwnd, _T("A custom DirectDraw library has been detected in \
|
| | 261 | +your game folder. Would you like to replace it with DXGL?\r\n\r\n\
|
| | 262 | +Warning: Installing DXGL will remove any customizations that the existing custom DirectDraw \
|
| | 263 | +library may have."), _T("DXGL Config"), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) == IDYES)
|
| | 264 | + {
|
| | 265 | + error = CopyFile(srcpath, destpath, FALSE);
|
| | 266 | + goto error_loop;
|
| | 267 | + }
|
| | 268 | + else
|
| | 269 | + {
|
| | 270 | + if (backupped) DeleteFile(backuppath);
|
| | 271 | + }
|
| | 272 | + }
|
| | 273 | + }
|
| | 274 | + if((error == ERROR_ACCESS_DENIED) && !admin)
|
| | 275 | + {
|
| | 276 | + if(old_dxgl) _tcscpy(command,_T(" install "));
|
| | 277 | + else _tcscpy(command, _T(" forceinstall "));
|
| | 278 | + _tcscat(command,path);
|
| | 279 | + ZeroMemory(&shex,sizeof(SHELLEXECUTEINFO));
|
| | 280 | + shex.cbSize = sizeof(SHELLEXECUTEINFO);
|
| | 281 | + shex.lpVerb = _T("runas");
|
| | 282 | + shex.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| | 283 | + _tcscat(installpath,_T("\\dxglcfg.exe"));
|
| | 284 | + shex.lpFile = installpath;
|
| | 285 | + shex.lpParameters = command;
|
| | 286 | + ShellExecuteEx(&shex);
|
| | 287 | + WaitForSingleObject(shex.hProcess,INFINITE);
|
| | 288 | + GetExitCodeProcess(shex.hProcess,&exitcode);
|
| | 289 | + return exitcode;
|
| | 290 | + }
|
| | 291 | + return error;
|
| | 292 | + }
|
| | 293 | + }
|
| | 294 | + return 0;
|
| | 295 | +}
|
| | 296 | +
|
| | 297 | +DWORD DelApp(LPCTSTR path, BOOL admin, HWND hwnd)
|
| | 298 | +{
|
| | 299 | + BOOL installed = FALSE;
|
| | 300 | + TCHAR command[MAX_PATH + 32];
|
| | 301 | + BOOL old_dxgl = TRUE;
|
| | 302 | + DWORD sizeout = (MAX_PATH+1)*sizeof(TCHAR);
|
| | 303 | + TCHAR installpath[MAX_PATH+1];
|
| | 304 | + TCHAR inipath[MAX_PATH + 1];
|
| | 305 | + TCHAR backuppath[MAX_PATH + 1];
|
| | 306 | + HKEY hKeyInstall;
|
| | 307 | + HMODULE hmod;
|
| | 308 | + SHELLEXECUTEINFO shex;
|
| | 309 | + DWORD exitcode;
|
| | 310 | + HANDLE exists;
|
| | 311 | + app_ini_options inioptions;
|
| | 312 | + LONG error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\DXGL"), 0, KEY_READ, &hKeyInstall);
|
| | 313 | + if(error == ERROR_SUCCESS)
|
| | 314 | + {
|
| | 315 | + error = RegQueryValueEx(hKeyInstall,_T("InstallDir"),NULL,NULL,(LPBYTE)installpath,&sizeout);
|
| | 316 | + if(error == ERROR_SUCCESS) installed = TRUE;
|
| | 317 | + }
|
| | 318 | + if(hKeyInstall) RegCloseKey(hKeyInstall);
|
| | 319 | + if(!installed)
|
| | 320 | + {
|
| | 321 | + GetModuleFileName(NULL,installpath,MAX_PATH+1);
|
| | 322 | + }
|
| | 323 | + _tcsncpy(inipath, path, MAX_PATH + 1);
|
| | 324 | + (_tcsrchr(inipath, _T('\\')))[1] = 0;
|
| | 325 | + _tcsncpy(backuppath, path, MAX_PATH + 1);
|
| | 326 | + (_tcsrchr(backuppath, _T('\\')))[1] = 0;
|
| | 327 | + _tcscat(backuppath, _T("ddraw.dll.dxgl-backup"));
|
| | 328 | + // Check for DXGL ini file and existing ddraw.dll
|
| | 329 | + ReadAppINIOptions(inipath, &inioptions);
|
| | 330 | + if (inioptions.NoOverwrite || inioptions.NoUninstall)
|
| | 331 | + {
|
| | 332 | + MessageBox(hwnd,_T("DXGL has not been removed from your game folder. \
|
| | 333 | +An INI file has been found in your game folder prohibiting the DirectDraw \
|
| | 334 | +library in your game folder from being deleted.\r\n\r\n\
|
| | 335 | +If this is in error, you will have to manually delete ddraw.dll from your \
|
| | 336 | +game folder. If your game was distributed by Steam or a similar service \
|
| | 337 | +please verify your game files after removing the file, in case the game \
|
| | 338 | +shipped with a custom DirectDraw library."), _T("Warning"), MB_OK | MB_ICONWARNING);
|
| | 339 | + return 0; // Continue to delete registry profile.
|
| | 340 | + }
|
| | 341 | + error = SetErrorMode(SEM_FAILCRITICALERRORS);
|
| | 342 | + SetErrorMode(error | SEM_FAILCRITICALERRORS);
|
| | 343 | + hmod = LoadLibrary(path);
|
| | 344 | + SetErrorMode(error);
|
| | 345 | + if(hmod)
|
| | 346 | + {
|
| | 347 | + if(!GetProcAddress(hmod,"IsDXGLDDraw")) old_dxgl = FALSE;
|
| | 348 | + FreeLibrary(hmod);
|
| | 349 | + }
|
| | 350 | + else old_dxgl = FALSE;
|
| | 351 | + if(!old_dxgl) return 0;
|
| | 352 | + if(!DeleteFile(path))
|
| | 353 | + {
|
| | 354 | + error = GetLastError();
|
| | 355 | + if((error == ERROR_ACCESS_DENIED) && !admin)
|
| | 356 | + {
|
| | 357 | + _tcscpy(command,_T(" remove "));
|
| | 358 | + _tcscat(command,path);
|
| | 359 | + ZeroMemory(&shex,sizeof(SHELLEXECUTEINFO));
|
| | 360 | + shex.cbSize = sizeof(SHELLEXECUTEINFO);
|
| | 361 | + shex.lpVerb = _T("runas");
|
| | 362 | + shex.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| | 363 | + _tcscat(installpath,_T("\\dxglcfg.exe"));
|
| | 364 | + shex.lpFile = installpath;
|
| | 365 | + shex.lpParameters = command;
|
| | 366 | + ShellExecuteEx(&shex);
|
| | 367 | + WaitForSingleObject(shex.hProcess,INFINITE);
|
| | 368 | + GetExitCodeProcess(shex.hProcess,&exitcode);
|
| | 369 | + return exitcode;
|
| | 370 | + }
|
| | 371 | + else if (error != ERROR_FILE_NOT_FOUND) return error;
|
| | 372 | + }
|
| | 373 | + exists = CreateFile(backuppath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
| | 374 | + NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
| | 375 | + if (exists == INVALID_HANDLE_VALUE) return 0;
|
| | 376 | + else
|
| | 377 | + {
|
| | 378 | + CloseHandle(exists);
|
| | 379 | + error = MoveFile(backuppath, path);
|
| | 380 | + if (!error)
|
| | 381 | + {
|
| | 382 | + error = GetLastError();
|
| | 383 | + if ((error == ERROR_ACCESS_DENIED) && !admin)
|
| | 384 | + {
|
| | 385 | + _tcscpy(command, _T(" remove "));
|
| | 386 | + _tcscat(command, path);
|
| | 387 | + ZeroMemory(&shex, sizeof(SHELLEXECUTEINFO));
|
| | 388 | + shex.cbSize = sizeof(SHELLEXECUTEINFO);
|
| | 389 | + shex.lpVerb = _T("runas");
|
| | 390 | + shex.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| | 391 | + _tcscat(installpath, _T("\\dxglcfg.exe"));
|
| | 392 | + shex.lpFile = installpath;
|
| | 393 | + shex.lpParameters = command;
|
| | 394 | + ShellExecuteEx(&shex);
|
| | 395 | + WaitForSingleObject(shex.hProcess, INFINITE);
|
| | 396 | + GetExitCodeProcess(shex.hProcess, &exitcode);
|
| | 397 | + return exitcode;
|
| | 398 | + }
|
| | 399 | + else return error;
|
| | 400 | + }
|
| | 401 | + }
|
| | 402 | + return 0;
|
| | 403 | +}
|
| | 404 | +
|
| | 405 | +void SaveChanges(HWND hWnd)
|
| | 406 | +{
|
| | 407 | + int i;
|
| | 408 | + if(apps[0].dirty) SetGlobalConfig(&apps[0].cfg);
|
| | 409 | + for(i = 1; i < appcount; i++)
|
| | 410 | + {
|
| | 411 | + if(apps[i].dirty) SetConfig(&apps[i].cfg,&apps[i].mask,apps[i].regkey);
|
| | 412 | + }
|
| | 413 | + EnableWindow(GetDlgItem(hWnd,IDC_APPLY),FALSE);
|
| | 414 | +}
|
| | 415 | +
|
| | 416 | +void FloatToAspect(float f, LPTSTR aspect)
|
| | 417 | +{
|
| | 418 | + float integer;
|
| | 419 | + float dummy;
|
| | 420 | + float fract;
|
| | 421 | + TCHAR denominator[5];
|
| | 422 | + int i;
|
| | 423 | + if (_isnan(f)) f = 0.0f; //Handle NAN condition
|
| | 424 | + if (f >= 1000.0f) // Clamp ridiculously wide aspects
|
| | 425 | + {
|
| | 426 | + _tcscpy(aspect, _T("1000:1"));
|
| | 427 | + return;
|
| | 428 | + }
|
| | 429 | + if (f < 0.001f) // Exclude ridiculously tall aspects, zero, and negative
|
| | 430 | + {
|
| | 431 | + _tcscpy(aspect, _T("Default"));
|
| | 432 | + return;
|
| | 433 | + }
|
| | 434 | + // Handle common aspects
|
| | 435 | + if (fabsf(f - 1.25f) < 0.0001f)
|
| | 436 | + {
|
| | 437 | + _tcscpy(aspect, _T("5:4"));
|
| | 438 | + return;
|
| | 439 | + }
|
| | 440 | + if (fabsf(f - 1.3333333f) < 0.0001f)
|
| | 441 | + {
|
| | 442 | + _tcscpy(aspect, _T("4:3"));
|
| | 443 | + return;
|
| | 444 | + }
|
| | 445 | + if (fabsf(f - 1.6f) < 0.0001f)
|
| | 446 | + {
|
| | 447 | + _tcscpy(aspect, _T("16:10"));
|
| | 448 | + return;
|
| | 449 | + }
|
| | 450 | + if (fabsf(f - 1.7777777) < 0.0001f)
|
| | 451 | + {
|
| | 452 | + _tcscpy(aspect, _T("16:9"));
|
| | 453 | + return;
|
| | 454 | + }
|
| | 455 | + if (fabsf(f - 1.9333333) < 0.0001f)
|
| | 456 | + {
|
| | 457 | + _tcscpy(aspect, _T("256:135"));
|
| | 458 | + return;
|
| | 459 | + }
|
| | 460 | + fract = modff(f, &integer);
|
| | 461 | + if (fract < 0.0001f) //Handle integer aspects
|
| | 462 | + {
|
| | 463 | + _itot((int)integer, aspect, 10);
|
| | 464 | + _tcscat(aspect, _T(":1"));
|
| | 465 | + return;
|
| | 466 | + }
|
| | 467 | + // Finally try from 2 to 1000
|
| | 468 | + for (i = 2; i < 1000; i++)
|
| | 469 | + {
|
| | 470 | + if (fabsf(modff(fract*i, &dummy)) < 0.0001f)
|
| | 471 | + {
|
| | 472 | + _itot((f*i) + .5f, aspect, 10);
|
| | 473 | + _itot(i, denominator, 10);
|
| | 474 | + _tcscat(aspect, _T(":"));
|
| | 475 | + _tcscat(aspect, denominator);
|
| | 476 | + return;
|
| | 477 | + }
|
| | 478 | + }
|
| | 479 | + // Cannot find a reasonable fractional aspect, so display as decimal.
|
| | 480 | +#ifdef _UNICODE
|
| | 481 | + swprintf(aspect, 31, L"%.6g", f);
|
| | 482 | +#else
|
| | 483 | + sprintf(aspect,"%.6g", f);
|
| | 484 | +#endif
|
| | 485 | +}
|
| | 486 | +
|
| | 487 | +void FloatToScale(float x, float y, LPTSTR scale)
|
| | 488 | +{
|
| | 489 | + TCHAR numberx[8];
|
| | 490 | + TCHAR numbery[8];
|
| | 491 | + if (_isnan(x)) x = 0.0f; //Handle NAN condition
|
| | 492 | + if (_isnan(y)) y = 0.0f;
|
| | 493 | + // Too low number, round to "Auto"
|
| | 494 | + if (x < 0.25f) x = 0.0f;
|
| | 495 | + if (y < 0.25f) y = 0.0f;
|
| | 496 | + // Too high number, round to 16
|
| | 497 | + if (x > 16.0f) x = 16.0f;
|
| | 498 | + if (y > 16.0f) y = 16.0f;
|
| | 499 | + // Test if either scale is zero
|
| | 500 | + if ((x == 0) || (y == 0))
|
| | 501 | + {
|
| | 502 | + _tcscpy(scale, _T("Auto"));
|
| | 503 | + return;
|
| | 504 | + }
|
| | 505 | + // Write numbers
|
| | 506 | +#ifdef _UNICODE
|
| | 507 | + swprintf(numberx, 7, L"%.4g", x);
|
| | 508 | + swprintf(numbery, 7, L"%.4g", y);
|
| | 509 | +#else
|
| | 510 | + sprintf(numberx, ".4g", x);
|
| | 511 | + sprintf(numbery, ".4g", y);
|
| | 512 | +#endif
|
| | 513 | + // Fill out string
|
| | 514 | + _tcscpy(scale, numberx);
|
| | 515 | + _tcscat(scale, _T("x"));
|
| | 516 | + if (x != y) _tcscat(scale, numbery);
|
| | 517 | +}
|
| | 518 | +
|
| | 519 | +void SetCheck(HWND hWnd, int DlgItem, BOOL value, BOOL mask, BOOL tristate)
|
| | 520 | +{
|
| | 521 | + if(tristate && !mask)
|
| | 522 | + SendDlgItemMessage(hWnd,DlgItem,BM_SETCHECK,BST_INDETERMINATE,0);
|
| | 523 | + else
|
| | 524 | + {
|
| | 525 | + if(value) SendDlgItemMessage(hWnd,DlgItem,BM_SETCHECK,BST_CHECKED,0);
|
| | 526 | + else SendDlgItemMessage(hWnd,DlgItem,BM_SETCHECK,BST_UNCHECKED,0);
|
| | 527 | + }
|
| | 528 | +}
|
| | 529 | +
|
| | 530 | +void SetCombo(HWND hWnd, int DlgItem, DWORD value, DWORD mask, BOOL tristate)
|
| | 531 | +{
|
| | 532 | + if(tristate && !mask)
|
| | 533 | + SendDlgItemMessage(hWnd,DlgItem,CB_SETCURSEL,
|
| | 534 | + SendDlgItemMessage(hWnd,DlgItem,CB_FINDSTRING,-1,(LPARAM)strdefault),0);
|
| | 535 | + else
|
| | 536 | + SendDlgItemMessage(hWnd,DlgItem,CB_SETCURSEL,value,0);
|
| | 537 | +}
|
| | 538 | +
|
| | 539 | +__inline DWORD EncodePrimaryScale(DWORD scale)
|
| | 540 | +{
|
| | 541 | + switch (scale)
|
| | 542 | + {
|
| | 543 | + case 0:
|
| | 544 | + return 2;
|
| | 545 | + case 1:
|
| | 546 | + return 0;
|
| | 547 | + case 2:
|
| | 548 | + return 1;
|
| | 549 | + default:
|
| | 550 | + return scale;
|
| | 551 | + }
|
| | 552 | +}
|
| | 553 | +
|
| | 554 | +void SetPrimaryScaleCombo(HWND hWnd, int DlgItem, DWORD value, DWORD mask, BOOL tristate)
|
| | 555 | +{
|
| | 556 | + if (tristate && !mask)
|
| | 557 | + SendDlgItemMessage(hWnd, DlgItem, CB_SETCURSEL,
|
| | 558 | + SendDlgItemMessage(hWnd, DlgItem, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 559 | + else
|
| | 560 | + SendDlgItemMessage(hWnd, DlgItem, CB_SETCURSEL, EncodePrimaryScale(value), 0);
|
| | 561 | +}
|
| | 562 | +
|
| | 563 | +void SetAspectCombo(HWND hWnd, int DlgItem, float value, DWORD mask, BOOL tristate)
|
| | 564 | +{
|
| | 565 | + TCHAR buffer[32];
|
| | 566 | + if (tristate && !mask)
|
| | 567 | + SendDlgItemMessage(hWnd, DlgItem, CB_SETCURSEL,
|
| | 568 | + SendDlgItemMessage(hWnd, DlgItem, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 569 | + else
|
| | 570 | + {
|
| | 571 | + FloatToAspect(value, buffer);
|
| | 572 | + SendDlgItemMessage(hWnd,DlgItem,CB_SETCURSEL,
|
| | 573 | + SendDlgItemMessage(hWnd, DlgItem, CB_FINDSTRING, -1, (LPARAM)buffer), 0);
|
| | 574 | + SetDlgItemText(hWnd, DlgItem, buffer);
|
| | 575 | + }
|
| | 576 | +}
|
| | 577 | +
|
| | 578 | +void SetPostScaleCombo(HWND hWnd, int DlgItem, float x, float y, DWORD maskx, DWORD masky, BOOL tristate)
|
| | 579 | +{
|
| | 580 | + TCHAR buffer[32];
|
| | 581 | + if (tristate && !maskx && !masky)
|
| | 582 | + SendDlgItemMessage(hWnd, DlgItem, CB_SETCURSEL,
|
| | 583 | + SendDlgItemMessage(hWnd, DlgItem, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 584 | + else
|
| | 585 | + {
|
| | 586 | + FloatToScale(x, y, buffer);
|
| | 587 | + SendDlgItemMessage(hWnd, DlgItem, CB_SETCURSEL,
|
| | 588 | + SendDlgItemMessage(hWnd, DlgItem, CB_FINDSTRING, -1, (LPARAM)buffer), 0);
|
| | 589 | + SetDlgItemText(hWnd, DlgItem, buffer);
|
| | 590 | + }
|
| | 591 | +}
|
| | 592 | +
|
| | 593 | +void SetText(HWND hWnd, int DlgItem, TCHAR *value, TCHAR *mask, BOOL tristate)
|
| | 594 | +{
|
| | 595 | + if(tristate && (mask[0] == 0))
|
| | 596 | + SetWindowText(GetDlgItem(hWnd,DlgItem),_T(""));
|
| | 597 | + else SetWindowText(GetDlgItem(hWnd,DlgItem),value);
|
| | 598 | +}
|
| | 599 | +
|
| | 600 | +BOOL GetCheck(HWND hWnd, int DlgItem, BOOL *mask)
|
| | 601 | +{
|
| | 602 | + int check = SendDlgItemMessage(hWnd,DlgItem,BM_GETCHECK,0,0);
|
| | 603 | + switch(check)
|
| | 604 | + {
|
| | 605 | + case BST_CHECKED:
|
| | 606 | + *mask = TRUE;
|
| | 607 | + return TRUE;
|
| | 608 | + case BST_UNCHECKED:
|
| | 609 | + *mask = TRUE;
|
| | 610 | + return FALSE;
|
| | 611 | + case BST_INDETERMINATE:
|
| | 612 | + default:
|
| | 613 | + *mask = FALSE;
|
| | 614 | + return FALSE;
|
| | 615 | + }
|
| | 616 | +}
|
| | 617 | +
|
| | 618 | +DWORD GetCombo(HWND hWnd, int DlgItem, DWORD *mask)
|
| | 619 | +{
|
| | 620 | + int value = SendDlgItemMessage(hWnd,DlgItem,CB_GETCURSEL,0,0);
|
| | 621 | + if(value == SendDlgItemMessage(hWnd,DlgItem,CB_FINDSTRING,-1,(LPARAM)strdefault))
|
| | 622 | + {
|
| | 623 | + *mask = 0;
|
| | 624 | + return 0;
|
| | 625 | + }
|
| | 626 | + else
|
| | 627 | + {
|
| | 628 | + *mask = 1;
|
| | 629 | + return value;
|
| | 630 | + }
|
| | 631 | +}
|
| | 632 | +
|
| | 633 | +void GetPostScaleCombo(HWND hWnd, int DlgItem, float *x, float *y, float *maskx, float *masky)
|
| | 634 | +{
|
| | 635 | + TCHAR buffer[32];
|
| | 636 | + TCHAR *ptr;
|
| | 637 | + GetDlgItemText(hWnd, DlgItem, buffer, 31);
|
| | 638 | + buffer[31] = 0;
|
| | 639 | + if (!_tcscmp(buffer, strdefault))
|
| | 640 | + {
|
| | 641 | + *maskx = 0.0f;
|
| | 642 | + *masky = 0.0f;
|
| | 643 | + *x = 0.0f;
|
| | 644 | + *y = 0.0f;
|
| | 645 | + return;
|
| | 646 | + }
|
| | 647 | + else
|
| | 648 | + {
|
| | 649 | + *maskx = 1.0f;
|
| | 650 | + *masky = 1.0f;
|
| | 651 | + // Check for Auto
|
| | 652 | + if (!_tcsicmp(buffer, _T("Auto)")))
|
| | 653 | + {
|
| | 654 | + *x = 0.0f;
|
| | 655 | + *y = 0.0f;
|
| | 656 | + return;
|
| | 657 | + }
|
| | 658 | + else
|
| | 659 | + {
|
| | 660 | + // Check for certain characters
|
| | 661 | + ptr = _tcsstr(buffer, _T("x"));
|
| | 662 | + if (!ptr) ptr = _tcsstr(buffer, _T("X"));
|
| | 663 | + if (!ptr) ptr = _tcsstr(buffer, _T(","));
|
| | 664 | + if (!ptr) ptr = _tcsstr(buffer, _T("-"));
|
| | 665 | + if (!ptr) ptr = _tcsstr(buffer, _T(":"));
|
| | 666 | + if (ptr)
|
| | 667 | + {
|
| | 668 | + *ptr = 0;
|
| | 669 | + *x = _ttof(buffer);
|
| | 670 | + *y = _ttof(ptr + 1);
|
| | 671 | + if ((*x >= 0.25f) && (*y < 0.25f)) *y = *x;
|
| | 672 | + return;
|
| | 673 | + }
|
| | 674 | + else
|
| | 675 | + {
|
| | 676 | + *x = _ttof(buffer);
|
| | 677 | + *y = _ttof(buffer);
|
| | 678 | + return;
|
| | 679 | + }
|
| | 680 | + }
|
| | 681 | + }
|
| | 682 | +}
|
| | 683 | +
|
| | 684 | +float GetAspectCombo(HWND hWnd, int DlgItem, float *mask)
|
| | 685 | +{
|
| | 686 | + TCHAR buffer[32];
|
| | 687 | + TCHAR *ptr;
|
| | 688 | + float numerator, denominator;
|
| | 689 | + GetDlgItemText(hWnd, DlgItem, buffer, 31);
|
| | 690 | + buffer[31] = 0;
|
| | 691 | + if (!_tcscmp(buffer, strdefault))
|
| | 692 | + {
|
| | 693 | + *mask = 0.0f;
|
| | 694 | + return 0.0f;
|
| | 695 | + }
|
| | 696 | + else
|
| | 697 | + {
|
| | 698 | + *mask = 1.0f;
|
| | 699 | + if (!_tcsicmp(buffer, _T("Default"))) return 0.0f;
|
| | 700 | + else
|
| | 701 | + {
|
| | 702 | + // Check for colon
|
| | 703 | + ptr = _tcsstr(buffer, _T(":"));
|
| | 704 | + if (ptr)
|
| | 705 | + {
|
| | 706 | + *ptr = 0;
|
| | 707 | + numerator = (float)_ttof(buffer);
|
| | 708 | + denominator = (float)_ttof(ptr + 1);
|
| | 709 | + return numerator / denominator;
|
| | 710 | + }
|
| | 711 | + else return (float)_ttof(buffer);
|
| | 712 | + }
|
| | 713 | + }
|
| | 714 | +}
|
| | 715 | +
|
| | 716 | +void GetText(HWND hWnd, int DlgItem, TCHAR *str, TCHAR *mask)
|
| | 717 | +{
|
| | 718 | + GetDlgItemText(hWnd,DlgItem,str,MAX_PATH+1);
|
| | 719 | + if(str[0] == 0) mask[0] = 0;
|
| | 720 | + else mask[0] = 0xff;
|
| | 721 | +}
|
| | 722 | +
|
| | 723 | +void DrawCheck(HDC hdc, BOOL selected, BOOL checked, BOOL grayed, BOOL tristate, RECT *r)
|
| | 724 | +{
|
| | 725 | + if (grayed)
|
| | 726 | + {
|
| | 727 | + if (checked)
|
| | 728 | + {
|
| | 729 | + if (hThemeDisplay)
|
| | 730 | + {
|
| | 731 | + if (selected)
|
| | 732 | + _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_CHECKEDHOT, r, NULL);
|
| | 733 | + else _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_CHECKEDDISABLED, r, NULL);
|
| | 734 | + }
|
| | 735 | + else
|
| | 736 | + {
|
| | 737 | + if (selected)
|
| | 738 | + DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_INACTIVE | DFCS_HOT);
|
| | 739 | + else DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_INACTIVE);
|
| | 740 | + }
|
| | 741 | + }
|
| | 742 | + else if (tristate)
|
| | 743 | + {
|
| | 744 | + if (hThemeDisplay)
|
| | 745 | + {
|
| | 746 | + if (selected)
|
| | 747 | + _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_MIXEDHOT, r, NULL);
|
| | 748 | + else _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_MIXEDDISABLED, r, NULL);
|
| | 749 | + }
|
| | 750 | + else
|
| | 751 | + {
|
| | 752 | + if (selected)
|
| | 753 | + DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_INACTIVE | DFCS_HOT);
|
| | 754 | + else DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_INACTIVE);
|
| | 755 | + }
|
| | 756 | + }
|
| | 757 | + else
|
| | 758 | + {
|
| | 759 | + if (hThemeDisplay)
|
| | 760 | + {
|
| | 761 | + if (selected)
|
| | 762 | + _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_UNCHECKEDHOT, r, NULL);
|
| | 763 | + else _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_UNCHECKEDDISABLED, r, NULL);
|
| | 764 | + }
|
| | 765 | + else
|
| | 766 | + {
|
| | 767 | + if (selected)
|
| | 768 | + DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_INACTIVE | DFCS_HOT);
|
| | 769 | + else DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_INACTIVE);
|
| | 770 | + }
|
| | 771 | + }
|
| | 772 | + }
|
| | 773 | + else
|
| | 774 | + {
|
| | 775 | + if (checked)
|
| | 776 | + {
|
| | 777 | + if (hThemeDisplay)
|
| | 778 | + {
|
| | 779 | + if (selected)
|
| | 780 | + _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_CHECKEDHOT, r, NULL);
|
| | 781 | + else _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_CHECKEDNORMAL, r, NULL);
|
| | 782 | + }
|
| | 783 | + else
|
| | 784 | + {
|
| | 785 | + if (selected)
|
| | 786 | + DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_HOT);
|
| | 787 | + else DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_CHECKED);
|
| | 788 | + }
|
| | 789 | + }
|
| | 790 | + else if (tristate)
|
| | 791 | + {
|
| | 792 | + if (hThemeDisplay)
|
| | 793 | + {
|
| | 794 | + if (selected)
|
| | 795 | + _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_MIXEDHOT, r, NULL);
|
| | 796 | + else _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_MIXEDNORMAL, r, NULL);
|
| | 797 | + }
|
| | 798 | + else
|
| | 799 | + {
|
| | 800 | + if (selected)
|
| | 801 | + DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_HOT);
|
| | 802 | + else DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTON3STATE | DFCS_CHECKED);
|
| | 803 | + }
|
| | 804 | + }
|
| | 805 | + else
|
| | 806 | + {
|
| | 807 | + if (hThemeDisplay)
|
| | 808 | + {
|
| | 809 | + if (selected)
|
| | 810 | + _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_UNCHECKEDHOT, r, NULL);
|
| | 811 | + else _DrawThemeBackground(hThemeDisplay, hdc, BS_AUTOCHECKBOX, CBS_UNCHECKEDNORMAL, r, NULL);
|
| | 812 | + }
|
| | 813 | + else
|
| | 814 | + {
|
| | 815 | + if (selected)
|
| | 816 | + DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_HOT);
|
| | 817 | + else DrawFrameControl(hdc, r, DFC_BUTTON, DFCS_BUTTONCHECK);
|
| | 818 | + }
|
| | 819 | + }
|
| | 820 | + }
|
| | 821 | +}
|
| | 822 | +
|
| | 823 | +LRESULT CALLBACK DisplayTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| | 824 | +{
|
| | 825 | + DRAWITEMSTRUCT* drawitem;
|
| | 826 | + COLORREF OldTextColor, OldBackColor;
|
| | 827 | + RECT r;
|
| | 828 | + TCHAR combotext[64];
|
| | 829 | + DWORD cursel;
|
| | 830 | + HDC hdc;
|
| | 831 | + HFONT font1, font2;
|
| | 832 | + SIZE size;
|
| | 833 | + int i;
|
| | 834 | + switch (Msg)
|
| | 835 | + {
|
| | 836 | + case WM_INITDIALOG:
|
| | 837 | + if (uxtheme) hThemeDisplay = _OpenThemeData(hWnd, L"Button");
|
| | 838 | + else hThemeDisplay = NULL;
|
| | 839 | + if (_EnableThemeDialogTexture) _EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
|
| | 840 | + return TRUE;
|
| | 841 | + case WM_MEASUREITEM:
|
| | 842 | + switch (wParam)
|
| | 843 | + {
|
| | 844 | + case IDC_COLORDEPTH:
|
| | 845 | + case IDC_EXTRAMODES:
|
| | 846 | + if (((LPMEASUREITEMSTRUCT)lParam)->itemID == -1)
|
| | 847 | + {
|
| | 848 | + hdc = GetDC(hWnd);
|
| | 849 | + font1 = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0);
|
| | 850 | + font2 = (HFONT)SelectObject(hdc, font1);
|
| | 851 | + GetTextExtentPoint(hdc, _T(" "), 1, &size);
|
| | 852 | + SelectObject(hdc, font2);
|
| | 853 | + ReleaseDC(hWnd, hdc);
|
| | 854 | + ((LPMEASUREITEMSTRUCT)lParam)->itemHeight = size.cy + 2;
|
| | 855 | + }
|
| | 856 | + else
|
| | 857 | + {
|
| | 858 | + ((LPMEASUREITEMSTRUCT)lParam)->itemHeight = GetSystemMetrics(SM_CYMENUCHECK);
|
| | 859 | + ((LPMEASUREITEMSTRUCT)lParam)->itemWidth = GetSystemMetrics(SM_CXMENUCHECK);
|
| | 860 | + }
|
| | 861 | + break;
|
| | 862 | + default:
|
| | 863 | + break;
|
| | 864 | + }
|
| | 865 | + case WM_DRAWITEM:
|
| | 866 | + drawitem = (DRAWITEMSTRUCT*)lParam;
|
| | 867 | + switch (wParam)
|
| | 868 | + {
|
| | 869 | + case IDC_COLORDEPTH:
|
| | 870 | + OldTextColor = GetTextColor(drawitem->hDC);
|
| | 871 | + OldBackColor = GetBkColor(drawitem->hDC);
|
| | 872 | + if ((drawitem->itemState & ODS_SELECTED) && !(drawitem->itemState & ODS_COMBOBOXEDIT))
|
| | 873 | + {
|
| | 874 | + SetTextColor(drawitem->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
| | 875 | + SetBkColor(drawitem->hDC, GetSysColor(COLOR_HIGHLIGHT));
|
| | 876 | + FillRect(drawitem->hDC, &drawitem->rcItem, (HBRUSH)(COLOR_HIGHLIGHT + 1));
|
| | 877 | + }
|
| | 878 | + else ExtTextOut(drawitem->hDC, 0, 0, ETO_OPAQUE, &drawitem->rcItem, NULL, 0, NULL);
|
| | 879 | + memcpy(&r, &drawitem->rcItem, sizeof(RECT));
|
| | 880 | + if (drawitem->itemID != -1 && !(drawitem->itemState & ODS_COMBOBOXEDIT))
|
| | 881 | + {
|
| | 882 | + r.left = r.left + 2;
|
| | 883 | + r.right = r.left + GetSystemMetrics(SM_CXMENUCHECK);
|
| | 884 | + if (drawitem->itemID == 5)
|
| | 885 | + {
|
| | 886 | + if(!cfgmask->AddColorDepths)
|
| | 887 | + DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, TRUE, FALSE, FALSE, &r);
|
| | 888 | + else DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, FALSE, FALSE, FALSE, &r);
|
| | 889 | + }
|
| | 890 | + else
|
| | 891 | + {
|
| | 892 | + if ((cfg->AddColorDepths >> drawitem->itemID) & 1)
|
| | 893 | + DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, TRUE, !cfgmask->AddColorDepths, FALSE, &r);
|
| | 894 | + else DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, FALSE, !cfgmask->AddColorDepths, FALSE, &r);
|
| | 895 | + }
|
| | 896 | + drawitem->rcItem.left += GetSystemMetrics(SM_CXMENUCHECK) + 5;
|
| | 897 | + }
|
| | 898 | + combotext[0] = 0;
|
| | 899 | + if (drawitem->itemID != -1 && !(drawitem->itemState & ODS_COMBOBOXEDIT))
|
| | 900 | + SendDlgItemMessage(hWnd, IDC_COLORDEPTH, CB_GETLBTEXT, drawitem->itemID, (LPARAM)combotext);
|
| | 901 | + else
|
| | 902 | + {
|
| | 903 | + if(!cfgmask->AddColorDepths) _tcscpy(combotext, strdefault);
|
| | 904 | + else _tcscpy(combotext, colormodes[cfg->AddColorDepths & 31]);
|
| | 905 | + }
|
| | 906 | + DrawText(drawitem->hDC, combotext, _tcslen(combotext), &drawitem->rcItem,
|
| | 907 | + DT_LEFT | DT_SINGLELINE | DT_VCENTER);
|
| | 908 | + SetTextColor(drawitem->hDC, OldTextColor);
|
| | 909 | + SetBkColor(drawitem->hDC, OldBackColor);
|
| | 910 | + if (drawitem->itemID != -1 && !(drawitem->itemState & ODS_COMBOBOXEDIT))
|
| | 911 | + drawitem->rcItem.left -= GetSystemMetrics(SM_CXMENUCHECK) + 5;
|
| | 912 | + if (drawitem->itemState & ODS_FOCUS) DrawFocusRect(drawitem->hDC, &drawitem->rcItem);
|
| | 913 | + DefWindowProc(hWnd, Msg, wParam, lParam);
|
| | 914 | + break;
|
| | 915 | + case IDC_EXTRAMODES:
|
| | 916 | + OldTextColor = GetTextColor(drawitem->hDC);
|
| | 917 | + OldBackColor = GetBkColor(drawitem->hDC);
|
| | 918 | + if ((drawitem->itemState & ODS_SELECTED) && !(drawitem->itemState & ODS_COMBOBOXEDIT))
|
| | 919 | + {
|
| | 920 | + SetTextColor(drawitem->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
| | 921 | + SetBkColor(drawitem->hDC, GetSysColor(COLOR_HIGHLIGHT));
|
| | 922 | + FillRect(drawitem->hDC, &drawitem->rcItem, (HBRUSH)(COLOR_HIGHLIGHT + 1));
|
| | 923 | + }
|
| | 924 | + else ExtTextOut(drawitem->hDC, 0, 0, ETO_OPAQUE, &drawitem->rcItem, NULL, 0, NULL);
|
| | 925 | + memcpy(&r, &drawitem->rcItem, sizeof(RECT));
|
| | 926 | + if (drawitem->itemID != -1 && !(drawitem->itemState & ODS_COMBOBOXEDIT))
|
| | 927 | + {
|
| | 928 | + r.left = r.left + 2;
|
| | 929 | + r.right = r.left + GetSystemMetrics(SM_CXMENUCHECK);
|
| | 930 | + if (drawitem->itemID == 7)
|
| | 931 | + {
|
| | 932 | + if (!cfgmask->AddModes)
|
| | 933 | + DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, TRUE, FALSE, FALSE, &r);
|
| | 934 | + else DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, FALSE, FALSE, FALSE, &r);
|
| | 935 | + }
|
| | 936 | + else
|
| | 937 | + {
|
| | 938 | + if ((cfg->AddModes >> drawitem->itemID) & 1)
|
| | 939 | + DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, TRUE, !cfgmask->AddModes, FALSE, &r);
|
| | 940 | + else DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, FALSE, !cfgmask->AddModes, FALSE, &r);
|
| | 941 | + }
|
| | 942 | + drawitem->rcItem.left += GetSystemMetrics(SM_CXMENUCHECK) + 5;
|
| | 943 | + }
|
| | 944 | + combotext[0] = 0;
|
| | 945 | + if (drawitem->itemID != -1 && !(drawitem->itemState & ODS_COMBOBOXEDIT))
|
| | 946 | + SendDlgItemMessage(hWnd, IDC_EXTRAMODES, CB_GETLBTEXT, drawitem->itemID, (LPARAM)combotext);
|
| | 947 | + else
|
| | 948 | + {
|
| | 949 | + if (!cfgmask->AddModes) _tcscpy(combotext, strdefault);
|
| | 950 | + else
|
| | 951 | + {
|
| | 952 | + switch (cfg->AddModes)
|
| | 953 | + {
|
| | 954 | + case 0:
|
| | 955 | + _tcscpy(combotext, _T("None"));
|
| | 956 | + break;
|
| | 957 | + case 1:
|
| | 958 | + _tcscpy(combotext, extramodes[0]);
|
| | 959 | + break;
|
| | 960 | + case 2:
|
| | 961 | + _tcscpy(combotext, extramodes[1]);
|
| | 962 | + break;
|
| | 963 | + case 4:
|
| | 964 | + _tcscpy(combotext, extramodes[2]);
|
| | 965 | + break;
|
| | 966 | + case 8:
|
| | 967 | + _tcscpy(combotext, extramodes[3]);
|
| | 968 | + break;
|
| | 969 | + case 16:
|
| | 970 | + _tcscpy(combotext, extramodes[4]);
|
| | 971 | + break;
|
| | 972 | + case 32:
|
| | 973 | + _tcscpy(combotext, extramodes[5]);
|
| | 974 | + break;
|
| | 975 | + case 64:
|
| | 976 | + _tcscpy(combotext, extramodes[6]);
|
| | 977 | + break;
|
| | 978 | + default:
|
| | 979 | + _tcscpy(combotext, _T("Multiple selections"));
|
| | 980 | + }
|
| | 981 | + }
|
| | 982 | + }
|
| | 983 | + DrawText(drawitem->hDC, combotext, _tcslen(combotext), &drawitem->rcItem,
|
| | 984 | + DT_LEFT | DT_SINGLELINE | DT_VCENTER);
|
| | 985 | + SetTextColor(drawitem->hDC, OldTextColor);
|
| | 986 | + SetBkColor(drawitem->hDC, OldBackColor);
|
| | 987 | + if (drawitem->itemID != -1 && !(drawitem->itemState & ODS_COMBOBOXEDIT))
|
| | 988 | + drawitem->rcItem.left -= GetSystemMetrics(SM_CXMENUCHECK) + 5;
|
| | 989 | + if (drawitem->itemState & ODS_FOCUS) DrawFocusRect(drawitem->hDC, &drawitem->rcItem);
|
| | 990 | + DefWindowProc(hWnd, Msg, wParam, lParam);
|
| | 991 | + break;
|
| | 992 | + default:
|
| | 993 | + break;
|
| | 994 | + }
|
| | 995 | + case WM_THEMECHANGED:
|
| | 996 | + if (uxtheme)
|
| | 997 | + {
|
| | 998 | + if (hThemeDisplay) _CloseThemeData(hThemeDisplay);
|
| | 999 | + _OpenThemeData(hWnd, L"Button");
|
| | 1000 | + }
|
| | 1001 | + case WM_COMMAND:
|
| | 1002 | + {
|
| | 1003 | + switch (LOWORD(wParam))
|
| | 1004 | + {
|
| | 1005 | + case IDC_COLORDEPTH:
|
| | 1006 | + if (HIWORD(wParam) == CBN_SELENDOK)
|
| | 1007 | + {
|
| | 1008 | + if (ColorDepth_Dropdown)
|
| | 1009 | + {
|
| | 1010 | + cursel = SendDlgItemMessage(hWnd, IDC_COLORDEPTH, CB_GETCURSEL, 0, 0);
|
| | 1011 | + if (cursel == 5)
|
| | 1012 | + {
|
| | 1013 | + if (cfgmask->AddColorDepths) cfgmask->AddColorDepths = 0;
|
| | 1014 | + else cfgmask->AddColorDepths = 1;
|
| | 1015 | + }
|
| | 1016 | + else
|
| | 1017 | + {
|
| | 1018 | + if (!cfgmask->AddColorDepths) cfgmask->AddColorDepths = 1;
|
| | 1019 | + i = ((cfg->AddColorDepths >> cursel) & 1);
|
| | 1020 | + if (i) cfg->AddColorDepths &= ~(1 << cursel);
|
| | 1021 | + else cfg->AddColorDepths |= 1 << cursel;
|
| | 1022 | + }
|
| | 1023 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1024 | + *dirty = TRUE;
|
| | 1025 | + }
|
| | 1026 | + }
|
| | 1027 | + if (HIWORD(wParam) == CBN_DROPDOWN)
|
| | 1028 | + {
|
| | 1029 | + ColorDepth_Dropdown = TRUE;
|
| | 1030 | + }
|
| | 1031 | + if (HIWORD(wParam) == CBN_CLOSEUP)
|
| | 1032 | + {
|
| | 1033 | + ColorDepth_Dropdown = FALSE;
|
| | 1034 | + }
|
| | 1035 | + break;
|
| | 1036 | + case IDC_EXTRAMODES:
|
| | 1037 | + if (HIWORD(wParam) == CBN_SELENDOK)
|
| | 1038 | + {
|
| | 1039 | + if (ExtraModes_Dropdown)
|
| | 1040 | + {
|
| | 1041 | + cursel = SendDlgItemMessage(hWnd, IDC_EXTRAMODES, CB_GETCURSEL, 0, 0);
|
| | 1042 | + if (cursel == 7)
|
| | 1043 | + {
|
| | 1044 | + if (cfgmask->AddModes) cfgmask->AddModes = 0;
|
| | 1045 | + else cfgmask->AddModes = 1;
|
| | 1046 | + }
|
| | 1047 | + else
|
| | 1048 | + {
|
| | 1049 | + if (!cfgmask->AddModes) cfgmask->AddModes = 1;
|
| | 1050 | + i = ((cfg->AddModes >> cursel) & 1);
|
| | 1051 | + if (i) cfg->AddModes &= ~(1 << cursel);
|
| | 1052 | + else cfg->AddModes |= 1 << cursel;
|
| | 1053 | + }
|
| | 1054 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1055 | + *dirty = TRUE;
|
| | 1056 | + }
|
| | 1057 | + }
|
| | 1058 | + if (HIWORD(wParam) == CBN_DROPDOWN)
|
| | 1059 | + {
|
| | 1060 | + ExtraModes_Dropdown = TRUE;
|
| | 1061 | + }
|
| | 1062 | + if (HIWORD(wParam) == CBN_CLOSEUP)
|
| | 1063 | + {
|
| | 1064 | + ExtraModes_Dropdown = FALSE;
|
| | 1065 | + }
|
| | 1066 | + break;
|
| | 1067 | + case IDC_VIDMODE:
|
| | 1068 | + cfg->scaler = GetCombo(hWnd, IDC_VIDMODE, &cfgmask->scaler);
|
| | 1069 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1070 | + *dirty = TRUE;
|
| | 1071 | + break;
|
| | 1072 | + case IDC_SCALE:
|
| | 1073 | + cfg->scalingfilter = GetCombo(hWnd, IDC_SCALE, &cfgmask->scalingfilter);
|
| | 1074 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1075 | + *dirty = TRUE;
|
| | 1076 | + break;
|
| | 1077 | + case IDC_ASPECT:
|
| | 1078 | + if (HIWORD(wParam) == CBN_KILLFOCUS)
|
| | 1079 | + {
|
| | 1080 | + cfg->aspect = GetAspectCombo(hWnd, IDC_ASPECT, &cfgmask->aspect);
|
| | 1081 | + SetAspectCombo(hWnd, IDC_ASPECT, cfg->aspect, cfgmask->aspect, tristate);
|
| | 1082 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1083 | + *dirty = TRUE;
|
| | 1084 | + }
|
| | 1085 | + else if (HIWORD(wParam) == CBN_SELCHANGE)
|
| | 1086 | + {
|
| | 1087 | + cfg->aspect = GetAspectCombo(hWnd, IDC_ASPECT, &cfgmask->aspect);
|
| | 1088 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1089 | + *dirty = TRUE;
|
| | 1090 | + }
|
| | 1091 | + break;
|
| | 1092 | + case IDC_SORTMODES:
|
| | 1093 | + cfg->SortModes = GetCombo(hWnd, IDC_SORTMODES, &cfgmask->SortModes);
|
| | 1094 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1095 | + *dirty = TRUE;
|
| | 1096 | + break;
|
| | 1097 | + case IDC_DPISCALE:
|
| | 1098 | + cfg->DPIScale = GetCombo(hWnd, IDC_DPISCALE, &cfgmask->DPIScale);
|
| | 1099 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1100 | + *dirty = TRUE;
|
| | 1101 | + break;
|
| | 1102 | + case IDC_VSYNC:
|
| | 1103 | + cfg->vsync = GetCombo(hWnd, IDC_VSYNC, &cfgmask->vsync);
|
| | 1104 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1105 | + *dirty = TRUE;
|
| | 1106 | + break;
|
| | 1107 | + case IDC_FULLMODE:
|
| | 1108 | + cfg->fullmode = GetCombo(hWnd, IDC_FULLMODE, &cfgmask->fullmode);
|
| | 1109 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1110 | + *dirty = TRUE;
|
| | 1111 | + break;
|
| | 1112 | + case IDC_COLOR:
|
| | 1113 | + cfg->colormode = GetCheck(hWnd, IDC_COLOR, &cfgmask->colormode);
|
| | 1114 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1115 | + *dirty = TRUE;
|
| | 1116 | + break;
|
| | 1117 | + case IDC_SINGLEBUFFER:
|
| | 1118 | + cfg->SingleBufferDevice = GetCheck(hWnd, IDC_SINGLEBUFFER, &cfgmask->SingleBufferDevice);
|
| | 1119 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1120 | + *dirty = TRUE;
|
| | 1121 | + break;
|
| | 1122 | + default:
|
| | 1123 | + break;
|
| | 1124 | + }
|
| | 1125 | + }
|
| | 1126 | + default:
|
| | 1127 | + return FALSE;
|
| | 1128 | + }
|
| | 1129 | + return TRUE;
|
| | 1130 | +}
|
| | 1131 | +
|
| | 1132 | +LRESULT CALLBACK EffectsTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| | 1133 | +{
|
| | 1134 | + switch (Msg)
|
| | 1135 | + {
|
| | 1136 | + case WM_INITDIALOG:
|
| | 1137 | + if (_EnableThemeDialogTexture) _EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
|
| | 1138 | + return TRUE;
|
| | 1139 | + case WM_COMMAND:
|
| | 1140 | + switch (LOWORD(wParam))
|
| | 1141 | + {
|
| | 1142 | + case IDC_POSTSCALE:
|
| | 1143 | + cfg->postfilter = GetCombo(hWnd, IDC_POSTSCALE, &cfgmask->postfilter);
|
| | 1144 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1145 | + *dirty = TRUE;
|
| | 1146 | + break;
|
| | 1147 | + case IDC_POSTSCALESIZE:
|
| | 1148 | + if (HIWORD(wParam) == CBN_KILLFOCUS)
|
| | 1149 | + {
|
| | 1150 | + GetPostScaleCombo(hWnd, IDC_POSTSCALESIZE, &cfg->postsizex, &cfg->postsizey,
|
| | 1151 | + &cfgmask->postsizex, &cfgmask->postsizey);
|
| | 1152 | + SetPostScaleCombo(hWnd, IDC_POSTSCALESIZE, cfg->postsizex, cfg->postsizey,
|
| | 1153 | + cfgmask->postsizex, cfgmask->postsizey, tristate);
|
| | 1154 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1155 | + *dirty = TRUE;
|
| | 1156 | + }
|
| | 1157 | + else if (HIWORD(wParam) == CBN_SELCHANGE)
|
| | 1158 | + {
|
| | 1159 | + GetPostScaleCombo(hWnd, IDC_POSTSCALESIZE, &cfg->postsizex, &cfg->postsizey,
|
| | 1160 | + &cfgmask->postsizex, &cfgmask->postsizey);
|
| | 1161 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1162 | + *dirty = TRUE;
|
| | 1163 | + }
|
| | 1164 | + break;
|
| | 1165 | + case IDC_PRIMARYSCALE:
|
| | 1166 | + cfg->primaryscale = GetCombo(hWnd, IDC_PRIMARYSCALE, &cfgmask->primaryscale);
|
| | 1167 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1168 | + *dirty = TRUE;
|
| | 1169 | + break;
|
| | 1170 | + case IDC_SHADER:
|
| | 1171 | + if (HIWORD(wParam) == EN_CHANGE)
|
| | 1172 | + {
|
| | 1173 | + GetText(hWnd, IDC_SHADER, cfg->shaderfile, cfgmask->shaderfile);
|
| | 1174 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1175 | + *dirty = TRUE;
|
| | 1176 | + }
|
| | 1177 | + break;
|
| | 1178 | + default:
|
| | 1179 | + break;
|
| | 1180 | + }
|
| | 1181 | + default:
|
| | 1182 | + return FALSE;
|
| | 1183 | + }
|
| | 1184 | + return TRUE;
|
| | 1185 | +}
|
| | 1186 | +
|
| | 1187 | +LRESULT CALLBACK Tab3DCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| | 1188 | +{
|
| | 1189 | + switch (Msg)
|
| | 1190 | + {
|
| | 1191 | + case WM_INITDIALOG:
|
| | 1192 | + if (_EnableThemeDialogTexture) _EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
|
| | 1193 | + return TRUE;
|
| | 1194 | + case WM_COMMAND:
|
| | 1195 | + switch (LOWORD(wParam))
|
| | 1196 | + {
|
| | 1197 | + case IDC_TEXFILTER:
|
| | 1198 | + cfg->texfilter = GetCombo(hWnd, IDC_TEXFILTER, &cfgmask->texfilter);
|
| | 1199 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1200 | + *dirty = TRUE;
|
| | 1201 | + break;
|
| | 1202 | + case IDC_ANISO:
|
| | 1203 | + cfg->anisotropic = GetCombo(hWnd, IDC_ANISO, &cfgmask->anisotropic);
|
| | 1204 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1205 | + *dirty = TRUE;
|
| | 1206 | + break;
|
| | 1207 | + case IDC_MSAA:
|
| | 1208 | + cfg->msaa = GetCombo(hWnd, IDC_MSAA, &cfgmask->msaa);
|
| | 1209 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1210 | + *dirty = TRUE;
|
| | 1211 | + break;
|
| | 1212 | + case IDC_ASPECT3D:
|
| | 1213 | + cfg->aspect3d = GetCombo(hWnd, IDC_ASPECT3D, &cfgmask->aspect3d);
|
| | 1214 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1215 | + *dirty = TRUE;
|
| | 1216 | + break;
|
| | 1217 | + default:
|
| | 1218 | + break;
|
| | 1219 | + }
|
| | 1220 | + default:
|
| | 1221 | + return FALSE;
|
| | 1222 | + }
|
| | 1223 | + return TRUE;
|
| | 1224 | +}
|
| | 1225 | +
|
| | 1226 | +LRESULT CALLBACK AdvancedTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| | 1227 | +{
|
| | 1228 | + switch (Msg)
|
| | 1229 | + {
|
| | 1230 | + case WM_INITDIALOG:
|
| | 1231 | + if (_EnableThemeDialogTexture) _EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
|
| | 1232 | + return TRUE;
|
| | 1233 | + case WM_COMMAND:
|
| | 1234 | + switch (LOWORD(wParam))
|
| | 1235 | + {
|
| | 1236 | + case IDC_TEXTUREFORMAT:
|
| | 1237 | + cfg->TextureFormat = GetCombo(hWnd, IDC_TEXTUREFORMAT, &cfgmask->TextureFormat);
|
| | 1238 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1239 | + *dirty = TRUE;
|
| | 1240 | + break;
|
| | 1241 | + case IDC_TEXUPLOAD:
|
| | 1242 | + cfg->TexUpload = GetCombo(hWnd, IDC_TEXUPLOAD, &cfgmask->TexUpload);
|
| | 1243 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1244 | + *dirty = TRUE;
|
| | 1245 | + break;
|
| | 1246 | + default:
|
| | 1247 | + break;
|
| | 1248 | + }
|
| | 1249 | + default:
|
| | 1250 | + return FALSE;
|
| | 1251 | + }
|
| | 1252 | + return TRUE;
|
| | 1253 | +}
|
| | 1254 | +
|
| | 1255 | +void ReadDebugItem(int item, BOOL *value, BOOL *mask)
|
| | 1256 | +{
|
| | 1257 | + switch (item)
|
| | 1258 | + {
|
| | 1259 | + case 0:
|
| | 1260 | + *value = cfg->DebugNoExtFramebuffer;
|
| | 1261 | + *mask = cfgmask->DebugNoExtFramebuffer;
|
| | 1262 | + break;
|
| | 1263 | + case 1:
|
| | 1264 | + *value = cfg->DebugNoArbFramebuffer;
|
| | 1265 | + *mask = cfgmask->DebugNoArbFramebuffer;
|
| | 1266 | + break;
|
| | 1267 | + case 2:
|
| | 1268 | + *value = cfg->DebugNoES2Compatibility;
|
| | 1269 | + *mask = cfgmask->DebugNoES2Compatibility;
|
| | 1270 | + break;
|
| | 1271 | + case 3:
|
| | 1272 | + *value = cfg->DebugNoExtDirectStateAccess;
|
| | 1273 | + *mask = cfgmask->DebugNoExtDirectStateAccess;
|
| | 1274 | + break;
|
| | 1275 | + case 4:
|
| | 1276 | + *value = cfg->DebugNoArbDirectStateAccess;
|
| | 1277 | + *mask = cfgmask->DebugNoArbDirectStateAccess;
|
| | 1278 | + break;
|
| | 1279 | + case 5:
|
| | 1280 | + *value = cfg->DebugNoSamplerObjects;
|
| | 1281 | + *mask = cfgmask->DebugNoSamplerObjects;
|
| | 1282 | + break;
|
| | 1283 | + case 6:
|
| | 1284 | + *value = cfg->DebugNoGpuShader4;
|
| | 1285 | + *mask = cfgmask->DebugNoGpuShader4;
|
| | 1286 | + break;
|
| | 1287 | + case 7:
|
| | 1288 | + *value = cfg->DebugNoGLSL130;
|
| | 1289 | + *mask = cfgmask->DebugNoGLSL130;
|
| | 1290 | + break;
|
| | 1291 | + /*case 8:
|
| | 1292 | + *value = cfg->DebugDisableErrors;
|
| | 1293 | + *mask = cfgmask->DebugDisableErrors;
|
| | 1294 | + break;*/
|
| | 1295 | + default:
|
| | 1296 | + *value = FALSE;
|
| | 1297 | + *mask = FALSE;
|
| | 1298 | + break;
|
| | 1299 | + }
|
| | 1300 | +}
|
| | 1301 | +
|
| | 1302 | +void WriteDebugItem(int item, BOOL value, BOOL mask)
|
| | 1303 | +{
|
| | 1304 | + switch (item)
|
| | 1305 | + {
|
| | 1306 | + case 0:
|
| | 1307 | + cfg->DebugNoExtFramebuffer = value;
|
| | 1308 | + cfgmask->DebugNoExtFramebuffer = mask;
|
| | 1309 | + break;
|
| | 1310 | + case 1:
|
| | 1311 | + cfg->DebugNoArbFramebuffer = value;
|
| | 1312 | + cfgmask->DebugNoArbFramebuffer = mask;
|
| | 1313 | + break;
|
| | 1314 | + case 2:
|
| | 1315 | + cfg->DebugNoES2Compatibility = value;
|
| | 1316 | + cfgmask->DebugNoES2Compatibility = mask;
|
| | 1317 | + break;
|
| | 1318 | + case 3:
|
| | 1319 | + cfg->DebugNoExtDirectStateAccess = value;
|
| | 1320 | + cfgmask->DebugNoExtDirectStateAccess = mask;
|
| | 1321 | + break;
|
| | 1322 | + case 4:
|
| | 1323 | + cfg->DebugNoArbDirectStateAccess = value;
|
| | 1324 | + cfgmask->DebugNoArbDirectStateAccess = mask;
|
| | 1325 | + break;
|
| | 1326 | + case 5:
|
| | 1327 | + cfg->DebugNoSamplerObjects = value;
|
| | 1328 | + cfgmask->DebugNoSamplerObjects = mask;
|
| | 1329 | + break;
|
| | 1330 | + case 6:
|
| | 1331 | + cfg->DebugNoGpuShader4 = value;
|
| | 1332 | + cfgmask->DebugNoGpuShader4 = mask;
|
| | 1333 | + break;
|
| | 1334 | + case 7:
|
| | 1335 | + cfg->DebugNoGLSL130 = value;
|
| | 1336 | + cfgmask->DebugNoGLSL130 = mask;
|
| | 1337 | + break;
|
| | 1338 | + /*case 8:
|
| | 1339 | + cfg->DebugDisableErrors = value;
|
| | 1340 | + cfgmask->DebugDisableErrors = mask;
|
| | 1341 | + break;*/
|
| | 1342 | + default:
|
| | 1343 | + break;
|
| | 1344 | + }
|
| | 1345 | +}
|
| | 1346 | +
|
| | 1347 | +LRESULT CALLBACK DebugTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| | 1348 | +{
|
| | 1349 | + TCHAR str[64];
|
| | 1350 | + RECT r;
|
| | 1351 | + DRAWITEMSTRUCT* drawitem;
|
| | 1352 | + COLORREF OldTextColor, OldBackColor;
|
| | 1353 | + BOOL debugvalue, debugmask;
|
| | 1354 | + DWORD item;
|
| | 1355 | + switch (Msg)
|
| | 1356 | + {
|
| | 1357 | + case WM_INITDIALOG:
|
| | 1358 | + if (_EnableThemeDialogTexture) _EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
|
| | 1359 | + return TRUE;
|
| | 1360 | + case WM_MEASUREITEM:
|
| | 1361 | + switch (wParam)
|
| | 1362 | + {
|
| | 1363 | + case IDC_DEBUGLIST:
|
| | 1364 | + ((LPMEASUREITEMSTRUCT)lParam)->itemHeight = GetSystemMetrics(SM_CYMENUCHECK);
|
| | 1365 | + ((LPMEASUREITEMSTRUCT)lParam)->itemWidth = GetSystemMetrics(SM_CXMENUCHECK);
|
| | 1366 | + break;
|
| | 1367 | + default:
|
| | 1368 | + break;
|
| | 1369 | + }
|
| | 1370 | + break;
|
| | 1371 | + case WM_COMMAND:
|
| | 1372 | + switch (LOWORD(wParam))
|
| | 1373 | + {
|
| | 1374 | + case IDC_DEBUGLIST:
|
| | 1375 | + if ((HIWORD(wParam) == LBN_SELCHANGE) || (HIWORD(wParam) == LBN_DBLCLK))
|
| | 1376 | + {
|
| | 1377 | + item = SendDlgItemMessage(hWnd, IDC_DEBUGLIST, LB_GETCURSEL, 0, 0);
|
| | 1378 | + ReadDebugItem(item, &debugvalue, &debugmask);
|
| | 1379 | + if (tristate)
|
| | 1380 | + {
|
| | 1381 | + if (debugvalue && debugmask)
|
| | 1382 | + {
|
| | 1383 | + debugvalue = FALSE;
|
| | 1384 | + debugmask = FALSE;
|
| | 1385 | + }
|
| | 1386 | + else if (!debugmask)
|
| | 1387 | + {
|
| | 1388 | + debugvalue = FALSE;
|
| | 1389 | + debugmask = TRUE;
|
| | 1390 | + }
|
| | 1391 | + else
|
| | 1392 | + {
|
| | 1393 | + debugvalue = TRUE;
|
| | 1394 | + debugmask = TRUE;
|
| | 1395 | + }
|
| | 1396 | + }
|
| | 1397 | + else
|
| | 1398 | + {
|
| | 1399 | + if (debugvalue)
|
| | 1400 | + debugvalue = FALSE;
|
| | 1401 | + else debugvalue = TRUE;
|
| | 1402 | + }
|
| | 1403 | + WriteDebugItem(item, debugvalue, debugmask);
|
| | 1404 | + RedrawWindow(GetDlgItem(hWnd, IDC_DEBUGLIST), NULL, NULL, RDW_INVALIDATE);
|
| | 1405 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1406 | + *dirty = TRUE;
|
| | 1407 | + }
|
| | 1408 | + break;
|
| | 1409 | + default:
|
| | 1410 | + break;
|
| | 1411 | + }
|
| | 1412 | + case WM_DRAWITEM:
|
| | 1413 | + drawitem = (DRAWITEMSTRUCT*)lParam;
|
| | 1414 | + switch (wParam)
|
| | 1415 | + {
|
| | 1416 | + case IDC_DEBUGLIST:
|
| | 1417 | + OldTextColor = GetTextColor(drawitem->hDC);
|
| | 1418 | + OldBackColor = GetBkColor(drawitem->hDC);
|
| | 1419 | + if((drawitem->itemState & ODS_SELECTED))
|
| | 1420 | + {
|
| | 1421 | + SetTextColor(drawitem->hDC,GetSysColor(COLOR_HIGHLIGHTTEXT));
|
| | 1422 | + SetBkColor(drawitem->hDC,GetSysColor(COLOR_HIGHLIGHT));
|
| | 1423 | + FillRect(drawitem->hDC,&drawitem->rcItem,(HBRUSH)(COLOR_HIGHLIGHT+1));
|
| | 1424 | + }
|
| | 1425 | + else
|
| | 1426 | + {
|
| | 1427 | + SetTextColor(drawitem->hDC, GetSysColor(COLOR_WINDOWTEXT));
|
| | 1428 | + SetBkColor(drawitem->hDC, GetSysColor(COLOR_WINDOW));
|
| | 1429 | + FillRect(drawitem->hDC, &drawitem->rcItem, (HBRUSH)(COLOR_WINDOW + 1));
|
| | 1430 | + }
|
| | 1431 | + memcpy(&r, &drawitem->rcItem, sizeof(RECT));
|
| | 1432 | + r.left = r.left + 2;
|
| | 1433 | + r.right = r.left + GetSystemMetrics(SM_CXMENUCHECK);
|
| | 1434 | + ReadDebugItem(drawitem->itemID, &debugvalue, &debugmask);
|
| | 1435 | + DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, debugvalue, FALSE, !debugmask, &r);
|
| | 1436 | + drawitem->rcItem.left += GetSystemMetrics(SM_CXSMICON)+5;
|
| | 1437 | + SendDlgItemMessage(hWnd, IDC_DEBUGLIST, LB_GETTEXT, drawitem->itemID, (LPARAM)str);
|
| | 1438 | + DrawText(drawitem->hDC, str, _tcslen(str), &drawitem->rcItem,
|
| | 1439 | + DT_LEFT | DT_SINGLELINE | DT_VCENTER);
|
| | 1440 | + drawitem->rcItem.left -= GetSystemMetrics(SM_CXSMICON)+5;
|
| | 1441 | + if (drawitem->itemState & ODS_FOCUS) DrawFocusRect(drawitem->hDC, &drawitem->rcItem);
|
| | 1442 | + SetTextColor(drawitem->hDC,OldTextColor);
|
| | 1443 | + SetBkColor(drawitem->hDC,OldBackColor);
|
| | 1444 | + DefWindowProc(hWnd,Msg,wParam,lParam);
|
| | 1445 | + break;
|
| | 1446 | + default:
|
| | 1447 | + break;
|
| | 1448 | + }
|
| | 1449 | + break;
|
| | 1450 | + default:
|
| | 1451 | + return FALSE;
|
| | 1452 | + }
|
| | 1453 | + return TRUE;
|
| | 1454 | +}
|
| | 1455 | +
|
| | 1456 | +void ReadHacksItem(int item, BOOL *value, BOOL *mask)
|
| | 1457 | +{
|
| | 1458 | + switch (item)
|
| | 1459 | + {
|
| | 1460 | + default:
|
| | 1461 | + *value = FALSE;
|
| | 1462 | + *mask = FALSE;
|
| | 1463 | + break;
|
| | 1464 | + }
|
| | 1465 | +}
|
| | 1466 | +
|
| | 1467 | +void WriteHacksItem(int item, BOOL value, BOOL mask)
|
| | 1468 | +{
|
| | 1469 | + switch (item)
|
| | 1470 | + {
|
| | 1471 | + default:
|
| | 1472 | + break;
|
| | 1473 | + }
|
| | 1474 | +}
|
| | 1475 | +
|
| | 1476 | +LRESULT CALLBACK HacksTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| | 1477 | +{
|
| | 1478 | + TCHAR str[64];
|
| | 1479 | + RECT r;
|
| | 1480 | + DRAWITEMSTRUCT* drawitem;
|
| | 1481 | + COLORREF OldTextColor, OldBackColor;
|
| | 1482 | + BOOL hackvalue, hackmask;
|
| | 1483 | + DWORD item;
|
| | 1484 | + switch (Msg)
|
| | 1485 | + {
|
| | 1486 | + case WM_INITDIALOG:
|
| | 1487 | + if (_EnableThemeDialogTexture) _EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
|
| | 1488 | + return TRUE;
|
| | 1489 | + case WM_MEASUREITEM:
|
| | 1490 | + switch (wParam)
|
| | 1491 | + {
|
| | 1492 | + case IDC_HACKSLIST:
|
| | 1493 | + ((LPMEASUREITEMSTRUCT)lParam)->itemHeight = GetSystemMetrics(SM_CYMENUCHECK);
|
| | 1494 | + ((LPMEASUREITEMSTRUCT)lParam)->itemWidth = GetSystemMetrics(SM_CXMENUCHECK);
|
| | 1495 | + break;
|
| | 1496 | + default:
|
| | 1497 | + break;
|
| | 1498 | + }
|
| | 1499 | + break;
|
| | 1500 | + case WM_COMMAND:
|
| | 1501 | + switch (LOWORD(wParam))
|
| | 1502 | + {
|
| | 1503 | + case IDC_HACKSLIST:
|
| | 1504 | + if ((HIWORD(wParam) == LBN_SELCHANGE) || (HIWORD(wParam) == LBN_DBLCLK))
|
| | 1505 | + {
|
| | 1506 | + item = SendDlgItemMessage(hWnd, IDC_HACKSLIST, LB_GETCURSEL, 0, 0);
|
| | 1507 | + ReadHacksItem(item, &hackvalue, &hackmask);
|
| | 1508 | + if (tristate)
|
| | 1509 | + {
|
| | 1510 | + if (hackvalue && hackmask)
|
| | 1511 | + {
|
| | 1512 | + hackvalue = FALSE;
|
| | 1513 | + hackmask = FALSE;
|
| | 1514 | + }
|
| | 1515 | + else if (!hackmask)
|
| | 1516 | + {
|
| | 1517 | + hackvalue = FALSE;
|
| | 1518 | + hackmask = TRUE;
|
| | 1519 | + }
|
| | 1520 | + else
|
| | 1521 | + {
|
| | 1522 | + hackvalue = TRUE;
|
| | 1523 | + hackmask = TRUE;
|
| | 1524 | + }
|
| | 1525 | + }
|
| | 1526 | + else
|
| | 1527 | + {
|
| | 1528 | + if (hackvalue)
|
| | 1529 | + hackvalue = FALSE;
|
| | 1530 | + else hackvalue = TRUE;
|
| | 1531 | + }
|
| | 1532 | + WriteHacksItem(item, hackvalue, hackmask);
|
| | 1533 | + RedrawWindow(GetDlgItem(hWnd, IDC_HACKSLIST), NULL, NULL, RDW_INVALIDATE);
|
| | 1534 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| | 1535 | + *dirty = TRUE;
|
| | 1536 | + }
|
| | 1537 | + break;
|
| | 1538 | + default:
|
| | 1539 | + break;
|
| | 1540 | + }
|
| | 1541 | + case WM_DRAWITEM:
|
| | 1542 | + drawitem = (DRAWITEMSTRUCT*)lParam;
|
| | 1543 | + switch (wParam)
|
| | 1544 | + {
|
| | 1545 | + case IDC_HACKSLIST:
|
| | 1546 | + OldTextColor = GetTextColor(drawitem->hDC);
|
| | 1547 | + OldBackColor = GetBkColor(drawitem->hDC);
|
| | 1548 | + if ((drawitem->itemState & ODS_SELECTED))
|
| | 1549 | + {
|
| | 1550 | + SetTextColor(drawitem->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
| | 1551 | + SetBkColor(drawitem->hDC, GetSysColor(COLOR_HIGHLIGHT));
|
| | 1552 | + FillRect(drawitem->hDC, &drawitem->rcItem, (HBRUSH)(COLOR_HIGHLIGHT + 1));
|
| | 1553 | + }
|
| | 1554 | + else
|
| | 1555 | + {
|
| | 1556 | + SetTextColor(drawitem->hDC, GetSysColor(COLOR_WINDOWTEXT));
|
| | 1557 | + SetBkColor(drawitem->hDC, GetSysColor(COLOR_WINDOW));
|
| | 1558 | + FillRect(drawitem->hDC, &drawitem->rcItem, (HBRUSH)(COLOR_WINDOW + 1));
|
| | 1559 | + }
|
| | 1560 | + memcpy(&r, &drawitem->rcItem, sizeof(RECT));
|
| | 1561 | + r.left = r.left + 2;
|
| | 1562 | + r.right = r.left + GetSystemMetrics(SM_CXMENUCHECK);
|
| | 1563 | + ReadHacksItem(drawitem->itemID, &hackvalue, &hackmask);
|
| | 1564 | + DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, hackvalue, FALSE, !hackmask, &r);
|
| | 1565 | + drawitem->rcItem.left += GetSystemMetrics(SM_CXSMICON) + 5;
|
| | 1566 | + SendDlgItemMessage(hWnd, IDC_HACKSLIST, LB_GETTEXT, drawitem->itemID, (LPARAM)str);
|
| | 1567 | + DrawText(drawitem->hDC, str, _tcslen(str), &drawitem->rcItem,
|
| | 1568 | + DT_LEFT | DT_SINGLELINE | DT_VCENTER);
|
| | 1569 | + drawitem->rcItem.left -= GetSystemMetrics(SM_CXSMICON) + 5;
|
| | 1570 | + if (drawitem->itemState & ODS_FOCUS) DrawFocusRect(drawitem->hDC, &drawitem->rcItem);
|
| | 1571 | + SetTextColor(drawitem->hDC, OldTextColor);
|
| | 1572 | + SetBkColor(drawitem->hDC, OldBackColor);
|
| | 1573 | + DefWindowProc(hWnd, Msg, wParam, lParam);
|
| | 1574 | + break;
|
| | 1575 | + default:
|
| | 1576 | + break;
|
| | 1577 | + }
|
| | 1578 | + break;
|
| | 1579 | + default:
|
| | 1580 | + return FALSE;
|
| | 1581 | + }
|
| | 1582 | + return TRUE;
|
| | 1583 | +}
|
| | 1584 | +
|
| | 1585 | +
|
| | 1586 | +LRESULT CALLBACK PathsTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| | 1587 | +{
|
| | 1588 | + switch (Msg)
|
| | 1589 | + {
|
| | 1590 | + case WM_INITDIALOG:
|
| | 1591 | + if (_EnableThemeDialogTexture) _EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
|
| | 1592 | + return TRUE;
|
| | 1593 | + default:
|
| | 1594 | + return FALSE;
|
| | 1595 | + }
|
| | 1596 | + return TRUE;
|
| | 1597 | +}
|
| | 1598 | +
|
| | 1599 | +LRESULT CALLBACK DXGLCfgCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| | 1600 | +{
|
| | 1601 | + PIXELFORMATDESCRIPTOR pfd =
|
| | 1602 | + {
|
| | 1603 | + sizeof(PIXELFORMATDESCRIPTOR),
|
| | 1604 | + 1,
|
| | 1605 | + PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, //Flags
|
| | 1606 | + PFD_TYPE_RGBA, //The kind of framebuffer. RGBA or palette.
|
| | 1607 | + 0, //Colordepth of the framebuffer.
|
| | 1608 | + 0, 0, 0, 0, 0, 0,
|
| | 1609 | + 0,
|
| | 1610 | + 0,
|
| | 1611 | + 0,
|
| | 1612 | + 0, 0, 0, 0,
|
| | 1613 | + 24, //Number of bits for the depthbuffer
|
| | 1614 | + 8, //Number of bits for the stencilbuffer
|
| | 1615 | + 0, //Number of Aux buffers in the framebuffer.
|
| | 1616 | + PFD_MAIN_PLANE,
|
| | 1617 | + 0,
|
| | 1618 | + 0, 0, 0
|
| | 1619 | + };
|
| | 1620 | + GLfloat anisotropic;
|
| | 1621 | + HDC dc;
|
| | 1622 | + HGLRC rc;
|
| | 1623 | + GLint maxsamples;
|
| | 1624 | + GLint maxcoverage = 0;
|
| | 1625 | + GLint coveragemodes[64];
|
| | 1626 | + int msaamodes[32];
|
| | 1627 | + int pf;
|
| | 1628 | + int i;
|
| | 1629 | + HKEY hKeyBase;
|
| | 1630 | + HKEY hKey;
|
| | 1631 | + DWORD keysize,keysize2;
|
| | 1632 | + DEVMODE mode;
|
| | 1633 | + LPTSTR keyname;
|
| | 1634 | + LPTSTR regbuffer;
|
| | 1635 | + DWORD regbuffersize;
|
| | 1636 | + DWORD buffersize;
|
| | 1637 | + LONG error;
|
| | 1638 | + TCHAR buffer[64];
|
| | 1639 | + TCHAR subkey[MAX_PATH];
|
| | 1640 | + LPTSTR path;
|
| | 1641 | + SHFILEINFO fileinfo;
|
| | 1642 | + DWORD verinfosize;
|
| | 1643 | + LPTSTR outbuffer;
|
| | 1644 | + UINT outlen;
|
| | 1645 | + TCHAR verpath[64];
|
| | 1646 | + WORD translation[2];
|
| | 1647 | + DWORD cursel;
|
| | 1648 | + DRAWITEMSTRUCT* drawitem;
|
| | 1649 | + BOOL hasname;
|
| | 1650 | + void *verinfo;
|
| | 1651 | + COLORREF OldTextColor,OldBackColor;
|
| | 1652 | + HANDLE token = NULL;
|
| | 1653 | + TOKEN_ELEVATION elevation;
|
| | 1654 | + HWND hGLWnd;
|
| | 1655 | + OPENFILENAME filename;
|
| | 1656 | + TCHAR selectedfile[MAX_PATH + 1];
|
| | 1657 | + LPTSTR regpath;
|
| | 1658 | + LPTSTR regkey;
|
| | 1659 | + BOOL failed;
|
| | 1660 | + LPTSTR installpath;
|
| | 1661 | + DWORD err;
|
| | 1662 | + RECT r;
|
| | 1663 | + NMHDR *nm;
|
| | 1664 | + int newtab;
|
| | 1665 | + TCITEM tab;
|
| | 1666 | + switch (Msg)
|
| | 1667 | + {
|
| | 1668 | + case WM_INITDIALOG:
|
| | 1669 | + hDialog = hWnd;
|
| | 1670 | + tristate = FALSE;
|
| | 1671 | + maxapps = 128;
|
| | 1672 | + apps = (app_setting *)malloc(maxapps*sizeof(app_setting));
|
| | 1673 | + apps[0].name = (TCHAR*)malloc(7 * sizeof(TCHAR));
|
| | 1674 | + _tcscpy(apps[0].name,_T("Global"));
|
| | 1675 | + apps[0].regkey = (TCHAR*)malloc(7 * sizeof(TCHAR));
|
| | 1676 | + _tcscpy(apps[0].regkey,_T("Global"));
|
| | 1677 | + GetGlobalConfig(&apps[0].cfg, FALSE);
|
| | 1678 | + cfg = &apps[0].cfg;
|
| | 1679 | + cfgmask = &apps[0].mask;
|
| | 1680 | + dirty = &apps[0].dirty;
|
| | 1681 | + memset(&apps[0].mask,0xff,sizeof(DXGLCFG));
|
| | 1682 | + apps[0].dirty = FALSE;
|
| | 1683 | + apps[0].icon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_STAR));
|
| | 1684 | + apps[0].icon_shared = TRUE;
|
| | 1685 | + apps[0].path[0] = 0;
|
| | 1686 | + SetClassLong(hWnd,GCL_HICON,(LONG)LoadIcon(hinstance,(LPCTSTR)IDI_DXGL));
|
| | 1687 | + SetClassLong(hWnd,GCL_HICONSM,(LONG)LoadIcon(hinstance,(LPCTSTR)IDI_DXGLSM));
|
| | 1688 | + // create temporary gl context to get AA and AF settings.
|
| | 1689 | + mode.dmSize = sizeof(DEVMODE);
|
| | 1690 | + EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&mode);
|
| | 1691 | + pfd.cColorBits = (BYTE)mode.dmBitsPerPel;
|
| | 1692 | + hGLWnd = CreateWindow(_T("STATIC"),NULL,WS_CHILD,0,0,16,16,hWnd,NULL,NULL,NULL);
|
| | 1693 | + dc = GetDC(hGLWnd);
|
| | 1694 | + pf = ChoosePixelFormat(dc,&pfd);
|
| | 1695 | + SetPixelFormat(dc,pf,&pfd);
|
| | 1696 | + rc = wglCreateContext(dc);
|
| | 1697 | + wglMakeCurrent(dc,rc);
|
| | 1698 | + extensions_string = (char*)glGetString(GL_EXTENSIONS);
|
| | 1699 | + if(strstr(extensions_string,"GL_EXT_texture_filter_anisotropic"))
|
| | 1700 | + glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT,&anisotropic);
|
| | 1701 | + else anisotropic = 0;
|
| | 1702 | + if(strstr(extensions_string,"GL_EXT_framebuffer_multisample"))
|
| | 1703 | + {
|
| | 1704 | + glGetIntegerv(GL_MAX_SAMPLES_EXT,&maxsamples);
|
| | 1705 | + if(strstr(extensions_string,"GL_NV_framebuffer_multisample_coverage")) // Supports NVIDIA CSAA
|
| | 1706 | + {
|
| | 1707 | + glGetIntegerv(GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV,&maxcoverage);
|
| | 1708 | + glGetIntegerv(GL_MULTISAMPLE_COVERAGE_MODES_NV,coveragemodes);
|
| | 1709 | + if(maxcoverage) for(i = 0; i < maxcoverage; i++)
|
| | 1710 | + {
|
| | 1711 | + msaamodes[i] = coveragemodes[2*i]+(4096*coveragemodes[(2*i)+1]);
|
| | 1712 | + msaa = TRUE;
|
| | 1713 | + }
|
| | 1714 | + }
|
| | 1715 | + }
|
| | 1716 | + wglMakeCurrent(dc,NULL);
|
| | 1717 | + wglDeleteContext(rc);
|
| | 1718 | + ReleaseDC(hGLWnd,dc);
|
| | 1719 | + DestroyWindow(hGLWnd);
|
| | 1720 | + uxtheme = LoadLibrary(_T("uxtheme.dll"));
|
| | 1721 | + if (uxtheme)
|
| | 1722 | + {
|
| | 1723 | +
|
| | 1724 | + _OpenThemeData = (HTHEME(WINAPI*)(HWND,LPCWSTR))GetProcAddress(uxtheme, "OpenThemeData");
|
| | 1725 | + _CloseThemeData = (HRESULT(WINAPI*)(HTHEME))GetProcAddress(uxtheme, "CloseThemeData");
|
| | 1726 | + _DrawThemeBackground =
|
| | 1727 | + (HRESULT(WINAPI*)(HTHEME, HDC, int, int, const RECT*, const RECT*))
|
| | 1728 | + GetProcAddress(uxtheme, "DrawThemeBackground");
|
| | 1729 | + _EnableThemeDialogTexture = (HRESULT(WINAPI*)(HWND, DWORD))
|
| | 1730 | + GetProcAddress(uxtheme, "EnableThemeDialogTexture");
|
| | 1731 | + if (!(_OpenThemeData && _CloseThemeData && _DrawThemeBackground && _EnableThemeDialogTexture))
|
| | 1732 | + {
|
| | 1733 | + FreeLibrary(uxtheme);
|
| | 1734 | + uxtheme = NULL;
|
| | 1735 | + }
|
| | 1736 | + }
|
| | 1737 | + // Add tabs
|
| | 1738 | + ZeroMemory(&tab, sizeof(TCITEM));
|
| | 1739 | + tab.mask = TCIF_TEXT;
|
| | 1740 | + tab.pszText = _T("Display");
|
| | 1741 | + SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 0, (LPARAM)&tab);
|
| | 1742 | + tab.pszText = _T("Effects");
|
| | 1743 | + SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 1, (LPARAM)&tab);
|
| | 1744 | + tab.pszText = _T("3D Graphics");
|
| | 1745 | + SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 2, (LPARAM)&tab);
|
| | 1746 | + tab.pszText = _T("Advanced");
|
| | 1747 | + SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 3, (LPARAM)&tab);
|
| | 1748 | + tab.pszText = _T("Debug");
|
| | 1749 | + SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 4, (LPARAM)&tab);
|
| | 1750 | + tab.pszText = _T("Hacks");
|
| | 1751 | + SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 5, (LPARAM)&tab);
|
| | 1752 | + /*tab.pszText = _T("Graphics Tests");
|
| | 1753 | + SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 6, (LPARAM)&tab);
|
| | 1754 | + tab.pszText = _T("About");
|
| | 1755 | + SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 7, (LPARAM)&tab);*/
|
| | 1756 | + hTab = GetDlgItem(hWnd, IDC_TABS);
|
| | 1757 | + hTabs[0] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_DISPLAY), hTab, (DLGPROC)DisplayTabCallback);
|
| | 1758 | + hTabs[1] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_EFFECTS), hTab, (DLGPROC)EffectsTabCallback);
|
| | 1759 | + hTabs[2] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_3DGRAPHICS), hTab, (DLGPROC)Tab3DCallback);
|
| | 1760 | + hTabs[3] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADVANCED), hTab, (DLGPROC)AdvancedTabCallback);
|
| | 1761 | + hTabs[4] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_DEBUG), hTab, (DLGPROC)DebugTabCallback);
|
| | 1762 | + hTabs[5] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_HACKS), hTab, (DLGPROC)HacksTabCallback);
|
| | 1763 | + SendDlgItemMessage(hWnd, IDC_TABS, TCM_GETITEMRECT, 0, (LPARAM)&r);
|
| | 1764 | + SetWindowPos(hTabs[0], NULL, r.left, r.bottom + 3, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
|
| | 1765 | + ShowWindow(hTabs[1], SW_HIDE);
|
| | 1766 | + ShowWindow(hTabs[2], SW_HIDE);
|
| | 1767 | + ShowWindow(hTabs[3], SW_HIDE);
|
| | 1768 | + ShowWindow(hTabs[4], SW_HIDE);
|
| | 1769 | + ShowWindow(hTabs[5], SW_HIDE);
|
| | 1770 | + tabopen = 0;
|
| | 1771 | +
|
| | 1772 | + // Load global settings.
|
| | 1773 | + // video mode
|
| | 1774 | + _tcscpy(buffer,_T("Change desktop resolution"));
|
| | 1775 | + SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1776 | + _tcscpy(buffer,_T("Stretch to screen"));
|
| | 1777 | + SendDlgItemMessage(hTabs[0],IDC_VIDMODE,CB_ADDSTRING,1,(LPARAM)buffer);
|
| | 1778 | + _tcscpy(buffer,_T("Aspect corrected stretch"));
|
| | 1779 | + SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_ADDSTRING, 2, (LPARAM)buffer);
|
| | 1780 | + _tcscpy(buffer,_T("Center image on screen"));
|
| | 1781 | + SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_ADDSTRING, 3, (LPARAM)buffer);
|
| | 1782 | + _tcscpy(buffer,_T("Stretch if mode not found"));
|
| | 1783 | + SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_ADDSTRING, 4, (LPARAM)buffer);
|
| | 1784 | + _tcscpy(buffer,_T("Scale if mode not found"));
|
| | 1785 | + SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_ADDSTRING, 5, (LPARAM)buffer);
|
| | 1786 | + _tcscpy(buffer,_T("Center if mode not found"));
|
| | 1787 | + SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_ADDSTRING, 6, (LPARAM)buffer);
|
| | 1788 | + _tcscpy(buffer,_T("Crop to screen"));
|
| | 1789 | + SendDlgItemMessage(hTabs[0],IDC_VIDMODE,CB_ADDSTRING,7,(LPARAM)buffer);
|
| | 1790 | + SendDlgItemMessage(hTabs[0],IDC_VIDMODE,CB_SETCURSEL,cfg->scaler,0);
|
| | 1791 | + // fullscreen window mode
|
| | 1792 | + _tcscpy(buffer, _T("Exclusive fullscreen"));
|
| | 1793 | + SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1794 | + _tcscpy(buffer, _T("Non-exclusive fullscreen"));
|
| | 1795 | + SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_ADDSTRING, 1, (LPARAM)buffer);
|
| | 1796 | + _tcscpy(buffer, _T("Non-resizable window"));
|
| | 1797 | + SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_ADDSTRING, 2, (LPARAM)buffer);
|
| | 1798 | + _tcscpy(buffer, _T("Resizable window"));
|
| | 1799 | + SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_ADDSTRING, 3, (LPARAM)buffer);
|
| | 1800 | + _tcscpy(buffer, _T("Borderless window"));
|
| | 1801 | + SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_ADDSTRING, 4, (LPARAM)buffer);
|
| | 1802 | + _tcscpy(buffer, _T("Borderless window (scaled)"));
|
| | 1803 | + SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_ADDSTRING, 5, (LPARAM)buffer);
|
| | 1804 | + SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_SETCURSEL, cfg->fullmode, 0);
|
| | 1805 | + // colormode
|
| | 1806 | + if (cfg->colormode) SendDlgItemMessage(hTabs[0], IDC_COLOR, BM_SETCHECK, BST_CHECKED, 0);
|
| | 1807 | + else SendDlgItemMessage(hTabs[0], IDC_COLOR, BM_SETCHECK, BST_UNCHECKED, 0);
|
| | 1808 | + // single buffer
|
| | 1809 | + if(cfg->SingleBufferDevice) SendDlgItemMessage(hTabs[0], IDC_SINGLEBUFFER, BM_SETCHECK, BST_CHECKED, 0);
|
| | 1810 | + else SendDlgItemMessage(hTabs[0], IDC_SINGLEBUFFER, BM_SETCHECK, BST_UNCHECKED, 0);
|
| | 1811 | + // first scaling filter
|
| | 1812 | + _tcscpy(buffer, _T("Nearest"));
|
| | 1813 | + SendDlgItemMessage(hTabs[1], IDC_POSTSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1814 | + _tcscpy(buffer, _T("Bilinear"));
|
| | 1815 | + SendDlgItemMessage(hTabs[1], IDC_POSTSCALE, CB_ADDSTRING, 1, (LPARAM)buffer);
|
| | 1816 | + SendDlgItemMessage(hTabs[1], IDC_POSTSCALE, CB_SETCURSEL, cfg->postfilter, 0);
|
| | 1817 | + // first scaling sizes
|
| | 1818 | + _tcscpy(buffer, _T("Auto"));
|
| | 1819 | + SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1820 | + _tcscpy(buffer, _T("1x"));
|
| | 1821 | + SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1822 | + _tcscpy(buffer, _T("2x1"));
|
| | 1823 | + SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1824 | + _tcscpy(buffer, _T("2x"));
|
| | 1825 | + SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1826 | + _tcscpy(buffer, _T("3x"));
|
| | 1827 | + SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1828 | + _tcscpy(buffer, _T("4x"));
|
| | 1829 | + SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1830 | + SetPostScaleCombo(hTabs[1], IDC_POSTSCALESIZE, cfg->postsizex, cfg->postsizey,
|
| | 1831 | + cfgmask->postsizex, cfgmask->postsizey, tristate);
|
| | 1832 | + // primary scaling
|
| | 1833 | + _tcscpy(buffer, _T("1x scale"));
|
| | 1834 | + SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1835 | + _tcscpy(buffer, _T("Scale to screen"));
|
| | 1836 | + SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1837 | + _tcscpy(buffer, _T("Maximum integer scaling"));
|
| | 1838 | + SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1839 | + _tcscpy(buffer, _T("1.5x scale"));
|
| | 1840 | + SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1841 | + _tcscpy(buffer, _T("2x scale"));
|
| | 1842 | + SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1843 | + _tcscpy(buffer, _T("2.5x scale"));
|
| | 1844 | + SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1845 | + _tcscpy(buffer, _T("3x scale"));
|
| | 1846 | + SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1847 | + _tcscpy(buffer, _T("4x scale"));
|
| | 1848 | + SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1849 | + _tcscpy(buffer, _T("5x scale"));
|
| | 1850 | + SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1851 | + _tcscpy(buffer, _T("6x scale"));
|
| | 1852 | + SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1853 | + _tcscpy(buffer, _T("7x scale"));
|
| | 1854 | + SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1855 | + _tcscpy(buffer, _T("8x scale"));
|
| | 1856 | + SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1857 | + _tcscpy(buffer, _T("Custom scale"));
|
| | 1858 | + SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1859 | + SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_SETCURSEL, cfg->primaryscale, 0);
|
| | 1860 | + // scaling filter
|
| | 1861 | + _tcscpy(buffer,_T("Nearest"));
|
| | 1862 | + SendDlgItemMessage(hTabs[0], IDC_SCALE, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1863 | + _tcscpy(buffer,_T("Bilinear"));
|
| | 1864 | + SendDlgItemMessage(hTabs[0],IDC_SCALE,CB_ADDSTRING,1,(LPARAM)buffer);
|
| | 1865 | + SendDlgItemMessage(hTabs[0],IDC_SCALE,CB_SETCURSEL,cfg->scalingfilter,0);
|
| | 1866 | + // aspect
|
| | 1867 | + _tcscpy(buffer,_T("Default"));
|
| | 1868 | + SendDlgItemMessage(hTabs[0], IDC_ASPECT, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1869 | + _tcscpy(buffer,_T("4:3"));
|
| | 1870 | + SendDlgItemMessage(hTabs[0], IDC_ASPECT, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1871 | + _tcscpy(buffer,_T("16:10"));
|
| | 1872 | + SendDlgItemMessage(hTabs[0], IDC_ASPECT, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1873 | + _tcscpy(buffer,_T("16:9"));
|
| | 1874 | + SendDlgItemMessage(hTabs[0], IDC_ASPECT, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1875 | + _tcscpy(buffer,_T("5:4"));
|
| | 1876 | + SendDlgItemMessage(hTabs[0], IDC_ASPECT, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1877 | + SetAspectCombo(hTabs[0], IDC_ASPECT, cfg->aspect, cfgmask->aspect, tristate);
|
| | 1878 | + // texfilter
|
| | 1879 | + _tcscpy(buffer,_T("Application default"));
|
| | 1880 | + SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1881 | + _tcscpy(buffer,_T("Nearest"));
|
| | 1882 | + SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_ADDSTRING, 1, (LPARAM)buffer);
|
| | 1883 | + _tcscpy(buffer,_T("Bilinear"));
|
| | 1884 | + SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_ADDSTRING, 2, (LPARAM)buffer);
|
| | 1885 | + _tcscpy(buffer,_T("Nearest, nearest mipmap"));
|
| | 1886 | + SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_ADDSTRING, 3, (LPARAM)buffer);
|
| | 1887 | + _tcscpy(buffer,_T("Nearest, linear mipmap"));
|
| | 1888 | + SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_ADDSTRING, 4, (LPARAM)buffer);
|
| | 1889 | + _tcscpy(buffer,_T("Bilinear, nearest mipmap"));
|
| | 1890 | + SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_ADDSTRING, 5, (LPARAM)buffer);
|
| | 1891 | + _tcscpy(buffer,_T("Bilinear, linear mipmap"));
|
| | 1892 | + SendDlgItemMessage(hTabs[2],IDC_TEXFILTER,CB_ADDSTRING,6,(LPARAM)buffer);
|
| | 1893 | + SendDlgItemMessage(hTabs[2],IDC_TEXFILTER,CB_SETCURSEL,cfg->texfilter,0);
|
| | 1894 | + // anisotropic
|
| | 1895 | + if (anisotropic < 2)
|
| | 1896 | + {
|
| | 1897 | + _tcscpy(buffer,_T("Not supported"));
|
| | 1898 | + SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1899 | + SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_SETCURSEL, 0, 0);
|
| | 1900 | + EnableWindow(GetDlgItem(hTabs[2], IDC_ANISO), FALSE);
|
| | 1901 | + cfg->anisotropic = 0;
|
| | 1902 | + }
|
| | 1903 | + else
|
| | 1904 | + {
|
| | 1905 | + _tcscpy(buffer,_T("Application default"));
|
| | 1906 | + SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1907 | + _tcscpy(buffer,_T("Disabled"));
|
| | 1908 | + SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 1, (LPARAM)buffer);
|
| | 1909 | + if(anisotropic >= 2)
|
| | 1910 | + {
|
| | 1911 | + _tcscpy(buffer,_T("2x"));
|
| | 1912 | + SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 2, (LPARAM)buffer);
|
| | 1913 | + }
|
| | 1914 | + if(anisotropic >= 4)
|
| | 1915 | + {
|
| | 1916 | + _tcscpy(buffer,_T("4x"));
|
| | 1917 | + SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 4, (LPARAM)buffer);
|
| | 1918 | + }
|
| | 1919 | + if(anisotropic >= 8)
|
| | 1920 | + {
|
| | 1921 | + _tcscpy(buffer,_T("8x"));
|
| | 1922 | + SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 8, (LPARAM)buffer);
|
| | 1923 | + }
|
| | 1924 | + if(anisotropic >= 16)
|
| | 1925 | + {
|
| | 1926 | + _tcscpy(buffer,_T("16x"));
|
| | 1927 | + SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 16, (LPARAM)buffer);
|
| | 1928 | + }
|
| | 1929 | + if(anisotropic >= 32)
|
| | 1930 | + {
|
| | 1931 | + _tcscpy(buffer,_T("32x"));
|
| | 1932 | + SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 4, (LPARAM)buffer);
|
| | 1933 | + }
|
| | 1934 | + SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_SETCURSEL, cfg->anisotropic, 0);
|
| | 1935 | + }
|
| | 1936 | + // msaa
|
| | 1937 | + if(msaa)
|
| | 1938 | + {
|
| | 1939 | + _tcscpy(buffer,_T("Application default"));
|
| | 1940 | + SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1941 | + _tcscpy(buffer,_T("Disabled"));
|
| | 1942 | + SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 1, (LPARAM)buffer);
|
| | 1943 | + if(maxcoverage)
|
| | 1944 | + {
|
| | 1945 | + for(i = 0; i < maxcoverage; i++)
|
| | 1946 | + {
|
| | 1947 | + if((msaamodes[i] & 0xfff) <= 4)
|
| | 1948 | + _sntprintf(buffer,64,_T("%dx"),msaamodes[i] & 0xfff);
|
| | 1949 | + else _sntprintf(buffer,64,_T("%dx coverage, %dx color"),(msaamodes[i] & 0xfff), (msaamodes[i] >> 12));
|
| | 1950 | + SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, msaamodes[i], (LPARAM)buffer);
|
| | 1951 | + }
|
| | 1952 | + }
|
| | 1953 | + else
|
| | 1954 | + {
|
| | 1955 | + if(maxsamples >= 2)
|
| | 1956 | + {
|
| | 1957 | + _tcscpy(buffer,_T("2x"));
|
| | 1958 | + SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 2, (LPARAM)buffer);
|
| | 1959 | + }
|
| | 1960 | + if(maxsamples >= 4)
|
| | 1961 | + {
|
| | 1962 | + _tcscpy(buffer,_T("4x"));
|
| | 1963 | + SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 4, (LPARAM)buffer);
|
| | 1964 | + }
|
| | 1965 | + if(maxsamples >= 8)
|
| | 1966 | + {
|
| | 1967 | + _tcscpy(buffer,_T("8x"));
|
| | 1968 | + SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 8, (LPARAM)buffer);
|
| | 1969 | + }
|
| | 1970 | + if(maxsamples >= 16)
|
| | 1971 | + {
|
| | 1972 | + _tcscpy(buffer,_T("16x"));
|
| | 1973 | + SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 16, (LPARAM)buffer);
|
| | 1974 | + }
|
| | 1975 | + if(maxsamples >= 32)
|
| | 1976 | + {
|
| | 1977 | + _tcscpy(buffer,_T("32x"));
|
| | 1978 | + SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 32, (LPARAM)buffer);
|
| | 1979 | + }
|
| | 1980 | + }
|
| | 1981 | + SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_SETCURSEL, cfg->msaa, 0);
|
| | 1982 | + }
|
| | 1983 | + else
|
| | 1984 | + {
|
| | 1985 | + _tcscpy(buffer,_T("Not supported"));
|
| | 1986 | + SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1987 | + SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_SETCURSEL, 0, 0);
|
| | 1988 | + EnableWindow(GetDlgItem(hTabs[2], IDC_MSAA), FALSE);
|
| | 1989 | + cfg->msaa = 0;
|
| | 1990 | + }
|
| | 1991 | + // aspect3d
|
| | 1992 | + _tcscpy(buffer,_T("Stretch to display"));
|
| | 1993 | + SendDlgItemMessage(hTabs[2], IDC_ASPECT3D, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 1994 | + _tcscpy(buffer,_T("Expand viewable area"));
|
| | 1995 | + SendDlgItemMessage(hTabs[2], IDC_ASPECT3D, CB_ADDSTRING, 1, (LPARAM)buffer);
|
| | 1996 | + _tcscpy(buffer,_T("Crop to display"));
|
| | 1997 | + SendDlgItemMessage(hTabs[2],IDC_ASPECT3D,CB_ADDSTRING,2,(LPARAM)buffer);
|
| | 1998 | + SendDlgItemMessage(hTabs[2],IDC_ASPECT3D,CB_SETCURSEL,cfg->aspect3d,0);
|
| | 1999 | + // sort modes
|
| | 2000 | + _tcscpy(buffer,_T("Use system order"));
|
| | 2001 | + SendDlgItemMessage(hTabs[0], IDC_SORTMODES, CB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 2002 | + _tcscpy(buffer,_T("Group by color depth"));
|
| | 2003 | + SendDlgItemMessage(hTabs[0], IDC_SORTMODES, CB_ADDSTRING, 1, (LPARAM)buffer);
|
| | 2004 | + _tcscpy(buffer,_T("Group by resolution"));
|
| | 2005 | + SendDlgItemMessage(hTabs[0],IDC_SORTMODES,CB_ADDSTRING,2,(LPARAM)buffer);
|
| | 2006 | + SendDlgItemMessage(hTabs[0],IDC_SORTMODES,CB_SETCURSEL,cfg->SortModes,0);
|
| | 2007 | + // color depths
|
| | 2008 | + for (i = 0; i < 5; i++)
|
| | 2009 | + {
|
| | 2010 | + _tcscpy(buffer, colormodedropdown[i]);
|
| | 2011 | + SendDlgItemMessage(hTabs[0], IDC_COLORDEPTH, CB_ADDSTRING, i, (LPARAM)buffer);
|
| | 2012 | + }
|
| | 2013 | + SendDlgItemMessage(hTabs[0], IDC_COLORDEPTH, CB_SETCURSEL, cfg->AddColorDepths, 0);
|
| | 2014 | + for (i = 0; i < 7; i++)
|
| | 2015 | + {
|
| | 2016 | + _tcscpy(buffer, extramodes[i]);
|
| | 2017 | + SendDlgItemMessage(hTabs[0], IDC_EXTRAMODES, CB_ADDSTRING, i, (LPARAM)buffer);
|
| | 2018 | + }
|
| | 2019 | + // Enable shader
|
| | 2020 | + if (cfg->colormode) SendDlgItemMessage(hTabs[1], IDC_USESHADER, BM_SETCHECK, BST_CHECKED, 0);
|
| | 2021 | + else SendDlgItemMessage(hTabs[1], IDC_USESHADER, BM_SETCHECK, BST_UNCHECKED, 0);
|
| | 2022 | + // shader path
|
| | 2023 | + SetText(hTabs[1],IDC_SHADER,cfg->shaderfile,cfgmask->shaderfile,FALSE);
|
| | 2024 | + // texture format
|
| | 2025 | + _tcscpy(buffer,_T("Automatic"));
|
| | 2026 | + SendDlgItemMessage(hTabs[3],IDC_TEXTUREFORMAT,CB_ADDSTRING,0,(LPARAM)buffer);
|
| | 2027 | + SendDlgItemMessage(hTabs[3],IDC_TEXTUREFORMAT,CB_SETCURSEL,cfg->TextureFormat,0);
|
| | 2028 | + // Texture upload
|
| | 2029 | + _tcscpy(buffer,_T("Automatic"));
|
| | 2030 | + SendDlgItemMessage(hTabs[3],IDC_TEXUPLOAD,CB_ADDSTRING,0,(LPARAM)buffer);
|
| | 2031 | + SendDlgItemMessage(hTabs[3],IDC_TEXUPLOAD,CB_SETCURSEL,cfg->TexUpload,0);
|
| | 2032 | + // DPI
|
| | 2033 | + _tcscpy(buffer, _T("Disabled"));
|
| | 2034 | + SendDlgItemMessage(hTabs[0],IDC_DPISCALE,CB_ADDSTRING,0,(LPARAM)buffer);
|
| | 2035 | + _tcscpy(buffer, _T("Enabled"));
|
| | 2036 | + SendDlgItemMessage(hTabs[0],IDC_DPISCALE,CB_ADDSTRING,1,(LPARAM)buffer);
|
| | 2037 | + _tcscpy(buffer, _T("Windows AppCompat"));
|
| | 2038 | + SendDlgItemMessage(hTabs[0],IDC_DPISCALE,CB_ADDSTRING,2,(LPARAM)buffer);
|
| | 2039 | + SendDlgItemMessage(hTabs[0],IDC_DPISCALE,CB_SETCURSEL,cfg->DPIScale,0);
|
| | 2040 | + // Paths
|
| | 2041 | + EnableWindow(GetDlgItem(hTabs[3], IDC_PATHLABEL), FALSE);
|
| | 2042 | + EnableWindow(GetDlgItem(hTabs[3], IDC_PROFILEPATH), FALSE);
|
| | 2043 | + // Debug
|
| | 2044 | + _tcscpy(buffer, _T("Disable EXT framebuffers"));
|
| | 2045 | + SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 2046 | + _tcscpy(buffer, _T("Disable ARB framebuffers"));
|
| | 2047 | + SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 2048 | + _tcscpy(buffer, _T("Disable GLES2 compatibility extension"));
|
| | 2049 | + SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 2050 | + _tcscpy(buffer, _T("Disable EXT direct state access"));
|
| | 2051 | + SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 2052 | + _tcscpy(buffer, _T("Disable ARB direct state access"));
|
| | 2053 | + SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 2054 | + _tcscpy(buffer, _T("Disable sampler objects"));
|
| | 2055 | + SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 2056 | + _tcscpy(buffer, _T("Disable EXT_gpu_shader4 extension"));
|
| | 2057 | + SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 2058 | + _tcscpy(buffer, _T("Disable GLSL 1.30 support"));
|
| | 2059 | + SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
|
| | 2060 | + /*_tcscpy(buffer, _T("Disable OpenGL errors (OpenGL 4.6+)"));
|
| | 2061 | + SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);*/
|
| | 2062 | +
|
| | 2063 | + // Check install path
|
| | 2064 | + installpath = NULL;
|
| | 2065 | + error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\DXGL"), 0, KEY_READ, &hKey);
|
| | 2066 | + if (error == ERROR_SUCCESS)
|
| | 2067 | + {
|
| | 2068 | + if (RegQueryValueEx(hKey, _T("InstallDir"), NULL, NULL, NULL, &keysize) == ERROR_SUCCESS)
|
| | 2069 | + {
|
| | 2070 | + installpath = (LPTSTR)malloc(keysize);
|
| | 2071 | + error = RegQueryValueEx(hKey, _T("InstallDir"), NULL, NULL, (LPBYTE)installpath, &keysize);
|
| | 2072 | + if (error != ERROR_SUCCESS)
|
| | 2073 | + {
|
| | 2074 | + free(installpath);
|
| | 2075 | + installpath = NULL;
|
| | 2076 | + }
|
| | 2077 | + }
|
| | 2078 | + RegCloseKey(hKey);
|
| | 2079 | + }
|
| | 2080 | + hKey = NULL;
|
| | 2081 | + // Add installed programs
|
| | 2082 | + current_app = 1;
|
| | 2083 | + appcount = 1;
|
| | 2084 | + regbuffersize = 1024;
|
| | 2085 | + regbuffer = (LPTSTR)malloc(regbuffersize * sizeof(TCHAR));
|
| | 2086 | + RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\DXGL\\Profiles"), 0, NULL, 0, KEY_READ, NULL, &hKeyBase, NULL);
|
| | 2087 | + RegQueryInfoKey(hKeyBase, NULL, NULL, NULL, NULL, &keysize, NULL, NULL, NULL, NULL, NULL, NULL);
|
| | 2088 | + keysize++;
|
| | 2089 | + keyname = (LPTSTR)malloc(keysize * sizeof(TCHAR));
|
| | 2090 | + keysize2 = keysize;
|
| | 2091 | + i = 0;
|
| | 2092 | + while (RegEnumKeyEx(hKeyBase, i, keyname, &keysize2, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
| | 2093 | + {
|
| | 2094 | + keysize2 = keysize;
|
| | 2095 | + i++;
|
| | 2096 | + appcount++;
|
| | 2097 | + if (appcount > maxapps)
|
| | 2098 | + {
|
| | 2099 | + maxapps += 128;
|
| | 2100 | + apps = (app_setting *)realloc(apps, maxapps * sizeof(app_setting));
|
| | 2101 | + }
|
| | 2102 | + _tcscpy(subkey, keyname);
|
| | 2103 | + if (_tcsrchr(subkey, _T('-'))) *(_tcsrchr(subkey, _T('-'))) = 0;
|
| | 2104 | + error = RegOpenKeyEx(hKeyBase, keyname, 0, KEY_READ, &hKey);
|
| | 2105 | + buffersize = regbuffersize;
|
| | 2106 | + RegQueryValueEx(hKey, _T("InstallPath"), NULL, NULL, NULL, &buffersize);
|
| | 2107 | + if (buffersize > regbuffersize)
|
| | 2108 | + {
|
| | 2109 | + regbuffersize = buffersize;
|
| | 2110 | + regbuffer = (LPTSTR)realloc(regbuffer, regbuffersize);
|
| | 2111 | + }
|
| | 2112 | + buffersize = regbuffersize;
|
| | 2113 | + regbuffer[0] = 0;
|
| | 2114 | + error = RegQueryValueEx(hKey, _T("InstallPath"), NULL, NULL, (LPBYTE)regbuffer, &buffersize);
|
| | 2115 | + apps[appcount - 1].regkey = (LPTSTR)malloc((_tcslen(keyname) + 1) * sizeof(TCHAR));
|
| | 2116 | + _tcscpy(apps[appcount - 1].regkey, keyname);
|
| | 2117 | + GetConfig(&apps[appcount - 1].cfg, &apps[appcount - 1].mask, keyname);
|
| | 2118 | + apps[appcount - 1].dirty = FALSE;
|
| | 2119 | + if ((regbuffer[0] == 0) || error != ERROR_SUCCESS)
|
| | 2120 | + {
|
| | 2121 | + // Default icon
|
| | 2122 | + apps[appcount - 1].icon = LoadIcon(NULL, IDI_APPLICATION);
|
| | 2123 | + apps[appcount - 1].icon_shared = TRUE;
|
| | 2124 | + apps[appcount - 1].name = (TCHAR*)malloc((_tcslen(subkey) + 1) * sizeof(TCHAR));
|
| | 2125 | + _tcscpy(apps[appcount - 1].name, subkey);
|
| | 2126 | + break;
|
| | 2127 | + }
|
| | 2128 | + path = (LPTSTR)malloc(((_tcslen(regbuffer) + _tcslen(subkey) + 2)) * sizeof(TCHAR));
|
| | 2129 | + _tcscpy(path, regbuffer);
|
| | 2130 | + _tcscpy(apps[appcount - 1].path, path);
|
| | 2131 | + if (installpath)
|
| | 2132 | + {
|
| | 2133 | + if (!_tcsicmp(installpath, path)) apps[appcount - 1].builtin = TRUE;
|
| | 2134 | + else apps[appcount - 1].builtin = FALSE;
|
| | 2135 | + }
|
| | 2136 | + _tcscat(path, _T("\\"));
|
| | 2137 | + _tcscat(path, subkey);
|
| | 2138 | + if (GetFileAttributes(path) == INVALID_FILE_ATTRIBUTES)
|
| | 2139 | + {
|
| | 2140 | + // Default icon
|
| | 2141 | + apps[appcount - 1].icon = LoadIcon(NULL, IDI_APPLICATION);
|
| | 2142 | + apps[appcount - 1].icon_shared = TRUE;
|
| | 2143 | + apps[appcount - 1].name = (TCHAR*)malloc((_tcslen(subkey) + 1) * sizeof(TCHAR));
|
| | 2144 | + _tcscpy(apps[appcount - 1].name, subkey);
|
| | 2145 | + break;
|
| | 2146 | + }
|
| | 2147 | + // Get exe attributes
|
| | 2148 | + error = SHGetFileInfo(path, 0, &fileinfo, sizeof(SHFILEINFO), SHGFI_ICON | SHGFI_SMALLICON | SHGFI_ADDOVERLAYS);
|
| | 2149 | + apps[appcount - 1].icon = fileinfo.hIcon;
|
| | 2150 | + apps[appcount - 1].icon_shared = FALSE;
|
| | 2151 | + verinfosize = GetFileVersionInfoSize(path, NULL);
|
| | 2152 | + verinfo = malloc(verinfosize);
|
| | 2153 | + hasname = FALSE;
|
| | 2154 | + if (GetFileVersionInfo(path, 0, verinfosize, verinfo))
|
| | 2155 | + {
|
| | 2156 | + if (VerQueryValue(verinfo, _T("\\VarFileInfo\\Translation"), (LPVOID*)&outbuffer, &outlen))
|
| | 2157 | + {
|
| | 2158 | + memcpy(translation, outbuffer, 4);
|
| | 2159 | + _sntprintf(verpath, 64, _T("\\StringFileInfo\\%04x%04x\\FileDescription"), translation[0], translation[1]);
|
| | 2160 | + if (VerQueryValue(verinfo, verpath, (LPVOID*)&outbuffer, &outlen))
|
| | 2161 | + {
|
| | 2162 | + hasname = TRUE;
|
| | 2163 | + apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(outbuffer) + 1) * sizeof(TCHAR));
|
| | 2164 | + _tcscpy(apps[appcount - 1].name, outbuffer);
|
| | 2165 | + }
|
| | 2166 | + else
|
| | 2167 | + {
|
| | 2168 | + _sntprintf(verpath, 64, _T("\\StringFileInfo\\%04x%04x\\ProductName"), ((WORD*)outbuffer)[0], ((WORD*)outbuffer)[1]);
|
| | 2169 | + if (VerQueryValue(verinfo, verpath, (LPVOID*)&outbuffer, &outlen))
|
| | 2170 | + {
|
| | 2171 | + hasname = TRUE;
|
| | 2172 | + apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(outbuffer) + 1) * sizeof(TCHAR));
|
| | 2173 | + _tcscpy(apps[appcount - 1].name, outbuffer);
|
| | 2174 | + }
|
| | 2175 | + else
|
| | 2176 | + {
|
| | 2177 | + _sntprintf(verpath, 64, _T("\\StringFileInfo\\%04x%04x\\InternalName"), ((WORD*)outbuffer)[0], ((WORD*)outbuffer)[1]);
|
| | 2178 | + if (VerQueryValue(verinfo, verpath, (LPVOID*)&outbuffer, &outlen))
|
| | 2179 | + {
|
| | 2180 | + hasname = TRUE;
|
| | 2181 | + apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(outbuffer) + 1) * sizeof(TCHAR));
|
| | 2182 | + _tcscpy(apps[appcount - 1].name, outbuffer);
|
| | 2183 | + }
|
| | 2184 | + }
|
| | 2185 | + }
|
| | 2186 | + }
|
| | 2187 | + }
|
| | 2188 | + free(path);
|
| | 2189 | + if (!hasname)
|
| | 2190 | + {
|
| | 2191 | + apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(subkey) + 1) * sizeof(TCHAR));
|
| | 2192 | + _tcscpy(apps[appcount - 1].name, subkey);
|
| | 2193 | + }
|
| | 2194 | + free(verinfo);
|
| | 2195 | + RegCloseKey(hKey);
|
| | 2196 | + }
|
| | 2197 | + RegCloseKey(hKeyBase);
|
| | 2198 | + free(keyname);
|
| | 2199 | + for(i = 0; i < appcount; i++)
|
| | 2200 | + {
|
| | 2201 | + SendDlgItemMessage(hWnd,IDC_APPS,CB_ADDSTRING,0,(LPARAM)apps[i].name);
|
| | 2202 | + }
|
| | 2203 | + current_app = 0;
|
| | 2204 | + SendDlgItemMessage(hWnd,IDC_APPS,CB_SETCURSEL,0,0);
|
| | 2205 | + GetWindowRect(GetDlgItem(hWnd, IDC_APPS), &r);
|
| | 2206 | + SetWindowPos(GetDlgItem(hWnd, IDC_APPS), HWND_TOP, r.left, r.top, r.right - r.left,
|
| | 2207 | + (r.bottom - r.top) + (16 * (GetSystemMetrics(SM_CYSMICON) + 1)+(2*GetSystemMetrics(SM_CYBORDER))),
|
| | 2208 | + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
|
| | 2209 | + if(osver.dwMajorVersion >= 6)
|
| | 2210 | + {
|
| | 2211 | + if(OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY,&token))
|
| | 2212 | + {
|
| | 2213 | + if(GetTokenInformation(token,(TOKEN_INFORMATION_CLASS)TokenElevation,&elevation,sizeof(TOKEN_ELEVATION),(PDWORD)&outlen))
|
| | 2214 | + {
|
| | 2215 | + if(!elevation.TokenIsElevated)
|
| | 2216 | + {
|
| | 2217 | + SendDlgItemMessage(hWnd,IDC_ADD,BCM_SETSHIELD,0,TRUE);
|
| | 2218 | + SendDlgItemMessage(hWnd,IDC_REMOVE,BCM_SETSHIELD,0,TRUE);
|
| | 2219 | + }
|
| | 2220 | + }
|
| | 2221 | + }
|
| | 2222 | + }
|
| | 2223 | + else
|
| | 2224 | + {
|
| | 2225 | + EnableWindow(GetDlgItem(hTabs[0], IDC_DPISCALE), FALSE);
|
| | 2226 | + }
|
| | 2227 | + if(token) CloseHandle(token);
|
| | 2228 | + return TRUE;
|
| | 2229 | + case WM_MEASUREITEM:
|
| | 2230 | + switch(wParam)
|
| | 2231 | + {
|
| | 2232 | + case IDC_APPS:
|
| | 2233 | + ((LPMEASUREITEMSTRUCT)lParam)->itemHeight = GetSystemMetrics(SM_CYSMICON) + 1;
|
| | 2234 | + ((LPMEASUREITEMSTRUCT)lParam)->itemWidth = GetSystemMetrics(SM_CXSMICON)+1;
|
| | 2235 | + break;
|
| | 2236 | + default:
|
| | 2237 | + break;
|
| | 2238 | + }
|
| | 2239 | + break;
|
| | 2240 | + case WM_NOTIFY:
|
| | 2241 | + nm = (LPNMHDR)lParam;
|
| | 2242 | + if (nm->code == TCN_SELCHANGE)
|
| | 2243 | + {
|
| | 2244 | + newtab = SendDlgItemMessage(hWnd, IDC_TABS, TCM_GETCURSEL, 0, 0);
|
| | 2245 | + if (newtab != tabopen)
|
| | 2246 | + {
|
| | 2247 | + ShowWindow(hTabs[tabopen], SW_HIDE);
|
| | 2248 | + tabopen = newtab;
|
| | 2249 | + SendDlgItemMessage(hWnd, IDC_TABS, TCM_GETITEMRECT, 0, (LPARAM)&r);
|
| | 2250 | + SetWindowPos(hTabs[tabopen], NULL, r.left, r.bottom + 3, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
|
| | 2251 | + }
|
| | 2252 | + }
|
| | 2253 | + break;
|
| | 2254 | + case WM_DRAWITEM:
|
| | 2255 | + drawitem = (DRAWITEMSTRUCT*)lParam;
|
| | 2256 | + switch (wParam)
|
| | 2257 | + {
|
| | 2258 | + case IDC_APPS:
|
| | 2259 | + OldTextColor = GetTextColor(drawitem->hDC);
|
| | 2260 | + OldBackColor = GetBkColor(drawitem->hDC);
|
| | 2261 | + if((drawitem->itemState & ODS_SELECTED))
|
| | 2262 | + {
|
| | 2263 | + SetTextColor(drawitem->hDC,GetSysColor(COLOR_HIGHLIGHTTEXT));
|
| | 2264 | + SetBkColor(drawitem->hDC,GetSysColor(COLOR_HIGHLIGHT));
|
| | 2265 | + FillRect(drawitem->hDC,&drawitem->rcItem,(HBRUSH)(COLOR_HIGHLIGHT+1));
|
| | 2266 | + }
|
| | 2267 | + else
|
| | 2268 | + {
|
| | 2269 | + SetTextColor(drawitem->hDC, GetSysColor(COLOR_WINDOWTEXT));
|
| | 2270 | + SetBkColor(drawitem->hDC, GetSysColor(COLOR_WINDOW));
|
| | 2271 | + FillRect(drawitem->hDC, &drawitem->rcItem, (HBRUSH)(COLOR_WINDOW + 1));
|
| | 2272 | + }
|
| | 2273 | + DrawIconEx(drawitem->hDC,drawitem->rcItem.left+2,drawitem->rcItem.top,
|
| | 2274 | + apps[drawitem->itemID].icon,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0,NULL,DI_NORMAL);
|
| | 2275 | + drawitem->rcItem.left += GetSystemMetrics(SM_CXSMICON)+5;
|
| | 2276 | + DrawText(drawitem->hDC,apps[drawitem->itemID].name,
|
| | 2277 | + _tcslen(apps[drawitem->itemID].name),&drawitem->rcItem,
|
| | 2278 | + DT_LEFT|DT_SINGLELINE|DT_VCENTER);
|
| | 2279 | + drawitem->rcItem.left -= GetSystemMetrics(SM_CXSMICON)+5;
|
| | 2280 | + if (drawitem->itemState & ODS_FOCUS) DrawFocusRect(drawitem->hDC, &drawitem->rcItem);
|
| | 2281 | + SetTextColor(drawitem->hDC,OldTextColor);
|
| | 2282 | + SetBkColor(drawitem->hDC,OldBackColor);
|
| | 2283 | + DefWindowProc(hWnd,Msg,wParam,lParam);
|
| | 2284 | + break;
|
| | 2285 | + default:
|
| | 2286 | + break;
|
| | 2287 | + }
|
| | 2288 | + break;
|
| | 2289 | + case WM_HELP:
|
| | 2290 | + HtmlHelp(hWnd,hlppath,HH_DISPLAY_TOPIC,(DWORD_PTR)_T("configuration.htm"));
|
| | 2291 | + return TRUE;
|
| | 2292 | + break;
|
| | 2293 | + case WM_SYSCOMMAND:
|
| | 2294 | + if(LOWORD(wParam) == SC_CONTEXTHELP)
|
| | 2295 | + {
|
| | 2296 | + HtmlHelp(hWnd,hlppath,HH_DISPLAY_TOPIC,(DWORD_PTR)_T("configuration.htm"));
|
| | 2297 | + return TRUE;
|
| | 2298 | + }
|
| | 2299 | + break;
|
| | 2300 | + case WM_COMMAND:
|
| | 2301 | + switch(LOWORD(wParam))
|
| | 2302 | + {
|
| | 2303 | + case IDOK:
|
| | 2304 | + SaveChanges(hWnd);
|
| | 2305 | + EndDialog(hWnd,IDOK);
|
| | 2306 | + return TRUE;
|
| | 2307 | + case IDCANCEL:
|
| | 2308 | + EndDialog(hWnd,IDCANCEL);
|
| | 2309 | + return TRUE;
|
| | 2310 | + case IDC_APPLY:
|
| | 2311 | + SaveChanges(hWnd);
|
| | 2312 | + return TRUE;
|
| | 2313 | + case IDC_APPS:
|
| | 2314 | + if(HIWORD(wParam) == CBN_SELCHANGE)
|
| | 2315 | + {
|
| | 2316 | + cursel = SendDlgItemMessage(hWnd,IDC_APPS,CB_GETCURSEL,0,0);
|
| | 2317 | + if(cursel == current_app) break;
|
| | 2318 | + current_app = cursel;
|
| | 2319 | + cfg = &apps[current_app].cfg;
|
| | 2320 | + cfgmask = &apps[current_app].mask;
|
| | 2321 | + dirty = &apps[current_app].dirty;
|
| | 2322 | + if (current_app)
|
| | 2323 | + {
|
| | 2324 | + EnableWindow(GetDlgItem(hTabs[3], IDC_PATHLABEL), TRUE);
|
| | 2325 | + EnableWindow(GetDlgItem(hTabs[3], IDC_PROFILEPATH), TRUE);
|
| | 2326 | + SetDlgItemText(hTabs[3], IDC_PROFILEPATH, apps[current_app].path);
|
| | 2327 | + if (apps[current_app].builtin) EnableWindow(GetDlgItem(hWnd, IDC_REMOVE), FALSE);
|
| | 2328 | + else EnableWindow(GetDlgItem(hWnd, IDC_REMOVE), TRUE);
|
| | 2329 | + }
|
| | 2330 | + else
|
| | 2331 | + {
|
| | 2332 | + EnableWindow(GetDlgItem(hTabs[3], IDC_PATHLABEL), FALSE);
|
| | 2333 | + EnableWindow(GetDlgItem(hTabs[3], IDC_PROFILEPATH), FALSE);
|
| | 2334 | + SetDlgItemText(hTabs[3], IDC_PROFILEPATH, _T(""));
|
| | 2335 | + EnableWindow(GetDlgItem(hWnd, IDC_REMOVE), FALSE);
|
| | 2336 | + }
|
| | 2337 | + // Set 3-state status
|
| | 2338 | + if(current_app && !tristate)
|
| | 2339 | + {
|
| | 2340 | + tristate = TRUE;
|
| | 2341 | + // Display tab
|
| | 2342 | + SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| | 2343 | + SendDlgItemMessage(hTabs[0], IDC_COLORDEPTH, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| | 2344 | + SendDlgItemMessage(hTabs[0], IDC_SCALE, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| | 2345 | + SendDlgItemMessage(hTabs[0], IDC_EXTRAMODES, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| | 2346 | + SendDlgItemMessage(hTabs[0], IDC_ASPECT, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| | 2347 | + SendDlgItemMessage(hTabs[0], IDC_SORTMODES, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| | 2348 | + SendDlgItemMessage(hTabs[0], IDC_DPISCALE, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| | 2349 | + SendDlgItemMessage(hTabs[0], IDC_VSYNC, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| | 2350 | + SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| | 2351 | + SendDlgItemMessage(hTabs[0], IDC_COLOR, BM_SETSTYLE, BS_AUTO3STATE, (LPARAM)TRUE);
|
| | 2352 | + SendDlgItemMessage(hTabs[0], IDC_SINGLEBUFFER, BM_SETSTYLE, BS_AUTO3STATE, (LPARAM)TRUE);
|
| | 2353 | + SendDlgItemMessage(hTabs[1], IDC_POSTSCALE, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| | 2354 | + SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| | 2355 | + SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| | 2356 | + SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| | 2357 | + SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| | 2358 | + SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| | 2359 | + SendDlgItemMessage(hTabs[2], IDC_ASPECT3D, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| | 2360 | + SendDlgItemMessage(hTabs[3],IDC_TEXTUREFORMAT,CB_ADDSTRING,0,(LPARAM)strdefault);
|
| | 2361 | + SendDlgItemMessage(hTabs[3],IDC_TEXUPLOAD,CB_ADDSTRING,0,(LPARAM)strdefault);
|
| | 2362 | + }
|
| | 2363 | + else if(!current_app && tristate)
|
| | 2364 | + {
|
| | 2365 | + tristate = FALSE;
|
| | 2366 | + // Display tab
|
| | 2367 | + SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_DELETESTRING,
|
| | 2368 | + SendDlgItemMessage(hTabs[0], IDC_VIDMODE, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 2369 | + SendDlgItemMessage(hTabs[0], IDC_COLORDEPTH, CB_DELETESTRING,
|
| | 2370 | + SendDlgItemMessage(hTabs[0], IDC_COLORDEPTH, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 2371 | + SendDlgItemMessage(hTabs[0], IDC_SCALE, CB_DELETESTRING,
|
| | 2372 | + SendDlgItemMessage(hTabs[0], IDC_SCALE, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 2373 | + SendDlgItemMessage(hTabs[0], IDC_EXTRAMODES, CB_DELETESTRING,
|
| | 2374 | + SendDlgItemMessage(hTabs[0], IDC_EXTRAMODES, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 2375 | + SendDlgItemMessage(hTabs[0], IDC_ASPECT, CB_DELETESTRING,
|
| | 2376 | + SendDlgItemMessage(hTabs[0], IDC_ASPECT, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 2377 | + SendDlgItemMessage(hTabs[0], IDC_SORTMODES, CB_DELETESTRING,
|
| | 2378 | + SendDlgItemMessage(hTabs[0], IDC_SORTMODES, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 2379 | + SendDlgItemMessage(hTabs[0], IDC_DPISCALE, CB_DELETESTRING,
|
| | 2380 | + SendDlgItemMessage(hTabs[0], IDC_DPISCALE, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 2381 | + SendDlgItemMessage(hTabs[0], IDC_VSYNC, CB_DELETESTRING,
|
| | 2382 | + SendDlgItemMessage(hTabs[0], IDC_VSYNC, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 2383 | + SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_DELETESTRING,
|
| | 2384 | + SendDlgItemMessage(hTabs[0], IDC_FULLMODE, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 2385 | + SendDlgItemMessage(hTabs[0], IDC_COLOR, BM_SETSTYLE, BS_AUTOCHECKBOX, (LPARAM)TRUE);
|
| | 2386 | + SendDlgItemMessage(hTabs[0], IDC_SINGLEBUFFER, BM_SETSTYLE, BS_AUTOCHECKBOX, (LPARAM)TRUE);
|
| | 2387 | + SendDlgItemMessage(hTabs[1], IDC_POSTSCALE, CB_DELETESTRING,
|
| | 2388 | + SendDlgItemMessage(hTabs[1], IDC_POSTSCALE, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 2389 | + SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_DELETESTRING,
|
| | 2390 | + SendDlgItemMessage(hTabs[1], IDC_POSTSCALESIZE, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 2391 | + SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_DELETESTRING,
|
| | 2392 | + SendDlgItemMessage(hTabs[1], IDC_PRIMARYSCALE, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 2393 | + SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_DELETESTRING,
|
| | 2394 | + SendDlgItemMessage(hTabs[2], IDC_TEXFILTER, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 2395 | + SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_DELETESTRING,
|
| | 2396 | + SendDlgItemMessage(hTabs[2], IDC_ANISO, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 2397 | + SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_DELETESTRING,
|
| | 2398 | + SendDlgItemMessage(hTabs[2], IDC_MSAA, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 2399 | + SendDlgItemMessage(hTabs[2], IDC_ASPECT3D, CB_DELETESTRING,
|
| | 2400 | + SendDlgItemMessage(hTabs[2], IDC_ASPECT3D, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| | 2401 | + SendDlgItemMessage(hTabs[3],IDC_TEXTUREFORMAT,CB_DELETESTRING,
|
| | 2402 | + SendDlgItemMessage(hTabs[3],IDC_ASPECT3D,CB_FINDSTRING,-1,(LPARAM)strdefault),0);
|
| | 2403 | + SendDlgItemMessage(hTabs[3],IDC_TEXUPLOAD,CB_DELETESTRING,
|
| | 2404 | + SendDlgItemMessage(hTabs[3],IDC_ASPECT3D,CB_FINDSTRING,-1,(LPARAM)strdefault),0);
|
| | 2405 | + }
|
| | 2406 | + // Read settings into controls
|
| | 2407 | + // Display tab
|
| | 2408 | + SetCombo(hTabs[0], IDC_VIDMODE, cfg->scaler, cfgmask->scaler, tristate);
|
| | 2409 | + SetCombo(hTabs[0], IDC_COLORDEPTH, 0, 0, tristate);
|
| | 2410 | + SetCombo(hTabs[0], IDC_SCALE, cfg->scalingfilter, cfgmask->scalingfilter, tristate);
|
| | 2411 | + SetCombo(hTabs[0], IDC_EXTRAMODES, 0, 0, tristate);
|
| | 2412 | + SetAspectCombo(hTabs[0], IDC_ASPECT, cfg->aspect, cfgmask->aspect, tristate);
|
| | 2413 | + SetCombo(hTabs[0], IDC_SORTMODES, cfg->SortModes, cfgmask->SortModes, tristate);
|
| | 2414 | + SetCombo(hTabs[0], IDC_DPISCALE, cfg->DPIScale, cfgmask->DPIScale, tristate);
|
| | 2415 | + SetCombo(hTabs[0], IDC_VSYNC, cfg->vsync, cfgmask->vsync, tristate);
|
| | 2416 | + SetCombo(hTabs[0], IDC_FULLMODE, cfg->fullmode, cfgmask->fullmode, tristate);
|
| | 2417 | + SetCheck(hTabs[0], IDC_COLOR, cfg->colormode, cfgmask->colormode, tristate);
|
| | 2418 | + SetCheck(hTabs[0], IDC_SINGLEBUFFER, cfg->SingleBufferDevice, cfgmask->SingleBufferDevice, tristate);
|
| | 2419 | + SetCombo(hTabs[1], IDC_POSTSCALE, cfg->postfilter, cfgmask->postfilter, tristate);
|
| | 2420 | + SetPostScaleCombo(hTabs[1], IDC_POSTSCALESIZE, cfg->postsizex, cfg->postsizey,
|
| | 2421 | + cfgmask->postsizex , cfgmask->postsizey, tristate);
|
| | 2422 | + SetCombo(hTabs[1], IDC_PRIMARYSCALE, cfg->primaryscale, cfgmask->primaryscale, tristate);
|
| | 2423 | + SetText(hTabs[1], IDC_SHADER, cfg->shaderfile, cfgmask->shaderfile, tristate);
|
| | 2424 | + SetCombo(hTabs[2], IDC_TEXFILTER, cfg->texfilter, cfgmask->texfilter, tristate);
|
| | 2425 | + SetCombo(hTabs[2], IDC_ANISO, cfg->anisotropic, cfgmask->anisotropic, tristate);
|
| | 2426 | + SetCombo(hTabs[2], IDC_MSAA, cfg->msaa, cfgmask->msaa, tristate);
|
| | 2427 | + SetCombo(hTabs[2], IDC_ASPECT3D, cfg->aspect3d, cfgmask->aspect3d, tristate);
|
| | 2428 | + SetCombo(hTabs[3],IDC_TEXTUREFORMAT,cfg->TextureFormat,cfgmask->TextureFormat,tristate);
|
| | 2429 | + SetCombo(hTabs[3],IDC_TEXUPLOAD,cfg->TexUpload,cfgmask->TexUpload,tristate);
|
| | 2430 | + RedrawWindow(GetDlgItem(hTabs[4], IDC_DEBUGLIST), NULL, NULL, RDW_INVALIDATE);
|
| | 2431 | + }
|
| | 2432 | + break;
|
| | 2433 | + case IDC_ADD:
|
| | 2434 | + selectedfile[0] = 0;
|
| | 2435 | + ZeroMemory(&filename, OPENFILENAME_SIZE_VERSION_400);
|
| | 2436 | + filename.lStructSize = OPENFILENAME_SIZE_VERSION_400;
|
| | 2437 | + filename.hwndOwner = hWnd;
|
| | 2438 | + filename.lpstrFilter = exe_filter;
|
| | 2439 | + filename.lpstrFile = selectedfile;
|
| | 2440 | + filename.nMaxFile = MAX_PATH + 1;
|
| | 2441 | + filename.lpstrInitialDir = _T("%ProgramFiles%");
|
| | 2442 | + filename.lpstrTitle = _T("Select program");
|
| | 2443 | + filename.Flags = OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
|
| | 2444 | + if (GetOpenFileName(&filename))
|
| | 2445 | + {
|
| | 2446 | + if (CheckProfileExists(filename.lpstrFile))
|
| | 2447 | + {
|
| | 2448 | + MessageBox(hWnd, _T("A profile already exists for this program."),
|
| | 2449 | + _T("Profile already exists"), MB_OK | MB_ICONWARNING);
|
| | 2450 | + break;
|
| | 2451 | + }
|
| | 2452 | + err = AddApp(filename.lpstrFile, TRUE, FALSE, FALSE, hWnd);
|
| | 2453 | + if (!err)
|
| | 2454 | + {
|
| | 2455 | + LPTSTR newkey = MakeNewConfig(filename.lpstrFile);
|
| | 2456 | + LPTSTR newkey2 = (LPTSTR)malloc((_tcslen(newkey) + 24) * sizeof(TCHAR));
|
| | 2457 | + _tcscpy(newkey2, _T("Software\\DXGL\\Profiles\\"));
|
| | 2458 | + _tcscat(newkey2, newkey);
|
| | 2459 | + appcount++;
|
| | 2460 | + if (appcount > maxapps)
|
| | 2461 | + {
|
| | 2462 | + maxapps += 128;
|
| | 2463 | + apps = (app_setting *)realloc(apps, maxapps * sizeof(app_setting));
|
| | 2464 | + }
|
| | 2465 | + RegOpenKeyEx(HKEY_CURRENT_USER, newkey2, 0, KEY_READ, &hKey);
|
| | 2466 | + RegQueryValueEx(hKey, _T("InstallPath"), NULL, NULL, NULL, &buffersize);
|
| | 2467 | + regbuffer = (LPTSTR)malloc(buffersize);
|
| | 2468 | + regbuffer[0] = 0;
|
| | 2469 | + error = RegQueryValueEx(hKey, _T("InstallPath"), NULL, NULL, (LPBYTE)regbuffer, &buffersize);
|
| | 2470 | + apps[appcount - 1].regkey = (LPTSTR)malloc((_tcslen(newkey) + 1) * sizeof(TCHAR));
|
| | 2471 | + _tcscpy(apps[appcount - 1].regkey, newkey);
|
| | 2472 | + GetConfig(&apps[appcount - 1].cfg, &apps[appcount - 1].mask, newkey);
|
| | 2473 | + apps[appcount - 1].dirty = FALSE;
|
| | 2474 | + free(newkey2);
|
| | 2475 | + if ((regbuffer[0] == 0) || error != ERROR_SUCCESS)
|
| | 2476 | + {
|
| | 2477 | + // Default icon
|
| | 2478 | + apps[appcount - 1].icon = LoadIcon(NULL, IDI_APPLICATION);
|
| | 2479 | + apps[appcount - 1].icon_shared = TRUE;
|
| | 2480 | + apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(newkey) + 1) * sizeof(TCHAR));
|
| | 2481 | + _tcscpy(apps[appcount - 1].name, newkey);
|
| | 2482 | + break;
|
| | 2483 | + }
|
| | 2484 | + if (_tcsrchr(newkey, _T('-'))) *(_tcsrchr(newkey, _T('-'))) = 0;
|
| | 2485 | + path = (LPTSTR)malloc(((_tcslen(regbuffer) + _tcslen(newkey) + 2)) * sizeof(TCHAR));
|
| | 2486 | + _tcscpy(path, regbuffer);
|
| | 2487 | + _tcscpy(apps[appcount - 1].path, path);
|
| | 2488 | + _tcscat(path, _T("\\"));
|
| | 2489 | + _tcscat(path, newkey);
|
| | 2490 | + if (GetFileAttributes(path) == INVALID_FILE_ATTRIBUTES)
|
| | 2491 | + {
|
| | 2492 | + // Default icon
|
| | 2493 | + apps[appcount - 1].icon = LoadIcon(NULL, IDI_APPLICATION);
|
| | 2494 | + apps[appcount - 1].icon_shared = TRUE;
|
| | 2495 | + apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(newkey) + 1) * sizeof(TCHAR));
|
| | 2496 | + _tcscpy(apps[appcount - 1].name, newkey);
|
| | 2497 | + break;
|
| | 2498 | + }
|
| | 2499 | + else
|
| | 2500 | + {
|
| | 2501 | + // Get exe attributes
|
| | 2502 | + error = SHGetFileInfo(path, 0, &fileinfo, sizeof(SHFILEINFO), SHGFI_ICON | SHGFI_SMALLICON | SHGFI_ADDOVERLAYS);
|
| | 2503 | + apps[appcount - 1].icon = fileinfo.hIcon;
|
| | 2504 | + apps[appcount - 1].icon_shared = FALSE;
|
| | 2505 | + verinfosize = GetFileVersionInfoSize(path, NULL);
|
| | 2506 | + verinfo = malloc(verinfosize);
|
| | 2507 | + hasname = FALSE;
|
| | 2508 | + if (GetFileVersionInfo(path, 0, verinfosize, verinfo))
|
| | 2509 | + {
|
| | 2510 | + if (VerQueryValue(verinfo, _T("\\VarFileInfo\\Translation"), (LPVOID*)&outbuffer, &outlen))
|
| | 2511 | + {
|
| | 2512 | + memcpy(translation, outbuffer, 4);
|
| | 2513 | + _sntprintf(verpath, 64, _T("\\StringFileInfo\\%04x%04x\\FileDescription"), translation[0], translation[1]);
|
| | 2514 | + if (VerQueryValue(verinfo, verpath, (LPVOID*)&outbuffer, &outlen))
|
| | 2515 | + {
|
| | 2516 | + hasname = TRUE;
|
| | 2517 | + apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(outbuffer) + 1) * sizeof(TCHAR));
|
| | 2518 | + _tcscpy(apps[appcount - 1].name, outbuffer);
|
| | 2519 | + }
|
| | 2520 | + else
|
| | 2521 | + {
|
| | 2522 | + _sntprintf(verpath, 64, _T("\\StringFileInfo\\%04x%04x\\ProductName"), ((WORD*)outbuffer)[0], ((WORD*)outbuffer)[1]);
|
| | 2523 | + if (VerQueryValue(verinfo, verpath, (LPVOID*)&outbuffer, &outlen))
|
| | 2524 | + {
|
| | 2525 | + hasname = TRUE;
|
| | 2526 | + apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(outbuffer) + 1) * sizeof(TCHAR));
|
| | 2527 | + _tcscpy(apps[appcount - 1].name, outbuffer);
|
| | 2528 | + }
|
| | 2529 | + else
|
| | 2530 | + {
|
| | 2531 | + _sntprintf(verpath, 64, _T("\\StringFileInfo\\%04x%04x\\InternalName"), ((WORD*)outbuffer)[0], ((WORD*)outbuffer)[1]);
|
| | 2532 | + if (VerQueryValue(verinfo, verpath, (LPVOID*)&outbuffer, &outlen))
|
| | 2533 | + {
|
| | 2534 | + hasname = TRUE;
|
| | 2535 | + apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(outbuffer) + 1) * sizeof(TCHAR));
|
| | 2536 | + _tcscpy(apps[appcount - 1].name, outbuffer);
|
| | 2537 | + }
|
| | 2538 | + }
|
| | 2539 | + }
|
| | 2540 | + }
|
| | 2541 | + }
|
| | 2542 | + if (!hasname)
|
| | 2543 | + {
|
| | 2544 | + apps[appcount - 1].name = (LPTSTR)malloc((_tcslen(newkey) + 1) * sizeof(TCHAR));
|
| | 2545 | + _tcscpy(apps[appcount - 1].name, newkey);
|
| | 2546 | + }
|
| | 2547 | + free(verinfo);
|
| | 2548 | + free(path);
|
| | 2549 | + }
|
| | 2550 | + SendDlgItemMessage(hWnd, IDC_APPS, CB_SETCURSEL,
|
| | 2551 | + SendDlgItemMessage(hWnd, IDC_APPS, CB_ADDSTRING, 0, (LPARAM)apps[appcount - 1].name), 0);
|
| | 2552 | + SendMessage(hWnd, WM_COMMAND, IDC_APPS + 0x10000, 0);
|
| | 2553 | + RegCloseKey(hKey);
|
| | 2554 | + free(regbuffer);
|
| | 2555 | + }
|
| | 2556 | + }
|
| | 2557 | + break;
|
| | 2558 | + case IDC_REMOVE:
|
| | 2559 | + if(MessageBox(hWnd,_T("Do you want to delete the selected application profile and remove DXGL from its installation folder(s)?"),
|
| | 2560 | + _T("Confirmation"),MB_YESNO|MB_ICONQUESTION) != IDYES) return FALSE;
|
| | 2561 | + regpath = (LPTSTR)malloc((_tcslen(apps[current_app].regkey) + 24)*sizeof(TCHAR));
|
| | 2562 | + _tcscpy(regpath, _T("Software\\DXGL\\Profiles\\"));
|
| | 2563 | + _tcscat(regpath, apps[current_app].regkey);
|
| | 2564 | + regkey = (LPTSTR)malloc((_tcslen(apps[current_app].regkey) + 1) * sizeof(TCHAR));
|
| | 2565 | + _tcscpy(regkey, apps[current_app].regkey);
|
| | 2566 | + RegOpenKeyEx(HKEY_CURRENT_USER,regpath,0,KEY_READ,&hKey);
|
| | 2567 | + RegQueryValueEx(hKey,_T("InstallPath"),NULL,NULL,NULL,&buffersize);
|
| | 2568 | + regbuffer = (LPTSTR)malloc(buffersize);
|
| | 2569 | + regbuffer[0] = 0;
|
| | 2570 | + failed = FALSE;
|
| | 2571 | + error = RegQueryValueEx(hKey, _T("InstallPath"), NULL, NULL, (LPBYTE)regbuffer, &buffersize);
|
| | 2572 | + path = (LPTSTR)malloc(((_tcslen(regbuffer) + 12)) * sizeof(TCHAR));
|
| | 2573 | + _tcscpy(path, regbuffer);
|
| | 2574 | + _tcscat(path, _T("\\ddraw.dll"));
|
| | 2575 | + if (GetFileAttributes(path) != INVALID_FILE_ATTRIBUTES)
|
| | 2576 | + {
|
| | 2577 | + if (DelApp(path, FALSE, hWnd)) failed = TRUE;
|
| | 2578 | + }
|
| | 2579 | + free(path);
|
| | 2580 | + free(regbuffer);
|
| | 2581 | + RegCloseKey(hKey);
|
| | 2582 | + if(!failed)
|
| | 2583 | + {
|
| | 2584 | + RegDeleteKey(HKEY_CURRENT_USER,regpath);
|
| | 2585 | + if(!apps[current_app].icon_shared) DeleteObject(apps[current_app].icon);
|
| | 2586 | + if(apps[current_app].name) free(apps[current_app].name);
|
| | 2587 | + if(apps[current_app].regkey) free(apps[current_app].regkey);
|
| | 2588 | + for(i = current_app; i < appcount; i++)
|
| | 2589 | + {
|
| | 2590 | + apps[i] = apps[i+1];
|
| | 2591 | + }
|
| | 2592 | + appcount--;
|
| | 2593 | + }
|
| | 2594 | + SendDlgItemMessage(hWnd, IDC_APPS, CB_SETCURSEL, 0, 0);
|
| | 2595 | + SendDlgItemMessage(hWnd,IDC_APPS,CB_DELETESTRING,current_app,0);
|
| | 2596 | + SendMessage(hWnd, WM_COMMAND, IDC_APPS + 0x10000, 0);
|
| | 2597 | + break;
|
| | 2598 | + }
|
| | 2599 | + break;
|
| | 2600 | + }
|
| | 2601 | + return FALSE;
|
| | 2602 | +}
|
| | 2603 | +
|
| | 2604 | +void UpgradeDXGL()
|
| | 2605 | +{
|
| | 2606 | + HKEY hKeyBase;
|
| | 2607 | + HKEY hKey;
|
| | 2608 | + DWORD keysize, keysize2;
|
| | 2609 | + int i = 0;
|
| | 2610 | + LONG error;
|
| | 2611 | + LPTSTR keyname;
|
| | 2612 | + DWORD sizeout;
|
| | 2613 | + DWORD buffersize;
|
| | 2614 | + DWORD regbuffersize;
|
| | 2615 | + LPTSTR regbuffer;
|
| | 2616 | + BOOL installed = FALSE;
|
| | 2617 | + BOOL dxgl_installdir = FALSE;
|
| | 2618 | + BOOL old_dxgl = FALSE;
|
| | 2619 | + HKEY hKeyInstall;
|
| | 2620 | + TCHAR installpath[MAX_PATH + 1];
|
| | 2621 | + TCHAR srcpath[MAX_PATH + 1];
|
| | 2622 | + TCHAR destpath[MAX_PATH + 1];
|
| | 2623 | + TCHAR inipath[MAX_PATH + 1];
|
| | 2624 | + TCHAR backuppath[MAX_PATH + 1];
|
| | 2625 | + app_ini_options inioptions;
|
| | 2626 | + HMODULE hmod;
|
| | 2627 | + UpgradeConfig();
|
| | 2628 | + regbuffersize = 1024;
|
| | 2629 | + regbuffer = (LPTSTR)malloc(regbuffersize * sizeof(TCHAR));
|
| | 2630 | + RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\DXGL\\Profiles"), 0, NULL, 0, KEY_READ, NULL, &hKeyBase, NULL);
|
| | 2631 | + RegQueryInfoKey(hKeyBase, NULL, NULL, NULL, NULL, &keysize, NULL, NULL, NULL, NULL, NULL, NULL);
|
| | 2632 | + keysize++;
|
| | 2633 | + keyname = (LPTSTR)malloc(keysize * sizeof(TCHAR));
|
| | 2634 | + keysize2 = keysize;
|
| | 2635 | + error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\DXGL"), 0, KEY_READ, &hKeyInstall);
|
| | 2636 | + if (error == ERROR_SUCCESS)
|
| | 2637 | + {
|
| | 2638 | + dxgl_installdir = TRUE;
|
| | 2639 | + sizeout = (MAX_PATH + 1) * sizeof(TCHAR);
|
| | 2640 | + error = RegQueryValueEx(hKeyInstall, _T("InstallDir"), NULL, NULL, (LPBYTE)installpath, &sizeout);
|
| | 2641 | + if (error == ERROR_SUCCESS) installed = TRUE;
|
| | 2642 | + }
|
| | 2643 | + if (hKeyInstall) RegCloseKey(hKeyInstall);
|
| | 2644 | + if (!installed)
|
| | 2645 | + {
|
| | 2646 | + GetModuleFileName(NULL, installpath, MAX_PATH + 1);
|
| | 2647 | + }
|
| | 2648 | + if (dxgl_installdir) _tcscat(installpath, _T("\\"));
|
| | 2649 | + else (_tcsrchr(installpath, _T('\\')))[1] = 0;
|
| | 2650 | + _tcsncpy(srcpath, installpath, MAX_PATH + 1);
|
| | 2651 | + _tcscat(srcpath, _T("ddraw.dll"));
|
| | 2652 | + while (RegEnumKeyEx(hKeyBase, i, keyname, &keysize2, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
| | 2653 | + {
|
| | 2654 | + keysize2 = keysize;
|
| | 2655 | + i++;
|
| | 2656 | + error = RegOpenKeyEx(hKeyBase, keyname, 0, KEY_READ, &hKey);
|
| | 2657 | + buffersize = regbuffersize;
|
| | 2658 | + RegQueryValueEx(hKey, _T("InstallPath"), NULL, NULL, NULL, &buffersize);
|
| | 2659 | + if (buffersize > regbuffersize)
|
| | 2660 | + {
|
| | 2661 | + regbuffersize = buffersize;
|
| | 2662 | + regbuffer = (LPTSTR)realloc(regbuffer, regbuffersize);
|
| | 2663 | + }
|
| | 2664 | + buffersize = regbuffersize;
|
| | 2665 | + regbuffer[0] = 0;
|
| | 2666 | + error = RegQueryValueEx(hKey, _T("InstallPath"), NULL, NULL, (LPBYTE)regbuffer, &buffersize);
|
| | 2667 | + if (regbuffer[0] != 0)
|
| | 2668 | + {
|
| | 2669 | + _tcsncpy(destpath, regbuffer, MAX_PATH + 1);
|
| | 2670 | + _tcscat(destpath, _T("\\ddraw.dll"));
|
| | 2671 | + _tcsncpy(inipath, regbuffer, MAX_PATH + 1);
|
| | 2672 | + _tcscat(inipath, _T("\\"));
|
| | 2673 | + _tcsncpy(backuppath, regbuffer, MAX_PATH + 1);
|
| | 2674 | + _tcscat(backuppath, _T("\\ddraw.dll.dxgl-backup"));
|
| | 2675 | + ReadAppINIOptions(inipath, &inioptions);
|
| | 2676 | + error = CopyFile(srcpath, destpath, TRUE);
|
| | 2677 | + if (!error)
|
| | 2678 | + {
|
| | 2679 | + error = GetLastError();
|
| | 2680 | + if (error == ERROR_FILE_EXISTS)
|
| | 2681 | + {
|
| | 2682 | + if (inioptions.NoOverwrite) continue;
|
| | 2683 | + if ((inioptions.sha256[0] != 0) && !memcmp(inioptions.sha256, inioptions.sha256comp, 64))
|
| | 2684 | + // Detected original ddraw matches INI hash
|
| | 2685 | + CopyFile(srcpath, backuppath, FALSE);
|
| | 2686 | + old_dxgl = FALSE;
|
| | 2687 | + error = SetErrorMode(SEM_FAILCRITICALERRORS);
|
| | 2688 | + SetErrorMode(error | SEM_FAILCRITICALERRORS);
|
| | 2689 | + hmod = LoadLibrary(destpath);
|
| | 2690 | + SetErrorMode(error);
|
| | 2691 | + if (hmod)
|
| | 2692 | + {
|
| | 2693 | + if (GetProcAddress(hmod, "IsDXGLDDraw")) old_dxgl = TRUE;
|
| | 2694 | + FreeLibrary(hmod);
|
| | 2695 | + }
|
| | 2696 | + if (old_dxgl) CopyFile(srcpath, destpath, FALSE);
|
| | 2697 | + }
|
| | 2698 | + }
|
| | 2699 | + }
|
| | 2700 | + RegCloseKey(hKey);
|
| | 2701 | + }
|
| | 2702 | + free(regbuffer);
|
| | 2703 | + free(keyname);
|
| | 2704 | + RegCloseKey(hKeyBase);
|
| | 2705 | +}
|
| | 2706 | +
|
| | 2707 | +// '0' for keep, '1' for remove, personal settings
|
| | 2708 | +void UninstallDXGL(TCHAR uninstall)
|
| | 2709 | +{
|
| | 2710 | + HKEY hKeyBase;
|
| | 2711 | + HKEY hKey;
|
| | 2712 | + DWORD keysize, keysize2;
|
| | 2713 | + LONG error;
|
| | 2714 | + LPTSTR keyname;
|
| | 2715 | + DWORD sizeout;
|
| | 2716 | + DWORD buffersize;
|
| | 2717 | + DWORD regbuffersize;
|
| | 2718 | + LPTSTR regbuffer;
|
| | 2719 | + BOOL installed = FALSE;
|
| | 2720 | + BOOL dxgl_installdir = FALSE;
|
| | 2721 | + BOOL old_dxgl = FALSE;
|
| | 2722 | + HKEY hKeyInstall;
|
| | 2723 | + TCHAR installpath[MAX_PATH + 1];
|
| | 2724 | + TCHAR srcpath[MAX_PATH + 1];
|
| | 2725 | + TCHAR destpath[MAX_PATH + 1];
|
| | 2726 | + TCHAR inipath[MAX_PATH + 1];
|
| | 2727 | + TCHAR backuppath[MAX_PATH + 1];
|
| | 2728 | + HANDLE exists;
|
| | 2729 | + app_ini_options inioptions;
|
| | 2730 | + HMODULE hmod;
|
| | 2731 | + int i = 0;
|
| | 2732 | + UpgradeConfig(); // Just to make sure the registry format is correct
|
| | 2733 | + regbuffersize = 1024;
|
| | 2734 | + regbuffer = (LPTSTR)malloc(regbuffersize * sizeof(TCHAR));
|
| | 2735 | + error = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\DXGL\\Profiles"), 0, KEY_ALL_ACCESS, &hKeyBase);
|
| | 2736 | + if (error != ERROR_SUCCESS) return;
|
| | 2737 | + RegQueryInfoKey(hKeyBase, NULL, NULL, NULL, NULL, &keysize, NULL, NULL, NULL, NULL, NULL, NULL);
|
| | 2738 | + keysize++;
|
| | 2739 | + keyname = (LPTSTR)malloc(keysize * sizeof(TCHAR));
|
| | 2740 | + keysize2 = keysize;
|
| | 2741 | + error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\DXGL"), 0, KEY_READ, &hKeyInstall);
|
| | 2742 | + if (error == ERROR_SUCCESS)
|
| | 2743 | + {
|
| | 2744 | + dxgl_installdir = TRUE;
|
| | 2745 | + sizeout = (MAX_PATH + 1) * sizeof(TCHAR);
|
| | 2746 | + error = RegQueryValueEx(hKeyInstall, _T("InstallDir"), NULL, NULL, (LPBYTE)installpath, &sizeout);
|
| | 2747 | + if (error == ERROR_SUCCESS) installed = TRUE;
|
| | 2748 | + }
|
| | 2749 | + if (hKeyInstall) RegCloseKey(hKeyInstall);
|
| | 2750 | + if (!installed)
|
| | 2751 | + {
|
| | 2752 | + GetModuleFileName(NULL, installpath, MAX_PATH + 1);
|
| | 2753 | + }
|
| | 2754 | + if (dxgl_installdir) _tcscat(installpath, _T("\\"));
|
| | 2755 | + else (_tcsrchr(installpath, _T('\\')))[1] = 0;
|
| | 2756 | + _tcsncpy(srcpath, installpath, MAX_PATH + 1);
|
| | 2757 | + _tcscat(srcpath, _T("ddraw.dll"));
|
| | 2758 | + while (RegEnumKeyEx(hKeyBase, i, keyname, &keysize2, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
| | 2759 | + {
|
| | 2760 | + keysize2 = keysize;
|
| | 2761 | + i++;
|
| | 2762 | + error = RegOpenKeyEx(hKeyBase, keyname, 0, KEY_READ, &hKey);
|
| | 2763 | + buffersize = regbuffersize;
|
| | 2764 | + if (buffersize > regbuffersize)
|
| | 2765 | + {
|
| | 2766 | + regbuffersize = buffersize;
|
| | 2767 | + regbuffer = (LPTSTR)realloc(regbuffer, regbuffersize);
|
| | 2768 | + }
|
| | 2769 | + buffersize = regbuffersize;
|
| | 2770 | + regbuffer[0] = 0;
|
| | 2771 | + error = RegQueryValueEx(hKey, _T("InstallPath"), NULL, NULL, (LPBYTE)regbuffer, &buffersize);
|
| | 2772 | + if (regbuffer[0] != 0)
|
| | 2773 | + {
|
| | 2774 | + _tcsncpy(destpath, regbuffer, MAX_PATH + 1);
|
| | 2775 | + _tcscat(destpath, _T("\\ddraw.dll"));
|
| | 2776 | + _tcsncpy(inipath, regbuffer, MAX_PATH + 1);
|
| | 2777 | + _tcscat(inipath, _T("\\"));
|
| | 2778 | + _tcsncpy(backuppath, regbuffer, MAX_PATH + 1);
|
| | 2779 | + _tcscat(backuppath, _T("\\ddraw.dll.dxgl-backup"));
|
| | 2780 | + ReadAppINIOptions(inipath, &inioptions);
|
| | 2781 | + if (inioptions.NoOverwrite || inioptions.NoUninstall) continue;
|
| | 2782 | + if (GetFileAttributes(destpath) != INVALID_FILE_ATTRIBUTES)
|
| | 2783 | + {
|
| | 2784 | + old_dxgl = FALSE;
|
| | 2785 | + error = SetErrorMode(SEM_FAILCRITICALERRORS);
|
| | 2786 | + SetErrorMode(error | SEM_FAILCRITICALERRORS);
|
| | 2787 | + hmod = LoadLibrary(destpath);
|
| | 2788 | + SetErrorMode(error);
|
| | 2789 | + if (hmod)
|
| | 2790 | + {
|
| | 2791 | + if (GetProcAddress(hmod, "IsDXGLDDraw")) old_dxgl = TRUE;
|
| | 2792 | + FreeLibrary(hmod);
|
| | 2793 | + }
|
| | 2794 | + if (_tcscmp(srcpath, destpath))
|
| | 2795 | + {
|
| | 2796 | + if (old_dxgl)
|
| | 2797 | + {
|
| | 2798 | + DeleteFile(destpath);
|
| | 2799 | + exists = CreateFile(backuppath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
| | 2800 | + NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
| | 2801 | + if (exists == INVALID_HANDLE_VALUE) continue;
|
| | 2802 | + else
|
| | 2803 | + {
|
| | 2804 | + CloseHandle(exists);
|
| | 2805 | + MoveFile(backuppath, destpath);
|
| | 2806 | + }
|
| | 2807 | + }
|
| | 2808 | + }
|
| | 2809 | + }
|
| | 2810 | + }
|
| | 2811 | + RegCloseKey(hKey);
|
| | 2812 | + }
|
| | 2813 | + free(regbuffer);
|
| | 2814 | + RegQueryInfoKey(hKeyBase, NULL, NULL, NULL, NULL, &keysize, NULL, NULL, NULL, NULL, NULL, NULL);
|
| | 2815 | + keysize++;
|
| | 2816 | + if (uninstall == '1') // Delete user settings
|
| | 2817 | + {
|
| | 2818 | + while (RegEnumKeyEx(hKeyBase, 0, keyname, &keysize2, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
| | 2819 | + {
|
| | 2820 | + keysize2 = keysize;
|
| | 2821 | + i++;
|
| | 2822 | + RegDeleteKey(hKeyBase, keyname);
|
| | 2823 | + }
|
| | 2824 | + RegCloseKey(hKeyBase);
|
| | 2825 | + RegDeleteKey(HKEY_CURRENT_USER, _T("Software\\DXGL\\Profiles"));
|
| | 2826 | + RegDeleteKey(HKEY_CURRENT_USER, _T("Software\\DXGL\\Global"));
|
| | 2827 | + RegDeleteKey(HKEY_CURRENT_USER, _T("Software\\DXGL"));
|
| | 2828 | + }
|
| | 2829 | + else RegCloseKey(hKeyBase);
|
| | 2830 | +}
|
| | 2831 | +
|
| | 2832 | +int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
|
| | 2833 | +{
|
| | 2834 | + INITCOMMONCONTROLSEX icc;
|
| | 2835 | + HMODULE comctl32;
|
| | 2836 | + BOOL(WINAPI *iccex)(LPINITCOMMONCONTROLSEX lpInitCtrls);
|
| | 2837 | + HANDLE hMutex;
|
| | 2838 | + HWND hWnd;
|
| | 2839 | + osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
| | 2840 | + GetVersionEx(&osver);
|
| | 2841 | + CoInitialize(NULL);
|
| | 2842 | + if (!_tcsnicmp(lpCmdLine, _T("upgrade"), 7))
|
| | 2843 | + {
|
| | 2844 | + UpgradeDXGL();
|
| | 2845 | + return 0;
|
| | 2846 | + }
|
| | 2847 | + if (!_tcsnicmp(lpCmdLine, _T("uninstall"), 9))
|
| | 2848 | + {
|
| | 2849 | + UninstallDXGL(lpCmdLine[10]);
|
| | 2850 | + return 0;
|
| | 2851 | + }
|
| | 2852 | + if(!_tcsnicmp(lpCmdLine,_T("install "),8))
|
| | 2853 | + {
|
| | 2854 | + return AddApp(lpCmdLine+8,TRUE,TRUE,FALSE,NULL);
|
| | 2855 | + }
|
| | 2856 | + if(!_tcsnicmp(lpCmdLine,_T("forceinstall "),13))
|
| | 2857 | + {
|
| | 2858 | + return AddApp(lpCmdLine+8,TRUE,TRUE,TRUE,NULL);
|
| | 2859 | + }
|
| | 2860 | + if(!_tcsnicmp(lpCmdLine,_T("remove "),7))
|
| | 2861 | + {
|
| | 2862 | + return DelApp(lpCmdLine+7,TRUE,NULL);
|
| | 2863 | + }
|
| | 2864 | + icc.dwSize = sizeof(icc);
|
| | 2865 | + icc.dwICC = ICC_WIN95_CLASSES;
|
| | 2866 | + comctl32 = LoadLibrary(_T("comctl32.dll"));
|
| | 2867 | + iccex = (BOOL (WINAPI *)(LPINITCOMMONCONTROLSEX))GetProcAddress(comctl32,"InitCommonControlsEx");
|
| | 2868 | + if(iccex) iccex(&icc);
|
| | 2869 | + else InitCommonControls();
|
| | 2870 | + hinstance = hInstance;
|
| | 2871 | + GetModuleFileName(NULL,hlppath,MAX_PATH);
|
| | 2872 | + GetDirFromPath(hlppath);
|
| | 2873 | + _tcscat(hlppath,_T("\\dxgl.chm"));
|
| | 2874 | + hMutex = CreateMutex(NULL, TRUE, _T("DXGLConfigMutex"));
|
| | 2875 | + if (GetLastError() == ERROR_ALREADY_EXISTS)
|
| | 2876 | + {
|
| | 2877 | + // Find DXGL Config window
|
| | 2878 | + hWnd = FindWindow(NULL, _T("DXGL Config"));
|
| | 2879 | + // Focus DXGL Config window
|
| | 2880 | + if (hWnd) SetForegroundWindow(hWnd);
|
| | 2881 | + return 0;
|
| | 2882 | + }
|
| | 2883 | + DialogBox(hInstance,MAKEINTRESOURCE(IDD_DXGLCFG),0,(DLGPROC)DXGLCfgCallback);
|
| | 2884 | + ReleaseMutex(hMutex);
|
| | 2885 | + CloseHandle(hMutex);
|
| | 2886 | +#ifdef _DEBUG
|
| | 2887 | + _CrtDumpMemoryLeaks();
|
| | 2888 | +#endif
|
| | 2889 | + return 0;
|
| | 2890 | +}
|
| Index: dxglcfg/dxglcfg.vcxproj |
| — | — | @@ -185,7 +185,7 @@ |
| 186 | 186 | <ClInclude Include="resource.h" />
|
| 187 | 187 | </ItemGroup>
|
| 188 | 188 | <ItemGroup>
|
| 189 | | - <ClCompile Include="dxglcfg.c" />
|
| | 189 | + <ClCompile Include="dxglcfg.cpp" />
|
| 190 | 190 | </ItemGroup>
|
| 191 | 191 | <ItemGroup>
|
| 192 | 192 | <Manifest Include="xp.manifest" />
|
| Index: dxglcfg/dxglcfg.vcxproj.filters |
| — | — | @@ -30,7 +30,7 @@ |
| 31 | 31 | </Manifest>
|
| 32 | 32 | </ItemGroup>
|
| 33 | 33 | <ItemGroup>
|
| 34 | | - <ClCompile Include="dxglcfg.c">
|
| | 34 | + <ClCompile Include="dxglcfg.cpp">
|
| 35 | 35 | <Filter>Source Files</Filter>
|
| 36 | 36 | </ClCompile>
|
| 37 | 37 | </ItemGroup>
|
| Index: dxglcfg |
| Property changes on: dxglcfg |
| ___________________________________________________________________ |
| Modified: svn:ignore |
| ## -3,3 +3,4 ## |
| 38 | 38 | Debug |
| 39 | 39 | Debug no DXGL |
| 40 | 40 | Release no DXGL |
| | 41 | +*.user |