Seven is the number.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

244 lines
8.4 KiB

3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Text.RegularExpressions;
  5. using Photon.Bolt.Editor.Utils;
  6. using UnityEditor;
  7. using UnityEngine;
  8. namespace Photon.Bolt.Editor
  9. {
  10. public partial class BoltWizardWindow
  11. {
  12. [Flags]
  13. enum PackageFlags
  14. {
  15. WarnForProjectOverwrite = 1 << 1,
  16. RunInitialSetup = 1 << 2
  17. }
  18. class BoltWizardText
  19. {
  20. internal static readonly string WINDOW_TITLE = "Bolt Wizard";
  21. internal static readonly string SUPPORT = "You can contact the Bolt Team or Photon Services using one of the following links. You can also go to Bolt Documentation in order to get started with Photon Bolt.";
  22. internal static readonly string PACKAGES = "Here you will be able to select all packages you want to use into your project. Packages marked green are already installed. \nClick to install.";
  23. internal static readonly string PHOTON = "In this step, you will configure your Photon Cloud credentials in order to use our servers for matchmaking, relay and much more. Please fill all fields with your desired configuration.";
  24. internal static readonly string PHOTON_DASH = "Go to Dashboard to create your App ID: ";
  25. internal static readonly string CONNECTION_TITLE = "Connecting";
  26. internal static readonly string CONNECTION_INFO = "Connecting to the account service...";
  27. internal static readonly string FINISH_TITLE = "Bolt Setup Complete";
  28. internal static readonly string FINISH_QUESTION = "In order to finish the setup, Bolt needs to compile all Assets, do you want to proceed? If you opt to not compile now, you can run it on \"Bolt/Compile Assembly\".";
  29. internal static readonly string CLOSE_MSG_TITLE = "Incomplete Installation";
  30. internal static readonly string CLOSE_MSG_QUESTION = "Are you sure you want to exit the Wizard?";
  31. internal static readonly string DISCORD_TEXT = "Join the Bolt Discord Community.";
  32. internal static readonly string DISCORD_HEADER = "Community";
  33. internal static readonly string BUGTRACKER_TEXT = "Open bugtracker on github.";
  34. internal static readonly string BUGTRACKER_HEADER = "Bug Tracker";
  35. internal static readonly string DOCUMENTATION_TEXT = "Open the documentation.";
  36. internal static readonly string DOCUMENTATION_HEADER = "Documentation";
  37. internal static readonly string REVIEW_TEXT = "Please, let others know what you think about Bolt.";
  38. internal static readonly string REVIEW_HEADER = "Leave a review";
  39. internal static readonly string SAMPLES_TEXT = "Import the samples package.";
  40. internal static readonly string SAMPLES_HEADER = "Samples";
  41. internal static readonly string WIZARD_INTRO =
  42. @"Hello! Welcome to Bolt Wizard!
  43. We are glad that you decided to use our products and services. Here at Photon, we work hard to make your multiplayer game easier to build and much more fun to play.
  44. This is a simple step by step configuration that you can follow and in just a few minutes you will be ready to use Bolt in all its power. If you have any doubt, please to our Getting Started page.
  45. Please, feel free to click on the Next button, and get started.";
  46. }
  47. class BoltPackage
  48. {
  49. public string name;
  50. public string title;
  51. public string description;
  52. public Func<bool> installTest;
  53. public PackageFlags packageFlags = default(PackageFlags);
  54. }
  55. enum BoltSetupStage
  56. {
  57. Intro = 1,
  58. ReleaseHistory = 2,
  59. Photon = 3,
  60. Bolt = 4,
  61. Support = 5
  62. }
  63. [Flags]
  64. enum BoltInstalls
  65. {
  66. Core = 1 << 0,
  67. Mobile = 1 << 1,
  68. Samples = 1 << 3,
  69. XB1 = 1 << 4,
  70. PS4 = 1 << 5
  71. }
  72. String PackagePath(String packageName)
  73. {
  74. return Path.Combine(BoltPathUtility.PackagesPath, packageName + ".unitypackage");
  75. }
  76. Boolean PackageExists(String packageName)
  77. {
  78. return File.Exists(PackagePath(packageName));
  79. }
  80. Boolean ProjectExists()
  81. {
  82. return File.Exists(BoltPathUtility.ProjectPath);
  83. }
  84. Boolean MainPackageInstalled()
  85. {
  86. string SETTINGS_PATH = Path.Combine(BoltPathUtility.ResourcesPath, "BoltRuntimeSettings.asset");
  87. string PREFABDB_PATH = Path.Combine(BoltPathUtility.ResourcesPath, "BoltPrefabDatabase.asset");
  88. return File.Exists(SETTINGS_PATH) && File.Exists(PREFABDB_PATH);
  89. }
  90. Boolean SamplesPackageInstalled()
  91. {
  92. return Directory.Exists("Assets/samples");
  93. }
  94. Boolean XB1PackageInstalled()
  95. {
  96. return File.Exists("Assets/Plugins/XB1.dll");
  97. }
  98. Boolean PS4PackageInstalled()
  99. {
  100. return File.Exists("Assets/Plugins/PS4.dll");
  101. }
  102. Boolean MobilePackageInstalled()
  103. {
  104. return Directory.Exists("Assets/Plugins/iOS") && Directory.Exists("Assets/Plugins/Android");
  105. }
  106. Action OpenURL(String url, params System.Object[] args)
  107. {
  108. return () =>
  109. {
  110. if (args.Length > 0)
  111. {
  112. url = String.Format(url, args);
  113. }
  114. Application.OpenURL(url);
  115. };
  116. }
  117. void InitialSetup()
  118. {
  119. string SETTINGS_PATH = Path.Combine(BoltPathUtility.ResourcesPath, "BoltRuntimeSettings.asset");
  120. string PREFABDB_PATH = Path.Combine(BoltPathUtility.ResourcesPath, "BoltPrefabDatabase.asset");
  121. if (!AssetDatabase.LoadAssetAtPath(SETTINGS_PATH, typeof(BoltRuntimeSettings)))
  122. {
  123. BoltRuntimeSettings settings = CreateInstance<BoltRuntimeSettings>();
  124. AssetDatabase.CreateAsset(settings, SETTINGS_PATH);
  125. AssetDatabase.ImportAsset(SETTINGS_PATH, ImportAssetOptions.Default);
  126. }
  127. if (!AssetDatabase.LoadAssetAtPath(PREFABDB_PATH, typeof(PrefabDatabase)))
  128. {
  129. AssetDatabase.CreateAsset(CreateInstance<PrefabDatabase>(), PREFABDB_PATH);
  130. AssetDatabase.ImportAsset(PREFABDB_PATH, ImportAssetOptions.Default);
  131. }
  132. BoltMenuItems.RunCompiler();
  133. }
  134. static bool IsAppId(string val)
  135. {
  136. try
  137. {
  138. #pragma warning disable RECS0026 // Possible unassigned object created by 'new'
  139. new Guid(val);
  140. #pragma warning restore RECS0026 // Possible unassigned object created by 'new'
  141. }
  142. catch
  143. {
  144. return false;
  145. }
  146. return true;
  147. }
  148. private void PrepareReleaseHistoryText()
  149. {
  150. var text = (TextAsset)AssetDatabase.LoadAssetAtPath(Path.Combine(BoltPathUtility.BasePath, "release_history.txt"), typeof(TextAsset));
  151. var baseText = text.text;
  152. var regexVersion = new Regex(@"^(\d+\.?)+", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Multiline);
  153. var regexAdded = new Regex(@"\b(Added:)(.*)\b", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Multiline);
  154. var regexChanged = new Regex(@"\b(Changed:)(.*)\b", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Multiline);
  155. var regexFixed = new Regex(@"\b(Fixed:)(.*)\b", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Multiline);
  156. var regexRemoved = new Regex(@"\b(Removed:)(.*)\b", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Multiline);
  157. var matches = regexVersion.Matches(baseText);
  158. if (matches.Count > 0)
  159. {
  160. var currentVersionMatch = matches[0];
  161. var lastVersionMatch = currentVersionMatch.NextMatch();
  162. if (currentVersionMatch.Success && lastVersionMatch.Success)
  163. {
  164. var header = currentVersionMatch.Value.Trim();
  165. var mainText = baseText.Substring(currentVersionMatch.Index + currentVersionMatch.Length,
  166. lastVersionMatch.Index - lastVersionMatch.Length - 1).Trim();
  167. var resultAdded = regexAdded.Matches(mainText);
  168. var resultChanged = regexChanged.Matches(mainText);
  169. var resultFixed = regexFixed.Matches(mainText);
  170. var resultRemoved = regexRemoved.Matches(mainText);
  171. Func<MatchCollection, List<string>> itemProcessor = (match) =>
  172. {
  173. var resultList = new List<string>();
  174. for (var index = 0; index < match.Count; index++)
  175. {
  176. var result = match[index];
  177. resultList.Add(result.Groups[2].Value.Trim());
  178. }
  179. return resultList;
  180. };
  181. ReleaseHistoryHeader = header;
  182. ReleaseHistoryTextAdded = itemProcessor(resultAdded);
  183. ReleaseHistoryTextChanged = itemProcessor(resultChanged);
  184. ReleaseHistoryTextFixed = itemProcessor(resultFixed);
  185. ReleaseHistoryTextRemoved = itemProcessor(resultRemoved);
  186. }
  187. }
  188. else
  189. {
  190. ReleaseHistoryHeader = "Please look the file release_history.txt";
  191. ReleaseHistoryTextAdded = new List<string>();
  192. ReleaseHistoryTextChanged = new List<string>();
  193. ReleaseHistoryTextFixed = new List<string>();
  194. ReleaseHistoryTextRemoved = new List<string>();
  195. }
  196. }
  197. public static bool Toggle(bool value)
  198. {
  199. var toggle = new GUIStyle("Toggle")
  200. {
  201. margin = new RectOffset(),
  202. padding = new RectOffset()
  203. };
  204. return EditorGUILayout.Toggle(value, toggle, GUILayout.Width(15));
  205. }
  206. }
  207. }