private void InitClassicMode() { // Yeah this is required. // If the Score Counter is all alone on its own Canvas with nothing to accompany them, // I need to give 'em a friend or else they get shy and hide away in the void. _ = CanvasUtility.CreateTextFromSettings(Settings, null); ScoreUIController scoreUIController = coreGameHUD.GetComponentInChildren <ScoreUIController>(); TextMeshProUGUI old = ScoreUIText(ref scoreUIController); // Setup Score Text GameObject baseGameScore = RelativeScoreGO(ref coreGameHUD); relativeScoreText = baseGameScore.GetComponent <TextMeshProUGUI>(); relativeScoreText.color = Color.white; // Setup Rank Text GameObject baseGameRank = ImmediateRankGO(ref coreGameHUD); rankText = baseGameRank.GetComponent <TextMeshProUGUI>(); rankText.color = Color.white; // Set up parenting Canvas currentCanvas = CanvasUtility.GetCanvasFromID(Settings.CanvasID); old.rectTransform.SetParent(currentCanvas.transform, true); baseGameScore.transform.SetParent(old.transform, true); // Hide score if we're not using it. if (!Configuration.Instance.showScore) { UnityEngine.Object.Destroy(baseGameScore.gameObject); } // Adjust font sizes. // TODO: Pull this from config? relativeScoreText.fontSize = 10; rankText.fontSize = 30; baseGameRank.transform.SetParent(old.transform, true); RectTransform pointsTextTransform = old.rectTransform; HUDCanvas currentSettings = CanvasUtility.GetCanvasSettingsFromID(Settings.CanvasID); Vector2 anchoredPos = CanvasUtility.GetAnchoredPositionFromConfig(Settings) + (offset * (3f / currentSettings.PositionScale)); pointsTextTransform.localPosition = anchoredPos * currentSettings.PositionScale; pointsTextTransform.localPosition = new Vector3(pointsTextTransform.localPosition.x, pointsTextTransform.localPosition.y, 0); pointsTextTransform.localEulerAngles = Vector3.zero; UnityEngine.Object.Destroy(coreGameHUD.GetComponentInChildren <ImmediateRankUIPanel>()); InitPercentageRing(); // Shift text into proper positions rankText.rectTransform.anchoredPosition += rankScoreOffset; relativeScoreText.rectTransform.anchoredPosition += rankScoreOffset; //relativeScoreAndImmediateRank.relativeScoreOrImmediateRankDidChangeEvent += UpdateClassicModeText; UpdateClassicModeText(); }
internal void ApplySettings(ConfigModel model) { ClearScreen(); if (editingConfigModel != null) { mainConfig.OnConfigChanged -= MainConfig_OnConfigChanged; } settingsHeader.text = $"{model.DisplayName} Settings"; mainConfig.OnConfigChanged += MainConfig_OnConfigChanged; editingConfigModel = model; mockCounter.HighlightCounter(editingConfigModel); // Setup helper functions for the config model to hook off of. model.GetCanvasFromID = (v) => canvasUtility.GetCanvasSettingsFromID(v); model.GetCanvasIDFromCanvasSettings = (v) => mainConfig.HUDConfig.OtherCanvasSettings.IndexOf(v); model.GetAllCanvases = () => GetAllCanvases(); // Loading settings base BSMLParser.instance.Parse(SettingsBase, settingsContainer, model); // Loading counter-specific settings if (!(model is CustomConfigModel customConfig)) { string resourceLocation = $"CountersPlus.UI.BSML.Config.{model.DisplayName}.bsml"; string resourceContent = Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), resourceLocation); BSMLParser.instance.Parse(resourceContent, settingsContainer, model); }
public override void CounterInit() { // Yeah this is required. // If the Score Counter is all alone on its own Canvas with nothing to accompany them, // I need to give 'em a friend or else they get shy and hide away in the void. _ = CanvasUtility.CreateTextFromSettings(Settings, null); ScoreUIController scoreUIController = coreGameHUD.GetComponentInChildren <ScoreUIController>(); TextMeshProUGUI old = ScoreUIText(ref scoreUIController); GameObject baseGameScore = RelativeScoreGO(ref coreGameHUD); relativeScoreText = baseGameScore.GetComponent <TextMeshProUGUI>(); relativeScoreText.color = Color.white; GameObject baseGameRank = ImmediateRankGO(ref coreGameHUD); rankText = baseGameRank.GetComponent <TextMeshProUGUI>(); rankText.color = Color.white; Canvas currentCanvas = CanvasUtility.GetCanvasFromID(Settings.CanvasID); old.rectTransform.SetParent(currentCanvas.transform, true); baseGameScore.transform.SetParent(old.transform, true); baseGameRank.transform.SetParent(old.transform, true); if (!mainConfig.ItalicText) { old.fontStyle = relativeScoreText.fontStyle = rankText.fontStyle = FontStyles.Normal; Vector3 localPosition = relativeScoreText.rectTransform.localPosition; relativeScoreText.rectTransform.localPosition = new Vector3(0, localPosition.y, localPosition.z); localPosition = rankText.rectTransform.localPosition; rankText.rectTransform.localPosition = new Vector3(0, localPosition.y, localPosition.z); } switch (Settings.Mode) { case ScoreMode.RankOnly: Object.Destroy(baseGameScore.gameObject); break; case ScoreMode.ScoreOnly: Object.Destroy(baseGameRank.gameObject); break; } RectTransform pointsTextTransform = old.rectTransform; HUDCanvas currentSettings = CanvasUtility.GetCanvasSettingsFromID(Settings.CanvasID); Vector2 anchoredPos = CanvasUtility.GetAnchoredPositionFromConfig(Settings) + (offset * (3f / currentSettings.PositionScale)); pointsTextTransform.localPosition = anchoredPos * currentSettings.PositionScale; pointsTextTransform.localPosition = new Vector3(pointsTextTransform.localPosition.x, pointsTextTransform.localPosition.y, 0); pointsTextTransform.localEulerAngles = Vector3.zero; Object.Destroy(coreGameHUD.GetComponentInChildren <ImmediateRankUIPanel>()); relativeScoreAndImmediateRank.relativeScoreOrImmediateRankDidChangeEvent += UpdateText; UpdateText(); }
public override void CounterInit() { modifiersModel = SCGameplayModsModel(ref scoreController); IDifficultyBeatmap beatmap = data.difficultyBeatmap; int maxRawScore = ScoreModel.MaxRawScoreForNumberOfNotes(noteCountProcessor.NoteCount); maxPossibleScore = ScoreModel.GetModifiedScoreForGameplayModifiersScoreMultiplier(maxRawScore, modifiersModel.GetTotalMultiplier(data.gameplayModifiers)); stats = playerDataModel.playerData.GetPlayerLevelStatsData(beatmap); highScore = stats.highScore; if (scoreConfig.Enabled && Settings.UnderScore) { HUDCanvas scoreCanvas = CanvasUtility.GetCanvasSettingsFromID(scoreConfig.CanvasID); counter = CanvasUtility.CreateTextFromSettings(scoreConfig, SCORE_COUNTER_OFFSET * (3f / scoreCanvas.PositionScale)); } else { counter = CanvasUtility.CreateTextFromSettings(Settings); } counter.alignment = TextAlignmentOptions.Top; counter.fontSize = Settings.TextSize; pbRatio = (float)highScore / maxPossibleScore; SetPersonalBest((float)highScore / maxPossibleScore); ScoreUpdated(0); }
public override void CounterInit() { IDifficultyBeatmap beatmap = data.difficultyBeatmap; maxPossibleScore = ScoreModel.ComputeMaxMultipliedScoreForBeatmap(beatmapData); stats = playerDataModel.playerData.GetPlayerLevelStatsData(beatmap); highScore = stats.highScore; if (scoreConfig.Enabled && Settings.UnderScore) { HUDCanvas scoreCanvas = CanvasUtility.GetCanvasSettingsFromID(scoreConfig.CanvasID); counter = CanvasUtility.CreateTextFromSettings(scoreConfig, SCORE_COUNTER_OFFSET * (3f / scoreCanvas.PositionScale)); } else { counter = CanvasUtility.CreateTextFromSettings(Settings); } counter.alignment = TextAlignmentOptions.Top; counter.fontSize = Settings.TextSize; pbRatio = (float)highScore / maxPossibleScore; SetPersonalBest(pbRatio); ScoreUpdated(0); }
private void InitPercentageRing() { if (Configuration.Instance.showPercentageRing) { // Create ring var canvas = CanvasUtility.GetCanvasFromID(Settings.CanvasID); if (canvas != null) { HUDCanvas currentSettings = CanvasUtility.GetCanvasSettingsFromID(Settings.CanvasID); Vector2 ringAnchoredPos = CanvasUtility.GetAnchoredPositionFromConfig(Settings) * currentSettings.PositionScale; ImageView backgroundImage = CreateRing(canvas); backgroundImage.rectTransform.anchoredPosition = ringAnchoredPos; backgroundImage.CrossFadeAlpha(0.05f, 1f, false); backgroundImage.transform.localScale = ringSize / 10; backgroundImage.type = Image.Type.Simple; progressRing = CreateRing(canvas); progressRing.rectTransform.anchoredPosition = ringAnchoredPos; progressRing.transform.localScale = ringSize / 10; } //relativeScoreAndImmediateRank.relativeScoreOrImmediateRankDidChangeEvent += UpdateRing; UpdateRing(); } }
public override void CounterInit() { ScoreUIController scoreUIController = coreGameHUD.GetComponentInChildren <ScoreUIController>(); TextMeshProUGUI old = ScoreUIText(ref scoreUIController); GameObject baseGameScore = RelativeScoreGO(ref coreGameHUD); relativeScoreText = baseGameScore.GetComponent <TextMeshProUGUI>(); relativeScoreText.color = Color.white; GameObject baseGameRank = ImmediateRankGO(ref coreGameHUD); rankText = baseGameRank.GetComponent <TextMeshProUGUI>(); rankText.color = Color.white; Canvas currentCanvas = CanvasUtility.GetCanvasFromID(Settings.CanvasID); old.rectTransform.SetParent(currentCanvas.transform, true); baseGameScore.transform.SetParent(old.transform, true); baseGameRank.transform.SetParent(old.transform, true); switch (Settings.Mode) { case ScoreMode.RankOnly: Object.Destroy(baseGameScore.gameObject); break; case ScoreMode.ScoreOnly: Object.Destroy(baseGameRank.gameObject); break; } RectTransform pointsTextTransform = old.rectTransform; HUDCanvas currentSettings = CanvasUtility.GetCanvasSettingsFromID(Settings.CanvasID); float positionScale = currentSettings?.PositionScale ?? 10; Vector2 anchoredPos = (CanvasUtility.GetAnchoredPositionFromConfig(Settings, currentSettings.IsMainCanvas) + offset) * positionScale; Plugin.Logger.Warn(anchoredPos.ToString()); pointsTextTransform.anchoredPosition = anchoredPos; // I dont know why Personal Best has even the SLIGHTEST of influence on the position of Score Counter... but it does? if (!personalBest.Enabled) { pointsTextTransform.anchoredPosition -= new Vector2(0, 25); } pointsTextTransform.localPosition = new Vector3(pointsTextTransform.localPosition.x, pointsTextTransform.localPosition.y, 0); pointsTextTransform.localEulerAngles = Vector3.zero; Object.Destroy(coreGameHUD.GetComponentInChildren <ImmediateRankUIPanel>()); relativeScoreAndImmediateRank.relativeScoreOrImmediateRankDidChangeEvent += UpdateText; UpdateText(); }
private void InitPercentMode() { // Required. We need to get a handle to the game's default score counter and destroy it. _ = CanvasUtility.CreateTextFromSettings(Settings, null); ScoreUIController scoreUIController = coreGameHUD.GetComponentInChildren <ScoreUIController>(); TextMeshProUGUI old = ScoreUIText(ref scoreUIController); GameObject baseGameScore = RelativeScoreGO(ref coreGameHUD); GameObject baseGameRank = ImmediateRankGO(ref coreGameHUD); // Set up parenting Canvas currentCanvas = CanvasUtility.GetCanvasFromID(Settings.CanvasID); old.rectTransform.SetParent(currentCanvas.transform, true); baseGameScore.transform.SetParent(old.transform, true); baseGameRank.transform.SetParent(old.transform, true); // Destroy Score UnityEngine.Object.Destroy(baseGameScore.gameObject); // Destroy Rank UnityEngine.Object.Destroy(baseGameRank.gameObject); if (!Configuration.Instance.showScore) { old.fontSize = 0; } percentMajorText = CanvasUtility.CreateTextFromSettings(Settings); percentMajorText.fontSize = 7; percentMinorText = CanvasUtility.CreateTextFromSettings(Settings); percentMinorText.fontSize = 3; RectTransform pointsTextTransform = old.rectTransform; HUDCanvas currentSettings = CanvasUtility.GetCanvasSettingsFromID(Settings.CanvasID); Vector2 anchoredPos = CanvasUtility.GetAnchoredPositionFromConfig(Settings) + (offset * (3f / currentSettings.PositionScale)); pointsTextTransform.localPosition = anchoredPos * currentSettings.PositionScale; pointsTextTransform.localPosition = new Vector3(pointsTextTransform.localPosition.x, pointsTextTransform.localPosition.y, 0); pointsTextTransform.localEulerAngles = Vector3.zero; UnityEngine.Object.Destroy(coreGameHUD.GetComponentInChildren <ImmediateRankUIPanel>()); InitPercentageRing(); percentMajorText.rectTransform.anchoredPosition += new Vector2(0.0f, 0.7f); percentMinorText.rectTransform.anchoredPosition += new Vector2(0.0f, -3.0f); prevPercentMajor = -1; prevPercentMinor = -1; //relativeScoreAndImmediateRank.relativeScoreOrImmediateRankDidChangeEvent += UpdatePercentModeText; UpdatePercentModeText(); }
protected void GenerateBasicText(string labelText, out TMP_Text count) { TMP_Text label = CanvasUtility.CreateTextFromSettings(Settings); label.fontSize = 3; label.text = labelText; HUDCanvas canvas = CanvasUtility.GetCanvasSettingsFromID(Settings.CanvasID); count = CanvasUtility.CreateTextFromSettings(Settings, new Vector3(0, -0.4f * (10 / canvas.PositionScale), 0)); count.text = "0"; count.fontSize = 4; }
protected void RefreshData() { data.data.Clear(); for (int i = -1; i < hudConfig.OtherCanvasSettings.Count; i++) { HUDCanvas settings = canvasUtility.GetCanvasSettingsFromID(i); int countersUsingCanvas = flowCoordinator.Value.AllConfigModels.Count(x => x.CanvasID == i); var info = new CustomListTableData.CustomCellInfo( settings?.Name ?? "Unknown", $"<i>{countersUsingCanvas} counter(s) use this Canvas.</i>", Texture2D.blackTexture); data.data.Add(info); } data.tableView.ReloadData(); }
internal void ApplySettings(ConfigModel model) { ClearScreen(); if (editingConfigModel != null) { mainConfig.OnConfigChanged -= MainConfig_OnConfigChanged; } settingsHeader.text = $"{model.DisplayName} Settings"; mainConfig.OnConfigChanged += MainConfig_OnConfigChanged; editingConfigModel = model; mockCounter.HighlightCounter(editingConfigModel); // Setup helper functions for the config model to hook off of. model.GetCanvasFromID = (v) => canvasUtility.GetCanvasSettingsFromID(v); model.GetCanvasIDFromCanvasSettings = (v) => mainConfig.HUDConfig.OtherCanvasSettings.IndexOf(v); model.GetAllCanvases = () => GetAllCanvases(); if (cachedSettings.TryGetValue(model, out var cache)) { if (model is CustomConfigModel customConfig) { CustomCounter customCounter = customConfig.AttachedCustomCounter; settingsHeader.text = $"{customCounter.Name} Settings"; } foreach (GameObject obj in cache) { obj.SetActive(true); } } else { // Loading settings base var settingsBaseParams = BSMLParser.instance.Parse(SettingsBase, settingsContainer, model); var multiplayerWarning = settingsBaseParams.GetObjectsWithTag("multiplayer-warning")[0]; // Only show multiplayer warning if this is a Custom Counter that is not enabled in multiplayer // Loading counter-specific settings if (model is not CustomConfigModel customConfig) { string resourceLocation = $"CountersPlus.UI.BSML.Config.{model.DisplayName}.bsml"; string resourceContent = Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), resourceLocation); BSMLParser.instance.Parse(resourceContent, settingsContainer, model); // All base Counters+ counters are (or should be) multiplayer ready. multiplayerWarning.SetActive(false); }
public void ApplyCanvasForEditing(int id) { canvasID = id; HUDCanvas settings = canvasUtility.GetCanvasSettingsFromID(canvasID); if (currentlyEditing != null) { currentlyEditing.OnCanvasSettingsChanged -= CurrentlyEditing_OnCanvasSettingsChanged; currentlyEditing.OnCanvasSettingsApply -= CurrentlyEditing_OnCanvasSettingsApply; } ClearScreen(); BSMLParser.instance.Parse(SettingsBase, gameObject, settings); currentlyEditing = settings; currentlyEditing.OnCanvasSettingsChanged += CurrentlyEditing_OnCanvasSettingsChanged; currentlyEditing.OnCanvasSettingsApply += CurrentlyEditing_OnCanvasSettingsApply; }
public void ApplyCanvasForEditing(int id) { if (id != canvasID) { hudList.Value.RefreshData(); } canvasID = id; HUDCanvas settings = canvasUtility.GetCanvasSettingsFromID(canvasID); if (currentlyEditing != null) { currentlyEditing.OnCanvasSettingsChanged -= CurrentlyEditing_OnCanvasSettingsChanged; currentlyEditing.OnCanvasSettingsApply -= CurrentlyEditing_OnCanvasSettingsApply; } ClearScreen(); var param = BSMLParser.instance.Parse(SettingsBase, gameObject, settings); currentlyEditing = settings; currentlyEditing.OnCanvasSettingsChanged += CurrentlyEditing_OnCanvasSettingsChanged; currentlyEditing.OnCanvasSettingsApply += CurrentlyEditing_OnCanvasSettingsApply; StringSetting nameFieldSetting = param.GetObjectsWithTag("name-field").First().GetComponent <StringSetting>(); nameFieldSetting.interactable = !(currentlyEditing?.IsMainCanvas ?? true); }