Use a standard config dir on non-Windows. Fixes #192

Also remove WindowInfo::GetDefault which was redundant.
This commit is contained in:
Sacha 2014-07-11 05:45:07 +10:00
parent f256153a2b
commit 3737993bb2
5 changed files with 35 additions and 13 deletions

View file

@ -2,6 +2,7 @@
#include "Ini.h"
#include "Utilities/StrFmt.h"
#include "Utilities/rPlatform.h"
#include <algorithm>
#include <cctype>
@ -16,7 +17,7 @@ CSimpleIniCaseA *getIniFile()
if (inited == false)
{
ini.SetUnicode(true);
ini.LoadFile(DEF_CONFIG_NAME);
ini.LoadFile(std::string(rPlatform::getConfigDir() + DEF_CONFIG_NAME).c_str());
inited = true;
}
return &ini;
@ -24,7 +25,7 @@ CSimpleIniCaseA *getIniFile()
void saveIniFile()
{
getIniFile()->SaveFile(DEF_CONFIG_NAME);
getIniFile()->SaveFile(std::string(rPlatform::getConfigDir() + DEF_CONFIG_NAME).c_str());
}
Inis Ini;
@ -77,14 +78,14 @@ static WindowInfo StringToWindowInfo(const std::string& str)
vec.push_back(std::stoi(str.substr(start, found == std::string::npos ? found : found - start)));
}
catch (const std::invalid_argument& e) {
return WindowInfo::GetDefault();
return WindowInfo();
}
if (found == std::string::npos)
break;
start = found + 1;
}
if (vec.size() < 4 || vec[0] <= 0 || vec[1] <= 0 || vec[2] < 0 || vec[3] < 0)
return WindowInfo::GetDefault();
return WindowInfo();
return WindowInfo(std::make_pair(vec[0], vec[1]), std::make_pair(vec[2], vec[3]));
}