mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-22 08:08:53 -05:00
move RawJson
to LUS (#4063)
This commit is contained in:
parent
7bde0f5289
commit
d22dbd6933
@ -3,6 +3,7 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <File.h>
|
||||
#include <Json.h>
|
||||
#include <libultraship/classes.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <spdlog/fmt/fmt.h>
|
||||
@ -12,7 +13,6 @@
|
||||
#include "overlays/gamestates/ovl_file_choose/file_choose.h"
|
||||
#include "soh/Enhancements/boss-rush/BossRush.h"
|
||||
#include "soh/resource/type/SohResourceType.h"
|
||||
#include "soh/resource/type/RawJson.h"
|
||||
|
||||
extern "C" {
|
||||
extern MapData* gMapData;
|
||||
@ -1041,19 +1041,19 @@ void InitTTSBank() {
|
||||
|
||||
auto initData = std::make_shared<LUS::ResourceInitData>();
|
||||
initData->Format = RESOURCE_FORMAT_BINARY;
|
||||
initData->Type = static_cast<uint32_t>(SOH::ResourceType::SOH_RawJson);
|
||||
initData->Type = static_cast<uint32_t>(LUS::ResourceType::Json);
|
||||
initData->ResourceVersion = 0;
|
||||
|
||||
sceneMap = std::static_pointer_cast<SOH::RawJson>(
|
||||
sceneMap = std::static_pointer_cast<LUS::Json>(
|
||||
LUS::Context::GetInstance()->GetResourceManager()->LoadResource("accessibility/texts/scenes" + languageSuffix, true, initData))->Data;
|
||||
|
||||
miscMap = std::static_pointer_cast<SOH::RawJson>(
|
||||
miscMap = std::static_pointer_cast<LUS::Json>(
|
||||
LUS::Context::GetInstance()->GetResourceManager()->LoadResource("accessibility/texts/misc" + languageSuffix, true, initData))->Data;
|
||||
|
||||
kaleidoMap = std::static_pointer_cast<SOH::RawJson>(
|
||||
kaleidoMap = std::static_pointer_cast<LUS::Json>(
|
||||
LUS::Context::GetInstance()->GetResourceManager()->LoadResource("accessibility/texts/kaleidoscope" + languageSuffix, true, initData))->Data;
|
||||
|
||||
fileChooseMap = std::static_pointer_cast<SOH::RawJson>(
|
||||
fileChooseMap = std::static_pointer_cast<LUS::Json>(
|
||||
LUS::Context::GetInstance()->GetResourceManager()->LoadResource("accessibility/texts/filechoose" + languageSuffix, true, initData))->Data;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,6 @@ GameInteractorSail* GameInteractorSail::Instance;
|
||||
#include "soh/resource/importer/SkeletonLimbFactory.h"
|
||||
#include "soh/resource/importer/TextFactory.h"
|
||||
#include "soh/resource/importer/BackgroundFactory.h"
|
||||
#include "soh/resource/importer/RawJsonFactory.h"
|
||||
|
||||
#include "soh/config/ConfigUpdaters.h"
|
||||
|
||||
@ -349,7 +348,6 @@ OTRGlobals::OTRGlobals() {
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryAudioSoundFontV2>(), RESOURCE_FORMAT_BINARY, "AudioSoundFont", static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSoundFont), 2);
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryAudioSequenceV2>(), RESOURCE_FORMAT_BINARY, "AudioSequence", static_cast<uint32_t>(SOH::ResourceType::SOH_AudioSequence), 2);
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryBackgroundV0>(), RESOURCE_FORMAT_BINARY, "Background", static_cast<uint32_t>(SOH::ResourceType::SOH_Background), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SOH::ResourceFactoryBinaryRawJsonV0>(), RESOURCE_FORMAT_BINARY, "RawJson", static_cast<uint32_t>(SOH::ResourceType::SOH_RawJson), 0);
|
||||
|
||||
gSaveStateMgr = std::make_shared<SaveStateMgr>();
|
||||
gRandoContext = Rando::Context::CreateInstance();
|
||||
|
@ -1,19 +0,0 @@
|
||||
#include "soh/resource/importer/RawJsonFactory.h"
|
||||
#include "soh/resource/type/RawJson.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace SOH {
|
||||
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryRawJsonV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto rawJson = std::make_shared<RawJson>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
rawJson->DataSize = file->Buffer->size();
|
||||
rawJson->Data = nlohmann::json::parse(reader->ReadCString(), nullptr, true, true);
|
||||
|
||||
return rawJson;
|
||||
}
|
||||
} // namespace SOH
|
@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "resource/Resource.h"
|
||||
#include "resource/ResourceFactoryBinary.h"
|
||||
|
||||
namespace SOH {
|
||||
class ResourceFactoryBinaryRawJsonV0 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
|
||||
};
|
||||
}; // namespace SOH
|
@ -1,14 +0,0 @@
|
||||
#include "RawJson.h"
|
||||
|
||||
namespace SOH {
|
||||
RawJson::RawJson() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {
|
||||
}
|
||||
|
||||
void* RawJson::GetPointer() {
|
||||
return &Data;
|
||||
}
|
||||
|
||||
size_t RawJson::GetPointerSize() {
|
||||
return DataSize * sizeof(char);
|
||||
}
|
||||
} // namespace SOH
|
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "resource/Resource.h"
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace SOH {
|
||||
|
||||
class RawJson : public LUS::Resource<void> {
|
||||
public:
|
||||
using Resource::Resource;
|
||||
|
||||
RawJson();
|
||||
|
||||
void* GetPointer() override;
|
||||
size_t GetPointerSize() override;
|
||||
|
||||
nlohmann::json Data;
|
||||
size_t DataSize;
|
||||
};
|
||||
}; // namespace SOH
|
@ -17,6 +17,5 @@ enum class ResourceType {
|
||||
SOH_AudioSequence = 0x4F534551, // OSEQ
|
||||
SOH_Background = 0x4F424749, // OBGI
|
||||
SOH_SceneCommand = 0x4F52434D, // ORCM
|
||||
SOH_RawJson = 0x4A534F4E, // JSON
|
||||
};
|
||||
} // namespace SOH
|
||||
|
Loading…
Reference in New Issue
Block a user