1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00

334 lines
10 KiB
C++
Raw Normal View History

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