void RaceDialog::open() { WindowModal::open(); updateRaces(); updateSkills(); updateSpellPowers(); mPreview = new MWRender::RaceSelectionPreview(); mPreview->setup(); mPreview->update (0); const ESM::NPC proto = mPreview->getPrototype(); setRaceId(proto.mRace); recountParts(); std::string index = proto.mHead.substr(proto.mHead.size() - 2, 2); mFaceIndex = boost::lexical_cast<int>(index) - 1; index = proto.mHair.substr(proto.mHair.size() - 2, 2); mHairIndex = boost::lexical_cast<int>(index) - 1; mPreviewImage->setImageTexture ("CharacterHeadPreview"); mPreviewDirty = true; }
void RaceDialog::onOpen() { WindowModal::onOpen(); updateRaces(); updateSkills(); updateSpellPowers(); mPreviewImage->setRenderItemTexture(nullptr); mPreview.reset(nullptr); mPreviewTexture.reset(nullptr); mPreview.reset(new MWRender::RaceSelectionPreview(mParent, mResourceSystem)); mPreview->rebuild(); mPreview->setAngle (mCurrentAngle); mPreviewTexture.reset(new osgMyGUI::OSGTexture(mPreview->getTexture())); mPreviewImage->setRenderItemTexture(mPreviewTexture.get()); mPreviewImage->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f)); const ESM::NPC& proto = mPreview->getPrototype(); setRaceId(proto.mRace); setGender(proto.isMale() ? GM_Male : GM_Female); recountParts(); for (unsigned int i=0; i<mAvailableHeads.size(); ++i) { if (Misc::StringUtils::ciEqual(mAvailableHeads[i], proto.mHead)) mFaceIndex = i; } for (unsigned int i=0; i<mAvailableHairs.size(); ++i) { if (Misc::StringUtils::ciEqual(mAvailableHairs[i], proto.mHair)) mHairIndex = i; } mPreviewDirty = true; size_t initialPos = mHeadRotate->getScrollRange()/2+mHeadRotate->getScrollRange()/10; mHeadRotate->setScrollPosition(initialPos); onHeadRotate(mHeadRotate, initialPos); MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mRaceList); }
void RaceDialog::open() { WindowModal::open(); updateRaces(); updateSkills(); updateSpellPowers(); mPreview.reset(NULL); mPreviewImage->setImageTexture(""); const std::string textureName = "CharacterHeadPreview"; MyGUI::RenderManager::getInstance().destroyTexture(MyGUI::RenderManager::getInstance().getTexture(textureName)); mPreview.reset(new MWRender::RaceSelectionPreview()); mPreview->setup(); mPreview->update (mCurrentAngle); const ESM::NPC proto = mPreview->getPrototype(); setRaceId(proto.mRace); recountParts(); for (unsigned int i=0; i<mAvailableHeads.size(); ++i) { if (mAvailableHeads[i] == proto.mHead) mFaceIndex = i; } for (unsigned int i=0; i<mAvailableHairs.size(); ++i) { if (mAvailableHairs[i] == proto.mHair) mHairIndex = i; } mPreviewImage->setImageTexture (textureName); mPreviewDirty = true; size_t initialPos = mHeadRotate->getScrollRange()/2+mHeadRotate->getScrollRange()/10; mHeadRotate->setScrollPosition(initialPos); onHeadRotate(mHeadRotate, initialPos); }