diff --git a/Counters+/BuildTargets.targets b/Counters+/BuildTargets.targets deleted file mode 100644 index 669fbf60..00000000 --- a/Counters+/BuildTargets.targets +++ /dev/null @@ -1,357 +0,0 @@ - - - - - 1.4 - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(BeatSaberDir)\IPA\Pending\Plugins - - - $(BeatSaberDir)\Plugins - - - - - - - - - - - - - - - - - - - - - 0 && endColumn > 0) - AssemblyVersion = firstLineStr.Substring(startColumn, endColumn - startColumn); - else - badParse = true; - } - else - badParse = true; - if (badParse) - { - Log.LogError("Build", "BSMOD03", "", assemblyFile, 0, 0, 0, 0, "Unable to parse the AssemblyVersion from {0}", assemblyFile); - if(ErrorOnMismatch) - return false; - badParse = false; - } - - if (PluginVersion != "E.R.R" && AssemblyVersion != PluginVersion) - { - Log.LogError("Build", "BSMOD01", "", assemblyFile, startLine, startColumn + 1, startLine, endColumn + 1, "PluginVersion {0} in manifest.json does not match AssemblyVersion {1} in AssemblyInfo.cs", PluginVersion, AssemblyVersion, assemblyFile); - Log.LogMessage(MessageImportance.High, "PluginVersion {0} does not match AssemblyVersion {1}", PluginVersion, AssemblyVersion); - if(ErrorOnMismatch) - return false; - } - if (!string.IsNullOrEmpty(endLineStr)) - { - startColumn = endLineStr.IndexOf('"') + 1; - endColumn = endLineStr.LastIndexOf('"'); - if (startColumn > 0 && endColumn > 0) - { - assemblyFileVersion = endLineStr.Substring(startColumn, endColumn - startColumn); - if (AssemblyVersion != assemblyFileVersion) - { - Log.LogWarning("Build", "BSMOD02", "", assemblyFile, endLine, startColumn + 1, endLine, endColumn + 1, "AssemblyVersion {0} does not match AssemblyFileVersion {1} in AssemblyInfo.cs", AssemblyVersion, assemblyFileVersion); - if(ErrorOnMismatch) - return false; - } - - } - else - { - Log.LogWarning("Build", "BSMOD06", "", assemblyFile, 0, 0, 0, 0, "Unable to parse the AssemblyFileVersion from {0}", assemblyFile); - if(ErrorOnMismatch) - return false; - } - } - return true; - } - catch (Exception ex) - { - Log.LogErrorFromException(ex); - return false; - } - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - = 7) - { - CommitShortHash = outText.Substring(0, 7); - return true; - } - } - catch (Win32Exception ex) - { - noGitFound = true; - - } - catch (Exception ex) - { - Log.LogErrorFromException(ex); - return true; - } - try - { - string gitPath = Path.GetFullPath(Path.Combine(ProjectDir, ".git")); - string headPath = Path.Combine(gitPath, "HEAD"); - string headContents = null; - if (File.Exists(headPath)) - headContents = File.ReadAllText(headPath); - else - { - gitPath = Path.GetFullPath(Path.Combine(ProjectDir, "..", ".git")); - headPath = Path.Combine(gitPath, "HEAD"); - if (File.Exists(headPath)) - headContents = File.ReadAllText(headPath); - } - headPath = null; - if (!string.IsNullOrEmpty(headContents) && headContents.StartsWith("ref:")) - headPath = Path.Combine(gitPath, headContents.Replace("ref:", "").Trim()); - if (File.Exists(headPath)) - { - headContents = File.ReadAllText(headPath); - if (headContents.Length >= 7) - CommitShortHash = headContents.Substring(0, 7); - } - } - catch { } - if (CommitShortHash == "local") - { - if(noGitFound) - Log.LogMessage(MessageImportance.High, " 'git' command not found, unable to retrieve current commit hash."); - else - Log.LogMessage(MessageImportance.High, " Unable to retrieve current commit hash."); - } - return true; - ]]> - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Counters+/ConfigModels/MainConfigModel.cs b/Counters+/ConfigModels/MainConfigModel.cs index 794140a2..2258b1f2 100644 --- a/Counters+/ConfigModels/MainConfigModel.cs +++ b/Counters+/ConfigModels/MainConfigModel.cs @@ -4,8 +4,11 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Runtime.CompilerServices; using UnityEngine; +[assembly: InternalsVisibleTo(IPA.Config.Stores.GeneratedStore.AssemblyVisibilityTarget)] + namespace CountersPlus.ConfigModels { /// diff --git a/Counters+/Counters+.csproj b/Counters+/Counters+.csproj index 3fc9d84c..0c5eb356 100644 --- a/Counters+/Counters+.csproj +++ b/Counters+/Counters+.csproj @@ -1,313 +1,133 @@ - - + + + + - Debug - AnyCPU - 8.0.30703 - 2.0 - {A5DBF7F3-FE93-4BB1-8023-2DD50DFD3350} - Library - Properties - CountersPlus - Counters+ - v4.8 - 512 - portable - $(ProjectDir)Refs - $(BeatSaberDir) - $(SolutionDir)Refs - $(MSBuildProjectDirectory)\ - $(AppOutputBase)=X:\$(AssemblyName)\ + net48 11 - - - - true - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - true - bin\Release\ - - - prompt - 4 - - - True - - - True - True + CountersPlus + True + $(BeatSaberDir)\Beat Saber_Data\Managed + + + + all + build; native; contentfiles; analyzers; buildtransitive + + + all + build; native; contentfiles; analyzers; buildtransitive + + + - + False $(BeatSaberDir)\Libs\0Harmony.dll - False - + False - $(BeatSaberDir)\Beat Saber_Data\Managed\BeatmapCore.dll - False - + False - $(BeatSaberDir)\Beat Saber_Data\Managed\BeatSaber.GameSettings.dll - False - + False - $(BeatSaberDir)\Beat Saber_Data\Managed\BeatSaber.PerformancePresets.dll - False - + False - $(BeatSaberDir)\Beat Saber_Data\Managed\BeatSaber.Settings.dll - False - + False - $(BeatSaberDir)\Beat Saber_Data\Managed\BeatSaber.ViewSystem.dll - False - - - False - $(BeatSaberDir)\Beat Saber_Data\Managed\BGLib.AppFlow.dll - + False - $(BeatSaberDir)\Beat Saber_Data\Managed\BGLib.SaveDataCore.dll - False + True - - False - $(BeatSaberDir)\Beat Saber_Data\Managed\BGLib.UnityExtension.dll - - + False - $(BeatSaberDir)\Plugins\BSML.dll - False - + False - $(BeatSaberDir)\Beat Saber_Data\Managed\Colors.dll - False + $(BeatSaberDir)\Plugins\BSML.dll - + False - $(BeatSaberDir)\Beat Saber_Data\Managed\DataModels.dll - False - + False - $(BeatSaberDir)\Beat Saber_Data\Managed\GameplayCore.dll - False - + False $(BeatSaberDir)\Plugins\Heck.dll - False - + False $(BeatSaberDir)\Libs\Hive.Versioning.dll - False - + False - $(BeatSaberDir)\Beat Saber_Data\Managed\MediaLoader.dll - False - - $(BeatSaberDir)\Beat Saber_Data\Managed\Microsoft.CSharp.dll + False - False + True - + False - $(BeatSaberDir)\Libs\Newtonsoft.Json.dll - True - + False - $(BeatSaberDir)\Beat Saber_Data\Managed\SegmentedControl.dll - False + True - + False - $(BeatSaberDir)\Libs\SemVer.dll - False - - False - $(BeatSaberDir)\Plugins\SiraUtil.dll - False - - - - - - - - - $(BeatSaberDir)\Beat Saber_Data\Managed\Main.dll - False + + false - - $(BeatSaberDir)\Beat Saber_Data\Managed\HMLib.dll + False - - $(BeatSaberDir)\Beat Saber_Data\Managed\HMUI.dll + False - - $(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Loader.dll + False + $(BeatSaberDir)\Plugins\SiraUtil.dll - $(BeatSaberDir)\Beat Saber_Data\Managed\Unity.TextMeshPro.dll False - $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.dll False - $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll - False - - False - $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.ImageConversionModule.dll - False - + False - $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.TextRenderingModule.dll - False - $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UI.dll - False - - - $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UIElementsModule.dll False - $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UIModule.dll - False - - False - $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UnityWebRequestModule.dll - False - - $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.VRModule.dll + False - + False - $(BeatSaberDir)\Beat Saber_Data\Managed\VRUI.dll - False - + False - $(BeatSaberDir)\Beat Saber_Data\Managed\Zenject.dll - False - + False - $(BeatSaberDir)\Beat Saber_Data\Managed\Zenject-usage.dll - False - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -331,6 +151,7 @@ + @@ -346,9 +167,8 @@ + - - @@ -357,16 +177,9 @@ - - - + - - - - - - - \ No newline at end of file + + diff --git a/Counters+/Counters/ProgressCounter.cs b/Counters+/Counters/ProgressCounter.cs index 734576a6..d1774c41 100644 --- a/Counters+/Counters/ProgressCounter.cs +++ b/Counters+/Counters/ProgressCounter.cs @@ -7,7 +7,6 @@ using UnityEngine; using UnityEngine.UI; using Zenject; -using static CountersPlus.Utils.Accessors; namespace CountersPlus.Counters { @@ -49,7 +48,7 @@ ProgressMode.TimeInBeats when Settings.ProgressTimeLeft }; // I'm sorry, little one. - GameObject baseGameProgress = SongProgressPanelGO(ref coreGameHUD); + GameObject baseGameProgress = coreGameHUD.songProgressPanelGO; UnityEngine.Object.Destroy(baseGameProgress); if (Settings.Mode != ProgressMode.Percent) diff --git a/Counters+/Counters/ScoreCounter.cs b/Counters+/Counters/ScoreCounter.cs index 1d799386..69f91060 100644 --- a/Counters+/Counters/ScoreCounter.cs +++ b/Counters+/Counters/ScoreCounter.cs @@ -2,7 +2,6 @@ using TMPro; using UnityEngine; using Zenject; -using static CountersPlus.Utils.Accessors; namespace CountersPlus.Counters { @@ -26,16 +25,15 @@ public override void CounterInit() // 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(); - TextMeshProUGUI old = ScoreUIText(ref scoreUIController); - - GameObject baseGameScore = RelativeScoreGO(ref coreGameHUD); + TextMeshProUGUI old = coreGameHUD.GetComponentInChildren()._scoreText; + + GameObject baseGameScore = coreGameHUD.relativeScoreGo; baseGameScore.SetActive(true); relativeScoreText = baseGameScore.GetComponent(); relativeScoreText.enabled = true; relativeScoreText.color = Color.white; - GameObject baseGameRank = ImmediateRankGO(ref coreGameHUD); + GameObject baseGameRank = coreGameHUD.immediateRankGo; baseGameRank.SetActive(true); rankText = baseGameRank.GetComponent(); rankText.enabled = true; diff --git a/Counters+/Properties/AssemblyInfo.cs b/Counters+/Properties/AssemblyInfo.cs deleted file mode 100644 index 0caab3d4..00000000 --- a/Counters+/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Counters+")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Counters+")] -[assembly: AssemblyCopyright("Copyright © Caeden117 2018-2024")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: InternalsVisibleTo(IPA.Config.Stores.GeneratedStore.AssemblyVisibilityTarget)] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("6240d1b1-390e-4808-adf5-2f1c9e18317f")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.3.11")] -[assembly: AssemblyFileVersion("2.3.11")] diff --git a/Counters+/UI/FlowCoordinators/CountersPlusSettingsFlowCoordinator.cs b/Counters+/UI/FlowCoordinators/CountersPlusSettingsFlowCoordinator.cs index a02d7661..069883b9 100644 --- a/Counters+/UI/FlowCoordinators/CountersPlusSettingsFlowCoordinator.cs +++ b/Counters+/UI/FlowCoordinators/CountersPlusSettingsFlowCoordinator.cs @@ -9,14 +9,13 @@ using UnityEngine; using VRUIControls; using Zenject; -using static CountersPlus.Utils.Accessors; namespace CountersPlus.UI.FlowCoordinators { public class CountersPlusSettingsFlowCoordinator : FlowCoordinator { public readonly Vector3 MAIN_SCREEN_OFFSET = new Vector3(0, -4, 0); - + [Inject] public List AllConfigModels; [Inject] private CanvasUtility canvasUtility; @@ -28,6 +27,8 @@ public class CountersPlusSettingsFlowCoordinator : FlowCoordinator [Inject] private VRInputModule vrInputModule; [Inject] private MenuShockwave menuShockwave; [Inject] private PlayerDataModel playerDataModel; + [Inject] private MainFlowCoordinator mainFlowCoordinator; + [Inject] private EnvironmentsListModel environmentsListModel; [Inject] private CountersPlusCreditsViewController credits; [Inject] private CountersPlusBlankViewController blank; @@ -36,29 +37,19 @@ public class CountersPlusSettingsFlowCoordinator : FlowCoordinator [Inject] private SettingsManager settingsManager; [Inject] private SongPreviewPlayer songPreviewPlayer; - private HashSet persistentScenes = new HashSet(); private bool hasTransitioned = false; - private ScreenSystem screenSystem; - protected override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { - if (addedToHierarchy) { showBackButton = true; SetTitle("Counters+"); } - screenSystem = IPA.Utilities.ReflectionUtil.GetField(this, "_screenSystem"); - //screenSystem.backButtonWasPressedEvent += HandleBackButtonWasPressed; - ProvideInitialViewControllers(mainScreenNavigation, credits, null, settingsSelection); RefreshAllMockCounters(); - - // temp fix for menu env showing in settings - GameObject.Find("RootContainer/Wrapper/MenuEnvironmentManager/DefaultMenuEnvironment").SetActive(false); } public void DoSceneTransition(Action callback = null) @@ -67,21 +58,18 @@ public void DoSceneTransition(Action callback = null) hasTransitioned = true; - persistentScenes = GSMPersistentScenes(ref gameScenesManager); // Get our hashset of persistent scenes - // Make sure our menu persists through the transition - persistentScenes.Add("MenuCore"); + gameScenesManager._neverUnloadScenes.Add("MenuCore"); - var tutorialSceneSetup = MTHTutorialScenesSetup(ref menuTransitionsHelper); // Grab the scene transition setup data - tutorialSceneSetup.Init(playerDataModel.playerData.playerSpecificSettings); + menuTransitionsHelper._tutorialScenesTransitionSetupData.Init(playerDataModel.playerData.playerSpecificSettings, environmentsListModel, new GameplayAdditionalInformation()); menuEnvironmentManager.ShowEnvironmentType(MenuEnvironmentManager.MenuEnvironmentType.None); // We're actually transitioning to the Tutorial sequence, but disabling the tutorial itself from starting. - gameScenesManager.PushScenes(tutorialSceneSetup, 0.25f, null, (_) => + gameScenesManager.PushScenes(menuTransitionsHelper._tutorialScenesTransitionSetupData, 0.25f, null, (_) => { // god this makes me want to retire from beat saber modding - static void DisableAllNonImportantObjects(Transform original, Transform source, IEnumerable importantObjects) + static void DisableAllNonImportantObjects(Transform original, Transform source, string[] importantObjects) { foreach (Transform child in source) { @@ -119,7 +107,7 @@ static void DisableAllNonImportantObjects(Transform original, Transform source, songPreviewPlayer.CrossfadeToDefault(); // When not in FPFC, disable the Menu input, and re-enable the Tutorial menu input - if (!Environment.GetCommandLineArgs().Any(x => x.ToLowerInvariant() == "fpfc") && + if (!Environment.GetCommandLineArgs().Any(x => x.Equals("fpfc", StringComparison.OrdinalIgnoreCase)) && !Resources.FindObjectsOfTypeAll().Any(x => x.isActiveAndEnabled)) { vrInputModule.gameObject.SetActive(false); @@ -170,8 +158,7 @@ protected override void BackButtonWasPressed(ViewController topViewController) { hasTransitioned = false; canvasUtility.ClearAllText(); - screenSystem.backButtonWasPressedEvent -= HandleBackButtonWasPressed; - BeatSaberUI.MainFlowCoordinator.DismissFlowCoordinator(this, TransitionToMenu, ViewController.AnimationDirection.Horizontal, true); + mainFlowCoordinator.DismissFlowCoordinator(this, TransitionToMenu, ViewController.AnimationDirection.Horizontal, true); } private void HandleBackButtonWasPressed() => BackButtonWasPressed(topViewController); @@ -190,7 +177,7 @@ private void TransitionToMenu() gameScenesManager.PopScenes(0.25f, null, (_) => { // Unmark these scenes as persistent so they won't bother us in-game. - persistentScenes.Remove("MenuCore"); + gameScenesManager._neverUnloadScenes.Remove("MenuCore"); menuEnvironmentManager.ShowEnvironmentType(MenuEnvironmentManager.MenuEnvironmentType.Default); fadeInOutController.FadeIn(); songPreviewPlayer.CrossfadeToDefault(); diff --git a/Counters+/UI/ViewControllers/CountersPlusSettingSectionSelectionViewController.cs b/Counters+/UI/ViewControllers/CountersPlusSettingSectionSelectionViewController.cs index b70b63db..fac8ad7c 100644 --- a/Counters+/UI/ViewControllers/CountersPlusSettingSectionSelectionViewController.cs +++ b/Counters+/UI/ViewControllers/CountersPlusSettingSectionSelectionViewController.cs @@ -3,7 +3,6 @@ using BeatSaberMarkupLanguage.ViewControllers; using CountersPlus.UI.SettingGroups; using HMUI; -using IPA.Utilities; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; @@ -29,7 +28,7 @@ protected override void DidActivate(bool firstActivation, bool addedToHierarchy, { base.DidActivate(firstActivation, addedToHierarchy, screenSystemEnabling); - scrollView = tableList.TableView.GetField("_scrollView"); + scrollView = tableList.TableView.scrollView; scrollView.scrollPositionChangedEvent += ScrollView_scrollPositionChangedEvent; HandleCellSelectedEvent(null, (selectedGroup != null) ? loadedSettingsGroups.IndexOf(selectedGroup) : 0); @@ -46,13 +45,8 @@ private void Parsed() private void ScrollView_scrollPositionChangedEvent(float obj) { - // TODO convert into accessors - var destinationPos = scrollView.GetField("_destinationPos"); - var contentSize = scrollView.GetProperty("contentSize"); - var scrollPageSize = scrollView.GetProperty("scrollPageSize"); - - leftButton.interactable = destinationPos > 0.001f; - rightButton.interactable = destinationPos < contentSize - scrollPageSize - 0.001f; + leftButton.interactable = scrollView._destinationPos > 0.001f; + rightButton.interactable = scrollView._destinationPos < scrollView.contentSize - scrollView.scrollPageSize - 0.001f; } protected override void DidDeactivate(bool removedFromHierarchy, bool screenSystemDisabling) @@ -71,7 +65,7 @@ private void OptionSelected(TableView view, CountersPlusListTableCell cell) private void HandleCellSelectedEvent(SegmentedControl _, int cellIdx) { selectedGroup?.OnDisable(); - + selectedGroup = loadedSettingsGroups[cellIdx]; selectedGroup.OnEnable(); diff --git a/Counters+/Utils/Accessors.cs b/Counters+/Utils/Accessors.cs deleted file mode 100644 index 9e72e24c..00000000 --- a/Counters+/Utils/Accessors.cs +++ /dev/null @@ -1,28 +0,0 @@ -using IPA.Utilities; -using System.Collections.Generic; -using TMPro; -using UnityEngine; - -namespace CountersPlus.Utils -{ - /// - /// Class that contains various s that see use within Counters+. - /// - static class Accessors - { - #region Core Game HUD Components - public static FieldAccessor.Accessor SongProgressPanelGO = FieldAccessor.GetAccessor("_songProgressPanelGO"); - public static FieldAccessor.Accessor RelativeScoreGO = FieldAccessor.GetAccessor("_relativeScoreGO"); - public static FieldAccessor.Accessor ImmediateRankGO = FieldAccessor.GetAccessor("_immediateRankGO"); - public static FieldAccessor.Accessor EnergyPanelGO = FieldAccessor.GetAccessor("_energyPanelGO"); - #endregion - - #region Counters+ UI - public static FieldAccessor>.Accessor GSMPersistentScenes = FieldAccessor>.GetAccessor("_neverUnloadScenes"); - public static FieldAccessor.Accessor MTHTutorialScenesSetup = FieldAccessor.GetAccessor("_tutorialScenesTransitionSetupData"); - #endregion - - public static FieldAccessor.Accessor ScoreUIText = FieldAccessor.GetAccessor("_scoreText"); - public static FieldAccessor.Accessor SCGameplayModsModel = FieldAccessor.GetAccessor("_gameplayModifiersModel"); - } -} diff --git a/Counters+/Utils/CanvasUtility.cs b/Counters+/Utils/CanvasUtility.cs index 192c99ea..628ac442 100644 --- a/Counters+/Utils/CanvasUtility.cs +++ b/Counters+/Utils/CanvasUtility.cs @@ -1,13 +1,10 @@ using BeatSaberMarkupLanguage; using CountersPlus.ConfigModels; using HMUI; -using System.Collections; using System.Collections.Generic; -using System.Linq; using TMPro; using UnityEngine; using Zenject; -using static CountersPlus.Utils.Accessors; namespace CountersPlus.Utils { @@ -41,7 +38,7 @@ internal CanvasUtility(HUDConfigModel hudConfig, hudHeight = comboPos.y; hudDepth = comboPos.z; - energyCanvas = EnergyPanelGO(ref coreGameHUD).GetComponent(); + energyCanvas = coreGameHUD.energyPanelGo.GetComponent(); // Hide base game elements if needed if (mainConfig.HideCombo) HideBaseGameHUDElement(coreGameHUD); @@ -207,7 +204,7 @@ public TMP_Text CreateText(Canvas canvas, Vector3 anchoredPosition, Vector3? off tmp_text.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 2f); tmp_text.enableWordWrapping = false; tmp_text.overflowMode = TextOverflowModes.Overflow; - + if (mainConfig.ItalicText) { tmp_text.fontStyle = FontStyles.Italic; @@ -240,7 +237,7 @@ public Vector3 GetAnchoredPositionFromConfig(ConfigModel settings) var canvasSettings = GetCanvasSettingsFromID(settings.CanvasID); - Vector3 offset = new Vector3(0, -0.75f * (index * canvasSettings.DistanceModifier), 0); // Offset + Vector3 offset = new Vector3(0, -0.75f * (index * canvasSettings.DistanceModifier), 0); // Offset if (canvasSettings != null) { @@ -277,7 +274,7 @@ public Vector3 GetAnchoredPositionFromConfig(ConfigModel settings) } return pos + offset + hudHeightOffset; } - + public void ClearAllText() { foreach (Canvas canvas in CanvasIDToCanvas.Values) diff --git a/Counters+/Utils/VersionUtility.cs b/Counters+/Utils/VersionUtility.cs index b9c9b2b9..d8b86cbf 100644 --- a/Counters+/Utils/VersionUtility.cs +++ b/Counters+/Utils/VersionUtility.cs @@ -22,30 +22,42 @@ public VersionUtility() private IEnumerator GetBeatModsVersion() { - using (UnityWebRequest www = UnityWebRequest.Get("https://beatmods.com/api/v1/mod?search=Counters%2B")) + using (UnityWebRequest www = UnityWebRequest.Get("https://beatmods.com/api/mods/37")) { + www.SetRequestHeader("User-Agent", $"Counters+/{PluginVersion}"); yield return www.SendWebRequest(); - if (www.isHttpError || www.isNetworkError) + if (www.result != UnityWebRequest.Result.Success) { Plugin.Logger.Error("Failed to download version info."); yield break; } - BeatmodsResult[] results = JsonConvert.DeserializeObject(www.downloadHandler.text); - foreach (BeatmodsResult result in results) + BeatmodsResult result = JsonConvert.DeserializeObject(www.downloadHandler.text); + foreach (BeatmodsModVersionResult versionResult in result.mod.versions) { - if (result.status != "approved") continue; - BeatModsVersion = new Version(result.version); + if (versionResult.status != "verified") continue; + BeatModsVersion = new Version(versionResult.modVersion); break; } } if (!HasLatestVersion) Plugin.Logger.Warn("Uh oh! We aren't up to date!"); } - + } + class BeatmodsResult + { + [JsonProperty("mod")] internal BeatmodsModResult mod; + } + + class BeatmodsModResult + { + [JsonProperty("versions")] internal BeatmodsModVersionResult[] versions; + } + + class BeatmodsModVersionResult { [JsonProperty("status")] internal string status; - [JsonProperty("version")] internal string version; + [JsonProperty("modVersion")] internal string modVersion; } } diff --git a/Counters+/manifest.json b/Counters+/manifest.json index c8f24e98..8a15c6d9 100644 --- a/Counters+/manifest.json +++ b/Counters+/manifest.json @@ -6,7 +6,7 @@ "version": "2.3.11", "description": "A suite of enhancements for Beat Saber's UI.", "icon": "CountersPlus.UI.Images.Logo.png", - "gameVersion": "1.40.0", + "gameVersion": "1.42.0", "dependsOn": { "BSIPA": "^4.3.5", "BeatSaberMarkupLanguage": "^1.12.5", @@ -18,4 +18,4 @@ "type": "CountersPlus.Custom.CustomCounterFeature" } } -} \ No newline at end of file +}