コード例 #1
0
 public WheelCaptureViewModel()
 {
     _service         = new WheelCaptureService();
     _categories      = _service.CategoryList;
     _unknownCategory = GetOrAddCategory("Unknown");
     _words           = new ObservableCollection <Word>(_service.WordList.Select(w => new Word(GetCategoryName(w.CategoryID), w.Word)));
     _analyzer        = new PuzzleAnalyzer(_words);
     _parser          = new WebSocketMessageParser(this);
 }
コード例 #2
0
        /// <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);
                }
            }
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
        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;
            }
        }
コード例 #5
0
 private void OnWheelOpen(Wheel sender, WheelCategory selectedCategory, WheelCategoryItem selectedItem)
 {
     AudioPlayer.PlaySound(AudioPlayer.MainPath + "Karen Hello.wav", 1f);
     _wheel.OnWheelOpen -= OnWheelOpen;
 }
コード例 #6
0
        public RadioStation(WheelCategory correspondingWheelCategory, IEnumerable <string> songFilesPaths)
        {
            corrWheelCat       = correspondingWheelCategory;
            Name               = corrWheelCat.Name;
            SoundFileTimePairs = new List <SoundFileTimePair>();
            List <Tuple <string, string> > commercials = new List <Tuple <string, string> >();

            foreach (var path in songFilesPaths)
            {
                try
                {
                    //Logger.Log(path.Substring(path.LastIndexOf('\\') + 1));
                    // If file is a shortcut, get the real path first
                    if (Path.GetExtension(path) == ".lnk")
                    {
                        string str = GeneralHelper.GetShortcutTargetFile(path);

                        if (str == string.Empty)
                        {
                            continue;
                        }

                        if (Path.GetFileNameWithoutExtension(str).Contains("[Commercial]") ||
                            Path.GetFileNameWithoutExtension(path).Contains("[Commercial]"))
                        {
                            commercials.Add(Tuple.Create(str, path));
                        }
                        else
                        {
                            SoundFileTimePairs.Add(new SoundFileTimePair(new SoundFile(str, path), 0));
                        }
                    }
                    else
                    {
                        if (Path.GetFileNameWithoutExtension(path).Contains("[Commercial]"))
                        {
                            commercials.Add(Tuple.Create(path, string.Empty));
                        }
                        else
                        {
                            SoundFileTimePairs.Add(new SoundFileTimePair(new SoundFile(path), 0));
                        }
                    }

                    Config.LoadTick();
                }
                catch (Exception ex)
                {
                    Logger.Log("ERROR : " + path.Substring(path.LastIndexOf('\\') + 1) + " : " + ex.Message);
                    Script.Wait(500);
                }
            }

            ShuffleList(); // Do this based on an ini setting? Yes. TODO
            InsertCommercials(commercials);

            // Calculate lengths and stuff for the station
            // Replaced by UpdateRadioLengthWithCurrentSound()
            //foreach (var s in SoundFileTimePairs)
            //{
            //    s.StartTime = TotalLength;
            //    TotalLength += s.SoundFile.Length;
            //}
        }