A game about forced loneliness, made by TACStudios
1using UnityEngine; 2using UnityEditor; 3 4namespace Unity.VisualScripting 5{ 6 public class AssemblyOptionsSettings 7 { 8 private const string CompleteLabel = "Regenerate Nodes"; 9 private readonly PluginConfigurationItemMetadata _assemblyOptionsMetadata; 10 11 private bool _showAssembly = false; 12 private const string TitleAssembly = "Node Library"; 13 private const string DescriptionAssembly = "Choose the assemblies in which you want to look for nodes.\n" 14 + "By default, all project and Unity assemblies are included.\n" 15 + "Unless you use a third-party plugin distributed as a DLL, you shouldn't need to change this."; 16 17 private ProjectAssemblyOptionsListInspector _assemblyOptionsInspector; 18 19 public AssemblyOptionsSettings(BoltCoreConfiguration coreConfig) 20 { 21 _assemblyOptionsMetadata = coreConfig.GetMetadata(nameof(coreConfig.assemblyOptions)); 22 _assemblyOptionsInspector = new ProjectAssemblyOptionsListInspector(_assemblyOptionsMetadata); 23 } 24 25 private static class Styles 26 { 27 public static readonly GUIStyle background; 28 public static readonly GUIStyle defaultsButton; 29 public const float OptionsWidth = 250; 30 31 static Styles() 32 { 33 background = new GUIStyle(LudiqStyles.windowBackground); 34 background.padding = new RectOffset(20, 20, 20, 20); 35 36 defaultsButton = new GUIStyle("Button"); 37 defaultsButton.padding = new RectOffset(10, 10, 4, 4); 38 } 39 } 40 41 public void OnGUI() 42 { 43 _showAssembly = EditorGUILayout.Foldout(_showAssembly, new GUIContent(TitleAssembly, DescriptionAssembly)); 44 45 if (_showAssembly) 46 { 47 GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true)); 48 49 var height = _assemblyOptionsInspector.GetCachedHeight(Styles.OptionsWidth, GUIContent.none, null); 50 51 EditorGUI.BeginChangeCheck(); 52 53 var position = GUILayoutUtility.GetRect(Styles.OptionsWidth, height); 54 55 _assemblyOptionsInspector.Draw(position, GUIContent.none); 56 57 if (EditorGUI.EndChangeCheck()) 58 { 59 _assemblyOptionsMetadata.SaveImmediately(true); 60 Codebase.UpdateSettings(); 61 } 62 63 if (GUILayout.Button("Reset to Defaults", Styles.defaultsButton) && EditorUtility.DisplayDialog("Reset the Node Library", "Reset the Node Library to its default state?", "Reset to Default", "Cancel")) 64 { 65 _assemblyOptionsMetadata.Reset(true); 66 _assemblyOptionsMetadata.SaveImmediately(true); 67 } 68 69 LudiqGUI.EndVertical(); 70 } 71 72 if (GUILayout.Button(CompleteLabel, Styles.defaultsButton)) 73 { 74 UnitBase.Rebuild(); 75 76 EditorUtility.DisplayDialog("Visual Script", "Regenerate Nodes completed", "OK"); 77 } 78 } 79 } 80}