Browse Source

Added sample song provider

Added a simple implementation of a song provider.  Will be updated when
more features are available.
nosoop 8 years ago
parent
commit
c424891bc9
1 changed files with 65 additions and 0 deletions
  1. 65 0
      scripting/round_end_music_sample_provider.sp

+ 65 - 0
scripting/round_end_music_sample_provider.sp

@@ -0,0 +1,65 @@
+/**
+ * Round End Music: Sample Sources
+ * 
+ * An example plugin showing how to add songs to the Round End Music playlist.
+ */
+#pragma semicolon 1
+#include <sourcemod>
+
+#pragma newdecls required
+#include <round_end_music>
+
+#define PLUGIN_VERSION "0.0.1"
+public Plugin myinfo = {
+    name = "Round End Music: Sample Source",
+    author = "nosoop",
+    description = "Loads hard-coded music entries.  Mostly for testing.",
+    version = PLUGIN_VERSION,
+    url = "https://pika.nom-nom-nom.us/"
+}
+
+char SONGS[][][] = {
+	{ "You're at the Party", "Lemon Demon", "nomnomnomsongs/pikapoo/attheparty.mp3" },
+	{ "Come on Down", "The Price is Right", "nomnomnomsongs/tpir.mp3" },
+	{ "1812 Overture", "Tchaikovsky", "nomnomnomsongs/1812.mp3" },
+	{ "Back to the Future", "The Outatime Orchestra", "nomnomnomsongs/bttf.mp3" },
+	{ "Blinded by Light", "Final Fantasy 13", "nomnomnomsongs/blindedbylight.mp3" },
+	{ "Yatta!", "Green Leaves", "nomnomnomsongs/yatta.mp3" },
+};
+
+public void HardcodedArrayMusicSource() {
+	for (int i = 0; i < sizeof(SONGS); i++) {
+		MusicEntry entry = GenerateSong(SONGS[i][0], SONGS[i][1], SONGS[i][2]);
+		
+		if (!REM_AddSong(entry)) {
+			PrintToServer("[rem-sample] Song %s is already queued.", SONGS[i][2]);
+		}
+		delete entry;
+	}
+	
+	PrintToServer("Songs requested");
+}
+
+MusicEntry GenerateSong(const char[] title, const char[] source, const char[] filePath) {
+	MusicEntry song = new MusicEntry();
+	song.SetTitle(title);
+	song.SetSource(source);
+	song.SetFilePath(filePath);
+	return song;
+}
+
+void OnRoundEndMusicAvailable() {
+	REM_RegisterSource(HardcodedArrayMusicSource);
+}
+
+public void OnAllPluginsLoaded() {
+	if (LibraryExists("round-end-music")) {
+		OnRoundEndMusicAvailable();
+	}
+}
+
+public void OnLibraryAdded(const char[] name) {
+	if (StrEqual(name, "round-end-music")) {
+		OnRoundEndMusicAvailable();
+	}
+}