1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 08:53:52 +00:00
openmw/apps/opencs/model/world/columnbase.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

159 lines
3.6 KiB
C++
Raw Normal View History

#include "columnbase.hpp"
2022-10-19 17:02:00 +00:00
#include <algorithm>
#include "columns.hpp"
CSMWorld::ColumnBase::ColumnBase(int columnId, Display displayType, int flags)
: mColumnId(columnId)
, mFlags(flags)
, mDisplayType(displayType)
{
}
bool CSMWorld::ColumnBase::isUserEditable() const
{
return isEditable();
}
std::string CSMWorld::ColumnBase::getTitle() const
{
return Columns::getName(static_cast<Columns::ColumnId>(mColumnId));
2014-03-08 14:27:43 +00:00
}
int CSMWorld::ColumnBase::getId() const
{
return mColumnId;
}
bool CSMWorld::ColumnBase::isId(Display display)
{
static const Display ids[] = {
Display_Skill,
Display_Class,
Display_Faction,
Display_Rank,
Display_Race,
Display_Sound,
Display_Region,
Display_Birthsign,
Display_Spell,
Display_Cell,
Display_Referenceable,
Display_Activator,
Display_Potion,
Display_Apparatus,
Display_Armor,
Display_Book,
Display_Clothing,
Display_Container,
Display_Creature,
Display_Door,
Display_Ingredient,
Display_CreatureLevelledList,
Display_ItemLevelledList,
Display_Light,
Display_Lockpick,
Display_Miscellaneous,
Display_Npc,
Display_Probe,
Display_Repair,
Display_Static,
Display_Weapon,
Display_Reference,
Display_Filter,
Display_Topic,
Display_Journal,
Display_TopicInfo,
Display_JournalInfo,
Display_Scene,
Display_GlobalVariable,
Display_BodyPart,
Display_Enchantment,
2015-04-04 17:55:53 +00:00
Display_Script,
Display_Mesh,
Display_Icon,
Display_Music,
Display_SoundRes,
Display_Texture,
Display_Video,
2015-04-10 11:27:34 +00:00
Display_Id,
Display_SkillId,
Display_EffectRange,
Display_EffectId,
Display_PartRefType,
Display_AiPackageType,
Display_InfoCondFunc,
Display_InfoCondVar,
Display_InfoCondComp,
2015-04-10 11:27:34 +00:00
Display_EffectSkill,
Display_EffectAttribute,
Display_IngredEffectId,
Display_None,
};
for (int i = 0; ids[i] != Display_None; ++i)
if (ids[i] == display)
return true;
return false;
}
bool CSMWorld::ColumnBase::isText(Display display)
{
2015-06-26 16:19:00 +00:00
return display == Display_String || display == Display_LongString || display == Display_String32
|| display == Display_String64 || display == Display_LongString256;
}
bool CSMWorld::ColumnBase::isScript(Display display)
{
2015-04-04 17:55:53 +00:00
return display == Display_ScriptFile || display == Display_ScriptLines;
}
void CSMWorld::NestableColumn::addColumn(CSMWorld::NestableColumn* column)
{
mNestedColumns.push_back(column);
}
const CSMWorld::ColumnBase& CSMWorld::NestableColumn::nestedColumn(int subColumn) const
{
2015-04-11 01:26:29 +00:00
if (mNestedColumns.empty())
throw std::logic_error("Tried to access nested column of the non-nest column");
return *mNestedColumns.at(subColumn);
}
CSMWorld::NestableColumn::NestableColumn(int columnId, CSMWorld::ColumnBase::Display displayType, int flag)
2015-04-11 01:26:29 +00:00
: CSMWorld::ColumnBase(columnId, displayType, flag)
{
}
CSMWorld::NestableColumn::~NestableColumn()
{
for (auto* col : mNestedColumns)
{
delete col;
}
}
bool CSMWorld::NestableColumn::hasChildren() const
{
2015-04-11 01:26:29 +00:00
return !mNestedColumns.empty();
}
CSMWorld::NestedChildColumn::NestedChildColumn(
int id, CSMWorld::ColumnBase::Display display, int flags, bool isEditable)
: NestableColumn(id, display, flags)
, mIsEditable(isEditable)
{
}
bool CSMWorld::NestedChildColumn::isEditable() const
{
return mIsEditable;
}