forked from mirror/openmw-tes3mp
in the trade window, don't show items that the merchant has equipped.
This commit is contained in:
parent
6ae642aa06
commit
41efea4c1d
8 changed files with 85 additions and 14 deletions
|
@ -300,10 +300,13 @@ void ContainerBase::drawItems()
|
||||||
equippedItems.erase(found);
|
equippedItems.erase(found);
|
||||||
}
|
}
|
||||||
// and add the items that are left (= have the correct category)
|
// and add the items that are left (= have the correct category)
|
||||||
for (std::vector<MWWorld::Ptr>::const_iterator it=equippedItems.begin();
|
if (!ignoreEquippedItems())
|
||||||
it != equippedItems.end(); ++it)
|
|
||||||
{
|
{
|
||||||
items.push_back( std::make_pair(*it, ItemState_Equipped) );
|
for (std::vector<MWWorld::Ptr>::const_iterator it=equippedItems.begin();
|
||||||
|
it != equippedItems.end(); ++it)
|
||||||
|
{
|
||||||
|
items.push_back( std::make_pair(*it, ItemState_Equipped) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// now add the regular items
|
// now add the regular items
|
||||||
|
|
|
@ -98,6 +98,9 @@ namespace MWGui
|
||||||
virtual bool isInventory() { return false; }
|
virtual bool isInventory() { return false; }
|
||||||
virtual std::vector<MWWorld::Ptr> getEquippedItems() { return std::vector<MWWorld::Ptr>(); }
|
virtual std::vector<MWWorld::Ptr> getEquippedItems() { return std::vector<MWWorld::Ptr>(); }
|
||||||
virtual void _unequipItem(MWWorld::Ptr item) { ; }
|
virtual void _unequipItem(MWWorld::Ptr item) { ; }
|
||||||
|
|
||||||
|
// to be reimplemented by TradeWindow
|
||||||
|
virtual bool ignoreEquippedItems() { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class ContainerWindow : public ContainerBase, public WindowBase
|
class ContainerWindow : public ContainerBase, public WindowBase
|
||||||
|
|
|
@ -84,13 +84,13 @@ namespace MWGui
|
||||||
mFilterAll->setStateSelected(true);
|
mFilterAll->setStateSelected(true);
|
||||||
|
|
||||||
setCoord(0, 342, 600, 258);
|
setCoord(0, 342, 600, 258);
|
||||||
|
|
||||||
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||||
|
openContainer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InventoryWindow::openInventory()
|
void InventoryWindow::openInventory()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
|
||||||
openContainer(player);
|
|
||||||
|
|
||||||
onWindowResize(static_cast<MyGUI::Window*>(mMainWidget));
|
onWindowResize(static_cast<MyGUI::Window*>(mMainWidget));
|
||||||
|
|
||||||
updateEncumbranceBar();
|
updateEncumbranceBar();
|
||||||
|
@ -232,4 +232,17 @@ namespace MWGui
|
||||||
|
|
||||||
ContainerBase::Update();
|
ContainerBase::Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int InventoryWindow::getPlayerGold()
|
||||||
|
{
|
||||||
|
MWWorld::InventoryStore& invStore = static_cast<MWWorld::InventoryStore&>(MWWorld::Class::get(mContainer).getContainerStore(mContainer));
|
||||||
|
|
||||||
|
for (MWWorld::ContainerStoreIterator it = invStore.begin();
|
||||||
|
it != invStore.end(); ++it)
|
||||||
|
{
|
||||||
|
if (MWWorld::Class::get(*it).getName(*it) == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGold")->str)
|
||||||
|
return it->getRefData().getCount();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ namespace MWGui
|
||||||
virtual void Update();
|
virtual void Update();
|
||||||
virtual void notifyContentChanged();
|
virtual void notifyContentChanged();
|
||||||
|
|
||||||
|
int getPlayerGold();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MyGUI::Widget* mAvatar;
|
MyGUI::Widget* mAvatar;
|
||||||
MyGUI::TextBox* mArmorRating;
|
MyGUI::TextBox* mArmorRating;
|
||||||
|
|
|
@ -1,15 +1,20 @@
|
||||||
#include "tradewindow.hpp"
|
#include "tradewindow.hpp"
|
||||||
|
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/world.hpp"
|
||||||
|
#include "../mwworld/inventorystore.hpp"
|
||||||
|
|
||||||
#include "window_manager.hpp"
|
#include "window_manager.hpp"
|
||||||
|
#include "inventorywindow.hpp"
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
TradeWindow::TradeWindow(WindowManager& parWindowManager) :
|
TradeWindow::TradeWindow(WindowManager& parWindowManager) :
|
||||||
WindowBase("openmw_trade_window_layout.xml", parWindowManager),
|
WindowBase("openmw_trade_window_layout.xml", parWindowManager)
|
||||||
ContainerBase(NULL) // no drag&drop
|
, ContainerBase(NULL) // no drag&drop
|
||||||
|
, mCurrentBalance(0)
|
||||||
{
|
{
|
||||||
MyGUI::ScrollView* itemView;
|
MyGUI::ScrollView* itemView;
|
||||||
MyGUI::Widget* containerWidget;
|
MyGUI::Widget* containerWidget;
|
||||||
|
@ -40,9 +45,6 @@ namespace MWGui
|
||||||
mCancelButton->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sCancel")->str);
|
mCancelButton->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sCancel")->str);
|
||||||
mOfferButton->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sOffer")->str);
|
mOfferButton->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sOffer")->str);
|
||||||
/*
|
/*
|
||||||
mTotalBalanceLabel->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sTotalCost")->str);
|
|
||||||
mTotalBalanceLabel->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sTotalSold")->str);
|
|
||||||
mPlayerGold->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sYourGold")->str);
|
|
||||||
mMerchantGold->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sSellerGold")->str);
|
mMerchantGold->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sSellerGold")->str);
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@ -108,6 +110,10 @@ namespace MWGui
|
||||||
|
|
||||||
setTitle(MWWorld::Class::get(actor).getName(actor));
|
setTitle(MWWorld::Class::get(actor).getName(actor));
|
||||||
adjustWindowCaption();
|
adjustWindowCaption();
|
||||||
|
|
||||||
|
mCurrentBalance = 0;
|
||||||
|
|
||||||
|
updateLabels();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TradeWindow::onFilterChanged(MyGUI::Widget* _sender)
|
void TradeWindow::onFilterChanged(MyGUI::Widget* _sender)
|
||||||
|
@ -145,4 +151,40 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
mWindowManager.setGuiMode(GM_Game);
|
mWindowManager.setGuiMode(GM_Game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TradeWindow::updateLabels()
|
||||||
|
{
|
||||||
|
mPlayerGold->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sYourGold")->str
|
||||||
|
+ " " + boost::lexical_cast<std::string>(mWindowManager.getInventoryWindow()->getPlayerGold()));
|
||||||
|
|
||||||
|
if (mCurrentBalance > 0)
|
||||||
|
{
|
||||||
|
mTotalBalanceLabel->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sTotalSold")->str);
|
||||||
|
mTotalBalance->setCaption(boost::lexical_cast<std::string>(mCurrentBalance));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mTotalBalanceLabel->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sTotalCost")->str);
|
||||||
|
mTotalBalance->setCaption(boost::lexical_cast<std::string>(-mCurrentBalance));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<MWWorld::Ptr> TradeWindow::getEquippedItems()
|
||||||
|
{
|
||||||
|
MWWorld::InventoryStore& invStore = static_cast<MWWorld::InventoryStore&>(MWWorld::Class::get(mContainer).getContainerStore(mContainer));
|
||||||
|
|
||||||
|
std::vector<MWWorld::Ptr> items;
|
||||||
|
|
||||||
|
for (int slot=0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
||||||
|
{
|
||||||
|
MWWorld::ContainerStoreIterator it = invStore.getSlot(slot);
|
||||||
|
if (it != invStore.end())
|
||||||
|
{
|
||||||
|
items.push_back(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,10 +50,18 @@ namespace MWGui
|
||||||
MyGUI::TextBox* mPlayerGold;
|
MyGUI::TextBox* mPlayerGold;
|
||||||
MyGUI::TextBox* mMerchantGold;
|
MyGUI::TextBox* mMerchantGold;
|
||||||
|
|
||||||
|
int mCurrentBalance;
|
||||||
|
|
||||||
void onWindowResize(MyGUI::Window* _sender);
|
void onWindowResize(MyGUI::Window* _sender);
|
||||||
void onFilterChanged(MyGUI::Widget* _sender);
|
void onFilterChanged(MyGUI::Widget* _sender);
|
||||||
void onOfferButtonClicked(MyGUI::Widget* _sender);
|
void onOfferButtonClicked(MyGUI::Widget* _sender);
|
||||||
void onCancelButtonClicked(MyGUI::Widget* _sender);
|
void onCancelButtonClicked(MyGUI::Widget* _sender);
|
||||||
|
|
||||||
|
// don't show items that the NPC has equipped in his trade-window.
|
||||||
|
virtual bool ignoreEquippedItems() { return true; }
|
||||||
|
virtual std::vector<MWWorld::Ptr> getEquippedItems();
|
||||||
|
|
||||||
|
void updateLabels();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,10 +108,10 @@ WindowManager::WindowManager(
|
||||||
console = new Console(w,h, extensions);
|
console = new Console(w,h, extensions);
|
||||||
mJournal = new JournalWindow(*this);
|
mJournal = new JournalWindow(*this);
|
||||||
mMessageBoxManager = new MessageBoxManager(this);
|
mMessageBoxManager = new MessageBoxManager(this);
|
||||||
|
mInventoryWindow = new InventoryWindow(*this,mDragAndDrop);
|
||||||
mTradeWindow = new TradeWindow(*this);
|
mTradeWindow = new TradeWindow(*this);
|
||||||
mDialogueWindow = new DialogueWindow(*this);
|
mDialogueWindow = new DialogueWindow(*this);
|
||||||
mContainerWindow = new ContainerWindow(*this,mDragAndDrop);
|
mContainerWindow = new ContainerWindow(*this,mDragAndDrop);
|
||||||
mInventoryWindow = new InventoryWindow(*this,mDragAndDrop);
|
|
||||||
hud = new HUD(w,h, showFPSLevel, mDragAndDrop);
|
hud = new HUD(w,h, showFPSLevel, mDragAndDrop);
|
||||||
mToolTips = new ToolTips(this);
|
mToolTips = new ToolTips(this);
|
||||||
mScrollWindow = new ScrollWindow(*this);
|
mScrollWindow = new ScrollWindow(*this);
|
||||||
|
|
|
@ -22,10 +22,10 @@
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
<Widget type="Widget" skin="" position="8 231 566 92" name="BottomPane" align="Left Bottom HStretch">
|
<Widget type="Widget" skin="" position="8 231 566 92" name="BottomPane" align="Left Bottom HStretch">
|
||||||
<Widget type="TextBox" skin="SandText" position="292 0 274 24" name="PlayerGold" align="Left Top HStretch">
|
<Widget type="TextBox" skin="SandText" position="192 0 374 24" name="PlayerGold" align="Left Top HStretch">
|
||||||
<Property key="TextAlign" value="Right"/>
|
<Property key="TextAlign" value="Right"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
<Widget type="TextBox" skin="SandText" position="292 28 274 24" name="MerchantGold" align="Left Top HStretch">
|
<Widget type="TextBox" skin="SandText" position="192 28 374 24" name="MerchantGold" align="Left Top HStretch">
|
||||||
<Property key="TextAlign" value="Right"/>
|
<Property key="TextAlign" value="Right"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue