mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 13:15:32 +00:00
Merge branch 'spellbuying'
This commit is contained in:
commit
273ac0a97f
17 changed files with 367 additions and 25 deletions
|
@ -29,7 +29,7 @@ add_openmw_dir (mwgui
|
||||||
map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list
|
map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list
|
||||||
formatting inventorywindow container hud countdialog tradewindow settingswindow
|
formatting inventorywindow container hud countdialog tradewindow settingswindow
|
||||||
confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu
|
confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu
|
||||||
itemselection
|
itemselection spellbuyingwindow
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwdialogue
|
add_openmw_dir (mwdialogue
|
||||||
|
|
|
@ -42,6 +42,7 @@ namespace MWGui
|
||||||
class Console;
|
class Console;
|
||||||
class SpellWindow;
|
class SpellWindow;
|
||||||
class TradeWindow;
|
class TradeWindow;
|
||||||
|
class SpellBuyingWindow;
|
||||||
class ConfirmationDialog;
|
class ConfirmationDialog;
|
||||||
class CountDialog;
|
class CountDialog;
|
||||||
class ScrollWindow;
|
class ScrollWindow;
|
||||||
|
@ -106,6 +107,7 @@ namespace MWBase
|
||||||
virtual MWGui::CountDialog* getCountDialog() = 0;
|
virtual MWGui::CountDialog* getCountDialog() = 0;
|
||||||
virtual MWGui::ConfirmationDialog* getConfirmationDialog() = 0;
|
virtual MWGui::ConfirmationDialog* getConfirmationDialog() = 0;
|
||||||
virtual MWGui::TradeWindow* getTradeWindow() = 0;
|
virtual MWGui::TradeWindow* getTradeWindow() = 0;
|
||||||
|
virtual MWGui::SpellBuyingWindow* getSpellBuyingWindow() = 0;
|
||||||
virtual MWGui::SpellWindow* getSpellWindow() = 0;
|
virtual MWGui::SpellWindow* getSpellWindow() = 0;
|
||||||
virtual MWGui::Console* getConsole() = 0;
|
virtual MWGui::Console* getConsole() = 0;
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,11 @@ namespace MWClass
|
||||||
data->mCreatureStats.setFlee(ref->base->mAiData.mFlee);
|
data->mCreatureStats.setFlee(ref->base->mAiData.mFlee);
|
||||||
data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm);
|
data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm);
|
||||||
|
|
||||||
|
// spells
|
||||||
|
for (std::vector<std::string>::const_iterator iter (ref->base->mSpells.list.begin());
|
||||||
|
iter!=ref->base->mSpells.list.end(); ++iter)
|
||||||
|
data->mCreatureStats.getSpells().add (*iter);
|
||||||
|
|
||||||
// store
|
// store
|
||||||
ptr.getRefData().setCustomData (data.release());
|
ptr.getRefData().setCustomData (data.release());
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,11 @@ namespace MWClass
|
||||||
data->mCreatureStats.setFlee(ref->base->mAiData.mFlee);
|
data->mCreatureStats.setFlee(ref->base->mAiData.mFlee);
|
||||||
data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm);
|
data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm);
|
||||||
|
|
||||||
|
// spells
|
||||||
|
for (std::vector<std::string>::const_iterator iter (ref->base->spells.list.begin());
|
||||||
|
iter!=ref->base->spells.list.end(); ++iter)
|
||||||
|
data->mCreatureStats.getSpells().add (*iter);
|
||||||
|
|
||||||
// store
|
// store
|
||||||
ptr.getRefData().setCustomData (data.release());
|
ptr.getRefData().setCustomData (data.release());
|
||||||
}
|
}
|
||||||
|
|
|
@ -794,6 +794,11 @@ namespace MWDialogue
|
||||||
else
|
else
|
||||||
win->setShowTrade(false);
|
win->setShowTrade(false);
|
||||||
|
|
||||||
|
if (services & ESM::NPC::Spells)
|
||||||
|
win->setShowSpells(true);
|
||||||
|
else
|
||||||
|
win->setShowSpells(false);
|
||||||
|
|
||||||
// sort again, because the previous sort was case-sensitive
|
// sort again, because the previous sort was case-sensitive
|
||||||
keywordList.sort(stringCompareNoCase);
|
keywordList.sort(stringCompareNoCase);
|
||||||
win->setKeywords(keywordList);
|
win->setKeywords(keywordList);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "widgets.hpp"
|
#include "widgets.hpp"
|
||||||
#include "list.hpp"
|
#include "list.hpp"
|
||||||
#include "tradewindow.hpp"
|
#include "tradewindow.hpp"
|
||||||
|
#include "spellbuyingwindow.hpp"
|
||||||
#include "inventorywindow.hpp"
|
#include "inventorywindow.hpp"
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
@ -46,6 +47,7 @@ DialogueWindow::DialogueWindow(MWBase::WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_dialogue_window.layout", parWindowManager)
|
: WindowBase("openmw_dialogue_window.layout", parWindowManager)
|
||||||
, mEnabled(true)
|
, mEnabled(true)
|
||||||
, mShowTrade(false)
|
, mShowTrade(false)
|
||||||
|
, mShowSpells(false)
|
||||||
{
|
{
|
||||||
// Centre dialog
|
// Centre dialog
|
||||||
center();
|
center();
|
||||||
|
@ -127,6 +129,11 @@ void DialogueWindow::onSelectTopic(std::string topic)
|
||||||
mWindowManager.pushGuiMode(GM_Barter);
|
mWindowManager.pushGuiMode(GM_Barter);
|
||||||
mWindowManager.getTradeWindow()->startTrade(mPtr);
|
mWindowManager.getTradeWindow()->startTrade(mPtr);
|
||||||
}
|
}
|
||||||
|
else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sSpells")->str)
|
||||||
|
{
|
||||||
|
mWindowManager.pushGuiMode(GM_SpellBuying);
|
||||||
|
mWindowManager.getSpellBuyingWindow()->startSpellBuying(mPtr);
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(topic));
|
MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(topic));
|
||||||
|
@ -148,11 +155,14 @@ void DialogueWindow::setKeywords(std::list<std::string> keyWords)
|
||||||
{
|
{
|
||||||
mTopicsList->clear();
|
mTopicsList->clear();
|
||||||
|
|
||||||
bool anyService = mShowTrade;
|
bool anyService = mShowTrade||mShowSpells;
|
||||||
|
|
||||||
if (mShowTrade)
|
if (mShowTrade)
|
||||||
mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sBarter")->str);
|
mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sBarter")->str);
|
||||||
|
|
||||||
|
if (mShowSpells)
|
||||||
|
mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sSpells")->str);
|
||||||
|
|
||||||
if (anyService)
|
if (anyService)
|
||||||
mTopicsList->addSeparator();
|
mTopicsList->addSeparator();
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ namespace MWGui
|
||||||
// various service button visibilities, depending if the npc/creature talked to has these services
|
// various service button visibilities, depending if the npc/creature talked to has these services
|
||||||
// make sure to call these before setKeywords()
|
// make sure to call these before setKeywords()
|
||||||
void setShowTrade(bool show) { mShowTrade = show; }
|
void setShowTrade(bool show) { mShowTrade = show; }
|
||||||
|
void setShowSpells(bool show) { mShowSpells = show; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onSelectTopic(std::string topic);
|
void onSelectTopic(std::string topic);
|
||||||
|
@ -70,6 +71,7 @@ namespace MWGui
|
||||||
|
|
||||||
// various service button visibilities, depending if the npc/creature talked to has these services
|
// various service button visibilities, depending if the npc/creature talked to has these services
|
||||||
bool mShowTrade;
|
bool mShowTrade;
|
||||||
|
bool mShowSpells;
|
||||||
|
|
||||||
bool mEnabled;
|
bool mEnabled;
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ namespace MWGui
|
||||||
GM_Dialogue, // NPC interaction
|
GM_Dialogue, // NPC interaction
|
||||||
GM_Barter,
|
GM_Barter,
|
||||||
GM_Rest,
|
GM_Rest,
|
||||||
|
GM_SpellBuying,
|
||||||
|
|
||||||
// Startup character creation dialogs
|
// Startup character creation dialogs
|
||||||
GM_Name,
|
GM_Name,
|
||||||
|
|
190
apps/openmw/mwgui/spellbuyingwindow.cpp
Normal file
190
apps/openmw/mwgui/spellbuyingwindow.cpp
Normal file
|
@ -0,0 +1,190 @@
|
||||||
|
#include "spellbuyingwindow.hpp"
|
||||||
|
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/soundmanager.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
#include "../mwworld/manualref.hpp"
|
||||||
|
|
||||||
|
#include "../mwmechanics/spells.hpp"
|
||||||
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
|
|
||||||
|
#include "inventorywindow.hpp"
|
||||||
|
#include "tradewindow.hpp"
|
||||||
|
|
||||||
|
namespace MWGui
|
||||||
|
{
|
||||||
|
const int SpellBuyingWindow::sLineHeight = 18;
|
||||||
|
|
||||||
|
SpellBuyingWindow::SpellBuyingWindow(MWBase::WindowManager& parWindowManager) :
|
||||||
|
WindowBase("openmw_spell_buying_window.layout", parWindowManager)
|
||||||
|
, ContainerBase(NULL) // no drag&drop
|
||||||
|
, mCurrentY(0)
|
||||||
|
, mLastPos(0)
|
||||||
|
{
|
||||||
|
setCoord(0, 0, 450, 300);
|
||||||
|
|
||||||
|
getWidget(mCancelButton, "CancelButton");
|
||||||
|
getWidget(mPlayerGold, "PlayerGold");
|
||||||
|
getWidget(mSelect, "Select");
|
||||||
|
getWidget(mSpells, "Spells");
|
||||||
|
getWidget(mSpellsBoxWidget, "SpellsBox");
|
||||||
|
getWidget(mSpellsClientWidget, "SpellsClient");
|
||||||
|
getWidget(mSpellsScrollerWidget, "SpellsScroller");
|
||||||
|
|
||||||
|
mSpellsClientWidget->eventMouseWheel += MyGUI::newDelegate(this, &SpellBuyingWindow::onMouseWheel);
|
||||||
|
|
||||||
|
mSpellsScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &SpellBuyingWindow::onScrollChangePosition);
|
||||||
|
|
||||||
|
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellBuyingWindow::onCancelButtonClicked);
|
||||||
|
|
||||||
|
int cancelButtonWidth = mCancelButton->getTextSize().width + 24;
|
||||||
|
mCancelButton->setCoord(430-cancelButtonWidth,
|
||||||
|
mCancelButton->getTop(),
|
||||||
|
cancelButtonWidth,
|
||||||
|
mCancelButton->getHeight());
|
||||||
|
mSpells->setCoord(450/2-mSpells->getTextSize().width/2,
|
||||||
|
mSpells->getTop(),
|
||||||
|
mSpells->getTextSize().width,
|
||||||
|
mSpells->getHeight());
|
||||||
|
mSelect->setCoord(8,
|
||||||
|
mSelect->getTop(),
|
||||||
|
mSelect->getTextSize().width,
|
||||||
|
mSelect->getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpellBuyingWindow::addSpell(const std::string& spellId)
|
||||||
|
{
|
||||||
|
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId);
|
||||||
|
int price = spell->data.cost*MWBase::Environment::get().getWorld()->getStore().gameSettings.search("fSpellValueMult")->f;
|
||||||
|
MyGUI::Button* toAdd = mSpellsClientWidget->createWidget<MyGUI::Button>((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SpellText", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default);
|
||||||
|
mCurrentY += sLineHeight;
|
||||||
|
/// \todo price adjustment depending on merchantile skill
|
||||||
|
toAdd->setUserData(price);
|
||||||
|
toAdd->setCaption(spell->name+" - "+boost::lexical_cast<std::string>(price)+MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sgp")->str);
|
||||||
|
toAdd->setSize(toAdd->getTextSize().width,sLineHeight);
|
||||||
|
toAdd->eventMouseWheel += MyGUI::newDelegate(this, &SpellBuyingWindow::onMouseWheel);
|
||||||
|
toAdd->setUserString("ToolTipType", "Spell");
|
||||||
|
toAdd->setUserString("Spell", spellId);
|
||||||
|
toAdd->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellBuyingWindow::onSpellButtonClick);
|
||||||
|
mSpellsWidgetMap.insert(std::make_pair (toAdd, spellId));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpellBuyingWindow::clearSpells()
|
||||||
|
{
|
||||||
|
mSpellsScrollerWidget->setScrollPosition(0);
|
||||||
|
onScrollChangePosition(mSpellsScrollerWidget, mSpellsScrollerWidget->getScrollPosition());
|
||||||
|
mCurrentY = 0;
|
||||||
|
while (mSpellsClientWidget->getChildCount())
|
||||||
|
MyGUI::Gui::getInstance().destroyWidget(mSpellsClientWidget->getChildAt(0));
|
||||||
|
mSpellsWidgetMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpellBuyingWindow::startSpellBuying(const MWWorld::Ptr& actor)
|
||||||
|
{
|
||||||
|
center();
|
||||||
|
mActor = actor;
|
||||||
|
clearSpells();
|
||||||
|
|
||||||
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||||
|
|
||||||
|
MWMechanics::Spells& playerSpells = MWWorld::Class::get (player).getCreatureStats (player).getSpells();
|
||||||
|
MWMechanics::Spells& merchantSpells = MWWorld::Class::get (actor).getCreatureStats (actor).getSpells();
|
||||||
|
|
||||||
|
for (MWMechanics::Spells::TIterator iter = merchantSpells.begin(); iter!=merchantSpells.end(); ++iter)
|
||||||
|
{
|
||||||
|
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find (*iter);
|
||||||
|
|
||||||
|
if (spell->data.type!=ESM::Spell::ST_Spell)
|
||||||
|
continue; // don't try to sell diseases, curses or powers
|
||||||
|
|
||||||
|
if (std::find (playerSpells.begin(), playerSpells.end(), *iter)!=playerSpells.end())
|
||||||
|
continue; // we have that spell already
|
||||||
|
|
||||||
|
addSpell (*iter);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateLabels();
|
||||||
|
updateScroller();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpellBuyingWindow::onSpellButtonClick(MyGUI::Widget* _sender)
|
||||||
|
{
|
||||||
|
int price = *_sender->getUserData<int>();
|
||||||
|
|
||||||
|
if (mWindowManager.getInventoryWindow()->getPlayerGold()>=price)
|
||||||
|
{
|
||||||
|
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 (mSpellsWidgetMap.find(_sender)->second);
|
||||||
|
mWindowManager.getTradeWindow()->addOrRemoveGold(-price);
|
||||||
|
mSpellsScrollerWidget->setScrollPosition(0);
|
||||||
|
onScrollChangePosition(mSpellsScrollerWidget, mSpellsScrollerWidget->getScrollPosition());
|
||||||
|
updateScroller();
|
||||||
|
startSpellBuying(mActor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpellBuyingWindow::onCancelButtonClicked(MyGUI::Widget* _sender)
|
||||||
|
{
|
||||||
|
mWindowManager.removeGuiMode(GM_SpellBuying);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpellBuyingWindow::updateLabels()
|
||||||
|
{
|
||||||
|
mPlayerGold->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGold")->str
|
||||||
|
+ ": " + boost::lexical_cast<std::string>(mWindowManager.getInventoryWindow()->getPlayerGold()));
|
||||||
|
mPlayerGold->setCoord(8,
|
||||||
|
mPlayerGold->getTop(),
|
||||||
|
mPlayerGold->getTextSize().width,
|
||||||
|
mPlayerGold->getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpellBuyingWindow::onReferenceUnavailable()
|
||||||
|
{
|
||||||
|
// remove both Spells and Dialogue (since you always trade with the NPC/creature that you have previously talked to)
|
||||||
|
mWindowManager.removeGuiMode(GM_SpellBuying);
|
||||||
|
mWindowManager.removeGuiMode(GM_Dialogue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpellBuyingWindow::updateScroller()
|
||||||
|
{
|
||||||
|
mSpellsScrollerWidget->setScrollRange(std::max(mCurrentY - mSpellsClientWidget->getHeight(), 0));
|
||||||
|
mSpellsScrollerWidget->setScrollPage(std::max(mSpellsClientWidget->getHeight() - sLineHeight, 0));
|
||||||
|
if (mCurrentY != 0)
|
||||||
|
mSpellsScrollerWidget->setTrackSize( (mSpellsBoxWidget->getHeight() / float(mCurrentY)) * mSpellsScrollerWidget->getLineSize() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpellBuyingWindow::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos)
|
||||||
|
{
|
||||||
|
int diff = mLastPos - pos;
|
||||||
|
// Adjust position of all widget according to difference
|
||||||
|
if (diff == 0)
|
||||||
|
return;
|
||||||
|
mLastPos = pos;
|
||||||
|
|
||||||
|
for (unsigned int i=0;i<mSpellsClientWidget->getChildCount();i++)
|
||||||
|
{
|
||||||
|
MyGUI::Widget* toMove = mSpellsClientWidget->getChildAt(i);
|
||||||
|
toMove->setCoord(toMove->getCoord() + MyGUI::IntPoint(0, diff));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpellBuyingWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel)
|
||||||
|
{
|
||||||
|
if (mSpellsScrollerWidget->getScrollPosition() - _rel*0.3 < 0)
|
||||||
|
mSpellsScrollerWidget->setScrollPosition(0);
|
||||||
|
else if (mSpellsScrollerWidget->getScrollPosition() - _rel*0.3 > mSpellsScrollerWidget->getScrollRange()-1)
|
||||||
|
mSpellsScrollerWidget->setScrollPosition(mSpellsScrollerWidget->getScrollRange()-1);
|
||||||
|
else
|
||||||
|
mSpellsScrollerWidget->setScrollPosition(mSpellsScrollerWidget->getScrollPosition() - _rel*0.3);
|
||||||
|
|
||||||
|
onScrollChangePosition(mSpellsScrollerWidget, mSpellsScrollerWidget->getScrollPosition());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
60
apps/openmw/mwgui/spellbuyingwindow.hpp
Normal file
60
apps/openmw/mwgui/spellbuyingwindow.hpp
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
#ifndef MWGUI_SpellBuyingWINDOW_H
|
||||||
|
#define MWGUI_SpellBuyingWINDOW_H
|
||||||
|
|
||||||
|
#include "container.hpp"
|
||||||
|
#include "window_base.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
|
namespace MyGUI
|
||||||
|
{
|
||||||
|
class Gui;
|
||||||
|
class Widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWGui
|
||||||
|
{
|
||||||
|
class WindowManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace MWGui
|
||||||
|
{
|
||||||
|
class SpellBuyingWindow : public ContainerBase, public WindowBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SpellBuyingWindow(MWBase::WindowManager& parWindowManager);
|
||||||
|
|
||||||
|
void startSpellBuying(const MWWorld::Ptr& actor);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
MyGUI::Button* mCancelButton;
|
||||||
|
MyGUI::TextBox* mPlayerGold;
|
||||||
|
MyGUI::TextBox* mSpells;
|
||||||
|
MyGUI::TextBox* mSelect;
|
||||||
|
|
||||||
|
MyGUI::WidgetPtr mSpellsBoxWidget, mSpellsClientWidget;
|
||||||
|
MyGUI::ScrollBar* mSpellsScrollerWidget;
|
||||||
|
|
||||||
|
MWWorld::Ptr mActor;
|
||||||
|
|
||||||
|
std::map<MyGUI::Widget*, std::string> mSpellsWidgetMap;
|
||||||
|
|
||||||
|
void onCancelButtonClicked(MyGUI::Widget* _sender);
|
||||||
|
void onSpellButtonClick(MyGUI::Widget* _sender);
|
||||||
|
void updateScroller();
|
||||||
|
void onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos);
|
||||||
|
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
|
||||||
|
void addSpell(const std::string& spellID);
|
||||||
|
void clearSpells();
|
||||||
|
int mLastPos,mCurrentY;
|
||||||
|
|
||||||
|
static const int sLineHeight;
|
||||||
|
|
||||||
|
void updateLabels();
|
||||||
|
|
||||||
|
virtual void onReferenceUnavailable();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -136,6 +136,33 @@ namespace MWGui
|
||||||
drawItems();
|
drawItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TradeWindow::addOrRemoveGold(int amount)
|
||||||
|
{
|
||||||
|
bool goldFound = false;
|
||||||
|
MWWorld::Ptr gold;
|
||||||
|
MWWorld::ContainerStore& playerStore = mWindowManager.getInventoryWindow()->getContainerStore();
|
||||||
|
for (MWWorld::ContainerStoreIterator it = playerStore.begin();
|
||||||
|
it != playerStore.end(); ++it)
|
||||||
|
{
|
||||||
|
if (MWWorld::Class::get(*it).getName(*it) == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGold")->str)
|
||||||
|
{
|
||||||
|
goldFound = true;
|
||||||
|
gold = *it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (goldFound)
|
||||||
|
{
|
||||||
|
gold.getRefData().setCount(gold.getRefData().getCount() + amount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
assert(amount > 0);
|
||||||
|
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), "Gold_001");
|
||||||
|
ref.getPtr().getRefData().setCount(amount);
|
||||||
|
playerStore.add(ref.getPtr());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TradeWindow::onOfferButtonClicked(MyGUI::Widget* _sender)
|
void TradeWindow::onOfferButtonClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
// were there any items traded at all?
|
// were there any items traded at all?
|
||||||
|
@ -186,29 +213,7 @@ namespace MWGui
|
||||||
mWindowManager.getInventoryWindow()->transferBoughtItems();
|
mWindowManager.getInventoryWindow()->transferBoughtItems();
|
||||||
|
|
||||||
// add or remove gold from the player.
|
// add or remove gold from the player.
|
||||||
bool goldFound = false;
|
addOrRemoveGold(mCurrentBalance);
|
||||||
MWWorld::Ptr gold;
|
|
||||||
MWWorld::ContainerStore& playerStore = mWindowManager.getInventoryWindow()->getContainerStore();
|
|
||||||
for (MWWorld::ContainerStoreIterator it = playerStore.begin();
|
|
||||||
it != playerStore.end(); ++it)
|
|
||||||
{
|
|
||||||
if (MWWorld::Class::get(*it).getName(*it) == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGold")->str)
|
|
||||||
{
|
|
||||||
goldFound = true;
|
|
||||||
gold = *it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (goldFound)
|
|
||||||
{
|
|
||||||
gold.getRefData().setCount(gold.getRefData().getCount() + mCurrentBalance);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
assert(mCurrentBalance > 0);
|
|
||||||
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), "Gold_001");
|
|
||||||
ref.getPtr().getRefData().setCount(mCurrentBalance);
|
|
||||||
playerStore.add(ref.getPtr());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string sound = "Item Gold Up";
|
std::string sound = "Item Gold Up";
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
||||||
|
|
|
@ -32,6 +32,8 @@ namespace MWGui
|
||||||
|
|
||||||
bool npcAcceptsItem(MWWorld::Ptr item);
|
bool npcAcceptsItem(MWWorld::Ptr item);
|
||||||
|
|
||||||
|
void addOrRemoveGold(int gold);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MyGUI::Button* mFilterAll;
|
MyGUI::Button* mFilterAll;
|
||||||
MyGUI::Button* mFilterWeapon;
|
MyGUI::Button* mFilterWeapon;
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "mainmenu.hpp"
|
#include "mainmenu.hpp"
|
||||||
#include "countdialog.hpp"
|
#include "countdialog.hpp"
|
||||||
#include "tradewindow.hpp"
|
#include "tradewindow.hpp"
|
||||||
|
#include "spellbuyingwindow.hpp"
|
||||||
#include "settingswindow.hpp"
|
#include "settingswindow.hpp"
|
||||||
#include "confirmationdialog.hpp"
|
#include "confirmationdialog.hpp"
|
||||||
#include "alchemywindow.hpp"
|
#include "alchemywindow.hpp"
|
||||||
|
@ -61,6 +62,7 @@ WindowManager::WindowManager(
|
||||||
, mScrollWindow(NULL)
|
, mScrollWindow(NULL)
|
||||||
, mCountDialog(NULL)
|
, mCountDialog(NULL)
|
||||||
, mTradeWindow(NULL)
|
, mTradeWindow(NULL)
|
||||||
|
, mSpellBuyingWindow(NULL)
|
||||||
, mSettingsWindow(NULL)
|
, mSettingsWindow(NULL)
|
||||||
, mConfirmationDialog(NULL)
|
, mConfirmationDialog(NULL)
|
||||||
, mAlchemyWindow(NULL)
|
, mAlchemyWindow(NULL)
|
||||||
|
@ -126,6 +128,7 @@ WindowManager::WindowManager(
|
||||||
mMessageBoxManager = new MessageBoxManager(this);
|
mMessageBoxManager = new MessageBoxManager(this);
|
||||||
mInventoryWindow = new InventoryWindow(*this,mDragAndDrop);
|
mInventoryWindow = new InventoryWindow(*this,mDragAndDrop);
|
||||||
mTradeWindow = new TradeWindow(*this);
|
mTradeWindow = new TradeWindow(*this);
|
||||||
|
mSpellBuyingWindow = new SpellBuyingWindow(*this);
|
||||||
mDialogueWindow = new DialogueWindow(*this);
|
mDialogueWindow = new DialogueWindow(*this);
|
||||||
mContainerWindow = new ContainerWindow(*this,mDragAndDrop);
|
mContainerWindow = new ContainerWindow(*this,mDragAndDrop);
|
||||||
mHud = new HUD(w,h, mShowFPSLevel, mDragAndDrop);
|
mHud = new HUD(w,h, mShowFPSLevel, mDragAndDrop);
|
||||||
|
@ -182,6 +185,7 @@ WindowManager::~WindowManager()
|
||||||
delete mBookWindow;
|
delete mBookWindow;
|
||||||
delete mScrollWindow;
|
delete mScrollWindow;
|
||||||
delete mTradeWindow;
|
delete mTradeWindow;
|
||||||
|
delete mSpellBuyingWindow;
|
||||||
delete mSettingsWindow;
|
delete mSettingsWindow;
|
||||||
delete mConfirmationDialog;
|
delete mConfirmationDialog;
|
||||||
delete mAlchemyWindow;
|
delete mAlchemyWindow;
|
||||||
|
@ -228,6 +232,7 @@ void WindowManager::updateVisible()
|
||||||
mScrollWindow->setVisible(false);
|
mScrollWindow->setVisible(false);
|
||||||
mBookWindow->setVisible(false);
|
mBookWindow->setVisible(false);
|
||||||
mTradeWindow->setVisible(false);
|
mTradeWindow->setVisible(false);
|
||||||
|
mSpellBuyingWindow->setVisible(false);
|
||||||
mSettingsWindow->setVisible(false);
|
mSettingsWindow->setVisible(false);
|
||||||
mAlchemyWindow->setVisible(false);
|
mAlchemyWindow->setVisible(false);
|
||||||
mSpellWindow->setVisible(false);
|
mSpellWindow->setVisible(false);
|
||||||
|
@ -317,6 +322,9 @@ void WindowManager::updateVisible()
|
||||||
mInventoryWindow->setVisible(true);
|
mInventoryWindow->setVisible(true);
|
||||||
mTradeWindow->setVisible(true);
|
mTradeWindow->setVisible(true);
|
||||||
break;
|
break;
|
||||||
|
case GM_SpellBuying:
|
||||||
|
mSpellBuyingWindow->setVisible(true);
|
||||||
|
break;
|
||||||
case GM_InterMessageBox:
|
case GM_InterMessageBox:
|
||||||
break;
|
break;
|
||||||
case GM_Journal:
|
case GM_Journal:
|
||||||
|
@ -509,6 +517,7 @@ void WindowManager::onFrame (float frameDuration)
|
||||||
|
|
||||||
mDialogueWindow->checkReferenceAvailable();
|
mDialogueWindow->checkReferenceAvailable();
|
||||||
mTradeWindow->checkReferenceAvailable();
|
mTradeWindow->checkReferenceAvailable();
|
||||||
|
mSpellBuyingWindow->checkReferenceAvailable();
|
||||||
mContainerWindow->checkReferenceAvailable();
|
mContainerWindow->checkReferenceAvailable();
|
||||||
mConsole->checkReferenceAvailable();
|
mConsole->checkReferenceAvailable();
|
||||||
}
|
}
|
||||||
|
@ -786,6 +795,7 @@ MWGui::ScrollWindow* WindowManager::getScrollWindow() { return mScrollWindow; }
|
||||||
MWGui::CountDialog* WindowManager::getCountDialog() { return mCountDialog; }
|
MWGui::CountDialog* WindowManager::getCountDialog() { return mCountDialog; }
|
||||||
MWGui::ConfirmationDialog* WindowManager::getConfirmationDialog() { return mConfirmationDialog; }
|
MWGui::ConfirmationDialog* WindowManager::getConfirmationDialog() { return mConfirmationDialog; }
|
||||||
MWGui::TradeWindow* WindowManager::getTradeWindow() { return mTradeWindow; }
|
MWGui::TradeWindow* WindowManager::getTradeWindow() { return mTradeWindow; }
|
||||||
|
MWGui::SpellBuyingWindow* WindowManager::getSpellBuyingWindow() { return mSpellBuyingWindow; }
|
||||||
MWGui::SpellWindow* WindowManager::getSpellWindow() { return mSpellWindow; }
|
MWGui::SpellWindow* WindowManager::getSpellWindow() { return mSpellWindow; }
|
||||||
MWGui::Console* WindowManager::getConsole() { return mConsole; }
|
MWGui::Console* WindowManager::getConsole() { return mConsole; }
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ namespace MWGui
|
||||||
virtual MWGui::CountDialog* getCountDialog();
|
virtual MWGui::CountDialog* getCountDialog();
|
||||||
virtual MWGui::ConfirmationDialog* getConfirmationDialog();
|
virtual MWGui::ConfirmationDialog* getConfirmationDialog();
|
||||||
virtual MWGui::TradeWindow* getTradeWindow();
|
virtual MWGui::TradeWindow* getTradeWindow();
|
||||||
|
virtual MWGui::SpellBuyingWindow* getSpellBuyingWindow();
|
||||||
virtual MWGui::SpellWindow* getSpellWindow();
|
virtual MWGui::SpellWindow* getSpellWindow();
|
||||||
virtual MWGui::Console* getConsole();
|
virtual MWGui::Console* getConsole();
|
||||||
|
|
||||||
|
@ -212,6 +213,7 @@ namespace MWGui
|
||||||
BookWindow* mBookWindow;
|
BookWindow* mBookWindow;
|
||||||
CountDialog* mCountDialog;
|
CountDialog* mCountDialog;
|
||||||
TradeWindow* mTradeWindow;
|
TradeWindow* mTradeWindow;
|
||||||
|
SpellBuyingWindow* mSpellBuyingWindow;
|
||||||
SettingsWindow* mSettingsWindow;
|
SettingsWindow* mSettingsWindow;
|
||||||
ConfirmationDialog* mConfirmationDialog;
|
ConfirmationDialog* mConfirmationDialog;
|
||||||
AlchemyWindow* mAlchemyWindow;
|
AlchemyWindow* mAlchemyWindow;
|
||||||
|
|
|
@ -64,11 +64,13 @@ set(MYGUI_FILES
|
||||||
openmw_text.skin.xml
|
openmw_text.skin.xml
|
||||||
openmw_tooltips.layout
|
openmw_tooltips.layout
|
||||||
openmw_trade_window.layout
|
openmw_trade_window.layout
|
||||||
|
openmw_spell_buying_window.layout
|
||||||
openmw_windows.skin.xml
|
openmw_windows.skin.xml
|
||||||
openmw_quickkeys_menu.layout
|
openmw_quickkeys_menu.layout
|
||||||
openmw_quickkeys_menu_assign.layout
|
openmw_quickkeys_menu_assign.layout
|
||||||
openmw_itemselection_dialog.layout
|
openmw_itemselection_dialog.layout
|
||||||
openmw_magicselection_dialog.layout
|
openmw_magicselection_dialog.layout
|
||||||
|
openmw_spell_buying_window.layout
|
||||||
smallbars.png
|
smallbars.png
|
||||||
VeraMono.ttf
|
VeraMono.ttf
|
||||||
markers.png
|
markers.png
|
||||||
|
|
33
files/mygui/openmw_spell_buying_window.layout
Normal file
33
files/mygui/openmw_spell_buying_window.layout
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<MyGUI type="Layout">
|
||||||
|
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 450 300" name="_Main">
|
||||||
|
<Property key="Visible" value="false"/>
|
||||||
|
|
||||||
|
|
||||||
|
<Widget type="TextBox" skin="SandText" position="8 10 24 24" name="Select" align="Right Top">
|
||||||
|
<Property key="TextAlign" value="Right"/>
|
||||||
|
<Property key="Caption" value="#{sSpellServiceTitle}"/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="TextBox" skin="SandText" position="0 0 24 24" name="Spells" align="Right Top">
|
||||||
|
<Property key="TextAlign" value="Right"/>
|
||||||
|
<Property key="Caption" value="#D8C09A#{sSpells}"/>
|
||||||
|
</Widget>
|
||||||
|
|
||||||
|
|
||||||
|
<Widget type="Widget" skin="MW_Box" position="6 31 430 225" align="ALIGN_LEFT ALIGN_STRETCH" name="SpellsBox">
|
||||||
|
<Widget type="Widget" skin="" position="4 4 404 217" align="ALIGN_LEFT ALIGN_TOP ALIGN_STRETCH" name="SpellsClient" />
|
||||||
|
<Widget type="ScrollBar" skin="MW_VScroll" position="412 4 14 217" align="ALIGN_RIGHT ALIGN_VSTRETCH" name="SpellsScroller" />
|
||||||
|
</Widget>
|
||||||
|
|
||||||
|
|
||||||
|
<Widget type="TextBox" skin="SandText" position="8 255 24 24" name="PlayerGold" align="Right Top">
|
||||||
|
<Property key="TextAlign" value="Right"/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="Button" skin="MW_Button" position="290 260 60 24" name="CancelButton" align="Right Top">
|
||||||
|
<Property key="Caption" value="#{sOK}"/>
|
||||||
|
</Widget>
|
||||||
|
|
||||||
|
</Widget>
|
||||||
|
|
||||||
|
</MyGUI>
|
|
@ -17,6 +17,14 @@
|
||||||
<BasisSkin type="SimpleText" offset = "0 0 16 16" align = "ALIGN_STRETCH"/>
|
<BasisSkin type="SimpleText" offset = "0 0 16 16" align = "ALIGN_STRETCH"/>
|
||||||
</Skin>
|
</Skin>
|
||||||
|
|
||||||
|
<!-- HTML colour: #9A9074 -->
|
||||||
|
<Skin name = "SandTextGreyedOut" size = "16 16">
|
||||||
|
<Property key="FontName" value = "Default" />
|
||||||
|
<Property key="TextAlign" value = "ALIGN_LEFT ALIGN_BOTTOM" />
|
||||||
|
<Property key="TextColour" value = "0.6 0.56 0.45" />
|
||||||
|
<BasisSkin type="SimpleText" offset = "0 0 16 16" align = "ALIGN_STRETCH"/>
|
||||||
|
</Skin>
|
||||||
|
|
||||||
<!-- HTML colour: #BF9959 -->
|
<!-- HTML colour: #BF9959 -->
|
||||||
<Skin name = "SandText" size = "16 16">
|
<Skin name = "SandText" size = "16 16">
|
||||||
<Property key="FontName" value = "Default" />
|
<Property key="FontName" value = "Default" />
|
||||||
|
|
Loading…
Reference in a new issue