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
{
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
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr));
}

@ -220,7 +220,9 @@ namespace MWClass
const MWWorld::Ptr& actor) const
{
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
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr));
}

@ -15,6 +15,7 @@
#include "../mwworld/manualref.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/player.hpp"
@ -70,9 +71,11 @@ namespace
}
ContainerBase::ContainerBase(DragAndDrop* dragAndDrop) :
mDragAndDrop(dragAndDrop),
mFilter(ContainerBase::Filter_All)
ContainerBase::ContainerBase(DragAndDrop* dragAndDrop)
: mDragAndDrop(dragAndDrop)
, mFilter(ContainerBase::Filter_All)
, mDisplayEquippedItems(true)
, mHighlightEquippedItems(true)
{
}
@ -313,7 +316,6 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
{
object.getRefData().setCount(origCount - mDragAndDrop->mDraggedCount);
}
std::cout << "container weight " << curWeight << "/" << capacity << std::endl;
}
else
{
@ -430,7 +432,7 @@ void ContainerBase::drawItems()
equippedItems.erase(found);
}
// 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();
it != equippedItems.end(); ++it)
@ -445,7 +447,8 @@ void ContainerBase::drawItems()
std::vector<MWWorld::Ptr> regularItems;
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(mBoughtItems.begin(), mBoughtItems.end(), *iter) == mBoughtItems.end())
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& store = MWWorld::Class::get(mPtr).getContainerStore(mPtr);
@ -599,6 +623,7 @@ ContainerWindow::ContainerWindow(MWBase::WindowManager& parWindowManager,DragAnd
: ContainerBase(dragAndDrop)
, WindowBase("openmw_container_window.layout", parWindowManager)
{
getWidget(mDisposeCorpseButton, "DisposeCorpseButton");
getWidget(mTakeButton, "TakeButton");
getWidget(mCloseButton, "CloseButton");
@ -608,6 +633,7 @@ ContainerWindow::ContainerWindow(MWBase::WindowManager& parWindowManager,DragAnd
getWidget(itemView, "ItemView");
setWidgets(containerWidget, itemView);
mDisposeCorpseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onDisposeCorpseButtonClicked);
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onCloseButtonClicked);
mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onTakeAllButtonClicked);
@ -625,8 +651,18 @@ void ContainerWindow::onWindowResize(MyGUI::Window* window)
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);
setTitle(MWWorld::Class::get(container).getName(container));
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()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container);

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

@ -211,24 +211,6 @@ namespace MWGui
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)
{
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);

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

@ -31,6 +31,9 @@ namespace MWGui
, mBalanceButtonsState(BBS_None)
, mBalanceChangePause(0.0)
{
// items the NPC is wearing should not be for trade
mDisplayEquippedItems = true;
MyGUI::ScrollView* itemView;
MyGUI::Widget* containerWidget;
getWidget(containerWidget, "Items");
@ -337,30 +340,6 @@ namespace MWGui
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)
{
int services = 0;

@ -82,10 +82,6 @@ namespace MWGui
void onIncreaseButtonTriggered();
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 isTradeWindow() { return true; }

@ -10,7 +10,9 @@
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;
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);
public:
ActionOpen (const Ptr& container);
///< \param The Container the Player has activated.
ActionOpen (const Ptr& container, bool loot=false);
///< \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">
<UserString key="HStretch" value="true"/>
</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">
<Property key="Caption" value="#{sTakeAll}"/>
</Widget>

Loading…
Cancel
Save