From bba024d6ad5c2398ee57ff873fb092293d77f618 Mon Sep 17 00:00:00 2001 From: Sergey Shambir Date: Sun, 10 Feb 2013 08:37:45 +0400 Subject: [PATCH 01/15] Right mouse button click now stops Container GuiMode. --- apps/openmw/mwinput/inputmanagerimp.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 1f270df8b..63afa3260 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -579,10 +579,14 @@ namespace MWInput // Toggle between game mode and inventory mode if(gameMode) mWindows.pushGuiMode(MWGui::GM_Inventory); - else if(mWindows.getMode() == MWGui::GM_Inventory) - mWindows.popGuiMode(); + else + { + MWGui::GuiMode mode = mWindows.getMode(); + if(mode == MWGui::GM_Inventory || mode == MWGui::GM_Container) + mWindows.popGuiMode(); + } - // .. but don't touch any other mode. + // .. but don't touch any other mode, except container. } void InputManager::toggleConsole() From 725bfe637218b4b87386f7bb7b385378556319d2 Mon Sep 17 00:00:00 2001 From: Sergey Shambir Date: Sun, 10 Feb 2013 08:50:36 +0400 Subject: [PATCH 02/15] TradeWindow: balance now changes per time if user holds +/- button pressed --- apps/openmw/mwgui/tradewindow.cpp | 51 +++++++++++++++++++++++--- apps/openmw/mwgui/tradewindow.hpp | 18 ++++++++- apps/openmw/mwgui/windowmanagerimp.cpp | 1 + 3 files changed, 63 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 51eb3d87e..2cc8ff444 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -19,12 +19,17 @@ #include "inventorywindow.hpp" +static const float BALANCE_CHANGE_INITIAL_PAUSE = 0.5; // in seconds +static const float BALANCE_CHANGE_INTERVAL = 0.1; // in seconds + namespace MWGui { TradeWindow::TradeWindow(MWBase::WindowManager& parWindowManager) : WindowBase("openmw_trade_window.layout", parWindowManager) , ContainerBase(NULL) // no drag&drop , mCurrentBalance(0) + , mBalanceButtonsState(BBS_None) + , mBalanceChangePause(0.0) { MyGUI::ScrollView* itemView; MyGUI::Widget* containerWidget; @@ -59,8 +64,10 @@ namespace MWGui mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onCancelButtonClicked); mOfferButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onOfferButtonClicked); - mIncreaseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onIncreaseButtonClicked); - mDecreaseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onDecreaseButtonClicked); + mIncreaseButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &TradeWindow::onIncreaseButtonPressed); + mIncreaseButton->eventMouseButtonReleased += MyGUI::newDelegate(this, &TradeWindow::onBalanceButtonReleased); + mDecreaseButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &TradeWindow::onDecreaseButtonPressed); + mDecreaseButton->eventMouseButtonReleased += MyGUI::newDelegate(this, &TradeWindow::onBalanceButtonReleased); setCoord(400, 0, 400, 300); @@ -143,6 +150,21 @@ namespace MWGui } } + void TradeWindow::onFrame(float frameDuration) + { + if (!mMainWidget->getVisible() || mBalanceButtonsState == BBS_None) + return; + + mBalanceChangePause -= frameDuration; + if (mBalanceChangePause < 0.0) { + mBalanceChangePause += BALANCE_CHANGE_INTERVAL; + if (mBalanceButtonsState == BBS_Increase) + onIncreaseButtonTriggered(); + else if (mBalanceButtonsState == BBS_Decrease) + onDecreaseButtonTriggered(); + } + } + void TradeWindow::onOfferButtonClicked(MyGUI::Widget* _sender) { const MWWorld::Store &gmst = @@ -242,7 +264,7 @@ namespace MWGui //skill use! MWWorld::Class::get(playerPtr).skillUsageSucceeded(playerPtr, ESM::Skill::Mercantile, 0); - } + } int iBarterSuccessDisposition = gmst.find("iBarterSuccessDisposition")->getInt(); MWBase::Environment::get().getDialogueManager()->applyTemporaryDispositionChange(iBarterSuccessDisposition); @@ -271,14 +293,33 @@ namespace MWGui mWindowManager.removeGuiMode(GM_Barter); } - void TradeWindow::onIncreaseButtonClicked(MyGUI::Widget* _sender) + void TradeWindow::onIncreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id) + { + mBalanceButtonsState = BBS_Increase; + mBalanceChangePause = BALANCE_CHANGE_INITIAL_PAUSE; + onIncreaseButtonTriggered(); + } + + void TradeWindow::onDecreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id) + { + mBalanceButtonsState = BBS_Decrease; + mBalanceChangePause = BALANCE_CHANGE_INITIAL_PAUSE; + onDecreaseButtonTriggered(); + } + + void TradeWindow::onBalanceButtonReleased(MyGUI::Widget *_sender, int _left, int _top, MyGUI::MouseButton _id) + { + mBalanceButtonsState = BBS_None; + } + + void TradeWindow::onIncreaseButtonTriggered() { if(mCurrentBalance<=-1) mCurrentBalance -= 1; if(mCurrentBalance>=1) mCurrentBalance += 1; updateLabels(); } - void TradeWindow::onDecreaseButtonClicked(MyGUI::Widget* _sender) + void TradeWindow::onDecreaseButtonTriggered() { if(mCurrentBalance<-1) mCurrentBalance += 1; if(mCurrentBalance>1) mCurrentBalance -= 1; diff --git a/apps/openmw/mwgui/tradewindow.hpp b/apps/openmw/mwgui/tradewindow.hpp index 219e44036..20d9b6069 100644 --- a/apps/openmw/mwgui/tradewindow.hpp +++ b/apps/openmw/mwgui/tradewindow.hpp @@ -34,6 +34,8 @@ namespace MWGui void addOrRemoveGold(int gold); + void onFrame(float frameDuration); + protected: MyGUI::Button* mFilterAll; MyGUI::Button* mFilterWeapon; @@ -57,12 +59,24 @@ namespace MWGui int mCurrentBalance; int mCurrentMerchantOffer; + enum BalanceButtonsState { + BBS_None, + BBS_Increase, + BBS_Decrease + } mBalanceButtonsState; + /// pause before next balance change will trigger while user holds +/- button pressed + float mBalanceChangePause; + void onWindowResize(MyGUI::Window* _sender); void onFilterChanged(MyGUI::Widget* _sender); void onOfferButtonClicked(MyGUI::Widget* _sender); void onCancelButtonClicked(MyGUI::Widget* _sender); - void onIncreaseButtonClicked(MyGUI::Widget* _sender); - void onDecreaseButtonClicked(MyGUI::Widget* _sender); + void onIncreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id); + void onDecreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id); + void onBalanceButtonReleased(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id); + + void onIncreaseButtonTriggered(); + void onDecreaseButtonTriggered(); // don't show items that the NPC has equipped in his trade-window. virtual bool ignoreEquippedItems() { return true; } diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 8ec495550..9663def5d 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -608,6 +608,7 @@ void WindowManager::onFrame (float frameDuration) mHud->onFrame(frameDuration); mTrainingWindow->onFrame (frameDuration); + mTradeWindow->onFrame(frameDuration); mTrainingWindow->checkReferenceAvailable(); mDialogueWindow->checkReferenceAvailable(); From 59808c3e10e0088def9bb4c07f7a5efeb69ab1c6 Mon Sep 17 00:00:00 2001 From: Sergey Shambir Date: Sun, 10 Feb 2013 08:59:38 +0400 Subject: [PATCH 03/15] GUI: Birth and Class dialogs now both select 1st item in list at first time. --- apps/openmw/mwgui/birth.cpp | 16 +++++++++++----- apps/openmw/mwgui/class.cpp | 9 ++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 4837821e0..99d6605d3 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -133,8 +133,6 @@ void BirthDialog::updateBirths() const MWWorld::Store &signs = MWBase::Environment::get().getWorld()->getStore().get(); - int index = 0; - // sort by name std::vector < std::pair > birthSigns; @@ -145,12 +143,20 @@ void BirthDialog::updateBirths() } std::sort(birthSigns.begin(), birthSigns.end(), sortBirthSigns); - for (std::vector < std::pair >::const_iterator it2 = birthSigns.begin(); it2 != birthSigns.end(); ++it2) + int index = 0; + for (std::vector >::const_iterator it2 = birthSigns.begin(); + it2 != birthSigns.end(); ++it2, ++index) { mBirthList->addItem(it2->second->mName, it2->first); - if (boost::iequals(it2->first, mCurrentBirthId)) + if (mCurrentBirthId.empty()) + { mBirthList->setIndexSelected(index); - ++index; + mCurrentBirthId = it2->first; + } + else if (boost::iequals(it2->first, mCurrentBirthId)) + { + mBirthList->setIndexSelected(index); + } } } diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index c14c7f74b..475efaab3 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -197,8 +197,15 @@ void PickClassDialog::updateClasses() const std::string &id = it->mId; mClassList->addItem(it->mName, id); - if (boost::iequals(id, mCurrentClassId)) + if (mCurrentClassId.empty()) + { + mCurrentClassId = id; mClassList->setIndexSelected(index); + } + else if (boost::iequals(id, mCurrentClassId)) + { + mClassList->setIndexSelected(index); + } ++index; } } From 4da11a96a5d51c0c22b62e033fb46ffaa7823f6c Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 15 Feb 2013 17:34:55 +0100 Subject: [PATCH 04/15] Fixed gold ref count always becoming 1 when dropped on the ground --- apps/openmw/mwclass/misc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 94d40bcb7..a21cc2aef 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -210,6 +210,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = newRef.getPtr().get(); newPtr = MWWorld::Ptr(&cell.mMiscItems.insert(*ref), &cell); + newPtr.getRefData ().setCount(goldAmount); } else { MWWorld::LiveCellRef *ref = ptr.get(); From df5919f2c59eeca4d38dd60b888d2aff019548b9 Mon Sep 17 00:00:00 2001 From: Douglas Mencken Date: Sat, 2 Feb 2013 10:17:20 -0500 Subject: [PATCH 05/15] Use `signed char' explicitly where needed. It is important because: - It is implementation-dependent if plain `char' signed or not. - C standard defines three *distinct* types: char, signed char, and unsigned char. - Assuming that char is always unsigned or signed can lead to compile-time and run-time errors. You can also use int8_t, but then it would be less obvious for developers to never assume that char is always unsigned (or always signed). Conflicts: components/esm/loadcell.hpp --- apps/esmtool/labels.cpp | 16 ++++++++-------- apps/esmtool/labels.hpp | 6 +++--- components/esm/loadcell.hpp | 12 ++++++------ components/esm/loaddial.hpp | 2 +- components/to_utf8/tables_gen.hpp | 6 +++--- components/to_utf8/to_utf8.cpp | 2 +- components/to_utf8/to_utf8.hpp | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/apps/esmtool/labels.cpp b/apps/esmtool/labels.cpp index 9fb233237..d7d3cf9ce 100644 --- a/apps/esmtool/labels.cpp +++ b/apps/esmtool/labels.cpp @@ -16,7 +16,7 @@ #include #include -std::string bodyPartLabel(char idx) +std::string bodyPartLabel(signed char idx) { const char *bodyPartLabels[] = { "Head", @@ -47,14 +47,14 @@ std::string bodyPartLabel(char idx) "Weapon", "Tail" }; - + if ((int)idx >= 0 && (int)(idx) <= 26) return bodyPartLabels[(int)(idx)]; else return "Invalid"; } -std::string meshPartLabel(char idx) +std::string meshPartLabel(signed char idx) { const char *meshPartLabels[] = { "Head", @@ -73,25 +73,25 @@ std::string meshPartLabel(char idx) "Clavicle", "Tail" }; - + if ((int)(idx) >= 0 && (int)(idx) <= ESM::BodyPart::MP_Tail) return meshPartLabels[(int)(idx)]; else return "Invalid"; } -std::string meshTypeLabel(char idx) +std::string meshTypeLabel(signed char idx) { const char *meshTypeLabels[] = { "Skin", "Clothing", "Armor" }; - + if ((int)(idx) >= 0 && (int)(idx) <= ESM::BodyPart::MT_Armor) return meshTypeLabels[(int)(idx)]; else - return "Invalid"; + return "Invalid"; } std::string clothingTypeLabel(int idx) @@ -108,7 +108,7 @@ std::string clothingTypeLabel(int idx) "Ring", "Amulet" }; - + if (idx >= 0 && idx <= 9) return clothingTypeLabels[idx]; else diff --git a/apps/esmtool/labels.hpp b/apps/esmtool/labels.hpp index 7f1ff7986..bf3958037 100644 --- a/apps/esmtool/labels.hpp +++ b/apps/esmtool/labels.hpp @@ -3,9 +3,9 @@ #include -std::string bodyPartLabel(char idx); -std::string meshPartLabel(char idx); -std::string meshTypeLabel(char idx); +std::string bodyPartLabel(signed char idx); +std::string meshPartLabel(signed char idx); +std::string meshTypeLabel(signed char idx); std::string clothingTypeLabel(int idx); std::string armorTypeLabel(int idx); std::string dialogTypeLabel(int idx); diff --git a/components/esm/loadcell.hpp b/components/esm/loadcell.hpp index 27bdd77ce..de467666e 100644 --- a/components/esm/loadcell.hpp +++ b/components/esm/loadcell.hpp @@ -77,8 +77,8 @@ public: std::string mKey, mTrap; // Key and trap ID names, if any // No idea - occurs ONCE in Morrowind.esm, for an activator - char mUnam; - + signed char mUnam; + // Track deleted references. 0 - not deleted, 1 - deleted, but respawns, 2 - deleted and does not respawn. int mDeleted; @@ -164,14 +164,14 @@ struct Cell bool mWaterInt; int mMapColor; int mNAM0; - + // References "leased" from another cell (i.e. a different cell // introduced this ref, and it has been moved here by a plugin) CellRefTracker mLeasedRefs; MovedCellRefTracker mMovedRefs; - + void load(ESMReader &esm, MWWorld::ESMStore &store); - + // This method is left in for compatibility with esmtool. Parsing moved references currently requires // passing ESMStore, bit it does not know about this parameter, so we do it this way. void load(ESMReader &esm) {}; @@ -209,7 +209,7 @@ struct Cell reuse one memory location without blanking it between calls. */ static bool getNextRef(ESMReader &esm, CellRef &ref); - + /* This fetches an MVRF record, which is used to track moved references. * Since they are comparably rare, we use a separate method for this. */ diff --git a/components/esm/loaddial.hpp b/components/esm/loaddial.hpp index 078c78811..61f3f763d 100644 --- a/components/esm/loaddial.hpp +++ b/components/esm/loaddial.hpp @@ -30,7 +30,7 @@ struct Dialogue }; std::string mId; - char mType; + signed char mType; std::vector mInfo; void load(ESMReader &esm); diff --git a/components/to_utf8/tables_gen.hpp b/components/to_utf8/tables_gen.hpp index 9c32f0427..a1d4b6d80 100644 --- a/components/to_utf8/tables_gen.hpp +++ b/components/to_utf8/tables_gen.hpp @@ -8,7 +8,7 @@ namespace ToUTF8 /// Central European and Eastern European languages that use Latin script, /// such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, /// Serbian (Latin script), Romanian and Albanian. -static char windows_1250[] = +static signed char windows_1250[] = { 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, @@ -270,7 +270,7 @@ static char windows_1250[] = /// Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic /// and other languages -static char windows_1251[] = +static signed char windows_1251[] = { 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, @@ -531,7 +531,7 @@ static char windows_1251[] = }; /// Latin alphabet used by English and some other Western languages -static char windows_1252[] = +static signed char windows_1252[] = { 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, diff --git a/components/to_utf8/to_utf8.cpp b/components/to_utf8/to_utf8.cpp index 275f5483f..e2a1b1220 100644 --- a/components/to_utf8/to_utf8.cpp +++ b/components/to_utf8/to_utf8.cpp @@ -216,7 +216,7 @@ void Utf8Encoder::copyFromArray(unsigned char ch, char* &out) return; } - const char *in = translationArray + ch*6; + const signed char *in = translationArray + ch*6; int len = *(in++); for (int i=0; i mOutput; - char* translationArray; + signed char* translationArray; }; } From a3e421167b3703e9943d82fb804073c99ac55651 Mon Sep 17 00:00:00 2001 From: Douglas Mencken Date: Sat, 9 Feb 2013 15:11:09 -0500 Subject: [PATCH 06/15] esmtool/labels: bodyPartLabel, meshPartLabel, meshTypeLabel Signed chars, unsigned chars... Just use int for index everywhere. --- apps/esmtool/labels.cpp | 18 +++++++++--------- apps/esmtool/labels.hpp | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/esmtool/labels.cpp b/apps/esmtool/labels.cpp index d7d3cf9ce..f08c31003 100644 --- a/apps/esmtool/labels.cpp +++ b/apps/esmtool/labels.cpp @@ -16,7 +16,7 @@ #include #include -std::string bodyPartLabel(signed char idx) +std::string bodyPartLabel(int idx) { const char *bodyPartLabels[] = { "Head", @@ -48,13 +48,13 @@ std::string bodyPartLabel(signed char idx) "Tail" }; - if ((int)idx >= 0 && (int)(idx) <= 26) - return bodyPartLabels[(int)(idx)]; + if (idx >= 0 && idx <= 26) + return bodyPartLabels[idx]; else return "Invalid"; } -std::string meshPartLabel(signed char idx) +std::string meshPartLabel(int idx) { const char *meshPartLabels[] = { "Head", @@ -74,13 +74,13 @@ std::string meshPartLabel(signed char idx) "Tail" }; - if ((int)(idx) >= 0 && (int)(idx) <= ESM::BodyPart::MP_Tail) - return meshPartLabels[(int)(idx)]; + if (idx >= 0 && idx <= ESM::BodyPart::MP_Tail) + return meshPartLabels[idx]; else return "Invalid"; } -std::string meshTypeLabel(signed char idx) +std::string meshTypeLabel(int idx) { const char *meshTypeLabels[] = { "Skin", @@ -88,8 +88,8 @@ std::string meshTypeLabel(signed char idx) "Armor" }; - if ((int)(idx) >= 0 && (int)(idx) <= ESM::BodyPart::MT_Armor) - return meshTypeLabels[(int)(idx)]; + if (idx >= 0 && idx <= ESM::BodyPart::MT_Armor) + return meshTypeLabels[idx]; else return "Invalid"; } diff --git a/apps/esmtool/labels.hpp b/apps/esmtool/labels.hpp index bf3958037..48d7b249b 100644 --- a/apps/esmtool/labels.hpp +++ b/apps/esmtool/labels.hpp @@ -3,9 +3,9 @@ #include -std::string bodyPartLabel(signed char idx); -std::string meshPartLabel(signed char idx); -std::string meshTypeLabel(signed char idx); +std::string bodyPartLabel(int idx); +std::string meshPartLabel(int idx); +std::string meshTypeLabel(int idx); std::string clothingTypeLabel(int idx); std::string armorTypeLabel(int idx); std::string dialogTypeLabel(int idx); From eb09662f1ddd67cdae0c5af2b1d96aa0ceba3d9e Mon Sep 17 00:00:00 2001 From: Douglas Mencken Date: Thu, 14 Feb 2013 04:22:00 -0500 Subject: [PATCH 07/15] Don't include boost/filesystem/v3/operations.hpp, use boost/filesystem/operations.hpp instead. It is boost headers' job to deal with their internals. --- apps/openmw/mwworld/esmstore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index 1666ad823..257676076 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include namespace MWWorld { From 7d918caa9355f59cb37f38c326a5fbf9523d9604 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 16 Feb 2013 16:26:40 +0100 Subject: [PATCH 08/15] Don't allow dialogue if player controls are disabled. --- apps/openmw/mwworld/actiontalk.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/actiontalk.cpp b/apps/openmw/mwworld/actiontalk.cpp index 905497f85..59b37370a 100644 --- a/apps/openmw/mwworld/actiontalk.cpp +++ b/apps/openmw/mwworld/actiontalk.cpp @@ -3,6 +3,7 @@ #include "../mwbase/environment.hpp" #include "../mwbase/dialoguemanager.hpp" +#include "../mwbase/inputmanager.hpp" namespace MWWorld { @@ -10,6 +11,7 @@ namespace MWWorld void ActionTalk::executeImp (const Ptr& actor) { - MWBase::Environment::get().getDialogueManager()->startDialogue (getTarget()); + if (MWBase::Environment::get().getInputManager ()->getControlSwitch ("playercontrols")) + MWBase::Environment::get().getDialogueManager()->startDialogue (getTarget()); } } From 0bc34c1c0d7eb10fd7eb942efd23d7443be6e328 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 16 Feb 2013 16:40:44 +0100 Subject: [PATCH 09/15] Action::executeImp returns a bool value to indicate if the sound should be played. --- apps/openmw/mwworld/action.cpp | 4 +--- apps/openmw/mwworld/action.hpp | 3 ++- apps/openmw/mwworld/actionalchemy.cpp | 3 ++- apps/openmw/mwworld/actionalchemy.hpp | 2 +- apps/openmw/mwworld/actionapply.cpp | 6 ++++-- apps/openmw/mwworld/actionapply.hpp | 4 ++-- apps/openmw/mwworld/actioneat.cpp | 4 +++- apps/openmw/mwworld/actioneat.hpp | 2 +- apps/openmw/mwworld/actionequip.cpp | 4 +++- apps/openmw/mwworld/actionequip.hpp | 2 +- apps/openmw/mwworld/actionopen.cpp | 5 +++-- apps/openmw/mwworld/actionopen.hpp | 2 +- apps/openmw/mwworld/actionread.cpp | 3 ++- apps/openmw/mwworld/actionread.hpp | 2 +- apps/openmw/mwworld/actiontake.cpp | 6 ++++-- apps/openmw/mwworld/actiontake.hpp | 2 +- apps/openmw/mwworld/actiontalk.cpp | 6 +++++- apps/openmw/mwworld/actiontalk.hpp | 2 +- apps/openmw/mwworld/actionteleport.cpp | 3 ++- apps/openmw/mwworld/actionteleport.hpp | 2 +- apps/openmw/mwworld/failedaction.cpp | 9 +++++---- apps/openmw/mwworld/failedaction.hpp | 4 ++-- apps/openmw/mwworld/nullaction.hpp | 2 +- 23 files changed, 49 insertions(+), 33 deletions(-) diff --git a/apps/openmw/mwworld/action.cpp b/apps/openmw/mwworld/action.cpp index a5199fb3e..b4897109a 100644 --- a/apps/openmw/mwworld/action.cpp +++ b/apps/openmw/mwworld/action.cpp @@ -18,7 +18,7 @@ MWWorld::Action::~Action() {} void MWWorld::Action::execute (const Ptr& actor) { - if (!mSoundId.empty()) + if (!mSoundId.empty() && executeImp (actor)) { if (mKeepSound && actor.getRefData().getHandle()=="player") { @@ -35,8 +35,6 @@ void MWWorld::Action::execute (const Ptr& actor) mKeepSound ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal); } } - - executeImp (actor); } void MWWorld::Action::setSound (const std::string& id) diff --git a/apps/openmw/mwworld/action.hpp b/apps/openmw/mwworld/action.hpp index d8e5d93bb..42c2ad084 100644 --- a/apps/openmw/mwworld/action.hpp +++ b/apps/openmw/mwworld/action.hpp @@ -18,7 +18,8 @@ namespace MWWorld Action (const Action& action); Action& operator= (const Action& action); - virtual void executeImp (const Ptr& actor) = 0; + /// @return true if the sound should be played, false if not (e.g. if the action is not allowed) + virtual bool executeImp (const Ptr& actor) = 0; protected: diff --git a/apps/openmw/mwworld/actionalchemy.cpp b/apps/openmw/mwworld/actionalchemy.cpp index bba75bc49..20093279e 100644 --- a/apps/openmw/mwworld/actionalchemy.cpp +++ b/apps/openmw/mwworld/actionalchemy.cpp @@ -5,8 +5,9 @@ namespace MWWorld { - void ActionAlchemy::executeImp (const Ptr& actor) + bool ActionAlchemy::executeImp (const Ptr& actor) { MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Alchemy); + return true; } } diff --git a/apps/openmw/mwworld/actionalchemy.hpp b/apps/openmw/mwworld/actionalchemy.hpp index e6d1a7976..814f347c8 100644 --- a/apps/openmw/mwworld/actionalchemy.hpp +++ b/apps/openmw/mwworld/actionalchemy.hpp @@ -7,7 +7,7 @@ namespace MWWorld { class ActionAlchemy : public Action { - virtual void executeImp (const Ptr& actor); + virtual bool executeImp (const Ptr& actor); }; } diff --git a/apps/openmw/mwworld/actionapply.cpp b/apps/openmw/mwworld/actionapply.cpp index f78b8f798..2a41b5613 100644 --- a/apps/openmw/mwworld/actionapply.cpp +++ b/apps/openmw/mwworld/actionapply.cpp @@ -9,9 +9,10 @@ namespace MWWorld : Action (false, target), mId (id) {} - void ActionApply::executeImp (const Ptr& actor) + bool ActionApply::executeImp (const Ptr& actor) { MWWorld::Class::get (getTarget()).apply (getTarget(), mId, actor); + return true; } @@ -20,9 +21,10 @@ namespace MWWorld : Action (false, target), mId (id), mSkillIndex (skillIndex), mUsageType (usageType) {} - void ActionApplyWithSkill::executeImp (const Ptr& actor) + bool ActionApplyWithSkill::executeImp (const Ptr& actor) { if (MWWorld::Class::get (getTarget()).apply (getTarget(), mId, actor) && mUsageType!=-1) MWWorld::Class::get (getTarget()).skillUsageSucceeded (actor, mSkillIndex, mUsageType); + return true; } } diff --git a/apps/openmw/mwworld/actionapply.hpp b/apps/openmw/mwworld/actionapply.hpp index 3353ae0ee..53b2de1d0 100644 --- a/apps/openmw/mwworld/actionapply.hpp +++ b/apps/openmw/mwworld/actionapply.hpp @@ -13,7 +13,7 @@ namespace MWWorld { std::string mId; - virtual void executeImp (const Ptr& actor); + virtual bool executeImp (const Ptr& actor); public: @@ -26,7 +26,7 @@ namespace MWWorld int mSkillIndex; int mUsageType; - virtual void executeImp (const Ptr& actor); + virtual bool executeImp (const Ptr& actor); public: diff --git a/apps/openmw/mwworld/actioneat.cpp b/apps/openmw/mwworld/actioneat.cpp index 63efff738..81c45f051 100644 --- a/apps/openmw/mwworld/actioneat.cpp +++ b/apps/openmw/mwworld/actioneat.cpp @@ -16,7 +16,7 @@ namespace MWWorld { - void ActionEat::executeImp (const Ptr& actor) + bool ActionEat::executeImp (const Ptr& actor) { // remove used item getTarget().getRefData().setCount (getTarget().getRefData().getCount()-1); @@ -42,6 +42,8 @@ namespace MWWorld // increase skill Class::get (actor).skillUsageSucceeded (actor, ESM::Skill::Alchemy, 1); } + + return true; } ActionEat::ActionEat (const MWWorld::Ptr& object) : Action (false, object) {} diff --git a/apps/openmw/mwworld/actioneat.hpp b/apps/openmw/mwworld/actioneat.hpp index ce5330db7..265f5aa68 100644 --- a/apps/openmw/mwworld/actioneat.hpp +++ b/apps/openmw/mwworld/actioneat.hpp @@ -8,7 +8,7 @@ namespace MWWorld { class ActionEat : public Action { - virtual void executeImp (const Ptr& actor); + virtual bool executeImp (const Ptr& actor); public: diff --git a/apps/openmw/mwworld/actionequip.cpp b/apps/openmw/mwworld/actionequip.cpp index 2d257aa61..902e0fdb6 100644 --- a/apps/openmw/mwworld/actionequip.cpp +++ b/apps/openmw/mwworld/actionequip.cpp @@ -16,7 +16,7 @@ namespace MWWorld { } - void ActionEquip::executeImp (const Ptr& actor) + bool ActionEquip::executeImp (const Ptr& actor) { MWWorld::InventoryStore& invStore = MWWorld::Class::get(actor).getInventoryStore(actor); @@ -113,5 +113,7 @@ namespace MWWorld /* Set OnPCEquip Variable on item's script, if the player is equipping it, and it has a script with that variable declared */ if(equipped && actor == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() && script != "") (*it).mRefData->getLocals().setVarByInt(script, "onpcequip", 1); + + return true; } } diff --git a/apps/openmw/mwworld/actionequip.hpp b/apps/openmw/mwworld/actionequip.hpp index 3b56c7402..fb3a1ac10 100644 --- a/apps/openmw/mwworld/actionequip.hpp +++ b/apps/openmw/mwworld/actionequip.hpp @@ -8,7 +8,7 @@ namespace MWWorld { class ActionEquip : public Action { - virtual void executeImp (const Ptr& actor); + virtual bool executeImp (const Ptr& actor); public: /// @param item to equip diff --git a/apps/openmw/mwworld/actionopen.cpp b/apps/openmw/mwworld/actionopen.cpp index 040a3856e..da570dff0 100644 --- a/apps/openmw/mwworld/actionopen.cpp +++ b/apps/openmw/mwworld/actionopen.cpp @@ -14,12 +14,13 @@ namespace MWWorld { } - void ActionOpen::executeImp (const MWWorld::Ptr& actor) + bool ActionOpen::executeImp (const MWWorld::Ptr& actor) { if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory)) - return; + return false; MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Container); MWBase::Environment::get().getWindowManager()->getContainerWindow()->open(getTarget()); + return true; } } diff --git a/apps/openmw/mwworld/actionopen.hpp b/apps/openmw/mwworld/actionopen.hpp index c49ebefa5..42ad4aecb 100644 --- a/apps/openmw/mwworld/actionopen.hpp +++ b/apps/openmw/mwworld/actionopen.hpp @@ -10,7 +10,7 @@ namespace MWWorld { class ActionOpen : public Action { - virtual void executeImp (const MWWorld::Ptr& actor); + virtual bool executeImp (const MWWorld::Ptr& actor); public: ActionOpen (const Ptr& container); diff --git a/apps/openmw/mwworld/actionread.cpp b/apps/openmw/mwworld/actionread.cpp index 6d5d9d8fd..157b051d6 100644 --- a/apps/openmw/mwworld/actionread.cpp +++ b/apps/openmw/mwworld/actionread.cpp @@ -19,7 +19,7 @@ namespace MWWorld { } - void ActionRead::executeImp (const MWWorld::Ptr& actor) + bool ActionRead::executeImp (const MWWorld::Ptr& actor) { LiveCellRef *ref = getTarget().get(); @@ -53,5 +53,6 @@ namespace MWWorld npcStats.flagAsUsed (ref->mBase->mId); } + return true; } } diff --git a/apps/openmw/mwworld/actionread.hpp b/apps/openmw/mwworld/actionread.hpp index 00a4756dd..dfb536c64 100644 --- a/apps/openmw/mwworld/actionread.hpp +++ b/apps/openmw/mwworld/actionread.hpp @@ -8,7 +8,7 @@ namespace MWWorld { class ActionRead : public Action { - virtual void executeImp (const MWWorld::Ptr& actor); + virtual bool executeImp (const MWWorld::Ptr& actor); public: /// @param book or scroll to read diff --git a/apps/openmw/mwworld/actiontake.cpp b/apps/openmw/mwworld/actiontake.cpp index fd28dd52e..fef8a7e73 100644 --- a/apps/openmw/mwworld/actiontake.cpp +++ b/apps/openmw/mwworld/actiontake.cpp @@ -12,10 +12,10 @@ namespace MWWorld { ActionTake::ActionTake (const MWWorld::Ptr& object) : Action (true, object) {} - void ActionTake::executeImp (const Ptr& actor) + bool ActionTake::executeImp (const Ptr& actor) { if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory)) - return; + return false; // insert into player's inventory MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPtr ("player", true); @@ -23,5 +23,7 @@ namespace MWWorld MWWorld::Class::get (player).getContainerStore (player).add (getTarget()); MWBase::Environment::get().getWorld()->deleteObject (getTarget()); + + return true; } } diff --git a/apps/openmw/mwworld/actiontake.hpp b/apps/openmw/mwworld/actiontake.hpp index b0a9b8247..2a87156d0 100644 --- a/apps/openmw/mwworld/actiontake.hpp +++ b/apps/openmw/mwworld/actiontake.hpp @@ -8,7 +8,7 @@ namespace MWWorld { class ActionTake : public Action { - virtual void executeImp (const Ptr& actor); + virtual bool executeImp (const Ptr& actor); public: diff --git a/apps/openmw/mwworld/actiontalk.cpp b/apps/openmw/mwworld/actiontalk.cpp index 59b37370a..36c54f00e 100644 --- a/apps/openmw/mwworld/actiontalk.cpp +++ b/apps/openmw/mwworld/actiontalk.cpp @@ -9,9 +9,13 @@ namespace MWWorld { ActionTalk::ActionTalk (const Ptr& actor) : Action (false, actor) {} - void ActionTalk::executeImp (const Ptr& actor) + bool ActionTalk::executeImp (const Ptr& actor) { if (MWBase::Environment::get().getInputManager ()->getControlSwitch ("playercontrols")) + { MWBase::Environment::get().getDialogueManager()->startDialogue (getTarget()); + return true; + } + return false; } } diff --git a/apps/openmw/mwworld/actiontalk.hpp b/apps/openmw/mwworld/actiontalk.hpp index b88b168d8..91c71dc79 100644 --- a/apps/openmw/mwworld/actiontalk.hpp +++ b/apps/openmw/mwworld/actiontalk.hpp @@ -8,7 +8,7 @@ namespace MWWorld { class ActionTalk : public Action { - virtual void executeImp (const Ptr& actor); + virtual bool executeImp (const Ptr& actor); public: diff --git a/apps/openmw/mwworld/actionteleport.cpp b/apps/openmw/mwworld/actionteleport.cpp index ae5ffc3b9..9b21cc876 100644 --- a/apps/openmw/mwworld/actionteleport.cpp +++ b/apps/openmw/mwworld/actionteleport.cpp @@ -12,11 +12,12 @@ namespace MWWorld { } - void ActionTeleport::executeImp (const Ptr& actor) + bool ActionTeleport::executeImp (const Ptr& actor) { if (mCellName.empty()) MWBase::Environment::get().getWorld()->changeToExteriorCell (mPosition); else MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, mPosition); + return true; } } diff --git a/apps/openmw/mwworld/actionteleport.hpp b/apps/openmw/mwworld/actionteleport.hpp index a13cb61b2..4f771cac9 100644 --- a/apps/openmw/mwworld/actionteleport.hpp +++ b/apps/openmw/mwworld/actionteleport.hpp @@ -14,7 +14,7 @@ namespace MWWorld std::string mCellName; ESM::Position mPosition; - virtual void executeImp (const Ptr& actor); + virtual bool executeImp (const Ptr& actor); public: diff --git a/apps/openmw/mwworld/failedaction.cpp b/apps/openmw/mwworld/failedaction.cpp index ec763dba0..7ce27f76f 100644 --- a/apps/openmw/mwworld/failedaction.cpp +++ b/apps/openmw/mwworld/failedaction.cpp @@ -11,11 +11,12 @@ namespace MWWorld { } - void FailedAction::executeImp (const Ptr& actor) + bool FailedAction::executeImp (const Ptr& actor) { if ( actor.getRefData().getHandle()=="player" && !(message.empty())) - { - MWBase::Environment::get().getWindowManager() ->messageBox(message, std::vector()); - } + { + MWBase::Environment::get().getWindowManager() ->messageBox(message, std::vector()); + } + return false; } } diff --git a/apps/openmw/mwworld/failedaction.hpp b/apps/openmw/mwworld/failedaction.hpp index e736bfb63..7d64afe74 100644 --- a/apps/openmw/mwworld/failedaction.hpp +++ b/apps/openmw/mwworld/failedaction.hpp @@ -10,11 +10,11 @@ namespace MWWorld { std::string message; - virtual void executeImp (const Ptr& actor); + virtual bool executeImp (const Ptr& actor); public: FailedAction (const std::string& message = std::string()); }; } -#endif \ No newline at end of file +#endif diff --git a/apps/openmw/mwworld/nullaction.hpp b/apps/openmw/mwworld/nullaction.hpp index 7ef8b4a06..f5544e4c1 100644 --- a/apps/openmw/mwworld/nullaction.hpp +++ b/apps/openmw/mwworld/nullaction.hpp @@ -8,7 +8,7 @@ namespace MWWorld /// \brief Action: do nothing class NullAction : public Action { - virtual void executeImp (const Ptr& actor) {} + virtual bool executeImp (const Ptr& actor) {return false;} }; } From a5c8d5748f990025ef7a3dd3eb5bb5d291fe9703 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 16 Feb 2013 18:05:25 +0100 Subject: [PATCH 10/15] fix FailedAction. --- apps/openmw/mwworld/failedaction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/failedaction.cpp b/apps/openmw/mwworld/failedaction.cpp index 7ce27f76f..e2ca78b2c 100644 --- a/apps/openmw/mwworld/failedaction.cpp +++ b/apps/openmw/mwworld/failedaction.cpp @@ -17,6 +17,6 @@ namespace MWWorld { MWBase::Environment::get().getWindowManager() ->messageBox(message, std::vector()); } - return false; + return true; } } From f0220fb06b099dd48aa4c3825135fabecb9cd400 Mon Sep 17 00:00:00 2001 From: Wareya Date: Sat, 16 Feb 2013 13:35:03 -0500 Subject: [PATCH 11/15] Implement "Rest Until Healed" Fixes: https://bugs.openmw.org/issues/563 --- apps/openmw/mwgui/waitdialog.cpp | 62 ++++++++++++++++++++++++++++---- apps/openmw/mwgui/waitdialog.hpp | 3 +- 2 files changed, 58 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwgui/waitdialog.cpp b/apps/openmw/mwgui/waitdialog.cpp index 4f2c98c08..2953ca58d 100644 --- a/apps/openmw/mwgui/waitdialog.cpp +++ b/apps/openmw/mwgui/waitdialog.cpp @@ -1,5 +1,8 @@ #include "waitdialog.hpp" +#include +#include + #include #include @@ -14,6 +17,7 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/class.hpp" +#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/npcstats.hpp" #include "widgets.hpp" @@ -132,21 +136,66 @@ namespace MWGui void WaitDialog::onUntilHealedButtonClicked(MyGUI::Widget* sender) { - startWaiting(); + // we need to sleep for a specific time, and since that isn't calculated yet, we'll do it here + // I'm making the assumption here that the # of hours rested is calculated when rest is started + // TODO: the rougher logic here (calculating the hourly deltas) should really go into helper funcs elsewhere + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + MWMechanics::CreatureStats stats = MWWorld::Class::get(player).getCreatureStats(player); + const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + + float hourlyHealthDelta = stats.getAttribute(ESM::Attribute::Endurance).getModified() * 0.1; + + bool stunted = (stats.getMagicEffects().get(MWMechanics::EffectKey(136)).mMagnitude > 0); + float fRestMagicMult = store.get().find("fRestMagicMult")->getFloat(); + float hourlyMagickaDelta = fRestMagicMult * stats.getAttribute(ESM::Attribute::Intelligence).getModified(); + + // this massive duplication is why it has to be put into helper functions instead + float fFatigueReturnBase = store.get().find("fFatigueReturnBase")->getFloat(); + float fFatigueReturnMult = store.get().find("fFatigueReturnMult")->getFloat(); + float fEndFatigueMult = store.get().find("fEndFatigueMult")->getFloat(); + float capacity = MWWorld::Class::get(player).getCapacity(player); + float encumbrance = MWWorld::Class::get(player).getEncumbrance(player); + float normalizedEncumbrance = (capacity == 0 ? 1 : encumbrance/capacity); + if (normalizedEncumbrance > 1) + normalizedEncumbrance = 1; + float hourlyFatigueDelta = fFatigueReturnBase + fFatigueReturnMult * (1 - normalizedEncumbrance); + hourlyFatigueDelta *= 3600 * fEndFatigueMult * stats.getAttribute(ESM::Attribute::Endurance).getModified(); + + std::cout << "Calced health per hour: " << hourlyHealthDelta << std::endl; + + float healthHours = hourlyHealthDelta >= 0.0 + ? (stats.getHealth().getBase() - stats.getHealth().getCurrent()) / hourlyHealthDelta + : 1.0f; + std::cout << "Calced health hours: " << healthHours << std::endl; + std::cout << "getBase returns " << stats.getHealth().getBase() << ", getModified() returns " << stats.getHealth().getModified() << std::endl; + float magickaHours = stunted ? 0.0 : + hourlyMagickaDelta >= 0.0 + ? (stats.getMagicka().getBase() - stats.getMagicka().getCurrent()) / hourlyMagickaDelta + : 1.0f; + float fatigueHours = hourlyFatigueDelta >= 0.0 + ? (stats.getFatigue().getBase() - stats.getFatigue().getCurrent()) / hourlyFatigueDelta + : 1.0f; + + int autoHours = int(std::ceil( std::max(std::max(healthHours, magickaHours), std::max(fatigueHours, 1.0f)) )); // this should use a variadic max if possible + + startWaiting(autoHours); } void WaitDialog::onWaitButtonClicked(MyGUI::Widget* sender) { - startWaiting(); + startWaiting(mManualHours); } - void WaitDialog::startWaiting () + void WaitDialog::startWaiting(int hoursToWait) { MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(0.2); setVisible(false); mProgressBar.setVisible (true); + mWaiting = true; mCurHour = 0; + mHours = hoursToWait; + mRemainingTime = 0.05; mProgressBar.setProgress (0, mHours); } @@ -159,7 +208,7 @@ namespace MWGui void WaitDialog::onHourSliderChangedPosition(MyGUI::ScrollBar* sender, size_t position) { mHourText->setCaptionWithReplacing (boost::lexical_cast(position+1) + " #{sRestMenu2}"); - mHours = position+1; + mManualHours = position+1; } void WaitDialog::setCanRest (bool canRest) @@ -181,9 +230,9 @@ namespace MWGui mRemainingTime -= dt; - if (mRemainingTime < 0) + while (mRemainingTime < 0) { - mRemainingTime = 0.05; + mRemainingTime += 0.05; ++mCurHour; mProgressBar.setProgress (mCurHour, mHours); @@ -197,6 +246,7 @@ namespace MWGui if (mCurHour > mHours) stopWaiting(); + } void WaitDialog::stopWaiting () diff --git a/apps/openmw/mwgui/waitdialog.hpp b/apps/openmw/mwgui/waitdialog.hpp index 6af565c6e..c102d0fc6 100644 --- a/apps/openmw/mwgui/waitdialog.hpp +++ b/apps/openmw/mwgui/waitdialog.hpp @@ -47,6 +47,7 @@ namespace MWGui bool mSleeping; int mCurHour; int mHours; + int mManualHours; // stores the hours to rest selected via slider float mRemainingTime; WaitDialogProgressBar mProgressBar; @@ -58,7 +59,7 @@ namespace MWGui void setCanRest(bool canRest); - void startWaiting(); + void startWaiting(int hoursToWait); void stopWaiting(); }; From c98a81558151092542bc4882fb6a6ded4dcaddb0 Mon Sep 17 00:00:00 2001 From: Wareya Date: Sat, 16 Feb 2013 13:37:25 -0500 Subject: [PATCH 12/15] Remove debug printing from previous commit --- apps/openmw/mwgui/waitdialog.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/apps/openmw/mwgui/waitdialog.cpp b/apps/openmw/mwgui/waitdialog.cpp index 2953ca58d..2c74dd2fd 100644 --- a/apps/openmw/mwgui/waitdialog.cpp +++ b/apps/openmw/mwgui/waitdialog.cpp @@ -1,6 +1,5 @@ #include "waitdialog.hpp" -#include #include #include @@ -160,14 +159,10 @@ namespace MWGui normalizedEncumbrance = 1; float hourlyFatigueDelta = fFatigueReturnBase + fFatigueReturnMult * (1 - normalizedEncumbrance); hourlyFatigueDelta *= 3600 * fEndFatigueMult * stats.getAttribute(ESM::Attribute::Endurance).getModified(); - - std::cout << "Calced health per hour: " << hourlyHealthDelta << std::endl; float healthHours = hourlyHealthDelta >= 0.0 ? (stats.getHealth().getBase() - stats.getHealth().getCurrent()) / hourlyHealthDelta - : 1.0f; - std::cout << "Calced health hours: " << healthHours << std::endl; - std::cout << "getBase returns " << stats.getHealth().getBase() << ", getModified() returns " << stats.getHealth().getModified() << std::endl; + : 1.0f; float magickaHours = stunted ? 0.0 : hourlyMagickaDelta >= 0.0 ? (stats.getMagicka().getBase() - stats.getMagicka().getCurrent()) / hourlyMagickaDelta From df8e502f8c5139a850fa74cc2ff53f3804fb970c Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 17 Feb 2013 02:52:49 +0100 Subject: [PATCH 13/15] Ouch, I used && instead of &, this broke actions without a sound --- apps/openmw/mwworld/action.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/action.cpp b/apps/openmw/mwworld/action.cpp index b4897109a..0d50d8ded 100644 --- a/apps/openmw/mwworld/action.cpp +++ b/apps/openmw/mwworld/action.cpp @@ -18,7 +18,7 @@ MWWorld::Action::~Action() {} void MWWorld::Action::execute (const Ptr& actor) { - if (!mSoundId.empty() && executeImp (actor)) + if (!mSoundId.empty() & executeImp (actor)) { if (mKeepSound && actor.getRefData().getHandle()=="player") { From 373de19aeec752958a37e9fe0f120ef95493ab1d Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 17 Feb 2013 03:02:47 +0100 Subject: [PATCH 14/15] Removed dialogue fix again, now on separate branch --- apps/openmw/mwworld/actiontalk.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwworld/actiontalk.cpp b/apps/openmw/mwworld/actiontalk.cpp index 36c54f00e..6bee9eb26 100644 --- a/apps/openmw/mwworld/actiontalk.cpp +++ b/apps/openmw/mwworld/actiontalk.cpp @@ -11,11 +11,7 @@ namespace MWWorld bool ActionTalk::executeImp (const Ptr& actor) { - if (MWBase::Environment::get().getInputManager ()->getControlSwitch ("playercontrols")) - { - MWBase::Environment::get().getDialogueManager()->startDialogue (getTarget()); - return true; - } - return false; + MWBase::Environment::get().getDialogueManager()->startDialogue (getTarget()); + return true; } } From c4f17f5596efde3267c802f1463a0b822d97f70a Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 17 Feb 2013 03:03:41 +0100 Subject: [PATCH 15/15] playercontrols switch now disables activation in general (Chris' suggestion) --- apps/openmw/mwinput/inputmanagerimp.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 02a699ece..296ff3cc7 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -642,7 +642,8 @@ namespace MWInput void InputManager::activate() { - mEngine.activate(); + if (mControlSwitch["playercontrols"]) + mEngine.activate(); } void InputManager::toggleAutoMove()