forked from mirror/openmw-tes3mp
buying created spell
This commit is contained in:
parent
8ccb0907e6
commit
c991f68a2d
4 changed files with 66 additions and 0 deletions
|
@ -28,6 +28,7 @@ namespace ESM
|
|||
struct Cell;
|
||||
struct Class;
|
||||
struct Potion;
|
||||
struct Spell;
|
||||
}
|
||||
|
||||
namespace ESMS
|
||||
|
@ -235,6 +236,11 @@ namespace MWBase
|
|||
///< Create a new recrod (of type potion) in the ESM store.
|
||||
/// \return ID, pointer to created record
|
||||
|
||||
virtual std::pair<std::string, const ESM::Spell *> createRecord (const ESM::Spell& record)
|
||||
= 0;
|
||||
///< Create a new recrod (of type spell) in the ESM store.
|
||||
/// \return ID, pointer to created record
|
||||
|
||||
virtual std::pair<std::string, const ESM::Class *> createRecord (const ESM::Class& record)
|
||||
= 0;
|
||||
///< Create a new recrod (of type class) in the ESM store.
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
|
||||
#include "../mwworld/player.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
|
@ -297,7 +298,35 @@ namespace MWGui
|
|||
|
||||
void SpellCreationDialog::onBuyButtonClicked (MyGUI::Widget* sender)
|
||||
{
|
||||
if (mEffects.size() <= 0)
|
||||
{
|
||||
mWindowManager.messageBox ("#{sNotifyMessage30}", std::vector<std::string>());
|
||||
return;
|
||||
}
|
||||
|
||||
if (mNameEdit->getCaption () == "")
|
||||
{
|
||||
mWindowManager.messageBox ("#{sNotifyMessage10}", std::vector<std::string>());
|
||||
return;
|
||||
}
|
||||
|
||||
ESM::Spell newSpell;
|
||||
ESM::EffectList effectList;
|
||||
effectList.mList = mEffects;
|
||||
newSpell.mEffects = effectList;
|
||||
newSpell.mName = mNameEdit->getCaption();
|
||||
newSpell.mData.mType = ESM::Spell::ST_Spell;
|
||||
|
||||
std::pair<std::string, const ESM::Spell*> result = MWBase::Environment::get().getWorld()->createRecord(newSpell);
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
||||
MWMechanics::Spells& spells = stats.getSpells();
|
||||
spells.add (result.first);
|
||||
|
||||
MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0);
|
||||
|
||||
mWindowManager.removeGuiMode (GM_SpellCreation);
|
||||
}
|
||||
|
||||
void SpellCreationDialog::open()
|
||||
|
@ -372,6 +401,9 @@ namespace MWGui
|
|||
|
||||
ToolTips::createMagicEffectToolTip (w, *it);
|
||||
}
|
||||
|
||||
mEffects.clear();
|
||||
updateEffectsView ();
|
||||
}
|
||||
|
||||
void EffectEditorBase::setWidgets (Widgets::MWList *availableEffectsList, MyGUI::ScrollView *usedEffectsView)
|
||||
|
@ -413,6 +445,16 @@ namespace MWGui
|
|||
{
|
||||
|
||||
short effectId = *sender->getUserData<short>();
|
||||
|
||||
for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it)
|
||||
{
|
||||
if (it->mEffectID == effectId)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->messageBox ("#{sOnetypeEffectMessage}", std::vector<std::string>());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(effectId);
|
||||
|
||||
mAddEffectDialog.newEffect (effect);
|
||||
|
|
|
@ -802,6 +802,20 @@ namespace MWWorld
|
|||
return std::make_pair (stream.str(), created);
|
||||
}
|
||||
|
||||
std::pair<std::string, const ESM::Spell *> World::createRecord (const ESM::Spell& record)
|
||||
{
|
||||
/// \todo See function above.
|
||||
std::ostringstream stream;
|
||||
stream << "$dynamic" << mNextDynamicRecord++;
|
||||
|
||||
const ESM::Spell *created =
|
||||
&mStore.spells.list.insert (std::make_pair (stream.str(), record)).first->second;
|
||||
|
||||
mStore.all.insert (std::make_pair (stream.str(), ESM::REC_SPEL));
|
||||
|
||||
return std::make_pair (stream.str(), created);
|
||||
}
|
||||
|
||||
const ESM::Cell *World::createRecord (const ESM::Cell& record)
|
||||
{
|
||||
if (record.mData.mFlags & ESM::Cell::Interior)
|
||||
|
|
|
@ -253,6 +253,10 @@ namespace MWWorld
|
|||
///< Create a new recrod (of type potion) in the ESM store.
|
||||
/// \return ID, pointer to created record
|
||||
|
||||
virtual std::pair<std::string, const ESM::Spell *> createRecord (const ESM::Spell& record);
|
||||
///< Create a new recrod (of type spell) in the ESM store.
|
||||
/// \return ID, pointer to created record
|
||||
|
||||
virtual std::pair<std::string, const ESM::Class *> createRecord (const ESM::Class& record);
|
||||
///< Create a new recrod (of type class) in the ESM store.
|
||||
/// \return ID, pointer to created record
|
||||
|
|
Loading…
Reference in a new issue