示例#1
0
	virtual void OnInit()
	{
		CharSet::SetCharSet("gb2312");

		MGUI::FontManager::Instance()->Load("Editor.font");

		mConfig = new ConfigFile;
		mConfig->Load("UIEditor.ini");

		rml_node * node = mConfig->first_node("Media");
		while (node != NULL)
		{
			String path = node->value();

			ResourceManager::Instance()->AddArchive(new FilePathArchive(path));

			node = node->next_sibling("Media");
		}

		node = mConfig->first_node("Font");
		while (node != NULL)
		{
			String source = node->value();

			MGUI::FontManager::Instance()->Load(source);

			node = node->next_sibling("Font");
		}

		mMainFrame = new MainFrame();
	}
Atlas* AtlasResourceCompiler::Load_Compiled()
{
	std::string compiled_path = Get_Compiled_Path();
	Platform* platform = Platform::Get();

	// Compile time.
	DBG_LOG("Loading atlas resource '%s'.", compiled_path.c_str());
	
	// Load configuration settings.
	ConfigFile config;
	if (!config.Load(compiled_path.c_str()))
	{
		DBG_LOG("Failed to load atlas, config file could not be found: '%s'", compiled_path.c_str());
		return NULL;
	}

	// Load the compile atlas file.
	Atlas* atlas = new Atlas();
	if (!atlas->Load_Compiled_Config(&config))
	{
		return NULL;
	}

	DBG_LOG("Finished loading compiled atlas from '%s'.", compiled_path.c_str());
	return atlas;
}
示例#3
0
文件: global.cpp 项目: stal888/gnet
bool Config::Load(){

  serverPort = 666;
  isPublic = true;
  memset(serverName,0,SERVERNAME_MAX); sprintf(serverName,"G Server");
  enableLogging = true;
  ignoreUnknownPackets = false;
  spriteMaxX = 50;
  spriteMaxY = 50;
  usernameMax = 20;

  ConfigFile file; file.Construct();

  if(file.Load(CONFIG_FILE)){
    file.Get("serverPort",&serverPort);
    file.Get("isPublic",&isPublic);
    file.Get("serverName",serverName,SERVERNAME_MAX);
    file.Get("enableLogging",&enableLogging);
    file.Get("ignoreUnknownPackets",&ignoreUnknownPackets);
    file.Get("spriteMaxX",&spriteMaxX);
    file.Get("spriteMaxY",&spriteMaxY);
    file.Get("usernameMax",&usernameMax);
  }else{
    fprintf(stderr,"WARNING: %s not found. Generating with default settings.\n",CONFIG_FILE);
  }

  file.Clear();
  file.Set("serverPort",serverPort);
  file.Set("isPublic",isPublic);
  file.Set("serverName",serverName);
  file.Set("enableLogging",enableLogging);
  file.Set("ignoreUnknownPackets",ignoreUnknownPackets);
  file.Set("spriteMaxX",spriteMaxX);
  file.Set("spriteMaxY",spriteMaxY);
  file.Set("usernameMax",usernameMax);

  if(file.Save(CONFIG_FILE)){
    file.Destruct();
    return true;
  }else{
    fprintf(stderr,"ERROR: Unable to save %s.\n",CONFIG_FILE);
    file.Destruct();
    return false;
  }

}
示例#4
0
int main()
{

    ConfigFile conf;

    cout<<"=====> Loading and parsing ./config.cfg..."<<endl;
    enum ConfigFile::Error err = conf.Load("./config.cfg");
    if(err == ConfigFile::no_error)
    {
    	cout<<"\tFile loaded successfully !"<<endl;
    }
    else
    {
    	cout<<"\tError while loading the file : "<<ConfigFile::GetErrorString(err);
    	return 1;
    }

    conf.Print();
    cout<<endl;

    cout<<"=====> Set MySentense to \"This world is great :)\""<<endl;
	conf.SetValue("MySentense", "This world is great :)");

	cout<<"=====> Add a new variable : NewVar=68"<<endl;
	conf.SetValue("NewVar", "68");

    conf.Print();
    cout<<endl;

    cout<<"=====> The size of MyArray is "<<conf.GetArrayValue<int>("MyArray").size()<<" and the third value is "<<conf.GetValue<int>("MyArray", 2)<<endl;
    cout<<endl;
    cout<<"=====> Here is the letter :"<<endl;
    cout<<conf.GetValueString("MyMultilineValue")<<endl;

    cout<<endl;
    cout<<"=====> Saving new configuration file into ./newconfig.cfg"<<endl;
    conf.WriteToFile("./newconfig.cfg");

    return 0;
}