round_end_music.inc 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. }
  37. typedef OnSongsRequested = function void ();
  38. /**
  39. * Register a function in this plugin as a music source.
  40. *
  41. * @param callback A function called whenever music is requested.
  42. */
  43. native void REM_RegisterSource(OnSongsRequested callback);
  44. /**
  45. * Adds a song to the Round End Music plugin's queued playlist.
  46. * This function can only be called during REM_RegisterSource.
  47. *
  48. * @param song A song to add. This handle is cloned, so you will also need to close your
  49. * copy of the handle.
  50. *
  51. * @return True if adding the song was successful, false if not (playlist full or song
  52. * with same filepath is already queued).
  53. */
  54. native bool REM_AddSong(MusicEntry song);
  55. /**
  56. * Returns the maximum number of songs that can be played on this map. Has the correct number
  57. * after OnAutoConfigsBuffered, but you'll probably only end up using it in an OnSongsRequested
  58. * callback.
  59. */
  60. native int REM_GetActiveSongCount();
  61. /**
  62. * Called when a song is about to be played.
  63. *
  64. * @param song The KeyValues data for the song about to be played.
  65. *
  66. * @return Plugin_Continue for default song playback, Plugin_Handled if another plugin
  67. * handled the playback, Plugin_Stop if the song should not be considered
  68. * played.
  69. */
  70. forward Action OnRoundEndMusicWillPlay(MusicEntry song);
  71. /**
  72. * Called when a song has been played (or playback is handled by another plugin).
  73. */
  74. forward void OnRoundEndMusicPlayed(MusicEntry song);