forked from teamnwah/openmw-tes3coop
and go
parent
f45a6b71a9
commit
9d7c35ae48
@ -0,0 +1,120 @@
|
||||
#include "spellcreationdialog.hpp"
|
||||
|
||||
#include <components/esm_store/store.hpp>
|
||||
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
||||
#include "../mwworld/player.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
#include "../mwmechanics/spells.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "tooltips.hpp"
|
||||
#include "widgets.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool sortMagicEffects (short id1, short id2)
|
||||
{
|
||||
return MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(MWGui::Widgets::MWSpellEffect::effectIDToString (id1))->getString()
|
||||
< MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(MWGui::Widgets::MWSpellEffect::effectIDToString (id2))->getString();
|
||||
}
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
SpellCreationDialog::SpellCreationDialog(MWBase::WindowManager &parWindowManager)
|
||||
: WindowBase("openmw_spellcreation_dialog.layout", parWindowManager)
|
||||
{
|
||||
getWidget(mNameEdit, "NameEdit");
|
||||
getWidget(mMagickaCost, "MagickaCost");
|
||||
getWidget(mSuccessChance, "SuccessChance");
|
||||
getWidget(mAvailableEffectsList, "AvailableEffects");
|
||||
getWidget(mUsedEffectsView, "UsedEffects");
|
||||
getWidget(mPriceLabel, "PriceLabel");
|
||||
getWidget(mBuyButton, "BuyButton");
|
||||
getWidget(mCancelButton, "CancelButton");
|
||||
|
||||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onCancelButtonClicked);
|
||||
mBuyButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onBuyButtonClicked);
|
||||
}
|
||||
|
||||
|
||||
void SpellCreationDialog::open()
|
||||
{
|
||||
center();
|
||||
}
|
||||
|
||||
void SpellCreationDialog::onReferenceUnavailable ()
|
||||
{
|
||||
mWindowManager.removeGuiMode (GM_Dialogue);
|
||||
mWindowManager.removeGuiMode (GM_SpellCreation);
|
||||
}
|
||||
|
||||
void SpellCreationDialog::startSpellMaking (MWWorld::Ptr actor)
|
||||
{
|
||||
mPtr = actor;
|
||||
|
||||
// get the list of magic effects that are known to the player
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
||||
MWMechanics::Spells& spells = stats.getSpells();
|
||||
|
||||
std::vector<short> knownEffects;
|
||||
|
||||
for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it)
|
||||
{
|
||||
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it);
|
||||
|
||||
// only normal spells count
|
||||
if (spell->data.type != ESM::Spell::ST_Spell)
|
||||
continue;
|
||||
|
||||
const std::vector<ESM::ENAMstruct>& list = spell->effects.list;
|
||||
for (std::vector<ESM::ENAMstruct>::const_iterator it2 = list.begin(); it2 != list.end(); ++it2)
|
||||
{
|
||||
if (std::find(knownEffects.begin(), knownEffects.end(), it2->effectID) == knownEffects.end())
|
||||
knownEffects.push_back(it2->effectID);
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(knownEffects.begin(), knownEffects.end(), sortMagicEffects);
|
||||
|
||||
mAvailableEffectsList->clear ();
|
||||
|
||||
for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it)
|
||||
{
|
||||
mAvailableEffectsList->addItem(MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(
|
||||
MWGui::Widgets::MWSpellEffect::effectIDToString (*it))->getString());
|
||||
}
|
||||
mAvailableEffectsList->adjustSize ();
|
||||
|
||||
for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it)
|
||||
{
|
||||
std::string name = MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(
|
||||
MWGui::Widgets::MWSpellEffect::effectIDToString (*it))->getString();
|
||||
MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name);
|
||||
|
||||
ToolTips::createMagicEffectToolTip (w, *it);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SpellCreationDialog::onCancelButtonClicked (MyGUI::Widget* sender)
|
||||
{
|
||||
mWindowManager.removeGuiMode (MWGui::GM_SpellCreation);
|
||||
}
|
||||
|
||||
void SpellCreationDialog::onBuyButtonClicked (MyGUI::Widget* sender)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
#ifndef MWGUI_SPELLCREATION_H
|
||||
#define MWGUI_SPELLCREATION_H
|
||||
|
||||
#include "window_base.hpp"
|
||||
#include "referenceinterface.hpp"
|
||||
#include "list.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
class SpellCreationDialog : public WindowBase, public ReferenceInterface
|
||||
{
|
||||
public:
|
||||
SpellCreationDialog(MWBase::WindowManager& parWindowManager);
|
||||
|
||||
virtual void open();
|
||||
|
||||
void startSpellMaking(MWWorld::Ptr actor);
|
||||
|
||||
protected:
|
||||
virtual void onReferenceUnavailable ();
|
||||
|
||||
void onCancelButtonClicked (MyGUI::Widget* sender);
|
||||
void onBuyButtonClicked (MyGUI::Widget* sender);
|
||||
|
||||
|
||||
MyGUI::EditBox* mNameEdit;
|
||||
MyGUI::TextBox* mMagickaCost;
|
||||
MyGUI::TextBox* mSuccessChance;
|
||||
Widgets::MWList* mAvailableEffectsList;
|
||||
MyGUI::ScrollView* mUsedEffectsView;
|
||||
MyGUI::Button* mBuyButton;
|
||||
MyGUI::Button* mCancelButton;
|
||||
MyGUI::TextBox* mPriceLabel;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Layout">
|
||||
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 560 400" name="_Main">
|
||||
|
||||
<Widget type="HBox" position="12 12 250 30">
|
||||
|
||||
<Widget type="AutoSizedTextBox" skin="NormalText">
|
||||
<Property key="Caption" value="#{sName}"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="EditBox" skin="MW_TextEdit" position="0 0 30 30" name="NameEdit">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="Widget">
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="280 0 300 24">
|
||||
<Property key="Caption" value="#{sEnchantmentMenu4}"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="SandText" position="280 0 258 24" name="MagickaCost">
|
||||
<Property key="Caption" value="1"/>
|
||||
<Property key="TextAlign" value="Right HCenter"/>
|
||||
</Widget>
|
||||
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="280 24 300 24">
|
||||
<Property key="Caption" value="#{sSpellmakingMenu1}"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="SandText" position="280 24 258 24" name="SuccessChance">
|
||||
<Property key="Caption" value="39"/>
|
||||
<Property key="TextAlign" value="Right HCenter"/>
|
||||
</Widget>
|
||||
|
||||
|
||||
<!-- Available effects -->
|
||||
<Widget type="TextBox" skin="NormalText" position="12 48 300 24">
|
||||
<Property key="Caption" value="#{sMagicEffects}"/>
|
||||
</Widget>
|
||||
<Widget type="MWList" skin="MW_SimpleList" position="12 76 202 269" name="AvailableEffects">
|
||||
</Widget>
|
||||
|
||||
<!-- Used effects -->
|
||||
<Widget type="TextBox" skin="NormalText" position="226 48 300 24">
|
||||
<Property key="Caption" value="#{sEffects}"/>
|
||||
</Widget>
|
||||
<Widget type="Widget" skin="MW_Box" position="226 76 316 269">
|
||||
<Widget type="ScrollView" skin="MW_ScrollView" position="4 4 308 261" name="UsedEffects">
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<Widget type="HBox" position="0 340 560 60">
|
||||
<Property key="Padding" value="16"/>
|
||||
|
||||
<Widget type="Widget" position="0 0 0 0">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="AutoSizedTextBox" skin="NormalText">
|
||||
<Property key="Caption" value="#{sBarterDialog7}"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedTextBox" skin="SandText" name="PriceLabel">
|
||||
<Property key="Caption" value="30"/>
|
||||
</Widget>
|
||||
|
||||
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="BuyButton">
|
||||
<Property key="Caption" value="#{sBuy}"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton">
|
||||
<Property key="Caption" value="#{sCancel}"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
</MyGUI>
|
Loading…
Reference in New Issue