/** 解析*.effect文件 */ void VEffectManager::_parseEffectFile(Ogre::DataStreamPtr &stream) { Ogre::String line; VEffect *effect = VNULL; Ogre::StringVector vecparams; while (!stream->eof()) { line = stream->getLine(); ++mParsingLineNumber; if (!(line.empty() || line.substr(0, 2) == "//")) { // 只要不是空行或者注释 if (VNULL == effect) { // 一个新特效 vecparams = Ogre::StringUtil::split(line, "\t "); if (vecparams[0] != "effect" || vecparams.size() != 2) { _logErrorInfo("Bad effect system name line", line, "VEffectManager::_parseEffectFile"); return; } // 创建空的effect effect = _createEffectTemplate(vecparams[1]); _skipToNextOpenBrace(stream); } else { if (line == "}") { // 完整的解析一个特效 effect = VNULL; } else if (line.substr(0, 7) == "element") { // 一个新的特效元素 vecparams = Ogre::StringUtil::split(line, "\t "); if (vecparams.size() < 2) { _logErrorInfo("Bad effect system element line", line, "VEffectManager::_parseEffectFile"); return; } _skipToNextOpenBrace(stream); // 解析特效元素的参数 _parseElement(vecparams[1], stream, effect); } else { // 解析特效自己的参数 _parseEffectAttrib(line, effect); } } } } }
void WeaponSelectorDialog::OnInitDialog(wxInitDialogEvent &e) { wxDialog::OnInitDialog(e); wxSizer* sizer = WeaponSelector(this, true, true); if (false == mInitDialog) { // 读取武器表 mWeaponData = new FairyConfig("../EditorConfigFiles/Weapon.cfg"); // 根据武器表建立武器树 mWeaponTree = wxDynamicCast(this->FindWindow(ID_TREECTRL_WEAPON), wxTreeCtrl); mWeaponTree->Freeze(); mWeaponTree->DeleteAllItems(); wxTreeItemId rootId = mWeaponTree->AddRoot(_("Weapons")); if (mWeaponData) { // 配置weapon tree int sectionCount = mWeaponData->startGetSections(); for (int i=0; i<sectionCount; ++i) { const Ogre::String& sectionName = mWeaponData->getNextSection(); wxTreeItemId sectionId = mWeaponTree->AppendItem(rootId, sectionName.c_str()); Ogre::StringVector valueList = mWeaponData->getList(sectionName, "Combo", ","); for (size_t j=0; j<valueList.size(); ++j) { mWeaponTree->AppendItem(sectionId, valueList[j].c_str()); } } mWeaponTree->Thaw(); mWeaponTree->UnselectAll(); mWeaponTree->Expand( mWeaponTree->GetRootItem() ); } // 显示特效列表 mWeaponEffectList = wxDynamicCast(this->FindWindow(ID_LISTBOX_WEAPON_EFFECT), wxListBox); Fairy::EffectManager::EffectTemplateIterator it = Fairy::EffectManager::getSingleton().getEffectTemplateIterator(); while ( it.hasMoreElements() ) { mWeaponEffectList->AppendString(it.peekNextKey().c_str()); it.moveNext(); } mColourButton = wxDynamicCast(this->FindWindow(ID_BUTTON_WEAPON_EFFECT_COLOUR), wxButton); mColourText = wxDynamicCast(this->FindWindow(ID_TEXTCTRL_COLOUR_TEXT), wxTextCtrl); mAlphaTextCtrl = wxDynamicCast(this->FindWindow(ID_TEXTCTRL_ALPHA), wxTextCtrl); mInitDialog = true; } // mWeaponEffectList->Refresh(); unsigned char r, g, b; FColourToIColour(mCurrentColour.r, mCurrentColour.g, mCurrentColour.b, r, g, b); mColourButton->SetBackgroundColour(wxColour(r,g,b)); setColourText(); setAlphaText(); }
void Terrain::loadResource(Ogre::Resource* resource) { const Ogre::String& name = resource->getName(); if (name.find("<Lightmap>") !=Ogre::String::npos) { Ogre::String::size_type left_parentheses = name.find_first_of('('); Ogre::String::size_type right_parentheses = name.find_last_of(')'); if (left_parentheses ==Ogre::String::npos || right_parentheses ==Ogre::String::npos) { OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR, "Unorganised lightmap texture name '" + name + "'", "Terrain::loadResource"); } Ogre::StringVector vec = Ogre::StringUtil::split( name.substr(left_parentheses + 1, right_parentheses - left_parentheses - 1), ",", 2); if (vec.size() != 2) { OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR, "Unorganised lightmap texture name '" + name + "'", "Terrain::loadResource"); } int nPosX = Ogre::StringConverter::parseInt(vec[0]); int nPosZ = Ogre::StringConverter::parseInt(vec[1]); if (nPosX < 0 || nPosX >= mData->mNumTilePerX || nPosZ < 0 || nPosZ >= mData->mNumTilePerZ) { OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR, "Unorganised lightmap texture name '" + name + "'", "Terrain::loadResource"); } Ogre::uint uWidth, uHeight; if (getLightmapQuality() == LMQ_LOW) { uWidth = mData->mTileSize * 2; uHeight = mData->mTileSize * 2; } else { uWidth = mData->mTileSize * 8; uHeight = mData->mTileSize * 8; } Ogre::Texture* pTexture = static_cast<Ogre::Texture*>(resource); if (pTexture->getWidth() != uWidth || pTexture->getHeight() != uHeight) { pTexture->freeInternalResources(); pTexture->setWidth(uWidth); pTexture->setHeight(uHeight); } pTexture->createInternalResources(); Ogre::HardwarePixelBufferSharedPtr bufferPtr = pTexture->getBuffer(); size_t l = nPosX * mData->mTileSize * 8; size_t t = nPosZ * mData->mTileSize * 8; size_t r = l + mData->mTileSize * 8; size_t b = t + mData->mTileSize * 8; if (r > mData->mLightmapImage->getWidth()) r = mData->mLightmapImage->getWidth(); if (b > mData->mLightmapImage->getHeight()) b = mData->mLightmapImage->getHeight(); bufferPtr->blitFromMemory( mData->mLightmapImage->getPixelBox().getSubVolume(Ogre::Box(l, t, r, b))); } else { for (AtlasArray::const_iterator it = mAtlases.begin(); it != mAtlases.end(); ++it) { if (it->texture.get() == resource) { assert(!it->image.isNull()); it->texture->loadImage(*it->image); break; } } } }
size_t CLASS::SearchCompare(Ogre::String searchString, CacheEntry *ce) { if (searchString.find(":") == Ogre::String::npos) { // normal search // the name Ogre::String dname_lower = ce->dname; Ogre::StringUtil::toLowerCase(dname_lower); if (dname_lower.find(searchString) != Ogre::String::npos) return dname_lower.find(searchString); // the filename Ogre::String fname_lower = ce->fname; Ogre::StringUtil::toLowerCase(fname_lower); if (fname_lower.find(searchString) != Ogre::String::npos) return 100 + fname_lower.find(searchString); // the description Ogre::String desc = ce->description; Ogre::StringUtil::toLowerCase(desc); if (desc.find(searchString) != Ogre::String::npos) return 200 + desc.find(searchString); // the authors if (!ce->authors.empty()) { std::vector<AuthorInfo>::const_iterator it; for (it = ce->authors.begin(); it != ce->authors.end(); it++) { // author name Ogre::String aname = it->name; Ogre::StringUtil::toLowerCase(aname); if (aname.find(searchString) != Ogre::String::npos) return 300 + aname.find(searchString); // author email Ogre::String aemail = it->email; Ogre::StringUtil::toLowerCase(aemail); if (aemail.find(searchString) != Ogre::String::npos) return 400 + aemail.find(searchString); } } return Ogre::String::npos; } else { Ogre::StringVector v = Ogre::StringUtil::split(searchString, ":"); if (v.size() < 2) return Ogre::String::npos; //invalid syntax if (v[0] == "hash") { Ogre::String hash = ce->hash; Ogre::StringUtil::toLowerCase(hash); return hash.find(v[1]); } else if (v[0] == "guid") { Ogre::String guid = ce->guid; Ogre::StringUtil::toLowerCase(guid); return guid.find(v[1]); } else if (v[0] == "author") { // the authors if (!ce->authors.empty()) { std::vector<AuthorInfo>::const_iterator it; for (it = ce->authors.begin(); it != ce->authors.end(); it++) { // author name Ogre::String aname = it->name; Ogre::StringUtil::toLowerCase(aname); if (aname.find(v[1]) != Ogre::String::npos) return aname.find(v[1]); // author email Ogre::String aemail = it->email; Ogre::StringUtil::toLowerCase(aemail); if (aemail.find(v[1]) != Ogre::String::npos) return aemail.find(v[1]); } } return Ogre::String::npos; } else if (v[0] == "wheels") { Ogre::String wheelsStr = TOUTFSTRING(ce->wheelcount) + "x" + TOUTFSTRING(ce->propwheelcount); return wheelsStr.find(v[1]); } else if (v[0] == "file") { Ogre::String fn = ce->fname; Ogre::StringUtil::toLowerCase(fn); return fn.find(v[1]); } } return Ogre::String::npos; }
//------------------------------------------------------------------------------------- void BaseApplication::createFrameListener(void) { Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***"); OIS::ParamList pl; size_t windowHnd = 0; std::ostringstream windowHndStr; mWindow->getCustomAttribute("WINDOW", &windowHnd); windowHndStr << windowHnd; pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); mInputManager = OIS::InputManager::createInputSystem( pl ); mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, true )); mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, true )); mMouse->setEventCallback(this); mKeyboard->setEventCallback(this); //Set initial mouse clipping size windowResized(mWindow); //Register as a Window listener Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this); mTrayMgr = new OgreBites::SdkTrayManager("InterfaceName", mWindow, mMouse, this); //mTrayMgr->showFrameStats(OgreBites::TL_BOTTOMLEFT); //mTrayMgr->showLogo(OgreBites::TL_BOTTOMRIGHT); Button_All[0] = mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"Start","Start",200); Button_All[1] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"About","About",200); Button_All[2] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"Exit","Exit",200); Button_All[3] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"Back_toMain","Back",200); Button_All[4] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"Unlimit","Unlimit",200); Button_All[5] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"TimeLimit","TimeLimit",200); Button_All[6] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"Collect","Collect",200); Button_All[7] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"Restart","Restart",200); Button_All[8] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"Exit_toMain","Exit",200); Button_All[9] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"Resume_Game","Resume Game",200); Button_All[10] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"TimeLimit_Most","Collect Most",200); Button_All[11] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"TimeLimit_Collect","Collect in time",200); Button_All[12] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"TimeLimit_state_1","State1",200); Button_All[13] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"TimeLimit_state_2","State2",200); Button_All[14] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"TimeLimit_state_3","State3",200); Button_All[15] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"TimeLimit_state_4","State4",200); Button_All[16] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"TimeLimit_state_5","State5",200); Button_All[17] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"Collect_state_1","State1",200); Button_All[18] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"Collect_state_2","State2",200); Button_All[19] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"Collect_state_3","State3",200); Button_All[20] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"Collect_state_4","State4",200); Button_All[21] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"Collect_state_5","State5",200); Button_All[22] =mTrayMgr->createButton(OgreBites::TL_BOTTOMLEFT,"AI_type","AI type",200); mTrayMgr->removeWidgetFromTray("Back_toMain"); mTrayMgr->removeWidgetFromTray("Unlimit"); mTrayMgr->removeWidgetFromTray("TimeLimit"); mTrayMgr->removeWidgetFromTray("Collect"); mTrayMgr->removeWidgetFromTray("Restart"); mTrayMgr->removeWidgetFromTray("Exit_toMain"); mTrayMgr->removeWidgetFromTray("Resume_Game"); mTrayMgr->removeWidgetFromTray("TimeLimit_Most"); mTrayMgr->removeWidgetFromTray("TimeLimit_Collect"); mTrayMgr->removeWidgetFromTray("TimeLimit_state_1"); mTrayMgr->removeWidgetFromTray("TimeLimit_state_2"); mTrayMgr->removeWidgetFromTray("TimeLimit_state_3"); mTrayMgr->removeWidgetFromTray("TimeLimit_state_4"); mTrayMgr->removeWidgetFromTray("TimeLimit_state_5"); mTrayMgr->removeWidgetFromTray("Collect_state_1"); mTrayMgr->removeWidgetFromTray("Collect_state_2"); mTrayMgr->removeWidgetFromTray("Collect_state_3"); mTrayMgr->removeWidgetFromTray("Collect_state_4"); mTrayMgr->removeWidgetFromTray("Collect_state_5"); mTrayMgr->removeWidgetFromTray("AI_type"); for(int i=3;i<23;i++){ Button_All[i]->hide(); } About_Text = mTrayMgr->createTextBox(OgreBites::TL_TOPLEFT,"About_Textbox","About",250,208); Time_Show = mTrayMgr->createLabel(OgreBites::TL_TOPLEFT,"Time_Show_Label","Time",240); Time_Value_Show = mTrayMgr->createLabel(OgreBites::TL_TOPLEFT,"Time_Value_Label","",240); Score_Show = mTrayMgr->createLabel(OgreBites::TL_TOPLEFT,"Score_Show_Label","Score",240); Score_Value_Show = mTrayMgr->createLabel(OgreBites::TL_TOPLEFT,"Score_Value_Label","",240); mTrayMgr->removeWidgetFromTray("About_Textbox"); mTrayMgr->removeWidgetFromTray("Time_Show_Label"); mTrayMgr->removeWidgetFromTray("Time_Value_Label"); mTrayMgr->removeWidgetFromTray("Score_Show_Label"); mTrayMgr->removeWidgetFromTray("Score_Value_Label"); About_Text->hide(); Time_Show->hide(); Time_Value_Show->hide(); Score_Show->hide(); Score_Value_Show->hide(); //mTrayMgr->hideCursor(); // create a params panel for displaying sample details Ogre::StringVector items; items.push_back("cam.pX"); items.push_back("cam.pY"); items.push_back("cam.pZ"); items.push_back(""); items.push_back("cam.oW"); items.push_back("cam.oX"); items.push_back("cam.oY"); items.push_back("cam.oZ"); items.push_back(""); items.push_back("Filtering"); items.push_back("Poly Mode"); mDetailsPanel = mTrayMgr->createParamsPanel(OgreBites::TL_NONE, "DetailsPanel", 200, items); mDetailsPanel->setParamValue(9, "Bilinear"); mDetailsPanel->setParamValue(10, "Solid"); mDetailsPanel->hide(); mRoot->addFrameListener(this); }
void SaveAsSkillDialog::OnInitDialog(wxInitDialogEvent &e) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); wxBoxSizer* bSizer13; bSizer13 = new wxBoxSizer( wxVERTICAL ); wxFlexGridSizer* fgSizer4; fgSizer4 = new wxFlexGridSizer( 2, 2, 0, 0 ); fgSizer4->SetFlexibleDirection( wxBOTH ); fgSizer4->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); wxStaticText* staticText1 = new wxStaticText( this, wxID_ANY, wxT("脚本文件:"), wxDefaultPosition, wxSize( 60,-1 ), 0 ); fgSizer4->Add( staticText1, 0, wxALL, 5 ); mComboBox = new wxComboBox( this, wxID_ANY,wxEmptyString, wxDefaultPosition, wxSize( 200,-1 ), 0, NULL, 0 ); fgSizer4->Add( mComboBox, 0, wxALL, 5 ); wxStaticText* staticText2 = new wxStaticText( this, wxID_ANY, wxT("模板名称:"), wxDefaultPosition, wxDefaultSize, 0 ); staticText2->SetMinSize( wxSize( 60,-1 ) ); fgSizer4->Add( staticText2, 0, wxALL, 5 ); mTextCtrl = new wxTextCtrl( this, wxID_ANY,wxT(""), wxDefaultPosition, wxSize( 200,-1 ), 0 ); fgSizer4->Add( mTextCtrl, 0, wxALL, 5 ); bSizer13->Add( fgSizer4, 1, wxEXPAND, 5 ); wxStdDialogButtonSizer* m_sdbSizer5 = new wxStdDialogButtonSizer(); wxButton* m_sdbSizer5OK = new wxButton( this, wxID_OK ); m_sdbSizer5->AddButton( m_sdbSizer5OK ); wxButton* m_sdbSizer5Cancel = new wxButton( this, wxID_CANCEL ); m_sdbSizer5->AddButton( m_sdbSizer5Cancel ); m_sdbSizer5->Realize(); bSizer13->Add( m_sdbSizer5, 1, wxEXPAND, 5 ); this->SetSizer( bSizer13 ); this->Layout(); Ogre::StringVector loadedScripts; Fairy::EffectManager::getSingleton().getLoadedSkillScripts( loadedScripts ); for ( size_t i=0; i<loadedScripts.size(); ++i ) { if (loadedScripts[i] != "EmptySkill.skill") mComboBox->AppendString(loadedScripts[i]); } // 若曾保存过,则显示上次保存的文件名 SkillObjectEditor* pSkillObjectEditor = static_cast<SkillObjectEditor*>(mParent); if (!pSkillObjectEditor->getSaveFileName().empty()) { Ogre::String fileName = Fairy::EffectManager::getSingleton().getFileNameBySkillTemplateName(mSkill->getSkillName()); if ( fileName == "EmptySkill.skill" ) mComboBox->SetSelection(0); else mComboBox->SetValue(fileName); } }
void SkillObjectEditor::OnSaveAsSkillObject(wxCommandEvent &e) { if (NULL == mSkill) { wxMessageBox("您还没有创建技能,请创建后重试!","提示"); return; } SaveAsSkillDialog *dlg = new SaveAsSkillDialog(this, wxID_ANY, _("另存技能"), mSkill); bool ok = (dlg->ShowModal() == wxID_OK); if(ok) { Ogre::StringVector templates; Ogre::String fileName = dlg->mComboBox->GetValue().c_str(); Ogre::String templateName = dlg->mTextCtrl->GetValue().c_str(); if(templateName.length() == 0) { dlg->Destroy(); return; } //判断文件名 Ogre::StringVector strings = Ogre::StringUtil::split( fileName, "." ); if (strings.size() != 2 || strings[1] != "skill") { fileName.append(".skill"); } Fairy::EffectManager::getSingleton().getSkillTemplatesFromScriptFile(fileName, templates); std::ofstream outFile; Ogre::String pathFileName = EFFECT_PATH+fileName; outFile.open ( pathFileName.c_str(), std::ios::out | std::ios::trunc ); // append to file if (!outFile.is_open()) { dlg->Destroy(); return; } bool newTemplate = true; // 把所有的模板都写入该文件中 for ( size_t i=0; i<templates.size(); ++i ) { // if (templates[i] != mEffect->getTemplateName()) ///{ Fairy::Skill *skill = Fairy::EffectManager::getSingleton().getSkill(templates[i]); assert (skill); if (skill->getSkillName() == dlg->mTextCtrl->GetValue().c_str()) { saveSkill(mSkill, dlg->mTextCtrl->GetValue().c_str(), outFile ); newTemplate = false; } else saveSkill(skill, skill->getSkillName(), outFile); } if (newTemplate) { // 刷新EffectManager中的模板内容 Fairy::Skill *skill = Fairy::EffectManager::getSingleton().getSkill(templateName); if (NULL == skill) { skill = Fairy::EffectManager::getSingleton().createSkillTemplate(templateName); } *skill = *mSkill; saveSkill(skill, templateName, outFile ); Fairy::EffectManager::getSingleton().addToSkillTemplateScriptFileMap(templateName, fileName); InitSkillEditor(skill, templateName); } outFile.close(); } wxBusyInfo* busyInfo = new wxBusyInfo(wxT("更新技能数据 ..."), this); m_Frame->GetSkillSelector()->Reload(); delete busyInfo; dlg->Destroy(); }
void OgreConsole::onKeyPressed(const OIS::KeyEvent &arg) { if(!mIsVisible) return; if (arg.key == OIS::KC_RETURN || arg.key == OIS::KC_NUMPADENTER) { print("%3> " + prompt + "%R"); //split the parameter list Ogre::StringVector params = Ogre::StringUtil::split(prompt, " "); if (params.size()) { std::map<Ogre::String, OgreConsoleFunctionPtr>::iterator i; for(i=commands.begin();i!=commands.end();i++){ if((*i).first==params[0]){ if((*i).second) (*i).second(params); break; } } prompt.clear(); mUpdateConsole = true; mUpdatePrompt = true; } } else if (arg.key == OIS::KC_BACK) { if (prompt.size()) { prompt.erase(prompt.end() - 1); //=prompt.substr(0,prompt.length()-1); mUpdatePrompt = true; } } else if (arg.key == OIS::KC_PGUP) { if(mStartline>0) mStartline--; mUpdateConsole = true; } else if (arg.key == OIS::KC_PGDOWN) { if(mStartline<lines.size()) mStartline++; mUpdateConsole = true; } else { for(unsigned int c=0;c<sizeof(legalchars);c++){ if(legalchars[c]==arg.text){ prompt+=arg.text; break; } } mUpdatePrompt = true; } }
//----------------------------------------------------------------------------------------- void CPGInstanceManager::_onLoad() { Ogre::String filename; if(mTempModified->get()) { if(mTempFileName.empty()) mTempFileName = OgitorsUtils::QualifyPath(mOgitorsRoot->GetProjectOptions()->ProjectDir + "/Temp/tmp" + Ogre::StringConverter::toString(mObjectID->get()) + ".instance"); filename = mTempFileName; } else { Ogre::String name = mName->get(); std::replace(name.begin(), name.end(), '<', ' '); std::replace(name.begin(), name.end(), '>', ' '); std::replace(name.begin(), name.end(), '#', ' '); name = Ogre::StringConverter::toString(mObjectID->get()) + "_" + name; filename = OgitorsUtils::QualifyPath(mOgitorsRoot->GetProjectOptions()->ProjectDir + "/PGInstances/" + name + ".instance"); } std::ifstream stream(filename.c_str()); if(!stream.is_open()) return; if(!mTempModified->get()) mLastFileName = filename; Ogre::StringVector list; char res[128]; while(!stream.eof()) { stream.getline(res, 128); Ogre::String resStr(res); OgitorsUtils::ParseStringVector(resStr, list); if(list.size() == 3) { PGInstanceInfo info; info.pos = Ogre::StringConverter::parseVector3(list[0]); info.scale = Ogre::StringConverter::parseReal(list[1]); info.yaw = Ogre::StringConverter::parseReal(list[2]); mInstanceList[mNextInstanceIndex++] = info; } else if(list.size() == 4) { PGInstanceInfo info; int index = Ogre::StringConverter::parseInt(list[0]); info.pos = Ogre::StringConverter::parseVector3(list[1]); info.scale = Ogre::StringConverter::parseReal(list[2]); info.yaw = Ogre::StringConverter::parseReal(list[3]); info.instance = 0; mInstanceList[index] = info; if(index >= mNextInstanceIndex) mNextInstanceIndex = index + 1; } } stream.close(); }
void TutorialApplication::createFrameListener(void) { BaseApplication::createFrameListener(); // create a params panel for displaying sample details Ogre::StringVector items; // items.push_back("Filtering"); // items.push_back("Poly Mode"); mStatusPanel = mTrayMgr->createParamsPanel(OgreBites::TL_BOTTOMRIGHT, "Params", 300, items); OgreBites::Slider* slider = NULL; mTrayMgr->createButton(OgreBites::TL_BOTTOMRIGHT, "Reset pose", "Reset pose"); mTrayMgr->createButton(OgreBites::TL_BOTTOMRIGHT, "Reload controller", "Reload controller"); mTrayMgr->createButton(OgreBites::TL_BOTTOMRIGHT, "Go to pose", "Go to pose"); // animations control slider = mTrayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "Gravity X", "Gravity X", 400, 150, 50, -9.8, 9.8, 149 ); slider->setValue(0); slider = mTrayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "Gravity Y", "Gravity Y", 400, 150, 50, -9.8, 9.8, 149 ); slider->setValue(0.0f); slider = mTrayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "Gravity Z", "Gravity Z", 400, 150, 50, -9.8, 9.8, 149 ); slider->setValue(0.0f); slider = mTrayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "Time multiplier", "Time multiplier", 400, 150, 50, 0, 1, 1000 ); slider->setValue(DEFAULT_TIME_MULTIPLIER); slider = mTrayMgr->createLongSlider(OgreBites::TL_TOPLEFT, "Animation speed", "Animation speed", 400, 150, 50, 0, 2, 1000 ); slider->setValue(DEFAULT_ANIMATION_SPEED); // animation selector int defaultAnimationIndex = 0; Ogre::SkeletonInstance* skel = mFigureEnt->getSkeleton(); Ogre::StringVector animationNames; animationNames.push_back("<none>"); if ( skel ) { std::cout << "got skeleton" << std::endl; for ( int i=0; i<skel->getNumAnimations(); i++ ) { std::string name = skel->getAnimation(i)->getName(); std::cout << " animation: " << name << std::endl; if ( /*i<5 || name == "WalkNew"*/true ) { animationNames.push_back(name); if ( name == DEFAULT_ANIMATION ) { defaultAnimationIndex = i; } } } //mFigureEnt->setDisplaySkeleton(true); } else { std::cout << "no skeleton" << std::endl; } mAnimationSelectMenu = mTrayMgr->createThickSelectMenu( OgreBites::TL_TOPLEFT, "Animation", "Animation", 400, animationNames.size()); if ( animationNames.size() ) { mAnimationSelectMenu->setItems(animationNames); mAnimationSelectMenu->selectItem(defaultAnimationIndex); } static const int debugDrawStyleCount = 8; OgreBites::SelectMenu* select = mTrayMgr->createThickSelectMenu( OgreBites::TL_BOTTOMRIGHT, "Debug draw", "Debug draw", 400, debugDrawStyleCount ); Ogre::StringVector debugDrawStates; const char* debugDrawStateNames[debugDrawStyleCount] = { "None", "Nodes", "Links", "Faces", "FaceAnchors", "Tetras", "TetraForces", "BadTetras" }; for ( int i=0; i<debugDrawStyleCount; i++ ) { debugDrawStates.push_back(debugDrawStateNames[i]); } select->setItems(debugDrawStates); select->selectItem(0); showControls(false); }
void CLASS::UpdateControls() { int valuecounter = 0; // Going to be usefull for selections //Lang (Still not done) if (!IsLoaded) { m_lang->addItem("English (U.S.)"); } m_lang->setIndexSelected(0); //TODO if (!IsLoaded) { m_gearbox_mode->addItem("Automatic shift"); m_gearbox_mode->addItem("Manual shift - Auto clutch"); m_gearbox_mode->addItem("Fully Manual: sequential shift"); m_gearbox_mode->addItem("Fully Manual: stick shift"); m_gearbox_mode->addItem("Fully Manual: stick shift with ranges"); } //Gearbox Ogre::String gearbox_mode = GameSettingsMap["GearboxMode"]; if (gearbox_mode == "Manual shift - Auto clutch") m_gearbox_mode->setIndexSelected(1); else if (gearbox_mode == "Fully Manual: sequential shift") m_gearbox_mode->setIndexSelected(2); else if (gearbox_mode == "Fully Manual: stick shift") m_gearbox_mode->setIndexSelected(3); else if (gearbox_mode == "Fully Manual: stick shift with ranges") m_gearbox_mode->setIndexSelected(4); else m_gearbox_mode->setIndexSelected(0); Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem(); // add all rendersystems to the list if (m_render_sys->getItemCount() == 0) { const Ogre::RenderSystemList list = Application::GetOgreSubsystem()->GetOgreRoot()->getAvailableRenderers(); int selection = 0; for (Ogre::RenderSystemList::const_iterator it = list.begin(); it != list.end(); it++, valuecounter++) { if (rs && rs->getName() == (*it)->getName()) { ExOgreSettingsMap["Render System"] = rs->getName(); selection = valuecounter; } else if (!rs) { LOG("Error: No Ogre Render System found"); } if (!IsLoaded) { m_render_sys->addItem(Ogre::String((*it)->getName())); } } m_render_sys->setIndexSelected(selection); } Ogre::ConfigFile cfg; cfg.load(SSETTING("ogre.cfg", "ogre.cfg")); //Few GameSettingsMap Ogre::String bFullScreen = cfg.getSetting("Full Screen", rs->getName()); if (bFullScreen == "Yes") { ExOgreSettingsMap["Full Screen"] = "Yes"; m_fullscreen->setStateCheck(true); } else { ExOgreSettingsMap["Full Screen"] = "No"; m_fullscreen->setStateCheck(false); } Ogre::String bVsync = cfg.getSetting("VSync", rs->getName()); if (bVsync == "Yes") { ExOgreSettingsMap["VSync"] = "Yes"; m_vsync->setStateCheck(true); } else { ExOgreSettingsMap["VSync"] = "No"; m_vsync->setStateCheck(false); } // store available rendering devices and available resolutions Ogre::ConfigOptionMap& CurrentRendererOptions = rs->getConfigOptions(); Ogre::ConfigOptionMap::iterator configItr = CurrentRendererOptions.begin(); Ogre::StringVector mFoundResolutions; Ogre::StringVector mFoundFSAA; while (configItr != CurrentRendererOptions.end()) { if ((configItr)->first == "Video Mode") { // Store Available Resolutions mFoundResolutions = ((configItr)->second.possibleValues); } if ((configItr)->first == "FSAA") { // Store Available Resolutions mFoundFSAA = ((configItr)->second.possibleValues); } configItr++; } //Loop thru the vector for the resolutions valuecounter = 0; //Back to default Ogre::StringVector::iterator iterRes = mFoundResolutions.begin(); for (; iterRes != mFoundResolutions.end(); iterRes++) { if (!IsLoaded) { m_resolution->addItem(Ogre::String((iterRes)->c_str())); } if ((iterRes)->c_str() == cfg.getSetting("Video Mode", rs->getName())) { ExOgreSettingsMap["Video Mode"] = (iterRes)->c_str(); m_resolution->setIndexSelected(valuecounter); } valuecounter++; } //Loop thru the vector for the FSAAs valuecounter = 0; //Back to default Ogre::StringVector::iterator iterFSAA = mFoundFSAA.begin(); for (; iterFSAA != mFoundFSAA.end(); iterFSAA++) { if (!IsLoaded) { m_fsaa->addItem(Ogre::String((iterFSAA)->c_str())); } if ((iterFSAA)->c_str() == cfg.getSetting("FSAA", rs->getName())) { ExOgreSettingsMap["FSAA"] = (iterFSAA)->c_str(); m_fsaa->setIndexSelected(valuecounter); } valuecounter++; } //Few GameSettingsMap if (GameSettingsMap["ArcadeControls"] == "Yes") m_arc_mode->setStateCheck(true); else m_arc_mode->setStateCheck(false); if (GameSettingsMap["External Camera Mode"] == "Static") m_d_cam_pitch->setStateCheck(true); else m_d_cam_pitch->setStateCheck(false); if (GameSettingsMap["Creak Sound"] == "No") m_d_creak_sound->setStateCheck(true); else m_d_creak_sound->setStateCheck(false); //Fov m_fovexternal->setCaption(GameSettingsMap["FOV External"]); m_fovinternal->setCaption(GameSettingsMap["FOV Internal"]); //Texture Filtering Ogre::String texfilter = GameSettingsMap["Texture Filtering"]; if (texfilter == "Bilinear") m_tex_filter->setIndexSelected(1); else if (texfilter == "Trilinear") m_tex_filter->setIndexSelected(2); else if (texfilter == "Anisotropic (best looking)") m_tex_filter->setIndexSelected(3); else m_tex_filter->setIndexSelected(0); if (!IsLoaded) { m_water_type->addItem("Hydrax"); //It's working good enough to be here now. } if (BSETTING("DevMode", false) && !IsLoaded) { //Things that aren't ready to be used yet. m_sky_type->addItem("SkyX (best looking, slower)"); m_shadow_type->addItem("Parallel-split Shadow Maps"); } //Sky effects Ogre::String skytype = GameSettingsMap["Sky effects"]; if (skytype == "Caelum (best looking, slower)") m_sky_type->setIndexSelected(1); else if (skytype == "SkyX (best looking, slower)" && BSETTING("DevMode", false)) m_sky_type->setIndexSelected(2); else m_sky_type->setIndexSelected(0); //Shadow technique Ogre::String shadowtype = GameSettingsMap["Shadow technique"]; if (shadowtype == "Texture shadows") m_shadow_type->setIndexSelected(1); else if (shadowtype == "Parallel-split Shadow Maps" && BSETTING("DevMode", false)) m_shadow_type->setIndexSelected(2); else m_shadow_type->setIndexSelected(0); //Water effects Ogre::String watertype = GameSettingsMap["Water effects"]; if (watertype == "Reflection") m_water_type->setIndexSelected(1); else if (watertype == "Reflection + refraction (speed optimized)") m_water_type->setIndexSelected(2); else if (watertype == "Reflection + refraction (quality optimized)") m_water_type->setIndexSelected(3); else if (watertype == "Hydrax") m_water_type->setIndexSelected(4); else m_water_type->setIndexSelected(0); //Vegetation Ogre::String vegetationtype = GameSettingsMap["Vegetation"]; if (vegetationtype == "20%") m_vegetation->setIndexSelected(1); else if (vegetationtype == "50%") m_vegetation->setIndexSelected(2); else if (vegetationtype == "Full (best looking, slower)") m_vegetation->setIndexSelected(3); else m_vegetation->setIndexSelected(0); //Light source effects Ogre::String lightstype = GameSettingsMap["Lights"]; if (lightstype == "Only current vehicle, main lights") m_light_source_effects->setIndexSelected(1); else if (lightstype == "All vehicles, main lights") m_light_source_effects->setIndexSelected(2); else if (lightstype == "All vehicles, all lights") m_light_source_effects->setIndexSelected(3); else m_light_source_effects->setIndexSelected(0); //Speed until selection Ogre::String speedunit = GameSettingsMap["SpeedUnit"]; if (speedunit == "Metric") m_speed_unit->setIndexSelected(1); else m_speed_unit->setIndexSelected(0); //Other configs if (GameSettingsMap["DigitalSpeedo"] == "Yes") m_digital_speedo->setStateCheck(true); else m_digital_speedo->setStateCheck(false); if (GameSettingsMap["Particles"] == "Yes") m_psystem->setStateCheck(true); else m_psystem->setStateCheck(false); if (GameSettingsMap["HeatHaze"] == "Yes") m_heathaze->setStateCheck(true); else m_heathaze->setStateCheck(false); if (GameSettingsMap["Mirrors"] == "Yes") m_mirrors->setStateCheck(true); else m_mirrors->setStateCheck(false); if (GameSettingsMap["Sunburn"] == "Yes") m_sunburn->setStateCheck(true); else m_sunburn->setStateCheck(false); if (GameSettingsMap["HDR"] == "Yes") m_hdr->setStateCheck(true); else m_hdr->setStateCheck(false); if (GameSettingsMap["Motion blur"] == "Yes") m_mblur->setStateCheck(true); else m_mblur->setStateCheck(false); if (GameSettingsMap["Skidmarks"] == "Yes") m_skidmarks->setStateCheck(true); else m_skidmarks->setStateCheck(false); if (GameSettingsMap["Envmap"] == "Yes") m_hq_ref->setStateCheck(true); else m_hq_ref->setStateCheck(false); if (GameSettingsMap["Glow"] == "Yes") m_glow->setStateCheck(true); else m_glow->setStateCheck(false); if (GameSettingsMap["DOF"] == "Yes") m_dof->setStateCheck(true); else m_dof->setStateCheck(false); if (GameSettingsMap["Waves"] == "Yes") m_e_waves->setStateCheck(true); else m_e_waves->setStateCheck(false); if (GameSettingsMap["Shadow optimizations"] == "Yes") m_sh_pf_opti->setStateCheck(true); else m_sh_pf_opti->setStateCheck(false); if (GameSettingsMap["AsynchronousPhysics"] == "Yes") m_enable_async_physics->setStateCheck(true); else m_enable_async_physics->setStateCheck(false); if (GameSettingsMap["DisableCollisions"] == "Yes") m_disable_inter_collsion->setStateCheck(true); else m_disable_inter_collsion->setStateCheck(false); if (GameSettingsMap["DisableSelfCollisions"] == "Yes") m_disable_intra_collision->setStateCheck(true); else m_disable_intra_collision->setStateCheck(false); if (GameSettingsMap["Multi-threading"] == "No") m_disable_multithreading->setStateCheck(true); else m_disable_multithreading->setStateCheck(false); //Volume slider long sound_volume = Ogre::StringConverter::parseLong(GameSettingsMap["Sound Volume"], 100); m_volume_slider->setScrollRange(101); m_volume_slider->setScrollPosition(sound_volume -1); if (m_volume_slider->getScrollPosition() >= 100) m_volume_indicator->setCaption("100%"); else m_volume_indicator->setCaption(Ogre::StringConverter::toString(sound_volume) + "%"); //Audio Devices valuecounter = 0; //Back to default char *devices = (char *)alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER); while (devices && *devices != 0) { if (!IsLoaded) { m_audio_dev->addItem(Ogre::String(devices)); } if (Ogre::String(devices) == GameSettingsMap["AudioDevice"]) m_audio_dev->setIndexSelected(valuecounter); devices += strlen(devices) + 1; //next device valuecounter++; } //FPS Limiter slider long fps_limit = Ogre::StringConverter::parseLong(GameSettingsMap["FPS-Limiter"], 60); m_fps_limiter_slider->setScrollRange(200); m_fps_limiter_slider->setScrollPosition(fps_limit -1); if (fps_limit >= 199) m_fps_limiter_indicator->setCaption("Unlimited"); else m_fps_limiter_indicator->setCaption(Ogre::StringConverter::toString(fps_limit) + " FPS"); //SightRange slider long sight_range = Ogre::StringConverter::parseLong(GameSettingsMap["SightRange"], 5000); m_sightrange->setScrollRange(5000); m_sightrange->setScrollPosition(sight_range -1); if (sight_range >= TerrainManager::UNLIMITED_SIGHTRANGE) m_sightrange_indicator->setCaption("Unlimited"); else m_sightrange_indicator->setCaption(Ogre::StringConverter::toString(sight_range) + " m"); if (GameSettingsMap["Replay mode"] == "Yes") m_enable_replay->setStateCheck(true); else m_enable_replay->setStateCheck(false); if (GameSettingsMap["Screenshot Format"] == "png (bigger, no quality loss)") m_hq_screenshots->setStateCheck(true); else m_hq_screenshots->setStateCheck(false); if (GameSettingsMap["ChatAutoHide"] == "Yes") m_autohide_chatbox->setStateCheck(true); else m_autohide_chatbox->setStateCheck(false); if (GameSettingsMap["Flexbody_EnableLODs"] == "Yes") m_flexbodies_lods->setStateCheck(true); else m_flexbodies_lods->setStateCheck(false); if (GameSettingsMap["Flexbody_UseCache"] == "Yes") m_flexbody_cache_system->setStateCheck(true); else m_flexbody_cache_system->setStateCheck(false); Ogre::String skidmarks_quality = GameSettingsMap["SkidmarksBuckets"]; if (skidmarks_quality == "5") m_skidmarks_quality->setIndexSelected(1); else m_light_source_effects->setIndexSelected(0); if (GameSettingsMap["MainMenuMusic"] == "Yes") m_main_menu_music->setStateCheck(true); else m_main_menu_music->setStateCheck(false); }
VBOOL VLogicModel::_setEntityMaterial(const VString &entityName, const VString &matName) { if (matName.empty()) { return VTRUE; } else { VEntityMap::iterator itr = mEntities.find(entityName); if (itr == mEntities.end()) { Ogre::LogManager::getSingleton().logMessage( "Logic Model Entity with name '" + entityName + "' dosen't exists! " + "LogicModel::_setEntityMaterial " + mName ); return VFALSE; } VEntityValue &entValue = itr->second; Ogre::Entity *entity = entValue.mEntity; assert(entity); if (matName.find(";") != VString::npos) { Ogre::StringVector matNames = Ogre::StringUtil::split(matName, ";"); assert(matName.size() > 1); for (VUINT32 i = 0; i < entity->getNumSubEntities(); ++i) { Ogre::SubEntity *subEntity = entity->getSubEntity(i); assert(subEntity); VString subMatName; if (i < matNames.size()) { subMatName = matNames[i]; } else { subMatName = matNames[0]; } const Ogre::MaterialPtr subMat = Ogre::MaterialManager::getSingleton().getByName(subMatName); if (!subMat.isNull()) { subEntity->setMaterialName(subMatName); } } } else { const Ogre::MaterialPtr entityMat = Ogre::MaterialManager::getSingleton().getByName(matName); if (!entityMat.isNull()) { entity->setMaterialName(matName); } } } return VTRUE; }
void WXEffectEditDialog::OnSaveAsButtonDown(wxCommandEvent &e) { SaveAsEffectDialog *dlg = new SaveAsEffectDialog(this, wxID_ANY, _("保存特效"), mEffect); bool ok = (dlg->ShowModal() == wxID_OK); if(ok) { // bool append = true; // 如果模板名称不一样了,说明是要存成一个新的模板 /*if ( dlg->mTextCtrl->GetValue().c_str() == mEffect->getTemplateName() ) { append = false; }*/ Ogre::StringVector templates; const Ogre::String fileName = dlg->mComboBox->GetValue().c_str(); const Ogre::String templateName = dlg->mTextCtrl->GetValue().c_str(); Ogre::StringVector strings = Ogre::StringUtil::split( fileName, "." ); if ( (strings.size() != 2) || (strings[1] != "effect") ) { wxMessageBox ( _("The Script File Name Is Wrong!") ); return; } Fairy::EffectManager::getSingleton().getTemplatesFromScriptFile(fileName, templates); std::ofstream outFile; Ogre::String pathFileName = EFFECT_PATH+fileName; outFile.open ( pathFileName.c_str(), std::ios::out | std::ios::trunc ); // append to file if (!outFile.is_open()) { return; } bool newTemplate = true; // 把所有的模板都写入该文件中 for ( size_t i=0; i<templates.size(); ++i ) { // if (templates[i] != mEffect->getTemplateName()) ///{ Fairy::Effect *effect = Fairy::EffectManager::getSingleton().getTemplate(templates[i]); assert (effect); if (effect->getTemplateName() == dlg->mTextCtrl->GetValue().c_str()) { saveEffect(mEffect, dlg->mTextCtrl->GetValue().c_str(), outFile ); *effect = *mEffect; newTemplate = false; } else saveEffect(effect, effect->getTemplateName(), outFile); } if (newTemplate) { saveEffect(mEffect, templateName, outFile ); mEffect->setTemplateName(templateName); // 刷新EffectManager中的模板内容 Fairy::Effect *effect = Fairy::EffectManager::getSingleton().createEffectTemplate(mEffect->getTemplateName()); *effect = *mEffect; Fairy::EffectManager::getSingleton().addToEffectTemplateScriptFileMap(templateName, fileName); } outFile.close(); } dlg->Destroy(); }
/** 解析*.skill文件 */ void VEffectManager::_parseSkillFile(Ogre::DataStreamPtr &stream) { Ogre::String line; VSkill *skill = VNULL; Ogre::StringVector vecparams; while (!stream->eof()) { line = stream->getLine(); ++mParsingLineNumber; if (!(line.empty() || line.substr(0, 2) == "//")) { if (VNULL == skill) { vecparams = Ogre::StringUtil::split(line, "\t "); if (vecparams[0] != "skill" || vecparams.size() != 2) { _logErrorInfo("Wrong skill name line", line, "EffectManager::parseSkillFile"); continue; } // 创建了一个空的effect skill = _createSkillTemplate(vecparams[1]); _skipToNextOpenBrace(stream); } else { if (line == "}") { // 解析一个完整的技能 skill = VNULL; } else if (line == "AnimEffect") { _skipToNextOpenBrace(stream); _parseAnimEffectInfo(stream, skill); } else if (line == "Ribbon") { _skipToNextOpenBrace(stream); _parseAnimRibbon(stream, skill); } else if (line == "SceneLight") { _skipToNextOpenBrace(stream); _parseAnimSceneLight(stream, skill); } else if (line == "Sound") { _skipToNextOpenBrace(stream); _parseAnimSound(stream, skill); } else { // 解析技能属性 _parseSkillAttrib(line, skill); } } } } }
//---------------------------------------------------------------------------- Ogre::StringVector AngelScriptInterpreter::compileModule(std::string §ion, std::string &file) { Ogre::StringVector ret; int r = mBuilder->StartNewModule(mEngine, section.c_str()); if( r < 0 ) { // If the code fails here it is usually because there // is no more memory to allocate the module return ret; } if(file.substr(0,5) == "proj:") { file.erase(0,5); OFS::OFSHANDLE fHandle; OFS::OfsPtr& ofsFile = OgitorsRoot::getSingletonPtr()->GetProjectFile(); if(ofsFile->openFile(fHandle, file.c_str()) == OFS::OFS_OK) { char *contents; OFS::ofs64 file_size = 0; ofsFile->getFileSize(fHandle, file_size); if(file_size > 0) { contents = new char[(unsigned int)file_size + 1]; ofsFile->read(fHandle, contents, (unsigned int)file_size); contents[file_size] = 0; r = mBuilder->AddSectionFromMemory(section.c_str(), contents); delete [] contents; } else r = -1; ofsFile->closeFile(fHandle); } else r = -1; } else r = mBuilder->AddSectionFromFile(file.c_str()); if( r < 0 ) { // The builder wasn't able to load the file. Maybe the file // has been removed, or the wrong name was given, or some // preprocessing commands are incorrectly written. ret.push_back("The script file can not be found."); return ret; } int errpos; { OGRE_LOCK_AUTO_MUTEX; errpos = mBuffer.size(); } r = mBuilder->BuildModule(); if( r < 0 ) { // An error occurred. Instruct the script writer to fix the // compilation errors that were listed in the output stream. ret.push_back("Please correct the errors in the script and try again."); ret.push_back("Following errors found in script:"); OGRE_LOCK_AUTO_MUTEX; for(unsigned int i = errpos;i < mBuffer.size();i++) { char buf[1000]; sprintf(buf,"Row: %d, Col: %d :: %s", mBuffer[i].mRow, mBuffer[i].mCol, mBuffer[i].mMessage.c_str()); ret.push_back(Ogre::String(buf)); } return ret; } return ret; }
bool SoundScriptTemplate::setParameter(Ogre::StringVector vec) { if (vec.empty()) return false; if (vec[0] == String("trigger_source")) { if (vec.size() < 2) return false; if (vec[1] == String("engine")) {trigger_source=SS_TRIG_ENGINE; return true;}; if (vec[1] == String("aeroengine1")) {trigger_source=SS_TRIG_AEROENGINE1; return true;}; if (vec[1] == String("aeroengine2")) {trigger_source=SS_TRIG_AEROENGINE2; return true;}; if (vec[1] == String("aeroengine3")) {trigger_source=SS_TRIG_AEROENGINE3; return true;}; if (vec[1] == String("aeroengine4")) {trigger_source=SS_TRIG_AEROENGINE4; return true;}; if (vec[1] == String("aeroengine5")) {trigger_source=SS_TRIG_AEROENGINE5; return true;}; if (vec[1] == String("aeroengine6")) {trigger_source=SS_TRIG_AEROENGINE6; return true;}; if (vec[1] == String("aeroengine7")) {trigger_source=SS_TRIG_AEROENGINE7; return true;}; if (vec[1] == String("aeroengine8")) {trigger_source=SS_TRIG_AEROENGINE8; return true;}; if (vec[1] == String("horn")) {trigger_source=SS_TRIG_HORN; return true;}; if (vec[1] == String("brake")) {trigger_source=SS_TRIG_BRAKE; return true;}; if (vec[1] == String("pump")) {trigger_source=SS_TRIG_PUMP; return true;}; if (vec[1] == String("starter")) {trigger_source=SS_TRIG_STARTER; return true;}; if (vec[1] == String("always_on")) {trigger_source=SS_TRIG_ALWAYSON; return true;}; if (vec[1] == String("repair")) {trigger_source=SS_TRIG_REPAIR; return true;}; if (vec[1] == String("air")) {trigger_source=SS_TRIG_AIR; return true;}; if (vec[1] == String("gpws_ap_disconnect")) {trigger_source=SS_TRIG_GPWS_APDISCONNECT; return true;}; if (vec[1] == String("gpws_10")) {trigger_source=SS_TRIG_GPWS_10; return true;}; if (vec[1] == String("gpws_20")) {trigger_source=SS_TRIG_GPWS_20; return true;}; if (vec[1] == String("gpws_30")) {trigger_source=SS_TRIG_GPWS_30; return true;}; if (vec[1] == String("gpws_40")) {trigger_source=SS_TRIG_GPWS_40; return true;}; if (vec[1] == String("gpws_50")) {trigger_source=SS_TRIG_GPWS_50; return true;}; if (vec[1] == String("gpws_100")) {trigger_source=SS_TRIG_GPWS_100; return true;}; if (vec[1] == String("gpws_pull_up")) {trigger_source=SS_TRIG_GPWS_PULLUP; return true;}; if (vec[1] == String("gpws_minimums")) {trigger_source=SS_TRIG_GPWS_MINIMUMS; return true;}; if (vec[1] == String("air_purge")) {trigger_source=SS_TRIG_AIR_PURGE; return true;}; if (vec[1] == String("shift")) {trigger_source=SS_TRIG_SHIFT; return true;}; if (vec[1] == String("gear_slide")) {trigger_source=SS_TRIG_GEARSLIDE; return true;}; if (vec[1] == String("creak") && BSETTING("Creak Sound", false)) {trigger_source=SS_TRIG_CREAK; return true;}; if (vec[1] == String("break")) {trigger_source=SS_TRIG_BREAK; return true;}; if (vec[1] == String("screetch")) {trigger_source=SS_TRIG_SCREETCH; return true;}; if (vec[1] == String("parking_brake")) {trigger_source=SS_TRIG_PARK; return true;}; if (vec[1] == String("antilock")) {trigger_source=SS_TRIG_ALB_ACTIVE; return true;}; if (vec[1] == String("tractioncontrol")) {trigger_source=SS_TRIG_TC_ACTIVE; return true;}; if (vec[1] == String("afterburner1")) {trigger_source=SS_TRIG_AFTERBURNER1; return true;}; if (vec[1] == String("afterburner2")) {trigger_source=SS_TRIG_AFTERBURNER2; return true;}; if (vec[1] == String("afterburner3")) {trigger_source=SS_TRIG_AFTERBURNER3; return true;}; if (vec[1] == String("afterburner4")) {trigger_source=SS_TRIG_AFTERBURNER4; return true;}; if (vec[1] == String("afterburner5")) {trigger_source=SS_TRIG_AFTERBURNER5; return true;}; if (vec[1] == String("afterburner6")) {trigger_source=SS_TRIG_AFTERBURNER6; return true;}; if (vec[1] == String("afterburner7")) {trigger_source=SS_TRIG_AFTERBURNER7; return true;}; if (vec[1] == String("afterburner8")) {trigger_source=SS_TRIG_AFTERBURNER8; return true;}; if (vec[1] == String("avionic_chat_01")) {trigger_source=SS_TRIG_AVICHAT01; return true;}; if (vec[1] == String("avionic_chat_02")) {trigger_source=SS_TRIG_AVICHAT02; return true;}; if (vec[1] == String("avionic_chat_03")) {trigger_source=SS_TRIG_AVICHAT03; return true;}; if (vec[1] == String("avionic_chat_04")) {trigger_source=SS_TRIG_AVICHAT04; return true;}; if (vec[1] == String("avionic_chat_05")) {trigger_source=SS_TRIG_AVICHAT05; return true;}; if (vec[1] == String("avionic_chat_06")) {trigger_source=SS_TRIG_AVICHAT06; return true;}; if (vec[1] == String("avionic_chat_07")) {trigger_source=SS_TRIG_AVICHAT07; return true;}; if (vec[1] == String("avionic_chat_08")) {trigger_source=SS_TRIG_AVICHAT08; return true;}; if (vec[1] == String("avionic_chat_09")) {trigger_source=SS_TRIG_AVICHAT09; return true;}; if (vec[1] == String("avionic_chat_10")) {trigger_source=SS_TRIG_AVICHAT10; return true;}; if (vec[1] == String("avionic_chat_11")) {trigger_source=SS_TRIG_AVICHAT11; return true;}; if (vec[1] == String("avionic_chat_12")) {trigger_source=SS_TRIG_AVICHAT12; return true;}; if (vec[1] == String("avionic_chat_13")) {trigger_source=SS_TRIG_AVICHAT13; return true;}; if (vec[1] == String("aoa_horn")) {trigger_source=SS_TRIG_AOA; return true;}; if (vec[1] == String("ignition")) {trigger_source=SS_TRIG_IGNITION; return true;}; if (vec[1] == String("reverse_gear")) {trigger_source=SS_TRIG_REVERSE_GEAR; return true;}; if (vec[1] == String("turn_signal")) {trigger_source=SS_TRIG_TURN_SIGNAL; return true;}; if (vec[1] == String("turn_signal_tick")) {trigger_source=SS_TRIG_TURN_SIGNAL_TICK; return true;}; if (vec[1] == String("turn_signal_warn_tick")) {trigger_source=SS_TRIG_TURN_SIGNAL_WARN_TICK; return true;}; if (vec[1] == String("linked_command")) {trigger_source=SS_TRIG_LINKED_COMMAND; return true;}; if (vec[1] == String("main_menu")) { trigger_source = SS_TRIG_MAIN_MENU; return true; }; return false; } if (vec[0] == String("pitch_source")) { if (vec.size() < 2) return false; int mod = parseModulation(vec[1]); if (mod >= 0) { pitch_source = mod; return true; } return false; } if (vec[0] == String("pitch_factors")) { if (vec.size() < 3) return false; pitch_offset = StringConverter::parseReal(vec[1]); pitch_multiplier = StringConverter::parseReal(vec[2]); if (vec.size() == 4) { pitch_square=StringConverter::parseReal(vec[3]); } return true; } if (vec[0] == String("gain_source")) { if (vec.size() < 2) return false; int mod = parseModulation(vec[1]); if (mod >= 0) { gain_source = mod; return true; } return false; } if (vec[0] == String("gain_factors")) { if (vec.size() < 3) return false; gain_offset = StringConverter::parseReal(vec[1]); gain_multiplier = StringConverter::parseReal(vec[2]); if (vec.size() == 4) { gain_square = StringConverter::parseReal(vec[3]); } return true; } if (vec[0] == String("start_sound")) { if (vec.size() < 3) return false; start_sound_pitch = StringConverter::parseReal(vec[1]); // unparsable (e.g. "unpitched") will result in value 0.0 start_sound_name = vec[2]; has_start_sound = true; return true; } if (vec[0] == String("stop_sound")) { if (vec.size() < 3) return false; stop_sound_pitch = StringConverter::parseReal(vec[1]); // unparsable (e.g. "unpitched") will result in value 0.0 stop_sound_name = vec[2]; has_stop_sound = true; return true; } if (vec[0] == String("sound")) { if (vec.size() < 3) return false; if (free_sound >= MAX_SOUNDS_PER_SCRIPT) { LOG("SoundScriptManager: Reached MAX_SOUNDS_PER_SCRIPT limit (" + TOSTRING(MAX_SOUNDS_PER_SCRIPT) + ")"); return false; } sound_pitches[free_sound] = StringConverter::parseReal(vec[1]); // unparsable (e.g. "unpitched") will result in value 0.0 if (sound_pitches[free_sound] == 0) { unpitchable = true; } if (free_sound > 0 && !unpitchable && sound_pitches[free_sound] <= sound_pitches[free_sound - 1]) { return false; } sound_names[free_sound] = vec[2]; free_sound++; return true; } return false; }
//---------------------------------------------------------------------------- Ogre::StringVector AngelScriptInterpreter::runUpdateFunction(std::string §ion, CBaseEditor *object, Ogre::Real time) { Ogre::StringVector ret; ContextDef *def; unsigned int objectresourcehandle = object->getScriptResourceHandle(); asIScriptContext* ctx = 0; if(objectresourcehandle != 0) { ObjectContextMap::iterator it = mObjectContexts.find(objectresourcehandle); if(it != mObjectContexts.end()) { def = &(it->second); ctx = def->context; float tsince = mTimeSinceLastFrame; def->sleep -= mTimeSinceLastFrame; def->delay += mTimeSinceLastFrame; if(def->sleep > 0.0f) return ret; } } if(ctx == 0) { objectresourcehandle = ++mObjectHandleCounter; object->setScriptResourceHandle(objectresourcehandle); Ogre::String script = object->getUpdateScript(); assert(!script.empty()); Ogre::String module = Ogre::StringConverter::toString(object->getObjectID()); script = "proj:/Scripts/" + script; compileModule(module, script); ContextDef newdef; newdef.sleep = 0.0f; newdef.delay = 0.0f; newdef.module = mEngine->GetModule(section.c_str()); newdef.funcID = newdef.module->GetFunctionByDecl("void update()"); newdef.context = mEngine->CreateContext(); newdef.context->SetExceptionCallback(asFUNCTION(ExceptionCallback), this, asCALL_CDECL); mObjectContexts[objectresourcehandle] = newdef; def = &(mObjectContexts[objectresourcehandle]); ctx = newdef.context; } if( def->funcID < 0 ) { // The function couldn't be found. Instruct the script writer // to include the expected function in the script. ret.push_back("The script must have the function 'void update()'. Please add it and try again."); return ret; } //CDebugger* dbg = new CDebugger(); //dbg->TakeCommands(ctx); //ctx->SetLineCallback(asMETHOD(CDebugger, LineCallback), dbg, asCALL_THISCALL); mActiveContext = def; mActiveObject = object; if(ctx->GetState() != asEXECUTION_SUSPENDED) ctx->Prepare(def->funcID); int r = ctx->Execute(); def->delay = 0.0f; switch(r) { case asEXECUTION_SUSPENDED: case asEXECUTION_FINISHED:break; default:{ ctx->Release(); ctx = mEngine->CreateContext(); ctx->SetExceptionCallback(asFUNCTION(ExceptionCallback), this, asCALL_CDECL); mObjectContexts[objectresourcehandle].context = ctx; // The execution didn't complete as expected. Determine what happened. if( r == asEXECUTION_EXCEPTION ) { // An exception occurred, let the script writer know what happened so it can be corrected. ret.push_back("An exception '" + std::string(ctx->GetExceptionString()) + "' occurred. Please correct the code and try again."); } } } mActiveContext = 0; mActiveObject = 0; //delete dbg; return ret; }
/* All commands are here */ void Console::eventCommandAccept(MyGUI::Edit* _sender) { UTFString msg = convertFromMyGUIString(m_Console_TextBox->getCaption()); // we did not autoComplete, so try to handle the message m_Console_TextBox->setCaption(""); if (msg.empty()) { // discard the empty message return; } if (msg[0] == '/' || msg[0] == '\\') { Ogre::StringVector args = StringUtil::split(msg, " "); sTextHistory[iText] = msg; iText++; //Used for text history if (args[0] == "/help") { putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_TITLE, _L("Available commands:"), "help.png"); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/help - information on commands (this)"), "help.png"); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/ver - shows the Rigs of Rods version"), "information.png"); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/pos - outputs the current position"), "world.png"); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/goto <x> <y> <z> - jumps to the mentioned position"), "world.png"); //if (gEnv->terrainManager->getHeightFinder()) //Not needed imo -max98 putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/terrainheight - get height of terrain at current position"), "world.png"); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/log - toggles log output on the console"), "table_save.png"); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/quit - exit Rigs of Rods"), "table_save.png"); #ifdef USE_ANGELSCRIPT putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/as <code here> - interpret angel code using console"), "script_go.png"); #endif // USE_ANGELSCRIPT putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/gravity <real> or <text string> - changes gravity constant. Outputs current value if no argument is given"), "script_go.png"); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("Possible values: \n earth \n moon \n jupiter \n A random number (use negative)"), "script_go.png"); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("/setwaterlevel <real> - changes water's level"), "script_go.png"); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_TITLE, _L("Tips:"), "help.png"); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, _L("- use Arrow Up/Down Keys in the InputBox to reuse old messages"), "information.png"); return; } else if (args[0] == "/gravity") { float gValue; if (args.size() > 1) { if (args[1] == "earth") gValue = -9.81; else if (args[1] == "moon") gValue = -1.6; else if (args[1] == "jupiter") gValue = -50; else gValue = boost::lexical_cast<float>(args[1].c_str()); } else { putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, _L("Current gravity is: ") + StringConverter::toString(gEnv->terrainManager->getGravity()), "information.png"); return; } gEnv->terrainManager->setGravity(gValue); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, _L("Gravity set to: ") + StringConverter::toString(gValue), "information.png"); return; } else if (args[0] == "/setwaterlevel") { if (gEnv->terrainManager && gEnv->terrainManager->getWater() && args.size() > 1) { IWater* water = gEnv->terrainManager->getWater(); water->setCamera(gEnv->mainCamera); water->setHeight(boost::lexical_cast<float>(args[1].c_str())); water->update(); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, _L("Water level set to: ") + StringConverter::toString(water->getHeight()), "information.png"); } else { putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_ERROR, _L("Please enter a correct value. "), "information.png"); } return; } else if (args[0] == "/pos" && (gEnv->frameListener->loading_state == TERRAIN_LOADED || gEnv->frameListener->loading_state == ALL_LOADED)) { Beam *b = BeamFactory::getSingleton().getCurrentTruck(); if (!b && gEnv->player) { Vector3 pos = gEnv->player->getPosition(); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, _L("Character position: ") + String("x: ") + TOSTRING(pos.x) + String(" y: ") + TOSTRING(pos.y) + String(" z: ") + TOSTRING(pos.z), "world.png"); } else if (b) { Vector3 pos = b->getPosition(); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, _L("Vehicle position: ") + String("x: ") + TOSTRING(pos.x) + String(" y: ") + TOSTRING(pos.y) + String(" z: ") + TOSTRING(pos.z), "world.png"); } return; } else if (args[0] == "/goto" && (gEnv->frameListener->loading_state == TERRAIN_LOADED || gEnv->frameListener->loading_state == ALL_LOADED)) { if (args.size() != 4) { putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_HELP, ChatSystem::commandColour + _L("usage: /goto x y z"), "information.png"); return; } Vector3 pos = Vector3(PARSEREAL(args[1]), PARSEREAL(args[2]), PARSEREAL(args[3])); Beam *b = BeamFactory::getSingleton().getCurrentTruck(); if (!b && gEnv->player) { gEnv->player->setPosition(pos); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, _L("Character position set to: ") + String("x: ") + TOSTRING(pos.x) + String(" y: ") + TOSTRING(pos.y) + String(" z: ") + TOSTRING(pos.z), "world.png"); } else if (b) { b->resetPosition(pos, false); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, _L("Vehicle position set to: ") + String("x: ") + TOSTRING(pos.x) + String(" y: ") + TOSTRING(pos.y) + String(" z: ") + TOSTRING(pos.z), "world.png"); } return; } else if (args[0] == "/terrainheight" && (gEnv->frameListener->loading_state == TERRAIN_LOADED || gEnv->frameListener->loading_state == ALL_LOADED)) { if (!gEnv->terrainManager->getHeightFinder()) return; Vector3 pos = Vector3::ZERO; Beam *b = BeamFactory::getSingleton().getCurrentTruck(); if (!b && gEnv->player) { pos = gEnv->player->getPosition(); } else if (b) { pos = b->getPosition(); } Real h = gEnv->terrainManager->getHeightFinder()->getHeightAt(pos.x, pos.z); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, _L("Terrain height at position: ") + String("x: ") + TOSTRING(pos.x) + String("z: ") + TOSTRING(pos.z) + _L(" = ") + TOSTRING(h), "world.png"); return; } else if (args[0] == "/ver") { putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_TITLE, "Rigs of Rods:", "information.png"); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, " Version: " + String(ROR_VERSION_STRING), "information.png"); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, " Protocol version: " + String(RORNET_VERSION), "information.png"); putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_REPLY, " build time: " + String(__DATE__) + ", " + String(__TIME__), "information.png"); return; } else if (args[0] == "/quit") { gEnv->frameListener->shutdown_final(); return; } #ifdef USE_ANGELSCRIPT else if (args[0] == "/as" && (gEnv->frameListener->loading_state == TERRAIN_LOADED || gEnv->frameListener->loading_state == ALL_LOADED)) { // we want to notify any running scripts that we might change something (prevent cheating) ScriptEngine::getSingleton().triggerEvent(SE_ANGELSCRIPT_MANIPULATIONS); String command = msg.substr(args[0].length()); StringUtil::trim(command); if (command.empty()) return; String nmsg = ChatSystem::scriptCommandColour + ">>> " + ChatSystem::normalColour + command; putMessage(CONSOLE_MSGTYPE_SCRIPT, CONSOLE_LOCAL_SCRIPT, nmsg, "script_go.png"); int res = ScriptEngine::getSingleton().executeString(command); return; } #endif //ANGELSCRIPT else if (args[0] == "/log") { // switch to console logging bool logging = BSETTING("Enable Ingame Console", false); if (!logging) { putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_NOTICE, _L(" logging to console enabled"), "information.png"); SETTINGS.setSetting("Enable Ingame Console", "Yes"); } else { putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_NOTICE, _L(" logging to console disabled"), "information.png"); SETTINGS.setSetting("Enable Ingame Console", "No"); } return; } else { //TODO: Angelscript here putMessage(CONSOLE_MSGTYPE_INFO, CONSOLE_SYSTEM_ERROR, _L("unknown command: ") + msg, "error.png"); } } }
void AddEffectInfoDialog::OnInitDialog(wxInitDialogEvent &e) { wxDialog::OnInitDialog(e); wxSizer* sizer = new wxBoxSizer( wxVERTICAL ); wxFlexGridSizer *item1 = new wxFlexGridSizer( 2, 0, 0 ); wxComboBox *item2 = new wxComboBox( this, feID_COMBOCTRL_EFFECT, wxT(""), wxDefaultPosition, wxSize(200,-1), 0, NULL, wxCB_DROPDOWN ); item1->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 ); wxComboBox *item3 = new wxComboBox( this, feID_COMBOCTRL_LOCATOR, wxT(""), wxDefaultPosition, wxSize(200,-1), 0, NULL, wxCB_DROPDOWN ); item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 ); sizer->Add( item1, 0, wxALIGN_CENTER|wxALL, 10 ); wxFlexGridSizer *item5 = new wxFlexGridSizer( 2, 0, 0 ); wxButton *item6 = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 ); item6->SetDefault(); item5->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 ); wxButton *item7 = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); item5->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 ); sizer->Add( item5, 0, wxALIGN_CENTER|wxALL, 10 ); this->SetSizer( sizer ); sizer->SetSizeHints( this ); Fairy::EffectManager::EffectTemplateIterator it = Fairy::EffectManager::getSingleton().getEffectTemplateIterator(); while ( it.hasMoreElements() ) { item2->AppendString(it.peekNextKey().c_str()); it.moveNext(); } item2->SetSelection(0); SkillObjectEditor* pEditor= static_cast<SkillObjectEditor*>(this->GetParent()); if(!pEditor) return; Fairy::LogicModel *pMbject = pEditor->GetParentFrame()->GetActorSettingEditor()->GetActorObject(); assert (pMbject); Ogre::StringVector boneNameList; for ( unsigned short i=0; i<pMbject->getNumBones(); ++i ) { boneNameList.push_back(pMbject->getBoneName(i)); } Ogre::StringVector locatorNames; pMbject->getLocatorNames(locatorNames); for ( size_t i=0; i<locatorNames.size(); ++i ) { Fairy::LogicModel::LocatorValue value; if(pMbject->getLocatorInfo(locatorNames[i], value)) { if(value.mBoneName != "" ) { for ( int index=0; index<(int)boneNameList.size(); ++index ) { if (boneNameList[index] == value.mBoneName) { // info of the locator is valid item3->Append(locatorNames[i].c_str()); break; } } } } } item3->SetSelection(0); }
void DashBoard::loadLayoutRecursive(MyGUI::WidgetPtr w) { std::string name = w->getName(); std::string anim = w->getUserString("anim"); std::string debug = w->getUserString("debug"); // make it unclickable w->setUserString("interactive", "0"); if(!debug.empty()) { w->setVisible(false); return; } // find the root widget and ignore debug widgets if(name.size() > prefix.size()) { std::string prefixLessName = name.substr(prefix.size()); if(prefixLessName == "_Main") { mainWidget = w; // resize it windowResized(); } // ignore debug widgets if(prefixLessName == "DEBUG") { w->setVisible(false); return; } } // animations for this control? if(!anim.empty()) { layoutLink_t ctrl; memset(&ctrl, 0, sizeof(ctrl)); if(!name.empty()) strncpy(ctrl.name, name.c_str(), 255); ctrl.widget = w; ctrl.initialSize = w->getSize(); ctrl.initialPosition = w->getPosition(); ctrl.last = 1337.1337f; // force update ctrl.lastState = true; // establish the link { String linkArgs = w->getUserString("link"); replaceString(linkArgs, ">", ">"); replaceString(linkArgs, "<", "<"); String linkName = ""; if(linkArgs.empty()) { LOG("Dashboard ("+filename+"/"+name+"): empty Link"); return; } // conditional checks // TODO: improve the logic, this is crap ... if(linkArgs.find(">") != linkArgs.npos) { Ogre::StringVector args = Ogre::StringUtil::split(linkArgs, ">"); if(args.size() == 2) { linkName = args[0]; ctrl.conditionArgument = StringConverter::parseReal(args[1]); ctrl.condition = CONDITION_GREATER; } else { LOG("Dashboard ("+filename+"/"+name+"): error in conditional Link: " + linkArgs); return; } } else if(linkArgs.find("<") != linkArgs.npos ) { Ogre::StringVector args = Ogre::StringUtil::split(linkArgs, "<"); if(args.size() == 2) { linkName = args[0]; ctrl.conditionArgument = StringConverter::parseReal(args[1]); ctrl.condition = CONDITION_LESSER; } else { LOG("Dashboard ("+filename+"/"+name+"): error in conditional Link: " + linkArgs); return; } } else { ctrl.condition = CONDITION_NONE; ctrl.conditionArgument = 0; linkName = linkArgs; } // now try to get the enum id for it int linkID = manager->getLinkIDForName(linkName); if(linkID < 0) { LOG("Dashboard ("+filename+"/"+name+"): unknown Link: " + linkName); return; } ctrl.linkID = linkID; } // parse more attributes ctrl.wmin = StringConverter::parseReal(w->getUserString("min")); ctrl.wmax = StringConverter::parseReal(w->getUserString("max")); ctrl.vmin = StringConverter::parseReal(w->getUserString("vmin")); ctrl.vmax = StringConverter::parseReal(w->getUserString("vmax")); String texture = w->getUserString("texture"); if(!texture.empty()) strncpy(ctrl.texture, texture.c_str(), 255); String format = w->getUserString("format"); if(!format.empty()) strncpy(ctrl.format, format.c_str(), 255); String direction = w->getUserString("direction"); if(direction == "right") ctrl.direction = DIRECTION_RIGHT; else if(direction == "left") ctrl.direction = DIRECTION_LEFT; else if(direction == "down") ctrl.direction = DIRECTION_DOWN; else if(direction == "up") ctrl.direction = DIRECTION_UP; else if(!direction.empty()) { LOG("Dashboard ("+filename+"/"+name+"): unknown direction: " + direction); return; } // then specializations if(anim == "rotate") { ctrl.animationType = ANIM_ROTATE; // check if its the correct control // try to cast, will throw // and if the link is a float /* if(manager->getDataType(ctrl.linkID) != DC_FLOAT) { LOG("Dashboard ("+filename+"/"+name+"): Rotating controls can only link to floats"); continue; } */ try { ctrl.rotImg = w->getSubWidgetMain()->castType<MyGUI::RotatingSkin>(); } catch (...) { LOG("Dashboard ("+filename+"/"+name+"): Rotating controls must use the RotatingSkin"); return; } if(!ctrl.rotImg) { LOG("Dashboard ("+filename+"/"+name+"): error loading rotation control"); return; } // special: set rotation center now into the middle ctrl.rotImg->setCenter(MyGUI::IntPoint(w->getHeight() * 0.5f, w->getWidth() * 0.5f)); } else if(anim == "scale") { ctrl.animationType = ANIM_SCALE; if(ctrl.direction == DIRECTION_NONE) { LOG("Dashboard ("+filename+"/"+name+"): direction empty: scale needs a direction"); return; } } else if(anim == "translate") { ctrl.animationType = ANIM_TRANSLATE; if(ctrl.direction == DIRECTION_NONE) { LOG("Dashboard ("+filename+"/"+name+"): direction empty: translate needs a direction"); return; } } else if(anim == "series") { ctrl.animationType = ANIM_SERIES; ctrl.img = (MyGUI::ImageBox *)w; //w->getSubWidgetMain()->castType<MyGUI::ImageBox>(); if(!ctrl.img) { LOG("Dashboard ("+filename+"/"+name+"): error loading series control"); return; } } else if(anim == "text") { // try to cast, will throw try { ctrl.txt = (MyGUI::TextBox *)w; // w->getSubWidgetMain()->castType<MyGUI::TextBox>(); } catch (...) { LOG("Dashboard ("+filename+"/"+name+"): Lamp controls must use the ImageBox Control"); return; } ctrl.animationType = ANIM_TEXT; } else if(anim == "text2") { // try to cast, will throw try { ctrl.txt = (MyGUI::TextBox *)w; // w->getSubWidgetMain()->castType<MyGUI::TextBox>(); } catch (...) { LOG("Dashboard ("+filename+"/"+name+"): Lamp controls must use the ImageBox Control"); return; } ctrl.animationType = ANIM_TEXT2; } else if(anim == "lamp") { // try to cast, will throw /* { try { w->getSubWidgetMain()->castType<MyGUI::ImageBox>(); } catch (...) { LOG("Dashboard ("+filename+"/"+name+"): Lamp controls must use the ImageBox Control"); continue; } } */ ctrl.animationType = ANIM_LAMP; ctrl.img = (MyGUI::ImageBox *)w; //w->getSubWidgetMain()->castType<MyGUI::ImageBox>(); if(!ctrl.img) { LOG("Dashboard ("+filename+"/"+name+"): error loading Lamp control"); return; } } controls[free_controls] = ctrl; free_controls++; if(free_controls >= MAX_CONTROLS) { LOG("maximum amount of controls reached, discarding the rest: " + TOSTRING(MAX_CONTROLS)); return; } } // walk the children now MyGUI::EnumeratorWidgetPtr e = w->getEnumerator(); while (e.next()) { loadLayoutRecursive(e.current()); } }
void SkillObjectEditor::OnSaveSkillObject(wxCommandEvent &e) { if (NULL == mSkill) { wxMessageBox("您还没有创建技能,请创建后重试!","提示"); return; } if(mSaveFileName == "") { SaveSkillDialog *dlg = new SaveSkillDialog(this, wxID_ANY, _("保存技能"), mSkill); bool ok = (dlg->ShowModal() == wxID_OK); if(ok) { mSaveFileName = dlg->mComboBox->GetValue().c_str(); //判断文件名 Ogre::StringVector strings = Ogre::StringUtil::split( mSaveFileName, "." ); if (strings.size() != 2 || strings[1] != "skill") { mSaveFileName.append(".skill"); } dlg->Destroy(); } else { dlg->Destroy(); return; } } //if(mbRecoverSave) //{ // char buf[256]; // sprintf(buf,"是否覆盖文件%s中的%s效果数据!",mSaveFileName.c_str(),mSkillTemplateName.c_str()); // RecoverSaveDialog* dlg = new RecoverSaveDialog(m_Frame,wxID_ANY,wxT("覆盖文件")); // dlg->SetText(wxString(buf)); // if(wxID_OK == dlg->ShowModal()) // { // mbRecoverSave = false; // dlg->Destroy(); // } // else // { // dlg->Destroy(); // return; // } //} Ogre::StringVector templates; const Ogre::String fileName = mSaveFileName; Fairy::EffectManager::getSingleton().getSkillTemplatesFromScriptFile(fileName, templates); std::ofstream outFile; Ogre::String pathFileName = EFFECT_PATH+fileName; outFile.open ( pathFileName.c_str(), std::ios::out | std::ios::trunc ); // append to file if (!outFile.is_open()) { return; } bool newTemplate = true; // 把所有的模板都写入该文件中 for ( size_t i=0; i<templates.size(); ++i ) { // if (templates[i] != mEffect->getTemplateName()) ///{ Fairy::Skill *skill = Fairy::EffectManager::getSingleton().getSkill(templates[i]); assert (skill); if (skill->getSkillName() == mSkillTemplateName) { saveSkill(mSkill, mSkillTemplateName, outFile ); *skill = *mSkill; newTemplate = false; } else saveSkill(skill, skill->getSkillName(), outFile); } if (newTemplate) { saveSkill(mSkill, mSkillTemplateName, outFile ); mSkill->setSkillName(mSkillTemplateName); Fairy::EffectManager::getSingleton().addToSkillTemplateScriptFileMap(mSkillTemplateName, fileName); } outFile.close(); }
void FixPaintAction::parseInfoString() { Ogre::MemoryDataStream* stream = new Ogre::MemoryDataStream((void *)(mInfoString.c_str()), mInfoString.length(), false); String line; Ogre::String textureName; while(!stream->eof()) { line = stream->getLine(); // junction height if ( line.substr(0,8) == "junction") { mPasteHeightInfo = true; stream->skipLine(); String valueLine; Ogre::StringVector vecparams; valueLine = stream->getLine(); while ( valueLine != "}" ) { vecparams = Ogre::StringUtil::split(valueLine); assert ( vecparams.size() == 3 ); valueLine = stream->getLine(); int junctionX = Ogre::StringConverter::parseInt(vecparams[0]); int junctionZ = Ogre::StringConverter::parseInt(vecparams[1]); float height = Ogre::StringConverter::parseReal(vecparams[2]); mGridSelection.setJunctionValue(Point(junctionX, junctionZ), height); } } // texture else if ( line.substr(0,12) == "grid_texture" ) { mPasteTextureInfo = true; stream->skipLine(); String valueLine; Ogre::StringVector vecparams; valueLine = stream->getLine(); char strBuf[128]; strcpy(strBuf,valueLine.c_str()); while ( valueLine != "}" ) { vecparams = Ogre::StringUtil::split(valueLine); assert ( vecparams.size() == 14 || vecparams.size() == 8 ); valueLine = stream->getLine(); char strBuf[128]; strcpy(strBuf,valueLine.c_str()); // 获取当前要操作的grid的绝对坐标 int gridX = Ogre::StringConverter::parseInt(vecparams[0]); int gridZ = Ogre::StringConverter::parseInt(vecparams[1]); FixPaintSelection::TextureGridInfo gridInfo; textureName = Ogre::StringConverter::toString(Ogre::StringConverter::parseStringVector(vecparams[2])); gridInfo.layers[0].textureName = textureName; gridInfo.layers[0].left = Ogre::StringConverter::parseReal(vecparams[3]); gridInfo.layers[0].top = Ogre::StringConverter::parseReal(vecparams[4]); gridInfo.layers[0].right = Ogre::StringConverter::parseReal(vecparams[5]); gridInfo.layers[0].bottom = Ogre::StringConverter::parseReal(vecparams[6]); gridInfo.layers[0].orientation = Ogre::StringConverter::parseUnsignedInt(vecparams[7]); if(vecparams.size() == 14) { textureName = Ogre::StringConverter::toString(Ogre::StringConverter::parseStringVector(vecparams[8])); gridInfo.layers[1].textureName = textureName; gridInfo.layers[1].left = Ogre::StringConverter::parseReal(vecparams[9]); gridInfo.layers[1].top = Ogre::StringConverter::parseReal(vecparams[10]); gridInfo.layers[1].right = Ogre::StringConverter::parseReal(vecparams[11]); gridInfo.layers[1].bottom = Ogre::StringConverter::parseReal(vecparams[12]); gridInfo.layers[1].orientation = Ogre::StringConverter::parseUnsignedInt(vecparams[13]); } else gridInfo.layers[1].textureName = "UnTextured"; mGridSelection.setGridValue(Point(gridX, gridZ),gridInfo); } } // diagonal else if ( line.substr(0,13) == "grid_diagonal" ) { mPasteDiagonalInfo = true; stream->skipLine(); String valueLine; Ogre::StringVector vecparams; valueLine = stream->getLine(); while ( valueLine != "}" ) { vecparams = Ogre::StringUtil::split(valueLine); assert ( vecparams.size() == 3 ); valueLine = stream->getLine(); int gridX = Ogre::StringConverter::parseInt(vecparams[0]); int gridZ = Ogre::StringConverter::parseInt(vecparams[1]); uint flags = Ogre::StringConverter::parseUnsignedInt(vecparams[2]); mGridSelection.setFlagValue(Point(gridX, gridZ),flags); } } } delete stream; }
void QOgreWindow::initialize() { // Initialize Ogre like normal #ifdef _MSC_VER oRoot = new Ogre::Root(Ogre::String("plugins" OGRE_BUILD_SUFFIX ".cfg")); #else oRoot = new Ogre::Root(Ogre::String("plugins.cfg")); #endif Ogre::ConfigFile oConf; oConf.load(resConfig); Ogre::ConfigFile::SectionIterator seci = oConf.getSectionIterator(); Ogre::String secName, typeName, archName; while (seci.hasMoreElements()) { secName = seci.peekNextKey(); Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); Ogre::ConfigFile::SettingsMultiMap::iterator i; for (i = settings->begin(); i != settings->end(); ++i) { typeName = i->first; archName = i->second; Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName); } } /*Ogre::String name, locType; Ogre::ConfigFile::SectionIterator secIt = oConf.getSectionIterator(); while(secIt.hasMoreElements()) { Ogre::ConfigFile::SettingsMultiMap* _settings = secIt.getNext(); Ogre::ConfigFile::SettingsMultiMap::iterator it; for (it = _settings->begin(); it != _settings->end(); ++it) { locType = it->first; name = it->second; } Ogre::ResourceGroupManager::getSingleton().addResourceLocation(name,locType); }*/ //if (!oRoot->restoreConfig() || oRoot->showConfigDialog()) return; const Ogre::RenderSystemList& rsList = oRoot->getAvailableRenderers(); Ogre::RenderSystem* rs = rsList[0]; // This list setup search order for used render system Ogre::StringVector renderOrder; renderOrder.push_back("OpenGL"); #if PONY_PLATFORM == PLAT_WIN32 || PONY_PLATFORM == PLAT_WIN64 renderOrder.push_back("Direct3D9"); renderOrder.push_back("Direct3D11"); #endif //renderOrder.push_back("OpenGL 3+"); for (Ogre::StringVector::iterator iter = renderOrder.begin(); iter != renderOrder.end(); iter++) { for (Ogre::RenderSystemList::const_iterator it = rsList.begin(); it != rsList.end(); it++) { if ((*it)->getName().find(*iter) != Ogre::String::npos) { rs = *it; break; } } if (rs != NULL) break; } if (rs == NULL) { if (!oRoot->restoreConfig()) { if (!oRoot->showConfigDialog()) { OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "[PoneNgine][Ogre3D] Abort render system configuration.","QOgreWindow::initialize"); } } } // Settings size on windows will solve a lot of problems // VSync... why is this praised by developers again? Becuase I hate it in games. // Soon, I'll make a settings class for the in-game settings. QString dimensions = QString("%1 x %2").arg(this->width()).arg(this->height()); rs->setConfigOption("Video Mode", dimensions.toStdString()); rs->setConfigOption("Full Screen", "No"); rs->setConfigOption("VSync", "No"); oRoot->setRenderSystem(rs); oRoot->initialise(false); Ogre::NameValuePairList parameters; if (rs->getName().find("GL") <= rs->getName().size()) parameters["currentGLContext"] = Ogre::String("false"); #if PONY_PLATFORM == PLAT_WIN32 || PONY_PLATFORM == PLAT_WIN64 || PONY_PLATFORM == PLAT_MACOSX parameters["externalWindowHandle"] = Ogre::StringConverter::toString((size_t)(this->winId())); parameters["parentWindowHandle"] = Ogre::StringConverter::toString((size_t)(this->winId())); #else parameters["externalWindowHandle"] = Ogre::StringConverter::toString((unsigned long)(this->winId())); parameters["parentWindowHandle"] = Ogre::StringConverter::toString((unsigned long)(this->winId())); #endif #if PONY_PLATFORM == PLAT_MACOSX parameters["macAPI"] = "cocoa"; parameters["macAPICocoaUseNSView"] = "true"; #endif oWin = oRoot->createRenderWindow("QOgreWindow Test | PoneNgine Version "+Ogre::String(PONENGINE_VERSION)+" Build "+Ogre::String(PONENGINE_BUILD), this->width(), this->height(), false, ¶meters); oWin->setVisible(true); Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); #if OGRE_VERSION >= ((2 << 16) | (0 << 8) | 0) const size_t numThreads = std::max<int>(1, Ogre::PlatformInformation::getNumLogicalCores()); Ogre::InstancingTheadedCullingMethod threadedCullingMethod = Ogre::INSTANCING_CULLING_SINGLETHREAD; if (numThreads > 1)threadedCullingMethod = Ogre::INSTANCING_CULLING_THREADED; oSceneMgr = oRoot->createSceneManager(Ogre::ST_GENERIC, numThreads, threadedCullingMethod); #else oSceneMgr = oRoot->createSceneManager(Ogre::ST_GENERIC); #endif oCam = oSceneMgr->createCamera("MainCamera"); oCam->setPosition(Ogre::Vector3(0.0f,0.0f,10.0f)); oCam->lookAt(Ogre::Vector3(0.0f,0.0f,-300.0f)); oCam->setNearClipDistance(0.1f); oCam->setFarClipDistance(200.0f); camMan = new OgreQtBites::QtOgreSdkCameraMan(oCam); #if OGRE_VERSION >= ((2 << 16) | (0 << 8) | 0) createCompositor(); #else Ogre::Viewport* oViewPort = oWin->addViewport(oCam); oViewPort->setBackgroundColour(oBgColor); #endif oCam->setAspectRatio(Ogre::Real(oWin->getWidth()) / Ogre::Real(oWin->getHeight())); oCam->setAutoAspectRatio(true); createScene(); oRoot->addFrameListener(this); }
AdvancedRenderControls::AdvancedRenderControls(TrayManager* trayMgr, Ogre::Camera* cam) : mCamera(cam), mTrayMgr(trayMgr) { mRoot = Ogre::Root::getSingletonPtr(); // create a params panel for displaying sample details Ogre::StringVector items; items.push_back("cam.pX"); items.push_back("cam.pY"); items.push_back("cam.pZ"); items.push_back(""); items.push_back("cam.oW"); items.push_back("cam.oX"); items.push_back("cam.oY"); items.push_back("cam.oZ"); items.push_back(""); items.push_back("Filtering"); items.push_back("Poly Mode"); #ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM mShaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr(); items.push_back("RT Shaders"); items.push_back("Lighting Model"); items.push_back("Compact Policy"); items.push_back("Generated VS"); items.push_back("Generated FS"); #endif mDetailsPanel = mTrayMgr->createParamsPanel(TL_NONE, "DetailsPanel", 200, items); mDetailsPanel->hide(); mDetailsPanel->setParamValue(9, "Bilinear"); mDetailsPanel->setParamValue(10, "Solid"); #ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM mDetailsPanel->setParamValue(11, "Off"); if (!mRoot->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_FIXED_FUNCTION)) { mDetailsPanel->setParamValue(11, "On"); } mDetailsPanel->setParamValue(12, "Vertex"); mDetailsPanel->setParamValue(13, "Low"); mDetailsPanel->setParamValue(14, "0"); mDetailsPanel->setParamValue(15, "0"); #endif }
Ogre::StringVector StringTokenise(const Ogre::String& str, const Ogre::String& delimiters, const Ogre::String& delimiters_preserve, const Ogre::String& quote, const Ogre::String& esc) { Ogre::StringVector ret; Ogre::String::size_type pos = 0; // the current position (char) in the string char ch = 0; // buffer for the current character char delimiter = 0; // the buffer for the delimiter char which // will be added to the tokens if the delimiter // is preserved char current_quote = 0; // the char of the current open quote bool quoted = false; // indicator if there is an open quote Ogre::String token; // string buffer for the token bool token_complete = false; // indicates if the current token is // read to be added to the result vector Ogre::String::size_type len = str.length(); // length of the input-string // for every char in the input-string while(len > pos) { // get the character of the string and reset the delimiter buffer ch = str.at(pos); delimiter = 0; // assume ch isn't a delimiter bool add_char = true; // check ... // ... if the delimiter is an escaped character bool escaped = false; // indicates if the next char is protected if(esc.empty() == false) // check if esc-chars are provided { if(esc.find_first_of(ch) != std::string::npos) { // get the escaped char ++pos; if(pos < len) // if there are more chars left { // get the next one ch = str.at(pos); // add the escaped character to the token add_char = true; } else // cannot get any more characters { // don't add the esc-char add_char = false; } // ignore the remaining delimiter checks escaped = true; } } // ... if the delimiter is a quote if(quote.empty() == false && escaped == false) { // if quote chars are provided and the char isn't protected if(quote.find_first_of(ch) != std::string::npos) { // if not quoted, set state to open quote and set // the quote character if(quoted == false) { quoted = true; current_quote = ch; // don't add the quote-char to the token add_char = false; } else // if quote is open already { // check if it is the matching character to close it if(current_quote == ch) { // close quote and reset the quote character quoted = false; current_quote = 0; // don't add the quote-char to the token add_char = false; } } } } // if the delimiter isn't preserved if(delimiters.empty() == false && escaped == false && quoted == false) { // if a delimiter is provided and the char isn't protected by // quote or escape char if(delimiters.find_first_of(ch) != std::string::npos) { // if ch is a delimiter and the token string isn't empty // the token is complete if(token.empty() == false) { token_complete = true; } // don't add the delimiter to the token add_char = false; } } // if the delimiter is preserved - add it as a token bool add_delimiter = false; if(delimiters_preserve.empty() == false && escaped == false && quoted == false) { // if a delimiter which will be preserved is provided and the // char isn't protected by quote or escape char if(delimiters_preserve.find_first_of(ch) != std::string::npos) { // if ch is a delimiter and the token string isn't empty the token is complete if(token.empty() == false) { token_complete = true; } // don't add the delimiter to the token add_char = false; // add the delimiter delimiter = ch; add_delimiter = true; } } // add the character to the token if(add_char == true) { // add the current char token.push_back(ch); } // add the token if it is complete if(token_complete == true && token.empty() == false) { // add the token string ret.push_back(token); // clear the contents token.clear(); // build the next token token_complete = false; } // add the delimiter if(add_delimiter == true) { // the next token is the delimiter Ogre::String delim_token; delim_token.push_back(delimiter); ret.push_back(delim_token); } // repeat for the next character ++pos; } // add the final token if(token.empty() == false) { ret.push_back(token); } return ret; }
void CLASS::Export(RigEditor::RigProperties* data) { data->m_title = m_editbox_title->getCaption(); data->m_guid = m_editbox_guid->getCaption(); bool has_uid = ! m_editbox_uid->getCaption().empty(); if (has_uid) { data->m_fileinfo.unique_id = m_editbox_uid->getCaption(); } data->m_fileinfo._has_unique_id = has_uid; bool has_category = ! m_textbox_category_id->getCaption().empty(); if (has_category) { data->m_fileinfo.category_id = PARSEUINT(m_textbox_category_id->getCaption()); } data->m_fileinfo._has_category_id = has_category; bool has_version = ! m_editbox_version->getCaption().empty(); if (has_version) { data->m_fileinfo.file_version = PARSEUINT(m_editbox_version->getCaption()); } data->m_fileinfo._has_file_version_set = has_version; // Description data->m_description.clear(); Ogre::String description_str = m_editbox_description->getCaption(); Ogre::StringUtil::trim(description_str); if (! description_str.empty()) { Ogre::StringVector lines = Ogre::StringUtil::split(description_str, "\r\n"); // Split over CR or LF for (auto itor = lines.begin(); itor != lines.end(); ++itor) { if (! itor->empty()) // Empty line? { std::string line = RoR::Utils::TrimBlanksAndLinebreaks(*itor); if (! line.empty()) { data->m_description.push_back(line); } } } } // Authors data->m_authors.clear(); Ogre::String authors_str = m_editbox_authors->getCaption(); Ogre::StringUtil::trim(authors_str); if (! authors_str.empty()) { Ogre::StringVector lines = Ogre::StringUtil::split(authors_str, "\n"); for (auto itor = lines.begin(); itor != lines.end(); ++itor) { Ogre::String line = *itor; Ogre::StringUtil::trim(line); if (line.empty()) { continue; } Ogre::StringVector tokens = Ogre::StringUtil::split(line, " \t"); RigDef::Author author; author.type = tokens[0]; if (tokens.size() > 1) { int account_id = PARSEINT(tokens[1]); if (account_id > -1) { author.forum_account_id = static_cast<unsigned int>(account_id); author._has_forum_account = true; } if (tokens.size() > 2) { author.name = tokens[2]; if (tokens.size() > 3) { author.email = tokens[3]; } } } data->m_authors.push_back(author); } } // Checkboxes data->m_hide_in_chooser = m_checkbox_hide_in_chooser->getStateSelected(); data->m_forward_commands = m_checkbox_forwardcommands->getStateSelected(); data->m_import_commands = m_checkbox_importcommands->getStateSelected(); data->m_is_rescuer = m_checkbox_rescuer->getStateSelected(); data->m_disable_default_sounds = m_checkbox_disable_default_sounds->getStateSelected(); data->m_enable_advanced_deformation = m_checkbox_use_advanced_deform->getStateSelected(); data->m_rollon = m_checkbox_rollon->getStateSelected(); // Section 'extcamera' RigDef::ExtCamera::Mode extcamera_mode = RigDef::ExtCamera::MODE_CLASSIC; extcamera_mode = m_radio_camera_behaviour_classic->getStateSelected() ? RigDef::ExtCamera::MODE_CLASSIC : extcamera_mode; extcamera_mode = m_radio_camera_behaviour_cinecam->getStateSelected() ? RigDef::ExtCamera::MODE_CINECAM : extcamera_mode; extcamera_mode = m_radio_camera_behaviour_node->getStateSelected() ? RigDef::ExtCamera::MODE_NODE : extcamera_mode; data->m_extcamera.mode = extcamera_mode; if (extcamera_mode == RigDef::ExtCamera::MODE_NODE) { std::string node_ref_str = m_editbox_extcamera_node->getCaption(); unsigned flags = Node::Ref::REGULAR_STATE_IS_VALID | Node::Ref::REGULAR_STATE_IS_NAMED; // Fileformatversion>=450 ~ Use named-only nodes data->m_extcamera.node = Node::Ref(node_ref_str, 0, flags, 0); } // Section 'set_skeleton_settings' data->m_skeleton_settings.beam_thickness_meters = PARSEREAL(m_editbox_beam_thickness_meters->getCaption()); data->m_skeleton_settings.visibility_range_meters = PARSEREAL(m_editbox_beam_visibility_range_meters->getCaption()); data->m_help_panel_material_name = m_editbox_help_panel_mat_name->getCaption(); data->m_globals_cab_material_name = m_editbox_cab_material_name->getCaption(); data->m_globals_dry_mass = PARSEREAL(m_editbox_dry_mass->getCaption()); data->m_globals_load_mass = PARSEREAL(m_editbox_load_mass->getCaption()); data->m_minimass = PARSEREAL(m_editbox_minimass->getCaption()); // Section 'guisettings' GuiSettings::MapMode minimap_mode = GuiSettings::MAP_MODE_OFF; minimap_mode = m_radio_guisettings_minimap_off->getStateSelected() ? GuiSettings::MAP_MODE_OFF : minimap_mode; minimap_mode = m_radio_guisettings_minimap_simple->getStateSelected() ? GuiSettings::MAP_MODE_SIMPLE : minimap_mode; minimap_mode = m_radio_guisettings_minimap_zoom->getStateSelected() ? GuiSettings::MAP_MODE_ZOOM : minimap_mode; data->m_gui_settings.interactive_overview_map_mode = minimap_mode; data->m_gui_settings.use_max_rpm = m_checkbox_guisettings_speedo_use_engine_max_rpm->getStateSelected(); data->m_gui_settings.help_material = m_editbox_guisettings_help_mat->getCaption(); data->m_gui_settings.speedo_highest_kph = PARSEUINT(m_editbox_guisettings_speedo_max->getCaption()); data->m_gui_settings.speedo_material = m_editbox_guisettings_speedo->getCaption(); data->m_gui_settings.tacho_material = m_editbox_guisettings_tacho->getCaption(); Ogre::String rtt_layouts_str = m_editbox_guisettings_rtt_dashboard_layout->getCaption(); Ogre::StringUtil::trim(rtt_layouts_str); if (! rtt_layouts_str.empty()) { Ogre::StringVector lines = Ogre::StringUtil::split(rtt_layouts_str, "\n"); for (auto itor = lines.begin(); itor != lines.end(); ++itor) { data->m_gui_settings.rtt_dashboard_layouts.push_back(*itor); } } Ogre::String dash_layouts_str = m_editbox_guisettings_rtt_dashboard_layout->getCaption(); Ogre::StringUtil::trim(dash_layouts_str); if (! dash_layouts_str.empty()) { Ogre::StringVector lines = Ogre::StringUtil::split(dash_layouts_str, "\n"); for (auto itor = lines.begin(); itor != lines.end(); ++itor) { data->m_gui_settings.dashboard_layouts.push_back(*itor); } } }
void Player::createFrameListener(){ Ogre::LogManager::getSingletonPtr()->logMessage("*** OIS Initalizing ***"); OIS::ParamList pl; size_t windowHnd = 0; std::ostringstream windowHndStr; //Get window info video.ogreWindow->getCustomAttribute("WINDOW",&windowHnd); windowHndStr << windowHnd; pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); //Start input manager mInputManager=OIS::InputManager::createInputSystem(pl); mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, true)); mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject(OIS::OISMouse, true)); mMouse->setEventCallback(this); mKeyboard->setEventCallback(this); //Set mouse clipping size video.windowResized(video.ogreWindow); //Set rotation variables mRotate = 0.13; bRotate = 1.0; mMove = 200; mDirection = Ogre::Vector3::ZERO; //Register window listener Ogre::WindowEventUtilities::addWindowEventListener(video.ogreWindow, this); if(gui.usingCG == true){ } else { //Set input context for GUI inputContex.mMouse = mMouse; inputContex.mKeyboard = mKeyboard; //Create Interface and show debug info video.mTrayMgr->showFrameStats(OgreBites::TL_BOTTOMLEFT); //Show FPS //Hide cursor video.mTrayMgr->hideCursor(); hideCursor = true; // create a params panel for displaying sample details Ogre::StringVector items; items.push_back("cam.pX"); items.push_back("cam.pY"); items.push_back("cam.pZ"); items.push_back(""); items.push_back("cam.oW"); items.push_back("cam.oX"); items.push_back("cam.oY"); items.push_back("cam.oZ"); items.push_back(""); items.push_back("Filtering"); items.push_back("Poly Mode"); video.mDetailsPanel = video.mTrayMgr->createParamsPanel(OgreBites::TL_NONE, "DetailsPanel", 200, items); video.mDetailsPanel->setParamValue(9, "Bilinear"); video.mDetailsPanel->setParamValue(10, "Solid"); video.mDetailsPanel->hide(); } video.ogreRoot->addFrameListener(mainListener); //Populate camera container mCamNode = playerCamera->getParentSceneNode()->getParentSceneNode(); }
//---------------------------------------------------------------------------- Ogre::StringVector AngelScriptInterpreter::runScript(std::string §ion, std::string &file) { Ogre::StringVector ret; //CDebugger* dbg = 0; int r = mBuilder->StartNewModule(mEngine, section.c_str()); if( r < 0 ) { // If the code fails here it is usually because there // is no more memory to allocate the module return ret; } if(file.substr(0,5) == "proj:") { file.erase(0,5); OFS::OFSHANDLE fHandle; OFS::OfsPtr& ofsFile = OgitorsRoot::getSingletonPtr()->GetProjectFile(); if(ofsFile->openFile(fHandle, file.c_str()) == OFS::OFS_OK) { char *contents; OFS::ofs64 file_size = 0; ofsFile->getFileSize(fHandle, file_size); if(file_size > 0) { contents = new char[(unsigned int)file_size + 1]; ofsFile->read(fHandle, contents, (unsigned int)file_size); contents[file_size] = 0; r = mBuilder->AddSectionFromMemory(contents, file.c_str()); delete [] contents; } else r = -1; ofsFile->closeFile(fHandle); } else r = -1; } else r = mBuilder->AddSectionFromFile(file.c_str()); if( r < 0 ) { // The builder wasn't able to load the file. Maybe the file // has been removed, or the wrong name was given, or some // preprocessing commands are incorrectly written. ret.push_back("The script file can not be found."); return ret; } int errpos; { OGRE_LOCK_AUTO_MUTEX; errpos = mBuffer.size(); } r = mBuilder->BuildModule(); if( r < 0 ) { // An error occurred. Instruct the script writer to fix the // compilation errors that were listed in the output stream. OGRE_LOCK_AUTO_MUTEX; for(unsigned int i = errpos;i < mBuffer.size();i++) { char buf[1000]; sprintf(buf,"Row: %d, Col: %d :: %s", mBuffer[i].mRow, mBuffer[i].mCol, mBuffer[i].mMessage.c_str()); ret.push_back(Ogre::String(buf)); } ret.push_back("Please correct the errors in the script and try again."); return ret; } // Find the function that is to be called. asIScriptModule *mod = mEngine->GetModule(section.c_str()); asIScriptFunction *funcId = mod->GetFunctionByDecl("void main()"); if( funcId == NULL ) { // The function couldn't be found. Instruct the script writer // to include the expected function in the script. ret.push_back("The script must have the function 'void main()'. Please add it and try again."); return ret; } // Create our context, prepare it, and then execute asIScriptContext *ctx = mEngine->CreateContext(); //dbg = new CDebugger(); //dbg->TakeCommands(ctx); //ctx->SetLineCallback(asMETHOD(CDebugger, LineCallback), dbg, asCALL_THISCALL); ctx->SetExceptionCallback(asFUNCTION(ExceptionCallback), this, asCALL_CDECL); ctx->Prepare(funcId); ContextDef def; def.context = ctx; def.module = mod; def.funcID = funcId; def.sleep = 0.0f; def.delay = 0.0f; mActiveContext = &def; r = ctx->Execute(); if( r != asEXECUTION_FINISHED ) { // The execution didn't complete as expected. Determine what happened. if( r == asEXECUTION_EXCEPTION ) { // An exception occurred, let the script writer know what happened so it can be corrected. ret.push_back("An exception '" + std::string(ctx->GetExceptionString()) + "' occurred. Please correct the code and try again."); } } mActiveContext = 0; ctx->Release(); //delete dbg; return ret; }
//----------------------------------------------------------------------- void TerrainTypeInfos::parseTerrainTypeConfigFile(const Ogre::String& filename) { mTextureNameTerrainTypeMap.clear(); mTerrainTypeEffectMap.clear(); Ogre::ConfigFile cf; cf.load(filename); // Go through all sections & settings in the file Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); Ogre::String secName, texNames, effectNames; while (seci.hasMoreElements()) { secName = seci.peekNextKey(); seci.getNext(); if (secName.empty()) continue; TerrainTypeMap::const_iterator terrainTypeIterator = mTerrainTypeMap.find(secName); if (terrainTypeIterator == mTerrainTypeMap.end()) { Ogre::LogManager::getSingleton().logMessage("can't find the terrain type! TerrainTypeInfos::parseTerrainTypeConfigFile"); continue; } TerrainType terrainType = terrainTypeIterator->second; texNames = cf.getSetting("texture", secName); effectNames = cf.getSetting("effect", secName); //if (texNames.empty()) //{ // Ogre::LogManager::getSingleton().logMessage("texture names is empty! TerrainTypeInfos::parseTerrainTypeConfigFile"); //// continue; //} //else // 如果有纹理名称,就解析(像liquid这种是不需要定义纹理名称的) if (false == texNames.empty()) { Ogre::StringVector texNameArray = Ogre::StringUtil::split(texNames); for (size_t texNameIndex = 0; texNameIndex < texNameArray.size(); ++texNameIndex) { mTextureNameTerrainTypeMap.insert( TextureNameTerrainTypeMap::value_type(texNameArray[texNameIndex], terrainType) ); } } // 解析特效描述 if (effectNames.empty()) { Ogre::LogManager::getSingleton().logMessage("effect names is empty! TerrainTypeInfos::parseTerrainTypeConfigFile"); continue; } EffectTemplateList effectTemplateList; Ogre::StringVector effectNameArray = Ogre::StringUtil::split(effectNames); for (size_t effectNameIndex = 0; effectNameIndex < effectNameArray.size(); ++effectNameIndex) { Ogre::String str = effectNameArray[effectNameIndex]; Ogre::StringVector effectDefine = Ogre::StringUtil::split(str,":"); if (effectDefine.size() != 2) { Ogre::LogManager::getSingleton().logMessage("the effect define line is wrong! TerrainTypeInfos::parseTerrainTypeConfigFile"); continue; } EffectTemplate effectTemplate; effectTemplate.mEffectName = effectDefine[0]; effectTemplate.mTemplateName = effectDefine[1]; effectTemplateList.push_back(effectTemplate); } // 插入这种地形所对应的特效名称 mTerrainTypeEffectMap.insert( TerrainTypeEffectMap::value_type(terrainType, effectTemplateList) ); } }
void CameraTrackSettingDialog::OnLoadTrack(wxCommandEvent& event) { wxFileDialog fileDialog(this, _("Load track file"), "", "", "Track files (*.track)|*.track", wxOPEN | wxFILE_MUST_EXIST); if (fileDialog.ShowModal() != wxID_OK) return; // 先清除当前的轨迹 ClearTrack(); std::ifstream stream; stream.open( fileDialog.GetPath().c_str() ); if (stream) { Ogre::DataStreamPtr ifStream( new Ogre::FileStreamDataStream(&stream, false) ); Ogre::String line; line = ifStream->getAsString(); Ogre::StringVector paras = Ogre::StringUtil::split(line, ","); if (paras.size() >= 2) { float length = Ogre::StringConverter::parseReal(paras[0]); if (!mCameraNode) { mCameraNode = mSceneManipulator->getBaseSceneNode()->createChildSceneNode(); } if (mTrackClear) { mCameraAnimation = mSceneManipulator->getSceneManager()->createAnimation("CameraTrack", length); // Spline it for nice curves mCameraAnimation->setInterpolationMode(Ogre::Animation::IM_SPLINE); // Create a track to animate the camera's node mCameraTrack = mCameraAnimation->createNodeTrack(0, mCameraNode); mCameraAnimState = mSceneManipulator->getSceneManager()->createAnimationState("CameraTrack"); mTrackClear = false; } unsigned int keyCount = Ogre::StringConverter::parseUnsignedInt(paras[1]); for (unsigned int i=0; i<keyCount; ++i) { Ogre::Vector3 pos = Ogre::StringConverter::parseVector3(paras[2 + i*3]); Ogre::Quaternion ori = Ogre::StringConverter::parseQuaternion(paras[3 + i*3]); float time = Ogre::StringConverter::parseReal(paras[4 + i*3]); Ogre::TransformKeyFrame* key = mCameraTrack->createNodeKeyFrame(time); // startposition key->setTranslate(pos); key->setRotation(ori); } RefreshCodeText(); } } }