From 49f891f2e53b3a66a49df8deb8c2889edc366db0 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Sun, 21 Apr 2024 21:16:59 -0400 Subject: [PATCH] move `RawJson` to LUS (#4063) --- libultraship | 2 +- soh/soh/Enhancements/tts/tts.cpp | 12 ++++++------ soh/soh/OTRGlobals.cpp | 2 -- soh/soh/resource/importer/RawJsonFactory.cpp | 19 ------------------- soh/soh/resource/importer/RawJsonFactory.h | 11 ----------- soh/soh/resource/type/RawJson.cpp | 14 -------------- soh/soh/resource/type/RawJson.h | 20 -------------------- soh/soh/resource/type/SohResourceType.h | 1 - 8 files changed, 7 insertions(+), 74 deletions(-) delete mode 100644 soh/soh/resource/importer/RawJsonFactory.cpp delete mode 100644 soh/soh/resource/importer/RawJsonFactory.h delete mode 100644 soh/soh/resource/type/RawJson.cpp delete mode 100644 soh/soh/resource/type/RawJson.h diff --git a/libultraship b/libultraship index 26ecbc197..8a079ed15 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 26ecbc19784347773f750aa838190e45172b63e6 +Subproject commit 8a079ed15852fbd26e701fd317afc14530578a92 diff --git a/soh/soh/Enhancements/tts/tts.cpp b/soh/soh/Enhancements/tts/tts.cpp index f4b498815..3a375230f 100644 --- a/soh/soh/Enhancements/tts/tts.cpp +++ b/soh/soh/Enhancements/tts/tts.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -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(); initData->Format = RESOURCE_FORMAT_BINARY; - initData->Type = static_cast(SOH::ResourceType::SOH_RawJson); + initData->Type = static_cast(LUS::ResourceType::Json); initData->ResourceVersion = 0; - sceneMap = std::static_pointer_cast( + sceneMap = std::static_pointer_cast( LUS::Context::GetInstance()->GetResourceManager()->LoadResource("accessibility/texts/scenes" + languageSuffix, true, initData))->Data; - miscMap = std::static_pointer_cast( + miscMap = std::static_pointer_cast( LUS::Context::GetInstance()->GetResourceManager()->LoadResource("accessibility/texts/misc" + languageSuffix, true, initData))->Data; - kaleidoMap = std::static_pointer_cast( + kaleidoMap = std::static_pointer_cast( LUS::Context::GetInstance()->GetResourceManager()->LoadResource("accessibility/texts/kaleidoscope" + languageSuffix, true, initData))->Data; - fileChooseMap = std::static_pointer_cast( + fileChooseMap = std::static_pointer_cast( LUS::Context::GetInstance()->GetResourceManager()->LoadResource("accessibility/texts/filechoose" + languageSuffix, true, initData))->Data; } diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index e8c88fc61..48489d542 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -118,7 +118,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" @@ -343,7 +342,6 @@ OTRGlobals::OTRGlobals() { loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "AudioSoundFont", static_cast(SOH::ResourceType::SOH_AudioSoundFont), 2); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "AudioSequence", static_cast(SOH::ResourceType::SOH_AudioSequence), 2); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Background", static_cast(SOH::ResourceType::SOH_Background), 0); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "RawJson", static_cast(SOH::ResourceType::SOH_RawJson), 0); gSaveStateMgr = std::make_shared(); gRandomizer = std::make_shared(); diff --git a/soh/soh/resource/importer/RawJsonFactory.cpp b/soh/soh/resource/importer/RawJsonFactory.cpp deleted file mode 100644 index 4978f6f96..000000000 --- a/soh/soh/resource/importer/RawJsonFactory.cpp +++ /dev/null @@ -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 ResourceFactoryBinaryRawJsonV0::ReadResource(std::shared_ptr file) { - if (!FileHasValidFormatAndReader(file)) { - return nullptr; - } - - auto rawJson = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); - - rawJson->DataSize = file->Buffer->size(); - rawJson->Data = nlohmann::json::parse(reader->ReadCString(), nullptr, true, true); - - return rawJson; -} -} // namespace SOH diff --git a/soh/soh/resource/importer/RawJsonFactory.h b/soh/soh/resource/importer/RawJsonFactory.h deleted file mode 100644 index d5fa656b6..000000000 --- a/soh/soh/resource/importer/RawJsonFactory.h +++ /dev/null @@ -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 ReadResource(std::shared_ptr file) override; -}; -}; // namespace SOH diff --git a/soh/soh/resource/type/RawJson.cpp b/soh/soh/resource/type/RawJson.cpp deleted file mode 100644 index 3022a67ef..000000000 --- a/soh/soh/resource/type/RawJson.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "RawJson.h" - -namespace SOH { -RawJson::RawJson() : Resource(std::shared_ptr()) { -} - -void* RawJson::GetPointer() { - return &Data; -} - -size_t RawJson::GetPointerSize() { - return DataSize * sizeof(char); -} -} // namespace SOH diff --git a/soh/soh/resource/type/RawJson.h b/soh/soh/resource/type/RawJson.h deleted file mode 100644 index 47e0323cc..000000000 --- a/soh/soh/resource/type/RawJson.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "resource/Resource.h" -#include - -namespace SOH { - -class RawJson : public LUS::Resource { - public: - using Resource::Resource; - - RawJson(); - - void* GetPointer() override; - size_t GetPointerSize() override; - - nlohmann::json Data; - size_t DataSize; -}; -}; // namespace SOH diff --git a/soh/soh/resource/type/SohResourceType.h b/soh/soh/resource/type/SohResourceType.h index 3ef4163fe..fdf39031e 100644 --- a/soh/soh/resource/type/SohResourceType.h +++ b/soh/soh/resource/type/SohResourceType.h @@ -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