Ejemplo n.º 1
0
config_setting_t *cfgLookup(const config_t *config, const TCHAR *path)
{
	char uPath[MAX_PATH];

	UTF8_Encode(path, uPath, MAX_PATH);
	return config_lookup(config, uPath);
}
Ejemplo n.º 2
0
config_setting_t *cfgSettingAdd(config_setting_t *parent, const TCHAR *name, int type)
{
	char uName[CONFIG_UTF8_MAXSTRING];

	if(name) UTF8_Encode(name, uName, CONFIG_UTF8_MAXSTRING);
	return config_setting_add(parent, uName, type);
}
Ejemplo n.º 3
0
int cfgWriteFile(config_t *config, const TCHAR *filename)
{
	char uFileName[MAX_PATH];

	UTF8_Encode(filename, uFileName, MAX_PATH);
	return config_write_file(config, uFileName);
}
Ejemplo n.º 4
0
int cfgReadFile(config_t *config, const TCHAR *filename)
{
	char uFileName[MAX_PATH];

	UTF8_Encode(filename, uFileName, MAX_PATH);

	return config_read_file(config, uFileName);
}
Ejemplo n.º 5
0
int cfgGetIntD(const config_setting_t *setting, const TCHAR *name, int def)
{
	int value; 
	char uName[CONFIG_UTF8_MAXSTRING];

	UTF8_Encode(name, uName, CONFIG_UTF8_MAXSTRING);
	
	if(!config_setting_lookup_int(setting, uName, &value))
		return def;

	return value;
}
Ejemplo n.º 6
0
config_setting_t *cfgSetInt(config_setting_t *parent, const TCHAR *name, int value)
{
	config_setting_t *setting;
	char uName[CONFIG_UTF8_MAXSTRING];

	UTF8_Encode(name, uName, CONFIG_UTF8_MAXSTRING);

	setting = config_setting_add(parent, uName, CONFIG_TYPE_INT);
	config_setting_set_int(setting, value);

	return setting;
}
Ejemplo n.º 7
0
long long cfgGetInt64(const config_setting_t *setting, const TCHAR *name)
{
	long long value; 
	char uName[CONFIG_UTF8_MAXSTRING];

	UTF8_Encode(name, uName, CONFIG_UTF8_MAXSTRING);
	
	if(!config_setting_lookup_int64(setting, uName, &value))
	{
		wcscpy_s(ConfigErrorString, CONFIG_ERROR_MAXSTRING, name);
		ConfigError = TRUE;
		return 0;
	}
	return value;
}
Ejemplo n.º 8
0
config_setting_t *cfgGetMember(const config_setting_t *setting, const TCHAR *name)
{
	config_setting_t *member;
	char uName[CONFIG_UTF8_MAXSTRING];

	UTF8_Encode(name, uName, CONFIG_UTF8_MAXSTRING);

	if(!(member = config_setting_get_member(setting, uName)))
	{
		wcscpy_s(ConfigErrorString, CONFIG_ERROR_MAXSTRING, name);
		ConfigError = TRUE;
		return NULL;
	}
	return member;
}
Ejemplo n.º 9
0
config_setting_t *cfgSetString(config_setting_t *parent, const TCHAR *name, const TCHAR *value)
{
	config_setting_t *setting;
	char *cfgStr;
	char uName[CONFIG_UTF8_MAXSTRING];

	UTF8_Encode(name, uName, CONFIG_UTF8_MAXSTRING);

	setting = config_setting_add(parent, uName, CONFIG_TYPE_STRING);

	cfgStr = UTF8_Encode_Dyn(value);
	config_setting_set_string(setting, cfgStr);
	free(cfgStr);

	return setting;
}
Ejemplo n.º 10
0
std::string CSystemUtilsWindows::GetSaveDir()
{
    std::string savegameDir;

    wchar_t* envUSERPROFILE = _wgetenv(L"USERPROFILE");
    if (envUSERPROFILE == nullptr)
    {
        savegameDir = "./saves";
    }
    else
    {
        savegameDir = UTF8_Encode(std::wstring(envUSERPROFILE)) + "\\colobot";
    }
    GetLogger()->Trace("Saved game files are going to %s\n", savegameDir.c_str());

    return savegameDir;
}
Ejemplo n.º 11
0
TCHAR *cfgGetString(const config_setting_t *setting, const TCHAR *name, TCHAR *outStr)
{
	char *value;
	char uName[CONFIG_UTF8_MAXSTRING];

	UTF8_Encode(name, uName, CONFIG_UTF8_MAXSTRING);

	if(!config_setting_lookup_string(setting, uName, &value))
	{
		wcscpy_s(ConfigErrorString, CONFIG_ERROR_MAXSTRING, name);
		ConfigError = TRUE;
		return NULL;
	}

	if(!outStr)
		return UTF8_Decode_Dyn(value);
	
	return UTF8_Decode(value, outStr, CONFIG_WCHAR_MAXSTRING);
}
Ejemplo n.º 12
0
config_setting_t *cfgAddString(config_setting_t * setting, const TCHAR * value)
{
	char cfgStr[CONFIG_UTF8_MAXSTRING];

	return config_setting_set_string_elem(setting, -1, UTF8_Encode(value, cfgStr, CONFIG_UTF8_MAXSTRING));
}