mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +00:00
Merge remote-tracking branch 'potatoesmaster/magic'
This commit is contained in:
commit
e2e76147c8
@ -13,6 +13,7 @@
|
||||
#include "../mwworld/containerstore.hpp"
|
||||
#include "../mwworld/customdata.hpp"
|
||||
#include "../mwworld/cellstore.hpp"
|
||||
#include "../mwworld/actionapply.hpp"
|
||||
#include "../mwworld/actionopen.hpp"
|
||||
#include "../mwworld/physicssystem.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
@ -148,7 +149,7 @@ namespace MWClass
|
||||
{
|
||||
// Trap activation goes here
|
||||
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);
|
||||
ptr.getCellRef().mTrap = "";
|
||||
return action;
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/nullaction.hpp"
|
||||
#include "../mwworld/failedaction.hpp"
|
||||
#include "../mwworld/actionapply.hpp"
|
||||
#include "../mwworld/actionteleport.hpp"
|
||||
#include "../mwworld/actiondoor.hpp"
|
||||
#include "../mwworld/cellstore.hpp"
|
||||
@ -110,7 +111,7 @@ namespace MWClass
|
||||
// Trap activation
|
||||
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);
|
||||
ptr.getCellRef().mTrap = "";
|
||||
|
||||
|
@ -129,48 +129,17 @@ namespace MWGui
|
||||
effectInfo.mMagnitude = static_cast<int> (0.05*it->second.second / (0.1 * magicEffect->mData.mBaseCost));
|
||||
}
|
||||
|
||||
|
||||
effects[effectIt->mEffectID].push_back (effectInfo);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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 =
|
||||
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;
|
||||
|
||||
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;
|
||||
tooltipInfo.caption = "#{" + name + "}";
|
||||
tooltipInfo.icon = effect->mIcon;
|
||||
tooltipInfo.text = sourcesDescription;
|
||||
tooltipInfo.imageSize = 16;
|
||||
tooltipInfo.wordWrap = false;
|
||||
std::string icon = effect->mIcon;
|
||||
icon[icon.size()-3] = 'd';
|
||||
icon[icon.size()-2] = 'd';
|
||||
icon[icon.size()-1] = 's';
|
||||
icon = "icons\\" + icon;
|
||||
|
||||
image->setUserData(tooltipInfo);
|
||||
image->setUserString("ToolTipType", "ToolTipInfo");
|
||||
image->setImageTexture(icon);
|
||||
|
||||
// Fade out during the last 5 seconds
|
||||
image->setAlpha(std::min(remainingDuration/fadeTime, 1.f));
|
||||
std::string name = ESM::MagicEffect::effectIdToString (it->first);
|
||||
|
||||
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
|
||||
@ -232,7 +242,6 @@ namespace MWGui
|
||||
if (effects.find(it->first) == effects.end())
|
||||
it->second->setVisible(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user