mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-28 20:06:41 +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>();
|
ptr.get<ESM::Miscellaneous>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
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();
|
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 != "")
|
if (ref->ref.soul != "")
|
||||||
{
|
{
|
||||||
const ESM::Creature *creature = store.creatures.search(ref->ref.soul);
|
const ESM::Creature *creature = store.creatures.search(ref->ref.soul);
|
||||||
|
@ -151,9 +158,7 @@ namespace MWClass
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
|
|
||||||
if (ref->base->name == store.gameSettings.search("sGold")->str)
|
if (!isGold)
|
||||||
info.caption += " (" + boost::lexical_cast<std::string>(ref->base->data.value) + ")";
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
|
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);
|
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
#include "../mwclass/container.hpp"
|
#include "../mwclass/container.hpp"
|
||||||
#include "../mwinput/inputmanager.hpp"
|
#include "../mwinput/inputmanager.hpp"
|
||||||
|
#include "../mwsound/soundmanager.hpp"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -53,34 +54,41 @@ void ContainerBase::onSelectedItem(MyGUI::Widget* _sender)
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
MWWorld::ContainerStore& containerStore = MWWorld::Class::get(mContainer).getContainerStore(mContainer);
|
MWWorld::ContainerStore& containerStore = MWWorld::Class::get(mContainer).getContainerStore(mContainer);
|
||||||
|
MWWorld::Ptr object;
|
||||||
for (MWWorld::ContainerStoreIterator iter (containerStore.begin()); iter!=containerStore.end(); ++iter)
|
for (MWWorld::ContainerStoreIterator iter (containerStore.begin()); iter!=containerStore.end(); ++iter)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
if(count == item->mPos)
|
if(count == item->mPos)
|
||||||
{
|
{
|
||||||
mDragAndDrop->mStore.add(*iter);
|
mDragAndDrop->mStore.add(*iter);
|
||||||
|
object = *iter;
|
||||||
iter->getRefData().setCount(0);
|
iter->getRefData().setCount(0);
|
||||||
break;
|
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");
|
_sender->setUserString("drag","on");
|
||||||
mDragAndDrop->mDraggedWidget = _sender;
|
mDragAndDrop->mDraggedWidget = _sender;
|
||||||
mDragAndDrop->mContainerWindow = const_cast<MWGui::ContainerBase*>(this);
|
mDragAndDrop->mContainerWindow = const_cast<MWGui::ContainerBase*>(this);
|
||||||
drawItems();
|
drawItems();
|
||||||
std::cout << "selected!";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
|
void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
std::cout << "container clicked";
|
|
||||||
if(mDragAndDrop->mIsOnDragAndDrop) //drop widget here
|
if(mDragAndDrop->mIsOnDragAndDrop) //drop widget here
|
||||||
{
|
{
|
||||||
ItemWidget* item = static_cast<ItemWidget*>(mDragAndDrop->mDraggedWidget);
|
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);
|
MWWorld::ContainerStore& containerStore = MWWorld::Class::get(mContainer).getContainerStore(mContainer);
|
||||||
containerStore.add(*mDragAndDrop->mStore.begin());
|
containerStore.add(*mDragAndDrop->mStore.begin());
|
||||||
mDragAndDrop->mStore.clear();
|
mDragAndDrop->mStore.clear();
|
||||||
|
|
Loading…
Reference in a new issue