コード例 #1
0
        public override void OnEnterWorld(Player player)
        {
            // When entering a world, we must setup the players music boxes and determine whether they can be played or not.
            // This is important wince we can change "Unlock all music boxes" in the configs while outside of a world.
            MusicPlayerUI musicPlayerUI = tMusicPlayer.MusicPlayerUI;

            if (tMusicPlayer.tMPConfig.StartWithSmall != tMusicPlayer.MusicPlayerUI.smallPanel)
            {
                tMusicPlayer.MusicPlayerUI.SwapPanelSize();
            }
            if (musicPlayerUI != null)
            {
                for (int i = 0; i < tMusicPlayer.AllMusic.Count; i++)
                {
                    if (MusicBoxList.Any(x => x.Type == tMusicPlayer.AllMusic[i].musicbox))
                    {
                        musicPlayerUI.canPlay.Add(tMusicPlayer.AllMusic[i].music);
                    }
                }

                /*
                 * if (tMusicPlayer.tMPConfig.EnableAllMusicBoxes) musicPlayerUI.canPlay[i] = true;
                 * else musicPlayerUI.canPlay[i] = MusicBoxList.Any(x => x.Type == tMusicPlayer.AllMusic[i].musicbox);
                 */
                // Remove above line if bringing back EnableAllMusicBoxes
            }
        }
コード例 #2
0
 public override void Unload()
 {
     tMPConfig            = null;
     HidePlayerHotkey     = null;
     PlayStopHotkey       = null;
     PrevSongHotkey       = null;
     NextSongHotkey       = null;
     MP_UserInterface     = null;
     MusicPlayerUI        = null;
     AllMusic             = null;
     itemToMusicReference = null;
 }
コード例 #3
0
        public override void OnChanged()
        {
            if (!Main.gameMenu)
            {
                MusicPlayerUI musicPlayerUI = tMusicPlayer.MusicPlayerUI;
                if (ResettingPanels)
                {
                    musicPlayerUI.MusicPlayerPanel.Left.Pixels = 500f;
                    musicPlayerUI.MusicPlayerPanel.Top.Pixels  = 6f;
                    musicPlayerUI.selectionPanel.Left.Pixels   = (Main.screenWidth / 2) - musicPlayerUI.selectionPanel.Width.Pixels / 2f;
                    musicPlayerUI.selectionPanel.Top.Pixels    = (Main.screenHeight / 2) - musicPlayerUI.selectionPanel.Height.Pixels / 2f;
                    musicPlayerUI.musicEntryPanel.Left.Pixels  = musicPlayerUI.selectionPanel.Left.Pixels + musicPlayerUI.selectionPanel.Width.Pixels - musicPlayerUI.musicEntryPanel.Width.Pixels - 10f;
                    musicPlayerUI.musicEntryPanel.Top.Pixels   = musicPlayerUI.selectionPanel.Top.Pixels - musicPlayerUI.musicEntryPanel.Height.Pixels;
                    ResettingPanels = false;
                }

                /*
                 * if (EnableAllMusicBoxes) {
                 *      for (int j = 0; j < musicPlayerUI.canPlay.Count; j++) {
                 *              musicPlayerUI.canPlay[j] = true;
                 *      }
                 *      tMusicPlayer.SendDebugText("EnableAllMusicBoxes enabled. All music in canPlay set to true.");
                 * }
                 * else {
                 *      MusicPlayerPlayer modPlayer = Main.LocalPlayer.GetModPlayer<MusicPlayerPlayer>();
                 *      for (int i = 0; i < musicPlayerUI.canPlay.Count; i++) {
                 *              musicPlayerUI.canPlay[i] = (modPlayer.MusicBoxList.FindIndex((ItemDefinition x) => x.Type == tMusicPlayer.AllMusic[i].musicbox) != -1);
                 *      }
                 *      Main.NewText("EnableAllMusicBoxes disabled. Music in canPlay restored appropriately", Color.White);
                 *      int next = tMusicPlayer.MusicPlayerUI.FindNextIndex();
                 *      int prev = tMusicPlayer.MusicPlayerUI.FindPrevIndex();
                 *      if (modPlayer.MusicBoxList.FindIndex((ItemDefinition x) => x.Type == tMusicPlayer.MusicPlayerUI.DisplayBox) == -1) {
                 *              if (next != -1) {
                 *                      tMusicPlayer.MusicPlayerUI.DisplayBox = next;
                 *              }
                 *              else if (prev != -1) {
                 *                      tMusicPlayer.MusicPlayerUI.DisplayBox = prev;
                 *              }
                 *              else {
                 *                      musicPlayerUI.listening = true;
                 *              }
                 *      }
                 * }
                 */
            }
        }
コード例 #4
0
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            CalculatedStyle innerDimensions = GetInnerDimensions();
            Rectangle       hitbox          = innerDimensions.ToRectangle();
            //base.DrawSelf(spriteBatch);
            Texture2D searchbar = ModContent.GetTexture("tMusicPlayer/UI/search");

            spriteBatch.Draw(searchbar, GetDimensions().Position(), Color.White);
            if (ContainsPoint(Main.MouseScreen) && !PlayerInput.IgnoreMouseInterface)
            {
                Main.LocalPlayer.mouseInterface = true;
            }
            if (focused)
            {
                PlayerInput.WritingText = true;
                Main.instance.HandleIME();
                string newString = Main.GetInputText(currentString);
                if (Main.fontMouseText.MeasureString(newString.ToLower()).X < Width.Pixels - 10f)
                {
                    if (!newString.Equals(currentString))
                    {
                        currentString = newString.ToLower();
                    }
                    else
                    {
                        currentString = newString.ToLower();
                    }
                    MusicPlayerUI ui = tMusicPlayer.MusicPlayerUI;
                    if (currentString.Length > 0)
                    {
                        List <MusicData> musicData = new List <MusicData>();
                        foreach (MusicData item in tMusicPlayer.AllMusic.ToArray())
                        {
                            if (item.name.ToLower().Contains(currentString))
                            {
                                musicData.Add(item);
                            }
                        }
                        ui.musicData = musicData;
                        ui.OrganizeSelection(ui.sortType, ui.availabililty, ui.FilterMod);
                    }
                    else
                    {
                        ui.OrganizeSelection(ui.sortType, ui.availabililty, ui.FilterMod);
                    }
                }
                if (JustPressed(Keys.Tab) || JustPressed(Keys.Escape))
                {
                    Unfocus();
                }
                if (JustPressed(Keys.Enter))
                {
                    Main.drawingPlayerChat = false;
                    Unfocus();
                }
                if (++textBlinkerCount >= 20)
                {
                    textBlinkerState = (textBlinkerState + 1) % 2;
                    textBlinkerCount = 0;
                }
                Main.instance.DrawWindowsIMEPanel(new Vector2(198f, Main.screenHeight - 36), 0f);
            }
            string displayString = currentString;

            if (textBlinkerState == 1 && focused)
            {
                displayString += "|";
            }
            Color   color2  = Color.White;
            Vector2 drawPos = GetDimensions().Position() + new Vector2(32f, 3f);

            if (currentString.Length == 0 && !focused)
            {
                color2 *= 0.6f;
                DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, Main.fontMouseText, hintText, drawPos, color2);
            }
            else
            {
                color2 *= 0.8f;
                DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, Main.fontMouseText, displayString, drawPos, color2);
            }
        }
コード例 #5
0
        public override void Load()
        {
            // Setup hotkeys and the configs instance.
            tMPConfig        = ModContent.GetInstance <TMPConfig>();
            HidePlayerHotkey = RegisterHotKey("Hide Music Player", "Up");
            PlayStopHotkey   = RegisterHotKey("Play/Stop Music", "Down");
            PrevSongHotkey   = RegisterHotKey("Previous Song", "Left");
            NextSongHotkey   = RegisterHotKey("Next Song", "Right");

            // Register this mods music boxes.
            // TODO: [1.4] Remove music boxes. The 1.4 update reimplements the console music.
            if (!Main.dedServ)
            {
                AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/ConsoleSpace"), ModContent.ItemType <Items.MusicBoxConsoleSpace>(), ModContent.TileType <Tiles.MusicBoxConsoleSpace>());
                AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/ConsoleOcean"), ModContent.ItemType <Items.MusicBoxConsoleOcean>(), ModContent.TileType <Tiles.MusicBoxConsoleOcean>());
                AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/ConsoleTitle"), ModContent.ItemType <Items.MusicBoxConsoleTitle>(), ModContent.TileType <Tiles.MusicBoxConsoleTitle>());
                AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/ConsoleTutorial"), ModContent.ItemType <Items.MusicBoxConsoleTutorial>(), ModContent.TileType <Tiles.MusicBoxConsoleTutorial>());
            }

            // A list that contains all the MusicData we need, including mod and name.
            // TODO: [1.4] Reorder boxes based on progression? Maybe grab info from bosschecklist in the future?
            AllMusic = new List <MusicData>
            {
                new MusicData(MusicID.OverworldDay, ItemID.MusicBoxOverworldDay),
                new MusicData(MusicID.AltOverworldDay, ItemID.MusicBoxAltOverworldDay),
                new MusicData(MusicID.Night, ItemID.MusicBoxNight),
                new MusicData(MusicID.Rain, ItemID.MusicBoxRain),
                new MusicData(MusicID.Snow, ItemID.MusicBoxSnow),
                new MusicData(MusicID.Ice, ItemID.MusicBoxIce),
                new MusicData(MusicID.Desert, ItemID.MusicBoxDesert),
                new MusicData(MusicID.Ocean, ItemID.MusicBoxOcean),
                new MusicData(MusicID.Space, ItemID.MusicBoxSpace),
                new MusicData(MusicID.Underground, ItemID.MusicBoxUnderground),
                new MusicData(MusicID.AltUnderground, ItemID.MusicBoxAltUnderground),
                new MusicData(MusicID.Mushrooms, ItemID.MusicBoxMushrooms),
                new MusicData(MusicID.Jungle, ItemID.MusicBoxJungle),
                new MusicData(MusicID.Corruption, ItemID.MusicBoxCorruption),
                new MusicData(MusicID.UndergroundCorruption, ItemID.MusicBoxUndergroundCorruption),
                new MusicData(MusicID.Crimson, ItemID.MusicBoxCrimson),
                new MusicData(MusicID.UndergroundCrimson, ItemID.MusicBoxUndergroundCrimson),
                new MusicData(MusicID.TheHallow, ItemID.MusicBoxTheHallow),
                new MusicData(MusicID.UndergroundHallow, ItemID.MusicBoxUndergroundHallow),
                new MusicData(MusicID.Hell, ItemID.MusicBoxHell),
                new MusicData(MusicID.Dungeon, ItemID.MusicBoxDungeon),
                new MusicData(MusicID.Temple, ItemID.MusicBoxTemple),
                new MusicData(MusicID.Boss1, ItemID.MusicBoxBoss1),
                new MusicData(MusicID.Boss2, ItemID.MusicBoxBoss2),
                new MusicData(MusicID.Boss3, ItemID.MusicBoxBoss3),
                new MusicData(MusicID.Boss4, ItemID.MusicBoxBoss4),
                new MusicData(MusicID.Boss5, ItemID.MusicBoxBoss5),
                new MusicData(MusicID.Plantera, ItemID.MusicBoxPlantera),
                new MusicData(MusicID.Eerie, ItemID.MusicBoxEerie),
                new MusicData(MusicID.Eclipse, ItemID.MusicBoxEclipse),
                new MusicData(MusicID.GoblinInvasion, ItemID.MusicBoxGoblins),
                new MusicData(MusicID.PirateInvasion, ItemID.MusicBoxPirates),
                new MusicData(MusicID.MartianMadness, ItemID.MusicBoxMartians),
                new MusicData(MusicID.PumpkinMoon, ItemID.MusicBoxPumpkinMoon),
                new MusicData(MusicID.FrostMoon, ItemID.MusicBoxFrostMoon),
                new MusicData(MusicID.TheTowers, ItemID.MusicBoxTowers),
                new MusicData(MusicID.LunarBoss, ItemID.MusicBoxLunarBoss),
                new MusicData(MusicID.Sandstorm, ItemID.MusicBoxSandstorm),
                new MusicData(MusicID.OldOnesArmy, ItemID.MusicBoxDD2),
                new MusicData(MusicID.Title, ItemID.MusicBoxTitle)
            };

            // Code provided by Jopojelly. Thank you, Jopo!
            // This grabs the entire dictionary of MODDED music-to-musicbox correlations.
            FieldInfo field = typeof(SoundLoader).GetField("itemToMusic", BindingFlags.Static | BindingFlags.NonPublic);

            itemToMusicReference = (Dictionary <int, int>)field.GetValue(null);

            // Setup the Music Player UI.
            if (!Main.dedServ)
            {
                MusicPlayerUI = new MusicPlayerUI();
                MusicPlayerUI.Activate();
                MP_UserInterface = new UserInterface();
                MP_UserInterface.SetState(MusicPlayerUI);
            }
        }