void CProfileOptions::FlushPendingOptionValues() { if(m_pendingOptions.empty()) return; WriteGameCfg(); std::vector<SPendingOption>::const_iterator it = m_pendingOptions.begin(); std::vector<SPendingOption>::const_iterator end = m_pendingOptions.end(); bool bResetOverscan = false; bool bIsMultiGPUEnabled = false; if(gEnv->pRenderer) gEnv->pRenderer->EF_Query(EFQ_MultiGPUEnabled, bIsMultiGPUEnabled); if (bIsMultiGPUEnabled) { bool bRequiresMGPUCfgReload = false; for(; it!=end; ++it) { const SPendingOption& option = (*it); const char* szCommandStr = option.command.c_str(); if ( (strcmp(szCommandStr, "Resolution") != 0) && (strcmp(szCommandStr, "Fullscreen") != 0) && (strcmp(szCommandStr, "VSync") != 0) && (strcmp(szCommandStr, "SysSpec") != 0)) // mgpu.cfg is automatically reloaded when cvar is changed { bRequiresMGPUCfgReload = true; } SetOptionValue(szCommandStr, option.param.c_str()); } if (bRequiresMGPUCfgReload) { GetISystem()->LoadConfiguration("mgpu.cfg"); } } else { for(; it!=end; ++it) { const SPendingOption& option = (*it); const char* szCommandStr = option.command.c_str(); if (strcmp(szCommandStr, "Stereo") == 0) { bResetOverscan = true; } SetOptionValue(option.command.c_str(), option.param.c_str()); } } stl::free_container(m_pendingOptions); if (bResetOverscan) { ResetOverscanBorders (); } }
void SimpleAppSettings::SetOptionValue(const char *name, oaOptionDataType type, const char *value) { assert(name != NULL); assert(type != OA_TYPE_INVALID); assert(value != NULL); oaValue Value; switch(type) { case OA_TYPE_INT: Value.Int = atoi(value); break; case OA_TYPE_FLOAT: Value.Float = StrToFloat(value); break; case OA_TYPE_BOOL: Value.Bool = atoi(value) ? OA_TRUE : OA_FALSE; break; case OA_TYPE_STRING: Value.String = (oaString)value; break; case OA_TYPE_ENUM: Value.Enum = (oaString)value; break; } SetOptionValue(name, type, &Value); }
/* #508936 - CSS class naming for -clean option */ Bool ParseCSS1Selector( TidyDocImpl* doc, const TidyOptionImpl* option ) { char buf[256] = {0}; uint i = 0; uint c = SkipWhite( &doc->config ); while ( i < sizeof(buf)-2 && c != EndOfStream && !IsWhite(c) ) { buf[i++] = (tmbchar) c; c = AdvanceChar( &doc->config ); } buf[i] = '\0'; if ( i == 0 || !IsCSS1Selector(buf) ) { ReportBadArgument( doc, option->name ); return no; } buf[i++] = '-'; /* Make sure any escaped Unicode is terminated */ buf[i] = 0; /* so valid class names are generated after */ /* Tidy appends last digits. */ SetOptionValue( doc, option->id, buf ); return yes; }
void CProfileOptions::SetOptionValue(const char* command, float value, bool toPendingOptions) { if (!command || !command[0]) return; string strValue; strValue.Format("%f", value); SetOptionValue(command,strValue.c_str(), toPendingOptions); }
void CProfileOptions::AddOrReplacePendingOption(const char* command, const char* param) { std::vector<SPendingOption>::iterator it = m_pendingOptions.begin(); std::vector<SPendingOption>::const_iterator end = m_pendingOptions.end(); for(; it!=end; ++it) { SPendingOption& option = (*it); if(option.command.compare(command)) continue; if(option.preview) { SetOptionValue(command, param); } if(option.original.compare(param)) { option.param = param; } else { m_pendingOptions.erase(it); } return; } COption* pOption = GetOption(command); if(pOption != NULL) { if(pOption->IsPreview()) { m_pendingOptions.push_back(SPendingOption(command, param, GetOptionValue(command), true, pOption->IsConfirmation(), pOption->IsRequiresRestart(), pOption->IsWriteToConfig())); SetOptionValue(command, param); } else { m_pendingOptions.push_back(SPendingOption(command, param, GetOptionValue(command), false, pOption->IsConfirmation(), pOption->IsRequiresRestart(), pOption->IsWriteToConfig())); } } }
void CProfileOptions::ApplyPendingOptionsValuesForConfirmation() { std::vector<SPendingOption>::const_iterator it = m_pendingOptions.begin(); std::vector<SPendingOption>::const_iterator end = m_pendingOptions.end(); for(; it!=end; ++it) { const SPendingOption& option = (*it); SetOptionValue(option.command.c_str(), option.param.c_str()); } }
void SimpleAppSettings::ReadOptionsFile(void) { TCHAR optionFile[MAX_PATH]; if(!GetExePath(optionFile)) { fprintf(stderr, "Cannot get exe path\r\n"); } strcat(optionFile, OptionsFileName); FILE *FP = fopen(optionFile, "rb"); if(!FP) return; fprintf(stderr, "simple_app: Reading options file \"%s\".\n", optionFile); fflush(stderr); char Line[1024]; int LineNum = 1; while(fgets(Line, sizeof(Line), FP) != NULL) { StripNewLine(Line); if(Line[0] == 0) continue; char *Name = strtok(Line, "\t"); char *Value = strtok(NULL, ""); if(!Name || !Value) Error("Invalid format in options file \"%s\" on line %d\n", OptionsFileName, LineNum); map<string, OptionValue>::const_iterator OptVal = OptionValueMap.find(string(Name)); if(OptVal == OptionValueMap.end()) Error("Unknown option \"%s\" defined in options file \"%s\" on line %d.", Name, OptionsFileName, LineNum); SetOptionValue(Name, OptVal->second.Type, Value); LineNum++; } fclose(FP); }
void CProfileOptions::ClearPendingOptionValuesFromConfirmation() { if(m_pendingOptions.empty()) return; std::vector<SPendingOption>::const_iterator it = m_pendingOptions.begin(); std::vector<SPendingOption>::const_iterator end = m_pendingOptions.end(); for(; it!=end; ++it) { const SPendingOption& option = (*it); SetOptionValue(option.command.c_str(), option.original.c_str()); } stl::free_container(m_pendingOptions); }
/* Coordinates Config update and Tags data */ static void DeclareUserTag( TidyDocImpl* doc, TidyOptionId optId, UserTagType tagType, ctmbstr name ) { ctmbstr prvval = cfgStr( doc, optId ); tmbstr catval = NULL; ctmbstr theval = name; if ( prvval ) { uint len = tmbstrlen(name) + tmbstrlen(prvval) + 3; catval = tmbstrndup( prvval, len ); tmbstrcat( catval, ", " ); tmbstrcat( catval, name ); theval = catval; } DefineTag( doc, tagType, name ); SetOptionValue( doc, optId, theval ); if ( catval ) MemFree( catval ); }
/* a string excluding whitespace */ Bool ParseName( TidyDocImpl* doc, const TidyOptionImpl* option ) { tmbchar buf[ 1024 ] = {0}; uint i = 0; uint c = SkipWhite( &doc->config ); while ( i < sizeof(buf)-2 && c != EndOfStream && !IsWhite(c) ) { buf[i++] = (tmbchar) c; c = AdvanceChar( &doc->config ); } buf[i] = 0; if ( i == 0 ) ReportBadArgument( doc, option->name ); else SetOptionValue( doc, option->id, buf ); return ( i > 0 ); }
Bool ParseString( TidyDocImpl* doc, const TidyOptionImpl* option ) { TidyConfigImpl* cfg = &doc->config; tmbchar buf[8192]; uint i = 0; tchar delim = 0; Bool waswhite = yes; tchar c = SkipWhite( cfg ); if ( c == '"' || c == '\'' ) { delim = c; c = AdvanceChar( cfg ); } while ( i < sizeof(buf)-2 && c != EndOfStream && c != '\r' && c != '\n' ) { if ( delim && c == delim ) break; if ( IsWhite(c) ) { if ( waswhite ) { c = AdvanceChar( cfg ); continue; } c = ' '; } else waswhite = no; buf[i++] = (tmbchar) c; c = AdvanceChar( cfg ); } buf[i] = '\0'; SetOptionValue( doc, option->id, buf ); return yes; }
void SimpleAppSettings::InitDefaultOptions(void) { oaValue Value; Value.Enum = "1024x768"; SetOptionValue("User/Resolution", OA_TYPE_ENUM, &Value); Value.Enum = "4X"; SetOptionValue("User/AA", OA_TYPE_ENUM, &Value); Value.Bool = OA_OFF; SetOptionValue("User/Sound", OA_TYPE_BOOL, &Value); Value.Int = 5; SetOptionValue("Compression Level", OA_TYPE_INT, &Value); Value.Int = 5; SetOptionValue("User/Enemy Density", OA_TYPE_INT, &Value); Value.Float = 20; SetOptionValue("Texture Quality", OA_TYPE_FLOAT, &Value); Value.Enum = "256"; SetOptionValue("Texture Size", OA_TYPE_ENUM, &Value); /////////////////////////////////////////////////////// Value.Enum = "640x480"; SetOptionValue("vid_mode", OA_TYPE_ENUM, &Value); Value.Int = 5; SetOptionValue("r__tf_aniso", OA_TYPE_INT, &Value); Value.Enum = "Low"; SetOptionValue("r2_sun_shafts", OA_TYPE_ENUM, &Value); Value.Float = 3; SetOptionValue("r2_slight_fade", OA_TYPE_FLOAT, &Value); }
void CProfileOptions::ResetOverscanBorders() { SetOptionValue("OverscanBorderX", 0.f, true); SetOptionValue("OverscanBorderY", 0.f, true); }
void Game::SetGameMode( int _mode ) { // // Reset all options to defaults for( int i = 0; i < m_options.Size(); ++i ) { GameOption *option = m_options[i]; if( strcmp(option->m_name, "GameMode") != 0 && strcmp(option->m_name, "ServerName") != 0 && strcmp(option->m_name, "ScoreMode") != 0 && strcmp(option->m_name, "MaxTeams") != 0 && strcmp(option->m_name, "MaxSpectators") ) { option->m_currentValue = option->m_default; } } m_gameMode = _mode; // // Set specific options switch( _mode ) { case GAMEMODE_STANDARD: break; case GAMEMODE_OFFICEMODE: SetOptionValue( "GameSpeed", 1 ); SetOptionValue( "SlowestSpeed", 1 ); SetOptionValue( "MaxGameRealTime", 360 ); SetOptionValue( "VictoryTimer", 60 ); break; case GAMEMODE_SPEEDDEFCON: SetOptionValue( "GameSpeed", 4 ); SetOptionValue( "MaxGameRealTime", 15 ); SetOptionValue( "SlowestSpeed", 4 ); break; case GAMEMODE_BIGWORLD: SetOptionValue( "WorldScale", 200 ); SetOptionValue( "CitiesPerTerritory", 40 ); break; case GAMEMODE_DIPLOMACY: SetOptionValue( "PermitDefection", 1 ); SetOptionValue( "RadarSharing", 1 ); SetOptionValue( "ScoreMode", 1 ); break; case GAMEMODE_TOURNAMENT: SetOptionValue( "MaxSpectators", 10 ); SetOptionValue( "SpectatorChatChannel", 0 ); SetOptionValue( "RandomTerritories", 1 ); break; } }
/* for use with Gnu Emacs */ void SetEmacsFilename( TidyDocImpl* doc, ctmbstr filename ) { SetOptionValue( doc, TidyEmacsFile, filename ); }
/* a space or comma separated list of tag names */ Bool ParseTagNames( TidyDocImpl* doc, const TidyOptionImpl* option ) { TidyConfigImpl* cfg = &doc->config; tmbchar buf[1024]; uint i = 0, nTags = 0; uint c = SkipWhite( cfg ); UserTagType ttyp = tagtype_null; switch ( option->id ) { case TidyInlineTags: ttyp = tagtype_inline; break; case TidyBlockTags: ttyp = tagtype_block; break; case TidyEmptyTags: ttyp = tagtype_empty; break; case TidyPreTags: ttyp = tagtype_pre; break; default: ReportUnknownOption( doc, option->name ); return no; } SetOptionValue( doc, option->id, NULL ); FreeDeclaredTags( doc, ttyp ); cfg->defined_tags |= ttyp; do { if (c == ' ' || c == '\t' || c == ',') { c = AdvanceChar( cfg ); continue; } if ( c == '\r' || c == '\n' ) { uint c2 = AdvanceChar( cfg ); if ( c == '\r' && c2 == '\n' ) c = AdvanceChar( cfg ); else c = c2; if ( !IsWhite(c) ) { buf[i] = 0; UngetChar( c, cfg->cfgIn ); UngetChar( '\n', cfg->cfgIn ); break; } } /* if ( c == '\n' ) { c = AdvanceChar( cfg ); if ( !IsWhite(c) ) { buf[i] = 0; UngetChar( c, cfg->cfgIn ); UngetChar( '\n', cfg->cfgIn ); break; } } */ while ( i < sizeof(buf)-2 && c != EndOfStream && !IsWhite(c) && c != ',' ) { buf[i++] = (tmbchar) c; c = AdvanceChar( cfg ); } buf[i] = '\0'; if (i == 0) /* Skip empty tag definition. Possible when */ continue; /* there is a trailing space on the line. */ /* add tag to dictionary */ DeclareUserTag( doc, option->id, ttyp, buf ); i = 0; ++nTags; } while ( c != EndOfStream ); if ( i > 0 ) DeclareUserTag( doc, option->id, ttyp, buf ); return ( nTags > 0 ); }