1 /** 2 * Copyright © Novelate 2020 3 * License: MIT (https://github.com/Novelate/NovelateEngine/blob/master/LICENSE) 4 * Author: Jacob Jensen (bausshf) 5 * Website: https://novelate.com/ 6 * ------ 7 * Novelate is a free and open-source visual novel engine and framework written in the D programming language. 8 * It can be used freely for both personal and commercial projects. 9 * ------ 10 * Module Description: 11 * This module handles music files. 12 */ 13 module novelate.music; 14 15 /// A music file. 16 final class NovelateMusic 17 { 18 private: 19 /// The name of the music file. 20 string _name; 21 /// The path of the music file. 22 string _path; 23 24 public: 25 final: 26 /** 27 * Creates a new music file. 28 * Params: 29 * name = The name of the music file. 30 * path = The path of the music file. 31 */ 32 this(string name, string path) 33 { 34 _name = name; 35 _path = path; 36 } 37 38 @property 39 { 40 /// Gets the name of the music file. 41 string name() { return _name; } 42 43 /// Gets the path of the music file. 44 string path() { return _path; } 45 } 46 } 47 48 /// The music file collection. 49 private NovelateMusic[string] _musicFiles; 50 51 /** 52 * Adds a music file to the music file collection. 53 * Params: 54 * name = The name of the music file. 55 * path = The path of the music file. 56 */ 57 void addMusicFile(string name, string path) 58 { 59 _musicFiles[name] = new NovelateMusic(name, path); 60 } 61 62 /** 63 * Gets a music file. 64 * Params: 65 * name = The name of the music file. 66 * Returns: 67 * The music file from the music file collection. 68 */ 69 NovelateMusic getMusicFile(string name) 70 { 71 return _musicFiles.get(name, null); 72 }