//saves the options in .ini format
//returns 1 for failure
int saveOptions(const string fileName)
{
	vector <vector <IniValue> > iniValues;
	vector <string> iniSections;

	iniSections.push_back("GraphicsOptions");
	iniValues.push_back(vector<IniValue>());


	iniValues.back().push_back(IniValue("borderless", to_string(graphicsOptions.isBorderless)));
	iniValues.back().push_back(IniValue("fov", graphicsOptions.fov));
	iniValues.back().push_back(IniValue("fullScreen", to_string(graphicsOptions.isFullscreen)));
	iniValues.back().push_back(IniValue("gamma", graphicsOptions.gamma));
	iniValues.back().push_back(IniValue("screenWidth", to_string(graphicsOptions.screenWidth)));
	iniValues.back().push_back(IniValue("screenHeight", to_string(graphicsOptions.screenHeight)));
	iniValues.back().push_back(IniValue("maxFps", to_string(graphicsOptions.maxFps)));
	iniValues.back().push_back(IniValue("vSync", to_string(graphicsOptions.isVsync)));

	iniSections.push_back("ControlsOptions");
	iniValues.push_back(vector<IniValue>());
	iniValues.back().push_back(IniValue("invertMouse", to_string(controlsOptions.invertMouse)));
	iniValues.back().push_back(IniValue("mouseSensitivity", controlsOptions.mouseSensitivity));

	if (fileManager.saveIniFile(fileName, iniValues, iniSections)) return 1;
	return 0;
}
Example #2
0
void IniFile::parseText(BufInputStream& txtFile)
{
    //txtFile.seek(0, skBegin);
    clearList();
    const char notesFlag = ';';
    String strLine;
    while (txtFile.readLine(strLine))
    {
        trimTo(strLine);
        String& strTmp=strLine;
        long strTmp_size=(long)strTmp.size();
        //Notes
        if ((strTmp_size > 0) && (notesFlag != strTmp[0]))		
        {
            //Section
            if (strTmp_size >= 2)
            {
                if ((sectionStart == strTmp[0]) && (sectionEnd == strTmp[strTmp_size - 1]))
                {
                    String strSection;
                    trim(strTmp.c_str()+1,strTmp_size-2,strSection);
                    m_sctList.push_back(Section(strSection));
                }
                else
                {
                    long nIdxSpace = findStr(strTmp, valSpace);
                    if (nIdxSpace >= 0) {
                        String strKey;
                        trim(strTmp.c_str(),nIdxSpace,strKey);
                        
                        String strVal;
                        if ((nIdxSpace + 1) < strTmp_size) 
                            trim(strTmp.c_str()+nIdxSpace + 1,strTmp_size - nIdxSpace - 1,strVal);
                        getBackSection()->list.push_back(IniValue(strKey, strVal));
                    }
                    //else getBackSection()->list.push_back(IniValue(strLine));					
                }				
            }
            //else getBackSection()->list.push_back(IniValue(strLine));
        }
        else 
        {
            getBackSection()->list.push_back(IniValue(strLine));
        }
    }	
}
Example #3
0
void Section::writeString(const String& strKey,const String& strVal)
{
    IniValue* value = findKey(strKey);
    if (value == 0) 
    {
        list.push_back(IniValue(strKey, strVal));
    }else
    {
        value->value = strVal;
    }
}
Example #4
0
void saveOption(HWND nppHandle, StruOptions struOptions)
{
    tstring tsConfigFilePath = GetConfigFilePath(nppHandle);

    IniFileProcessor processor(tsConfigFilePath);
    IniFileProcessor::IniMap map;

    map[keyPutCR] = IniValue(struOptions.bPutCR ? string("1") : string("0"));
    map[keyChIndent] = IniValue(struOptions.chIndent == '\t' ? string("tab") : string("space"));
    char buffer[256];
    itoa(struOptions.nChPerInd, buffer, 10);
    map[keyChPerInd] = IniValue(string(buffer));
    map[keyNLBracket] = IniValue(struOptions.bNLBracket ? string("1") : string("0"));
    map[keyKeepTopComt] = IniValue(struOptions.bKeepTopComt ? string("1") : string("0"));
    map[keyIndentInEmpty] = IniValue(struOptions.bIndentInEmpty ? string("1") : string("0"));

    processor.SetMap(map);

    processor.Save();
}