mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 04:15:33 +00:00
Merge branch 'cell'
This commit is contained in:
commit
f692fc1093
14 changed files with 132 additions and 4 deletions
|
@ -22,7 +22,7 @@ opencs_units (model/world
|
||||||
|
|
||||||
|
|
||||||
opencs_units_noqt (model/world
|
opencs_units_noqt (model/world
|
||||||
universalid data record idcollection commands columnbase scriptcontext
|
universalid data record idcollection commands columnbase scriptcontext cell
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_hdrs_noqt (model/world
|
opencs_hdrs_noqt (model/world
|
||||||
|
|
20
apps/opencs/model/world/cell.cpp
Normal file
20
apps/opencs/model/world/cell.cpp
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
#include "cell.hpp"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
void CSMWorld::Cell::load (ESM::ESMReader &esm)
|
||||||
|
{
|
||||||
|
mName = mId;
|
||||||
|
|
||||||
|
ESM::Cell::load (esm, true); /// \todo set this to false, once the bug in ESM::Cell::load is fixed
|
||||||
|
|
||||||
|
if (!(mData.mFlags & Interior))
|
||||||
|
{
|
||||||
|
std::ostringstream stream;
|
||||||
|
|
||||||
|
stream << "#" << mData.mX << " " << mData.mY;
|
||||||
|
|
||||||
|
mId = stream.str();
|
||||||
|
}
|
||||||
|
}
|
17
apps/opencs/model/world/cell.hpp
Normal file
17
apps/opencs/model/world/cell.hpp
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef CSM_WOLRD_CELL_H
|
||||||
|
#define CSM_WOLRD_CELL_H
|
||||||
|
|
||||||
|
#include <components/esm/loadcell.hpp>
|
||||||
|
|
||||||
|
namespace CSMWorld
|
||||||
|
{
|
||||||
|
/// \brief Wrapper for Cell record
|
||||||
|
struct Cell : public ESM::Cell
|
||||||
|
{
|
||||||
|
std::string mId;
|
||||||
|
|
||||||
|
void load (ESM::ESMReader &esm);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -748,6 +748,31 @@ namespace CSMWorld
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename ESXRecordT>
|
||||||
|
struct RegionColumn : public Column<ESXRecordT>
|
||||||
|
{
|
||||||
|
RegionColumn() : Column<ESXRecordT> ("Region", ColumnBase::Display_String) {}
|
||||||
|
|
||||||
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||||
|
{
|
||||||
|
return QString::fromUtf8 (record.get().mRegion.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
||||||
|
{
|
||||||
|
ESXRecordT record2 = record.get();
|
||||||
|
|
||||||
|
record2.mRegion = data.toString().toUtf8().constData();
|
||||||
|
|
||||||
|
record.setModified (record2);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool isEditable() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -119,6 +119,15 @@ CSMWorld::Data::Data()
|
||||||
mSpells.addColumn (new FlagColumn<ESM::Spell> ("Starter Spell", 0x2));
|
mSpells.addColumn (new FlagColumn<ESM::Spell> ("Starter Spell", 0x2));
|
||||||
mSpells.addColumn (new FlagColumn<ESM::Spell> ("Always Succeeds", 0x4));
|
mSpells.addColumn (new FlagColumn<ESM::Spell> ("Always Succeeds", 0x4));
|
||||||
|
|
||||||
|
mCells.addColumn (new StringIdColumn<Cell>);
|
||||||
|
mCells.addColumn (new RecordStateColumn<Cell>);
|
||||||
|
mCells.addColumn (new FixedRecordTypeColumn<Cell> (UniversalId::Type_Cell));
|
||||||
|
mCells.addColumn (new NameColumn<Cell>);
|
||||||
|
mCells.addColumn (new FlagColumn<Cell> ("Sleep forbidden", ESM::Cell::NoSleep));
|
||||||
|
mCells.addColumn (new FlagColumn<Cell> ("Interior Water", ESM::Cell::HasWater));
|
||||||
|
mCells.addColumn (new FlagColumn<Cell> ("Interior Sky", ESM::Cell::QuasiEx));
|
||||||
|
mCells.addColumn (new RegionColumn<Cell>);
|
||||||
|
|
||||||
addModel (new IdTable (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global);
|
addModel (new IdTable (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global);
|
||||||
addModel (new IdTable (&mGmsts), UniversalId::Type_Gmsts, UniversalId::Type_Gmst);
|
addModel (new IdTable (&mGmsts), UniversalId::Type_Gmsts, UniversalId::Type_Gmst);
|
||||||
addModel (new IdTable (&mSkills), UniversalId::Type_Skills, UniversalId::Type_Skill);
|
addModel (new IdTable (&mSkills), UniversalId::Type_Skills, UniversalId::Type_Skill);
|
||||||
|
@ -130,6 +139,7 @@ CSMWorld::Data::Data()
|
||||||
addModel (new IdTable (&mRegions), UniversalId::Type_Regions, UniversalId::Type_Region);
|
addModel (new IdTable (&mRegions), UniversalId::Type_Regions, UniversalId::Type_Region);
|
||||||
addModel (new IdTable (&mBirthsigns), UniversalId::Type_Birthsigns, UniversalId::Type_Birthsign);
|
addModel (new IdTable (&mBirthsigns), UniversalId::Type_Birthsigns, UniversalId::Type_Birthsign);
|
||||||
addModel (new IdTable (&mSpells), UniversalId::Type_Spells, UniversalId::Type_Spell);
|
addModel (new IdTable (&mSpells), UniversalId::Type_Spells, UniversalId::Type_Spell);
|
||||||
|
addModel (new IdTable (&mCells), UniversalId::Type_Cells, UniversalId::Type_Cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::Data::~Data()
|
CSMWorld::Data::~Data()
|
||||||
|
@ -248,6 +258,16 @@ CSMWorld::IdCollection<ESM::Spell>& CSMWorld::Data::getSpells()
|
||||||
return mSpells;
|
return mSpells;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CSMWorld::IdCollection<CSMWorld::Cell>& CSMWorld::Data::getCells() const
|
||||||
|
{
|
||||||
|
return mCells;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMWorld::IdCollection<CSMWorld::Cell>& CSMWorld::Data::getCells()
|
||||||
|
{
|
||||||
|
return mCells;
|
||||||
|
}
|
||||||
|
|
||||||
QAbstractItemModel *CSMWorld::Data::getTableModel (const UniversalId& id)
|
QAbstractItemModel *CSMWorld::Data::getTableModel (const UniversalId& id)
|
||||||
{
|
{
|
||||||
std::map<UniversalId::Type, QAbstractItemModel *>::iterator iter = mModelIndex.find (id.getType());
|
std::map<UniversalId::Type, QAbstractItemModel *>::iterator iter = mModelIndex.find (id.getType());
|
||||||
|
@ -293,6 +313,7 @@ void CSMWorld::Data::loadFile (const boost::filesystem::path& path, bool base)
|
||||||
case ESM::REC_REGN: mRegions.load (reader, base); break;
|
case ESM::REC_REGN: mRegions.load (reader, base); break;
|
||||||
case ESM::REC_BSGN: mBirthsigns.load (reader, base); break;
|
case ESM::REC_BSGN: mBirthsigns.load (reader, base); break;
|
||||||
case ESM::REC_SPEL: mSpells.load (reader, base); break;
|
case ESM::REC_SPEL: mSpells.load (reader, base); break;
|
||||||
|
case ESM::REC_CELL: mCells.load (reader, base); break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "idcollection.hpp"
|
#include "idcollection.hpp"
|
||||||
#include "universalid.hpp"
|
#include "universalid.hpp"
|
||||||
|
#include "cell.hpp"
|
||||||
|
|
||||||
class QAbstractItemModel;
|
class QAbstractItemModel;
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ namespace CSMWorld
|
||||||
IdCollection<ESM::Region> mRegions;
|
IdCollection<ESM::Region> mRegions;
|
||||||
IdCollection<ESM::BirthSign> mBirthsigns;
|
IdCollection<ESM::BirthSign> mBirthsigns;
|
||||||
IdCollection<ESM::Spell> mSpells;
|
IdCollection<ESM::Spell> mSpells;
|
||||||
|
IdCollection<Cell> mCells;
|
||||||
std::vector<QAbstractItemModel *> mModels;
|
std::vector<QAbstractItemModel *> mModels;
|
||||||
std::map<UniversalId::Type, QAbstractItemModel *> mModelIndex;
|
std::map<UniversalId::Type, QAbstractItemModel *> mModelIndex;
|
||||||
|
|
||||||
|
@ -98,6 +100,10 @@ namespace CSMWorld
|
||||||
|
|
||||||
IdCollection<ESM::Spell>& getSpells();
|
IdCollection<ESM::Spell>& getSpells();
|
||||||
|
|
||||||
|
const IdCollection<Cell>& getCells() const;
|
||||||
|
|
||||||
|
IdCollection<Cell>& getCells();
|
||||||
|
|
||||||
QAbstractItemModel *getTableModel (const UniversalId& id);
|
QAbstractItemModel *getTableModel (const UniversalId& id);
|
||||||
///< If no table model is available for \a id, an exception is thrown.
|
///< If no table model is available for \a id, an exception is thrown.
|
||||||
///
|
///
|
||||||
|
|
|
@ -325,10 +325,10 @@ namespace CSMWorld
|
||||||
{
|
{
|
||||||
std::string id = reader.getHNOString ("NAME");
|
std::string id = reader.getHNOString ("NAME");
|
||||||
|
|
||||||
int index = searchId (id);
|
|
||||||
|
|
||||||
if (reader.isNextSub ("DELE"))
|
if (reader.isNextSub ("DELE"))
|
||||||
{
|
{
|
||||||
|
int index = searchId (id);
|
||||||
|
|
||||||
reader.skipRecord();
|
reader.skipRecord();
|
||||||
|
|
||||||
if (index==-1)
|
if (index==-1)
|
||||||
|
@ -354,6 +354,8 @@ namespace CSMWorld
|
||||||
record.mId = id;
|
record.mId = id;
|
||||||
record.load (reader);
|
record.load (reader);
|
||||||
|
|
||||||
|
int index = searchId (record.mId);
|
||||||
|
|
||||||
if (index==-1)
|
if (index==-1)
|
||||||
{
|
{
|
||||||
// new record
|
// new record
|
||||||
|
|
|
@ -28,6 +28,7 @@ namespace
|
||||||
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Regions, "Regions" },
|
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Regions, "Regions" },
|
||||||
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Birthsigns, "Birthsigns" },
|
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Birthsigns, "Birthsigns" },
|
||||||
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Spells, "Spells" },
|
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Spells, "Spells" },
|
||||||
|
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Cells, "Cells" },
|
||||||
|
|
||||||
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
|
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
|
||||||
};
|
};
|
||||||
|
@ -45,6 +46,7 @@ namespace
|
||||||
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Region, "Region" },
|
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Region, "Region" },
|
||||||
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Birthsign, "Birthsign" },
|
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Birthsign, "Birthsign" },
|
||||||
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Spell, "Spell" },
|
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Spell, "Spell" },
|
||||||
|
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Cell, "Cell" },
|
||||||
|
|
||||||
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
|
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,7 +55,9 @@ namespace CSMWorld
|
||||||
Type_Birthsigns,
|
Type_Birthsigns,
|
||||||
Type_Birthsign,
|
Type_Birthsign,
|
||||||
Type_Spells,
|
Type_Spells,
|
||||||
Type_Spell
|
Type_Spell,
|
||||||
|
Type_Cells,
|
||||||
|
Type_Cell
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -125,6 +125,10 @@ void CSVDoc::View::setupWorldMenu()
|
||||||
QAction *spells = new QAction (tr ("Spells"), this);
|
QAction *spells = new QAction (tr ("Spells"), this);
|
||||||
connect (spells, SIGNAL (triggered()), this, SLOT (addSpellsSubView()));
|
connect (spells, SIGNAL (triggered()), this, SLOT (addSpellsSubView()));
|
||||||
world->addAction (spells);
|
world->addAction (spells);
|
||||||
|
|
||||||
|
QAction *cells = new QAction (tr ("Cells"), this);
|
||||||
|
connect (cells, SIGNAL (triggered()), this, SLOT (addCellsSubView()));
|
||||||
|
world->addAction (cells);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::View::setupUi()
|
void CSVDoc::View::setupUi()
|
||||||
|
@ -325,6 +329,11 @@ void CSVDoc::View::addSpellsSubView()
|
||||||
addSubView (CSMWorld::UniversalId::Type_Spells);
|
addSubView (CSMWorld::UniversalId::Type_Spells);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVDoc::View::addCellsSubView()
|
||||||
|
{
|
||||||
|
addSubView (CSMWorld::UniversalId::Type_Cells);
|
||||||
|
}
|
||||||
|
|
||||||
void CSVDoc::View::abortOperation (int type)
|
void CSVDoc::View::abortOperation (int type)
|
||||||
{
|
{
|
||||||
mDocument->abortOperation (type);
|
mDocument->abortOperation (type);
|
||||||
|
|
|
@ -133,6 +133,8 @@ namespace CSVDoc
|
||||||
void addBirthsignsSubView();
|
void addBirthsignsSubView();
|
||||||
|
|
||||||
void addSpellsSubView();
|
void addSpellsSubView();
|
||||||
|
|
||||||
|
void addCellsSubView();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
|
||||||
CSMWorld::UniversalId::Type_Regions,
|
CSMWorld::UniversalId::Type_Regions,
|
||||||
CSMWorld::UniversalId::Type_Birthsigns,
|
CSMWorld::UniversalId::Type_Birthsigns,
|
||||||
CSMWorld::UniversalId::Type_Spells,
|
CSMWorld::UniversalId::Type_Spells,
|
||||||
|
CSMWorld::UniversalId::Type_Cells,
|
||||||
|
|
||||||
CSMWorld::UniversalId::Type_None // end marker
|
CSMWorld::UniversalId::Type_None // end marker
|
||||||
};
|
};
|
||||||
|
|
|
@ -356,4 +356,22 @@ bool Cell::getNextMVRF(ESMReader &esm, MovedCellRef &mref)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Cell::blank()
|
||||||
|
{
|
||||||
|
mName.clear();
|
||||||
|
mRegion.clear();
|
||||||
|
mWater = 0;
|
||||||
|
mWaterInt = false;
|
||||||
|
mMapColor = 0;
|
||||||
|
mNAM0 = 0;
|
||||||
|
|
||||||
|
mData.mFlags = 0;
|
||||||
|
mData.mX = 0;
|
||||||
|
mData.mY = 0;
|
||||||
|
|
||||||
|
mAmbi.mAmbient = 0;
|
||||||
|
mAmbi.mSunlight = 0;
|
||||||
|
mAmbi.mFog = 0;
|
||||||
|
mAmbi.mFogDensity = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,9 @@ struct Cell
|
||||||
* Since they are comparably rare, we use a separate method for this.
|
* Since they are comparably rare, we use a separate method for this.
|
||||||
*/
|
*/
|
||||||
static bool getNextMVRF(ESMReader &esm, MovedCellRef &mref);
|
static bool getNextMVRF(ESMReader &esm, MovedCellRef &mref);
|
||||||
|
|
||||||
|
void blank();
|
||||||
|
///< Set record to default state (does not touch the ID/index).
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue