1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-12 04:14:05 +00:00

Fix a few gold conditions that I missed, trade window was affected

This commit is contained in:
scrawl 2013-03-30 18:29:21 +01:00
parent a723ad8f29
commit 0f0cc0e3e3
3 changed files with 25 additions and 26 deletions

View File

@ -23,6 +23,18 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
namespace
{
bool isGold (const MWWorld::Ptr& ptr)
{
return Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_001")
|| Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_005")
|| Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_010")
|| Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_025")
|| Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_100");
}
}
namespace MWClass namespace MWClass
{ {
void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -109,25 +121,15 @@ namespace MWClass
std::string Miscellaneous::getUpSoundId (const MWWorld::Ptr& ptr) const std::string Miscellaneous::getUpSoundId (const MWWorld::Ptr& ptr) const
{ {
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = if (isGold(ptr))
ptr.get<ESM::Miscellaneous>();
if (ref->mBase->mName == MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sGold")->getString())
{
return std::string("Item Gold Up"); return std::string("Item Gold Up");
}
return std::string("Item Misc Up"); return std::string("Item Misc Up");
} }
std::string Miscellaneous::getDownSoundId (const MWWorld::Ptr& ptr) const std::string Miscellaneous::getDownSoundId (const MWWorld::Ptr& ptr) const
{ {
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = if (isGold(ptr))
ptr.get<ESM::Miscellaneous>();
if (ref->mBase->mName == MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sGold")->getString())
{
return std::string("Item Gold Down"); return std::string("Item Gold Down");
}
return std::string("Item Misc Down"); return std::string("Item Misc Down");
} }
@ -158,19 +160,15 @@ namespace MWClass
int count = ptr.getRefData().getCount(); int count = ptr.getRefData().getCount();
bool isGold = Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_001") bool gold = isGold(ptr);
|| Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_005")
|| Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_010")
|| Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_025")
|| Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_100");
if (isGold && ptr.getCellRef().mGoldValue != 1) if (gold && ptr.getCellRef().mGoldValue != 1)
count = ptr.getCellRef().mGoldValue; count = ptr.getCellRef().mGoldValue;
else if (isGold) else if (gold)
count *= ref->mBase->mData.mValue; count *= ref->mBase->mData.mValue;
std::string countString; std::string countString;
if (!isGold) if (!gold)
countString = MWGui::ToolTips::getCountString(count); countString = MWGui::ToolTips::getCountString(count);
else // gold displays its count also if it's 1. else // gold displays its count also if it's 1.
countString = " (" + boost::lexical_cast<std::string>(count) + ")"; countString = " (" + boost::lexical_cast<std::string>(count) + ")";
@ -186,7 +184,7 @@ namespace MWClass
std::string text; std::string text;
if (!isGold) if (!gold)
{ {
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}"); text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
@ -210,7 +208,7 @@ namespace MWClass
const MWWorld::ESMStore &store = const MWWorld::ESMStore &store =
MWBase::Environment::get().getWorld()->getStore(); MWBase::Environment::get().getWorld()->getStore();
if (MWWorld::Class::get(ptr).getName(ptr) == store.get<ESM::GameSetting>().find("sGold")->getString()) { if (isGold(ptr)) {
int goldAmount = ptr.getRefData().getCount(); int goldAmount = ptr.getRefData().getCount();
std::string base = "Gold_001"; std::string base = "Gold_001";

View File

@ -144,9 +144,7 @@ void ContainerBase::onSelectedItem(MyGUI::Widget* _sender)
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
// the player is trying to sell an item, check if the merchant accepts it // the player is trying to sell an item, check if the merchant accepts it
// also, don't allow selling gold (let's be better than Morrowind at this, can we?) if (!MWBase::Environment::get().getWindowManager()->getTradeWindow()->npcAcceptsItem(object))
if (!MWBase::Environment::get().getWindowManager()->getTradeWindow()->npcAcceptsItem(object) ||
MWWorld::Class::get(object).getName(object) == gmst.find("sGold")->getString())
{ {
// user notification "i don't buy this item" // user notification "i don't buy this item"
MWBase::Environment::get().getWindowManager()-> MWBase::Environment::get().getWindowManager()->

View File

@ -135,7 +135,7 @@ namespace MWGui
for (MWWorld::ContainerStoreIterator it = playerStore.begin(); for (MWWorld::ContainerStoreIterator it = playerStore.begin();
it != playerStore.end(); ++it) it != playerStore.end(); ++it)
{ {
if (MWWorld::Class::get(*it).getName(*it) == gmst.find("sGold")->getString()) if (Misc::StringUtils::ciEqual(it->getCellRef().mRefID, "gold_001"))
{ {
goldFound = true; goldFound = true;
gold = *it; gold = *it;
@ -342,6 +342,9 @@ namespace MWGui
bool TradeWindow::npcAcceptsItem(MWWorld::Ptr item) bool TradeWindow::npcAcceptsItem(MWWorld::Ptr item)
{ {
if (Misc::StringUtils::ciEqual(item.getCellRef().mRefID, "gold_001"))
return false;
int services = 0; int services = 0;
if (mPtr.getTypeName() == typeid(ESM::NPC).name()) if (mPtr.getTypeName() == typeid(ESM::NPC).name())
{ {