コード例 #1
0
void GalaxySetupWnd::OkClicked() {
    // record selected galaxy setup options as new defaults
    GetOptionsDB().Set("GameSetup.seed",                m_galaxy_setup_panel->GetSeed());
    GetOptionsDB().Set("GameSetup.stars",               m_galaxy_setup_panel->Systems());
    GetOptionsDB().Set("GameSetup.galaxy-shape",        m_galaxy_setup_panel->GetShape());
    GetOptionsDB().Set("GameSetup.galaxy-age",          m_galaxy_setup_panel->GetAge());
    GetOptionsDB().Set("GameSetup.starlane-frequency",  m_galaxy_setup_panel->GetStarlaneFrequency());
    GetOptionsDB().Set("GameSetup.planet-density",      m_galaxy_setup_panel->GetPlanetDensity());
    GetOptionsDB().Set("GameSetup.specials-frequency",  m_galaxy_setup_panel->GetSpecialsFrequency());
    GetOptionsDB().Set("GameSetup.monster-frequency",   m_galaxy_setup_panel->GetMonsterFrequency());
    GetOptionsDB().Set("GameSetup.native-frequency",    m_galaxy_setup_panel->GetNativeFrequency());
    GetOptionsDB().Set("GameSetup.ai-aggression",       m_galaxy_setup_panel->GetAIAggression());
    GetOptionsDB().Set("GameSetup.player-name",         m_player_name_edit->Text());
    GetOptionsDB().Set("GameSetup.empire-name",         EmpireName());
    GetOptionsDB().Set("GameSetup.empire-color",        static_cast<int>(m_empire_color_selector->CurrentItemIndex()));
    GetOptionsDB().Set("GameSetup.starting-species",    m_starting_secies_selector->CurrentSpeciesName());
    GetOptionsDB().Set("GameSetup.ai-players",          m_number_ais_spin->Value());

    // Save the changes:
    {
        boost::filesystem::ofstream ofs(GetConfigPath());
        if (ofs) {
            GetOptionsDB().GetXML().WriteDoc(ofs);
        } else {
            std::cerr << UserString("UNABLE_TO_WRITE_CONFIG_XML") << std::endl;
            std::cerr << GetConfigPath().string() << std::endl;
            Logger().errorStream() << UserString("UNABLE_TO_WRITE_CONFIG_XML");
            Logger().errorStream() << GetConfigPath().string();
        }
    }


    m_ended_with_ok = true;
    m_done = true;
}
コード例 #2
0
ファイル: Options.c プロジェクト: nicnilov/truecrypt-api
// Returns the number of partitions where non-system in-place encryption is progress or had been in progress
// but was interrupted. In addition, via the passed pointer, returns the last selected wipe algorithm ID.
// nee int LoadNonSysInPlaceEncSettings (WipeAlgorithmId *wipeAlgorithm)
int TryDetectNonSysInPlaceEncSettings (WipeAlgorithmId *wipeAlgorithm)
{
	char *fileBuf = NULL;
	char *fileBuf2 = NULL;
	DWORD size, size2;
	int count;

	*wipeAlgorithm = TC_WIPE_NONE;

	if (!FileExists (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC)))
		return 0;

	if ((fileBuf = LoadFile (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC), &size)) == NULL)
		return 0;

	if (FileExists (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE)))
	{
		if ((fileBuf2 = LoadFile (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE), &size2)) != NULL)
			*wipeAlgorithm = (WipeAlgorithmId) atoi (fileBuf2);
	}

	count = atoi (fileBuf);

	if (fileBuf != NULL)
		TCfree (fileBuf);

	if (fileBuf2 != NULL)
		TCfree (fileBuf2);

	return (count);
}
コード例 #3
0
void ServerConnectWnd::OkClicked()
{
    // record selected galaxy setup options as new defaults
    GetOptionsDB().Set("multiplayersetup.player-name",  m_player_name_edit->Text());
    GetOptionsDB().Set("multiplayersetup.host-address", m_IP_address_edit->Text());

    // Save the changes:
    {
        boost::filesystem::ofstream ofs(GetConfigPath());
        if (ofs) {
            GetOptionsDB().GetXML().WriteDoc(ofs);
        } else {
            std::cerr << UserString("UNABLE_TO_WRITE_CONFIG_XML") << std::endl;
            std::cerr << GetConfigPath().string() << std::endl;
            Logger().errorStream() << UserString("UNABLE_TO_WRITE_CONFIG_XML");
            Logger().errorStream() << GetConfigPath().string();
        }
    }

    m_result.first = *m_player_name_edit;
    if (m_host_or_join_radio_group->CheckedButton() == 0) {
        m_result.second = "HOST GAME SELECTED";
    } else {
        m_result.second = *m_IP_address_edit;
        if (m_result.second == "") {
            m_result.second =
                boost::polymorphic_downcast<GG::TextControl*>(
                    (***m_servers_lb->Selections().begin())[0])->Text();
        }
    }
    CUIWnd::CloseClicked();
}
コード例 #4
0
QString PathManager::GetDataBasePath()
{
	QString path("");
	if (!GetConfigPath().isEmpty()){
		path = GetConfigPath() + "/database.db";
	}
	return path;
}
コード例 #5
0
ファイル: steopts.cpp プロジェクト: cubemoon/game-editor
void wxSTEditorOptions::LoadConfig(wxConfigBase &config)
{
    if (HasConfigOption(STE_CONFIG_PREFS) && GetEditorPrefs().Ok())
        GetEditorPrefs().LoadConfig(config, GetConfigPath(STE_OPTION_CFGPATH_PREFS));
    if (HasConfigOption(STE_CONFIG_STYLES) && GetEditorStyles().Ok())
        GetEditorStyles().LoadConfig(config, GetConfigPath(STE_OPTION_CFGPATH_STYLES));
    if (HasConfigOption(STE_CONFIG_LANGS) && GetEditorLangs().Ok())
        GetEditorLangs().LoadConfig(config, GetConfigPath(STE_OPTION_CFGPATH_LANGS));
}
コード例 #6
0
GuideAlgorithmLowpass::GuideAlgorithmLowpass(Mount *pMount, GuideAxis axis)
    : GuideAlgorithm(pMount, axis)
{
    double minMove     = pConfig->Profile.GetDouble(GetConfigPath() + "/minMove", DefaultMinMove);
    SetMinMove(minMove);

    double slopeWeight = pConfig->Profile.GetDouble(GetConfigPath() + "/SlopeWeight", DefaultSlopeWeight);
    SetSlopeWeight(slopeWeight);

    reset();
}
コード例 #7
0
ファイル: steopts.cpp プロジェクト: cubemoon/game-editor
void wxSTEditorOptions::SaveConfig(wxConfigBase &config)
{
    if (HasConfigOption(STE_CONFIG_PREFS) && GetEditorPrefs().Ok())
        GetEditorPrefs().SaveConfig(config, GetConfigPath(STE_OPTION_CFGPATH_PREFS));
    if (HasConfigOption(STE_CONFIG_STYLES) && GetEditorStyles().Ok())
        GetEditorStyles().SaveConfig(config, GetConfigPath(STE_OPTION_CFGPATH_STYLES));
    if (HasConfigOption(STE_CONFIG_LANGS) && GetEditorLangs().Ok())
        GetEditorLangs().SaveConfig(config, GetConfigPath(STE_OPTION_CFGPATH_LANGS));

    if (GetEditorPrefs().Ok() || GetEditorStyles().Ok() || GetEditorLangs().Ok())
        config.Flush(true); // what is current only?
}
コード例 #8
0
/**
 * CSC_ParseDomainList
 *
 * @return     CDomainList*
 * @exception    -
 * @see        
 */
CDomainList *CSC_ParseDomainList(BOOL fullDownload)
{
    CDomainList *retval = new CDomainList;

    CCsvParse parser;
    CString filename = GetConfigPath() + (fullDownload?pszDomainFileName:pszOnlineDomainName);
    HRESULT hr = parser.Open(filename);
    if (FAILED(hr)) {
        FC_DEBUGPRINT1(_T("CSVPARS> file not found: %s\n"), filename);
        TrcPrint(TRC_ERROR, _T("CSVPARS> file not found: %s\n"), filename);
        return retval;
    }

    BOOL syntax = TRUE;
    for (;;) {
      CSC_DOMAINENTRY domain;
      CString strType, strFile;
      if (!parser.IsEndOfLine()) {
        syntax = FALSE;
        break;
      }
      BOOL ok = parser.ParseNextField(strType);
      if (!ok)
          break;
      strType.MakeLower();
      if (strType == _T("code"))
          domain.type = CSC_DOMAINTYPE_CODE;
      else if (strType == _T("init"))
          domain.type = CSC_DOMAINTYPE_INITIAL;
      else if (strType == _T("config"))
          domain.type = CSC_DOMAINTYPE_CONFIG;
      else if (strType == _T("custom"))
          domain.type = CSC_DOMAINTYPE_CUSTOM;
      else if (strType == _T("debug"))
          domain.type = CSC_DOMAINTYPE_DEBUG;
      else
          domain.type = CSC_DOMAINTYPE_UNKNOWN;
      syntax = parser.ParseNextField(strFile);
      if (!syntax)
          break;
      domain.file = GetConfigPath() + strFile;
      retval->AddTail(domain);
      while (!parser.IsEndOfLine() && parser.ParseNextField(strFile))
          ;
    }
    if (!syntax) {
        FC_DEBUGPRINT3(_T("CSVPARS> syntax error in %s(%d:%d)\n"), filename, parser.GetLineNo(), parser.GetLinePos());
        TrcPrint(TRC_ERROR, _T("CSVPARS> syntax error in %s(%d:%d)\n"), filename, parser.GetLineNo(), parser.GetLinePos());
    }
    return retval;
}
コード例 #9
0
GuideAlgorithmResistSwitch::GuideAlgorithmResistSwitch(Mount *pMount, GuideAxis axis)
    : GuideAlgorithm(pMount, axis)
{
    double minMove  = pConfig->Profile.GetDouble(GetConfigPath() + "/minMove", DefaultMinMove);
    SetMinMove(minMove);

    double aggr = pConfig->Profile.GetDouble(GetConfigPath() + "/aggression", DefaultAggression);
    SetAggression(aggr);

    bool enable = pConfig->Profile.GetBoolean(GetConfigPath() + "/fastSwitch", true);
    SetFastSwitchEnabled(enable);

    reset();
}
コード例 #10
0
ファイル: instance.cpp プロジェクト: Glought/MultiMC4
Instance::Instance(const wxString &rootDir)
    : modList(this), m_running(false)
{
    if (!rootDir.EndsWith("/"))
        this->rootDir = wxFileName::DirName(rootDir + "/");
    else
        this->rootDir = wxFileName::DirName(rootDir);
    config = new wxFileConfig(wxEmptyString, wxEmptyString, GetConfigPath().GetFullPath(), wxEmptyString,
                              wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
    evtHandler = NULL;
    MkDirs();

    // initialize empty mod lists - they are filled later and only if requested (see apropriate Get* methods)
    modList.SetDir(GetInstModsDir().GetFullPath());
    mlModList.SetDir(GetMLModsDir().GetFullPath());
    coreModList.SetDir(GetCoreModsDir().GetFullPath());
    worldList.SetDir(GetSavesDir().GetFullPath());
    tpList.SetDir(GetTexturePacksDir().GetFullPath());
    modloader_list_inited = false;
    coremod_list_inited = false;
    jar_list_inited = false;
    world_list_initialized = false;
    tp_list_initialized = false;
    parentModel = nullptr;
    UpdateVersion();
}
コード例 #11
0
bool GuideAlgorithmResistSwitch::SetMinMove(double minMove)
{
    bool bError = false;

    try
    {
        if (minMove <= 0.0)
        {
            throw ERROR_INFO("invalid minMove");
        }

        m_minMove = minMove;
        m_currentSide = 0;
    }
    catch (wxString Msg)
    {
        POSSIBLY_UNUSED(Msg);
        bError = true;
        m_minMove = DefaultMinMove;
    }

    pConfig->Profile.SetDouble(GetConfigPath() + "/minMove", m_minMove);

    Debug.Write(wxString::Format("GuideAlgorithmResistSwitch::SetMinMove() returns %d, m_minMove=%.2f\n", bError, m_minMove));

    return bError;
}
コード例 #12
0
bool GuideAlgorithmResistSwitch::SetAggression(double aggr)
{
    bool bError = false;

    try
    {
        if (aggr <= 0.0 || aggr > 1.0)
        {
            throw ERROR_INFO("invalid aggression");
        }

        m_aggression = aggr;
    }
    catch (const wxString& Msg)
    {
        POSSIBLY_UNUSED(Msg);
        bError = true;
        m_aggression = DefaultAggression;
    }

    pConfig->Profile.SetDouble(GetConfigPath() + "/aggression", m_aggression);

    Debug.Write(wxString::Format("GuideAlgorithmResistSwitch::SetAggression() returns %d, m_aggression=%.2f\n", bError, m_aggression));

    return bError;
}
コード例 #13
0
ファイル: m_misc.cpp プロジェクト: JohnnyonFlame/odamex
void STACK_ARGS M_SaveDefaults (void)
{
	FILE *f;

	if (!DefaultsLoaded)
		return;

	std::string configfile = GetConfigPath();

	// Make sure the user hasn't changed configver
	configver.Set(CONFIGVERSIONSTR);

	if ( (f = fopen (configfile.c_str(), "w")) )
	{
		fprintf (f, "// Generated by Odamex " DOTVERSIONSTR " - don't hurt anything\n");

		// Archive all cvars marked as CVAR_ARCHIVE
		cvar_t::C_ArchiveCVars (f);

		// Archive all active key bindings
		//C_ArchiveBindings (f);

		// Archive all aliases
		DConsoleAlias::C_ArchiveAliases (f);

		// Archive master list
		SV_ArchiveMasters (f);

		fclose (f);
	}
}
コード例 #14
0
void OBSBasic::on_actionRemoveSceneCollection_triggered()
{
	std::string newName;
	std::string newPath;

	std::string oldFile = config_get_string(App()->GlobalConfig(),
			"Basic", "SceneCollectionFile");
	std::string oldName = config_get_string(App()->GlobalConfig(),
			"Basic", "SceneCollection");

	auto cb = [&](const char *name, const char *filePath)
	{
		if (strcmp(oldName.c_str(), name) != 0) {
			newName = name;
			newPath = filePath;
			return false;
		}

		return true;
	};

	EnumSceneCollections(cb);

	/* this should never be true due to menu item being grayed out */
	if (newPath.empty())
		return;

	QString text = QTStr("ConfirmRemove.Text");
	text.replace("$1", QT_UTF8(oldName.c_str()));

	QMessageBox::StandardButton button = QMessageBox::question(this,
			QTStr("ConfirmRemove.Title"), text);
	if (button == QMessageBox::No)
		return;

	char path[512];
	int ret = GetConfigPath(path, 512, "obs-studio/basic/scenes/");
	if (ret <= 0) {
		blog(LOG_WARNING, "Failed to get scene collection config path");
		return;
	}

	oldFile.insert(0, path);
	oldFile += ".json";
	os_unlink(oldFile.c_str());

	Load(newPath.c_str());
	RefreshSceneCollections();

	const char *newFile = config_get_string(App()->GlobalConfig(),
			"Basic", "SceneCollectionFile");

	blog(LOG_INFO, "Removed scene collection '%s' (%s.json), "
			"switched to '%s' (%s.json)",
			oldName.c_str(), oldFile.c_str(),
			newName.c_str(), newFile);
	blog(LOG_INFO, "------------------------------------------------");

	UpdateTitleBar();
}
コード例 #15
0
bool GuideAlgorithmHysteresis::SetHysteresis(double hysteresis)
{
    bool bError = false;

    try
    {
        if (hysteresis < 0.0 || hysteresis > MaxHysteresis)
        {
            throw ERROR_INFO("invalid hysteresis");
        }

        m_hysteresis = hysteresis;

    }
    catch (wxString Msg)
    {
        POSSIBLY_UNUSED(Msg);
        bError = true;
        m_hysteresis = wxMin(wxMax(hysteresis, 0.0), MaxHysteresis);
    }

    pConfig->Profile.SetDouble(GetConfigPath() + "/hysteresis", m_hysteresis);

    return bError;
}
コード例 #16
0
BOOL CSC_GetFileType(const CString& strFileName, CString& strFileType)
{
    CCsvParse parser;
	int found = 0;
	CString strFile;
	CString filename = GetConfigPath() + pszDomainFileName;

	HRESULT hr = parser.Open(filename);
	if (FAILED(hr)) {
		FC_DEBUGPRINT1(_T("CSVPARS> file not found: %s\n"), filename);
		TrcPrint(TRC_ERROR, _T("CSVPARS> file not found: %s\n"), filename);
	}
	else {
		while(1)
		{
			BOOL ok = parser.ParseNextField(strFileType);
			if (!ok)
				break;
			ok = parser.ParseNextField(strFile);
			if (!ok)
				break;
			if(strFileName.CompareNoCase(strFile) == 0)
			{
				found = 1;
				break;
			}
		}
		parser.Close();
	}

	if(!found) 
		strFileType = _T("unknown");

	return found;
}
コード例 #17
0
bool GuideAlgorithmHysteresis::SetMinMove(double minMove)
{
    bool bError = false;

    try
    {
        if (minMove < 0.0)
        {
            throw ERROR_INFO("invalid minMove");
        }

        m_minMove = minMove;

    }
    catch (wxString Msg)
    {
        POSSIBLY_UNUSED(Msg);
        bError = true;
        m_minMove = DefaultMinMove;
    }

    pConfig->Profile.SetDouble(GetConfigPath() + "/minMove", m_minMove);

    return bError;
}
コード例 #18
0
ファイル: appconfig.cpp プロジェクト: lelou6666/pcmanx-gtk2
void CAppConfig::SaveFavorites()
{
	string fpath = GetConfigPath("favorites");
	FILE* fo = fopen( fpath.c_str() , "w" );
	if( fo )
	{
		// bool has_sensitive_data = false;
		vector<CSite>::iterator it;
		for( it = Favorites.begin(); it != Favorites.end(); ++it )
		{
			CSite& site = *it;
			site.SaveToFile(fo);
			fputc( '\n', fo );

//			if( pSite->GetPasswd().length() )
//				has_sensitive_data = true;
		}
		fclose(fo);

//		if( ! has_sensitive_data )	// No data needs to be encrypted, cancel password.
//			SetUserPasswd( wxEmptyString );

		chmod(fpath.c_str(), 0600);	// Only the owner can access this file.
	}
}
コード例 #19
0
ファイル: m_misc.cpp プロジェクト: JohnnyonFlame/odamex
void STACK_ARGS M_SaveDefaults (void)
{
	FILE *f;

	if (!DefaultsLoaded)
		return;

	std::string configfile = GetConfigPath();

	// Make sure the user hasn't changed configver
	configver.Set(CONFIGVERSIONSTR);

	if ( (f = fopen (configfile.c_str(), "w")) )
	{
		fprintf (f, "// Generated by Odasrv " DOTVERSIONSTR "\n\n");

		// Archive all cvars marked as CVAR_ARCHIVE
		fprintf (f, "// --- Console variables ---\n\n");
		cvar_t::C_ArchiveCVars (f);

		// Archive all active key bindings
		//fprintf (f, "// --- Key Bindings ---\n\n");
		//C_ArchiveBindings (f);

		// Archive all aliases
		fprintf (f, "\n// --- Aliases ---\n\n");
		DConsoleAlias::C_ArchiveAliases (f);

		fclose (f);
	}
}
コード例 #20
0
ファイル: guide_algorithm.cpp プロジェクト: AndresPozo/phd2
// Default technique to force a reset on algo parameters is simply to remove the keys from the Registry - a subsequent creation of the algo 
// class will then use default values for everything.  If this is too brute-force for a particular algo, the function can be overridden. 
// For algos that use a min-move parameter, a smart value will be applied based on image scale
void GuideAlgorithm::ResetParams()
{
    wxString configPath = GetConfigPath();
    pConfig->Profile.DeleteGroup(configPath);
    if (GetMinMove() >= 0)
        SetMinMove(SmartDefaultMinMove());
}
コード例 #21
0
void PathManager::WriteLastPath(QString &key, QString &val)
{
	QSettings settings(GetConfigPath() + QStringLiteral("/Config.ini"), QSettings::IniFormat);
	settings.beginGroup("LastPathSetting");
	settings.setValue(key, val);
	settings.endGroup();
}
コード例 #22
0
ファイル: LoginDlg.cpp プロジェクト: dehilsterlexis/eclide-1
	void RefreshGlobal()
	{
		DoDataExchange(true);
		boost::filesystem::path configFile;
		GetConfigPath(static_cast<const TCHAR *>(m_ConfigLabel), configFile);
		CComPtr<IConfig> config = CreateIConfig(QUERYBUILDER_CFG, configFile);
		CString accountServer = config->Get(GLOBAL_SERVER_ACCOUNT);
		if (accountServer.IsEmpty())
		{
			GetDlgItem(IDC_EDIT_USER).EnableWindow(false);
			GetDlgItem(IDC_EDIT_PASSWORD).EnableWindow(false);
			m_User = _T("");
			m_Password = _T("");
		}
		else
		{
			GetDlgItem(IDC_EDIT_USER).EnableWindow(true);
			GetDlgItem(IDC_EDIT_PASSWORD).EnableWindow(true);
			m_User = config->Get(GLOBAL_USER);
			m_Password = config->Get(GLOBAL_PASSWORD);
		}
		if (m_configPrefs)
			GetDlgItem(IDC_LOGIN_PREFS).EnableWindow(m_ConfigLabel.IsEmpty()==false);
		DoDataExchange();
		m_autoUpdateLink.ShowWindow(SW_HIDE);
		if (!(bool)m_IniFile->Get(GLOBAL_DISABLEAUTOUPDATE))
			clib::thread run(__FUNCTION__, boost::bind(&thread_CheckForUpdates, this, m_autoupdate));

	}
コード例 #23
0
bool GuideAlgorithmHysteresis::SetAggression(double aggression)
{
    bool bError = false;

    try
    {
        if (aggression <= 0.0 || aggression > MaxAggression)
        {
            throw ERROR_INFO("invalid aggression");
        }

        m_aggression = aggression;
    }
    catch (wxString Msg)
    {
        POSSIBLY_UNUSED(Msg);
        bError = true;
        m_aggression = wxMin(wxMax(aggression, 0.1), MaxAggression);
    }

    m_lastMove = 0.0;
    pConfig->Profile.SetDouble(GetConfigPath() + "/aggression", m_aggression);

    return bError;
}
コード例 #24
0
static void CompareRadarAndCameraInArea(const t_Point radar_point, const t_Point camera_point, const double area_width, const double area_length, int *p_max_similary) {
	t_Point per_radar_point;
	int per_similary;
	int compare_count;
	int compare_index;
	int max_similary;
	char config_path[255];
	int basic_length;

	ASSERT(NULL != p_max_similary);
	max_similary = 0;
	GetConfigPath(config_path, sizeof(config_path));
	GetBasicLengthOfRadarCompareArea(config_path, &basic_length);
	compare_count = (int)(area_length / basic_length * 1000);
	for (compare_index = 0; compare_index < compare_count; compare_index++) {
		per_radar_point.m_x = radar_point.m_x - area_length / 2 + (double)(basic_length) * compare_index / 1000;
		per_radar_point.m_y = radar_point.m_y;
		CompareRadarAndCameraInLine(per_radar_point, camera_point, area_width, &per_similary);
		if (per_similary > max_similary)
			max_similary = per_similary;
		else
			continue;
	}
	*p_max_similary = max_similary;
}
コード例 #25
0
bool RunRadarDataList() {
	const int c_PerComDataSize = 1024;
	unsigned char com_data[1024];
	int act_com_size;
	bool ok_com;
	char config_path[255];
	int port_num;
	int baud_rate;

	GetConfigPath(config_path, sizeof(config_path));
	GetPortNumOfSerialInterface(config_path, &port_num);
	GetBaudRateOfSerialInterface(config_path, &baud_rate);
	ok_com = OpenComport(port_num, baud_rate);
	if (false == ok_com) {
		LOG("OpenComport() error!\n");
		return false;
	}
	else {
		while (true) {
			act_com_size = ReadComport(com_data, c_PerComDataSize);
			if (0 == act_com_size)
				continue;
			else
				AnalyseComData(com_data, act_com_size);
		}
		CloseComport();
		return true;
	}
}
コード例 #26
0
bool GetSpeed(const t_PlateArea plate_area, double *p_speed, int *p_speed_confidence) {
	t_CarArray car_array;
	t_Car car;
	double speed;
	bool ok_get;
	bool ok_find;
	int car_similary;
	char config_path[255];
	int past_num;

	ASSERT(NULL != p_speed && NULL != p_speed_confidence);
	GetConfigPath(config_path, sizeof(config_path));
	GetPastNumOfRadarDataList(config_path, &past_num);
	ok_get = GetCarArrayFromList(past_num, &car_array);
	if (false == ok_get) {
		return false;
	}
	else {
		ok_find = FindCar(plate_area, car_array, &car, &car_similary);
		if (false == ok_find) {
			return false;
		}
		else {
			speed = car.m_speed.m_x;
			*p_speed = speed;
			*p_speed_confidence = car_similary;
			return true;
		}
	}
}
コード例 #27
0
BOOL CSC_ReverseLookupTask(long taskid, CString &name)
{
    CCsvParse parser;
    CString filename = GetConfigPath() + pszTasksFileName;
    HRESULT hr = parser.Open(filename);
    if (FAILED(hr)) {
        FC_DEBUGPRINT1(_T("CSVPARS> file not found: %s\n"), filename);
        TrcPrint(TRC_ERROR, _T("CSVPARS> file not found: %s\n"), filename);
        return FALSE;
    }

    BOOL syntax = TRUE;
    for (;;) {
      CString task, str_taskid,loaded;

	  if (CConnection::GetFirmware() >= 20900 && CConnection::GetFirmware() < 21000)
	  {
		  // 04.04.06 SIS: do not check for end of line here (only for OSAI V2.09)
	  }
	  else
	  {
		  if (!parser.IsEndOfLine()) {
			syntax = FALSE;
			break;
		  }
	  }
	  
      BOOL ok = parser.ParseNextField(task);
      if (!ok)
          break;
      task.MakeLower();
      syntax = parser.ParseNextField(str_taskid);
      if (!syntax)
          break;

	  if (CConnection::GetFirmware() >= 20700)
	  {
		  // Skip loaded/unloaded flag
		  ok = parser.ParseNextField(loaded);
		  if (!ok)
			  break;
	  }

      if (taskid == _ttol(str_taskid)){
        name = task;
        return TRUE;
      }

	  if (CConnection::GetFirmware() >= 20900 && CConnection::GetFirmware() < 21000)
	  {
		parser.SkipLine();	// 04.04.06 SIS: skip rest of line
	  }
    }
    if (!syntax) {
        FC_DEBUGPRINT3(_T("CSVPARS> syntax error in %s(%d:%d)\n"), filename, parser.GetLineNo(), parser.GetLinePos());
        TrcPrint(TRC_ERROR, _T("CSVPARS> syntax error in %s(%d:%d)\n"), filename, parser.GetLineNo(), parser.GetLinePos());
    }
    return FALSE;
}
コード例 #28
0
ファイル: OptionsDB.cpp プロジェクト: MatGB/freeorion
void OptionsDB::Commit()
{
    if (!m_dirty)
        return;
    boost::filesystem::ofstream ofs(GetConfigPath());
    if (ofs) {
        XMLDoc doc;
        GetOptionsDB().GetXML(doc);
        doc.WriteDoc(ofs);
        m_dirty = false;
    } else {
        std::cerr << UserString("UNABLE_TO_WRITE_CONFIG_XML") << std::endl;
        std::cerr << PathString(GetConfigPath()) << std::endl;
        ErrorLogger() << UserString("UNABLE_TO_WRITE_CONFIG_XML");
        ErrorLogger() << PathString(GetConfigPath());
    }
}
コード例 #29
0
QString PathManager::ReadLastPath(QString &key)
{
	QString ret;
	QSettings settings(GetConfigPath() + QStringLiteral("/Config.ini"), QSettings::IniFormat);
	settings.beginGroup("LastPathSetting");
	ret = settings.value(key, "").toString();
	settings.endGroup();
	return ret;
}
コード例 #30
0
ファイル: utilities.cpp プロジェクト: BrummbQ/Clementine
QString GetConfigPath(ConfigPath config) {
  switch (config) {
    case Path_Root: {
      if (Application::kIsPortable) {
        return QString("%1/data").arg(QCoreApplication::applicationDirPath());
      }
      #ifdef Q_OS_DARWIN
        return mac::GetApplicationSupportPath() + "/" + QCoreApplication::organizationName();
      #else
        return QString("%1/.config/%2").arg(QDir::homePath(), QCoreApplication::organizationName());
      #endif
    }
    break;

    case Path_CacheRoot: {
      if (Application::kIsPortable) {
        return GetConfigPath(Path_Root) + "/cache";
      }
      #if defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN)
        char* xdg = getenv("XDG_CACHE_HOME");
        if (!xdg || !*xdg) {
          return QString("%1/.cache/%2").arg(QDir::homePath(), QCoreApplication::organizationName());
        } else {
          return QString("%1/%2").arg(xdg, QCoreApplication::organizationName());
        }
      #else
        return GetConfigPath(Path_Root);
      #endif
    }
    break;

    case Path_AlbumCovers:
      return GetConfigPath(Path_Root) + "/albumcovers";

    case Path_NetworkCache:
      return GetConfigPath(Path_CacheRoot) + "/networkcache";

    case Path_MoodbarCache:
      return GetConfigPath(Path_CacheRoot) + "/moodbarcache";

    case Path_GstreamerRegistry:
      return GetConfigPath(Path_Root) +
          QString("/gst-registry-%1-bin").arg(QCoreApplication::applicationVersion());

    case Path_DefaultMusicLibrary:
      #ifdef Q_OS_DARWIN
        return mac::GetMusicDirectory();
      #else
        return QDir::homePath();
      #endif

    case Path_LocalSpotifyBlob:
      return GetConfigPath(Path_Root) + "/spotifyblob";

    default:
      qFatal("%s", Q_FUNC_INFO);
      return QString::null;
  }
}