metaforce/Runtime/CResLoader.hpp

62 lines
2.8 KiB
C++
Raw Normal View History

2016-04-13 06:07:23 +00:00
#ifndef __URDE_CRESLOADER_HPP__
#define __URDE_CRESLOADER_HPP__
2015-08-23 06:42:29 +00:00
#include <memory>
#include <string>
#include "RetroTypes.hpp"
#include "CPakFile.hpp"
2015-08-23 23:58:07 +00:00
#include "IOStreams.hpp"
2015-08-23 06:42:29 +00:00
2016-03-04 23:04:53 +00:00
namespace urde
2015-08-23 06:42:29 +00:00
{
2015-08-31 03:44:42 +00:00
struct SObjectTag;
class IDvdRequest;
2015-08-23 06:42:29 +00:00
class CResLoader
{
std::string m_loaderPath;
2017-02-08 06:48:43 +00:00
//std::list<std::unique_ptr<CPakFile>> x0_aramList;
std::list<std::unique_ptr<CPakFile>> x18_pakLoadedList;
std::list<std::unique_ptr<CPakFile>> x30_pakLoadingList;
2015-08-23 06:42:29 +00:00
u32 x44_pakLoadingCount = 0;
2017-10-26 05:37:46 +00:00
std::list<std::unique_ptr<CPakFile>>::iterator x48_curPak;
mutable CAssetId x4c_cachedResId;
mutable const CPakFile::SResInfo* x50_cachedResInfo = nullptr;
bool x54_forwardSeek = false;
2015-08-23 06:42:29 +00:00
public:
2017-10-26 05:37:46 +00:00
CResLoader();
2017-08-13 05:26:14 +00:00
const std::vector<CAssetId>* GetTagListForFile(const std::string& name) const;
2017-10-27 10:10:32 +00:00
void AddPakFileAsync(const std::string& name, bool buildDepList, bool worldPak);
2017-02-08 06:48:43 +00:00
void AddPakFile(const std::string& name, bool samusPak, bool worldPak);
2017-10-27 10:10:32 +00:00
void WaitForPakFileLoadingComplete();
std::unique_ptr<CInputStream> LoadNewResourcePartSync(const SObjectTag& tag, u32 length, u32 offset, void* extBuf);
2017-10-26 05:37:46 +00:00
void LoadMemResourceSync(const SObjectTag& tag, std::unique_ptr<u8[]>& bufOut, int* sizeOut);
std::unique_ptr<CInputStream> LoadResourceFromMemorySync(const SObjectTag& tag, const void* buf);
std::unique_ptr<CInputStream> LoadNewResourceSync(const SObjectTag& tag, void* extBuf=nullptr);
2017-11-05 02:08:05 +00:00
std::shared_ptr<IDvdRequest> LoadResourcePartAsync(const SObjectTag& tag, u32 offset, u32 length, void* buf);
2016-03-07 03:12:32 +00:00
std::shared_ptr<IDvdRequest> LoadResourceAsync(const SObjectTag& tag, void* buf);
std::unique_ptr<u8[]> LoadResourceSync(const urde::SObjectTag& tag);
2017-11-05 02:08:05 +00:00
std::unique_ptr<u8[]> LoadNewResourcePartSync(const urde::SObjectTag& tag, u32 off, u32 size);
2017-10-28 07:08:48 +00:00
void GetTagListForFile(const char* pakName, std::vector<SObjectTag>& out) const;
2015-08-23 23:58:07 +00:00
bool GetResourceCompression(const SObjectTag& tag);
u32 ResourceSize(const SObjectTag& tag);
bool ResourceExists(const SObjectTag& tag);
2017-08-13 05:26:14 +00:00
FourCC GetResourceTypeById(CAssetId id) const;
2015-08-28 00:11:31 +00:00
const SObjectTag* GetResourceIdByName(const char* name) const;
2015-08-23 23:58:07 +00:00
bool AreAllPaksLoaded() const;
void AsyncIdlePakLoading();
2017-08-13 05:26:14 +00:00
bool FindResource(CAssetId id) const;
CPakFile* FindResourceForLoad(CAssetId id);
2015-08-23 23:58:07 +00:00
CPakFile* FindResourceForLoad(const SObjectTag& tag);
2017-08-13 05:26:14 +00:00
bool CacheFromPakForLoad(CPakFile& file, CAssetId id);
2017-10-26 05:37:46 +00:00
bool CacheFromPak(const CPakFile& file, CAssetId id) const;
2015-08-23 23:58:07 +00:00
void MoveToCorrectLoadedList(std::unique_ptr<CPakFile>&& file);
std::vector<std::pair<std::string, SObjectTag>> GetResourceIdToNameList() const;
void EnumerateResources(const std::function<bool(const SObjectTag&)>& lambda) const;
void EnumerateNamedResources(const std::function<bool(const std::string&, const SObjectTag&)>& lambda) const;
2015-08-23 06:42:29 +00:00
};
}
2016-04-13 06:07:23 +00:00
#endif // __URDE_CRESLOADER_HPP__