1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-20 15:53:54 +00:00
openmw/apps/opencs/model/world/data.hpp

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

327 lines
9.7 KiB
C++
Raw Normal View History

#ifndef CSM_WOLRD_DATA_H
#define CSM_WOLRD_DATA_H
#include <map>
#include <vector>
2013-02-07 10:33:08 +00:00
#include <QModelIndex>
2022-09-22 18:26:05 +00:00
#include <QObject>
2022-09-22 18:26:05 +00:00
#include <components/esm3/debugprofile.hpp>
#include <components/esm3/filter.hpp>
#include <components/esm3/loadbody.hpp>
#include <components/esm3/loadbsgn.hpp>
#include <components/esm3/loadclas.hpp>
2022-09-22 18:26:05 +00:00
#include <components/esm3/loaddial.hpp>
#include <components/esm3/loadench.hpp>
#include <components/esm3/loadfact.hpp>
2022-09-22 18:26:05 +00:00
#include <components/esm3/loadglob.hpp>
#include <components/esm3/loadgmst.hpp>
#include <components/esm3/loadmgef.hpp>
#include <components/esm3/loadrace.hpp>
#include <components/esm3/loadregn.hpp>
2022-09-22 18:26:05 +00:00
#include <components/esm3/loadscpt.hpp>
#include <components/esm3/loadskil.hpp>
#include <components/esm3/loadsndg.hpp>
2022-09-22 18:26:05 +00:00
#include <components/esm3/loadsoun.hpp>
#include <components/esm3/loadspel.hpp>
#include <components/esm3/loadsscr.hpp>
2015-03-26 17:02:51 +00:00
#include <components/resource/resourcesystem.hpp>
#include <components/files/multidircollection.hpp>
#include <components/to_utf8/to_utf8.hpp>
#include "actoradapter.hpp"
2013-04-14 15:04:55 +00:00
#include "cell.hpp"
2022-09-22 18:26:05 +00:00
#include "idcollection.hpp"
#include "infocollection.hpp"
#include "land.hpp"
#include "landtexture.hpp"
2022-09-22 18:26:05 +00:00
#include "metadata.hpp"
#include "nestedidcollection.hpp"
#include "nestedinfocollection.hpp"
2014-10-02 10:30:15 +00:00
#include "pathgrid.hpp"
2022-09-22 18:26:05 +00:00
#include "refcollection.hpp"
#include "refidcollection.hpp"
#include "resourcesmanager.hpp"
2022-09-22 18:26:05 +00:00
#include "universalid.hpp"
#ifndef Q_MOC_RUN
2014-10-04 13:36:52 +00:00
#include "subcellcollection.hpp"
#endif
class QAbstractItemModel;
namespace VFS
{
class Manager;
}
namespace Fallback
{
class Map;
}
namespace ESM
{
class ESMReader;
struct Dialogue;
}
namespace CSMWorld
{
2014-07-04 10:46:57 +00:00
class ResourcesManager;
class Resources;
class Data : public QObject
{
2022-09-22 18:26:05 +00:00
Q_OBJECT
2022-09-22 18:26:05 +00:00
ToUTF8::Utf8Encoder mEncoder;
IdCollection<ESM::Global> mGlobals;
IdCollection<ESM::GameSetting> mGmsts;
IdCollection<ESM::Skill> mSkills;
IdCollection<ESM::Class> mClasses;
NestedIdCollection<ESM::Faction> mFactions;
NestedIdCollection<ESM::Race> mRaces;
IdCollection<ESM::Sound> mSounds;
IdCollection<ESM::Script> mScripts;
NestedIdCollection<ESM::Region> mRegions;
NestedIdCollection<ESM::BirthSign> mBirthsigns;
NestedIdCollection<ESM::Spell> mSpells;
IdCollection<ESM::Dialogue> mTopics;
IdCollection<ESM::Dialogue> mJournals;
NestedIdCollection<ESM::Enchantment> mEnchantments;
IdCollection<ESM::BodyPart> mBodyParts;
IdCollection<ESM::MagicEffect> mMagicEffects;
IdCollection<ESM::DebugProfile> mDebugProfiles;
IdCollection<ESM::SoundGenerator> mSoundGens;
IdCollection<ESM::StartScript> mStartScripts;
NestedInfoCollection mTopicInfos;
InfoCollection mJournalInfos;
NestedIdCollection<Cell> mCells;
SubCellCollection<Pathgrid> mPathgrids;
IdCollection<LandTexture> mLandTextures;
IdCollection<Land> mLand;
RefIdCollection mReferenceables;
RefCollection mRefs;
IdCollection<ESM::Filter> mFilters;
Collection<MetaData> mMetaData;
std::unique_ptr<ActorAdapter> mActorAdapter;
std::vector<QAbstractItemModel*> mModels;
std::map<UniversalId::Type, QAbstractItemModel*> mModelIndex;
ESM::ESMReader* mReader;
const ESM::Dialogue* mDialogue; // last loaded dialogue
bool mBase;
bool mProject;
std::map<std::string, std::map<unsigned int, unsigned int>> mRefLoadCache;
int mReaderIndex;
2015-03-26 17:02:51 +00:00
2022-09-22 18:26:05 +00:00
bool mFsStrict;
Files::PathContainer mDataPaths;
std::vector<std::string> mArchives;
std::unique_ptr<VFS::Manager> mVFS;
ResourcesManager mResourcesManager;
std::shared_ptr<Resource::ResourceSystem> mResourceSystem;
2022-09-22 18:26:05 +00:00
std::vector<std::shared_ptr<ESM::ESMReader>> mReaders;
2022-09-22 18:26:05 +00:00
// not implemented
Data(const Data&);
Data& operator=(const Data&);
2022-09-22 18:26:05 +00:00
void addModel(QAbstractItemModel* model, UniversalId::Type type, bool update = true);
2022-09-22 18:26:05 +00:00
static void appendIds(std::vector<std::string>& ids, const CollectionBase& collection, bool listDeleted);
///< Append all IDs from collection to \a ids.
2013-09-24 15:08:24 +00:00
2022-09-22 18:26:05 +00:00
static int count(RecordBase::State state, const CollectionBase& collection);
2022-09-22 18:26:05 +00:00
void loadFallbackEntries();
2022-09-22 18:26:05 +00:00
public:
Data(ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths,
const std::vector<std::string>& archives, const std::filesystem::path& resDir);
2022-09-22 18:26:05 +00:00
~Data() override;
2022-09-22 18:26:05 +00:00
const VFS::Manager* getVFS() const;
2022-09-22 18:26:05 +00:00
std::shared_ptr<Resource::ResourceSystem> getResourceSystem();
2015-03-26 17:02:51 +00:00
2022-09-22 18:26:05 +00:00
std::shared_ptr<const Resource::ResourceSystem> getResourceSystem() const;
2015-06-02 23:18:36 +00:00
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::Global>& getGlobals() const;
2022-09-22 18:26:05 +00:00
IdCollection<ESM::Global>& getGlobals();
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::GameSetting>& getGmsts() const;
2022-09-22 18:26:05 +00:00
IdCollection<ESM::GameSetting>& getGmsts();
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::Skill>& getSkills() const;
2022-09-22 18:26:05 +00:00
IdCollection<ESM::Skill>& getSkills();
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::Class>& getClasses() const;
2013-04-04 08:10:26 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<ESM::Class>& getClasses();
2013-04-04 08:10:26 +00:00
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::Faction>& getFactions() const;
2013-04-02 10:00:45 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<ESM::Faction>& getFactions();
2013-04-02 10:00:45 +00:00
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::Race>& getRaces() const;
2013-04-04 12:34:39 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<ESM::Race>& getRaces();
2013-04-04 12:34:39 +00:00
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::Sound>& getSounds() const;
2013-04-06 19:21:10 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<ESM::Sound>& getSounds();
2013-04-06 19:21:10 +00:00
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::Script>& getScripts() const;
2013-04-07 13:17:35 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<ESM::Script>& getScripts();
2013-04-07 13:17:35 +00:00
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::Region>& getRegions() const;
2013-04-07 14:32:06 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<ESM::Region>& getRegions();
2013-04-07 14:32:06 +00:00
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::BirthSign>& getBirthsigns() const;
2013-04-07 18:26:39 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<ESM::BirthSign>& getBirthsigns();
2013-04-07 18:26:39 +00:00
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::Spell>& getSpells() const;
2013-04-09 09:40:36 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<ESM::Spell>& getSpells();
2013-04-09 09:40:36 +00:00
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::Dialogue>& getTopics() const;
2013-10-20 15:13:31 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<ESM::Dialogue>& getTopics();
2013-10-20 15:13:31 +00:00
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::Dialogue>& getJournals() const;
2013-10-20 15:13:31 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<ESM::Dialogue>& getJournals();
2013-10-20 15:13:31 +00:00
2022-09-22 18:26:05 +00:00
const InfoCollection& getTopicInfos() const;
2022-09-22 18:26:05 +00:00
InfoCollection& getTopicInfos();
2022-09-22 18:26:05 +00:00
const InfoCollection& getJournalInfos() const;
2022-09-22 18:26:05 +00:00
InfoCollection& getJournalInfos();
2022-09-22 18:26:05 +00:00
const IdCollection<Cell>& getCells() const;
2013-04-14 15:04:55 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<Cell>& getCells();
2013-04-14 15:04:55 +00:00
2022-09-22 18:26:05 +00:00
const RefIdCollection& getReferenceables() const;
2013-05-07 09:23:18 +00:00
2022-09-22 18:26:05 +00:00
RefIdCollection& getReferenceables();
2013-05-07 09:23:18 +00:00
2022-09-22 18:26:05 +00:00
const RefCollection& getReferences() const;
2022-09-22 18:26:05 +00:00
RefCollection& getReferences();
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::Filter>& getFilters() const;
2013-08-24 15:40:00 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<ESM::Filter>& getFilters();
2013-08-24 15:40:00 +00:00
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::Enchantment>& getEnchantments() const;
2014-06-30 18:40:34 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<ESM::Enchantment>& getEnchantments();
2014-06-30 18:40:34 +00:00
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::BodyPart>& getBodyParts() const;
2014-07-01 10:37:22 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<ESM::BodyPart>& getBodyParts();
2014-07-01 10:37:22 +00:00
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::DebugProfile>& getDebugProfiles() const;
2014-08-04 11:36:01 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<ESM::DebugProfile>& getDebugProfiles();
2014-08-04 11:36:01 +00:00
2022-09-22 18:26:05 +00:00
const IdCollection<CSMWorld::Land>& getLand() const;
2022-09-22 18:26:05 +00:00
IdCollection<CSMWorld::Land>& getLand();
2022-09-22 18:26:05 +00:00
const IdCollection<CSMWorld::LandTexture>& getLandTextures() const;
2022-09-22 18:26:05 +00:00
IdCollection<CSMWorld::LandTexture>& getLandTextures();
2015-08-30 12:27:22 +00:00
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::SoundGenerator>& getSoundGens() const;
2014-09-23 10:18:18 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<ESM::SoundGenerator>& getSoundGens();
2014-09-23 10:18:18 +00:00
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::MagicEffect>& getMagicEffects() const;
2014-09-26 11:05:51 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<ESM::MagicEffect>& getMagicEffects();
2014-09-26 11:05:51 +00:00
2022-09-22 18:26:05 +00:00
const SubCellCollection<Pathgrid>& getPathgrids() const;
2014-10-02 10:30:15 +00:00
2022-09-22 18:26:05 +00:00
SubCellCollection<Pathgrid>& getPathgrids();
2014-10-02 10:30:15 +00:00
2022-09-22 18:26:05 +00:00
const IdCollection<ESM::StartScript>& getStartScripts() const;
2015-03-03 12:52:36 +00:00
2022-09-22 18:26:05 +00:00
IdCollection<ESM::StartScript>& getStartScripts();
2015-03-03 12:52:36 +00:00
2022-09-22 18:26:05 +00:00
/// Throws an exception, if \a id does not match a resources list.
const Resources& getResources(const UniversalId& id) const;
2014-07-04 10:46:57 +00:00
2022-09-22 18:26:05 +00:00
const MetaData& getMetaData() const;
2022-09-22 18:26:05 +00:00
void setMetaData(const MetaData& metaData);
2022-09-22 18:26:05 +00:00
QAbstractItemModel* getTableModel(const UniversalId& id);
///< If no table model is available for \a id, an exception is thrown.
///
/// \note The returned table may either be the model for the ID itself or the model that
/// contains the record specified by the ID.
2022-09-22 18:26:05 +00:00
const ActorAdapter* getActorAdapter() const;
2022-09-22 18:26:05 +00:00
ActorAdapter* getActorAdapter();
2022-09-22 18:26:05 +00:00
void merge();
///< Merge modified into base.
2013-02-07 10:33:08 +00:00
2022-09-22 18:26:05 +00:00
int getTotalRecords(const std::vector<std::filesystem::path>& files); // for better loading bar
2022-09-22 18:26:05 +00:00
int startLoading(const std::filesystem::path& path, bool base, bool project);
///< Begin merging content of a file into base or modified.
///
/// \param project load project file instead of content file
///
///< \return estimated number of records
2022-09-22 18:26:05 +00:00
bool continueLoading(CSMDoc::Messages& messages);
///< \return Finished?
2022-09-22 18:26:05 +00:00
bool hasId(const std::string& id) const;
2022-09-22 18:26:05 +00:00
std::vector<std::string> getIds(bool listDeleted = true) const;
///< Return a sorted collection of all IDs that are not internal to the editor.
///
/// \param listDeleted include deleted record in the list
2022-09-22 18:26:05 +00:00
int count(RecordBase::State state) const;
///< Return number of top-level records with the given \a state.
2013-09-24 15:08:24 +00:00
2022-09-22 18:26:05 +00:00
signals:
2022-09-22 18:26:05 +00:00
void idListChanged();
2022-09-22 18:26:05 +00:00
void assetTablesChanged();
2017-08-19 23:36:45 +00:00
2022-09-22 18:26:05 +00:00
public slots:
2022-09-22 18:26:05 +00:00
void assetsChanged();
2017-08-19 07:43:31 +00:00
2022-09-22 18:26:05 +00:00
private slots:
2022-09-22 18:26:05 +00:00
void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
2022-09-22 18:26:05 +00:00
void rowsChanged(const QModelIndex& parent, int start, int end);
};
}
#endif