chore: restructure sound curve loader to load generic 2D graphs instead

This commit is contained in:
Jan
2024-05-20 13:21:58 +02:00
parent fcb73347c2
commit 6f6a70c212
9 changed files with 307 additions and 271 deletions

View File

@ -0,0 +1,23 @@
#include "SoundCurveLoader.h"
#include "Parsing/Graph2D/Graph2DReader.h"
#include <format>
#include <iostream>
namespace sound_curve
{
std::unique_ptr<GenericGraph2D> LoadSoundCurve(const IAssetLoadingManager* manager, const std::string& soundCurveName)
{
auto* searchPath = manager->GetAssetLoadingContext()->m_raw_search_path;
const auto fileName = std::format("soundaliases/{}.vfcurve", soundCurveName);
const auto file = searchPath->Open(fileName);
if (!file.IsOpen())
{
std::cerr << std::format("Failed to open file for sound curve \"{}\"\n", soundCurveName);
return nullptr;
}
return graph2d::Read("sound curve", "SNDCURVE", *file.m_stream, fileName, soundCurveName);
}
} // namespace sound_curve

View File

@ -0,0 +1,11 @@
#pragma once
#include "AssetLoading/IAssetLoadingManager.h"
#include "Parsing/GenericGraph2D.h"
#include <memory>
namespace sound_curve
{
std::unique_ptr<GenericGraph2D> LoadSoundCurve(const IAssetLoadingManager* manager, const std::string& soundCurveName);
}