Engine, adapter and tools without game data

This commit is contained in:
CRTkafa 2026-10-11 08:53:04 +08:00
commit e2ede736f3
3500 changed files with 1640229 additions and 0 deletions

43
engine/audio/cadi_bank.h Normal file
View file

@ -0,0 +1,43 @@
#pragma once
#include "core/inflate.h"
#include <cstdint>
#include <span>
#include <string>
#include <string_view>
#include <optional>
#include <unordered_map>
#include <vector>
namespace choco {
enum class CadiKind { OggVorbis, Xml };
enum class CadiChannel { Sfx, Music, Environment };
struct CadiEventInfo {
std::vector<size_t> clips;
CadiChannel channel = CadiChannel::Sfx;
bool loop = false;
};
struct CadiRecord {
uint32_t token = 0; // opaque bank index value; Project URL maps through resource index order
uint32_t offset = 0;
uint32_t size = 0;
CadiKind kind = CadiKind::OggVorbis;
};
// Read-only parser for the bundled CADI audio bank; does not execute CadiApi.dll.
class CadiBank {
public:
bool load(Bytes bytes, std::string* error = nullptr);
const std::vector<CadiRecord>& records() const { return records_; }
std::span<const uint8_t> data(size_t index) const;
std::optional<size_t> clipForEvent(std::string_view event) const;
std::vector<size_t> clipsForEvent(std::string_view event) const;
std::optional<CadiEventInfo> eventInfo(std::string_view event) const;
size_t mappedEventCount() const { return eventClips_.size(); }
private:
Bytes bytes_;
std::vector<CadiRecord> records_;
std::unordered_map<std::string,CadiEventInfo> eventClips_;
};
} // namespace choco