瀏覽代碼

Merge branch 'jumpstart-offset-stat'

Halsafar 4 年之前
父節點
當前提交
28e5deffdf

二進制
SongBrowserPlugin/Assets/NoteStartOffset.png


+ 11 - 36
SongBrowserPlugin/Internals/BeatSaberUI.cs

@@ -171,45 +171,20 @@ namespace SongBrowser.Internals
             return btn;
         }
 
-        /// <summary>
-        /// Creates a TextMeshProUGUI component.
-        /// </summary>
-        /// <param name="parent">Thet ransform to parent the new TextMeshProUGUI component to.</param>
-        /// <param name="text">The text to be displayed.</param>
-        /// <param name="anchoredPosition">The position the button should be anchored to.</param>
-        /// <returns>The newly created TextMeshProUGUI component.</returns>
-        public static TextMeshProUGUI CreateText(RectTransform parent, string text, Vector2 anchoredPosition)
+        public static RectTransform CreateStatIcon(string name, RectTransform template, Transform parent, Sprite icon, String hoverHintText = null)
         {
-            return CreateText(parent, text, anchoredPosition, new Vector2(60f, 10f));
-        }
+            RectTransform statIcon = UnityEngine.Object.Instantiate(template, parent, false);
+            statIcon.name = name;
+            (statIcon.transform as RectTransform).Translate(0, -0.1f, 0);
+            BeatSaberUI.SetStatButtonIcon(statIcon, icon);
+            BeatSaberUI.DestroyHoverHint(statIcon);
 
-        /// <summary>
-        /// Creates a TextMeshProUGUI component.
-        /// </summary>
-        /// <param name="parent">Thet transform to parent the new TextMeshProUGUI component to.</param>
-        /// <param name="text">The text to be displayed.</param>
-        /// <param name="anchoredPosition">The position the text component should be anchored to.</param>
-        /// <param name="sizeDelta">The size of the text components RectTransform.</param>
-        /// <returns>The newly created TextMeshProUGUI component.</returns>
-        public static TextMeshProUGUI CreateText(RectTransform parent, string text, Vector2 anchoredPosition, Vector2 sizeDelta)
-        {
-            GameObject gameObj = new GameObject("CustomUIText");
-            gameObj.SetActive(false);
-
-            TextMeshProUGUI textMesh = gameObj.AddComponent<TextMeshProUGUI>();
-            textMesh.font = UnityEngine.GameObject.Instantiate(Resources.FindObjectsOfTypeAll<TMP_FontAsset>().First(t => t.name == "Teko-Medium SDF No Glow"));
-            textMesh.rectTransform.SetParent(parent, false);
-            textMesh.text = text;
-            textMesh.fontSize = 4;
-            textMesh.color = Color.white;
-
-            textMesh.rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
-            textMesh.rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
-            textMesh.rectTransform.sizeDelta = sizeDelta;
-            textMesh.rectTransform.anchoredPosition = anchoredPosition;
+            if (!String.IsNullOrEmpty(hoverHintText))
+            {
+                BeatSaberUI.SetHoverHint(statIcon, $"{name}_hoverHintText", hoverHintText);
+            }
 
-            gameObj.SetActive(true);
-            return textMesh;
+            return statIcon;
         }
 
         /// <summary>

+ 1 - 1
SongBrowserPlugin/SongBrowser.csproj

@@ -167,6 +167,7 @@
     <EmbeddedResource Include="Assets\Search.png" />
     <EmbeddedResource Include="Assets\Speed.png" />
     <EmbeddedResource Include="Assets\X.png" />
+    <EmbeddedResource Include="Assets\NoteStartOffset.png" />
   </ItemGroup>
   <ItemGroup>
     <None Include="packages.config" />
@@ -174,7 +175,6 @@
   <ItemGroup>
     <EmbeddedResource Include="manifest.json" />
   </ItemGroup>
-  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <PropertyGroup>
     <PostBuildEvent>IF EXIST "C:\Program Files\Oculus\Software\Software\hyperbolic-magnetism-beat-saber\Plugins" xcopy "$(TargetDir)$(TargetFileName)" "C:\Program Files\Oculus\Software\Software\hyperbolic-magnetism-beat-saber\Plugins" /Y

+ 3 - 1
SongBrowserPlugin/UI/Base64Sprites.cs

@@ -14,8 +14,9 @@ namespace SongBrowser.UI
         public static Sprite GraphIcon;
         public static Sprite DeleteIcon;
         public static Sprite XIcon;
-        public static Sprite RandomIcon;
         public static Sprite DoubleArrow;
+        public static Sprite RandomIcon;
+        public static Sprite NoteStartOffsetIcon;        
 
         public static void Init()
         {
@@ -26,6 +27,7 @@ namespace SongBrowser.UI
             DeleteIcon = Base64Sprites.LoadSpriteFromResources("SongBrowser.Assets.DeleteIcon.png");
             DoubleArrow = Base64Sprites.LoadSpriteFromResources("SongBrowser.Assets.DoubleArrow.png");
             RandomIcon = Base64Sprites.LoadSpriteFromResources("SongBrowser.Assets.RandomIcon.png");
+            NoteStartOffsetIcon = Base64Sprites.LoadSpriteFromResources("SongBrowser.Assets.NoteStartOffset.png");
         }
 
         public static string SpriteToBase64(Sprite input)

+ 30 - 24
SongBrowserPlugin/UI/Browser/SongBrowserUI.cs

@@ -66,6 +66,7 @@ namespace SongBrowser.UI
         private RectTransform _ppStatButton;
         private RectTransform _starStatButton;
         private RectTransform _njsStatButton;
+        private RectTransform _noteJumpStartBeatOffsetLabel;
 
         private IAnnotatedBeatmapLevelCollection _lastLevelCollection;
 
@@ -405,26 +406,29 @@ namespace SongBrowser.UI
             var statsPanel = _beatUi.StandardLevelDetailView.GetPrivateField<LevelParamsPanel>("_levelParamsPanel");
             (statsPanel.transform as RectTransform).Translate(0, 0.05f, 0);
 
-            _ppStatButton = UnityEngine.Object.Instantiate(statsPanel.GetComponentsInChildren<RectTransform>().First(x => x.name == "NPS"), statsPanel.transform, false);
-            _ppStatButton.name = "PPStatLabel";
-            (_ppStatButton.transform as RectTransform).Translate(0, -0.1f, 0);
-            BeatSaberUI.SetStatButtonIcon(_ppStatButton, Base64Sprites.GraphIcon);
-            BeatSaberUI.DestroyHoverHint(_ppStatButton);
-            BeatSaberUI.SetHoverHint(_ppStatButton, "songBrowser_ppValue", "PP Value");
-
-            _starStatButton = UnityEngine.Object.Instantiate(statsPanel.GetComponentsInChildren<RectTransform>().First(x => x.name == "NotesCount"), statsPanel.transform, false);
-            _starStatButton.name = "StarStatLabel";
-            (_starStatButton.transform as RectTransform).Translate(0, -0.1f, 0);
-            BeatSaberUI.SetStatButtonIcon(_starStatButton, Base64Sprites.StarFullIcon);
-            BeatSaberUI.DestroyHoverHint(_starStatButton);
-            BeatSaberUI.SetHoverHint(_starStatButton, "songBrowser_starValue", "Star Difficulty Rating");
-
-            _njsStatButton = UnityEngine.Object.Instantiate(statsPanel.GetComponentsInChildren<RectTransform>().First(x => x.name == "ObstaclesCount"), statsPanel.transform, false);
-            _njsStatButton.name = "NoteJumpSpeedLabel";
-            (_njsStatButton.transform as RectTransform).Translate(0, -0.1f, 0);
-            BeatSaberUI.SetStatButtonIcon(_njsStatButton, Base64Sprites.SpeedIcon);
-            BeatSaberUI.DestroyHoverHint(_njsStatButton);
-            BeatSaberUI.SetHoverHint(_njsStatButton, "songBrowser_njsValue", "Note Jump Speed");
+            _ppStatButton = BeatSaberUI.CreateStatIcon("PPStatLabel",
+                statsPanel.GetComponentsInChildren<RectTransform>().First(x => x.name == "NPS"), 
+                statsPanel.transform,
+                Base64Sprites.GraphIcon,
+                "PP Value");
+
+            _starStatButton = BeatSaberUI.CreateStatIcon("StarStatLabel",
+                statsPanel.GetComponentsInChildren<RectTransform>().First(x => x.name == "NotesCount"),
+                statsPanel.transform,
+                Base64Sprites.StarFullIcon,
+                "Star Difficulty Rating");
+
+            _njsStatButton = BeatSaberUI.CreateStatIcon("NoteJumpSpeedLabel",
+                statsPanel.GetComponentsInChildren<RectTransform>().First(x => x.name == "ObstaclesCount"),
+                statsPanel.transform,
+                Base64Sprites.SpeedIcon,
+                "Note Jump Speed");
+
+            _noteJumpStartBeatOffsetLabel = BeatSaberUI.CreateStatIcon("NoteJumpStartBeatOffsetLabel",
+                statsPanel.GetComponentsInChildren<RectTransform>().First(x => x.name == "BombsCount"),
+                statsPanel.transform,
+                Base64Sprites.NoteStartOffsetIcon,
+                "Note Jump Start Beat Offset");
         }
 
         /// <summary>
@@ -846,7 +850,8 @@ namespace SongBrowser.UI
                 if (_beatUi.StandardLevelDetailView != null)
                 {
                     RefreshScoreSaberData(_beatUi.StandardLevelDetailView.selectedDifficultyBeatmap.level);
-                    RefreshNoteJumpSpeed(_beatUi.StandardLevelDetailView.selectedDifficultyBeatmap.noteJumpMovementSpeed);
+                    RefreshNoteJumpSpeed(_beatUi.StandardLevelDetailView.selectedDifficultyBeatmap.noteJumpMovementSpeed,
+                        _beatUi.StandardLevelDetailView.selectedDifficultyBeatmap.noteJumpStartBeatOffset);
                 }
             }
             catch (Exception e)
@@ -873,7 +878,7 @@ namespace SongBrowser.UI
             }
 
             RefreshScoreSaberData(view.selectedDifficultyBeatmap.level);
-            RefreshNoteJumpSpeed(beatmap.noteJumpMovementSpeed);
+            RefreshNoteJumpSpeed(beatmap.noteJumpMovementSpeed, beatmap.noteJumpStartBeatOffset);
         }
 
         /// <summary>
@@ -902,7 +907,7 @@ namespace SongBrowser.UI
             }
 
             RefreshScoreSaberData(view.selectedDifficultyBeatmap.level);
-            RefreshNoteJumpSpeed(view.selectedDifficultyBeatmap.noteJumpMovementSpeed);
+            RefreshNoteJumpSpeed(view.selectedDifficultyBeatmap.noteJumpMovementSpeed, view.selectedDifficultyBeatmap.noteJumpStartBeatOffset);
         }
 
         /// <summary>
@@ -1101,9 +1106,10 @@ namespace SongBrowser.UI
         /// Helper to refresh the NJS widget.
         /// </summary>
         /// <param name="noteJumpMovementSpeed"></param>
-        private void RefreshNoteJumpSpeed(float noteJumpMovementSpeed)
+        private void RefreshNoteJumpSpeed(float noteJumpMovementSpeed, float noteJumpStartBeatOffset)
         {
             BeatSaberUI.SetStatButtonText(_njsStatButton, String.Format("{0}", noteJumpMovementSpeed));
+            BeatSaberUI.SetStatButtonText(_noteJumpStartBeatOffsetLabel, String.Format("{0}", noteJumpStartBeatOffset));
         }
 
         /// <summary>