From c5e55d3cac140872de52455bdf1b9f658632d01d Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 27 Aug 2012 15:51:01 +0200 Subject: [PATCH] fix screenshot function --- apps/openmw/mwbase/windowmanager.hpp | 2 + apps/openmw/mwgui/quickkeysmenu.cpp | 82 +++++++++++++++++-- apps/openmw/mwgui/quickkeysmenu.hpp | 10 +++ apps/openmw/mwgui/windowmanagerimp.cpp | 5 ++ apps/openmw/mwgui/windowmanagerimp.hpp | 2 + apps/openmw/mwinput/inputmanagerimp.cpp | 8 +- .../mygui/openmw_itemselection_dialog.layout | 8 +- 7 files changed, 102 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index fde965256..589ab4a4b 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -171,6 +171,8 @@ namespace MWBase virtual void setWeaponVisibility(bool visible) = 0; virtual void setSpellVisibility(bool visible) = 0; + virtual void activateQuickKey (int index) = 0; + virtual void setSelectedSpell(const std::string& spellId, int successChancePercent) = 0; virtual void setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent) = 0; virtual void setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent) = 0; diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index 6739b3d1b..853e2ed14 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -82,6 +82,8 @@ namespace MWGui while (key->getChildCount ()) MyGUI::Gui::getInstance ().destroyWidget (key->getChildAt(0)); + key->setUserData(Type_Unassigned); + MyGUI::TextBox* textBox = key->createWidgetReal("SandText", MyGUI::FloatCoord(0,0,1,1), MyGUI::Align::Default); textBox->setTextAlign (MyGUI::Align::Center); textBox->setCaption (boost::lexical_cast(index+1)); @@ -159,16 +161,25 @@ namespace MWGui while (button->getChildCount ()) MyGUI::Gui::getInstance ().destroyWidget (button->getChildAt(0)); - MyGUI::ImageBox* image = button->createWidget("ImageBox", MyGUI::IntCoord(9, 8, 42, 42), MyGUI::Align::Default); - image->setUserString ("ToolTipType", "ItemPtr"); - image->setUserData(item); + button->setUserData(Type_Item); + + MyGUI::ImageBox* frame = button->createWidget("ImageBox", MyGUI::IntCoord(9, 8, 42, 42), MyGUI::Align::Default); + std::string backgroundTex = "textures\\menu_icon_barter.dds"; + frame->setImageTexture (backgroundTex); + frame->setImageCoord (MyGUI::IntCoord(4, 4, 40, 40)); + frame->setUserString ("ToolTipType", "ItemPtr"); + frame->setUserData(item); + frame->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked); + + + MyGUI::ImageBox* image = frame->createWidget("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default); std::string path = std::string("icons\\"); path += MWWorld::Class::get(item).getInventoryIcon(item); int pos = path.rfind("."); path.erase(pos); path.append(".dds"); image->setImageTexture (path); - image->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked); + image->setNeedMouseFocus (false); mItemSelectionDialog->setVisible(false); } @@ -180,7 +191,29 @@ namespace MWGui void QuickKeysMenu::onAssignMagicItem (MWWorld::Ptr item) { - onAssignItem(item); + MyGUI::Button* button = mQuickKeyButtons[mSelectedIndex]; + while (button->getChildCount ()) + MyGUI::Gui::getInstance ().destroyWidget (button->getChildAt(0)); + + button->setUserData(Type_MagicItem); + + MyGUI::ImageBox* frame = button->createWidget("ImageBox", MyGUI::IntCoord(9, 8, 42, 42), MyGUI::Align::Default); + std::string backgroundTex = "textures\\menu_icon_select_magic_magic.dds"; + frame->setImageTexture (backgroundTex); + frame->setImageCoord (MyGUI::IntCoord(2, 2, 40, 40)); + frame->setUserString ("ToolTipType", "ItemPtr"); + frame->setUserData(item); + frame->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked); + + MyGUI::ImageBox* image = frame->createWidget("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default); + std::string path = std::string("icons\\"); + path += MWWorld::Class::get(item).getInventoryIcon(item); + int pos = path.rfind("."); + path.erase(pos); + path.append(".dds"); + image->setImageTexture (path); + image->setNeedMouseFocus (false); + mMagicSelectionDialog->setVisible(false); } @@ -190,9 +223,17 @@ namespace MWGui while (button->getChildCount ()) MyGUI::Gui::getInstance ().destroyWidget (button->getChildAt(0)); - MyGUI::ImageBox* image = button->createWidget("ImageBox", MyGUI::IntCoord(9, 8, 42, 42), MyGUI::Align::Default); - image->setUserString ("ToolTipType", "Spell"); - image->setUserString ("Spell", spellId); + button->setUserData(Type_Magic); + + MyGUI::ImageBox* frame = button->createWidget("ImageBox", MyGUI::IntCoord(9, 8, 42, 42), MyGUI::Align::Default); + std::string backgroundTex = "textures\\menu_icon_select_magic.dds"; + frame->setImageTexture (backgroundTex); + frame->setImageCoord (MyGUI::IntCoord(2, 2, 40, 40)); + frame->setUserString ("ToolTipType", "Spell"); + frame->setUserString ("Spell", spellId); + frame->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked); + + MyGUI::ImageBox* image = frame->createWidget("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default); // use the icon of the first effect const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); @@ -206,7 +247,7 @@ namespace MWGui path.append(".dds"); image->setImageTexture (path); - image->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onQuickKeyButtonClicked); + image->setNeedMouseFocus (false); mMagicSelectionDialog->setVisible(false); } @@ -216,6 +257,29 @@ namespace MWGui mMagicSelectionDialog->setVisible(false); } + void QuickKeysMenu::activateQuickKey(int index) + { + MyGUI::Button* button = mQuickKeyButtons[index-1]; + + QuickKeyType type = *button->getUserData(); + + if (type == Type_Magic) + { + std::string spellId = button->getChildAt(0)->getUserString("Spell"); + MWBase::Environment::get().getWindowManager ()->setSelectedSpell (spellId, 100); + } + else if (type == Type_Item) + { + MWWorld::Ptr item = *button->getChildAt (0)->getUserData(); + MWBase::Environment::get().getWindowManager ()->setSelectedWeapon(item, 100); + } + else if (type == Type_MagicItem) + { + MWWorld::Ptr item = *button->getChildAt (0)->getUserData(); + MWBase::Environment::get().getWindowManager ()->setSelectedEnchantItem (item, 100); + } + } + // --------------------------------------------------------------------------------------------------------- QuickKeysMenuAssign::QuickKeysMenuAssign (MWBase::WindowManager &parWindowManager, QuickKeysMenu* parent) diff --git a/apps/openmw/mwgui/quickkeysmenu.hpp b/apps/openmw/mwgui/quickkeysmenu.hpp index 44e48d3b0..345ffa0c8 100644 --- a/apps/openmw/mwgui/quickkeysmenu.hpp +++ b/apps/openmw/mwgui/quickkeysmenu.hpp @@ -31,6 +31,16 @@ namespace MWGui void onAssignMagic (const std::string& spellId); void onAssignMagicCancel (); + void activateQuickKey(int index); + + enum QuickKeyType + { + Type_Item, + Type_Magic, + Type_MagicItem, + Type_Unassigned + }; + private: MyGUI::EditBox* mInstructionLabel; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index f1ee01c4d..138349c2e 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -854,3 +854,8 @@ void WindowManager::notifyInputActionBound () mSettingsWindow->updateControlsBox (); allowMouse(); } + +void WindowManager::activateQuickKey (int index) +{ + mQuickKeysMenu->activateQuickKey(index); +} diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index f27522986..8b011e259 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -152,6 +152,8 @@ namespace MWGui virtual void setWeaponVisibility(bool visible); virtual void setSpellVisibility(bool visible); + virtual void activateQuickKey (int index); + virtual void setSelectedSpell(const std::string& spellId, int successChancePercent); virtual void setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent); virtual void setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent); diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 49b9a08a8..7daafc726 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -599,7 +599,7 @@ namespace MWInput void InputManager::quickKey (int index) { - std::cout << "quick key " << index << std::endl; + mWindows.activateQuickKey (index); } void InputManager::showQuickKeysMenu() @@ -669,6 +669,7 @@ namespace MWInput defaultKeyBindings[A_QuickKey8] = OIS::KC_8; defaultKeyBindings[A_QuickKey9] = OIS::KC_9; defaultKeyBindings[A_QuickKey10] = OIS::KC_0; + defaultKeyBindings[A_Screenshot] = OIS::KC_SYSRQ; std::map defaultMouseButtonBindings; defaultMouseButtonBindings[A_Inventory] = OIS::MB_Right; @@ -689,7 +690,10 @@ namespace MWInput control = mInputCtrl->getChannel(i)->getAttachedControls ().front().control; } - if (!controlExists || force) + if (!controlExists || force || + ( mInputCtrl->getKeyBinding (control, ICS::Control::INCREASE) == OIS::KC_UNASSIGNED + && mInputCtrl->getMouseButtonBinding (control, ICS::Control::INCREASE) == ICS_MAX_DEVICE_BUTTONS + )) { clearAllBindings (control); diff --git a/files/mygui/openmw_itemselection_dialog.layout b/files/mygui/openmw_itemselection_dialog.layout index 93681e69e..81376d6d5 100644 --- a/files/mygui/openmw_itemselection_dialog.layout +++ b/files/mygui/openmw_itemselection_dialog.layout @@ -4,14 +4,14 @@ - - + + - + - +