BirthDialog::BirthDialog() : WindowModal("openmw_chargen_birth.layout") { // Centre dialog center(); getWidget(mSpellArea, "SpellArea"); getWidget(mBirthImage, "BirthsignImage"); getWidget(mBirthList, "BirthsignList"); mBirthList->setScrollVisible(true); mBirthList->eventListSelectAccept += MyGUI::newDelegate(this, &BirthDialog::onAccept); mBirthList->eventListChangePosition += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); MyGUI::Button* backButton; getWidget(backButton, "BackButton"); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onBackClicked); MyGUI::Button* okButton; getWidget(okButton, "OKButton"); okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onOkClicked); updateBirths(); updateSpells(); }
void SceneObjectPanel::notifyStateChanged(MyGUI::Widget* _sender) { if(mPickableObj == nullptr) return; MyGUI::Button *btn = static_cast<MyGUI::Button*>(_sender); std::string btnName = btn->getName(); btnName = btnName.substr(mPrefix.length(),btnName.length() - mPrefix.length()); if(btnName == "RB_FIX_XAXIS") { *mIsXFixed = !(*mIsXFixed); btn->setStateSelected((*mIsXFixed)); } else if(btnName == "RB_FIX_YAXIS") { *mIsYFixed = !(*mIsYFixed); btn->setStateSelected((*mIsYFixed)); } else { *mIsZFixed = !(*mIsZFixed); btn->setStateSelected((*mIsZFixed)); } }
void SceneObjectPanel::notifyRotationChange(MyGUI::Widget* _sender) { if(mPickableObj == nullptr) return; MyGUI::Button* btn = static_cast<MyGUI::Button*>(_sender); //TODO: change compare to AnyData injected in the widget later std::string btnName = btn->getName(); btnName = btnName.substr(mPrefix.length(),btnName.length() - mPrefix.length()); if(btnName == "BT_ROTATE_Y_LEFT") { *mRotateAngleY -= 1; std::string str = Ogre::StringConverter::toString(*mRotateAngleY); mEditBoxRotateY->setCaption(str); } else if(btnName == "BT_ROTATE_Y_RIGHT") { *mRotateAngleY += 1; std::string str = Ogre::StringConverter::toString(*mRotateAngleY); mEditBoxRotateY->setCaption(str); } mPickableObj->applyOperation(1); }
void GUIManager::addButtons(TiXmlNode* buttons_node, float* values, MyGUI::Window* w) { for(TiXmlNode* button_node = buttons_node->FirstChild("button"); button_node; button_node = button_node->NextSibling()) { std::string name_text = GameManager::textFromChildNode(button_node, "name"); std::string caption_text = GameManager::textFromChildNode(button_node, "caption"); std::string skin_text = GameManager::textFromChildNode(button_node, "skin"); std::string position_text = GameManager::textFromChildNode(button_node, "position"); GameManager::parseFloats(position_text, values); uint32 left = (uint32) values[0]; uint32 top = (uint32) values[1]; std::string size_text = GameManager::textFromChildNode(button_node, "size"); GameManager::parseFloats(size_text, values); uint32 width = (uint32) values[0]; uint32 height = (uint32) values[1]; std::string file_name_text = GameManager::textFromChildNode(button_node, "file_name"); std::string script_name_text = GameManager::textFromChildNode(button_node, "script_name"); std::string font_size_text = GameManager::textFromChildNode(button_node, "font"); uint32 font_size = (uint32) GameManager::parseFloat(font_size_text); MyGUI::Button* b = w->createWidget<MyGUI::Button>(skin_text, left, top, width, height, MyGUI::Align::Default, name_text); b->setCaption(caption_text); b->setFontHeight(font_size); b->setTextColour(MyGUI::Colour(0,0,0)); b->eventMouseButtonPressed += newDelegate(this, &GUIManager::buttonGUIDelegate); GUIWidgetScript* widget_script = new GUIWidgetScript(b, name_text); widget_script->setFileName(file_name_text); widget_script->setScriptName(script_name_text); all_widgets->tableInsert(widget_script); } }
/*向界面中加入数据相 */ void SimpleDataUI::add( const MyGUI::UString& caption,SimpleData sd ){ MyGUI::TextBox* pt = mParent->createWidget<MyGUI::TextBox>( "TextBox",MyGUI::IntCoord(), MyGUI::Align::Left|MyGUI::Align::Top); pt->setTextAlign( MyGUI::Align::Right ); pt->setCaption( caption ); pt->setUserData( MyGUI::Any(string("@")) ); //打一个标记为删除做准备 if( sd.type==SimpleData::BOOL ){ MyGUI::Button* pe = mParent->createWidget<MyGUI::Button>( "CheckBox",MyGUI::IntCoord(), MyGUI::Align::Left|MyGUI::Align::Top); pe->setStateSelected(sd.b); sd.change = mep; pe->setUserData(MyGUI::Any(sd)); pe->eventMouseButtonClick += newDelegate(_simpleDataCheckChange); }else if( sd.sv.empty() ){//编辑 MyGUI::EditBox* pe = mParent->createWidget<MyGUI::EditBox>( "EditBox",MyGUI::IntCoord(), MyGUI::Align::Left|MyGUI::Align::Top); if( sd.type== SimpleData::STRING ) pe->setCaption( sd.str ); else if( sd.type== SimpleData::REAL) { pe->setCaption( (boost::format("%.2f")%sd.real).str() ); } sd.change = mep; pe->setUserData(MyGUI::Any(sd)); //数据改变 pe->eventEditTextChange += newDelegate(_simpleDataEditTextChange); }else{//有可选数据 MyGUI::ComboBox* pc = mParent->createWidget<MyGUI::ComboBox>( "ComboBox",MyGUI::IntCoord(), MyGUI::Align::Left|MyGUI::Align::Top); if( sd.type== SimpleData::STRING ) pc->setCaption( sd.str ); else if( sd.type== SimpleData::REAL ) pc->setCaption( boost::lexical_cast<string>(sd.real) ); for( vector<MyGUI::UString>::const_iterator i = sd.sv.begin(); i!=sd.sv.end();++i){ pc->addItem(*i); if( *i == sd.str ){ if( sd.type== SimpleData::STRING ) pc->setEditStatic(true); pc->setIndexSelected(i-sd.sv.begin()); } } sd.change = mep; pc->setUserData(MyGUI::Any(sd)); //数据改变 pc->eventComboChangePosition += newDelegate(_simpleDataChange); } }
void RigEditorCommands2Panel::CallbackClick_NeedsEngineChekckbox(MyGUI::Widget* sender) { // Clear "mixed values" state m_needs_engine_checkbox->setTextColour(m_text_color_default); m_data.SetNeedsEngineIsUniform(true); // Update data MyGUI::Button* button = sender->castType<MyGUI::Button>(); m_data.SetBoolNeedsEngine(button->getStateSelected()); }
void SimpleUI::checkItem( const string& name,bool b ) { try{ MyGUI::Button * c = operator [](name)->castType<MyGUI::Button>(false); if( c ) c->setStateSelected( b ); }catch( out_of_range& e ){ WARNING_LOG(e.what()); } }
void TextInputDialog::setNextButtonShow(bool shown) { MyGUI::Button* okButton; getWidget(okButton, "OKButton"); if (shown) okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", "")); else okButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", "")); }
void ListBox::notifyCreateWidgetItem(MyGUI::ListCtrl* _sender, MyGUI::Widget* _item) { const MyGUI::IntSize& size = _item->getSize(); MyGUI::Button* text = _item->createWidget<MyGUI::Button>(mSkinLine, MyGUI::IntCoord(0, 0, size.width, size.height), MyGUI::Align::Stretch); text->setNeedMouseFocus(false); _item->setUserData(text); }
//数据发生改变 void Game::simpleDataChange(SimpleData* psd){ assert( psd ); try{ mNeedReset = true; MyGUI::Button* pb = mUI["Apply"]->castType<MyGUI::Button>(false); if( pb )pb->setStateSelected(true); }catch( out_of_range& e ){ WARNING_LOG(e.what()); } }
void WidgetsWindow::requestDrawItem(MyGUI::ItemBox* _sender, MyGUI::Widget* _item, const MyGUI::IBDrawItemInfo& _info) { MyGUI::Button* button = *_item->getUserData<MyGUI::Button*>(); SkinInfo data = *_sender->getItemDataAt<SkinInfo>(_info.index); if (_info.update) { button->setCaption(data.widget_button_name); } button->setStateSelected(_info.select); }
void ToolControl::requestCreateObjectItem(MyGUI::ItemBox* _sender, MyGUI::Widget* _item) { MyGUI::Button* button = _item->createWidget<MyGUI::Button>("Button", MyGUI::IntCoord(0, 0, _item->getWidth(), _item->getHeight()), MyGUI::Align::Stretch); button->setTextAlign(MyGUI::Align::Center); button->eventMouseButtonClick += MyGUI::newDelegate(this, &ToolControl::notifySelectObjectType); //button->setNeedToolTip(true); //button->eventToolTip += MyGUI::newDelegate(this, &ToolControl::notifyToolTip); _item->setUserData(button); }
/////////////////// <BOOL CONTROL> void PropertyGridManager::buildBoolControl(MyGUI::Widget *const control, PropertyGridProperty *const property) { int left = insertPropertyIdLabel(control, property) + WIDGET_SPACING; int size = control->getClientCoord().height; MyGUI::IntCoord coord(left, 0, size, size); MyGUI::Button *checkbox = (MyGUI::Button *)control->createWidget<MyGUI::Button>("CheckBox", coord, MyGUI::Align::Left | MyGUI::Align::VCenter, "CheckBox"); checkbox->setEnabled(!property->isReadOnly()); checkbox->setUserData(property); checkbox->eventMouseButtonClick += MyGUI::newDelegate(this, &PropertyGridManager::onMyGUIMouseButtonClickForCheckboxToggle); }
void ToolControl::requestDrawItem(MyGUI::ItemBox* _sender, MyGUI::Widget* _item, const MyGUI::IBDrawItemInfo& _info) { MyGUI::Button* button = *_item->getUserData<MyGUI::Button*>(); ShapeFactory * sf = *_sender->getItemDataAt<ShapeFactory*>(_info.index); if (_info.update) { button->setCaption(sf->GetTypeName()); } //button->setStateSelected(_info.select); }
void PropertyGridManager::updateBoolControlValue(MyGUI::Widget *const control, PropertyGridProperty *const property) { MyGUI::Button *checkbox = (MyGUI::Button *)control->findWidget("CheckBox"); if(nullptr == checkbox) { Debug::error(STEEL_METH_INTRO, "could not find checkbox button in bool propertyControl. Control: ", control, " property: ", *property, ". Aborting.").endl(); return; } bool checked = false; property->read(checked); checkbox->setStateSelected(checked); }
void SpellBuyingWindow::addSpell(const std::string& spellId) { const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId); int price = spell->mData.mCost*store.get<ESM::GameSetting>().find("fSpellValueMult")->getFloat(); price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId); MyGUI::Button* toAdd = mSpellsView->createWidget<MyGUI::Button>( "SandTextButton", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default ); toAdd->setEnabled(price<=playerGold); mCurrentY += sLineHeight; toAdd->setUserData(price); toAdd->setCaptionWithReplacing(spell->mName+" - "+boost::lexical_cast<std::string>(price)+"#{sgp}"); toAdd->setSize(toAdd->getTextSize().width,sLineHeight); toAdd->eventMouseWheel += MyGUI::newDelegate(this, &SpellBuyingWindow::onMouseWheel); toAdd->setUserString("ToolTipType", "Spell"); toAdd->setUserString("Spell", spellId); toAdd->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellBuyingWindow::onSpellButtonClick); mSpellsWidgetMap.insert(std::make_pair (toAdd, spellId)); }
/*BOOL型数据改变 Check */ static void _simpleDataCheckChange(MyGUI::Widget* _sender){ MyGUI::Button* sender = _sender->castType<MyGUI::Button>(false); if( sender ){ SimpleData* psd = sender->getUserData<SimpleData>(false); sender->setStateSelected(!sender->getStateSelected()); if( psd ){ if( psd->type==SimpleData::BOOL ){ psd->b = sender->getStateSelected(); } if( psd->change ) psd->change->invoke(psd); } } }
void TravelWindow::addDestination(const std::string& name, ESM::Position pos, bool interior) { int price; const MWWorld::Store<ESM::GameSetting> &gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr(); int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId); if (!mPtr.getCell()->isExterior()) { price = gmst.find("fMagesGuildTravel")->mValue.getInteger(); } else { ESM::Position PlayerPos = player.getRefData().getPosition(); float d = sqrt(pow(pos.pos[0] - PlayerPos.pos[0], 2) + pow(pos.pos[1] - PlayerPos.pos[1], 2) + pow(pos.pos[2] - PlayerPos.pos[2], 2)); price = static_cast<int>(d / gmst.find("fTravelMult")->mValue.getFloat()); } price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, price, true); // Add price for the travelling followers std::set<MWWorld::Ptr> followers; MWWorld::ActionTeleport::getFollowersToTeleport(player, followers); // Apply followers cost, in vanilla one follower travels for free if (Settings::Manager::getBool("charge for every follower travelling", "Game")) price *= 1 + static_cast<int>(followers.size()); else price *= std::max(1, static_cast<int>(followers.size())); int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2; MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>("SandTextButton", 0, mCurrentY, 200, lineHeight, MyGUI::Align::Default); toAdd->setEnabled(price <= playerGold); mCurrentY += lineHeight; if(interior) toAdd->setUserString("interior","y"); else toAdd->setUserString("interior","n"); std::ostringstream oss; oss << price; toAdd->setUserString("price",oss.str()); toAdd->setCaptionWithReplacing("#{sCell=" + name + "} - " + MyGUI::utility::toString(price)+"#{sgp}"); toAdd->setSize(mDestinationsView->getWidth(),lineHeight); toAdd->eventMouseWheel += MyGUI::newDelegate(this, &TravelWindow::onMouseWheel); toAdd->setUserString("Destination", name); toAdd->setUserData(pos); toAdd->eventMouseButtonClick += MyGUI::newDelegate(this, &TravelWindow::onTravelButtonClick); }
void SceneObjectPanel::notifyScaleChange(MyGUI::Widget* _sender) { if(mPickableObj == nullptr) return; MyGUI::Button* btn = static_cast<MyGUI::Button*>(_sender); //TODO: change compare to AnyData injected in the widget later std::string btnName = btn->getName(); btnName = btnName.substr(mPrefix.length(),btnName.length() - mPrefix.length()); if(btnName == "BT_SCALE_X_RIGHT") { mScale->x += 1; std::string str = Ogre::StringConverter::toString(mScale->x); mEditBoxScaleX->setCaption(str); } else if(btnName == "BT_SCALE_X_LEFT") { mScale->x -= 1; std::string str = Ogre::StringConverter::toString(mScale->x); mEditBoxScaleX->setCaption(str); } else if(btnName == "BT_SCALE_Y_LEFT") { mScale->y -= 1; std::string str = Ogre::StringConverter::toString(mScale->y); mEditBoxScaleY->setCaption(str); } else if(btnName == "BT_SCALE_Y_RIGHT") { mScale->y += 1; std::string str = Ogre::StringConverter::toString(mScale->y); mEditBoxScaleY->setCaption(str); } else if(btnName == "BT_SCALE_Z_LEFT") { mScale->z -= 1; std::string str = Ogre::StringConverter::toString(mScale->z); mEditBoxScaleZ->setCaption(str); } else if(btnName == "BT_SCALE_Z_RIGHT") { mScale->z += 1; std::string str = Ogre::StringConverter::toString(mScale->z); mEditBoxScaleZ->setCaption(str); } mPickableObj->applyOperation(0); }
void WidgetsWindow::requestCreateWidgetItem(MyGUI::ItemBox* _sender, MyGUI::Widget* _item) { MyGUI::Button* button = _item->createWidget<MyGUI::Button>(mButtonSkinName, MyGUI::IntCoord( mWidgetsButtonOffset, mWidgetsButtonOffset, _item->getWidth() - mWidgetsButtonOffset - mWidgetsButtonOffset, _item->getHeight() - mWidgetsButtonOffset - mWidgetsButtonOffset), MyGUI::Align::Stretch); button->setTextAlign(MyGUI::Align::Center); button->eventMouseButtonClick += MyGUI::newDelegate(this, &WidgetsWindow::notifySelectWidgetType); button->setNeedToolTip(true); button->eventToolTip += MyGUI::newDelegate(this, &WidgetsWindow::notifyToolTip); _item->setUserData(button); }
void EffectEditorBase::updateEffectsView () { MyGUI::EnumeratorWidgetPtr oldWidgets = mUsedEffectsView->getEnumerator (); MyGUI::Gui::getInstance ().destroyWidgets (oldWidgets); MyGUI::IntSize size(0,0); int i = 0; for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) { Widgets::SpellEffectParams params; params.mEffectID = it->mEffectID; params.mSkill = it->mSkill; params.mAttribute = it->mAttribute; params.mDuration = it->mDuration; params.mMagnMin = it->mMagnMin; params.mMagnMax = it->mMagnMax; params.mRange = it->mRange; params.mArea = it->mArea; params.mIsConstant = mConstantEffect; MyGUI::Button* button = mUsedEffectsView->createWidget<MyGUI::Button>("", MyGUI::IntCoord(0, size.height, 0, 24), MyGUI::Align::Default); button->setUserData(i); button->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onEditEffect); button->setNeedMouseFocus (true); Widgets::MWSpellEffectPtr effect = button->createWidget<Widgets::MWSpellEffect>("MW_EffectImage", MyGUI::IntCoord(0,0,0,24), MyGUI::Align::Default); effect->setNeedMouseFocus (false); effect->setSpellEffect (params); effect->setSize(effect->getRequestedWidth (), 24); button->setSize(effect->getRequestedWidth (), 24); size.width = std::max(size.width, effect->getRequestedWidth ()); size.height += 24; ++i; } // Canvas size must be expressed with HScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden mUsedEffectsView->setVisibleHScroll(false); mUsedEffectsView->setCanvasSize(size); mUsedEffectsView->setVisibleHScroll(true); notifyEffectsChanged(); }
void SpellBuyingWindow::addSpell(const std::string& spellId) { const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); int price = spell->mData.mCost*MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fSpellValueMult")->getFloat(); MyGUI::Button* toAdd = mSpellsView->createWidget<MyGUI::Button>( (price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SpellText", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default ); mCurrentY += sLineHeight; /// \todo price adjustment depending on merchantile skill toAdd->setUserData(price); toAdd->setCaptionWithReplacing(spell->mName+" - "+boost::lexical_cast<std::string>(price)+"#{sgp}"); toAdd->setSize(toAdd->getTextSize().width,sLineHeight); toAdd->eventMouseWheel += MyGUI::newDelegate(this, &SpellBuyingWindow::onMouseWheel); toAdd->setUserString("ToolTipType", "Spell"); toAdd->setUserString("Spell", spellId); toAdd->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellBuyingWindow::onSpellButtonClick); mSpellsWidgetMap.insert(std::make_pair (toAdd, spellId)); }
void MWList::redraw(bool scrollbarShown) { const int _scrollBarWidth = 20; // fetch this from skin? const int scrollBarWidth = scrollbarShown ? _scrollBarWidth : 0; const int spacing = 3; size_t viewPosition = -mScrollView->getViewOffset().top; while (mScrollView->getChildCount()) { MyGUI::Gui::getInstance().destroyWidget(mScrollView->getChildAt(0)); } mItemHeight = 0; int i=0; for (std::vector<std::string>::const_iterator it=mItems.begin(); it!=mItems.end(); ++it) { if (*it != "") { MyGUI::Button* button = mScrollView->createWidget<MyGUI::Button>( "MW_ListLine", MyGUI::IntCoord(0, mItemHeight, mScrollView->getSize().width - scrollBarWidth - 2, 24), MyGUI::Align::Left | MyGUI::Align::Top, getName() + "_item_" + (*it)); button->setCaption((*it)); button->getSubWidgetText()->setWordWrap(true); button->getSubWidgetText()->setTextAlign(MyGUI::Align::Left); button->eventMouseWheel += MyGUI::newDelegate(this, &MWList::onMouseWheel); button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWList::onItemSelected); int height = button->getTextSize().height; button->setSize(MyGUI::IntSize(button->getSize().width, height)); button->setUserData(i); mItemHeight += height + spacing; } else { MyGUI::ImageBox* separator = mScrollView->createWidget<MyGUI::ImageBox>("MW_HLine", MyGUI::IntCoord(2, mItemHeight, mScrollView->getWidth() - scrollBarWidth - 4, 18), MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch); separator->setNeedMouseFocus(false); mItemHeight += 18 + spacing; } ++i; } mScrollView->setCanvasSize(mClient->getSize().width, std::max(mItemHeight, mClient->getSize().height)); if (!scrollbarShown && mItemHeight > mClient->getSize().height) redraw(true); size_t viewRange = mScrollView->getCanvasSize().height; if(viewPosition > viewRange) viewPosition = viewRange; mScrollView->setViewOffset(MyGUI::IntPoint(0, -viewPosition)); }
void PropertyGridManager::onMyGUIMouseButtonClickForCheckboxToggle(MyGUI::Widget *button) { MyGUI::Button *checkbox = button->castType<MyGUI::Button>(); PropertyGridProperty *const property = *(button->getUserData<PropertyGridProperty *>()); if(nullptr == property) { Debug::error(STEEL_METH_INTRO, "no property linked to control ", button->getParent()).endl().breakHere(); return; } bool const currentState = checkbox->getStateSelected(); if(PropertyGridPropertyValueType::Bool == property->valueType()) property->write(!currentState); else Debug::error(STEEL_METH_INTRO, "got a checkbox event for property ", *property, ". Skipping event.").endl(); }
void KeyboardPanel::notifyMouseButtonClick(MyGUI::Widget* _sender) { MyGUI::Button* button = _sender->castType<MyGUI::Button>(); bool selected = button->getStateSelected(); if (selected) { button->setStateSelected(false); CommandManager::getInstance().execiteCommand("KeyboardClick", std::string(mMainWidget->getUserString("Command"))); } else { mButtonEngine->setStateSelected(false); mButtonGun->setStateSelected(false); mButtonAmmo->setStateSelected(false); mButtonArmor->setStateSelected(false); button->setStateSelected(true); CommandManager::getInstance().execiteCommand("KeyboardClick", std::string(button->getUserString("Command"))); } }
void EffectEditorBase::updateEffectsView () { MyGUI::EnumeratorWidgetPtr oldWidgets = mUsedEffectsView->getEnumerator (); MyGUI::Gui::getInstance ().destroyWidgets (oldWidgets); MyGUI::IntSize size(0,0); int i = 0; for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) { Widgets::SpellEffectParams params; params.mEffectID = it->mEffectID; params.mSkill = it->mSkill; params.mAttribute = it->mAttribute; params.mDuration = it->mDuration; params.mMagnMin = it->mMagnMin; params.mMagnMax = it->mMagnMax; params.mRange = it->mRange; params.mArea = it->mArea; MyGUI::Button* button = mUsedEffectsView->createWidget<MyGUI::Button>("", MyGUI::IntCoord(0, size.height, 0, 24), MyGUI::Align::Default); button->setUserData(i); button->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onEditEffect); button->setNeedMouseFocus (true); Widgets::MWSpellEffectPtr effect = button->createWidget<Widgets::MWSpellEffect>("MW_EffectImage", MyGUI::IntCoord(0,0,0,24), MyGUI::Align::Default); effect->setNeedMouseFocus (false); effect->setWindowManager (MWBase::Environment::get().getWindowManager ()); effect->setSpellEffect (params); effect->setSize(effect->getRequestedWidth (), 24); button->setSize(effect->getRequestedWidth (), 24); size.width = std::max(size.width, effect->getRequestedWidth ()); size.height += 24; ++i; } mUsedEffectsView->setCanvasSize(size); notifyEffectsChanged(); }
void TravelWindow::addDestination(const std::string& name,ESM::Position pos,bool interior) { int price = 0; const MWWorld::Store<ESM::GameSetting> &gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr(); int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId); if(interior) { price = gmst.find("fMagesGuildTravel")->getFloat(); } else { ESM::Position PlayerPos = player.getRefData().getPosition(); float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) ); price = d/gmst.find("fTravelMult")->getFloat(); } price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true); MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>("SandTextButton", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default); toAdd->setEnabled(price<=playerGold); mCurrentY += sLineHeight; if(interior) toAdd->setUserString("interior","y"); else toAdd->setUserString("interior","n"); std::ostringstream oss; oss << price; toAdd->setUserString("price",oss.str()); toAdd->setCaptionWithReplacing("#{sCell=" + name + "} - " + boost::lexical_cast<std::string>(price)+"#{sgp}"); toAdd->setSize(toAdd->getTextSize().width,sLineHeight); toAdd->eventMouseWheel += MyGUI::newDelegate(this, &TravelWindow::onMouseWheel); toAdd->setUserString("Destination", name); toAdd->setUserData(pos); toAdd->eventMouseButtonClick += MyGUI::newDelegate(this, &TravelWindow::onTravelButtonClick); }
void CameraPanel::notifyMouseButtonClick(MyGUI::Widget* _sender) { MyGUI::Button* button = _sender->castType<MyGUI::Button>(); bool pressed = button->getStateSelected(); if(!pressed) { mBtnFixed->setStateSelected(false); mBtnManipulable->setStateSelected(false); mBtnTracking->setStateSelected(false); button->setStateSelected(!pressed); std::string btName = button->getName(); if(btName == "RBCamFixed") mCamMode = 0; else if(btName == "RBCamFixed") mCamMode = 1; else mCamMode = 2; } }
void SceneObjectPanel::notifyApplyOperation(MyGUI::Widget* _sender) { if(mPickableObj == nullptr) return; MyGUI::Button* btn = static_cast<MyGUI::Button*>(_sender); //TODO: change compare to AnyData injected in the widget later std::string btnName = btn->getName(); btnName = btnName.substr(mPrefix.length(),btnName.length() - mPrefix.length()); if(btnName == "BT_APPLY_SCALE") { if(mPickableObj != nullptr) mPickableObj->applyOperation(0); } else if(btnName == "BT_APPLY_ROTATE") { if(mPickableObj != nullptr) mPickableObj->applyOperation(1); } }
void SpellBuyingWindow::addSpell(const ESM::Spell& spell) { const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); int price = static_cast<int>(spell.mData.mCost*store.get<ESM::GameSetting>().find("fSpellValueMult")->mValue.getFloat()); price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true); MWWorld::Ptr player = MWMechanics::getPlayer(); int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId); // TODO: refactor to use MyGUI::ListBox MyGUI::Button* toAdd = mSpellsView->createWidget<MyGUI::Button>( price <= playerGold ? "SandTextButton" : "SandTextButtonDisabled", // can't use setEnabled since that removes tooltip 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default ); mCurrentY += sLineHeight; toAdd->setUserData(price); toAdd->setCaptionWithReplacing(spell.mName+" - "+MyGUI::utility::toString(price)+"#{sgp}"); toAdd->setSize(mSpellsView->getWidth(),sLineHeight); toAdd->eventMouseWheel += MyGUI::newDelegate(this, &SpellBuyingWindow::onMouseWheel); toAdd->setUserString("ToolTipType", "Spell"); toAdd->setUserString("Spell", spell.mId); toAdd->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellBuyingWindow::onSpellButtonClick); mSpellsWidgetMap.insert(std::make_pair (toAdd, spell.mId)); }