padnull:windows: Fix copypasted stuff from fwnull

By doing more copy/pasting.

The directory creation code was removed - it doesn't create any
necessary parent directories so it's not all that useful.

It would be great if all plugins shared config code, but it's probably
to have all the plugins use Unicode on Windows first.
This commit is contained in:
Jonathan Li 2015-11-25 19:03:29 +00:00
parent 59dc0e8612
commit 31d6e05811
2 changed files with 25 additions and 44 deletions

View File

@ -13,54 +13,35 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include "../Pad.h"
extern HINSTANCE hInst;
extern std::string s_strIniPath;
void SaveConfig()
{
const std::string iniFile = s_strIniPath + "/Padnull.ini";
Config *Conf1 = &conf;
char *szTemp;
char szIniFile[256], szValue[256];
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return;
strcpy(szTemp, "\\inis\\fwnull.ini");
sprintf(szValue,"%u",Conf1->Log);
WritePrivateProfileString("Interface", "Logging",szValue,szIniFile);
}
void LoadConfig() {
FILE *fp;
Config *Conf1 = &conf;
char *szTemp;
char szIniFile[256], szValue[256];
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
szTemp = strrchr(szIniFile, '\\');
if(!szTemp) return ;
strcpy(szTemp, "\\inis\\fwnull.ini");
fp=fopen("inis\\fwnull.ini","rt");//check if firewirenull.ini really exists
if (!fp)
PluginConf ini;
if (!ini.Open(iniFile, READ_FILE))
{
CreateDirectory("inis",NULL);
memset(&conf, 0, sizeof(conf));
conf.Log = 0;//default value
printf("failed to open %s\n", iniFile.c_str());
SaveConfig();//save and return
return ;
return;
}
fclose(fp);
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
Conf1->Log = strtoul(szValue, NULL, 10);
return ;
conf.Log = ini.ReadInt("logging", 0);
ini.Close();
}
void LoadConfig()
{
const std::string iniFile(s_strIniPath + "/Padnull.ini");
PluginConf ini;
if (!ini.Open(iniFile, WRITE_FILE))
{
printf("failed to open %s\n", iniFile.c_str());
return;
}
ini.WriteInt("logging", conf.Log);
ini.Close();
}

View File

@ -52,7 +52,7 @@ END
IDD_CONFIG DIALOGEX 0, 0, 212, 121
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Firewireconfigure"
CAPTION "PadNull Settings"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,48,100,50,14
@ -63,11 +63,11 @@ END
IDD_ABOUT DIALOGEX 0, 0, 177, 106
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "FireWire About"
CAPTION "PadNull About"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,65,85,50,14
LTEXT "FireWire Driver",IDC_NAME,70,10,48,8
LTEXT "PadNull Plugin",IDC_NAME,70,10,48,8
GROUPBOX "",IDC_STATIC,5,35,170,40
LTEXT "Author: Shadow and linuzappz",IDC_STATIC,29,19,141,10
END