void QAutoGenDialog::AddParameterFromModel(const QString & strParam, const ModelParameter & modelValue, AutoGenParameter & param) { if (strParam.compare(PARAM_DEPENDS) == 0) { param.eType = AutoGenParamTypeDepends; param.strValue = modelValue.strValue; param.strAuxData = QString::null; } else if (strParam.compare(m_strIPAddressParam) == 0) { param.eType = AutoGenParamTypeIP; param.strValue = modelValue.strValue; param.strAuxData = QString::null; } else { switch (modelValue.eType & 0xF) { case ModelParameterTypeBool: param.eType = AutoGenParamTypeFixed; if ((modelValue.eType & ModelParameterFixed) == ModelParameterFixed) param.eType = (AutoGenParamType)(AutoGenParamTypeNoRandom | param.eType); param.strValue = StringToBoolean(modelValue.strValue) ? "True" : "False"; param.strAuxData = modelValue.strAuxData.isEmpty() ? "True;False" : modelValue.strAuxData; break; case ModelParameterTypeYesNo: param.eType = AutoGenParamTypeFixed; if ((modelValue.eType & ModelParameterFixed) == ModelParameterFixed) param.eType = (AutoGenParamType)(AutoGenParamTypeNoRandom | param.eType); param.strValue = StringToBoolean(modelValue.strValue) ? "Yes" : "No"; param.strAuxData = modelValue.strAuxData.isEmpty() ? "Yes;No" : modelValue.strAuxData; break; case ModelParameterTypeModel: param.eType = AutoGenParamTypeNewModel; param.strValue = NULLMODEL_NAME; param.strAuxData = modelValue.strAuxData; break; case ModelParameterTypeIP: param.eType = AutoGenParamTypeIP; param.strValue = modelValue.strValue; param.strAuxData = modelValue.strAuxData; break; default: param.eType = AutoGenParamTypeFixed; if ((modelValue.eType & ModelParameterFixed) == ModelParameterFixed) param.eType = (AutoGenParamType)(AutoGenParamTypeNoRandom | param.eType); param.strValue = modelValue.strValue; param.strAuxData = modelValue.strAuxData; break; } } }
int SimpleCommModel::Init(const std::map<QString, QString> & mapParams) { QString strValue; if (CarCommModel::Init(mapParams)) return 1; strValue = GetParam(mapParams, SIMPLECOMMMODEL_REBROADCASTINTERVAL_PARAM, SIMPLECOMMMODEL_REBROADCASTINTERVAL_PARAM_DEFAULT); m_tRebroadcastInterval = MakeTime(ValidateNumber(StringToNumber(strValue), 0., HUGE_VAL)); m_bRebroadcast = StringToBoolean(GetParam(mapParams, SIMPLECOMMMODEL_DOREBROADCAST_PARAM, SIMPLECOMMMODEL_DOREBROADCAST_PARAM_DEFAULT)); m_bGateway = StringToBoolean(GetParam(mapParams, SIMPLECOMMMODEL_MOBILEGATEWAY_PARAM, SIMPLECOMMMODEL_MOBILEGATEWAY_PARAM_DEFAULT)); m_bJitter = StringToBoolean(GetParam(mapParams, SIMPLECOMMMODEL_RBXJITTER_PARAM, SIMPLECOMMMODEL_RBXJITTER_PARAM_DEFAULT)); return 0; }
SkyboxComponent * CreateSkyboxComponent(std::vector<std::string> arguments, AssetManager * pAM) { SkyboxComponent * pSC = new SkyboxComponent; Texture2D * pTextures[6]; pTextures[0] = pAM->LoadTexture2D(arguments.at(0) + "/right.jpg"); pTextures[1] = pAM->LoadTexture2D(arguments.at(0) + "/left.jpg"); pTextures[2] = pAM->LoadTexture2D(arguments.at(0) + "/top.jpg"); pTextures[3] = pAM->LoadTexture2D(arguments.at(0) + "/bottom.jpg"); pTextures[4] = pAM->LoadTexture2D(arguments.at(0) + "/back.jpg"); pTextures[5] = pAM->LoadTexture2D(arguments.at(0) + "/front.jpg"); ShaderProgram * pSkyboxShader = pAM->LoadShader("assets/shaders/skybox"); Mesh * pSkyboxMesh = pAM->LoadMesh("assets/models/cube.cs418mesh"); pSC->Initialize(pTextures, pSkyboxShader, pSkyboxMesh); pSC->Enabled = StringToBoolean(arguments.at(1)); return pSC; }
bool CNifCopyDlg::UpdateTextures (CCsvRow* pRow) { CNifCopyInfo* pCopyInfo; CSString* pString; int Index; /* Update from all copy info records */ for (Index = 0; Index < m_CopyInfos.GetNumElements(); Index++) { pCopyInfo = m_CopyInfos.GetAt(Index); if (pCopyInfo->CsvColIndex < 0) continue; pString = pRow->GetAt(pCopyInfo->CsvColIndex); /* Change a texture record */ if (pCopyInfo->pSourceTexture != NULL) { if (pString != NULL) pCopyInfo->pSourceTexture->SetTextureName((const TCHAR *)*pString); } /* Autotint a material */ else if (pCopyInfo->pMaterialProperty != NULL) { if (pString != NULL && StringToBoolean(*pString)) pCopyInfo->pMaterialProperty->AutoTint(); } } return (true); }
void CBuildTarget::Read(const TiXmlElement *TargetRoot) { char *value = 0; if ((value = (char *)TargetRoot->Attribute("title"))) m_Title = value; TiXmlNode *_option = (TiXmlNode *)TargetRoot->FirstChild("Option"); while (0!=_option) { TiXmlElement* option = _option->ToElement(); if (0!=option) { char *value = 0; if ((value = (char *)option->Attribute("platforms"))) { ParseStr(value,';',m_Platforms); m_Platforms.RemoveEmpty(); } if ((value = (char *)option->Attribute("output"))) { m_Output = value; } if ((value = (char *)option->Attribute("prefix_auto"))) { m_AutoPrefix = StringToBoolean(value); } if ((value = (char *)option->Attribute("extension_auto"))) { m_AutoExtension = StringToBoolean(value); } if ((value = (char *)option->Attribute("working_dir"))) { m_WorkingDirectory = value; } if ((value = (char *)option->Attribute("object_output"))) { m_ObjectOutput = value; } if ((value = (char *)option->Attribute("external_deps"))) { ParseStr(value,';',m_ExternalDependencies); m_ExternalDependencies.RemoveEmpty(); } if ((value = (char *)option->Attribute("type"))) { m_Type = (CBuildTarget::TargetType)StringToInteger(value); } if ((value = (char *)option->Attribute("compiler"))) { m_Compiler = value; } if ((value = (char *)option->Attribute("projectCompilerOptionsRelation"))) { m_CompilerOptionsRelation = (CBuildTarget::OptionsRelation)StringToInteger(value); } if ((value = (char *)option->Attribute("projectLinkerOptionsRelation"))) { m_LinkerOptionsRelation = (CBuildTarget::OptionsRelation)StringToInteger(value); } if ((value = (char *)option->Attribute("projectIncludeDirsRelation"))) { m_IncludeDirectoriesRelation = (CBuildTarget::OptionsRelation)StringToInteger(value); } if ((value = (char *)option->Attribute("projectResourceIncludeDirsRelation"))) { m_ResourceIncludeDirectoriesRelation = (CBuildTarget::OptionsRelation)StringToInteger(value); } if ((value = (char *)option->Attribute("projectLibDirsRelation"))) { m_LibraryDirectoriesRelation = (CBuildTarget::OptionsRelation)StringToInteger(value); } /* if ((value = (char *)option->Attribute(""))) { = value; } */ } _option = (TiXmlNode *)TargetRoot->IterateChildren(_option); } // option TiXmlNode *_compiler = (TiXmlNode *)TargetRoot->FirstChild("Compiler"); if (0!=_compiler) { TiXmlNode *_option = (TiXmlNode *)_compiler->FirstChild("Add"); while (0!=_option) { TiXmlElement* option = _option->ToElement(); if (0!=option) { char *value = 0; if ((value = (char *)option->Attribute("option"))) { m_CompilerOptions.Insert(value); } if ((value = (char *)option->Attribute("directory"))) { m_CompilerDirectories.Insert(value); } } _option = (TiXmlNode *)_compiler->IterateChildren(_option); } // option } // compiler TiXmlNode *_res_compiler = (TiXmlNode *)TargetRoot->FirstChild("ResourceCompiler"); if (0!=_res_compiler) { TiXmlNode *_option = (TiXmlNode *)_res_compiler->FirstChild("Add"); while (0!=_option) { TiXmlElement* option = _option->ToElement(); if (0!=option) { char *value = 0; if ((value = (char *)option->Attribute("directory"))) { m_ResourceCompilerDirectories.Insert(value); } } _option = (TiXmlNode *)_res_compiler->IterateChildren(_option); } // option } // resource compiler TiXmlNode *_linker = (TiXmlNode *)TargetRoot->FirstChild("Linker"); if (0!=_linker) { TiXmlNode *_option = (TiXmlNode *)_linker->FirstChild("Add"); while (0!=_option) { TiXmlElement* option = _option->ToElement(); if (0!=option) { if (strcmp(option->Value(),"Add")) break; char *value = 0; if ((value = (char *)option->Attribute("option"))) { m_LinkerOptions.Insert(value); } if ((value = (char *)option->Attribute("directory"))) { m_LinkerDirectories.Insert(value); } if ((value = (char *)option->Attribute("library"))) { m_LinkerLibraries.Insert(value); } } _option = (TiXmlNode *)_linker->IterateChildren(_option); } // option } // linker TiXmlNode *_extra_cmd = (TiXmlNode *)TargetRoot->FirstChild("ExtraCommands"); if (0!=_extra_cmd) { TiXmlNode *_option = (TiXmlNode *)_extra_cmd->FirstChild("Add"); while (0!=_option) { TiXmlElement* option = _option->ToElement(); if (0!=option) { if (strcmp(option->Value(),"Add")) break; char *value = 0; if ((value = (char *)option->Attribute("before"))) { m_BeforeBuildCommands.Insert(value); } if ((value = (char *)option->Attribute("after"))) { m_AfterBuildCommands.Insert(value); } } _option = (TiXmlNode *)_extra_cmd->IterateChildren(_option); } // option _option = (TiXmlNode *)_extra_cmd->FirstChild("Mode"); while (0!=_option) { TiXmlElement* option = _option->ToElement(); if (0!=option) { if (strcmp(option->Value(),"Mode")) break; char *value = 0; if ((value = (char *)option->Attribute("before"))) { m_ForceBeforeBuildCommands = (strcmp(value,"always")==0); } if ((value = (char *)option->Attribute("after"))) { m_ForceAfterBuildCommands = (strcmp(value,"always")==0); } } _option = (TiXmlNode *)_extra_cmd->IterateChildren(_option); } // option } // extra commands // decorate target name { m_MFName = MakefileFriendly(m_Title); m_UCName = UpperCase(m_MFName); m_LCName = LowerCase(m_MFName); m_ObjectOutput = RemoveTrailingPathDelimiter(m_ObjectOutput); } }
int CarModel::Init(const std::map<QString, QString> & mapParams) { QString strValue; MapCarObject * pObject; Model * pModel; if (Model::Init(mapParams)) return 1; strValue = GetParam(mapParams, CARMODEL_PARAM_DELAY, CARMODEL_PARAM_DELAY_DEFAULT); m_tDelay = MakeTime(ValidateNumber(StringToNumber(strValue), 0., HUGE_VAL)); strValue = GetParam(mapParams, CARMODEL_PARAM_CARIP, CARMODEL_PARAM_CARIP_DEFAULT); if (!StringToIPAddress(strValue, m_ipCar)) return 2; strValue = GetParam(mapParams, CARMODEL_PARAM_LOGCAR, CARMODEL_PARAM_LOGCAR_DEFAULT); m_bLogThisCar = StringToBoolean(strValue); strValue = GetParam(mapParams, CARMODEL_LINK_PARAM, CARMODEL_LINK_PARAM_DEFAULT); if (!g_pSimulator->m_ModelMgr.GetModel(strValue, pModel)) return 5; m_pLinkModel = (CarLinkModel *)pModel; if (m_pLinkModel != NULL) m_pLinkModel->SetCar(m_ipCar); strValue = GetParam(mapParams, CARMODEL_PHYS_PARAM, CARMODEL_PHYS_PARAM_DEFAULT); if (!g_pSimulator->m_ModelMgr.GetModel(strValue, pModel)) return 6; m_pPhysModel = (CarPhysModel *)pModel; if (m_pPhysModel != NULL) m_pPhysModel->SetCar(m_ipCar); strValue = GetParam(mapParams, CARMODEL_COMM_PARAM, CARMODEL_COMM_PARAM_DEFAULT); if (!g_pSimulator->m_ModelMgr.GetModel(strValue, pModel)) return 4; m_pCommModel = (CarCommModel *)pModel; if (m_pCommModel != NULL) m_pCommModel->SetCar(m_ipCar); strValue = GetParam(mapParams, CARMODEL_TRACKSPEED_PARAM, CARMODEL_TRACKSPEED_PARAM_DEFAULT); m_bTrackSpeed = StringToBoolean(strValue); pObject = new MapCarObject(this); //HACK: set color based on ip group in_addr_t temp = pObject->m_pCar->GetIPAddress(); temp = temp>>8 & 0xFF; if(temp == 100) //red ones { QColor * redColor = new QColor(0xFF, 0x00, 0x00); pObject->SetColor(redColor->rgb()); } else if(temp == 200) //black ones { QColor * redColor = new QColor(0x00, 0x00, 0x00); pObject->SetColor(redColor->rgb()); } else //the others { pObject->SetColor(g_pMapObjects->GetColor()); } //end HACK m_iMapObjectID = g_pMapObjects->add(pObject); if (m_iMapObjectID == -1) delete pObject; g_pCarRegistry->addCar(this); m_iNextSeqNumber = 0; m_iNextRXSeqNumber = 0; return 0; }
bool CStringVariable::GetBoolean(void) const { return StringToBoolean(m_Value); }
void CBooleanVariable::SetString(const CString& Value) { m_Value = StringToBoolean(Value); }