void CreateClassDialog::setNextButtonShow(bool shown) { MyGUI::ButtonPtr descriptionButton; getWidget(descriptionButton, "DescriptionButton"); MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); // TODO: All hardcoded coords for buttons are temporary, will be replaced with a dynamic system. if (shown) { okButton->setCaption("Next"); // Adjust back button when next is shown descriptionButton->setCoord(MyGUI::IntCoord(207 - 18, 158, 143, 23)); backButton->setCoord(MyGUI::IntCoord(356 - 18, 158, 53, 23)); okButton->setCoord(MyGUI::IntCoord(417 - 18, 158, 42 + 18, 23)); } else { okButton->setCaption("OK"); descriptionButton->setCoord(MyGUI::IntCoord(207, 158, 143, 23)); backButton->setCoord(MyGUI::IntCoord(356, 158, 53, 23)); okButton->setCoord(MyGUI::IntCoord(417, 158, 42, 23)); } }
void BirthDialog::setNextButtonShow(bool shown) { MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); if (shown) okButton->setCaption(mWindowManager.getGameSettingString("sNext", "")); else okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); }
SelectSpecializationDialog::SelectSpecializationDialog(MWBase::WindowManager& parWindowManager) : WindowModal("openmw_chargen_select_specialization.layout", parWindowManager) { // Centre dialog center(); setText("LabelT", mWindowManager.getGameSettingString("sSpecializationMenu1", "")); getWidget(mSpecialization0, "Specialization0"); getWidget(mSpecialization1, "Specialization1"); getWidget(mSpecialization2, "Specialization2"); std::string combat = mWindowManager.getGameSettingString(ESM::Class::sGmstSpecializationIds[ESM::Class::Combat], ""); std::string magic = mWindowManager.getGameSettingString(ESM::Class::sGmstSpecializationIds[ESM::Class::Magic], ""); std::string stealth = mWindowManager.getGameSettingString(ESM::Class::sGmstSpecializationIds[ESM::Class::Stealth], ""); mSpecialization0->setCaption(combat); mSpecialization0->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); mSpecialization1->setCaption(magic); mSpecialization1->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); mSpecialization2->setCaption(stealth); mSpecialization2->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); mSpecializationId = ESM::Class::Combat; ToolTips::createSpecializationToolTip(mSpecialization0, combat, ESM::Class::Combat); ToolTips::createSpecializationToolTip(mSpecialization1, magic, ESM::Class::Magic); ToolTips::createSpecializationToolTip(mSpecialization2, stealth, ESM::Class::Stealth); MyGUI::ButtonPtr cancelButton; getWidget(cancelButton, "CancelButton"); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", "")); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked); }
GenerateClassResultDialog::GenerateClassResultDialog(WindowManager& parWindowManager) : WindowBase("openmw_chargen_generate_class_result.layout", parWindowManager) { // Centre dialog center(); setText("ReflectT", mWindowManager.getGameSettingString("sMessageQuestionAnswer1", "")); getWidget(mClassImage, "ClassImage"); getWidget(mClassName, "ClassName"); MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GenerateClassResultDialog::onBackClicked); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GenerateClassResultDialog::onOkClicked); int okButtonWidth = okButton->getTextSize().width + 24; int backButtonWidth = backButton->getTextSize().width + 24; okButton->setCoord(315 - okButtonWidth, 219, okButtonWidth, 23); backButton->setCoord(315 - okButtonWidth - backButtonWidth - 6, 219, backButtonWidth, 23); }
void InfoBoxDialog::setButtons(ButtonList &buttons) { for (std::vector<MyGUI::ButtonPtr>::iterator it = this->mButtons.begin(); it != this->mButtons.end(); ++it) { MyGUI::Gui::getInstance().destroyWidget(*it); } this->mButtons.clear(); mCurrentButton = -1; // TODO: The buttons should be generated from a template in the layout file, ie. cloning an existing widget MyGUI::ButtonPtr button; MyGUI::IntCoord coord = MyGUI::IntCoord(0, 0, mButtonBar->getWidth(), 10); ButtonList::const_iterator end = buttons.end(); for (ButtonList::const_iterator it = buttons.begin(); it != end; ++it) { const std::string &text = *it; button = mButtonBar->createWidget<MyGUI::Button>("MW_Button", coord, MyGUI::Align::Top | MyGUI::Align::HCenter, ""); button->getSubWidgetText()->setWordWrap(true); button->setCaption(text); fitToText(button); button->eventMouseButtonClick += MyGUI::newDelegate(this, &InfoBoxDialog::onButtonClicked); coord.top += button->getHeight(); this->mButtons.push_back(button); } }
SelectAttributeDialog::SelectAttributeDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize) : WindowBase("openmw_chargen_select_attribute_layout.xml", environment) { // Centre dialog center(); WindowManager *wm = environment.mWindowManager; setText("LabelT", wm->getGameSettingString("sAttributesMenu1", "")); for (int i = 0; i < 8; ++i) { Widgets::MWAttributePtr attribute; char theIndex = '0'+i; getWidget(attribute, std::string("Attribute").append(1, theIndex)); attribute->setWindowManager(wm); attribute->setAttributeId(ESM::Attribute::attributeIds[i]); attribute->eventClicked = MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked); } // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr cancelButton; getWidget(cancelButton, "CancelButton"); cancelButton->setCaption(wm->getGameSettingString("sCancel", "")); cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked); }
SelectSpecializationDialog::SelectSpecializationDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize) : WindowBase("openmw_chargen_select_specialization_layout.xml", environment) { // Centre dialog center(); WindowManager *wm = environment.mWindowManager; setText("LabelT", wm->getGameSettingString("sSpecializationMenu1", "")); getWidget(specialization0, "Specialization0"); getWidget(specialization1, "Specialization1"); getWidget(specialization2, "Specialization2"); specialization0->setCaption(wm->getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], "")); specialization0->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); specialization1->setCaption(wm->getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Magic], "")); specialization1->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); specialization2->setCaption(wm->getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Stealth], "")); specialization2->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); specializationId = ESM::Class::Combat; // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr cancelButton; getWidget(cancelButton, "CancelButton"); cancelButton->setCaption(wm->getGameSettingString("sCancel", "")); cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked); }
SelectAttributeDialog::SelectAttributeDialog(WindowManager& parWindowManager) : WindowBase("openmw_chargen_select_attribute.layout", parWindowManager) { // Centre dialog center(); setText("LabelT", mWindowManager.getGameSettingString("sAttributesMenu1", "")); for (int i = 0; i < 8; ++i) { Widgets::MWAttributePtr attribute; char theIndex = '0'+i; getWidget(attribute, std::string("Attribute").append(1, theIndex)); attribute->setWindowManager(&parWindowManager); attribute->setAttributeId(ESM::Attribute::attributeIds[i]); attribute->eventClicked += MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked); ToolTips::createAttributeToolTip(attribute, attribute->getAttributeId()); } MyGUI::ButtonPtr cancelButton; getWidget(cancelButton, "CancelButton"); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", "")); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked); int buttonWidth = cancelButton->getTextSize().width + 24; cancelButton->setCoord(186 - buttonWidth, 180, buttonWidth, 21); MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget); }
BirthDialog::BirthDialog(MWBase::WindowManager& parWindowManager) : WindowBase("openmw_chargen_birth.layout", parWindowManager) { // Centre dialog center(); getWidget(mSpellArea, "SpellArea"); getWidget(mBirthImage, "BirthsignImage"); getWidget(mBirthList, "BirthsignList"); mBirthList->setScrollVisible(true); mBirthList->eventListSelectAccept += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); mBirthList->eventListMouseItemActivate += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); mBirthList->eventListChangePosition += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onBackClicked); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onOkClicked); okButton->setEnabled(false); updateBirths(); updateSpells(); }
void PanelObjectsList::AddItem(Ogre::UTFString name) { MyGUI::ButtonPtr checkbox = mWidgetClient->createWidget<MyGUI::Button>("CheckBox", MyGUI::IntCoord(WidthStep, CurrentHeight, Width, Height), MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch); checkbox->setCaption(name); checkbox->eventMouseButtonClick = MyGUI::newDelegate(this, &PanelObjectsList::mousePressed); mItemsCheckBox.push_back(checkbox); UpdateItemsView(); }
void PickClassDialog::setNextButtonShow(bool shown) { MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); if (shown) okButton->setCaption(mWindowManager.getGameSettingString("sNext", "")); else okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); int okButtonWidth = okButton->getTextSize().width + 24; int backButtonWidth = backButton->getTextSize().width + 24; okButton->setCoord(476 - okButtonWidth, 265, okButtonWidth, 23); backButton->setCoord(476 - okButtonWidth - backButtonWidth - 6, 265, backButtonWidth, 23); }
void GraphicsImpl::setupGUI() { MyGUI::Gui * mGUI; MyGUI::OgrePlatform* platform = new MyGUI::OgrePlatform(); platform->initialise(window, sceneMgr); gui = new MyGUI::Gui(); gui->initialise(); mainGuiWidget = gui->createWidgetReal<MyGUI::Widget>("Default", 0.0, 0.0, 1.0, 1.0, MyGUI::Align::Default, "Main"); MyGUI::ButtonPtr button = mainGuiWidget->createWidgetReal<MyGUI::Button>("Button", 0.005, 0.008, 0.156, 0.05, MyGUI::Align::Default, "exit"); button->setCaption("exit"); // set callback button->eventMouseButtonClick = MyGUI::newDelegate(this, &GraphicsImpl::guiCallback); button = mainGuiWidget->createWidgetReal<MyGUI::Button>("Button", 0.182, 0.008, 0.156, 0.05, MyGUI::Align::Default, "do"); button->setCaption("do something"); // set callback button->eventMouseButtonClick = MyGUI::newDelegate(this, &GraphicsImpl::guiCallback); }
void CreateClassDialog::setNextButtonShow(bool shown) { MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); MyGUI::ButtonPtr descriptionButton; getWidget(descriptionButton, "DescriptionButton"); if (shown) okButton->setCaption(mWindowManager.getGameSettingString("sNext", "")); else okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); int okButtonWidth = okButton->getTextSize().width + 24; int backButtonWidth = backButton->getTextSize().width + 24; int descriptionButtonWidth = descriptionButton->getTextSize().width + 24; okButton->setCoord(459 - okButtonWidth, 158, okButtonWidth, 23); backButton->setCoord(459 - okButtonWidth - backButtonWidth - 6, 158, backButtonWidth, 23); descriptionButton->setCoord(459 - okButtonWidth - backButtonWidth - descriptionButtonWidth - 12, 158, descriptionButtonWidth, 23); }
void PickClassDialog::setNextButtonShow(bool shown) { MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); // TODO: All hardcoded coords for buttons are temporary, will be replaced with a dynamic system. if (shown) { okButton->setCaption("Next"); // Adjust back button when next is shown backButton->setCoord(MyGUI::IntCoord(382 - 18, 265, 53, 23)); okButton->setCoord(MyGUI::IntCoord(434 - 18, 265, 42 + 18, 23)); } else { okButton->setCaption("OK"); backButton->setCoord(MyGUI::IntCoord(382, 265, 53, 23)); okButton->setCoord(MyGUI::IntCoord(434, 265, 42, 23)); } }
DescriptionDialog::DescriptionDialog(MWBase::WindowManager& parWindowManager) : WindowModal("openmw_chargen_class_description.layout", parWindowManager) { // Centre dialog center(); getWidget(mTextEdit, "TextEdit"); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked); okButton->setCaption(mWindowManager.getGameSettingString("sInputMenu1", "")); // Make sure the edit box has focus MyGUI::InputManager::getInstance().setKeyFocusWidget(mTextEdit); }
DescriptionDialog::DescriptionDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize) : WindowBase("openmw_chargen_class_description_layout.xml", environment) { // Centre dialog center(); getWidget(textEdit, "TextEdit"); // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked); okButton->setCaption(environment.mWindowManager->getGameSettingString("sInputMenu1", "")); // Make sure the edit box has focus MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit); }
RaceDialog::RaceDialog(MWBase::WindowManager& parWindowManager) : WindowBase("openmw_chargen_race.layout", parWindowManager) , mGenderIndex(0) , mFaceIndex(0) , mHairIndex(0) , mFaceCount(10) , mHairCount(14) { // Centre dialog center(); // These are just demo values, you should replace these with // real calls from outside the class later. setText("AppearanceT", mWindowManager.getGameSettingString("sRaceMenu1", "Appearance")); getWidget(mAppearanceBox, "AppearanceBox"); getWidget(mHeadRotate, "HeadRotate"); mHeadRotate->setScrollRange(50); mHeadRotate->setScrollPosition(20); mHeadRotate->setScrollViewPage(10); mHeadRotate->eventScrollChangePosition += MyGUI::newDelegate(this, &RaceDialog::onHeadRotate); // Set up next/previous buttons MyGUI::ButtonPtr prevButton, nextButton; setText("GenderChoiceT", mWindowManager.getGameSettingString("sRaceMenu2", "Change Sex")); getWidget(prevButton, "PrevGenderButton"); getWidget(nextButton, "NextGenderButton"); prevButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousGender); nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextGender); setText("FaceChoiceT", mWindowManager.getGameSettingString("sRaceMenu3", "Change Face")); getWidget(prevButton, "PrevFaceButton"); getWidget(nextButton, "NextFaceButton"); prevButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousFace); nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextFace); setText("HairChoiceT", mWindowManager.getGameSettingString("sRaceMenu4", "Change Hair")); getWidget(prevButton, "PrevHairButton"); getWidget(nextButton, "NextHairButton"); prevButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousHair); nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextHair); setText("RaceT", mWindowManager.getGameSettingString("sRaceMenu4", "Race")); getWidget(mRaceList, "RaceList"); mRaceList->setScrollVisible(true); mRaceList->eventListSelectAccept += MyGUI::newDelegate(this, &RaceDialog::onSelectRace); mRaceList->eventListMouseItemActivate += MyGUI::newDelegate(this, &RaceDialog::onSelectRace); mRaceList->eventListChangePosition += MyGUI::newDelegate(this, &RaceDialog::onSelectRace); setText("SkillsT", mWindowManager.getGameSettingString("sBonusSkillTitle", "Skill Bonus")); getWidget(mSkillList, "SkillList"); setText("SpellPowerT", mWindowManager.getGameSettingString("sRaceMenu7", "Specials")); getWidget(mSpellPowerList, "SpellPowerList"); MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onBackClicked); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onOkClicked); updateRaces(); updateSkills(); updateSpellPowers(); }
SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager) : WindowBase("openmw_chargen_select_skill.layout", parWindowManager) { // Centre dialog center(); setText("LabelT", mWindowManager.getGameSettingString("sSkillsMenu1", "")); setText("CombatLabelT", mWindowManager.getGameSettingString("sSpecializationCombat", "")); setText("MagicLabelT", mWindowManager.getGameSettingString("sSpecializationMagic", "")); setText("StealthLabelT", mWindowManager.getGameSettingString("sSpecializationStealth", "")); for(int i = 0; i < 9; i++) { char theIndex = '0'+i; getWidget(mCombatSkill[i], std::string("CombatSkill").append(1, theIndex)); getWidget(mMagicSkill[i], std::string("MagicSkill").append(1, theIndex)); getWidget(mStealthSkill[i], std::string("StealthSkill").append(1, theIndex)); } struct {Widgets::MWSkillPtr widget; ESM::Skill::SkillEnum skillId;} mSkills[3][9] = { { {mCombatSkill[0], ESM::Skill::Block}, {mCombatSkill[1], ESM::Skill::Armorer}, {mCombatSkill[2], ESM::Skill::MediumArmor}, {mCombatSkill[3], ESM::Skill::HeavyArmor}, {mCombatSkill[4], ESM::Skill::BluntWeapon}, {mCombatSkill[5], ESM::Skill::LongBlade}, {mCombatSkill[6], ESM::Skill::Axe}, {mCombatSkill[7], ESM::Skill::Spear}, {mCombatSkill[8], ESM::Skill::Athletics} }, { {mMagicSkill[0], ESM::Skill::Enchant}, {mMagicSkill[1], ESM::Skill::Destruction}, {mMagicSkill[2], ESM::Skill::Alteration}, {mMagicSkill[3], ESM::Skill::Illusion}, {mMagicSkill[4], ESM::Skill::Conjuration}, {mMagicSkill[5], ESM::Skill::Mysticism}, {mMagicSkill[6], ESM::Skill::Restoration}, {mMagicSkill[7], ESM::Skill::Alchemy}, {mMagicSkill[8], ESM::Skill::Unarmored} }, { {mStealthSkill[0], ESM::Skill::Security}, {mStealthSkill[1], ESM::Skill::Sneak}, {mStealthSkill[2], ESM::Skill::Acrobatics}, {mStealthSkill[3], ESM::Skill::LightArmor}, {mStealthSkill[4], ESM::Skill::ShortBlade}, {mStealthSkill[5] ,ESM::Skill::Marksman}, {mStealthSkill[6] ,ESM::Skill::Mercantile}, {mStealthSkill[7] ,ESM::Skill::Speechcraft}, {mStealthSkill[8] ,ESM::Skill::HandToHand} } }; for (int spec = 0; spec < 3; ++spec) { for (int i = 0; i < 9; ++i) { mSkills[spec][i].widget->setWindowManager(&mWindowManager); mSkills[spec][i].widget->setSkillId(mSkills[spec][i].skillId); mSkills[spec][i].widget->eventClicked += MyGUI::newDelegate(this, &SelectSkillDialog::onSkillClicked); ToolTips::createSkillToolTip(mSkills[spec][i].widget, mSkills[spec][i].widget->getSkillId()); } } MyGUI::ButtonPtr cancelButton; getWidget(cancelButton, "CancelButton"); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", "")); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSkillDialog::onCancelClicked); int buttonWidth = cancelButton->getTextSize().width + 24; cancelButton->setCoord(447 - buttonWidth, 218, buttonWidth, 21); MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget); }
CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager) : WindowBase("openmw_chargen_create_class.layout", parWindowManager) , mSpecDialog(nullptr) , mAttribDialog(nullptr) , mSkillDialog(nullptr) , mDescDialog(nullptr) { // Centre dialog center(); setText("SpecializationT", mWindowManager.getGameSettingString("sChooseClassMenu1", "Specialization")); getWidget(mSpecializationName, "SpecializationName"); mSpecializationName->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationClicked); setText("FavoriteAttributesT", mWindowManager.getGameSettingString("sChooseClassMenu2", "Favorite Attributes:")); getWidget(mFavoriteAttribute0, "FavoriteAttribute0"); getWidget(mFavoriteAttribute1, "FavoriteAttribute1"); mFavoriteAttribute0->setWindowManager(&mWindowManager); mFavoriteAttribute1->setWindowManager(&mWindowManager); mFavoriteAttribute0->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked); mFavoriteAttribute1->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked); setText("MajorSkillT", mWindowManager.getGameSettingString("sSkillClassMajor", "")); setText("MinorSkillT", mWindowManager.getGameSettingString("sSkillClassMinor", "")); for(int i = 0; i < 5; i++) { char theIndex = '0'+i; getWidget(mMajorSkill[i], std::string("MajorSkill").append(1, theIndex)); getWidget(mMinorSkill[i], std::string("MinorSkill").append(1, theIndex)); mSkills.push_back(mMajorSkill[i]); mSkills.push_back(mMinorSkill[i]); } std::vector<Widgets::MWSkillPtr>::const_iterator end = mSkills.end(); for (std::vector<Widgets::MWSkillPtr>::const_iterator it = mSkills.begin(); it != end; ++it) { (*it)->setWindowManager(&mWindowManager); (*it)->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked); } setText("LabelT", mWindowManager.getGameSettingString("sName", "")); getWidget(mEditName, "EditName"); // Make sure the edit box has focus MyGUI::InputManager::getInstance().setKeyFocusWidget(mEditName); MyGUI::ButtonPtr descriptionButton; getWidget(descriptionButton, "DescriptionButton"); descriptionButton->setCaption(mWindowManager.getGameSettingString("sCreateClassMenu1", "")); descriptionButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionClicked); MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onBackClicked); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onOkClicked); // Set default skills, attributes mFavoriteAttribute0->setAttributeId(ESM::Attribute::Strength); mFavoriteAttribute1->setAttributeId(ESM::Attribute::Agility); mMajorSkill[0]->setSkillId(ESM::Skill::Block); mMajorSkill[1]->setSkillId(ESM::Skill::Armorer); mMajorSkill[2]->setSkillId(ESM::Skill::MediumArmor); mMajorSkill[3]->setSkillId(ESM::Skill::HeavyArmor); mMajorSkill[4]->setSkillId(ESM::Skill::BluntWeapon); mMinorSkill[0]->setSkillId(ESM::Skill::LongBlade); mMinorSkill[1]->setSkillId(ESM::Skill::Axe); mMinorSkill[2]->setSkillId(ESM::Skill::Spear); mMinorSkill[3]->setSkillId(ESM::Skill::Athletics); mMinorSkill[4]->setSkillId(ESM::Skill::Enchant); setSpecialization(0); update(); }
SelectSkillDialog::SelectSkillDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize) : WindowBase("openmw_chargen_select_skill_layout.xml", environment) { // Centre dialog center(); WindowManager *wm = environment.mWindowManager; setText("LabelT", wm->getGameSettingString("sSkillsMenu1", "")); setText("CombatLabelT", wm->getGameSettingString("sSpecializationCombat", "")); setText("MagicLabelT", wm->getGameSettingString("sSpecializationMagic", "")); setText("StealthLabelT", wm->getGameSettingString("sSpecializationStealth", "")); for(int i = 0; i < 9; i++) { char theIndex = '0'+i; getWidget(combatSkill[i], std::string("CombatSkill").append(1, theIndex)); getWidget(magicSkill[i], std::string("MagicSkill").append(1, theIndex)); getWidget(stealthSkill[i], std::string("StealthSkill").append(1, theIndex)); } struct {Widgets::MWSkillPtr widget; ESM::Skill::SkillEnum skillId;} skills[3][9] = { { {combatSkill[0], ESM::Skill::Block}, {combatSkill[1], ESM::Skill::Armorer}, {combatSkill[2], ESM::Skill::MediumArmor}, {combatSkill[3], ESM::Skill::HeavyArmor}, {combatSkill[4], ESM::Skill::BluntWeapon}, {combatSkill[5], ESM::Skill::LongBlade}, {combatSkill[6], ESM::Skill::Axe}, {combatSkill[7], ESM::Skill::Spear}, {combatSkill[8], ESM::Skill::Athletics} }, { {magicSkill[0], ESM::Skill::Enchant}, {magicSkill[1], ESM::Skill::Destruction}, {magicSkill[2], ESM::Skill::Alteration}, {magicSkill[3], ESM::Skill::Illusion}, {magicSkill[4], ESM::Skill::Conjuration}, {magicSkill[5], ESM::Skill::Mysticism}, {magicSkill[6], ESM::Skill::Restoration}, {magicSkill[7], ESM::Skill::Alchemy}, {magicSkill[8], ESM::Skill::Unarmored} }, { {stealthSkill[0], ESM::Skill::Security}, {stealthSkill[1], ESM::Skill::Sneak}, {stealthSkill[2], ESM::Skill::Acrobatics}, {stealthSkill[3], ESM::Skill::LightArmor}, {stealthSkill[4], ESM::Skill::ShortBlade}, {stealthSkill[5] ,ESM::Skill::Marksman}, {stealthSkill[6] ,ESM::Skill::Mercantile}, {stealthSkill[7] ,ESM::Skill::Speechcraft}, {stealthSkill[8] ,ESM::Skill::HandToHand} } }; for (int spec = 0; spec < 3; ++spec) { for (int i = 0; i < 9; ++i) { skills[spec][i].widget->setWindowManager(wm); skills[spec][i].widget->setSkillId(skills[spec][i].skillId); skills[spec][i].widget->eventClicked = MyGUI::newDelegate(this, &SelectSkillDialog::onSkillClicked); } } // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr cancelButton; getWidget(cancelButton, "CancelButton"); cancelButton->setCaption(wm->getGameSettingString("sCancel", "")); cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSkillDialog::onCancelClicked); }
InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector<std::string>& buttons) : Layout("openmw_interactive_messagebox_layout.xml") , mMessageBoxManager(parMessageBoxManager) , mButtonPressed(-1) { int fixedWidth = 500; int textPadding = 10; // padding between text-widget and main-widget int textButtonPadding = 20; // padding between the text-widget und the button-widget int buttonLeftPadding = 10; // padding between the buttons if horizontal int buttonTopPadding = 5; // ^-- if vertical int buttonPadding = 5; // padding between button label and button itself int buttonMainPadding = 10; // padding between buttons and bottom of the main widget mMarkedToDelete = false; getWidget(mMessageWidget, "message"); getWidget(mButtonsWidget, "buttons"); mMessageWidget->setOverflowToTheLeft(true); mMessageWidget->addText(message); MyGUI::IntSize textSize = mMessageWidget->_getTextSize(); MyGUI::IntSize gameWindowSize = mMessageBoxManager.mWindowManager->getGui()->getViewSize(); int biggestButtonWidth = 0; int buttonWidth = 0; int buttonsWidth = 0; int buttonHeight = 0; MyGUI::IntCoord dummyCoord(0, 0, 0, 0); std::vector<std::string>::const_iterator it; for(it = buttons.begin(); it != buttons.end(); ++it) { MyGUI::ButtonPtr button = mButtonsWidget->createWidget<MyGUI::Button>( MyGUI::WidgetStyle::Child, std::string("MW_Button"), dummyCoord, MyGUI::Align::Default); button->setCaption(*it); button->eventMouseButtonClick = MyGUI::newDelegate(this, &InteractiveMessageBox::mousePressed); mButtons.push_back(button); buttonWidth = button->_getTextSize().width + 2*buttonPadding + buttonLeftPadding; buttonsWidth += buttonWidth; buttonHeight = button->_getTextSize().height + 2*buttonPadding + buttonTopPadding; if(buttonWidth > biggestButtonWidth) { biggestButtonWidth = buttonWidth; } } buttonsWidth += buttonLeftPadding; MyGUI::IntSize mainWidgetSize; if(buttonsWidth < fixedWidth) { // on one line std::cout << "on one line" << std::endl; if(textSize.width + 2*textPadding < buttonsWidth) { std::cout << "width = buttonsWidth" << std::endl; mainWidgetSize.width = buttonsWidth; } else { mainWidgetSize.width = textSize.width + 3*textPadding; } mainWidgetSize.height = textSize.height + textButtonPadding + buttonHeight + buttonMainPadding; MyGUI::IntCoord absCoord; absCoord.left = (gameWindowSize.width - mainWidgetSize.width)/2; absCoord.top = (gameWindowSize.height - mainWidgetSize.height)/2; std::cout << "width " << mainWidgetSize.width << " height " << mainWidgetSize.height << std::endl; std::cout << "left " << absCoord.left << " top " << absCoord.top << std::endl; mMainWidget->setCoord(absCoord); mMainWidget->setSize(mainWidgetSize); MyGUI::IntCoord messageWidgetCoord; messageWidgetCoord.left = (mainWidgetSize.width - textSize.width)/2; messageWidgetCoord.top = textPadding; mMessageWidget->setCoord(messageWidgetCoord); mMessageWidget->setSize(textSize); MyGUI::IntCoord buttonCord; MyGUI::IntSize buttonSize(0, buttonHeight); int left = (mainWidgetSize.width - buttonsWidth)/2 + buttonPadding; std::vector<MyGUI::ButtonPtr>::const_iterator button; for(button = mButtons.begin(); button != mButtons.end(); ++button) { buttonCord.left = left; buttonCord.top = textSize.height + textButtonPadding; buttonSize.width = (*button)->_getTextSize().width + 2*buttonPadding; buttonSize.height = (*button)->_getTextSize().height + 2*buttonPadding; (*button)->setCoord(buttonCord); (*button)->setSize(buttonSize); left += buttonSize.width + buttonLeftPadding; } } else { // among each other if(biggestButtonWidth > textSize.width) { mainWidgetSize.width = biggestButtonWidth + buttonTopPadding; } else { mainWidgetSize.width = textSize.width + 3*textPadding; } mainWidgetSize.height = textSize.height + 2*textPadding + textButtonPadding + buttonHeight * buttons.size() + buttonMainPadding; std::cout << "biggestButtonWidth " << biggestButtonWidth << " textSize.width " << textSize.width << std::endl; std::cout << "width " << mainWidgetSize.width << " height " << mainWidgetSize.height << std::endl; mMainWidget->setSize(mainWidgetSize); MyGUI::IntCoord absCoord; absCoord.left = (gameWindowSize.width - mainWidgetSize.width)/2; absCoord.top = (gameWindowSize.height - mainWidgetSize.height)/2; mMainWidget->setCoord(absCoord); mMainWidget->setSize(mainWidgetSize); MyGUI::IntCoord messageWidgetCoord; messageWidgetCoord.left = (mainWidgetSize.width - textSize.width)/2; messageWidgetCoord.top = textPadding; mMessageWidget->setCoord(messageWidgetCoord); mMessageWidget->setSize(textSize); MyGUI::IntCoord buttonCord; MyGUI::IntSize buttonSize(0, buttonHeight); int top = textButtonPadding + buttonTopPadding + textSize.height; std::vector<MyGUI::ButtonPtr>::const_iterator button; for(button = mButtons.begin(); button != mButtons.end(); ++button) { buttonSize.width = (*button)->_getTextSize().width + buttonPadding*2; buttonSize.height = (*button)->_getTextSize().height + buttonPadding*2; buttonCord.top = top; buttonCord.left = (mainWidgetSize.width - buttonSize.width)/2 - 5; // FIXME: -5 is not so nice :/ (*button)->setCoord(buttonCord); (*button)->setSize(buttonSize); top += buttonSize.height + 2*buttonTopPadding; } } }