Example #1
0
        /*
         * Private methods
         */

        /// <summary>
        /// Raised after loading a save.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
        {
            //Monitor.Log("all heard:\t" + string.Join(", ",Game1.player.songsHeard.ToArray()));
            if (Config.PermanentUnheard)
            {
                // there was "don't repeat if already done"
                // but it's gone now (because i added permanent blacklist)

                if (Config.ShowUnheardTracks)
                {
                    BetterJukeboxHelper.AddUnheardTracks(
                        Game1.player.songsHeard,
                        Config.UnheardSoundtrack,
                        Config.UnheardNamed,
                        Config.UnheardRandom,
                        Config.UnheardMisc,
                        Config.UnheardDupes,
                        Config.UnheardMusical
                        );
                }

                //Game1.player.songsHeard.Remove("title_day"); // readded at every save load, so...
                int MTIndex = Game1.player.songsHeard.IndexOf("MainTheme");
                if (MTIndex.Equals(0) || MTIndex.Equals(-1))
                {
                }
                else
                {
                    Game1.player.songsHeard.RemoveAt(MTIndex);
                    Game1.player.songsHeard.Insert(0, "MainTheme");
                }

                Monitor.Log("permanentBlacklist: " + Config.PermanentBlacklist);
                Monitor.Log("permanentBlacklist converted: " + new FilterListConfig(Config.PermanentBlacklist));
                FilterListConfig blacklist = new FilterListConfig(Config.PermanentBlacklist);
                List <string>    toRemove  = blacklist.content.Distinct().ToList();
                if (toRemove.Count > 0)
                {
                    foreach (string cue in toRemove)
                    {
                        Game1.player.songsHeard.Remove(cue);
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Raised after a game menu is opened, closed, or replaced.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void OnMenuChanged(object sender, MenuChangedEventArgs e)
        {
            // replace ChooseFromListMenu (only used for jukeboxes as of 1.4) with BetterJukeboxMenu
            if (Config.ShowMenu &&
                e.NewMenu is ChooseFromListMenu &&
                Helper.Reflection.GetField <bool>(e.NewMenu, "isJukebox").GetValue() == true)
            {
                ChooseFromListMenu.actionOnChoosingListOption action =
                    Helper.Reflection.GetField <ChooseFromListMenu.actionOnChoosingListOption>(e.NewMenu, "chooseAction").GetValue();

                e.NewMenu.exitThisMenuNoSound(); // is this neccessary? is there a better way?

                // create default list of songs to play - apparently this is how CA hard-copied the list
                List <string> list = Game1.player.songsHeard.Distinct().ToList();

                // add unheard tracks
                if (Config.ShowUnheardTracks && !Config.PermanentUnheard)
                {
                    BetterJukeboxHelper.AddUnheardTracks(
                        list,
                        Config.UnheardSoundtrack,
                        Config.UnheardNamed,
                        Config.UnheardRandom,
                        Config.UnheardMisc,
                        Config.UnheardDupes,
                        Config.UnheardMusical
                        );
                }

                // remove specific tracks
                BetterJukeboxHelper.FilterTracksFromList(list, Config.AmbientTracks, Config.Blacklist, Config.Whitelist);

                list.Remove("title_day"); // this one gets removed for A Good Reason, apparently

                // this is the one change that isn't true to how the game does it, because it makes me angy >:L
                int MTIndex = list.IndexOf("MainTheme");
                // if permanent: not -1
                // if not permanent: -1
                // if in either blacklist: -1
                // impossible to tell directly, can't put into filtertracks because need to check both
                bool isMTPermanentBlacklisted = new FilterListConfig(Config.PermanentBlacklist).content.Contains("MainTheme");
                bool isMTRegularBlacklisted   = new FilterListConfig(Config.Blacklist).content.Contains("MainTheme");

                if (!isMTPermanentBlacklisted &&
                    !isMTRegularBlacklisted &&
                    !MTIndex.Equals(0))
                {
                    if (MTIndex.Equals(-1))
                    {
                    }
                    else
                    {
                        list.RemoveAt(MTIndex);
                    }
                    list.Insert(0, "MainTheme");
                }

                // speculative fix for Nexus page bug report
                list.Remove("resetVariable");


                // create and activate the menu
                Game1.activeClickableMenu = new BetterJukeboxMenu(
                    list,
                    new BetterJukeboxMenu.actionOnChoosingListOption(action),
                    Helper.Content.Load <Texture2D>(
                        "assets/BetterJukeboxGraphics.png",
                        ContentSource.ModFolder
                        ),
                    key => Helper.Translation.Get(key),
                    Monitor,
                    Config,
                    Game1.player.currentLocation.miniJukeboxTrack.Value
                    );
            }
        }