round_end_music.inc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #if defined __round_end_music_included
  2. #endinput
  3. #endif
  4. #define __round_end_music_included
  5. public SharedPlugin __pl_round_end_music = {
  6. name = "round-end-music",
  7. file = "round_end_music.smx",
  8. #if defined REQUIRE_PLUGIN
  9. required = 1,
  10. #else
  11. required = 0,
  12. #endif
  13. };
  14. methodmap MusicEntry < KeyValues {
  15. public MusicEntry() {
  16. return view_as<MusicEntry>(new KeyValues("music_entry"));
  17. }
  18. public void SetFilePath(const char[] filePath) {
  19. this.SetString("filepath", filePath);
  20. }
  21. public void GetFilePath(char[] buffer, int maxlen) {
  22. this.GetString("filepath", buffer, maxlen);
  23. }
  24. public void SetTitle(const char[] title) {
  25. this.SetString("title", title);
  26. }
  27. public void GetTitle(char[] buffer, int maxlen) {
  28. this.GetString("title", buffer, maxlen);
  29. }
  30. public void SetSource(const char[] source) {
  31. this.SetString("source", source);
  32. }
  33. public void GetSource(char[] buffer, int maxlen) {
  34. this.GetString("source", buffer, maxlen);
  35. }
  36. public bool HasFilePath(const char[] filePath) {
  37. char thisFilePath[PLATFORM_MAX_PATH];
  38. this.GetFilePath(thisFilePath, sizeof(thisFilePath));
  39. return StrEqual(thisFilePath, filePath);
  40. }
  41. public bool Equals(MusicEntry other) {
  42. char otherFilePath[PLATFORM_MAX_PATH];
  43. other.GetFilePath(otherFilePath, sizeof(otherFilePath));
  44. return this.HasFilePath(otherFilePath);
  45. }
  46. }
  47. /**
  48. * Adds a song to the Round End Music plugin's queued playlist.
  49. * This function can only be called during REM_RegisterSource.
  50. *
  51. * @param song A song to add. This handle is cloned, so you will also need to close your
  52. * copy of the handle.
  53. *
  54. * @return True if adding the song was successful, false if not (playlist full or song
  55. * with same filepath is already queued).
  56. */
  57. native bool REM_AddSong(MusicEntry song);
  58. /**
  59. * Returns the maximum number of songs that can be played on this map. Has the correct number
  60. * after OnAutoConfigsBuffered, but you'll probably only end up using it in an OnSongsRequested
  61. * callback.
  62. */
  63. native int REM_GetActiveSongCount();
  64. /**
  65. * Returns whether or not the song's file path exists in the played songs list.
  66. *
  67. * A song is recently played if it was already played on the current map (i.e., the first time
  68. * it was played since being queued). A song is considered played after OnRoundEndMusicPlayed
  69. * is done being called, so you can determine if it was recently played through that forward.
  70. */
  71. native bool REM_SongWasRecentlyPlayed(MusicEntry song);
  72. /**
  73. * Called when a song is about to be played.
  74. *
  75. * @param song The KeyValues data for the song about to be played.
  76. *
  77. * @return Plugin_Continue for default song playback, Plugin_Handled if another plugin
  78. * handled the playback, Plugin_Stop if the song should not be considered
  79. * played.
  80. */
  81. forward Action OnRoundEndMusicWillPlay(MusicEntry song);
  82. /**
  83. * Called when a song has been played (or playback is handled by another plugin).
  84. */
  85. forward void OnRoundEndMusicPlayed(MusicEntry song);
  86. /**
  87. * Called when the Round End Music plugin is available and in need of songs.
  88. */
  89. forward void OnRoundEndSongsRequested();