Skip to content

Commit b9f19f6

Browse files
committed
DiColors support
1 parent 5174065 commit b9f19f6

File tree

6 files changed

+105
-31
lines changed

6 files changed

+105
-31
lines changed

CustomMenuText/Configuration/PluginConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ internal class PluginConfig
1010
public static PluginConfig Instance { get; set; }
1111
public virtual int SelectionType { get; set; } = 0;
1212
public virtual int SelectedEntry { get; set; } = 0;
13+
public virtual bool UsingDiColors { get; set; } = true;
1314

1415
/// <summary>
1516
/// This is called whenever BSIPA reads the config from disk (including when file changes are detected).

CustomMenuText/CustomMenuText.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
<HintPath>$(BeatSaberDir)\Plugins\BSML.dll</HintPath>
4646
<SpecificVersion>False</SpecificVersion>
4747
</Reference>
48+
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
49+
<Private>False</Private>
50+
<HintPath>$(BeatSaberDir)\Libs\Newtonsoft.Json.dll</HintPath>
51+
<SpecificVersion>False</SpecificVersion>
52+
</Reference>
4853
<Reference Include="System" />
4954
<Reference Include="System.Core" />
5055
<Reference Include="System.Xml.Linq" />

CustomMenuText/Plugin.cs

Lines changed: 96 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.IO;
1313
using System.Text;
1414
using System.Reflection;
15+
using System.Threading.Tasks;
1516

1617
namespace CustomMenuText
1718
{
@@ -20,6 +21,9 @@ public class Plugin
2021
{
2122
public static int selection_type = 0;
2223
public static int choice = 0;
24+
internal static bool DiColorFound = false;
25+
26+
public static GameObject defaultLogo = new GameObject();
2327

2428
internal static Plugin Instance { get; private set; }
2529
internal static IPALogger Log { get; private set; }
@@ -65,7 +69,10 @@ public void InitWithConfig(Config conf)
6569
// used if we can't load any custom entries
6670
public static readonly string[] DEFAULT_TEXT = { "BEAT", "SABER" };
6771
public static readonly Color defaultMainColor = Color.red;
68-
public static readonly Color defaultBottomColor = new Color(0, 0.5019608f, 1);
72+
public static readonly Color defaultBottomColor = new Color(0, 0.659f, 1);
73+
74+
public static Color DiTopColor = Color.red;
75+
public static Color DiBottomColor = new Color(0, 0.5019608f, 1);
6976

7077
public const string DEFAULT_CONFIG =
7178
@"# Custom Menu Text v3.1.3
@@ -233,11 +240,34 @@ public void OnApplicationStart()
233240
SceneManager.sceneLoaded += SceneManager_sceneLoaded;
234241
Views.UICreator.CreateMenu();
235242
}
243+
public void YeetUpTheText()
244+
{
245+
switch (Configuration.PluginConfig.Instance.SelectionType)
246+
{
247+
case 0:
248+
//default
249+
setText(DEFAULT_TEXT);
250+
break;
251+
case 1:
252+
//random
253+
pickRandomEntry();
254+
break;
255+
case 2:
256+
//pre-chosen
257+
setText(allEntries[choice]);
258+
break;
259+
}
260+
}
236261

237262
private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene arg1)
238263
{
264+
265+
266+
267+
Log.Notice("Changed to scene " + arg1.name);
239268
if (arg1.name.Contains("Menu")) // Only run in menu scene
240269
{
270+
_ = FindDiColors();
241271
if (allEntries == null)
242272
{
243273
reloadFile();
@@ -248,23 +278,7 @@ private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene arg1)
248278
}
249279
else
250280
{
251-
switch (Configuration.PluginConfig.Instance.SelectionType)
252-
{
253-
case 0:
254-
//default
255-
setText(DEFAULT_TEXT);
256-
break;
257-
case 1:
258-
//random
259-
pickRandomEntry();
260-
break;
261-
case 2:
262-
//pre-chosen
263-
setText(allEntries[choice]);
264-
break;
265-
}
266-
267-
281+
YeetUpTheText();
268282
}
269283
}
270284
}
@@ -289,7 +303,10 @@ public void pickRandomEntry()
289303

290304
private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
291305
{
292-
306+
if (arg0.name.Equals("MenuCore"))
307+
{
308+
_ = FindDiColors();
309+
}
293310
}
294311

295312
public static GameObject loadTextPrefab(string path)
@@ -396,6 +413,10 @@ public static List<string[]> readFromFile(string relPath)
396413
///
397414
/// Code generously donated by Kyle1413; edited some by Arti
398415
/// </summary>
416+
///
417+
418+
419+
399420
public static void replaceLogo()
400421
{
401422
// Since 0.13.0, we have to create our TextMeshPros differently! You can't change the font at runtime, so we load a prefab with the right font from an AssetBundle. This has the side effect of allowing for custom fonts, an oft-requested feature.
@@ -404,6 +425,8 @@ public static void replaceLogo()
404425

405426
// Logo Top Pos : 0.63, 21.61, 24.82
406427
// Logo Bottom Pos : 0, 17.38, 24.82
428+
429+
407430
if (mainText == null) mainText = GameObject.Find("CustomMenuText")?.GetComponent<TextMeshPro>();
408431
if (mainText == null)
409432
{
@@ -421,8 +444,19 @@ public static void replaceLogo()
421444
mainText.enableWordWrapping = false;
422445
textObj.SetActive(true);
423446
}
424-
mainText.rectTransform.position = new Vector3(0f, 21.61f, 24.82f);
425-
mainText.color = defaultMainColor;
447+
mainText.rectTransform.position = new Vector3(0f, 18.61f, 26.1f);
448+
449+
switch (Configuration.PluginConfig.Instance.UsingDiColors)
450+
{
451+
case true:
452+
mainText.color = DiTopColor;
453+
break;
454+
case false:
455+
mainText.color = defaultMainColor;
456+
break;
457+
}
458+
459+
mainText.name = "CustomBeatText";
426460
mainText.text = "BEAT";
427461

428462
if (bottomText == null) bottomText = GameObject.Find("CustomMenuText-Bot")?.GetComponent<TextMeshPro>();
@@ -442,15 +476,51 @@ public static void replaceLogo()
442476
bottomText.enableWordWrapping = false;
443477
textObj2.SetActive(true);
444478
}
445-
bottomText.rectTransform.position = new Vector3(0f, 17f, 24.82f);
446-
bottomText.color = defaultBottomColor;
447-
mainText.text = "SABER";
479+
bottomText.rectTransform.position = new Vector3(0f, 14f, 26.1f);
480+
switch (Configuration.PluginConfig.Instance.UsingDiColors)
481+
{
482+
case true:
483+
bottomText.color = DiBottomColor;
484+
break;
485+
case false:
486+
bottomText.color = defaultBottomColor;
487+
break;
488+
}
489+
bottomText.name = "CustomSaberText";
490+
bottomText.text = "SABER";
491+
492+
448493

449494
// Destroy Default Logo
450-
GameObject defaultLogo = FindUnityObjectsHelper.GetAllGameObjectsInLoadedScenes().Where(go => go.name == "Logo").FirstOrDefault();
451-
if (defaultLogo != null) GameObject.Destroy(defaultLogo);
495+
defaultLogo = FindUnityObjectsHelper.GetAllGameObjectsInLoadedScenes().Where(go => go.name == "Logo").FirstOrDefault();
496+
if (defaultLogo != null) defaultLogo.SetActive(false);
497+
}
498+
499+
public async Task FindDiColors()
500+
{
501+
//find default logo, for DiColors
502+
await Task.Delay(2500);
503+
GameObject topLogo = FindUnityObjectsHelper.GetAllGameObjectsInLoadedScenes().Where(go => go.name == "BatLogo").FirstOrDefault();
504+
GameObject bottomLogo = FindUnityObjectsHelper.GetAllGameObjectsInLoadedScenes().Where(go => go.name == "SaberLogo").FirstOrDefault();
505+
506+
SpriteRenderer topSprite = (SpriteRenderer)topLogo.GetComponent(typeof(SpriteRenderer));
507+
SpriteRenderer bottomSprite = (SpriteRenderer)bottomLogo.GetComponent(typeof(SpriteRenderer));
508+
Plugin.Log.Notice("color yeet " + topSprite.color.ToString());
509+
Plugin.Log.Notice("color yeet 2 " + bottomSprite.color.ToString());
510+
DiTopColor = topSprite.color;
511+
DiBottomColor = bottomSprite.color;
512+
Plugin.Log.Notice("found DiColors");
513+
Plugin.Log.Notice("color " + DiTopColor);
514+
Plugin.Log.Notice("color " + DiBottomColor);
515+
DiColorFound = true;
516+
replaceLogo();
517+
YeetUpTheText();
452518
}
453519

520+
521+
522+
523+
454524
/// <summary>
455525
/// Sets the text in the main menu (which normally reads BEAT SABER) to
456526
/// the text of your choice. TextMeshPro formatting can be used here.

CustomMenuText/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("3.2.0")]
36-
[assembly: AssemblyFileVersion("3.2.0")]
35+
[assembly: AssemblyVersion("3.2.1")]
36+
[assembly: AssemblyFileVersion("3.2.1")]

CustomMenuText/Views/TextSelector/TextSelectorViewController.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
using UnityEngine;
1111
using UnityEngine.UI;
1212
using HMUI;
13-
using System.Linq;
14-
using BeatSaberMarkupLanguage.ViewControllers;
1513

1614
namespace CustomMenuText.ViewControllers
1715
{

CustomMenuText/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"id": "CustomMenuText",
44
"name": "CustomMenuText",
55
"author": "headassbtw",
6-
"version": "3.2.0",
6+
"version": "3.2.1",
77
"description": "",
88
"gameVersion": "1.13.2",
99
"dependsOn": {

0 commit comments

Comments
 (0)