当前位置: 首页>>代码示例>>C++>>正文


C++ CConfigFile::Load方法代码示例

本文整理汇总了C++中CConfigFile::Load方法的典型用法代码示例。如果您正苦于以下问题:C++ CConfigFile::Load方法的具体用法?C++ CConfigFile::Load怎么用?C++ CConfigFile::Load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CConfigFile的用法示例。


在下文中一共展示了CConfigFile::Load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Destroy

bool
CProject::Open(const char* filename)
{
  Destroy();
  // set the game directory
  m_Directory = filename;
  if (m_Directory.rfind('\\') != std::string::npos)
    m_Directory[m_Directory.rfind('\\')] = 0;
  // set the game filename
  m_Filename = filename;
  if (1) {
    char directory[MAX_PATH];
    GetCurrentDirectory(MAX_PATH, directory);
    if (SetCurrentDirectory(m_Directory.c_str()) == 0)
      return false;
    FILE* file = fopen(m_Filename.c_str(), "a");
    if (!file) return false;
    fclose(file);
    SetCurrentDirectory(directory);
  }
  // load the game.sgm
  CConfigFile config;
  if (!config.Load(m_Filename.c_str()))
    return false;
  m_GameTitle   = config.ReadString("", "name",        "Untitled");
  m_Author      = config.ReadString("", "author",      "Unknown");
  m_Description = config.ReadString("", "description", "");
  m_GameScript = config.ReadString("", "script", "");
  // screen dimensions
  m_ScreenWidth  = config.ReadInt("", "screen_width", 320);
  m_ScreenHeight = config.ReadInt("", "screen_height", 240);
  RefreshItems();
  return true;
}
开发者ID:FlyingJester,项目名称:sphere,代码行数:34,代码来源:Project.cpp

示例2: LoadConfiguration

void LoadConfiguration(std::string sphere_dir)
{
    CConfigFile file;
    file.Load((sphere_dir + "/system/video/sdl32.cfg").c_str());

    Config.fullscreen = file.ReadBool("sdl32", "Fullscreen", false);
    Config.vsync      = file.ReadBool("sdl32", "VSync",      false);
    Config.scale      = file.ReadBool("sdl32", "Scale",      false);
    Config.filter     = file.ReadInt ("sdl32", "Filter",        0);

    int vexpand       = file.ReadInt ("sdl32", "VExpand",       0);
    int hexpand       = file.ReadInt ("sdl32", "HExpand",       0);

    if (vexpand < 0 || vexpand > 1024)
        vexpand = 0;

    if (hexpand < 0 || hexpand > 1024)
        hexpand = 0;

    Config.border.top    = (int)(vexpand / 2);
    Config.border.bottom = (int)(vexpand / 2) + (vexpand % 2);
    Config.border.left   = (int)(hexpand / 2);
    Config.border.right  = (int)(hexpand / 2) + (hexpand % 2);

}
开发者ID:FlyingJester,项目名称:sphere,代码行数:25,代码来源:sdl32.cpp

示例3: SetCurrentDirectory

bool
CProject::Save() const
{
  SetCurrentDirectory(m_Directory.c_str());
  
  CConfigFile config;
  config.Load(m_Filename.c_str());
  config.WriteString("", "name", m_GameTitle.c_str());
  config.WriteString("", "author", m_Author.c_str());
  config.WriteString("", "description", m_Description.c_str());
  config.WriteString("", "script", m_GameScript.c_str());
  // screen dimensions
  config.WriteInt("", "screen_width",  m_ScreenWidth);
  config.WriteInt("", "screen_height", m_ScreenHeight);
  config.Save(m_Filename.c_str());
  return true;
}
开发者ID:FlyingJester,项目名称:sphere,代码行数:17,代码来源:Project.cpp


注:本文中的CConfigFile::Load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。