2024-01-05 10:15:41 -06:00
|
|
|
#include "2s2h/resource/importer/BackgroundFactory.h"
|
|
|
|
|
#include "2s2h/resource/type/Background.h"
|
|
|
|
|
#include "spdlog/spdlog.h"
|
|
|
|
|
|
2024-03-26 21:26:31 -04:00
|
|
|
namespace SOH {
|
2024-05-03 15:57:40 -04:00
|
|
|
std::shared_ptr<Ship::IResource> ResourceFactoryBinaryBackgroundV0::ReadResource(std::shared_ptr<Ship::File> file) {
|
2024-03-26 21:26:31 -04:00
|
|
|
if (!FileHasValidFormatAndReader(file)) {
|
2024-01-05 10:15:41 -06:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-26 21:26:31 -04:00
|
|
|
auto background = std::make_shared<Background>(file->InitData);
|
2024-05-03 15:57:40 -04:00
|
|
|
auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
|
2024-01-05 10:15:41 -06:00
|
|
|
|
|
|
|
|
uint32_t dataSize = reader->ReadUInt32();
|
|
|
|
|
|
|
|
|
|
background->Data.reserve(dataSize);
|
|
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < dataSize; i++) {
|
|
|
|
|
background->Data.push_back(reader->ReadUByte());
|
|
|
|
|
}
|
2024-03-26 21:26:31 -04:00
|
|
|
|
|
|
|
|
return background;
|
2024-01-05 10:15:41 -06:00
|
|
|
}
|
2024-03-26 21:26:31 -04:00
|
|
|
} // namespace SOH
|