1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 05:49:56 +00:00
openmw-tes3mp/apps/opencs/model/world/columnbase.cpp

64 lines
1.8 KiB
C++

#include "columnbase.hpp"
#include "columns.hpp"
CSMWorld::ColumnBase::ColumnBase (int columnId, Display displayType, int flags, bool canNest)
: mColumnId (columnId), mDisplayType (displayType), mFlags (flags), mCanNest(canNest)
{}
CSMWorld::ColumnBase::~ColumnBase() {}
bool CSMWorld::ColumnBase::isUserEditable() const
{
return isEditable();
}
std::string CSMWorld::ColumnBase::getTitle() const
{
return Columns::getName (static_cast<Columns::ColumnId> (mColumnId));
}
int CSMWorld::ColumnBase::getId() const
{
return mColumnId;
}
bool CSMWorld::NestColumn::canHaveNestedColumns() const
{
return mCanNest;
}
void CSMWorld::NestColumn::addNestedColumn(int columnId, Display displayType)
{
if (!mCanNest)
throw std::logic_error("Tried to nest inside of the non-nest column");
mNestedColumns.push_back(CSMWorld::NestedColumn(columnId, displayType, mFlags, this));
}
const CSMWorld::ColumnBase& CSMWorld::NestColumn::nestedColumn(int subColumn) const
{
if (!mCanNest)
throw std::logic_error("Tried to access nested column of the non-nest column");
return mNestedColumns.at(subColumn);
}
int CSMWorld::NestColumn::nestedColumnCount() const
{
if (!mCanNest)
throw std::logic_error("Tried to access number of the subcolumns in the non-nest column");
return mNestedColumns.size();
}
CSMWorld::NestColumn::NestColumn(int columnId, Display displayType, int flags, bool canNest)
: CSMWorld::ColumnBase(columnId, displayType, flags, canNest) {}
CSMWorld::NestedColumn::NestedColumn(int columnId, Display displayType, int flag, const CSMWorld::NestColumn* parent)
: mParent(parent), CSMWorld::ColumnBase(columnId, displayType, flag) {}
bool CSMWorld::NestedColumn::isEditable() const
{
return mParent->isEditable();
}