From bfe541a35d40c9aff24a79ccc73d87b82b7d6a57 Mon Sep 17 00:00:00 2001 From: Aruki Date: Sat, 15 Jul 2017 22:55:26 -0600 Subject: [PATCH] Added null progress notifier, optimized CResourceStore::BuildFromDirectory a little --- src/Core/Core.pro | 3 ++- src/Core/GameProject/CResourceStore.cpp | 4 ++-- src/Core/IProgressNotifier.cpp | 3 +++ src/Core/IProgressNotifier.h | 10 ++++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 src/Core/IProgressNotifier.cpp diff --git a/src/Core/Core.pro b/src/Core/Core.pro index 0fc38a4f..192983d0 100644 --- a/src/Core/Core.pro +++ b/src/Core/Core.pro @@ -339,4 +339,5 @@ SOURCES += \ Resource/CResTypeInfo.cpp \ CompressionUtil.cpp \ IUIRelay.cpp \ - GameProject\COpeningBanner.cpp + GameProject\COpeningBanner.cpp \ + IProgressNotifier.cpp diff --git a/src/Core/GameProject/CResourceStore.cpp b/src/Core/GameProject/CResourceStore.cpp index 1c615755..2dc001c6 100644 --- a/src/Core/GameProject/CResourceStore.cpp +++ b/src/Core/GameProject/CResourceStore.cpp @@ -303,9 +303,9 @@ bool CResourceStore::BuildFromDirectory(bool ShouldGenerateCacheFile) for (auto Iter = ResourceList.begin(); Iter != ResourceList.end(); Iter++) { TString Path = *Iter; - TString RelPath = FileUtil::MakeRelative(Path, ResDir); + TString RelPath = Path.ChopFront( ResDir.Size() ); - if (FileUtil::IsFile(Path) && Path.GetFileExtension() == "rsmeta") + if (FileUtil::IsFile(Path) && Path.EndsWith(".rsmeta")) { // Determine resource name TString DirPath = RelPath.GetFileDirectory(); diff --git a/src/Core/IProgressNotifier.cpp b/src/Core/IProgressNotifier.cpp new file mode 100644 index 00000000..450a5024 --- /dev/null +++ b/src/Core/IProgressNotifier.cpp @@ -0,0 +1,3 @@ +#include "IProgressNotifier.h" + +CNullProgressNotifier *gpNullProgress = new CNullProgressNotifier(); diff --git a/src/Core/IProgressNotifier.h b/src/Core/IProgressNotifier.h index 859ec5bc..1154cfe7 100644 --- a/src/Core/IProgressNotifier.h +++ b/src/Core/IProgressNotifier.h @@ -63,4 +63,14 @@ protected: virtual void UpdateProgress(const TString& rkTaskName, const TString& rkStepDesc, float ProgressPercent) = 0; }; +// Null progress notifier can be passed to functions that require a progress notifier if you don't want to use one. +class CNullProgressNotifier : public IProgressNotifier +{ +public: + bool ShouldCancel() const { return false; } +protected: + void UpdateProgress(const TString&, const TString&, float) {} +}; +extern CNullProgressNotifier *gpNullProgress; + #endif // IPROGRESSNOTIFIER_H