mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-01 10:45:33 +00:00
add the sound for item drag&drop
This commit is contained in:
parent
722af60337
commit
a31a9e51d3
2 changed files with 24 additions and 11 deletions
|
@ -138,11 +138,18 @@ namespace MWClass
|
|||
ptr.get<ESM::Miscellaneous>();
|
||||
|
||||
MWGui::ToolTipInfo info;
|
||||
info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
|
||||
info.icon = ref->base->icon;
|
||||
|
||||
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||
|
||||
int count = ptr.getRefData().getCount();
|
||||
// gold has count both as reference count and as value, multiply them together to get real count
|
||||
bool isGold = (ref->base->name == store.gameSettings.search("sGold")->str);
|
||||
if (isGold)
|
||||
count *= ref->base->data.value;
|
||||
|
||||
info.caption = ref->base->name + MWGui::ToolTips::getCountString(count);
|
||||
info.icon = ref->base->icon;
|
||||
|
||||
if (ref->ref.soul != "")
|
||||
{
|
||||
const ESM::Creature *creature = store.creatures.search(ref->ref.soul);
|
||||
|
@ -151,9 +158,7 @@ namespace MWClass
|
|||
|
||||
std::string text;
|
||||
|
||||
if (ref->base->name == store.gameSettings.search("sGold")->str)
|
||||
info.caption += " (" + boost::lexical_cast<std::string>(ref->base->data.value) + ")";
|
||||
else
|
||||
if (!isGold)
|
||||
{
|
||||
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
|
||||
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "../mwworld/player.hpp"
|
||||
#include "../mwclass/container.hpp"
|
||||
#include "../mwinput/inputmanager.hpp"
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
@ -53,34 +54,41 @@ void ContainerBase::onSelectedItem(MyGUI::Widget* _sender)
|
|||
|
||||
int count = 0;
|
||||
MWWorld::ContainerStore& containerStore = MWWorld::Class::get(mContainer).getContainerStore(mContainer);
|
||||
MWWorld::Ptr object;
|
||||
for (MWWorld::ContainerStoreIterator iter (containerStore.begin()); iter!=containerStore.end(); ++iter)
|
||||
{
|
||||
count++;
|
||||
if(count == item->mPos)
|
||||
{
|
||||
mDragAndDrop->mStore.add(*iter);
|
||||
object = *iter;
|
||||
iter->getRefData().setCount(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//containerStore.
|
||||
//std::cout << mContainerWidget->getParent()->getParent()->getName();
|
||||
|
||||
std::string sound = MWWorld::Class::get(object).getUpSoundId(object);
|
||||
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
||||
|
||||
_sender->setUserString("drag","on");
|
||||
mDragAndDrop->mDraggedWidget = _sender;
|
||||
mDragAndDrop->mContainerWindow = const_cast<MWGui::ContainerBase*>(this);
|
||||
drawItems();
|
||||
std::cout << "selected!";
|
||||
}
|
||||
}
|
||||
|
||||
void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
std::cout << "container clicked";
|
||||
if(mDragAndDrop->mIsOnDragAndDrop) //drop widget here
|
||||
{
|
||||
ItemWidget* item = static_cast<ItemWidget*>(mDragAndDrop->mDraggedWidget);
|
||||
std::cout << item->mPos << (*mDragAndDrop->mStore.begin()).getTypeName();
|
||||
if((*item->getUserData<MWWorld::Ptr>()).getContainerStore() == 0) std::cout << "nocontainer!";
|
||||
|
||||
MWWorld::Ptr object = *item->getUserData<MWWorld::Ptr>();
|
||||
assert(object.getContainerStore() && "Item is not in a container!");
|
||||
|
||||
std::string sound = MWWorld::Class::get(object).getDownSoundId(object);
|
||||
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
|
||||
|
||||
MWWorld::ContainerStore& containerStore = MWWorld::Class::get(mContainer).getContainerStore(mContainer);
|
||||
containerStore.add(*mDragAndDrop->mStore.begin());
|
||||
mDragAndDrop->mStore.clear();
|
||||
|
|
Loading…
Reference in a new issue