mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 15:29:55 +00:00
Show groundcover loading progress
This commit is contained in:
parent
c7449dc272
commit
9c93de65be
7 changed files with 44 additions and 15 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <components/lua/configuration.hpp>
|
||||
#include <components/misc/algorithm.hpp>
|
||||
#include <components/esm3/readerscache.hpp>
|
||||
#include <components/esmloader/load.hpp>
|
||||
|
||||
#include "../mwmechanics/spelllist.hpp"
|
||||
|
||||
|
@ -145,7 +146,8 @@ static bool isCacheableRecord(int id)
|
|||
|
||||
void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener, ESM::Dialogue*& dialogue)
|
||||
{
|
||||
listener->setProgressRange(1000);
|
||||
if (listener != nullptr)
|
||||
listener->setProgressRange(::EsmLoader::fileProgress);
|
||||
|
||||
// Land texture loading needs to use a separate internal store for each plugin.
|
||||
// We set the number of plugins here so we can properly verify if valid plugin
|
||||
|
@ -211,7 +213,8 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener, ESM::Dialo
|
|||
dialogue = nullptr;
|
||||
}
|
||||
}
|
||||
listener->setProgress(static_cast<size_t>(esm.getFileOffset() / (float)esm.getFileSize() * 1000));
|
||||
if (listener != nullptr)
|
||||
listener->setProgress(::EsmLoader::fileProgress * esm.getFileOffset() / esm.getFileSize());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,14 +6,16 @@
|
|||
|
||||
namespace MWWorld
|
||||
{
|
||||
void GroundcoverStore::init(const Store<ESM::Static>& statics, const Files::Collections& fileCollections, const std::vector<std::string>& groundcoverFiles, ToUTF8::Utf8Encoder* encoder)
|
||||
void GroundcoverStore::init(const Store<ESM::Static>& statics, const Files::Collections& fileCollections,
|
||||
const std::vector<std::string>& groundcoverFiles, ToUTF8::Utf8Encoder* encoder, Loading::Listener* listener)
|
||||
{
|
||||
::EsmLoader::Query query;
|
||||
query.mLoadStatics = true;
|
||||
query.mLoadCells = true;
|
||||
|
||||
ESM::ReadersCache readers;
|
||||
const ::EsmLoader::EsmData content = ::EsmLoader::loadEsmData(query, groundcoverFiles, fileCollections, readers, encoder);
|
||||
const ::EsmLoader::EsmData content = ::EsmLoader::loadEsmData(query, groundcoverFiles, fileCollections,
|
||||
readers, encoder, listener);
|
||||
|
||||
for (const ESM::Static& stat : statics)
|
||||
{
|
||||
|
|
|
@ -20,7 +20,10 @@ namespace MWWorld
|
|||
std::map<std::pair<int, int>, std::vector<ESM::ESM_Context>> mCellContexts;
|
||||
|
||||
public:
|
||||
void init(const Store<ESM::Static>& statics, const Files::Collections& fileCollections, const std::vector<std::string>& groundcoverFiles, ToUTF8::Utf8Encoder* encoder);
|
||||
void init(const Store<ESM::Static>& statics, const Files::Collections& fileCollections,
|
||||
const std::vector<std::string>& groundcoverFiles, ToUTF8::Utf8Encoder* encoder,
|
||||
Loading::Listener* listener);
|
||||
|
||||
std::string getGroundcoverModel(const std::string& id) const;
|
||||
void initCell(ESM::Cell& cell, int cellX, int cellY) const;
|
||||
};
|
||||
|
|
|
@ -157,7 +157,7 @@ namespace MWWorld
|
|||
listener->loadingOn();
|
||||
|
||||
loadContentFiles(fileCollections, contentFiles, encoder, listener);
|
||||
loadGroundcoverFiles(fileCollections, groundcoverFiles, encoder);
|
||||
loadGroundcoverFiles(fileCollections, groundcoverFiles, encoder, listener);
|
||||
|
||||
listener->loadingOff();
|
||||
|
||||
|
@ -2940,13 +2940,14 @@ namespace MWWorld
|
|||
ensureNeededRecords(); // Insert records that may not be present in all versions of master files.
|
||||
}
|
||||
|
||||
void World::loadGroundcoverFiles(const Files::Collections& fileCollections, const std::vector<std::string>& groundcoverFiles, ToUTF8::Utf8Encoder* encoder)
|
||||
void World::loadGroundcoverFiles(const Files::Collections& fileCollections,
|
||||
const std::vector<std::string>& groundcoverFiles, ToUTF8::Utf8Encoder* encoder, Loading::Listener* listener)
|
||||
{
|
||||
if (!Settings::Manager::getBool("enabled", "Groundcover")) return;
|
||||
|
||||
Log(Debug::Info) << "Loading groundcover:";
|
||||
|
||||
mGroundcoverStore.init(mStore.get<ESM::Static>(), fileCollections, groundcoverFiles, encoder);
|
||||
mGroundcoverStore.init(mStore.get<ESM::Static>(), fileCollections, groundcoverFiles, encoder, listener);
|
||||
}
|
||||
|
||||
bool World::startSpellCast(const Ptr &actor)
|
||||
|
|
|
@ -171,7 +171,9 @@ namespace MWWorld
|
|||
void loadContentFiles(const Files::Collections& fileCollections, const std::vector<std::string>& content,
|
||||
ToUTF8::Utf8Encoder* encoder, Loading::Listener* listener);
|
||||
|
||||
void loadGroundcoverFiles(const Files::Collections& fileCollections, const std::vector<std::string>& groundcoverFiles, ToUTF8::Utf8Encoder* encoder);
|
||||
void loadGroundcoverFiles(const Files::Collections& fileCollections,
|
||||
const std::vector<std::string>& groundcoverFiles, ToUTF8::Utf8Encoder* encoder,
|
||||
Loading::Listener* listener);
|
||||
|
||||
float feetToGameUnits(float feet);
|
||||
float getActivationDistancePlusTelekinesis();
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <components/misc/resourcehelpers.hpp>
|
||||
#include <components/misc/stringops.hpp>
|
||||
#include <components/esm3/readerscache.hpp>
|
||||
#include <components/loadinglistener/loadinglistener.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
|
@ -190,7 +191,7 @@ namespace EsmLoader
|
|||
reader.skipRecord();
|
||||
}
|
||||
|
||||
void loadEsm(const Query& query, ESM::ESMReader& reader, ShallowContent& content)
|
||||
void loadEsm(const Query& query, ESM::ESMReader& reader, ShallowContent& content, Loading::Listener* listener)
|
||||
{
|
||||
Log(Debug::Info) << "Loading ESM file " << reader.getName();
|
||||
|
||||
|
@ -204,12 +205,15 @@ namespace EsmLoader
|
|||
continue;
|
||||
}
|
||||
loadRecord(query, recName, reader, content);
|
||||
|
||||
if (listener != nullptr)
|
||||
listener->setProgress(fileProgress * reader.getFileOffset() / reader.getFileSize());
|
||||
}
|
||||
}
|
||||
|
||||
ShallowContent shallowLoad(const Query& query, const std::vector<std::string>& contentFiles,
|
||||
const Files::Collections& fileCollections, ESM::ReadersCache& readers,
|
||||
ToUTF8::Utf8Encoder* encoder)
|
||||
ToUTF8::Utf8Encoder* encoder, Loading::Listener* listener)
|
||||
{
|
||||
ShallowContent result;
|
||||
|
||||
|
@ -232,6 +236,12 @@ namespace EsmLoader
|
|||
continue;
|
||||
}
|
||||
|
||||
if (listener != nullptr)
|
||||
{
|
||||
listener->setLabel(file);
|
||||
listener->setProgressRange(fileProgress);
|
||||
}
|
||||
|
||||
const Files::MultiDirCollection& collection = fileCollections.getCollection(extension);
|
||||
|
||||
const ESM::ReadersCache::BusyItem reader = readers.get(i);
|
||||
|
@ -241,7 +251,7 @@ namespace EsmLoader
|
|||
if (query.mLoadCells)
|
||||
reader->resolveParentFileIndices(readers);
|
||||
|
||||
loadEsm(query, *reader, result);
|
||||
loadEsm(query, *reader, result, listener);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -290,11 +300,12 @@ namespace EsmLoader
|
|||
}
|
||||
|
||||
EsmData loadEsmData(const Query& query, const std::vector<std::string>& contentFiles,
|
||||
const Files::Collections& fileCollections, ESM::ReadersCache& readers, ToUTF8::Utf8Encoder* encoder)
|
||||
const Files::Collections& fileCollections, ESM::ReadersCache& readers, ToUTF8::Utf8Encoder* encoder,
|
||||
Loading::Listener* listener)
|
||||
{
|
||||
Log(Debug::Info) << "Loading ESM data...";
|
||||
|
||||
ShallowContent content = shallowLoad(query, contentFiles, fileCollections, readers, encoder);
|
||||
ShallowContent content = shallowLoad(query, contentFiles, fileCollections, readers, encoder, listener);
|
||||
|
||||
std::ostringstream loaded;
|
||||
|
||||
|
|
|
@ -16,10 +16,17 @@ namespace Files
|
|||
class Collections;
|
||||
}
|
||||
|
||||
namespace Loading
|
||||
{
|
||||
class Listener;
|
||||
}
|
||||
|
||||
namespace EsmLoader
|
||||
{
|
||||
struct EsmData;
|
||||
|
||||
inline constexpr std::size_t fileProgress = 1000;
|
||||
|
||||
struct Query
|
||||
{
|
||||
bool mLoadActivators = false;
|
||||
|
@ -33,7 +40,7 @@ namespace EsmLoader
|
|||
|
||||
EsmData loadEsmData(const Query& query, const std::vector<std::string>& contentFiles,
|
||||
const Files::Collections& fileCollections, ESM::ReadersCache& readers,
|
||||
ToUTF8::Utf8Encoder* encoder);
|
||||
ToUTF8::Utf8Encoder* encoder, Loading::Listener* listener = nullptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue