2009-02-09 21:15:56 +00:00
|
|
|
#if defined(_WIN32) || defined(__WIN32__)
|
|
|
|
#include <d3dx9.h>
|
2009-09-19 13:15:14 +00:00
|
|
|
#include <dxerr.h>
|
2009-02-09 21:15:56 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "Win32.h"
|
|
|
|
|
|
|
|
extern HINSTANCE hInst;
|
|
|
|
|
|
|
|
void SaveConfig() {
|
|
|
|
|
2009-12-20 15:29:38 +00:00
|
|
|
char szValue[256];
|
|
|
|
const std::string iniFile( s_strIniPath + "zerogs.ini" );
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
sprintf(szValue,"%u",conf.interlace);
|
2009-12-20 15:29:38 +00:00
|
|
|
WritePrivateProfileString("Settings", "Interlace",szValue,iniFile.c_str());
|
2009-02-09 21:15:56 +00:00
|
|
|
sprintf(szValue,"%u",conf.aa);
|
2009-12-20 15:29:38 +00:00
|
|
|
WritePrivateProfileString("Settings", "Antialiasing",szValue,iniFile.c_str());
|
2009-02-09 21:15:56 +00:00
|
|
|
sprintf(szValue,"%u",conf.bilinear);
|
2009-12-20 15:29:38 +00:00
|
|
|
WritePrivateProfileString("Settings", "Bilinear",szValue,iniFile.c_str());
|
2009-02-09 21:15:56 +00:00
|
|
|
sprintf(szValue,"%u",conf.options);
|
2009-12-20 15:29:38 +00:00
|
|
|
WritePrivateProfileString("Settings", "Options",szValue,iniFile.c_str());
|
2009-02-09 21:15:56 +00:00
|
|
|
sprintf(szValue,"%u",conf.gamesettings);
|
2009-12-20 15:29:38 +00:00
|
|
|
WritePrivateProfileString("Settings", "AdvancedOptions",szValue,iniFile.c_str());
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LoadConfig() {
|
|
|
|
|
2009-12-20 15:29:38 +00:00
|
|
|
char szValue[256];
|
|
|
|
const std::string iniFile( s_strIniPath + "zerogs.ini" );
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
memset(&conf, 0, sizeof(conf));
|
|
|
|
conf.interlace = 0; // on, mode 1
|
|
|
|
conf.mrtdepth = 1;
|
|
|
|
conf.options = 0;
|
|
|
|
conf.bilinear = 1;
|
|
|
|
conf.width = 640;
|
|
|
|
conf.height = 480;
|
|
|
|
|
2009-12-20 15:29:38 +00:00
|
|
|
FILE *fp=fopen(iniFile.c_str(),"rt");
|
2009-02-09 21:15:56 +00:00
|
|
|
if (!fp)
|
|
|
|
{
|
2009-12-20 15:29:38 +00:00
|
|
|
CreateDirectory(s_strIniPath.c_str(),NULL);
|
2009-02-09 21:15:56 +00:00
|
|
|
SaveConfig();//save and return
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
|
2009-12-20 15:29:38 +00:00
|
|
|
GetPrivateProfileString("Settings", "Interlace", NULL, szValue, 20, iniFile.c_str());
|
2009-02-09 21:15:56 +00:00
|
|
|
conf.interlace = (u8)strtoul(szValue, NULL, 10);
|
2009-12-20 15:29:38 +00:00
|
|
|
GetPrivateProfileString("Settings", "Antialiasing", NULL, szValue, 20, iniFile.c_str());
|
2009-02-09 21:15:56 +00:00
|
|
|
conf.aa = (u8)strtoul(szValue, NULL, 10);
|
2009-12-20 15:29:38 +00:00
|
|
|
GetPrivateProfileString("Settings", "Options", NULL, szValue, 20, iniFile.c_str());
|
2009-02-09 21:15:56 +00:00
|
|
|
conf.options = strtoul(szValue, NULL, 10);
|
2009-12-20 15:29:38 +00:00
|
|
|
GetPrivateProfileString("Settings", "AdvancedOptions", NULL, szValue, 20, iniFile.c_str());
|
2009-02-09 21:15:56 +00:00
|
|
|
conf.gamesettings = strtoul(szValue, NULL, 10);
|
2009-12-20 15:29:38 +00:00
|
|
|
GetPrivateProfileString("Settings", "Bilinear", NULL, szValue, 20, iniFile.c_str());
|
2009-02-09 21:15:56 +00:00
|
|
|
conf.bilinear = strtoul(szValue, NULL, 10);
|
|
|
|
|
|
|
|
if( conf.aa < 0 || conf.aa > 4 ) conf.aa = 0;
|
|
|
|
|
|
|
|
switch(conf.options&GSOPTION_WINDIMS) {
|
|
|
|
case GSOPTION_WIN640:
|
|
|
|
conf.width = 640;
|
|
|
|
conf.height = 480;
|
|
|
|
break;
|
|
|
|
case GSOPTION_WIN800:
|
|
|
|
conf.width = 800;
|
|
|
|
conf.height = 600;
|
|
|
|
break;
|
|
|
|
case GSOPTION_WIN1024:
|
|
|
|
conf.width = 1024;
|
|
|
|
conf.height = 768;
|
|
|
|
break;
|
|
|
|
case GSOPTION_WIN1280:
|
|
|
|
conf.width = 1280;
|
|
|
|
conf.height = 960;
|
|
|
|
break;
|
|
|
|
case GSOPTION_WIN960W:
|
|
|
|
conf.width = 960;
|
|
|
|
conf.height = 540;
|
|
|
|
break;
|
|
|
|
case GSOPTION_WIN1280W:
|
|
|
|
conf.width = 1280;
|
|
|
|
conf.height = 720;
|
|
|
|
break;
|
|
|
|
case GSOPTION_WIN1920W:
|
|
|
|
conf.width = 1920;
|
|
|
|
conf.height = 1080;
|
|
|
|
break;
|
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
// turn off all hacks by defaultof
|
|
|
|
conf.options &= ~(GSOPTION_FULLSCREEN|GSOPTION_WIREFRAME|GSOPTION_CAPTUREAVI);
|
|
|
|
conf.options |= GSOPTION_LOADED;
|
|
|
|
|
|
|
|
if( conf.width <= 0 || conf.height <= 0 ) {
|
|
|
|
conf.width = 640;
|
|
|
|
conf.height = 480;
|
|
|
|
}
|
|
|
|
}
|