mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-02 02:41:35 +00:00
Feature: display different brush for land vs water
This commit is contained in:
parent
aa0c9fb4cb
commit
5fca45565c
2 changed files with 28 additions and 8 deletions
|
@ -1,7 +1,9 @@
|
||||||
#include "regionmap.hpp"
|
#include "regionmap.hpp"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
#include <QPalette>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
|
@ -21,20 +23,36 @@
|
||||||
#include "data.hpp"
|
#include "data.hpp"
|
||||||
#include "universalid.hpp"
|
#include "universalid.hpp"
|
||||||
|
|
||||||
|
namespace CSMWorld
|
||||||
|
{
|
||||||
|
float getLandHeight(const CSMWorld::Cell& cell, CSMWorld::Data& data)
|
||||||
|
{
|
||||||
|
const IdCollection<Land>& lands = data.getLand();
|
||||||
|
int landIndex = lands.searchId(cell.mId);
|
||||||
|
const Land& land = lands.getRecord(landIndex).get();
|
||||||
|
|
||||||
|
// If any part of land is above water, returns > 0 - otherwise returns < 0
|
||||||
|
if (land.getLandData())
|
||||||
|
return land.getLandData()->mMaxHeight - cell.mWater;
|
||||||
|
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CSMWorld::RegionMap::CellDescription::CellDescription()
|
CSMWorld::RegionMap::CellDescription::CellDescription()
|
||||||
: mDeleted(false)
|
: mDeleted(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::RegionMap::CellDescription::CellDescription(const Record<Cell>& cell)
|
CSMWorld::RegionMap::CellDescription::CellDescription(const Record<Cell>& cell, float landHeight)
|
||||||
{
|
{
|
||||||
const Cell& cell2 = cell.get();
|
const Cell& cell2 = cell.get();
|
||||||
|
|
||||||
if (!cell2.isExterior())
|
if (!cell2.isExterior())
|
||||||
throw std::logic_error("Interior cell in region map");
|
throw std::logic_error("Interior cell in region map");
|
||||||
|
|
||||||
|
mMaxLandHeight = landHeight;
|
||||||
mDeleted = cell.isDeleted();
|
mDeleted = cell.isDeleted();
|
||||||
|
|
||||||
mRegion = cell2.mRegion;
|
mRegion = cell2.mRegion;
|
||||||
mName = cell2.mName;
|
mName = cell2.mName;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +110,7 @@ void CSMWorld::RegionMap::buildMap()
|
||||||
|
|
||||||
if (cell2.isExterior())
|
if (cell2.isExterior())
|
||||||
{
|
{
|
||||||
CellDescription description(cell);
|
CellDescription description(cell, getLandHeight(cell2, mData));
|
||||||
|
|
||||||
CellCoordinates index = getIndex(cell2);
|
CellCoordinates index = getIndex(cell2);
|
||||||
|
|
||||||
|
@ -140,7 +158,7 @@ void CSMWorld::RegionMap::addCells(int start, int end)
|
||||||
{
|
{
|
||||||
CellCoordinates index = getIndex(cell2);
|
CellCoordinates index = getIndex(cell2);
|
||||||
|
|
||||||
CellDescription description(cell);
|
CellDescription description(cell, getLandHeight(cell.get(), mData));
|
||||||
|
|
||||||
addCell(index, description);
|
addCell(index, description);
|
||||||
}
|
}
|
||||||
|
@ -335,10 +353,11 @@ QVariant CSMWorld::RegionMap::data(const QModelIndex& index, int role) const
|
||||||
auto iter = mColours.find(cell->second.mRegion);
|
auto iter = mColours.find(cell->second.mRegion);
|
||||||
|
|
||||||
if (iter != mColours.end())
|
if (iter != mColours.end())
|
||||||
return QBrush(QColor(iter->second & 0xff, (iter->second >> 8) & 0xff, (iter->second >> 16) & 0xff));
|
return QBrush(QColor(iter->second & 0xff, (iter->second >> 8) & 0xff, (iter->second >> 16) & 0xff),
|
||||||
|
cell->second.mMaxLandHeight > 0 ? Qt::SolidPattern : Qt::CrossPattern);
|
||||||
|
|
||||||
if (cell->second.mRegion.empty())
|
if (cell->second.mRegion.empty()) // no region
|
||||||
return QBrush(Qt::Dense6Pattern); // no region
|
return QBrush(cell->second.mMaxLandHeight > 0 ? Qt::Dense3Pattern : Qt::Dense6Pattern);
|
||||||
|
|
||||||
return QBrush(Qt::red, Qt::Dense6Pattern); // invalid region
|
return QBrush(Qt::red, Qt::Dense6Pattern); // invalid region
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,13 +40,14 @@ namespace CSMWorld
|
||||||
private:
|
private:
|
||||||
struct CellDescription
|
struct CellDescription
|
||||||
{
|
{
|
||||||
|
float mMaxLandHeight;
|
||||||
bool mDeleted;
|
bool mDeleted;
|
||||||
ESM::RefId mRegion;
|
ESM::RefId mRegion;
|
||||||
std::string mName;
|
std::string mName;
|
||||||
|
|
||||||
CellDescription();
|
CellDescription();
|
||||||
|
|
||||||
CellDescription(const Record<Cell>& cell);
|
CellDescription(const Record<Cell>& cell, float landHeight);
|
||||||
};
|
};
|
||||||
|
|
||||||
Data& mData;
|
Data& mData;
|
||||||
|
|
Loading…
Reference in a new issue