2010-03-19 00:31:15 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "GS.h"
|
|
|
|
#include "Win32.h"
|
|
|
|
|
|
|
|
extern HINSTANCE hInst;
|
|
|
|
|
|
|
|
|
2010-05-01 23:34:44 +00:00
|
|
|
void SaveConfig()
|
|
|
|
{
|
2010-03-19 00:31:15 +00:00
|
|
|
char szValue[256];
|
2010-05-01 23:34:44 +00:00
|
|
|
const std::string iniFile(s_strIniPath + "zzogl-pg.ini");
|
|
|
|
|
|
|
|
sprintf(szValue, "%u", conf.interlace);
|
|
|
|
WritePrivateProfileString("Settings", "Interlace", szValue, iniFile.c_str());
|
|
|
|
sprintf(szValue, "%u", conf.aa);
|
|
|
|
WritePrivateProfileString("Settings", "Antialiasing", szValue, iniFile.c_str());
|
|
|
|
sprintf(szValue, "%u", conf.bilinear);
|
|
|
|
WritePrivateProfileString("Settings", "Bilinear", szValue, iniFile.c_str());
|
|
|
|
sprintf(szValue, "%u", conf.options);
|
|
|
|
WritePrivateProfileString("Settings", "Options", szValue, iniFile.c_str());
|
|
|
|
sprintf(szValue, "%u", conf.gamesettings);
|
|
|
|
WritePrivateProfileString("Settings", "AdvancedOptions", szValue, iniFile.c_str());
|
2010-05-02 03:09:20 +00:00
|
|
|
sprintf(szValue, "%u", conf.width);
|
|
|
|
WritePrivateProfileString("Settings", "Width", szValue, iniFile.c_str());
|
|
|
|
sprintf(szValue, "%u", conf.height);
|
|
|
|
WritePrivateProfileString("Settings", "Height", szValue, iniFile.c_str());
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|
|
|
|
|
2010-05-01 23:34:44 +00:00
|
|
|
void LoadConfig()
|
|
|
|
{
|
2010-03-19 00:31:15 +00:00
|
|
|
char szValue[256];
|
2010-05-01 23:34:44 +00:00
|
|
|
const std::string iniFile(s_strIniPath + "zzogl-pg.ini");
|
2010-03-19 00:31:15 +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;
|
|
|
|
|
2010-05-01 23:34:44 +00:00
|
|
|
FILE *fp = fopen(iniFile.c_str(), "rt");
|
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
if (!fp)
|
|
|
|
{
|
2010-05-01 23:34:44 +00:00
|
|
|
CreateDirectory(s_strIniPath.c_str(), NULL);
|
2010-03-19 00:31:15 +00:00
|
|
|
SaveConfig();//save and return
|
|
|
|
return ;
|
|
|
|
}
|
2010-05-01 23:34:44 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
GetPrivateProfileString("Settings", "Interlace", NULL, szValue, 20, iniFile.c_str());
|
|
|
|
conf.interlace = (u8)strtoul(szValue, NULL, 10);
|
|
|
|
GetPrivateProfileString("Settings", "Antialiasing", NULL, szValue, 20, iniFile.c_str());
|
|
|
|
conf.aa = (u8)strtoul(szValue, NULL, 10);
|
|
|
|
GetPrivateProfileString("Settings", "Options", NULL, szValue, 20, iniFile.c_str());
|
|
|
|
conf.options = strtoul(szValue, NULL, 10);
|
|
|
|
GetPrivateProfileString("Settings", "AdvancedOptions", NULL, szValue, 20, iniFile.c_str());
|
|
|
|
conf.gamesettings = strtoul(szValue, NULL, 10);
|
|
|
|
GetPrivateProfileString("Settings", "Bilinear", NULL, szValue, 20, iniFile.c_str());
|
|
|
|
conf.bilinear = strtoul(szValue, NULL, 10);
|
2010-05-02 03:09:20 +00:00
|
|
|
GetPrivateProfileString("Settings", "Width", NULL, szValue, 20, iniFile.c_str());
|
|
|
|
conf.width = strtoul(szValue, NULL, 10);
|
|
|
|
GetPrivateProfileString("Settings", "Height", NULL, szValue, 20, iniFile.c_str());
|
|
|
|
conf.height = strtoul(szValue, NULL, 10);
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-05-01 23:34:44 +00:00
|
|
|
if (conf.aa < 0 || conf.aa > 4) conf.aa = 0;
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-03-19 04:36:28 +00:00
|
|
|
conf.isWideScreen = ((conf.options & GSOPTION_WIDESCREEN) != 0);
|
2010-05-01 23:34:44 +00:00
|
|
|
|
|
|
|
switch (conf.options & GSOPTION_WINDIMS)
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
|
|
|
case GSOPTION_WIN640:
|
|
|
|
conf.width = 640;
|
|
|
|
conf.height = conf.isWideScreen ? 360 : 480;
|
|
|
|
break;
|
2010-05-01 23:34:44 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
case GSOPTION_WIN800:
|
|
|
|
conf.width = 800;
|
|
|
|
conf.height = conf.isWideScreen ? 450 : 600;
|
|
|
|
break;
|
2010-05-01 23:34:44 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
case GSOPTION_WIN1024:
|
|
|
|
conf.width = 1024;
|
|
|
|
conf.height = conf.isWideScreen ? 576 : 768;
|
|
|
|
break;
|
2010-05-01 23:34:44 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
case GSOPTION_WIN1280:
|
|
|
|
conf.width = 1280;
|
|
|
|
conf.height = conf.isWideScreen ? 720 : 960;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// turn off all hacks by defaultof
|
2010-05-01 23:34:44 +00:00
|
|
|
conf.options &= ~(GSOPTION_WIREFRAME | GSOPTION_CAPTUREAVI);
|
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
conf.options |= GSOPTION_LOADED;
|
|
|
|
|
2010-05-01 23:34:44 +00:00
|
|
|
if (conf.width <= 0 || conf.height <= 0)
|
|
|
|
{
|
2010-03-19 00:31:15 +00:00
|
|
|
conf.width = 640;
|
|
|
|
conf.height = 480;
|
|
|
|
}
|
|
|
|
}
|