Пример #1
0
        // Using the magical power of Zenject™, we magically find ourselves with an instance of
        // our HUDConfigModel and the CoreGameHUDController.
        internal CanvasUtility(HUDConfigModel hudConfig,
                               MainConfigModel mainConfig,
                               [Inject(Optional = true)] GameplayCoreSceneSetupData data,
                               [Inject(Optional = true)] CoreGameHUDController coreGameHUD)
        {
            this.mainConfig = mainConfig;
            if (coreGameHUD != null)
            {
                var comboPos = coreGameHUD.GetComponentInChildren <ComboUIController>().transform.position;

                hudWidth  = Mathf.Abs(comboPos.x);
                hudHeight = comboPos.y;
                hudDepth  = comboPos.z;

                energyCanvas = EnergyPanelGO(ref coreGameHUD).GetComponent <Canvas>();

                // Hide Canvas and Multiplier if needed
                if (mainConfig.HideCombo)
                {
                    HideBaseGameHUDElement <ComboUIController>(coreGameHUD);
                }
                if (mainConfig.HideMultiplier)
                {
                    HideBaseGameHUDElement <ScoreMultiplierUIController>(coreGameHUD);
                }
            }

            RefreshAllCanvases(hudConfig, data, coreGameHUD);
        }
Пример #2
0
 private static void Postfix(CoreGameHUDController __instance)
 {
     if (GameplayCoreSceneSetupPatch.IsOverridingBaseGameHUD)
     {
         SharedCoroutineStarter.instance.StartCoroutine(RemoveAfterOneFrame(__instance));
     }
 }
Пример #3
0
        // Using the magical power of Zenject™, we magically find ourselves with an instance of
        // our HUDConfigModel and the CoreGameHUDController.
        internal CanvasUtility(HUDConfigModel hudConfig,
                               MainConfigModel mainConfig,
                               [Inject(Optional = true)] GameplayCoreSceneSetupData data,
                               [Inject(Optional = true)] CoreGameHUDController coreGameHUD)
        {
            this.mainConfig = mainConfig;
            if (coreGameHUD != null)
            {
                hudWidth  = Mathf.Abs(coreGameHUD.GetComponentInChildren <ComboUIController>().transform.position.x);
                hudDepth  = Mathf.Abs(coreGameHUD.GetComponentInChildren <ComboUIController>().transform.position.z);
                hudHeight = Mathf.Abs(coreGameHUD.GetComponentInChildren <ComboUIController>().transform.position.y) - 1.5f;

                energyCanvas = EnergyPanelGO(ref coreGameHUD).GetComponent <Canvas>();

                // Hide Canvas and Multiplier if needed
                if (mainConfig.HideCombo)
                {
                    HideBaseGameHUDElement <ComboUIController>(coreGameHUD);
                }
                if (mainConfig.HideMultiplier)
                {
                    HideBaseGameHUDElement <ScoreMultiplierUIController>(coreGameHUD);
                }
            }
            if (data != null)
            {
                // HUDType = GetGameplayCoreHUDTypeForEnvironmentSize(data.environmentInfo.environmentType);
            }

            RefreshAllCanvases(hudConfig, data, coreGameHUD);
        }
Пример #4
0
        private void Constractor(GameEnergyCounter gameEnergyCounter)
        {
            this.gameEnergyCounter = gameEnergyCounter;

            this.coreGameHUDController = Resources.FindObjectsOfTypeAll <CoreGameHUDController>().FirstOrDefault();
            this._energyPanelGO        = this.coreGameHUDController.GetField <GameObject, CoreGameHUDController>("_energyPanelGO");
            foreach (var item in _energyPanelGO.GetComponentsInChildren <Image>().OrderBy(x => x.name))
            {
                Plugin.Log.Debug($"{item}");
                if (item == null)
                {
                    continue;
                }
                if (item.name == "EnergyBar")
                {
                    this.barImage = item;
                }
                else if (item.name == "EnergyIconFull")
                {
                    this.fullIcon    = item;
                    this.DefaltColor = item.color;
                }
                else if (item.name == "EnergyIconEmpty")
                {
                    item.color = Color.red;
                }
            }
            //var difficultyBeatmap = gameplayCoreSceneSetupData.difficultyBeatmap;
            //if (0 < difficultyBeatmap.beatmapData.spawnRotationEventsCount) {
            //    this.barImage.rectTransform.sizeDelta = new Vector2(0f, 0.7f);
            //}
            this.fullIconMaterial  = Instantiate(this.fullIcon.material);
            this.fullIcon.material = this.fullIconMaterial;
        }
Пример #5
0
 private static void Postfix(CoreGameHUDController __instance)
 {
     if (isOverriding)
     {
         SharedCoroutineStarter.instance.StartCoroutine(RemoveAfterOneFrame(__instance));
     }
 }
Пример #6
0
        // Using the magical power of Zenject™, we magically find ourselves with an instance of
        // our HUDConfigModel and the CoreGameHUDController.
        internal CanvasUtility(HUDConfigModel hudConfig,
                               MainConfigModel mainConfig,
                               [Inject(Optional = true)] GameplayCoreSceneSetupData data,
                               [Inject(Optional = true)] CoreGameHUDController coreGameHUD)
        {
            this.mainConfig = mainConfig;
            if (coreGameHUD != null)
            {
                energyCanvas = EnergyPanelGO(ref coreGameHUD).GetComponent <Canvas>();

                // Hide Canvas and Multiplier if needed
                if (mainConfig.HideCombo)
                {
                    HideBaseGameHUDElement <ComboUIController>(coreGameHUD);
                }
                if (mainConfig.HideMultiplier)
                {
                    HideBaseGameHUDElement <ScoreMultiplierUIController>(coreGameHUD);
                }
            }
            if (data != null)
            {
                HUDType = GetGameplayCoreHUDTypeForEnvironmentSize(data.environmentInfo.environmentSizeData.width);
            }

            RefreshAllCanvases(hudConfig, data, coreGameHUD);
        }
        static void Postfix(CoreGameHUDController __instance)
        {
            if (LobbyJoinPatch.IsMultiplayer && Plugin.Config.VerticalHUD)
            {
                Plugin.Log?.Debug("Setting up multiplayer HUD");
                GameEnergyUIPanel gameEnergyUI = __instance.transform.GetComponentInChildren <GameEnergyUIPanel>();

                __instance.transform.position    = new Vector3(0f, 0f, 10f);
                __instance.transform.eulerAngles = new Vector3(270f, 0f, 0f);

                if (gameEnergyUI != null)
                {
                    gameEnergyUI.transform.localPosition    = new Vector3(0f, 4f, 0f);
                    gameEnergyUI.transform.localEulerAngles = new Vector3(270f, 0f, 0f);
                }

                if (Plugin.Config.SingleplayerHUD)
                {
                    Transform comboPanel         = __instance.transform.Find("ComboPanel");
                    Transform scoreCanvas        = __instance.transform.Find("ScoreCanvas");
                    Transform multiplierCanvas   = __instance.transform.Find("MultiplierCanvas");
                    Transform songProgressCanvas = __instance.transform.Find("SongProgressCanvas");

                    if (!__instance.transform.Find("LeftPanel"))
                    {
                        GameObject leftPanel  = new GameObject();
                        GameObject rightPanel = new GameObject();
                        leftPanel.name                     = "LeftPanel";
                        rightPanel.name                    = "RightPanel";
                        leftPanel.transform.parent         = __instance.transform;
                        rightPanel.transform.parent        = __instance.transform;
                        leftPanel.transform.localPosition  = new Vector3(-2.5f, 0f, 1f);
                        rightPanel.transform.localPosition = new Vector3(2.5f, 0f, 1f);

                        comboPanel.transform.parent         = leftPanel.transform;
                        scoreCanvas.transform.parent        = leftPanel.transform;
                        multiplierCanvas.transform.parent   = rightPanel.transform;
                        songProgressCanvas.transform.parent = rightPanel.transform;

                        comboPanel.transform.localPosition         = new Vector3(0f, 0f, 0f);
                        scoreCanvas.transform.localPosition        = new Vector3(0f, -1.1f, 0f);
                        multiplierCanvas.transform.localPosition   = new Vector3(0f, 0f, 0f);
                        songProgressCanvas.transform.localPosition = new Vector3(0f, -1.1f, 0f);

                        comboPanel.transform.SetParent(__instance.transform, true);
                        scoreCanvas.transform.SetParent(__instance.transform, true);
                        multiplierCanvas.transform.SetParent(__instance.transform, true);
                        songProgressCanvas.transform.SetParent(__instance.transform, true);

                        CurvedTextMeshPro[]? scorePanels = scoreCanvas.GetComponentsInChildren <CurvedTextMeshPro>();
                        foreach (CurvedTextMeshPro panel in scorePanels)
                        {
                            panel.enabled = true;
                        }
                    }
                }
            }
        }
Пример #8
0
        private static IEnumerator RemoveAfterOneFrame(CoreGameHUDController coreGameHUD)
        {
            yield return(new WaitForEndOfFrame());

            foreach (Transform child in coreGameHUD.transform)
            {
                child.gameObject.SetActive(false);
            }
        }
Пример #9
0
        static void Postfix(CoreGameHUDController __instance, ref GameObject ____songProgressPanelGO, ref GameObject ____energyPanelGO)
        {
            if (MPState.CurrentGameType != MultiplayerGameType.None && Plugin.Config.VerticalHUD)
            {
                Plugin.Log?.Debug("Setting up multiplayer HUD");

                __instance.transform.position    = new Vector3(0f, 0f, 10f);
                __instance.transform.eulerAngles = new Vector3(270f, 0f, 0f);

                ____energyPanelGO.transform.localPosition    = new Vector3(0f, 4f, 0f);
                ____energyPanelGO.transform.localEulerAngles = new Vector3(270f, 0f, 0f);

                if (Plugin.Config.SingleplayerHUD && !__instance.transform.Find("LeftPanel"))
                {
                    Transform comboPanel       = __instance.transform.Find("ComboPanel");
                    Transform scoreCanvas      = __instance.transform.Find("ScoreCanvas");
                    Transform multiplierCanvas = __instance.transform.Find("MultiplierCanvas");

                    GameObject leftPanel  = new GameObject();
                    GameObject rightPanel = new GameObject();
                    leftPanel.name                     = "LeftPanel";
                    rightPanel.name                    = "RightPanel";
                    leftPanel.transform.parent         = __instance.transform;
                    rightPanel.transform.parent        = __instance.transform;
                    leftPanel.transform.localPosition  = new Vector3(-2.5f, 0f, 1f);
                    rightPanel.transform.localPosition = new Vector3(2.5f, 0f, 1f);

                    ____songProgressPanelGO.transform.SetParent(rightPanel.transform, true);
                    ____songProgressPanelGO.transform.localPosition = new Vector3(0f, -1.1f, 0f);
                    ____songProgressPanelGO.transform.SetParent(__instance.transform, true);

                    multiplierCanvas.transform.SetParent(rightPanel.transform, true);
                    multiplierCanvas.transform.localPosition = new Vector3(0f, 0f, 0f);
                    multiplierCanvas.transform.SetParent(__instance.transform, true);

                    comboPanel.transform.SetParent(leftPanel.transform, true);
                    comboPanel.transform.localPosition = new Vector3(0f, 0f, 0f);
                    comboPanel.transform.SetParent(__instance.transform, true);

                    scoreCanvas.transform.SetParent(leftPanel.transform, true);
                    scoreCanvas.transform.localPosition = new Vector3(0f, -1.1f, 0f);
                    scoreCanvas.transform.SetParent(__instance.transform, true);

                    foreach (CurvedTextMeshPro panel in scoreCanvas.GetComponentsInChildren <CurvedTextMeshPro>())
                    {
                        panel.enabled = true;
                    }
                }
            }
        }
Пример #10
0
        public void RefreshAllCanvases(HUDConfigModel hudConfig, GameplayCoreSceneSetupData data = null, CoreGameHUDController coreGameHUD = null)
        {
            CanvasIDToCanvas.Clear();
            CanvasToSettings.Clear();
            CanvasIDToCanvas.Add(-1, CreateCanvasWithConfig(hudConfig.MainCanvasSettings));
            CanvasToSettings.Add(CanvasIDToCanvas[-1], hudConfig.MainCanvasSettings);
            if (coreGameHUD != null && hudConfig.MainCanvasSettings.ParentedToBaseGameHUD)
            {
                Transform parent = coreGameHUD.transform;
                //if (HUDType == GameplayCoreHUDInstaller.HudType.Flying) parent = coreGameHUD.transform.GetChild(0);
                SoftParent softParent = CanvasIDToCanvas[-1].gameObject.AddComponent <SoftParent>();
                softParent.AssignParent(parent);

                // Base Game HUD is rotated backwards, so we have to reflect our vector to match.
                Vector3 position = hudConfig.MainCanvasSettings.Position;

                position.y = hudHeight * -1;

                if (hudConfig.MainCanvasSettings.MatchBaseGameHUDDepth)
                {
                    position.z = hudDepth;
                }

                Vector3    posOofset = Vector3.Reflect(position, Vector3.back); // yknow what, f**k it, its posOofset now.
                Quaternion rotOofset = Quaternion.Euler(Vector3.Reflect(hudConfig.MainCanvasSettings.Rotation, Vector3.back));

                softParent.AssignOffsets(posOofset, rotOofset);
            }
            for (int i = 0; i < hudConfig.OtherCanvasSettings.Count; i++)
            {
                HUDCanvas canvasSettings = hudConfig.OtherCanvasSettings[i];
                RegisterNewCanvas(canvasSettings, i);

                if (coreGameHUD != null && hudConfig.OtherCanvasSettings[i].ParentedToBaseGameHUD)
                {
                    Transform parent = coreGameHUD.transform;
                    //if (HUDType == GameplayCoreHUDInstaller.HudType.Flying) parent = coreGameHUD.transform.GetChild(0);
                    SoftParent softParent = CanvasIDToCanvas[i].gameObject.AddComponent <SoftParent>();
                    softParent.AssignParent(parent);
                }
            }
        }
Пример #11
0
        public void PlayVideo(bool preview)
        {
            if (hasVideo || (!showVideo && !preview)) //If the current video is null or not downloaded or show video is off AND it isn't a preview hide the screen
            {
                HideScreen();
                return;
            }

            ShowScreen();
            vsRenderer.material.color = _onColor;
            float practiceSettingsSongStart = 0;

            if (!preview)
            {
                try     // Try to get these, as errors happen when only previewing (and they are unnecessary)
                {
                    try // Try to get these as there will be a null reference if not in practice mode or only previewing
                    {
                        practiceSettingsSongStart =
                            BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.practiceSettings.startSongTime - 1;
                        if (practiceSettingsSongStart < 0)
                        {
                            practiceSettingsSongStart = 0;
                        }
                    }
                    catch (NullReferenceException)
                    {
                        practiceSettingsSongStart = 0;
                    }

                    float songSpeed = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul;
                    videoPlayer.playbackSpeed =
                        BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.practiceSettings != null
                            ? BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.practiceSettings.songSpeedMul
                            : songSpeed; // Set video speed to practice or non-practice speed

                    if (offsetSec + practiceSettingsSongStart > 0)
                    {
                        videoPlayer.time = offsetSec + practiceSettingsSongStart;
                    }
                    else
                    {
                        videoPlayer.time = 0;
                    }
                }
                catch (Exception e)
                {
                    Plugin.logger.Debug("Probably cause previews don't have speed mults");
                    Plugin.logger.Error(e.ToString());
                }

                for (ushort track = 0;
                     track < videoPlayer.audioTrackCount;
                     track++) // For Each Track -> Decrease Audio volume to 0 on that track
                {
                    // videoPlayer.SetDirectAudioMute(track, true);
                    videoPlayer.SetDirectAudioVolume(track, 0f);
                }

                if (rotateIn360)
                {
                    try
                    {
                        Plugin.logger.Debug(BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.environmentInfo.environmentType.name);
                        CoreGameHUDController cgh = Resources.FindObjectsOfTypeAll <CoreGameHUDController>()
                                                    .LastOrDefault(x => x.isActiveAndEnabled);
                        screenSoftParentRotation.AssignParent(cgh.transform);
                    }
                    catch { }
                    //Null reference if done in preview
                    screenSoftParentRotation.enabled = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.environmentInfo.environmentType.name == "CircleEvironmentType";
                }
            }
            else
            {
                videoPlayer.time          = offsetSec > 0 ? offsetSec : 0;
                videoPlayer.playbackSpeed = 1;
                //TODO: Make Left Ear Audio the Preview and Right Ear Audio the BeatMap
                //ushort videoTrack = 1;
                for (ushort track = 0;
                     track < videoPlayer.audioTrackCount;
                     track++) // For Each Track -> Increase Audio volume to .5 (float) on that track
                {
                    //if (track != videoTrack) { videoPlayer.SetDirectAudioVolume(track, 0f); continue;}
                    bool failed = false;
                    try
                    {
                        videoPlayer.SetDirectAudioVolume(track, playPreviewAudio ? .8f : 0f);
                        Plugin.logger.Debug($"Channels: {videoPlayer.GetAudioChannelCount(track)}");
                    }
                    catch (Exception)
                    {
                        failed = true;
                    }
                    Plugin.logger.Debug($"Track: {track} {(failed ? "Failed" : "Succeeded")}");
                }
                Plugin.logger.Debug("Done lower volume");
            }
            Plugin.logger.Debug("Offset for video: " + offsetSec);
            StopAllCoroutines();
            StartCoroutine(StartVideoDelayed(preview ? -offsetSec : -(offsetSec + practiceSettingsSongStart), preview));
        }