forked from teamnwah/openmw-tes3coop
Merge pull request #306 from OpenMW/master
Add OpenMW commits up to 7 Oct 2017
This commit is contained in:
commit
3e8d7c8416
7 changed files with 40 additions and 28 deletions
|
@ -692,32 +692,23 @@ namespace CSMWorld
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \todo QColor is a GUI class and should not be in model. Need to think of an alternative
|
|
||||||
/// solution.
|
|
||||||
template<typename ESXRecordT>
|
template<typename ESXRecordT>
|
||||||
struct MapColourColumn : public Column<ESXRecordT>
|
struct MapColourColumn : public Column<ESXRecordT>
|
||||||
{
|
{
|
||||||
/// \todo Replace Display_Integer with something that displays the colour value more directly.
|
|
||||||
MapColourColumn()
|
MapColourColumn()
|
||||||
: Column<ESXRecordT> (Columns::ColumnId_MapColour, ColumnBase::Display_Colour)
|
: Column<ESXRecordT> (Columns::ColumnId_MapColour, ColumnBase::Display_Colour)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||||
{
|
{
|
||||||
int colour = record.get().mMapColor;
|
return record.get().mMapColor;
|
||||||
|
|
||||||
return QColor (colour & 0xff, (colour>>8) & 0xff, (colour>>16) & 0xff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
||||||
{
|
{
|
||||||
ESXRecordT record2 = record.get();
|
ESXRecordT copy = record.get();
|
||||||
|
copy.mMapColor = data.toInt();
|
||||||
QColor colour = data.value<QColor>();
|
record.setModified (copy);
|
||||||
|
|
||||||
record2.mMapColor = (colour.blue() << 16) | (colour.green() << 8) | colour.red();
|
|
||||||
|
|
||||||
record.setModified (record2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isEditable() const
|
virtual bool isEditable() const
|
||||||
|
|
|
@ -5,29 +5,32 @@
|
||||||
|
|
||||||
#include "../widget/coloreditor.hpp"
|
#include "../widget/coloreditor.hpp"
|
||||||
|
|
||||||
CSVWorld::ColorDelegate::ColorDelegate(CSMWorld::CommandDispatcher *dispatcher,
|
CSVWorld::ColorDelegate::ColorDelegate(CSMWorld::CommandDispatcher *dispatcher,
|
||||||
CSMDoc::Document& document,
|
CSMDoc::Document& document,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: CommandDelegate(dispatcher, document, parent)
|
: CommandDelegate(dispatcher, document, parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void CSVWorld::ColorDelegate::paint(QPainter *painter,
|
void CSVWorld::ColorDelegate::paint(QPainter *painter,
|
||||||
const QStyleOptionViewItem &option,
|
const QStyleOptionViewItem &option,
|
||||||
const QModelIndex &index) const
|
const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
|
int colorInt = index.data().toInt();
|
||||||
|
QColor color(colorInt & 0xff, (colorInt >> 8) & 0xff, (colorInt >> 16) & 0xff);
|
||||||
|
|
||||||
QRect coloredRect(option.rect.x() + qRound(option.rect.width() / 4.0),
|
QRect coloredRect(option.rect.x() + qRound(option.rect.width() / 4.0),
|
||||||
option.rect.y() + qRound(option.rect.height() / 4.0),
|
option.rect.y() + qRound(option.rect.height() / 4.0),
|
||||||
option.rect.width() / 2,
|
option.rect.width() / 2,
|
||||||
option.rect.height() / 2);
|
option.rect.height() / 2);
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->fillRect(coloredRect, index.data().value<QColor>());
|
painter->fillRect(coloredRect, color);
|
||||||
painter->setPen(Qt::black);
|
painter->setPen(Qt::black);
|
||||||
painter->drawRect(coloredRect);
|
painter->drawRect(coloredRect);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWorld::CommandDelegate *CSVWorld::ColorDelegateFactory::makeDelegate(CSMWorld::CommandDispatcher *dispatcher,
|
CSVWorld::CommandDelegate *CSVWorld::ColorDelegateFactory::makeDelegate(CSMWorld::CommandDispatcher *dispatcher,
|
||||||
CSMDoc::Document &document,
|
CSMDoc::Document &document,
|
||||||
QObject *parent) const
|
QObject *parent) const
|
||||||
{
|
{
|
||||||
return new ColorDelegate(dispatcher, document, parent);
|
return new ColorDelegate(dispatcher, document, parent);
|
||||||
|
|
|
@ -191,8 +191,7 @@ namespace MWGui
|
||||||
else if (type == "ItemPtr")
|
else if (type == "ItemPtr")
|
||||||
{
|
{
|
||||||
mFocusObject = *focus->getUserData<MWWorld::Ptr>();
|
mFocusObject = *focus->getUserData<MWWorld::Ptr>();
|
||||||
bool isAllowedToUse = checkOwned();
|
tooltipSize = getToolTipViaPtr(mFocusObject.getRefData().getCount(), false, checkOwned());
|
||||||
tooltipSize = getToolTipViaPtr(mFocusObject.getRefData().getCount(), false, !isAllowedToUse);
|
|
||||||
}
|
}
|
||||||
else if (type == "ItemModelIndex")
|
else if (type == "ItemModelIndex")
|
||||||
{
|
{
|
||||||
|
|
|
@ -1775,9 +1775,10 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
if (!mCurrentModals.empty())
|
if (!mCurrentModals.empty())
|
||||||
{
|
{
|
||||||
if (!mCurrentModals.back()->exit())
|
WindowModal* window = mCurrentModals.back();
|
||||||
|
if (!window->exit())
|
||||||
return;
|
return;
|
||||||
mCurrentModals.back()->setVisible(false);
|
window->setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,11 +87,7 @@ void adjustBoundItem (const std::string& item, bool bound, const MWWorld::Ptr& a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
actor.getClass().getInventoryStore(actor).remove(item, 1, actor, true);
|
||||||
MWWorld::Ptr itemPtr = actor.getClass().getInventoryStore(actor).search(item);
|
|
||||||
if (!itemPtr.isEmpty())
|
|
||||||
actor.getClass().getInventoryStore(actor).remove(itemPtr, 1, actor, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CheckActorCommanded : public MWMechanics::EffectSourceVisitor
|
class CheckActorCommanded : public MWMechanics::EffectSourceVisitor
|
||||||
|
|
|
@ -678,11 +678,30 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSelectedEnchantItem(
|
||||||
return mSelectedEnchantItem;
|
return mSelectedEnchantItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MWWorld::InventoryStore::remove(const std::string& itemId, int count, const Ptr& actor)
|
||||||
|
{
|
||||||
|
return remove(itemId, count, actor, false);
|
||||||
|
}
|
||||||
|
|
||||||
int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor)
|
int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor)
|
||||||
{
|
{
|
||||||
return remove(item, count, actor, false);
|
return remove(item, count, actor, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MWWorld::InventoryStore::remove(const std::string& itemId, int count, const Ptr& actor, bool equipReplacement)
|
||||||
|
{
|
||||||
|
int toRemove = count;
|
||||||
|
|
||||||
|
for (ContainerStoreIterator iter(begin()); iter != end() && toRemove > 0; ++iter)
|
||||||
|
if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), itemId))
|
||||||
|
toRemove -= remove(*iter, toRemove, actor, equipReplacement);
|
||||||
|
|
||||||
|
flagAsModified();
|
||||||
|
|
||||||
|
// number of removed items
|
||||||
|
return count - toRemove;
|
||||||
|
}
|
||||||
|
|
||||||
int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor, bool equipReplacement)
|
int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor, bool equipReplacement)
|
||||||
{
|
{
|
||||||
int retCount = ContainerStore::remove(item, count, actor);
|
int retCount = ContainerStore::remove(item, count, actor);
|
||||||
|
|
|
@ -177,6 +177,9 @@ namespace MWWorld
|
||||||
virtual bool stacks (const ConstPtr& ptr1, const ConstPtr& ptr2) const;
|
virtual bool stacks (const ConstPtr& ptr1, const ConstPtr& ptr2) const;
|
||||||
///< @return true if the two specified objects can stack with each other
|
///< @return true if the two specified objects can stack with each other
|
||||||
|
|
||||||
|
virtual int remove(const std::string& itemId, int count, const Ptr& actor);
|
||||||
|
virtual int remove(const std::string& itemId, int count, const Ptr& actor, bool equipReplacement);
|
||||||
|
|
||||||
virtual int remove(const Ptr& item, int count, const Ptr& actor);
|
virtual int remove(const Ptr& item, int count, const Ptr& actor);
|
||||||
virtual int remove(const Ptr& item, int count, const Ptr& actor, bool equipReplacement);
|
virtual int remove(const Ptr& item, int count, const Ptr& actor, bool equipReplacement);
|
||||||
///< Remove \a count item(s) designated by \a item from this inventory.
|
///< Remove \a count item(s) designated by \a item from this inventory.
|
||||||
|
|
Loading…
Reference in a new issue