Added "dispose corpse" button, added stealing (all items visible and no penalty yet)

actorid
scrawl 12 years ago
parent e34685b8a3
commit 0ee0dbdb97

@ -132,7 +132,7 @@ namespace MWClass
const MWWorld::Ptr& actor) const const MWWorld::Ptr& actor) const
{ {
if (MWWorld::Class::get (ptr).getCreatureStats (ptr).isDead()) if (MWWorld::Class::get (ptr).getCreatureStats (ptr).isDead())
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionOpen(ptr)); return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionOpen(ptr, true));
else else
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr)); return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr));
} }

@ -220,7 +220,9 @@ namespace MWClass
const MWWorld::Ptr& actor) const const MWWorld::Ptr& actor) const
{ {
if (MWWorld::Class::get (ptr).getCreatureStats (ptr).isDead()) if (MWWorld::Class::get (ptr).getCreatureStats (ptr).isDead())
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionOpen(ptr)); return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionOpen(ptr, true));
else if (MWWorld::Class::get(actor).getStance(actor, MWWorld::Class::Sneak))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionOpen(ptr)); // stealing
else else
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr)); return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr));
} }

@ -15,6 +15,7 @@
#include "../mwworld/manualref.hpp" #include "../mwworld/manualref.hpp"
#include "../mwworld/containerstore.hpp" #include "../mwworld/containerstore.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
@ -70,9 +71,11 @@ namespace
} }
ContainerBase::ContainerBase(DragAndDrop* dragAndDrop) : ContainerBase::ContainerBase(DragAndDrop* dragAndDrop)
mDragAndDrop(dragAndDrop), : mDragAndDrop(dragAndDrop)
mFilter(ContainerBase::Filter_All) , mFilter(ContainerBase::Filter_All)
, mDisplayEquippedItems(true)
, mHighlightEquippedItems(true)
{ {
} }
@ -313,7 +316,6 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
{ {
object.getRefData().setCount(origCount - mDragAndDrop->mDraggedCount); object.getRefData().setCount(origCount - mDragAndDrop->mDraggedCount);
} }
std::cout << "container weight " << curWeight << "/" << capacity << std::endl;
} }
else else
{ {
@ -430,7 +432,7 @@ 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)
if (!ignoreEquippedItems()) if (mDisplayEquippedItems && mHighlightEquippedItems)
{ {
for (std::vector<MWWorld::Ptr>::const_iterator it=equippedItems.begin(); for (std::vector<MWWorld::Ptr>::const_iterator it=equippedItems.begin();
it != equippedItems.end(); ++it) it != equippedItems.end(); ++it)
@ -445,7 +447,8 @@ void ContainerBase::drawItems()
std::vector<MWWorld::Ptr> regularItems; std::vector<MWWorld::Ptr> regularItems;
for (MWWorld::ContainerStoreIterator iter (containerStore.begin(categories)); iter!=containerStore.end(); ++iter) for (MWWorld::ContainerStoreIterator iter (containerStore.begin(categories)); iter!=containerStore.end(); ++iter)
{ {
if (std::find(equippedItems.begin(), equippedItems.end(), *iter) == equippedItems.end() if ( (std::find(equippedItems.begin(), equippedItems.end(), *iter) == equippedItems.end()
|| (!mHighlightEquippedItems && mDisplayEquippedItems))
&& std::find(ignoreItems.begin(), ignoreItems.end(), *iter) == ignoreItems.end() && std::find(ignoreItems.begin(), ignoreItems.end(), *iter) == ignoreItems.end()
&& std::find(mBoughtItems.begin(), mBoughtItems.end(), *iter) == mBoughtItems.end()) && std::find(mBoughtItems.begin(), mBoughtItems.end(), *iter) == mBoughtItems.end())
regularItems.push_back(*iter); regularItems.push_back(*iter);
@ -587,6 +590,27 @@ void ContainerBase::returnBoughtItems(MWWorld::ContainerStore& store)
} }
} }
std::vector<MWWorld::Ptr> ContainerBase::getEquippedItems()
{
if (mPtr.getTypeName() != typeid(ESM::NPC).name())
return std::vector<MWWorld::Ptr>();
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
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;
}
MWWorld::ContainerStore& ContainerBase::getContainerStore() MWWorld::ContainerStore& ContainerBase::getContainerStore()
{ {
MWWorld::ContainerStore& store = MWWorld::Class::get(mPtr).getContainerStore(mPtr); MWWorld::ContainerStore& store = MWWorld::Class::get(mPtr).getContainerStore(mPtr);
@ -599,6 +623,7 @@ ContainerWindow::ContainerWindow(MWBase::WindowManager& parWindowManager,DragAnd
: ContainerBase(dragAndDrop) : ContainerBase(dragAndDrop)
, WindowBase("openmw_container_window.layout", parWindowManager) , WindowBase("openmw_container_window.layout", parWindowManager)
{ {
getWidget(mDisposeCorpseButton, "DisposeCorpseButton");
getWidget(mTakeButton, "TakeButton"); getWidget(mTakeButton, "TakeButton");
getWidget(mCloseButton, "CloseButton"); getWidget(mCloseButton, "CloseButton");
@ -608,6 +633,7 @@ ContainerWindow::ContainerWindow(MWBase::WindowManager& parWindowManager,DragAnd
getWidget(itemView, "ItemView"); getWidget(itemView, "ItemView");
setWidgets(containerWidget, itemView); setWidgets(containerWidget, itemView);
mDisposeCorpseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onDisposeCorpseButtonClicked);
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onCloseButtonClicked); mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onCloseButtonClicked);
mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onTakeAllButtonClicked); mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onTakeAllButtonClicked);
@ -625,8 +651,18 @@ void ContainerWindow::onWindowResize(MyGUI::Window* window)
drawItems(); drawItems();
} }
void ContainerWindow::open(MWWorld::Ptr container) void ContainerWindow::open(MWWorld::Ptr container, bool loot)
{
mDisplayEquippedItems = true;
mHighlightEquippedItems = false;
if (container.getTypeName() == typeid(ESM::NPC).name() && !loot)
{ {
// we are stealing stuff
mDisplayEquippedItems = false;
}
mDisposeCorpseButton->setVisible(loot);
openContainer(container); openContainer(container);
setTitle(MWWorld::Class::get(container).getName(container)); setTitle(MWWorld::Class::get(container).getName(container));
drawItems(); drawItems();
@ -671,6 +707,22 @@ void ContainerWindow::onTakeAllButtonClicked(MyGUI::Widget* _sender)
} }
} }
void ContainerWindow::onDisposeCorpseButtonClicked(MyGUI::Widget *sender)
{
if(mDragAndDrop == NULL || !mDragAndDrop->mIsOnDragAndDrop)
{
onTakeAllButtonClicked(mTakeButton);
/// \todo I don't think this is the correct flag to check
if (MWWorld::Class::get(mPtr).isEssential(mPtr))
mWindowManager.messageBox("#{sDisposeCorpseFail}");
else
MWBase::Environment::get().getWorld()->deleteObject(mPtr);
mPtr = MWWorld::Ptr();
}
}
void ContainerWindow::onReferenceUnavailable() void ContainerWindow::onReferenceUnavailable()
{ {
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container);

@ -82,6 +82,9 @@ namespace MWGui
void drawItems(); void drawItems();
protected: protected:
bool mDisplayEquippedItems;
bool mHighlightEquippedItems;
MyGUI::ScrollView* mItemView; MyGUI::ScrollView* mItemView;
MyGUI::Widget* mContainerWidget; MyGUI::Widget* mContainerWidget;
@ -111,14 +114,13 @@ namespace MWGui
virtual bool isTradeWindow() { return false; } virtual bool isTradeWindow() { return false; }
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();
virtual void _unequipItem(MWWorld::Ptr item) { ; } virtual void _unequipItem(MWWorld::Ptr item) { ; }
virtual bool isTrading() { return false; } virtual bool isTrading() { return false; }
virtual void onSelectedItemImpl(MWWorld::Ptr item) { ; } virtual void onSelectedItemImpl(MWWorld::Ptr item) { ; }
virtual bool ignoreEquippedItems() { return false; }
virtual std::vector<MWWorld::Ptr> itemsToIgnore() { return std::vector<MWWorld::Ptr>(); } virtual std::vector<MWWorld::Ptr> itemsToIgnore() { return std::vector<MWWorld::Ptr>(); }
virtual void notifyContentChanged() { ; } virtual void notifyContentChanged() { ; }
@ -131,15 +133,17 @@ namespace MWGui
virtual ~ContainerWindow(); virtual ~ContainerWindow();
void open(MWWorld::Ptr container); void open(MWWorld::Ptr container, bool loot=false);
protected: protected:
MyGUI::Button* mDisposeCorpseButton;
MyGUI::Button* mTakeButton; MyGUI::Button* mTakeButton;
MyGUI::Button* mCloseButton; MyGUI::Button* mCloseButton;
void onWindowResize(MyGUI::Window* window); void onWindowResize(MyGUI::Window* window);
void onCloseButtonClicked(MyGUI::Widget* _sender); void onCloseButtonClicked(MyGUI::Widget* _sender);
void onTakeAllButtonClicked(MyGUI::Widget* _sender); void onTakeAllButtonClicked(MyGUI::Widget* _sender);
void onDisposeCorpseButtonClicked(MyGUI::Widget* sender);
virtual void onReferenceUnavailable(); virtual void onReferenceUnavailable();
}; };

@ -211,24 +211,6 @@ namespace MWGui
return MWWorld::Ptr(); return MWWorld::Ptr();
} }
std::vector<MWWorld::Ptr> InventoryWindow::getEquippedItems()
{
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
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;
}
void InventoryWindow::_unequipItem(MWWorld::Ptr item) void InventoryWindow::_unequipItem(MWWorld::Ptr item)
{ {
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr); MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);

@ -64,7 +64,6 @@ namespace MWGui
virtual bool isTrading() { return mTrading; } virtual bool isTrading() { return mTrading; }
virtual bool isInventory() { return true; } virtual bool isInventory() { return true; }
virtual std::vector<MWWorld::Ptr> getEquippedItems();
virtual void _unequipItem(MWWorld::Ptr item); virtual void _unequipItem(MWWorld::Ptr item);
virtual void onReferenceUnavailable() { ; } virtual void onReferenceUnavailable() { ; }

@ -31,6 +31,9 @@ namespace MWGui
, mBalanceButtonsState(BBS_None) , mBalanceButtonsState(BBS_None)
, mBalanceChangePause(0.0) , mBalanceChangePause(0.0)
{ {
// items the NPC is wearing should not be for trade
mDisplayEquippedItems = true;
MyGUI::ScrollView* itemView; MyGUI::ScrollView* itemView;
MyGUI::Widget* containerWidget; MyGUI::Widget* containerWidget;
getWidget(containerWidget, "Items"); getWidget(containerWidget, "Items");
@ -337,30 +340,6 @@ namespace MWGui
mMerchantGold->setCaptionWithReplacing("#{sSellerGold} " + boost::lexical_cast<std::string>(getMerchantGold())); mMerchantGold->setCaptionWithReplacing("#{sSellerGold} " + boost::lexical_cast<std::string>(getMerchantGold()));
} }
std::vector<MWWorld::Ptr> TradeWindow::getEquippedItems()
{
std::vector<MWWorld::Ptr> items;
if (mPtr.getTypeName() == typeid(ESM::Creature).name())
{
// creatures don't have equipment slots.
return items;
}
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
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;
}
bool TradeWindow::npcAcceptsItem(MWWorld::Ptr item) bool TradeWindow::npcAcceptsItem(MWWorld::Ptr item)
{ {
int services = 0; int services = 0;

@ -82,10 +82,6 @@ namespace MWGui
void onIncreaseButtonTriggered(); void onIncreaseButtonTriggered();
void onDecreaseButtonTriggered(); void onDecreaseButtonTriggered();
// don't show items that the NPC has equipped in his trade-window.
virtual bool ignoreEquippedItems() { return true; }
virtual std::vector<MWWorld::Ptr> getEquippedItems();
virtual bool isTrading() { return true; } virtual bool isTrading() { return true; }
virtual bool isTradeWindow() { return true; } virtual bool isTradeWindow() { return true; }

@ -10,7 +10,9 @@
namespace MWWorld namespace MWWorld
{ {
ActionOpen::ActionOpen (const MWWorld::Ptr& container) : Action (false, container) ActionOpen::ActionOpen (const MWWorld::Ptr& container, bool loot)
: Action (false, container)
, mLoot(loot)
{ {
} }
@ -20,6 +22,6 @@ namespace MWWorld
return; return;
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Container); MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Container);
MWBase::Environment::get().getWindowManager()->getContainerWindow()->open(getTarget()); MWBase::Environment::get().getWindowManager()->getContainerWindow()->open(getTarget(), mLoot);
} }
} }

@ -13,8 +13,12 @@ namespace MWWorld
virtual void executeImp (const MWWorld::Ptr& actor); virtual void executeImp (const MWWorld::Ptr& actor);
public: public:
ActionOpen (const Ptr& container); ActionOpen (const Ptr& container, bool loot=false);
///< \param The Container the Player has activated. ///< \param container The Container the Player has activated.
/// \param loot If true, display the "dispose of corpse" button
private:
bool mLoot;
}; };
} }

@ -15,6 +15,10 @@
<Widget type="Widget"> <Widget type="Widget">
<UserString key="HStretch" value="true"/> <UserString key="HStretch" value="true"/>
</Widget> </Widget>
<Widget type="AutoSizedButton" skin="MW_Button" name="DisposeCorpseButton" align="Right Bottom">
<Property key="Caption" value="#{sDisposeofCorpse}"/>
<Property key="Visible" value="false"/>
</Widget>
<Widget type="AutoSizedButton" skin="MW_Button" name="TakeButton" align="Right Bottom"> <Widget type="AutoSizedButton" skin="MW_Button" name="TakeButton" align="Right Bottom">
<Property key="Caption" value="#{sTakeAll}"/> <Property key="Caption" value="#{sTakeAll}"/>
</Widget> </Widget>

Loading…
Cancel
Save