Exemple #1
0
  void loadSettings(Glib::KeyFile &cfg)
  {
    for (guint i = 0; i < GCODE_TEXT_TYPE_COUNT; i++)
    {
      if (cfg.has_key ("GCode", GCodeNames[i]))
	m_GCode[i]->set_text(cfg.get_string ("GCode", GCodeNames[i]));
    }
  }
void Window::vApplyPerGameConfig()
{
    std::string sRDBFile = PKGDATADIR "/vba-over.ini";
    if (!Glib::file_test(sRDBFile, Glib::FILE_TEST_EXISTS))
        return;

    char csGameID[5];
    csGameID[0] = rom[0xac];
    csGameID[1] = rom[0xad];
    csGameID[2] = rom[0xae];
    csGameID[3] = rom[0xaf];
    csGameID[4] = '\0';

    Glib::KeyFile oKeyFile;
    oKeyFile.load_from_file(sRDBFile);

    if (!oKeyFile.has_group(csGameID))
        return;

    if (oKeyFile.has_key(csGameID, "rtcEnabled")) {
        bool bRTCEnabled = oKeyFile.get_boolean(csGameID, "rtcEnabled");
        rtcEnable(bRTCEnabled);
    }

    if (oKeyFile.has_key(csGameID, "flashSize")) {
        Glib::ustring sFlashSize = oKeyFile.get_string(csGameID, "flashSize");
        int iFlashSize = atoi(sFlashSize.c_str());
        if (iFlashSize == 0x10000 || iFlashSize == 0x20000)
            flashSetSize(iFlashSize);
    }

    if (oKeyFile.has_key(csGameID, "saveType")) {
        int iSaveType = oKeyFile.get_integer(csGameID, "saveType");
        if (iSaveType >= 0 && iSaveType <= 5)
            cpuSaveType = iSaveType;
    }

    if (oKeyFile.has_key(csGameID, "mirroringEnabled")) {
        mirroringEnable = oKeyFile.get_boolean(csGameID, "mirroringEnabled");
    }
}
Exemple #3
0
void Settings::load_settings (Glib::RefPtr<Gio::File> file)
{
  Glib::KeyFile cfg;

  set_defaults();

  try {
    if (!cfg.load_from_file (file->get_path())) {
      std::cout << "Failed to load settings from file '" << file->get_path() << "\n";
      return;
    }
  } catch (const Glib::KeyFileError &err) {
    std::cout << "Exception " << err.what() << " loading settings from file '" << file->get_path() << "\n";
    return;
  }

  std::cout << "parsing config from '" << file->get_path() << "\n";

  for (uint i = 0; i < G_N_ELEMENTS (settings); i++) {
    Glib::ustring group, key;

    if (!get_group_and_key (i, group, key))
      continue;

    if (!cfg.has_key (group, key))
      continue;

    // group & string ...
    switch (settings[i].type) {
    case T_BOOL:
      *PTR_BOOL(this, i) = cfg.get_boolean (group, key);
      break;
    case T_INT:
      *PTR_INT(this, i) = cfg.get_integer (group, key);
      break;
    case T_FLOAT:
    case T_COLOUR_MEMBER:
      *PTR_FLOAT(this, i) = cfg.get_double (group, key);
      break;
    case T_STRING:
      *PTR_STRING(this, i) = cfg.get_string (group, key);
      break;
    default:
      std::cerr << "corrupt setting type\n";
      break;
    }
  }

  GCode.m_impl->loadSettings (cfg);

  m_signal_visual_settings_changed.emit();
  m_signal_update_settings_gui.emit();
}