public void Stop() { if (CurrentSound == null || CurrentSound.Sound == null) { return; } // Get stopped position var stPair = SoundFileTimePairs.Find(s => s.SoundFile == CurrentSound); stoppedPositionStation = stPair.StartTime + CurrentSound.PlayPosition(); lastPlayedTime = DateTime.Now; lastPlayedSoundIndex = SoundFileTimePairs.IndexOf(stPair); stoppedPositionSound = CurrentSound.PlayPosition(); // Set name in wheel to just the station name WheelCategoryItem radioWheelItem = corrWheelCat.ItemList[0]; radioWheelItem.Name = Name; //CurrentSound.StopSound(); CurrentSoundIsPaused = true; CurrentSound = null; Function.Call(Hash.SET_AUDIO_FLAG, "DisableFlightMusic", false); Function.Call(Hash.SET_AUDIO_FLAG, "DisableWantedMusic", false); }
private void UpdateWheelInfo() { if (CurrentSound == null || CurrentSound.Sound == null) { return; } WheelCategoryItem radioWheelItem = corrWheelCat.ItemList[0]; radioWheelItem.Name = Name + "\n" + CurrentSound.DisplayName; }
/// <summary> /// Called when the player selects a new category / item. /// </summary> /// <param name="sender"></param> /// <param name="selectedCategory"></param> /// <param name="selectedItem"></param> private void OnWheelClose(Wheel sender, WheelCategory selectedCategory, WheelCategoryItem selectedItem) { // Get the selected tech. var selectedTech = (Tech)selectedItem.Tag; // Make sure this item is tied to some tech. if (selectedTech == null) { return; } foreach (var categorySlot in _slots) { if (categorySlot.ID == selectedCategory.ID) { SetTech(selectedTech, ref categorySlot.m_ActivateTech); } } }
/// <summary> /// Generates a category from the specified tech (the categoryItem tags will be a pointer to the tech). /// </summary> /// <param name="categoryName"></param> /// <param name="tech"></param> /// <returns></returns> private static WheelCategory GenerateCategory(int catID, string categoryName, List <Tech> tech) { // Keep a cache of our categories. var c = new WheelCategory(categoryName) { ID = catID }; // Loop through each tech object. foreach (var t in tech) { // Add the wheel category item. var categoryItem = new WheelCategoryItem(t.Name, t.Description) { // Set the tag to our tech item. Tag = t }; // Add the category item. c.AddItem(categoryItem); } return(c); }
public void SetupRadio() { // Get folders in script's main folder "Custom Radio Stations" string[] wheelDirectories = Directory.GetDirectories(mainPath, "*", SearchOption.TopDirectoryOnly); foreach (var wheelDir in wheelDirectories) { Logger.Log("Loading " + wheelDir); Logger.Log("Checking if " + wheelDir + "\\settings.ini exists"); var wheelIni = Config.LoadWheelINI(wheelDir); // Create wheel obj Wheel radioWheel = new Wheel("Radio Wheel", wheelDir, 0, 0, new System.Drawing.Size(wheelIni.iconX, wheelIni.iconY), 200, wheelIni.wheelRadius); // Get folders in script's main folder "Custom Radio Stations" string[] stationDirectories = Directory.GetDirectories(wheelDir, "*", SearchOption.TopDirectoryOnly); Logger.Log("Number of stations: " + stationDirectories.Count()); // Specify file extensions to search for in the next step var extensions = new List <string> { ".mp3", ".wav", ".flac", ".lnk" }; // Keep count of the number of station folders with actual music files int populatedStationCount = 0; // Generate wheel categories for each folder, which will be our individual stations on the wheel foreach (var stationDir in stationDirectories) { Logger.Log("Loading " + stationDir); // Get all files that have the above-mentioned extensions. var musicFilePaths = Directory.GetFiles(stationDir, "*.*", SearchOption.TopDirectoryOnly) .Where(x => extensions.Contains(Path.GetExtension(x))); // Don't make a station out of an empty folder if (musicFilePaths.Count() == 0) { Logger.Log("Skipping " + Path.GetFileName(stationDir) + " as there are no music files."); continue; } // Increase count populatedStationCount++; WheelCategory stationCat = new WheelCategory(Path.GetFileName(stationDir)); radioWheel.AddCategory(stationCat); WheelCategoryItem stationItem = new WheelCategoryItem(stationCat.Name); stationCat.AddItem(stationItem); RadioStation station = new RadioStation(stationCat, musicFilePaths); // Add wheel category-station combo to a station list StationWheelPair pair = new StationWheelPair(radioWheel, stationCat, station); StationWheelPair.List.Add(pair); // Get description pair.LoadStationINI(Path.Combine(stationDir, "station.ini")); radioWheel.OnCategoryChange += (sender, selectedCategory, selectedItem, wheelJustOpened) => { // HandleRadioWheelToggle() handles what happens when the wheel is opened. // So we will only use this anonymous method for when the station is actually changed. //if (wheelJustOpened) return; if (selectedCategory == stationCat) { // If there is no input for a short amount of time, set the selected station as next to play ActionQueued = ActionOptions.PlayQueued; RadioStation.NextQueuedStation = station; // If radio is still being decided, add delay before station changes SetActionDelay(Config.WheelActionDelay); lastRadioWasCustom = true; } }; radioWheel.OnItemChange += (sender, selectedCategory, selectedItem, wheelJustOpened, goTo) => { if (wheelJustOpened) { return; } if (radioWheel.Visible && radioWheel == WheelVars.CurrentRadioWheel && WheelVars.NextQueuedWheel == null) { if (goTo == GoTo.Next) { radioWheel.Visible = false; WheelVars.NextQueuedWheel = WheelVars.RadioWheels.GetNext(radioWheel); } else if (goTo == GoTo.Prev) { radioWheel.Visible = false; WheelVars.NextQueuedWheel = WheelVars.RadioWheels.GetPrevious(radioWheel); } } }; } if (populatedStationCount > 0) { WheelVars.RadioWheels.Add(radioWheel); radioWheel.Origin = new Vector2(0.5f, 0.45f); radioWheel.SetCategoryBackgroundIcons(iconBgPath, Config.IconBG, Config.IconBgSizeMultiple, iconhighlightPath, Config.IconHL, Config.IconHlSizeMultiple); radioWheel.CalculateCategoryPlacement(); } Logger.Log(@"/\/\/\/\/\/\/\/\/\/\/\/\/\/\"); } if (WheelVars.RadioWheels.Count > 0) { WheelVars.CurrentRadioWheel = WheelVars.RadioWheels[0]; } else { UI.ShowSubtitle("No music found in Custom Radio Stations. " + "Please add music and reload script with the INS key."); Logger.Log("ERROR: No music found in any station directory. Aborting script..."); Tick -= OnTick; } }
private void OnWheelOpen(Wheel sender, WheelCategory selectedCategory, WheelCategoryItem selectedItem) { AudioPlayer.PlaySound(AudioPlayer.MainPath + "Karen Hello.wav", 1f); _wheel.OnWheelOpen -= OnWheelOpen; }