SplashTexts.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. using UnityEngine;
  2. using GadgetCore.API;
  3. using UnityEngine.SceneManagement;
  4. using GadgetCore.API.ConfigMenu;
  5. using System;
  6. using System.Collections.Generic;
  7. namespace SplashTexts
  8. {
  9. [Gadget("SplashTexts", RequiredOnClients: false)]
  10. public class SplashTexts : Gadget<SplashTexts>
  11. {
  12. public const string MOD_VERSION = "1.1"; // Set this to the version of your mod.
  13. public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file.
  14. public override IGadgetConfigMenu GetConfigMenu() { return null; }
  15. public override string GetModDescription()
  16. {
  17. return "A mod that adds random splash texts to the main menu.";
  18. }
  19. protected override void Initialize()
  20. {
  21. Logger.Log("Splash Texts v" + Info.Mod.Version);
  22. Core.logger = Logger;
  23. SceneManager.sceneLoaded += OnSceneLoaded;
  24. ChangeMenuText();
  25. }
  26. internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
  27. {
  28. if (scene.buildIndex == 0)
  29. {
  30. ChangeMenuText();
  31. }
  32. }
  33. private static void ChangeMenuText()
  34. {
  35. try
  36. {
  37. var text = GetText();
  38. var textElement = GameObject.Find("MAIN").transform.Find("-").Find("txtALPHA").gameObject;
  39. var textElementShadow = textElement.transform.Find("txt0").gameObject;
  40. textElement.GetComponent<TextMesh>().color = SpliceColor(ref text);
  41. var shadowText = SpliceShadow(ref text);
  42. textElement.GetComponent<TextMesh>().text = text;
  43. textElementShadow.GetComponent<TextMesh>().text = shadowText;
  44. }
  45. catch (Exception e) { Core.logger.Log(e); }
  46. }
  47. private static System.Random random = new System.Random();
  48. private static string GetText()
  49. {
  50. List<string> texts = new List<string>();
  51. texts.Add("v1.5.1 Deluxe");
  52. texts.Add("10,000,000$ Edition");
  53. texts.Add("Premium Ultra Deluxe Gold Edition");
  54. texts.Add("#C#AAAAFF#Infinity Edition");
  55. texts.Add("Gadget Core " + GadgetCoreAPI.GetFullVersion());
  56. texts.Add("enhanced by Gadget Core");
  57. texts.Add("There are mods?");
  58. texts.Add("1 + 5 = 1#S#1 + 5 = 6");
  59. texts.Add("v1.5.1#S#v1.5");
  60. texts.Add("v1.5.1#S# 1");
  61. texts.Add("v1.5.1");
  62. texts.Add("v?.?.?");
  63. texts.Add("Magicite 2");
  64. texts.Add("Magicite In Space");
  65. texts.Add("I wouldn't talk to the guy with the pickaxe.");
  66. texts.Add("You should talk to the guy with the pickaxe.");
  67. texts.Add("powered by Unity");
  68. texts.Add("5% Explosions");
  69. Gadget[] gadgets = Gadgets.ListAllEnabledGadgets();
  70. if (gadgets.Length > 0)
  71. {
  72. Gadget g = gadgets[random.Next(gadgets.Length)];
  73. texts.Add(g.Info.ModName + " included");
  74. }
  75. if (random.Next(4) == 0)
  76. {
  77. texts.Add("#C#2160FF#Play Galactic Fleet");
  78. texts.Add("#C#AF9346#Play Church of Faust");
  79. texts.Add("#C#F42912#Play Starlight Rebellion");
  80. texts.Add("#C#632887#Play Gray Enigma");
  81. }
  82. if (random.Next(6) == 0)
  83. {
  84. texts.Add("#C#2160FF#Galactic Fleet is the best!");
  85. texts.Add("#C#AF9346#Church of Faust is the best!");
  86. texts.Add("#C#F42912#Starlight Rebellion is the best!");
  87. texts.Add("#C#632887#Gray Enigma is the best!");
  88. }
  89. texts.Add("The shrooms want to cuddle.");
  90. texts.Add("42");
  91. var time = DateTime.Now;
  92. texts.Add(time.Hour + ":" + time.Minute + ":" + time.Minute);
  93. texts.Add(((time.Hour + 11) % 12 + 1) + ":" + time.Minute + ":" + time.Minute + " " + (time.Hour >= 12 ? "PM" : "AM"));
  94. texts.Add("maybe " + (time.Year + 1) + "?");
  95. texts.Add(((int)(time - new DateTime(2017, 2, 14)).TotalSeconds)+ " seconds already");
  96. texts.Add("made on earth");
  97. for (int j = 0; j < 3; j++)
  98. {
  99. int i = random.Next(6);
  100. int @int = PreviewLabs.PlayerPrefs.GetInt(i + "isChar");
  101. if (@int > 0)
  102. {
  103. var name = PreviewLabs.PlayerPrefs.GetString(i + "name");
  104. texts.Add("Hi, " + name + "!");
  105. texts.Add("Have a nice day " + name + "!");
  106. break;
  107. }
  108. }
  109. texts.Add("Have a nice day!");
  110. texts.Add("You should go to sleep.");
  111. texts.Add("OwO");
  112. texts.Add(":3");
  113. texts.Add("Nice");
  114. texts.Add("made by Sean Young");
  115. texts.Add("music by Bashi Boizu");
  116. texts.Add("Exodus exists");
  117. texts.Add("end of 2019");
  118. texts.Add("finished since 2017");
  119. texts.Add("Rock Scarabs do like that.");
  120. texts.Add("RUN TO THE PORTALS!!!");
  121. texts.Add("Graphics: AMAZING");
  122. return texts[random.Next(texts.Count)];
  123. }
  124. private static Color SpliceColor(ref string s)
  125. {
  126. if (s.StartsWith("#C#"))
  127. {
  128. try
  129. {
  130. var ar = s.Split(new char[] { '#' }, 4);
  131. s = ar[3];
  132. if (ar[2].Length == 6)
  133. {
  134. var i1 = Convert.ToInt32(ar[2].Substring(0, 2), 16);
  135. var i2 = Convert.ToInt32(ar[2].Substring(2, 2), 16);
  136. var i3 = Convert.ToInt32(ar[2].Substring(4, 2), 16);
  137. return new Color(((float)i1) / 0xFF, ((float)i2) / 0xFF, ((float)i3) / 0xFF);
  138. }
  139. }
  140. catch { }
  141. }
  142. return new Color(((float)0xFF) / 0xFF, ((float)0xD7) / 0xFF, ((float)0x31) / 0xFF);
  143. }
  144. private static string SpliceShadow(ref string s)
  145. {
  146. if (s.Contains("#S#"))
  147. {
  148. try
  149. {
  150. var ar = s.Split(new string[] { "#S#" }, 2, StringSplitOptions.None);
  151. s = ar[0];
  152. return ar[1];
  153. }
  154. catch { }
  155. }
  156. return s;
  157. }
  158. }
  159. }