forked from mirror/openmw-tes3mp
Merge remote-tracking branch 'potatoesmaster/magic'
This commit is contained in:
commit
e2e76147c8
3 changed files with 56 additions and 45 deletions
|
@ -13,6 +13,7 @@
|
||||||
#include "../mwworld/containerstore.hpp"
|
#include "../mwworld/containerstore.hpp"
|
||||||
#include "../mwworld/customdata.hpp"
|
#include "../mwworld/customdata.hpp"
|
||||||
#include "../mwworld/cellstore.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
|
#include "../mwworld/actionapply.hpp"
|
||||||
#include "../mwworld/actionopen.hpp"
|
#include "../mwworld/actionopen.hpp"
|
||||||
#include "../mwworld/physicssystem.hpp"
|
#include "../mwworld/physicssystem.hpp"
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
|
@ -148,7 +149,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
// Trap activation goes here
|
// Trap activation goes here
|
||||||
std::cout << "Activated trap: " << ptr.getCellRef().mTrap << std::endl;
|
std::cout << "Activated trap: " << ptr.getCellRef().mTrap << std::endl;
|
||||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionApply(actor, ptr.getCellRef().mTrap));
|
||||||
action->setSound(trapActivationSound);
|
action->setSound(trapActivationSound);
|
||||||
ptr.getCellRef().mTrap = "";
|
ptr.getCellRef().mTrap = "";
|
||||||
return action;
|
return action;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/nullaction.hpp"
|
#include "../mwworld/nullaction.hpp"
|
||||||
#include "../mwworld/failedaction.hpp"
|
#include "../mwworld/failedaction.hpp"
|
||||||
|
#include "../mwworld/actionapply.hpp"
|
||||||
#include "../mwworld/actionteleport.hpp"
|
#include "../mwworld/actionteleport.hpp"
|
||||||
#include "../mwworld/actiondoor.hpp"
|
#include "../mwworld/actiondoor.hpp"
|
||||||
#include "../mwworld/cellstore.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
|
@ -110,7 +111,7 @@ namespace MWClass
|
||||||
// Trap activation
|
// Trap activation
|
||||||
std::cout << "Activated trap: " << ptr.getCellRef().mTrap << std::endl;
|
std::cout << "Activated trap: " << ptr.getCellRef().mTrap << std::endl;
|
||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionApply(actor, ptr.getCellRef().mTrap));
|
||||||
action->setSound(trapActivationSound);
|
action->setSound(trapActivationSound);
|
||||||
ptr.getCellRef().mTrap = "";
|
ptr.getCellRef().mTrap = "";
|
||||||
|
|
||||||
|
|
|
@ -129,48 +129,17 @@ namespace MWGui
|
||||||
effectInfo.mMagnitude = static_cast<int> (0.05*it->second.second / (0.1 * magicEffect->mData.mBaseCost));
|
effectInfo.mMagnitude = static_cast<int> (0.05*it->second.second / (0.1 * magicEffect->mData.mBaseCost));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
effects[effectIt->mEffectID].push_back (effectInfo);
|
effects[effectIt->mEffectID].push_back (effectInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int w=2;
|
int w=2;
|
||||||
|
|
||||||
if (adjustSize)
|
|
||||||
{
|
|
||||||
int s = effects.size() * 16+4;
|
|
||||||
if (effects.empty())
|
|
||||||
s = 0;
|
|
||||||
int diff = parent->getWidth() - s;
|
|
||||||
parent->setSize(s, parent->getHeight());
|
|
||||||
parent->setPosition(parent->getLeft()+diff, parent->getTop());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (std::map <int, std::vector<MagicEffectInfo> >::const_iterator it = effects.begin(); it != effects.end(); ++it)
|
for (std::map <int, std::vector<MagicEffectInfo> >::const_iterator it = effects.begin(); it != effects.end(); ++it)
|
||||||
{
|
{
|
||||||
MyGUI::ImageBox* image;
|
|
||||||
if (mWidgetMap.find(it->first) == mWidgetMap.end())
|
|
||||||
image = parent->createWidget<MyGUI::ImageBox>
|
|
||||||
("ImageBox", MyGUI::IntCoord(w,2,16,16), MyGUI::Align::Default);
|
|
||||||
else
|
|
||||||
image = mWidgetMap[it->first];
|
|
||||||
mWidgetMap[it->first] = image;
|
|
||||||
image->setPosition(w,2);
|
|
||||||
image->setVisible(true);
|
|
||||||
|
|
||||||
const ESM::MagicEffect* effect =
|
const ESM::MagicEffect* effect =
|
||||||
MWBase::Environment::get().getWorld ()->getStore ().get<ESM::MagicEffect>().find(it->first);
|
MWBase::Environment::get().getWorld ()->getStore ().get<ESM::MagicEffect>().find(it->first);
|
||||||
|
|
||||||
std::string icon = effect->mIcon;
|
|
||||||
icon[icon.size()-3] = 'd';
|
|
||||||
icon[icon.size()-2] = 'd';
|
|
||||||
icon[icon.size()-1] = 's';
|
|
||||||
icon = "icons\\" + icon;
|
|
||||||
|
|
||||||
image->setImageTexture(icon);
|
|
||||||
w += 16;
|
|
||||||
|
|
||||||
float remainingDuration = 0;
|
float remainingDuration = 0;
|
||||||
|
|
||||||
std::string sourcesDescription;
|
std::string sourcesDescription;
|
||||||
|
@ -210,20 +179,61 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string name = ESM::MagicEffect::effectIdToString (it->first);
|
if (remainingDuration > 0.f)
|
||||||
|
{
|
||||||
|
MyGUI::ImageBox* image;
|
||||||
|
if (mWidgetMap.find(it->first) == mWidgetMap.end())
|
||||||
|
{
|
||||||
|
image = parent->createWidget<MyGUI::ImageBox>
|
||||||
|
("ImageBox", MyGUI::IntCoord(w,2,16,16), MyGUI::Align::Default);
|
||||||
|
mWidgetMap[it->first] = image;
|
||||||
|
|
||||||
ToolTipInfo tooltipInfo;
|
std::string icon = effect->mIcon;
|
||||||
tooltipInfo.caption = "#{" + name + "}";
|
icon[icon.size()-3] = 'd';
|
||||||
tooltipInfo.icon = effect->mIcon;
|
icon[icon.size()-2] = 'd';
|
||||||
tooltipInfo.text = sourcesDescription;
|
icon[icon.size()-1] = 's';
|
||||||
tooltipInfo.imageSize = 16;
|
icon = "icons\\" + icon;
|
||||||
tooltipInfo.wordWrap = false;
|
|
||||||
|
|
||||||
image->setUserData(tooltipInfo);
|
image->setImageTexture(icon);
|
||||||
image->setUserString("ToolTipType", "ToolTipInfo");
|
|
||||||
|
|
||||||
// Fade out during the last 5 seconds
|
std::string name = ESM::MagicEffect::effectIdToString (it->first);
|
||||||
image->setAlpha(std::min(remainingDuration/fadeTime, 1.f));
|
|
||||||
|
ToolTipInfo tooltipInfo;
|
||||||
|
tooltipInfo.caption = "#{" + name + "}";
|
||||||
|
tooltipInfo.icon = effect->mIcon;
|
||||||
|
tooltipInfo.imageSize = 16;
|
||||||
|
tooltipInfo.wordWrap = false;
|
||||||
|
|
||||||
|
image->setUserData(tooltipInfo);
|
||||||
|
image->setUserString("ToolTipType", "ToolTipInfo");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
image = mWidgetMap[it->first];
|
||||||
|
|
||||||
|
image->setPosition(w,2);
|
||||||
|
image->setVisible(true);
|
||||||
|
w += 16;
|
||||||
|
|
||||||
|
ToolTipInfo* tooltipInfo = image->getUserData<ToolTipInfo>();
|
||||||
|
tooltipInfo->text = sourcesDescription;
|
||||||
|
|
||||||
|
// Fade out during the last 5 seconds
|
||||||
|
image->setAlpha(std::min(remainingDuration/fadeTime, 1.f));
|
||||||
|
}
|
||||||
|
else if (mWidgetMap.find(it->first) != mWidgetMap.end())
|
||||||
|
{
|
||||||
|
mWidgetMap[it->first]->setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (adjustSize)
|
||||||
|
{
|
||||||
|
int s = w + 2;
|
||||||
|
if (effects.empty())
|
||||||
|
s = 0;
|
||||||
|
int diff = parent->getWidth() - s;
|
||||||
|
parent->setSize(s, parent->getHeight());
|
||||||
|
parent->setPosition(parent->getLeft()+diff, parent->getTop());
|
||||||
}
|
}
|
||||||
|
|
||||||
// hide inactive effects
|
// hide inactive effects
|
||||||
|
@ -232,7 +242,6 @@ namespace MWGui
|
||||||
if (effects.find(it->first) == effects.end())
|
if (effects.find(it->first) == effects.end())
|
||||||
it->second->setVisible(false);
|
it->second->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue