Beispiel #1
0
/**
 * @brief 加载配置文件
 * @param void
 * @return void
 */
void LoadProfile (void)
{
    FILE           *fp;
    char            buf[PATH_MAX], *pbuf, *pbuf1;
    int             i;
    Configure       *tmpconfig;

    /* 前将窗口的位置设定为最原始的默认值,接下来如果配置文件有,
     * 会从配置文件中读取,如果没有就使用这个了*/
    iMainWindowX = MAINWND_STARTX;		//主窗口位置X
    iMainWindowY = MAINWND_STARTY;		//主窗口位置Y
    iInputWindowX = INPUTWND_STARTX;	//输入窗口位置X
    iInputWindowY = INPUTWND_STARTY;	//输入窗口位置Y

    fp = UserConfigFile ("profile", "rt", NULL);
    if(!fp){
        if(errno == ENOENT)
            SaveProfile();
        return;
    }

    /* FIXME: 也许应该用另外更恰当的缓冲区长度 */
    while(fgets(buf, PATH_MAX, fp)){
        i = strlen(buf);
        if(buf[i-1] != '\n'){
            fprintf(stderr, "error: profile file: line length\n");
            exit(1);
        }else
            buf[i-1] = '\0';

        pbuf = buf;
        while(*pbuf && isspace(*pbuf))
            pbuf++;
        if(!*pbuf || *pbuf == '#')
            continue;

        pbuf1 = strchr(pbuf, '=');
        if(!pbuf1){
            fprintf(stderr, "error: profile file: configure entry name\n");
            exit(1);
        }

        for(tmpconfig = profiles; tmpconfig->name; tmpconfig++)
            if(strncmp(tmpconfig->name, pbuf, pbuf1-pbuf) == 0)
                read_configure(tmpconfig, ++pbuf1);
    }

    fclose(fp);

    iIMIndex = iIMIndex_tmp;		/* piaoairy add 20080518 */

    if(bNeedSaveConfig){
        SaveConfig();
        SaveProfile();
     }
}
//=======================================================================================================================================
// Add a profile
void hedPlayerProfileManager::AddProfile(char* profileName, char* modName,int playerDifficulty)
{
    FILE* file;
    int   i;

    if(m_ProfileCount < HED_MAXPROFILES)
    {
        strcpy(m_ProfileList[m_ProfileCount].name, profileName);
        strcpy(m_ProfileList[m_ProfileCount].modName, modName);
        m_ProfileList[m_ProfileCount].modLevelNumber    = 0;
        m_ProfileList[m_ProfileCount].modLevelNumberMax = 0;
        m_ProfileList[m_ProfileCount].score             = 0;
        m_ProfileList[m_ProfileCount].difficulty        = playerDifficulty;

        m_ProfileCurrent = m_ProfileCount;
        SaveProfile(m_ProfileCurrent);

        m_ProfileCount++;

        // Save profile list
        file = fopen(sysGetAppDataPath("profiles"),"wt");
        fprintf(file,"%d\n",m_ProfileCount);
        for(i = 0; i < m_ProfileCount; i++)
            fprintf(file,"%s\n",m_ProfileList[i].name);
        fclose(file);
    }
    else
        sysLogPrint("hedPlayerProfileManager::AddProfile(%s) - Maximum number of profiles exceeded.",profileName); 
}
Beispiel #3
0
void COptionsManager::SystemConfigChanged(bool silent)
{
	//gEnv->pConsole->ExecuteString("sys_SaveCVars 1");
	//gEnv->pSystem->SaveConfiguration();
	//gEnv->pConsole->ExecuteString("sys_SaveCVars 0");

	if(m_pPlayerProfileManager)
	{
		UpdateToProfile();
		SaveProfile();
	}
	
	if(!silent)
	{
		if(CFlashMenuScreen *pCurrentMenu = GetCurrentMenu())
		{
			pCurrentMenu->Invoke("showErrorMessage", "Box1");
			CryFixedStringT<128> text = "@system_spec_";
			text.append(gEnv->pConsole->GetCVar("sys_spec")->GetString());
			pCurrentMenu->Invoke("setErrorText", text.c_str());
			text = "sys_spec_Full \0";
			text.append(gEnv->pConsole->GetCVar("sys_spec")->GetString());
			gEnv->pConsole->ExecuteString(text.c_str());
		}
	}
	UpdateFlashOptions();

}
void FLauncherProfileManager::SaveProfiles( )
{
	for (TArray<ILauncherProfilePtr>::TIterator It(SavedProfiles); It; ++It)
	{
		SaveProfile((*It).ToSharedRef());
	}
}
ILauncherProfileRef FLauncherProfileManager::AddNewProfile()
{
	// find a unique name for the profile.
	int32 ProfileIndex = SavedProfiles.Num();
	FString ProfileName = FString::Printf(TEXT("New Profile %d"), ProfileIndex);

	for (int32 Index = 0; Index < SavedProfiles.Num(); ++Index)
	{
		if (SavedProfiles[Index]->GetName() == ProfileName)
		{
			ProfileName = FString::Printf(TEXT("New Profile %d"), ++ProfileIndex);
			Index = -1;

			continue;
		}
	}

	// create and add the profile
	ILauncherProfileRef NewProfile = MakeShareable(new FLauncherProfile(AsShared(), FGuid::NewGuid(), ProfileName));

	AddProfile(NewProfile);

	SaveProfile(NewProfile);

	return NewProfile;
}
void LevelManager::ReloadCurrentLevel(bool clear, int deathCount)
{
	SaveProfile(deathCount);
	if (clear)
		cocos2d::Director::getInstance()->popToRootScene();
	cocos2d::Director::getInstance()->pushScene(TestLevel::createScene(m_curLevel));
}
Beispiel #7
0
void COptionsManager::SaveValueToProfile(const char* key, float value)
{
	if(!m_pPlayerProfileManager)
		return;

	IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(m_pPlayerProfileManager->GetCurrentUser());
	if(!pProfile)
		return;

	pProfile->SetAttribute(key, value);
	SaveProfile();
}
//------------------------------------------------------------------------------
void FContextMenuTargetProfile::SetContextTarget(EContextTargetFlags::Type Flag, bool bClear)
{
	if (bClear)
	{
		SavedTargetFlags &= ~Flag;
	}
	else
	{
		SavedTargetFlags |= Flag;
	}
	SaveProfile();
}
void LevelManager::LoadNextLevel(int deathCount)
{
	if (m_curLevel < m_maxLevels)
	{
		m_curLevel++;
		SaveProfile();
	}
	else
	{
		cocos2d::Director::getInstance()->popToRootScene();
		//m_unlockedLevels = m_maxLevels;
		m_curLevel = 1;
		SaveProfile();
		return;
	}
	if (m_curLevel > m_unlockedLevels)
	{
		++m_unlockedLevels;
		SaveProfile(deathCount);
	}
	cocos2d::Director::getInstance()->popToRootScene();
	cocos2d::Director::getInstance()->pushScene(TestLevel::createScene(m_curLevel));
}
Beispiel #10
0
void RemoteProfileDlg::SetProfile(unsigned int profile_id) {
	wxASSERT((int)profile_id != -1);

	if (m_currentProfile == (intptr_t)profile_id) return;
	else if (m_currentProfile != -1) SaveProfile();

	// Get the profile from db
	const RemoteProfile* rp = m_settings.GetRemoteProfile(profile_id);

	m_currentProfile = (intptr_t)profile_id;
	m_profileName->SetValue(rp->m_name);
	m_profileAddress->SetValue(rp->m_address);
	m_profileDir->SetValue(rp->m_dir);
	m_profileUsername->SetValue(rp->m_username);
	m_profilePassword->SetValue(rp->m_pwd);

	EnableSettings(true);
}
Beispiel #11
0
// This function saves the state (visible buttons, toolbar position, etc.)
// of the toolbar, using the registry key provided to the Create(...) function.
void CDkToolBar::SaveState()
{
	// if there is an associated registry subkey
	//if (registrySubKey.GetLength())
	//{
	//	// save the toolbar state to the registry
	//	GetToolBarCtrl().SaveState(registryKey, registrySubKey, registryValue);
	//}
	CString strINI = AfxGetApp()->m_pszProfileName;
	InitProfile();
	int i;

	for (i=0;i<pluginToolBarInfo.GetSize();i++) {
		CPluginToolBarInfo* button = (CPluginToolBarInfo*)pluginToolBarInfo.GetAt(i);
		int nPos = GetToolBarCtrl().CommandToIndex(button->tbButton.idCommand);
		MyWriteProfileInt(L"STEP\\ToolbarPosition", button->strRegName, nPos);
	}
	for (i=0;i<pluginToolBarInfo.GetSize();i++) {
		CPluginToolBarInfo* button = (CPluginToolBarInfo*)pluginToolBarInfo.GetAt(i);
		int nPos = GetToolBarCtrl().CommandToIndex(button->tbButton.idCommand);
		GetToolBarCtrl().DeleteButton(nPos);
	}

	// 標準ボタンの位置を保存
	for (i=0;i<GetToolBarCtrl().GetButtonCount();i++) {
		TBBUTTON tbButton;
		CString strRegName;
		strRegName.Format(L"Pos%02d", i);
		if (GetToolBarCtrl().GetButton(i, &tbButton)) {
			MyWriteProfileInt(L"STEP\\DefaultToolbarPosition", strRegName, tbButton.idCommand);
		}
	}
	{
		CString strRegName;
		strRegName.Format(L"Pos%02d", i);
		MyWriteProfileInt(L"STEP\\DefaultToolbarPosition", strRegName, -1);
	}
	SaveProfile();
	FreeProfile();
}
Beispiel #12
0
void COptionsManager::UpdateToProfile()
{
	std::map<string,SOptionEntry>::const_iterator it = m_profileOptions.begin();
	std::map<string,SOptionEntry>::const_iterator end = m_profileOptions.end();

	for(;it!=end;++it)
	{
		const SOptionEntry& entry = it->second;
		if(!strcmp(it->first.c_str(),"pb_client"))
		{
			SaveValueToProfile(entry.name.c_str(), m_pbEnabled?1:0);
		}
		else if(!strcmp(it->first.c_str(), "fsaa_mode"))
		{
			string value("");
			if(g_pGame->GetMenu())
			{
				if(gEnv->pConsole->GetCVar("r_FSAA")->GetIVal())
				{
					int samples = gEnv->pConsole->GetCVar("r_FSAA_samples")->GetIVal();
					int quality = gEnv->pConsole->GetCVar("r_FSAA_quality")->GetIVal();
					value = g_pGame->GetMenu()->GetFSAAMode(samples, quality);
				}
			}
			SaveValueToProfile(entry.name.c_str(), value);
		}
		else
		{
			ICVar *pCVAR = gEnv->pConsole->GetCVar(it->first);
			if(pCVAR)
			{
				string value(pCVAR->GetString());
				SaveValueToProfile(entry.name.c_str(), value);
			}
		}
	}
	SaveProfile();
}
Beispiel #13
0
void SaveProfCopy(CIccProfile *pIcc) 
{
  CIccProfile* pCopy = pIcc;
  SaveProfile(pCopy);
}
Beispiel #14
0
void CGame::SaveProfile( int _slot )
{
	SaveProfile(m_pProfile, _slot);
}
void FLauncherProfileManager::LoadProfiles( )
{
	TArray<FString> ProfileFileNames;

	//load and move legacy profiles
	{
		IFileManager::Get().FindFilesRecursive(ProfileFileNames, *GetLegacyProfileFolder(), TEXT("*.ulp"), true, false);
		for (TArray<FString>::TConstIterator It(ProfileFileNames); It; ++It)
		{
			FString ProfileFilePath = *It;
			FArchive* ProfileFileReader = IFileManager::Get().CreateFileReader(*ProfileFilePath);

			if (ProfileFileReader != nullptr)
			{
				ILauncherProfilePtr LoadedProfile = LoadProfile(*ProfileFileReader);
				delete ProfileFileReader;

				//re-save profile to new location
				if (LoadedProfile.IsValid())
				{
					SaveProfile(LoadedProfile.ToSharedRef());
				}

				//delete legacy profile.
				IFileManager::Get().Delete(*ProfileFilePath);				
			}
		}
	}

	//load and re-save legacy profiles
	{
		IFileManager::Get().FindFilesRecursive(ProfileFileNames, *FLauncherProfile::GetProfileFolder(), TEXT("*.ulp"), true, false);
		for (TArray<FString>::TConstIterator It(ProfileFileNames); It; ++It)
		{
			FString ProfileFilePath = *It;
			FArchive* ProfileFileReader = IFileManager::Get().CreateFileReader(*ProfileFilePath);

			if (ProfileFileReader != nullptr)
			{
				ILauncherProfilePtr LoadedProfile = LoadProfile(*ProfileFileReader);
				delete ProfileFileReader;

				//re-save profile to the new format
				if (LoadedProfile.IsValid())
				{
					if (ProfileFilePath.Contains("NotForLicensees"))
					{
						LoadedProfile->SetNotForLicensees();
					}
					SaveJSONProfile(LoadedProfile.ToSharedRef());
				}

				//delete legacy profile.
				IFileManager::Get().Delete(*ProfileFilePath);
			}
		}
	}

	ProfileFileNames.Reset();
	IFileManager::Get().FindFilesRecursive(ProfileFileNames, *FLauncherProfile::GetProfileFolder(), TEXT("*.ulp2"), true, false);
	
	for (TArray<FString>::TConstIterator It(ProfileFileNames); It; ++It)
	{
		FString ProfileFilePath = *It;
		ILauncherProfilePtr LoadedProfile = LoadJSONProfile(*ProfileFilePath);

		if (LoadedProfile.IsValid())
		{
			if (ProfileFilePath.Contains("NotForLicensees"))
			{
				LoadedProfile->SetNotForLicensees();
			}
			AddProfile(LoadedProfile.ToSharedRef());
		}
		else
		{
			IFileManager::Get().Delete(*ProfileFilePath);
		}
	}
}
Beispiel #16
0
void RemoteProfileDlg::OnButtonCancel(wxCommandEvent& WXUNUSED(event)) {
	SaveProfile();
	EndModal(wxID_CANCEL);
}
Beispiel #17
0
void RemoteProfileDlg::OnClose(wxCloseEvent& WXUNUSED(event)) {
	// Make sure any last changes to the profile is saved
	SaveProfile();
	EndModal(wxID_CANCEL);
}
Beispiel #18
0
void RemoteProfileDlg::OnButtonOpen(wxCommandEvent& WXUNUSED(event)) {
	SaveProfile();
	EndModal(wxID_OPEN);
}
Beispiel #19
0
//-----------------------------------------------------------------------------------------------------
bool COptionsManager::HandleFSCommand(const char *szCommand,const char *szArgs)
{
	
	if(!m_pPlayerProfileManager)
		return false;

	const char* user = m_pPlayerProfileManager->GetCurrentUser();
	IPlayerProfile *pProfile = m_pPlayerProfileManager->GetCurrentProfile(user);
	if(!pProfile)
		return false;

	if(!stricmp(szCommand, "SaveProfile"))
	{
		UpdateToProfile();
		SaveProfile();
		return true;
	}

	if(!stricmp(szCommand, "RestoreDefaultProfile"))
	{
		if(szArgs && szArgs[0])
			ResetDefaults(szArgs);
		else
			ResetDefaults(NULL);
		return true;
	}

	if(!stricmp(szCommand, "UpdateCVars"))
	{
		UpdateFlashOptions();
		return true;
	}

	if(!stricmp(szCommand, "hud_showAllObjectives"))
	{
		if(szArgs)
		{
			SAFE_HUD_FUNC(SetShowAllOnScreenObjectives(atoi(szArgs)?true:false));
		}
	}
	else if(!stricmp(szCommand,"hud_colorLine"))
	{
		SetCrysisProfileColor(szArgs);
	}
	else if(gEnv->bMultiplayer && !stricmp(szCommand,"g_psTutorial_Enabled"))
	{
		if(atoi(szArgs)==1)
		{
			gEnv->pConsole->ExecuteString("g_psTutorial_Reset");
		}
	}

	std::map<string,SOptionEntry>::iterator it = m_profileOptions.find(szCommand);
	if(it!=m_profileOptions.end())
	{
		ICVar *pCVAR = gEnv->pConsole->GetCVar(szCommand);
		if(pCVAR)
		{
			if(pCVAR->GetType()==1)	//int
			{
				int value = atoi(szArgs);
				pCVAR->Set(value);
			}
			else if(pCVAR->GetType()==2)	//float
			{
				float value = atof(szArgs);
				pCVAR->Set(value);
			}
			else if(pCVAR->GetType()==3)	//string
				pCVAR->Set(szArgs);
			return true; // it's a CVAR, we are done!
		}
	}
	//else //does this map to an options function? even if it is inside m_profileOptions, but not a console variable (e.g. pb_client), we want to see if it's a registered command
	{
		TOpFuncMapIt iter = m_opFuncMap.find(szCommand);
		if(iter!=m_opFuncMap.end())
		{
			(this->*(iter->second))(szArgs);
			return true;
		}
	}

	return false;
}
Beispiel #20
0
void COnlineSearch::DoSearch()
{
    CWaitCursor wait;

    // Save the infos to the profile
    SaveProfile();

#ifdef _DEBUG
    m_editRawData.Clear();
#endif

    m_lstResults.SetRedraw(FALSE);
    m_lstResults.DeleteAllItems();
    m_staticResults.SetWindowText(AfxLoadString(IDS_STRING_SEARCHRESULT));

    CString str;
    try {
        m_editHost.GetWindowText(str);
        CString port;
        m_editPort.GetWindowText(port);
        CYazConn conn(str, _ttoi(port));
        if (!conn.GetConnected()) {
            // Connection failed
            ShowError(conn.GetLastError());
        } else {
            // Connection established
            conn.SetOption(_T("implementationName"), _T("BibEdt Version ") + CAboutDlg::GetAppVersion());
            m_editUser.GetWindowText(str);
            if (!str.IsEmpty())
                conn.SetOption(_T("user"), str);
            m_editGroup.GetWindowText(str);
            if (!str.IsEmpty())
                conn.SetOption(_T("group"), str);
            m_editPass.GetWindowText(str);
            if (!str.IsEmpty())
                conn.SetOption(_T("password"), str);
            m_editProxy.GetWindowText(str);
            if (!str.IsEmpty())
                conn.SetOption(_T("proxy"), str);
            m_editDatabase.GetWindowText(str);
            if (!str.IsEmpty())
                conn.SetOption(_T("databaseName"), str);
            conn.SetOption(_T("preferredRecordSyntax"), m_RecordSyntax);
//			conn.SetOption(_T("preferredRecordSyntax"), "OPAC");

            m_editSearchFor.GetWindowText(str);

            CYazQuery* q = NULL;
            switch (GetQueryType()) {
            case QT_PREFIX:
                q = new CYazPrefixQuery();
                break;
            case QT_CQL:
                q = new CYazCQLQuery();
                break;
            case QT_CCL:
                q = new CYazCCLQuery();
                break;
            default:
                ShowError(IDS_STRING_STRANGEQUERYTYPE);
                return;
            }
            ASSERT(q);
            q->SetQueryString(str);
            CYazResultSet rs = conn.Search(q);

            m_editRecStart.GetWindowText(str);
            int recstart = _ttoi(str);
            m_editRecEnd.GetWindowText(str);
            int recend = _ttoi(str);
            int n = rs.GetCount();
            str.Format(AfxLoadString(IDS_STRING_SEARCHRESULTSNUM), n);
            m_staticResults.SetWindowText(str);
            if (recend > 0)
                n = min(n, recend);
            int ix = -1;
#ifdef _DEBUG
            CFile dbgfile;
            try {
                dbgfile.Open(COptions::AddBackslash(COptions::GetAppPath()) + _T("result.xml"), CFile::modeWrite | CFile::shareExclusive | CFile::modeCreate);
            } catch (...) {
            }
#endif
            for (int i = recstart - 1; i < n; i++) {
                CYazRecord rec = rs.GetRecord(i);
                CString rawdata = rec.GetRaw();

#ifdef _DEBUG
                try {
                    dbgfile.Write(rawdata, rawdata.GetLength());
                } catch (...) {
                }

                int selstart = m_editRawData.GetWindowTextLength();
                m_editRawData.SetSel(selstart, selstart, TRUE);
                m_editRawData.ReplaceSel(rawdata + _T("\r\n"));
#endif

                // Add the item to m_Results list
                CBibItem* item = m_Results.New();
                item->SetType(rec.GetType());
                item->Add(_T("raw"), rawdata);

                str = rec.GetValue(STR_AUTHOR);
                if (!str.IsEmpty())
                    item->Add(STR_AUTHOR, str);
                str = rec.GetValue(STR_EDITOR);
                if (!str.IsEmpty())
                    item->Add(STR_EDITOR, str);
                str = rec.GetValue(STR_TITLE);
                if (!str.IsEmpty())
                    item->Add(STR_TITLE, str);
                str = rec.GetValue(STR_EDITION);
                if (!str.IsEmpty())
                    item->Add(STR_EDITION, str);
                str = rec.GetValue(STR_SERIES);
                if (!str.IsEmpty())
                    item->Add(STR_SERIES, str);
                str = rec.GetValue(_T("Performer"));
                if (!str.IsEmpty())
                    item->Add(_T("Performer"), str);
                str = rec.GetValue(STR_YEAR);
                if (!str.IsEmpty())
                    item->Add(STR_YEAR, str);
                str = rec.GetValue(_T("ISBN"));
                if (!str.IsEmpty())
                    item->Add(_T("ISBN"), str);
                str = rec.GetValue(_T("Topic"));
                if (!str.IsEmpty())
                    item->Add(_T("Topic"), str);
                str = rec.GetValue(_T("Contents"));
                if (!str.IsEmpty())
                    item->Add(_T("Contents"), str);

                // Add it to the listview
                CField* field = item->Find(STR_AUTHOR);
                if (!field)
                    field = item->Find(STR_EDITOR);
                if (!field)
                    field = item->Find(_T("Performer"));
                if (field)
                    ix = m_lstResults.InsertItem(ix+1, field->GetValue(), -1);
                else
                    ix = m_lstResults.InsertItem(ix+1, NULL, -1);
                m_lstResults.SetItemData(ix, (DWORD)item);
                field = item->Find(STR_TITLE);
                if (field)
                    m_lstResults.SetItemText(ix, 1, field->GetValue());
                field = item->Find(STR_YEAR);
                if (field)
                    m_lstResults.SetItemText(ix, 2, field->GetValue());
            }

            delete q;

#ifdef _DEBUG
            try {
                dbgfile.Close();
            } catch (...) {
            }
#endif
        } // if (conn.GetConnected())
    } catch (...) {
        ShowError(IDS_STRING_YAZEXCEPTION);
    }
    m_lstResults.SetRedraw();
    m_staticResults.Invalidate();
}
void LevelManager::QuitToMenu(int deathCount)
{
	cocos2d::Director::getInstance()->popToRootScene();
	SaveProfile(deathCount);
}
Beispiel #22
0
int main(int argc, icChar* argv[])
{
  if (argc<=1) {
    printf("Usage: CmdIccProfLibTest profile\n");
    return -1;
  }

  
  CIccFileIO FileIO;
  if (!FileIO.Open(argv[1], "rb")) {
    printf("Unable to open '%s'\n", argv[1]);
    return -1;
  }

  CIccProfile *pIcc = new CIccProfile;

  if(!pIcc->Read(&FileIO)) {
    printf("Unable to read '%s'\n", argv[1]);
    delete pIcc;
    return -1;
  }

  bool Exit = false;
  std::string Option;

  ShowMenu();

  while(!Exit) {
    Option = GetUserInput();
    if(Option.size() >=2) {
      printf("\nInvalid Option\n");
      return -1;
    }
    
    icChar temp = Option[0];

    switch(temp) {
    case '0':
      ShowMenu();
      break;
    case '1':
      ShowHeader(pIcc);
      ShowMenu();
      break;
    case '2':
      ReadTag(pIcc);
      ShowMenu();
      break;
    case '3':
      AddTag(&FileIO,pIcc);
      ShowMenu();
      break;
    case '4':
      SaveProfile(pIcc);
      return 0;
    case '5':
      IsValidProfile(&FileIO, pIcc);
      ShowMenu();
      break;
    case '6':
      DeleteTag(&FileIO, pIcc);
      ShowMenu();
      break;
    case '7':
      SaveProfCopy(pIcc);
      ShowMenu();
      break;
    case '9':
      Exit = ConfirmExit();
      if(!Exit) ShowMenu();
      break;
    default:
      printf("\nInvalid Option\n");
      ShowMenu();      
    }
  }


  delete pIcc;
  
  return 0;
}