Merge remote-tracking branch 'zini/next' into animation2

actorid
Chris Robinson 12 years ago
commit e2d7cc49e3

@ -16,7 +16,7 @@
#include <iostream> #include <iostream>
#include <boost/format.hpp> #include <boost/format.hpp>
std::string bodyPartLabel(char idx) std::string bodyPartLabel(int idx)
{ {
const char *bodyPartLabels[] = { const char *bodyPartLabels[] = {
"Head", "Head",
@ -47,14 +47,14 @@ std::string bodyPartLabel(char idx)
"Weapon", "Weapon",
"Tail" "Tail"
}; };
if ((int)idx >= 0 && (int)(idx) <= 26) if (idx >= 0 && idx <= 26)
return bodyPartLabels[(int)(idx)]; return bodyPartLabels[idx];
else else
return "Invalid"; return "Invalid";
} }
std::string meshPartLabel(char idx) std::string meshPartLabel(int idx)
{ {
const char *meshPartLabels[] = { const char *meshPartLabels[] = {
"Head", "Head",
@ -73,25 +73,25 @@ std::string meshPartLabel(char idx)
"Clavicle", "Clavicle",
"Tail" "Tail"
}; };
if ((int)(idx) >= 0 && (int)(idx) <= ESM::BodyPart::MP_Tail) if (idx >= 0 && idx <= ESM::BodyPart::MP_Tail)
return meshPartLabels[(int)(idx)]; return meshPartLabels[idx];
else else
return "Invalid"; return "Invalid";
} }
std::string meshTypeLabel(char idx) std::string meshTypeLabel(int idx)
{ {
const char *meshTypeLabels[] = { const char *meshTypeLabels[] = {
"Skin", "Skin",
"Clothing", "Clothing",
"Armor" "Armor"
}; };
if ((int)(idx) >= 0 && (int)(idx) <= ESM::BodyPart::MT_Armor) if (idx >= 0 && idx <= ESM::BodyPart::MT_Armor)
return meshTypeLabels[(int)(idx)]; return meshTypeLabels[idx];
else else
return "Invalid"; return "Invalid";
} }
std::string clothingTypeLabel(int idx) std::string clothingTypeLabel(int idx)
@ -108,7 +108,7 @@ std::string clothingTypeLabel(int idx)
"Ring", "Ring",
"Amulet" "Amulet"
}; };
if (idx >= 0 && idx <= 9) if (idx >= 0 && idx <= 9)
return clothingTypeLabels[idx]; return clothingTypeLabels[idx];
else else

@ -3,9 +3,9 @@
#include <string> #include <string>
std::string bodyPartLabel(char idx); std::string bodyPartLabel(int idx);
std::string meshPartLabel(char idx); std::string meshPartLabel(int idx);
std::string meshTypeLabel(char idx); std::string meshTypeLabel(int idx);
std::string clothingTypeLabel(int idx); std::string clothingTypeLabel(int idx);
std::string armorTypeLabel(int idx); std::string armorTypeLabel(int idx);
std::string dialogTypeLabel(int idx); std::string dialogTypeLabel(int idx);

@ -210,6 +210,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
newRef.getPtr().get<ESM::Miscellaneous>(); newRef.getPtr().get<ESM::Miscellaneous>();
newPtr = MWWorld::Ptr(&cell.mMiscItems.insert(*ref), &cell); newPtr = MWWorld::Ptr(&cell.mMiscItems.insert(*ref), &cell);
newPtr.getRefData ().setCount(goldAmount);
} else { } else {
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>(); ptr.get<ESM::Miscellaneous>();

@ -133,8 +133,6 @@ void BirthDialog::updateBirths()
const MWWorld::Store<ESM::BirthSign> &signs = const MWWorld::Store<ESM::BirthSign> &signs =
MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>(); MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>();
int index = 0;
// sort by name // sort by name
std::vector < std::pair<std::string, const ESM::BirthSign*> > birthSigns; std::vector < std::pair<std::string, const ESM::BirthSign*> > birthSigns;
@ -145,12 +143,20 @@ void BirthDialog::updateBirths()
} }
std::sort(birthSigns.begin(), birthSigns.end(), sortBirthSigns); std::sort(birthSigns.begin(), birthSigns.end(), sortBirthSigns);
for (std::vector < std::pair<std::string, const ESM::BirthSign*> >::const_iterator it2 = birthSigns.begin(); it2 != birthSigns.end(); ++it2) int index = 0;
for (std::vector<std::pair<std::string, const ESM::BirthSign*> >::const_iterator it2 = birthSigns.begin();
it2 != birthSigns.end(); ++it2, ++index)
{ {
mBirthList->addItem(it2->second->mName, it2->first); mBirthList->addItem(it2->second->mName, it2->first);
if (boost::iequals(it2->first, mCurrentBirthId)) if (mCurrentBirthId.empty())
{
mBirthList->setIndexSelected(index); mBirthList->setIndexSelected(index);
++index; mCurrentBirthId = it2->first;
}
else if (boost::iequals(it2->first, mCurrentBirthId))
{
mBirthList->setIndexSelected(index);
}
} }
} }

@ -197,8 +197,15 @@ void PickClassDialog::updateClasses()
const std::string &id = it->mId; const std::string &id = it->mId;
mClassList->addItem(it->mName, id); mClassList->addItem(it->mName, id);
if (boost::iequals(id, mCurrentClassId)) if (mCurrentClassId.empty())
{
mCurrentClassId = id;
mClassList->setIndexSelected(index); mClassList->setIndexSelected(index);
}
else if (boost::iequals(id, mCurrentClassId))
{
mClassList->setIndexSelected(index);
}
++index; ++index;
} }
} }

@ -19,12 +19,17 @@
#include "inventorywindow.hpp" #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 namespace MWGui
{ {
TradeWindow::TradeWindow(MWBase::WindowManager& parWindowManager) : TradeWindow::TradeWindow(MWBase::WindowManager& parWindowManager) :
WindowBase("openmw_trade_window.layout", parWindowManager) WindowBase("openmw_trade_window.layout", parWindowManager)
, ContainerBase(NULL) // no drag&drop , ContainerBase(NULL) // no drag&drop
, mCurrentBalance(0) , mCurrentBalance(0)
, mBalanceButtonsState(BBS_None)
, mBalanceChangePause(0.0)
{ {
MyGUI::ScrollView* itemView; MyGUI::ScrollView* itemView;
MyGUI::Widget* containerWidget; MyGUI::Widget* containerWidget;
@ -59,8 +64,10 @@ namespace MWGui
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onCancelButtonClicked); mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onCancelButtonClicked);
mOfferButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onOfferButtonClicked); mOfferButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onOfferButtonClicked);
mIncreaseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onIncreaseButtonClicked); mIncreaseButton->eventMouseButtonPressed += MyGUI::newDelegate(this, &TradeWindow::onIncreaseButtonPressed);
mDecreaseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onDecreaseButtonClicked); 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); 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) void TradeWindow::onOfferButtonClicked(MyGUI::Widget* _sender)
{ {
const MWWorld::Store<ESM::GameSetting> &gmst = const MWWorld::Store<ESM::GameSetting> &gmst =
@ -242,7 +264,7 @@ namespace MWGui
//skill use! //skill use!
MWWorld::Class::get(playerPtr).skillUsageSucceeded(playerPtr, ESM::Skill::Mercantile, 0); MWWorld::Class::get(playerPtr).skillUsageSucceeded(playerPtr, ESM::Skill::Mercantile, 0);
} }
int iBarterSuccessDisposition = gmst.find("iBarterSuccessDisposition")->getInt(); int iBarterSuccessDisposition = gmst.find("iBarterSuccessDisposition")->getInt();
MWBase::Environment::get().getDialogueManager()->applyTemporaryDispositionChange(iBarterSuccessDisposition); MWBase::Environment::get().getDialogueManager()->applyTemporaryDispositionChange(iBarterSuccessDisposition);
@ -271,14 +293,33 @@ namespace MWGui
mWindowManager.removeGuiMode(GM_Barter); 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;
if(mCurrentBalance>=1) mCurrentBalance += 1; if(mCurrentBalance>=1) mCurrentBalance += 1;
updateLabels(); updateLabels();
} }
void TradeWindow::onDecreaseButtonClicked(MyGUI::Widget* _sender) void TradeWindow::onDecreaseButtonTriggered()
{ {
if(mCurrentBalance<-1) mCurrentBalance += 1; if(mCurrentBalance<-1) mCurrentBalance += 1;
if(mCurrentBalance>1) mCurrentBalance -= 1; if(mCurrentBalance>1) mCurrentBalance -= 1;

@ -34,6 +34,8 @@ namespace MWGui
void addOrRemoveGold(int gold); void addOrRemoveGold(int gold);
void onFrame(float frameDuration);
protected: protected:
MyGUI::Button* mFilterAll; MyGUI::Button* mFilterAll;
MyGUI::Button* mFilterWeapon; MyGUI::Button* mFilterWeapon;
@ -57,12 +59,24 @@ namespace MWGui
int mCurrentBalance; int mCurrentBalance;
int mCurrentMerchantOffer; 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 onWindowResize(MyGUI::Window* _sender);
void onFilterChanged(MyGUI::Widget* _sender); void onFilterChanged(MyGUI::Widget* _sender);
void onOfferButtonClicked(MyGUI::Widget* _sender); void onOfferButtonClicked(MyGUI::Widget* _sender);
void onCancelButtonClicked(MyGUI::Widget* _sender); void onCancelButtonClicked(MyGUI::Widget* _sender);
void onIncreaseButtonClicked(MyGUI::Widget* _sender); void onIncreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
void onDecreaseButtonClicked(MyGUI::Widget* _sender); 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. // don't show items that the NPC has equipped in his trade-window.
virtual bool ignoreEquippedItems() { return true; } virtual bool ignoreEquippedItems() { return true; }

@ -1,5 +1,7 @@
#include "waitdialog.hpp" #include "waitdialog.hpp"
#include <cmath>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <libs/openengine/ogre/fader.hpp> #include <libs/openengine/ogre/fader.hpp>
@ -14,6 +16,7 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/npcstats.hpp"
#include "widgets.hpp" #include "widgets.hpp"
@ -132,21 +135,62 @@ namespace MWGui
void WaitDialog::onUntilHealedButtonClicked(MyGUI::Widget* sender) 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<ESM::GameSetting>().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<ESM::GameSetting>().find("fFatigueReturnBase")->getFloat();
float fFatigueReturnMult = store.get<ESM::GameSetting>().find("fFatigueReturnMult")->getFloat();
float fEndFatigueMult = store.get<ESM::GameSetting>().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();
float healthHours = hourlyHealthDelta >= 0.0
? (stats.getHealth().getBase() - stats.getHealth().getCurrent()) / hourlyHealthDelta
: 1.0f;
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) 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); MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(0.2);
setVisible(false); setVisible(false);
mProgressBar.setVisible (true); mProgressBar.setVisible (true);
mWaiting = true; mWaiting = true;
mCurHour = 0; mCurHour = 0;
mHours = hoursToWait;
mRemainingTime = 0.05; mRemainingTime = 0.05;
mProgressBar.setProgress (0, mHours); mProgressBar.setProgress (0, mHours);
} }
@ -159,7 +203,7 @@ namespace MWGui
void WaitDialog::onHourSliderChangedPosition(MyGUI::ScrollBar* sender, size_t position) void WaitDialog::onHourSliderChangedPosition(MyGUI::ScrollBar* sender, size_t position)
{ {
mHourText->setCaptionWithReplacing (boost::lexical_cast<std::string>(position+1) + " #{sRestMenu2}"); mHourText->setCaptionWithReplacing (boost::lexical_cast<std::string>(position+1) + " #{sRestMenu2}");
mHours = position+1; mManualHours = position+1;
} }
void WaitDialog::setCanRest (bool canRest) void WaitDialog::setCanRest (bool canRest)
@ -181,9 +225,9 @@ namespace MWGui
mRemainingTime -= dt; mRemainingTime -= dt;
if (mRemainingTime < 0) while (mRemainingTime < 0)
{ {
mRemainingTime = 0.05; mRemainingTime += 0.05;
++mCurHour; ++mCurHour;
mProgressBar.setProgress (mCurHour, mHours); mProgressBar.setProgress (mCurHour, mHours);
@ -197,6 +241,7 @@ namespace MWGui
if (mCurHour > mHours) if (mCurHour > mHours)
stopWaiting(); stopWaiting();
} }
void WaitDialog::stopWaiting () void WaitDialog::stopWaiting ()

@ -47,6 +47,7 @@ namespace MWGui
bool mSleeping; bool mSleeping;
int mCurHour; int mCurHour;
int mHours; int mHours;
int mManualHours; // stores the hours to rest selected via slider
float mRemainingTime; float mRemainingTime;
WaitDialogProgressBar mProgressBar; WaitDialogProgressBar mProgressBar;
@ -58,7 +59,7 @@ namespace MWGui
void setCanRest(bool canRest); void setCanRest(bool canRest);
void startWaiting(); void startWaiting(int hoursToWait);
void stopWaiting(); void stopWaiting();
}; };

@ -613,6 +613,7 @@ void WindowManager::onFrame (float frameDuration)
mHud->onFrame(frameDuration); mHud->onFrame(frameDuration);
mTrainingWindow->onFrame (frameDuration); mTrainingWindow->onFrame (frameDuration);
mTradeWindow->onFrame(frameDuration);
mTrainingWindow->checkReferenceAvailable(); mTrainingWindow->checkReferenceAvailable();
mDialogueWindow->checkReferenceAvailable(); mDialogueWindow->checkReferenceAvailable();

@ -595,10 +595,14 @@ namespace MWInput
// Toggle between game mode and inventory mode // Toggle between game mode and inventory mode
if(gameMode) if(gameMode)
mWindows.pushGuiMode(MWGui::GM_Inventory); mWindows.pushGuiMode(MWGui::GM_Inventory);
else if(mWindows.getMode() == MWGui::GM_Inventory) else
mWindows.popGuiMode(); {
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() void InputManager::toggleConsole()
@ -643,7 +647,8 @@ namespace MWInput
void InputManager::activate() void InputManager::activate()
{ {
mEngine.activate(); if (mControlSwitch["playercontrols"])
mEngine.activate();
} }
void InputManager::toggleAutoMove() void InputManager::toggleAutoMove()

@ -18,7 +18,7 @@ MWWorld::Action::~Action() {}
void MWWorld::Action::execute (const Ptr& actor) void MWWorld::Action::execute (const Ptr& actor)
{ {
if (!mSoundId.empty()) if (!mSoundId.empty() & executeImp (actor))
{ {
if (mKeepSound && actor.getRefData().getHandle()=="player") 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); mKeepSound ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal);
} }
} }
executeImp (actor);
} }
void MWWorld::Action::setSound (const std::string& id) void MWWorld::Action::setSound (const std::string& id)

@ -18,7 +18,8 @@ namespace MWWorld
Action (const Action& action); Action (const Action& action);
Action& operator= (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: protected:

@ -5,8 +5,9 @@
namespace MWWorld namespace MWWorld
{ {
void ActionAlchemy::executeImp (const Ptr& actor) bool ActionAlchemy::executeImp (const Ptr& actor)
{ {
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Alchemy); MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Alchemy);
return true;
} }
} }

@ -7,7 +7,7 @@ namespace MWWorld
{ {
class ActionAlchemy : public Action class ActionAlchemy : public Action
{ {
virtual void executeImp (const Ptr& actor); virtual bool executeImp (const Ptr& actor);
}; };
} }

@ -9,9 +9,10 @@ namespace MWWorld
: Action (false, target), mId (id) : 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); 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) : 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) if (MWWorld::Class::get (getTarget()).apply (getTarget(), mId, actor) && mUsageType!=-1)
MWWorld::Class::get (getTarget()).skillUsageSucceeded (actor, mSkillIndex, mUsageType); MWWorld::Class::get (getTarget()).skillUsageSucceeded (actor, mSkillIndex, mUsageType);
return true;
} }
} }

@ -13,7 +13,7 @@ namespace MWWorld
{ {
std::string mId; std::string mId;
virtual void executeImp (const Ptr& actor); virtual bool executeImp (const Ptr& actor);
public: public:
@ -26,7 +26,7 @@ namespace MWWorld
int mSkillIndex; int mSkillIndex;
int mUsageType; int mUsageType;
virtual void executeImp (const Ptr& actor); virtual bool executeImp (const Ptr& actor);
public: public:

@ -16,7 +16,7 @@
namespace MWWorld namespace MWWorld
{ {
void ActionEat::executeImp (const Ptr& actor) bool ActionEat::executeImp (const Ptr& actor)
{ {
// remove used item // remove used item
getTarget().getRefData().setCount (getTarget().getRefData().getCount()-1); getTarget().getRefData().setCount (getTarget().getRefData().getCount()-1);
@ -42,6 +42,8 @@ namespace MWWorld
// increase skill // increase skill
Class::get (actor).skillUsageSucceeded (actor, ESM::Skill::Alchemy, 1); Class::get (actor).skillUsageSucceeded (actor, ESM::Skill::Alchemy, 1);
} }
return true;
} }
ActionEat::ActionEat (const MWWorld::Ptr& object) : Action (false, object) {} ActionEat::ActionEat (const MWWorld::Ptr& object) : Action (false, object) {}

@ -8,7 +8,7 @@ namespace MWWorld
{ {
class ActionEat : public Action class ActionEat : public Action
{ {
virtual void executeImp (const Ptr& actor); virtual bool executeImp (const Ptr& actor);
public: public:

@ -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); 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 */ /* 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 != "") if(equipped && actor == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() && script != "")
(*it).mRefData->getLocals().setVarByInt(script, "onpcequip", 1); (*it).mRefData->getLocals().setVarByInt(script, "onpcequip", 1);
return true;
} }
} }

@ -8,7 +8,7 @@ namespace MWWorld
{ {
class ActionEquip : public Action class ActionEquip : public Action
{ {
virtual void executeImp (const Ptr& actor); virtual bool executeImp (const Ptr& actor);
public: public:
/// @param item to equip /// @param item to equip

@ -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)) if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return; return false;
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Container); MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Container);
MWBase::Environment::get().getWindowManager()->getContainerWindow()->open(getTarget()); MWBase::Environment::get().getWindowManager()->getContainerWindow()->open(getTarget());
return true;
} }
} }

@ -10,7 +10,7 @@ namespace MWWorld
{ {
class ActionOpen : public Action class ActionOpen : public Action
{ {
virtual void executeImp (const MWWorld::Ptr& actor); virtual bool executeImp (const MWWorld::Ptr& actor);
public: public:
ActionOpen (const Ptr& container); ActionOpen (const Ptr& container);

@ -19,7 +19,7 @@ namespace MWWorld
{ {
} }
void ActionRead::executeImp (const MWWorld::Ptr& actor) bool ActionRead::executeImp (const MWWorld::Ptr& actor)
{ {
LiveCellRef<ESM::Book> *ref = getTarget().get<ESM::Book>(); LiveCellRef<ESM::Book> *ref = getTarget().get<ESM::Book>();
@ -53,5 +53,6 @@ namespace MWWorld
npcStats.flagAsUsed (ref->mBase->mId); npcStats.flagAsUsed (ref->mBase->mId);
} }
return true;
} }
} }

@ -8,7 +8,7 @@ namespace MWWorld
{ {
class ActionRead : public Action class ActionRead : public Action
{ {
virtual void executeImp (const MWWorld::Ptr& actor); virtual bool executeImp (const MWWorld::Ptr& actor);
public: public:
/// @param book or scroll to read /// @param book or scroll to read

@ -12,10 +12,10 @@ namespace MWWorld
{ {
ActionTake::ActionTake (const MWWorld::Ptr& object) : Action (true, object) {} 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)) if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
return; return false;
// insert into player's inventory // insert into player's inventory
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPtr ("player", true); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPtr ("player", true);
@ -23,5 +23,7 @@ namespace MWWorld
MWWorld::Class::get (player).getContainerStore (player).add (getTarget()); MWWorld::Class::get (player).getContainerStore (player).add (getTarget());
MWBase::Environment::get().getWorld()->deleteObject (getTarget()); MWBase::Environment::get().getWorld()->deleteObject (getTarget());
return true;
} }
} }

@ -8,7 +8,7 @@ namespace MWWorld
{ {
class ActionTake : public Action class ActionTake : public Action
{ {
virtual void executeImp (const Ptr& actor); virtual bool executeImp (const Ptr& actor);
public: public:

@ -3,13 +3,15 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/dialoguemanager.hpp" #include "../mwbase/dialoguemanager.hpp"
#include "../mwbase/inputmanager.hpp"
namespace MWWorld namespace MWWorld
{ {
ActionTalk::ActionTalk (const Ptr& actor) : Action (false, actor) {} ActionTalk::ActionTalk (const Ptr& actor) : Action (false, actor) {}
void ActionTalk::executeImp (const Ptr& actor) bool ActionTalk::executeImp (const Ptr& actor)
{ {
MWBase::Environment::get().getDialogueManager()->startDialogue (getTarget()); MWBase::Environment::get().getDialogueManager()->startDialogue (getTarget());
return true;
} }
} }

@ -8,7 +8,7 @@ namespace MWWorld
{ {
class ActionTalk : public Action class ActionTalk : public Action
{ {
virtual void executeImp (const Ptr& actor); virtual bool executeImp (const Ptr& actor);
public: public:

@ -12,11 +12,12 @@ namespace MWWorld
{ {
} }
void ActionTeleport::executeImp (const Ptr& actor) bool ActionTeleport::executeImp (const Ptr& actor)
{ {
if (mCellName.empty()) if (mCellName.empty())
MWBase::Environment::get().getWorld()->changeToExteriorCell (mPosition); MWBase::Environment::get().getWorld()->changeToExteriorCell (mPosition);
else else
MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, mPosition); MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, mPosition);
return true;
} }
} }

@ -14,7 +14,7 @@ namespace MWWorld
std::string mCellName; std::string mCellName;
ESM::Position mPosition; ESM::Position mPosition;
virtual void executeImp (const Ptr& actor); virtual bool executeImp (const Ptr& actor);
public: public:

@ -3,7 +3,7 @@
#include <set> #include <set>
#include <iostream> #include <iostream>
#include <boost/filesystem/v3/operations.hpp> #include <boost/filesystem/operations.hpp>
namespace MWWorld namespace MWWorld
{ {

@ -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())) if ( actor.getRefData().getHandle()=="player" && !(message.empty()))
{ {
MWBase::Environment::get().getWindowManager() ->messageBox(message, std::vector<std::string>()); MWBase::Environment::get().getWindowManager() ->messageBox(message, std::vector<std::string>());
} }
return true;
} }
} }

@ -10,11 +10,11 @@ namespace MWWorld
{ {
std::string message; std::string message;
virtual void executeImp (const Ptr& actor); virtual bool executeImp (const Ptr& actor);
public: public:
FailedAction (const std::string& message = std::string()); FailedAction (const std::string& message = std::string());
}; };
} }
#endif #endif

@ -8,7 +8,7 @@ namespace MWWorld
/// \brief Action: do nothing /// \brief Action: do nothing
class NullAction : public Action class NullAction : public Action
{ {
virtual void executeImp (const Ptr& actor) {} virtual bool executeImp (const Ptr& actor) {return false;}
}; };
} }

@ -77,8 +77,8 @@ public:
std::string mKey, mTrap; // Key and trap ID names, if any std::string mKey, mTrap; // Key and trap ID names, if any
// No idea - occurs ONCE in Morrowind.esm, for an activator // 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. // Track deleted references. 0 - not deleted, 1 - deleted, but respawns, 2 - deleted and does not respawn.
int mDeleted; int mDeleted;
@ -164,14 +164,14 @@ struct Cell
bool mWaterInt; bool mWaterInt;
int mMapColor; int mMapColor;
int mNAM0; int mNAM0;
// References "leased" from another cell (i.e. a different cell // References "leased" from another cell (i.e. a different cell
// introduced this ref, and it has been moved here by a plugin) // introduced this ref, and it has been moved here by a plugin)
CellRefTracker mLeasedRefs; CellRefTracker mLeasedRefs;
MovedCellRefTracker mMovedRefs; MovedCellRefTracker mMovedRefs;
void load(ESMReader &esm, MWWorld::ESMStore &store); void load(ESMReader &esm, MWWorld::ESMStore &store);
// This method is left in for compatibility with esmtool. Parsing moved references currently requires // 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. // passing ESMStore, bit it does not know about this parameter, so we do it this way.
void load(ESMReader &esm) {}; void load(ESMReader &esm) {};
@ -209,7 +209,7 @@ struct Cell
reuse one memory location without blanking it between calls. reuse one memory location without blanking it between calls.
*/ */
static bool getNextRef(ESMReader &esm, CellRef &ref); static bool getNextRef(ESMReader &esm, CellRef &ref);
/* This fetches an MVRF record, which is used to track moved references. /* This fetches an MVRF record, which is used to track moved references.
* Since they are comparably rare, we use a separate method for this. * Since they are comparably rare, we use a separate method for this.
*/ */

@ -30,7 +30,7 @@ struct Dialogue
}; };
std::string mId; std::string mId;
char mType; signed char mType;
std::vector<DialInfo> mInfo; std::vector<DialInfo> mInfo;
void load(ESMReader &esm); void load(ESMReader &esm);

@ -8,7 +8,7 @@ namespace ToUTF8
/// Central European and Eastern European languages that use Latin script, /// Central European and Eastern European languages that use Latin script,
/// such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, /// such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian,
/// Serbian (Latin script), Romanian and Albanian. /// Serbian (Latin script), Romanian and Albanian.
static char windows_1250[] = static signed char windows_1250[] =
{ {
1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
1, 1, 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 /// Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic
/// and other languages /// and other languages
static char windows_1251[] = static signed char windows_1251[] =
{ {
1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
1, 1, 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 /// 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, 0, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0,

@ -216,7 +216,7 @@ void Utf8Encoder::copyFromArray(unsigned char ch, char* &out)
return; return;
} }
const char *in = translationArray + ch*6; const signed char *in = translationArray + ch*6;
int len = *(in++); int len = *(in++);
for (int i=0; i<len; i++) for (int i=0; i<len; i++)
*(out++) = *(in++); *(out++) = *(in++);

@ -47,7 +47,7 @@ namespace ToUTF8
void copyFromArray2(const char*& chp, char* &out); void copyFromArray2(const char*& chp, char* &out);
std::vector<char> mOutput; std::vector<char> mOutput;
char* translationArray; signed char* translationArray;
}; };
} }

Loading…
Cancel
Save