1 /***************************************************************************** 2 * Copyright (c) 2014-2019 OpenRCT2 developers 3 * 4 * For a complete list of all authors, please refer to contributors.md 5 * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 6 * 7 * OpenRCT2 is licensed under the GNU General Public License version 3. 8 *****************************************************************************/ 9 10 #pragma once 11 12 #include "Object.h" 13 14 #include <string> 15 #include <vector> 16 17 class MusicObjectTrack 18 { 19 public: 20 std::string Name; 21 std::string Composer; 22 ObjectAsset Asset; 23 24 /** 25 * The number of PCM bytes to seek per game tick when the music is playing offscreen. 26 */ 27 size_t BytesPerTick; 28 29 /** 30 * The length of the PCM track in bytes. 31 */ 32 size_t Size; 33 }; 34 35 class MusicObject final : public Object 36 { 37 private: 38 std::vector<uint8_t> _rideTypes; 39 std::vector<MusicObjectTrack> _tracks; 40 std::optional<uint8_t> _originalStyleId; 41 42 public: 43 rct_string_id NameStringId{}; 44 45 void ReadJson(IReadObjectContext* context, json_t& root) override; 46 void Load() override; 47 void Unload() override; 48 49 void DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int32_t height) const override; 50 51 std::optional<uint8_t> GetOriginalStyleId() const; 52 bool SupportsRideType(uint8_t rideType); 53 size_t GetTrackCount() const; 54 const MusicObjectTrack* GetTrack(size_t trackIndex) const; 55 56 private: 57 void ParseRideTypes(const json_t& jRideTypes); 58 void ParseTracks(IReadObjectContext& context, json_t& jTracks); 59 static ObjectAsset GetAsset(IReadObjectContext& context, std::string_view path); 60 }; 61