Пример #1
0
            private static bool Prefix(SongSelect __instance, string response)

            {
                if (MenuState.GetState() == MenuState.State.Launched)
                {
                    return(false);
                }
                return(true);
            }
Пример #2
0
        public override void OnUpdate()
        {
            //Tracking menu state
            menuState = MenuState.GetState();

            //If menu changes
            if (menuState != oldMenuState)
            {
                //Updating state
                oldMenuState = menuState;

                //Put stuff to do when a menu change triggers here

                //Doing this in an effort to call this the less often possible.
                //It doesn't work at boot so going it at a menu change is reasonable I guess
                starThresholds = UnityEngine.Object.FindObjectOfType <StarThresholds>();
            }
        }
        public static void ProcessQueue()
        {
            bool addedAny = false;

            MelonLogger.Log(requestQueue.Count + " in queue.");

            if (requestQueue.Count != 0)
            {
                foreach (string str in requestQueue)
                {
                    QueryData         data   = new QueryData(str);
                    SongList.SongData result = SearchSong(data, out bool foundExactMatch);

                    if ((!hasCompatibleSongBrowser || foundExactMatch) && result != null)
                    {
                        // if we have web search we want to make sure we prioritize exact matches
                        // over partial local ones
                        MelonLogger.Log("Result: " + result.songID);
                        if (!requestList.Contains(result.songID))
                        {
                            requestList.Add(result.songID);
                            addedAny = true;
                        }
                    }
                    else if (hasCompatibleSongBrowser)
                    {
                        StartWebSearch(data);
                    }
                    else
                    {
                        MelonLogger.Log($"Found no match for \"{str}\"");
                    }
                }
                requestQueue.Clear();
            }

            if (addedAny && MenuState.GetState() == MenuState.State.SongPage)
            {
                RequestUI.UpdateFilter();
            }

            RequestUI.UpdateButtonText();
        }
Пример #4
0
        public override void OnUpdate()
        {
            //Tracking menu state
            menuState = MenuState.GetState();

            //If menu changes
            if (menuState != oldMenuState)
            {
                //Put stuff to do when a menu change triggers here
                if (menuState == MenuState.State.Launching)
                {
                    chainStartEither = false;
                    chainStartRight  = false;
                    chainStartLeft   = false;
                    chainStartNone   = false;
                }

                //Updating state
                oldMenuState = menuState;
            }
        }
Пример #5
0
        /// <summary>
        /// Makes sure the Song and Party buttons are only available if there is not currently
        /// an ongoing song search.
        /// </summary>
        public static void UpdateUI()
        {
            if (!Config.SafeSongListReload)
            {
                return;
            }
            if ((!searching || disabled || MenuState.GetState() != MenuState.State.MainPage) && !PlaylistDownloadManager.IsDownloadingMissing)
            {
                return;
            }

            disabled = true;

            if (soloButton == null)
            {
                soloButton      = GameObject.Find("menu/ShellPage_Main/page/ShellPanel_Center/Solo/Button").GetComponent <GunButton>();
                soloButtonLabel = GameObject.Find("menu/ShellPage_Main/page/ShellPanel_Center/Solo/Label").GetComponent <TextMeshPro>();
                GameObject.Destroy(soloButtonLabel.gameObject.GetComponent <Localizer>());
            }
            originalSoloButtonText = soloButtonLabel.text;
            soloButtonLabel.text   = "Loading...";
            soloButton.SetInteractable(false);

            if (!SongBrowser.modSettingsInstalled)
            {
                if (partyButton == null)
                {
                    partyButton      = GameObject.Find("menu/ShellPage_Main/page/ShellPanel_Center/Party/Button").GetComponent <GunButton>();
                    partyButtonLabel = GameObject.Find("menu/ShellPage_Main/page/ShellPanel_Center/Party/Label").GetComponent <TextMeshPro>();
                    GameObject.Destroy(partyButtonLabel.gameObject.GetComponent <Localizer>());
                }
                originalPartyButtonText = partyButtonLabel.text;
                partyButtonLabel.text   = "Loading...";
                partyButton.SetInteractable(false);
            }
        }
Пример #6
0
        public override void OnUpdate()
        {
            //Tracking menu state
            menuState = MenuState.GetState();

            //If menu changes
            if (menuState != oldMenuState)
            {
                //Put stuff to do when a menu change triggers here
                if (menuState == MenuState.State.LaunchPage)
                {
                    MelonCoroutines.Start(GameplaySettingsMenuCoroutine());
                }

                if (oldMenuState == MenuState.State.LaunchPage)
                {
                    SP.SetPageActive(false, true);
                }


                //Updating state
                oldMenuState = menuState;
            }

            /*
             * if (Input.GetKey(KeyCode.F6))
             * {
             *  MelonCoroutines.Start(GameplaySettingsMenuCoroutine());
             * }
             *
             * if (Input.GetKey(KeyCode.F4))
             * {
             *  SP.SetPageActive(false, true);
             * }
             */
        }
Пример #7
0
        public override void OnUpdate()
        {
            //Tracking menu state
            menuState = MenuState.GetState();

            //If menu changes
            if (menuState != oldMenuState)
            {
                MelonLogger.Log("Menu: " + menuState.ToString());

                if (menuState == MenuState.State.MainPage)
                {
                    CheckCamera();
                }

                if (menuState == MenuState.State.LaunchPage)
                {
                    scriptExists = LoadCameraCues();
                }

                if (menuState == MenuState.State.Launched && !KataConfig.I.practiceMode)
                {
                    if (scriptExists)
                    {
                        LoadFOV();
                    }

                    Camera thirdPersonCam = spectatorCam.cam;
                    startPointPos = thirdPersonCam.gameObject.transform.position;
                    startPointRot = thirdPersonCam.gameObject.transform.rotation.eulerAngles;
                }

                if (oldMenuState == MenuState.State.Launched && menuState == MenuState.State.SongPage)
                {
                    SetFOV(fovSetting);
                }

                oldMenuState = menuState;
            }

            //If playing a song
            if (menuState == MenuState.State.Launched && !KataConfig.I.practiceMode)
            {
                //Update midi tick
                lastTick = ScoreKeeper.I.mLastTick;

                if (lastTick != oldLastTick)
                {
                    if (camOK && scriptExists)
                    {
                        Camera    thirdPersonCam = spectatorCam.cam;
                        CameraCue cameraCue      = cameraCues[currentCameraCueIndex];

                        if (!ended && lastTick >= cameraCue.tick && timer <= cameraCue.tickLength && lastTick <= cameraCue.tick + cameraCue.tickLength)
                        {
                            timer  += lastTick - oldLastTick;
                            percent = timer / cameraCue.tickLength;

                            Vector3 destinationPos = new Vector3(cameraCue.xPos, cameraCue.yPos, cameraCue.zPos);
                            thirdPersonCam.gameObject.transform.position = startPointPos + (destinationPos - startPointPos) * percent;

                            Vector3 destinationRot = new Vector3(cameraCue.xRot, cameraCue.yRot, cameraCue.zRot);
                            thirdPersonCam.gameObject.transform.rotation = Quaternion.Euler(
                                startPointRot.y + (destinationRot.y - startPointRot.y) * percent,
                                startPointRot.x + (destinationRot.x - startPointRot.x) * percent,
                                startPointRot.z + (destinationRot.z - startPointRot.z) * percent
                                );
                        }

                        if (!ended && lastTick >= cameraCue.tick + cameraCue.tickLength)
                        {
                            if (timer != 0)
                            {
                                Vector3 destinationPos = new Vector3(cameraCue.xPos, cameraCue.yPos, cameraCue.zPos);
                                thirdPersonCam.gameObject.transform.position = destinationPos;

                                Vector3 destinationRot = new Vector3(cameraCue.xRot, cameraCue.yRot, cameraCue.zRot);
                                thirdPersonCam.gameObject.transform.rotation = Quaternion.Euler(destinationRot.y, destinationRot.x, destinationRot.z);

                                startPointPos = thirdPersonCam.gameObject.transform.position;
                                startPointRot = thirdPersonCam.gameObject.transform.rotation.eulerAngles;
                                timer         = 0;

                                if (cameraCues.Length > currentCameraCueIndex + 1)
                                {
                                    currentCameraCueIndex += 1;
                                }
                                else
                                {
                                    ended = true;
                                }
                            }
                        }
                    }
                    oldLastTick = lastTick;
                }
            }

            if (Input.GetKeyDown(KeyCode.R))
            {
                Camera  thirdPersonCam = spectatorCam.cam;
                Vector3 homePos        = new Vector3(0.0f, 2.4f, -2.6f);
                thirdPersonCam.gameObject.transform.position = homePos;
            }

            if (Input.GetKeyDown(KeyCode.T))
            {
                Camera  thirdPersonCam = spectatorCam.cam;
                Vector3 homePos        = new Vector3(0.0f, 2.4f, 22.4f);
                thirdPersonCam.gameObject.transform.position = homePos;
            }

            if (Input.GetKeyDown(KeyCode.Y))
            {
                Camera  thirdPersonCam = spectatorCam.cam;
                Vector3 homePos        = new Vector3(0.0f, 2.4f, -60.6f);
                thirdPersonCam.gameObject.transform.position = homePos;
            }

            if (Input.GetKeyDown(KeyCode.F))
            {
                Camera thirdPersonCam = spectatorCam.cam;

                Vector3 camPos = thirdPersonCam.gameObject.transform.position;
                MelonLogger.Log("Cam Pos: " + camPos.ToString());

                Vector3 euler = thirdPersonCam.gameObject.transform.rotation.eulerAngles;
                MelonLogger.Log("Cam Rot: " + euler.ToString());
            }
        }
        private static void ProcessWebSearchResult(string query, APISongList response)
        {
            QueryData data            = webSearchQueryData[query];
            bool      addedLocalMatch = false;

            if (response.song_count > 0)
            {
                Song bestMatch   = null;
                bool foundAny    = false;
                bool foundBetter = false;
                bool foundExact  = false;
                foreach (Song s in response.songs)
                {
                    if ((data.Artist == null || s.artist.ToLowerInvariant().Replace(" ", "").Contains(data.Artist)) &&
                        (data.Mapper == null || s.author.ToLowerInvariant().Replace(" ", "").Contains(data.Mapper)) &&
                        (s.title.ToLowerInvariant().Contains(data.Title) ||
                         s.song_id.ToLowerInvariant().Contains(data.Title.Replace(" ", ""))))
                    {
                        if (LookForMatch(data.Title, s.title, ref foundAny, ref foundBetter, ref foundExact))
                        {
                            bestMatch = s;
                            if (foundExact)
                            {
                                break;
                            }
                        }
                    }
                }
                if (bestMatch != null)
                {
                    // check if we already have that file downloaded
                    QueryData         matchData = new QueryData($"{bestMatch.title} -artist {bestMatch.artist} -mapper {bestMatch.author}");
                    SongList.SongData s         = SearchSong(matchData, out bool isExactMatch);
                    if (isExactMatch)
                    {
                        MelonLogger.Log("Result: " + s.songID);
                        if (!requestList.Contains(s.songID))
                        {
                            requestList.Add(s.songID);
                            addedLocalMatch = true;
                        }
                    }
                    else if (!missingSongs.ContainsKey(bestMatch.song_id))
                    {
                        missingSongs.Add(bestMatch.song_id, bestMatch);
                        MelonLogger.Log("Result (missing): " + bestMatch.song_id);
                    }
                }
                else
                {
                    MelonLogger.Log($"Found no match for \"{data.FullQuery}\"");
                }
            }
            else
            {
                // check if we have a local match (can happen if
                // this particular map hasn't been uploaded or was taken down)
                SongList.SongData s = SearchSong(data, out bool _);
                if (s != null)
                {
                    MelonLogger.Log("Result: " + s.songID);
                    if (!requestList.Contains(s.songID))
                    {
                        requestList.Add(s.songID);
                        addedLocalMatch = true;
                    }
                }
                else
                {
                    MelonLogger.Log($"Found no match for \"{data.FullQuery}\"");
                }
            }

            if (addedLocalMatch && MenuState.GetState() == MenuState.State.SongPage)
            {
                RequestUI.UpdateFilter();
            }

            webSearchQueryData.Remove(query);
            if (GetActiveWebSearchCount() == 0)
            {
                RequestUI.UpdateButtonText();
            }
        }