From 60affb5288f7d2abb53be16bf33a9b846bb2f96d Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 10 May 2012 12:47:15 +0200 Subject: [PATCH 1/6] removed include 2 --- apps/openmw/mwgui/formatting.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/openmw/mwgui/formatting.hpp b/apps/openmw/mwgui/formatting.hpp index c8f2c9e44..a1e115491 100644 --- a/apps/openmw/mwgui/formatting.hpp +++ b/apps/openmw/mwgui/formatting.hpp @@ -3,8 +3,6 @@ #include -#include - namespace MWGui { struct TextStyle From 65ccfba191318fd7b3bd4307ae62e08c9c6a26ac Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 11 May 2012 08:15:22 +0200 Subject: [PATCH 2/6] resize both the left and the right pane of the stats window --- apps/openmw/mwgui/stats_window.cpp | 4 + apps/openmw/mwgui/stats_window.hpp | 3 + files/mygui/openmw_stats_window_layout.xml | 93 ++++++++++++---------- 3 files changed, 58 insertions(+), 42 deletions(-) diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 8b688984f..9e6e17391 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -60,6 +60,8 @@ StatsWindow::StatsWindow (WindowManager& parWindowManager) getWidget(skillAreaWidget, "Skills"); getWidget(skillClientWidget, "SkillClient"); getWidget(skillScrollerWidget, "SkillScroller"); + getWidget(mLeftPane, "LeftPane"); + getWidget(mRightPane, "RightPane"); skillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &StatsWindow::onScrollChangePosition); updateScroller(); @@ -93,6 +95,8 @@ void StatsWindow::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos) void StatsWindow::onWindowResize(MyGUI::Window* window) { + mLeftPane->setCoord( MyGUI::IntCoord(0, 0, 0.44*window->getSize().width, window->getSize().height) ); + mRightPane->setCoord( MyGUI::IntCoord(0.44*window->getSize().width, 0, 0.56*window->getSize().width, window->getSize().height) ); updateScroller(); } diff --git a/apps/openmw/mwgui/stats_window.hpp b/apps/openmw/mwgui/stats_window.hpp index ecbc82894..b201b3387 100644 --- a/apps/openmw/mwgui/stats_window.hpp +++ b/apps/openmw/mwgui/stats_window.hpp @@ -57,6 +57,9 @@ namespace MWGui static const int lineHeight; + MyGUI::Widget* mLeftPane; + MyGUI::Widget* mRightPane; + MyGUI::WidgetPtr skillAreaWidget, skillClientWidget; MyGUI::ScrollBar* skillScrollerWidget; int lastPos, clientHeight; diff --git a/files/mygui/openmw_stats_window_layout.xml b/files/mygui/openmw_stats_window_layout.xml index 4f3f80e89..4056216ad 100644 --- a/files/mygui/openmw_stats_window_layout.xml +++ b/files/mygui/openmw_stats_window_layout.xml @@ -3,59 +3,68 @@ - - - - - - - - - - - - + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + - - + + - - + + - - + + - - + + - - + + - - + + + - - - - - - + + + + + + + + + From 1f1edea6af072a49889c5fac07fe2ab01aece314 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 11 May 2012 08:45:03 +0200 Subject: [PATCH 3/6] make it possible to use scroll wheel when mouse is over a skill in the stats window; set the correct track size for the scrollbar --- apps/openmw/mwgui/stats_window.cpp | 23 +++++++++++++++++++++- apps/openmw/mwgui/stats_window.hpp | 1 + files/mygui/openmw_stats_window_layout.xml | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 9e6e17391..2736270e1 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -63,6 +63,8 @@ StatsWindow::StatsWindow (WindowManager& parWindowManager) getWidget(mLeftPane, "LeftPane"); getWidget(mRightPane, "RightPane"); + skillClientWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); + skillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &StatsWindow::onScrollChangePosition); updateScroller(); @@ -93,6 +95,18 @@ void StatsWindow::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos) } } +void StatsWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel) +{ + if (skillScrollerWidget->getScrollPosition() - _rel*0.3 < 0) + skillScrollerWidget->setScrollPosition(0); + else if (skillScrollerWidget->getScrollPosition() - _rel*0.3 > skillScrollerWidget->getScrollRange()-1) + skillScrollerWidget->setScrollPosition(skillScrollerWidget->getScrollRange()-1); + else + skillScrollerWidget->setScrollPosition(skillScrollerWidget->getScrollPosition() - _rel*0.3); + + onScrollChangePosition(skillScrollerWidget, skillScrollerWidget->getScrollPosition()); +} + void StatsWindow::onWindowResize(MyGUI::Window* window) { mLeftPane->setCoord( MyGUI::IntCoord(0, 0, 0.44*window->getSize().width, window->getSize().height) ); @@ -237,6 +251,7 @@ void StatsWindow::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) MyGUI::ImageBox* separator = skillClientWidget->createWidget("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch); + separator->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); skillWidgets.push_back(separator); coord1.top += separator->getHeight(); @@ -249,6 +264,7 @@ void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, My MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch); groupWidget->setCaption(label); + groupWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); skillWidgets.push_back(groupWidget); coord1.top += lineHeight; @@ -263,12 +279,14 @@ MyGUI::TextBox* StatsWindow::addValueItem(const std::string& text, const std::st skillNameWidget->setCaption(text); skillNameWidget->setUserString("ToolTipType", "Text"); skillNameWidget->setUserString("ToolTipText", tooltip); + skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); skillValueWidget = skillClientWidget->createWidget("SandTextRight", coord2, MyGUI::Align::Right | MyGUI::Align::Top); skillValueWidget->setUserString("ToolTipType", "Text"); skillValueWidget->setUserString("ToolTipText", tooltip); skillValueWidget->setCaption(value); skillValueWidget->_setWidgetState(state); + skillValueWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); skillWidgets.push_back(skillNameWidget); skillWidgets.push_back(skillValueWidget); @@ -285,6 +303,7 @@ void StatsWindow::addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI skillNameWidget = skillClientWidget->createWidget("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default); skillNameWidget->setCaption(text); + skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); skillWidgets.push_back(skillNameWidget); @@ -370,7 +389,7 @@ void StatsWindow::updateSkillArea() if (!skillWidgets.empty()) addSeparator(coord1, coord2); - addGroup(mWindowManager.getGameSettingString("sSign", "Sign"), coord1, coord2); + addGroup(mWindowManager.getGameSettingString("sBirthSign", "Sign"), coord1, coord2); const ESM::BirthSign *sign = store.birthSigns.find(birthSignId); addItem(sign->name, coord1, coord2); } @@ -394,6 +413,8 @@ void StatsWindow::updateScroller() { skillScrollerWidget->setScrollRange(std::max(clientHeight - skillClientWidget->getHeight(), 0)); skillScrollerWidget->setScrollPage(std::max(skillClientWidget->getHeight() - lineHeight, 0)); + if (clientHeight != 0) + skillScrollerWidget->setTrackSize( (skillAreaWidget->getHeight() / float(clientHeight)) * skillAreaWidget->getHeight() ); } void StatsWindow::onPinToggled() diff --git a/apps/openmw/mwgui/stats_window.hpp b/apps/openmw/mwgui/stats_window.hpp index b201b3387..08c5148ec 100644 --- a/apps/openmw/mwgui/stats_window.hpp +++ b/apps/openmw/mwgui/stats_window.hpp @@ -54,6 +54,7 @@ namespace MWGui void onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos); void onWindowResize(MyGUI::Window* window); + void onMouseWheel(MyGUI::Widget* _sender, int _rel); static const int lineHeight; diff --git a/files/mygui/openmw_stats_window_layout.xml b/files/mygui/openmw_stats_window_layout.xml index 4056216ad..9406fe6bd 100644 --- a/files/mygui/openmw_stats_window_layout.xml +++ b/files/mygui/openmw_stats_window_layout.xml @@ -60,7 +60,7 @@ - + From 83e434e2e91c8a21becb88fac8687271cf42d8c2 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 11 May 2012 09:35:18 +0200 Subject: [PATCH 4/6] small fix --- apps/openmw/mwgui/stats_window.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 2736270e1..186668222 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -414,7 +414,7 @@ void StatsWindow::updateScroller() skillScrollerWidget->setScrollRange(std::max(clientHeight - skillClientWidget->getHeight(), 0)); skillScrollerWidget->setScrollPage(std::max(skillClientWidget->getHeight() - lineHeight, 0)); if (clientHeight != 0) - skillScrollerWidget->setTrackSize( (skillAreaWidget->getHeight() / float(clientHeight)) * skillAreaWidget->getHeight() ); + skillScrollerWidget->setTrackSize( (skillAreaWidget->getHeight() / float(clientHeight)) * skillScrollerWidget->getLineSize() ); } void StatsWindow::onPinToggled() From a99f74702ed26f9c3bacfca5ed9688816c618132 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 11 May 2012 09:57:43 +0200 Subject: [PATCH 5/6] workaround for a white square that appears in menubook_next texture --- files/mygui/openmw_book_layout.xml | 2 +- files/mygui/openmw_journal_layout.xml | 2 +- files/mygui/openmw_resources.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/files/mygui/openmw_book_layout.xml b/files/mygui/openmw_book_layout.xml index 07ebf5030..6c708cdd3 100644 --- a/files/mygui/openmw_book_layout.xml +++ b/files/mygui/openmw_book_layout.xml @@ -7,7 +7,7 @@ - + diff --git a/files/mygui/openmw_journal_layout.xml b/files/mygui/openmw_journal_layout.xml index 75bb5eea1..e4c3c7e47 100644 --- a/files/mygui/openmw_journal_layout.xml +++ b/files/mygui/openmw_journal_layout.xml @@ -7,7 +7,7 @@ - + diff --git a/files/mygui/openmw_resources.xml b/files/mygui/openmw_resources.xml index 455765aad..b2bd90d10 100644 --- a/files/mygui/openmw_resources.xml +++ b/files/mygui/openmw_resources.xml @@ -72,7 +72,7 @@ - + From 82b9f835b1a907f72acec44a325cb1d5a74bf85e Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 13 May 2012 16:54:18 +0200 Subject: [PATCH 6/6] make sure iterator is not end() before trying to get the equipped item --- apps/openmw/mwworld/containerstore.cpp | 2 +- apps/openmw/mwworld/containerstore.hpp | 2 +- apps/openmw/mwworld/inventorystore.cpp | 4 ++-- apps/openmw/mwworld/inventorystore.hpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index dcddc333b..ee1b620cd 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -45,7 +45,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::end() return ContainerStoreIterator (this); } -bool MWWorld::ContainerStore::stacks(const Ptr& ptr1, const Ptr& ptr2) const +bool MWWorld::ContainerStore::stacks(const Ptr& ptr1, const Ptr& ptr2) { /// \todo add current weapon/armor health, remaining lockpick/repair uses, current enchantment charge here as soon as they are implemented if ( ptr1.mCellRef->refID == ptr2.mCellRef->refID diff --git a/apps/openmw/mwworld/containerstore.hpp b/apps/openmw/mwworld/containerstore.hpp index f0e9d7e4a..3cb3f3bdc 100644 --- a/apps/openmw/mwworld/containerstore.hpp +++ b/apps/openmw/mwworld/containerstore.hpp @@ -78,7 +78,7 @@ namespace MWWorld void addImpl (const Ptr& ptr); ///< Add the item to this container (no stacking) - virtual bool stacks (const Ptr& ptr1, const Ptr& ptr2) const; + virtual bool stacks (const Ptr& ptr1, const Ptr& ptr2); ///< @return true if the two specified objects can stack with each other /// @note ptr1 is the item that is already in this container diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 6cf35ac64..3e535793c 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -201,7 +201,7 @@ void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats) } } -bool MWWorld::InventoryStore::stacks(const Ptr& ptr1, const Ptr& ptr2) const +bool MWWorld::InventoryStore::stacks(const Ptr& ptr1, const Ptr& ptr2) { bool canStack = MWWorld::ContainerStore::stacks(ptr1, ptr2); if (!canStack) @@ -211,7 +211,7 @@ bool MWWorld::InventoryStore::stacks(const Ptr& ptr1, const Ptr& ptr2) const for (TSlots::const_iterator iter (mSlots.begin()); iter!=mSlots.end(); ++iter) { - if (ptr1 == **iter) + if (*iter != end() && ptr1 == **iter) return false; } diff --git a/apps/openmw/mwworld/inventorystore.hpp b/apps/openmw/mwworld/inventorystore.hpp index 4162c7e2e..05fc651ee 100644 --- a/apps/openmw/mwworld/inventorystore.hpp +++ b/apps/openmw/mwworld/inventorystore.hpp @@ -67,7 +67,7 @@ namespace MWWorld protected: - virtual bool stacks (const Ptr& ptr1, const Ptr& ptr2) const; + virtual bool stacks (const Ptr& ptr1, const Ptr& ptr2); ///< @return true if the two specified objects can stack with each other /// @note ptr1 is the item that is already in this container