Beispiel #1
0
        public void OnGUI()
        {
            showTypeOption = EditorGUILayout.Foldout(showTypeOption, new GUIContent(titleTypeOption, descriptionTypeOption));

            if (showTypeOption)
            {
                GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

                float height =
                    LudiqGUI.GetInspectorHeight(null, typeOptionsMetadata, Styles.optionsWidth, GUIContent.none);

                EditorGUI.BeginChangeCheck();

                var position = GUILayoutUtility.GetRect(Styles.optionsWidth, height);

                LudiqGUI.Inspector(typeOptionsMetadata, position, GUIContent.none);

                if (EditorGUI.EndChangeCheck())
                {
                    typeOptionsMetadata.Save();
                    Codebase.UpdateSettings();
                }

                if (GUILayout.Button("Reset to Defaults", Styles.defaultsButton))
                {
                    typeOptionsMetadata.Reset(true);
                    typeOptionsMetadata.Save();
                }

                LudiqGUI.EndVertical();
            }
        }
Beispiel #2
0
        public override void LateInitialize()
        {
            base.LateInitialize();

            // Add all plugin runtime assemblies to the option list

            var missingPluginAssemblies = new List <LooseAssemblyName>();

            foreach (var pluginAssembly in PluginContainer.plugins.SelectMany(plugin => plugin.GetType().GetAttributes <PluginRuntimeAssemblyAttribute>().Select(a => a.assemblyName)).Distinct())
            {
                if (!assemblyOptions.Contains(pluginAssembly))
                {
                    missingPluginAssemblies.Add(pluginAssembly);
                }
            }

            if (missingPluginAssemblies.Any())
            {
                var assemblyOptionsMetadata = projectSettings.Single(metadata => metadata.key == nameof(assemblyOptions));

                assemblyOptions.AddRange(missingPluginAssemblies);
                assemblyOptionsMetadata.defaultValue = ((List <LooseAssemblyName>)assemblyOptionsMetadata.defaultValue).Concat(missingPluginAssemblies).ToList();
            }

            Codebase.UpdateSettings();
        }
        public void GenerateProviderScripts()
        {
            if (Directory.Exists(BoltCore.Paths.propertyProviders))
            {
                foreach (var file in Directory.GetFiles(BoltCore.Paths.propertyProviders))
                {
                    File.Delete(file);
                }
            }

            if (Directory.Exists(BoltCore.Paths.propertyProvidersEditor))
            {
                foreach (var file in Directory.GetFiles(BoltCore.Paths.propertyProvidersEditor))
                {
                    File.Delete(file);
                }
            }

            PathUtility.CreateDirectoryIfNeeded(BoltCore.Paths.propertyProviders);
            PathUtility.CreateDirectoryIfNeeded(BoltCore.Paths.propertyProvidersEditor);

            foreach (var type in typeset.Where(SerializedPropertyUtility.HasCustomDrawer))
            {
                var directory = Codebase.IsEditorType(type) ? BoltCore.Paths.propertyProvidersEditor : BoltCore.Paths.propertyProviders;
                var path      = Path.Combine(directory, GetProviderScriptName(type) + ".cs");

                VersionControlUtility.Unlock(path);
                File.WriteAllText(path, GenerateProviderSource(type));
            }

            AssetDatabase.Refresh();
        }
Beispiel #4
0
        public virtual UnitOptionRow Serialize()
        {
            var row = new UnitOptionRow();

            if (sourceScriptGuids.Count == 0)
            {
                // Important to set to null here, because the code relies on
                // null checks, not empty string checks.
                row.sourceScriptGuids = null;
            }
            else
            {
                row.sourceScriptGuids = string.Join(",", sourceScriptGuids.ToArray());
            }

            row.optionType = Codebase.SerializeType(GetType());
            row.unitType   = Codebase.SerializeType(unitType);
            row.unit       = unit.Serialize().json;

            row.category           = category?.fullName;
            row.labelHuman         = labelHuman;
            row.labelProgrammer    = labelProgrammer;
            row.order              = order;
            row.haystackHuman      = haystackHuman;
            row.haystackProgrammer = haystackProgrammer;
            row.favoriteKey        = favoriteKey;

            row.controlInputCount  = controlInputCount;
            row.controlOutputCount = controlOutputCount;
            row.valueInputTypes    = valueInputTypes.Select(Codebase.SerializeType).ToSeparatedString("|").NullIfEmpty();
            row.valueOutputTypes   = valueOutputTypes.Select(Codebase.SerializeType).ToSeparatedString("|").NullIfEmpty();

            return(row);
        }
 public MemberOptionTree(IEnumerable <Type> types, MemberFilter memberFilter, TypeFilter memberTypeFilter, ActionDirection direction) : base(new GUIContent("Member"))
 {
     favorites        = new Favorites(this);
     codebase         = Codebase.Subset(types, memberFilter.Configured(), memberTypeFilter?.Configured(false));
     this.direction   = direction;
     expectingBoolean = memberTypeFilter?.ExpectsBoolean ?? false;
 }
        public override UnitOptionRow Serialize()
        {
            var row = base.Serialize();

            row.tag1 = Codebase.SerializeType(literalType);

            return(row);
        }
Beispiel #7
0
        private IEnumerable <object> FindAllSettingsStubs()
        {
            // Include all custom operators for the formula node and generic math nodes
            // Also include all user defined conversion operators for the conversion utility
            var codebaseSubset = Codebase.Subset(Codebase.settingsTypes, TypeFilter.Any.Configured(), MemberFilter.Any.Configured());

            codebaseSubset.Cache();

            return(codebaseSubset.members
                   .Select(m => m.info)
                   .OfType <MethodInfo>()
                   .Where(m => m.IsOperator() || m.IsUserDefinedConversion()));
        }
        private static void UpdateCodebase(IEnumerable <Type> typeSet = null)
        {
            if (typeSet == null)
            {
                typeSet = Codebase.settingsTypes;
            }
            else
            {
                typeSet = typeSet.Where(t => Codebase.settingsTypes.Contains(t));
            }

            Codebase.UpdateSettings();
            codebase = Codebase.Subset(typeSet, TypeFilter.Any.Configured(), MemberFilter.Any.Configured(), TypeFilter.Any.Configured(false));
            codebase.Cache();
        }
Beispiel #9
0
        public IUnitOption ToOption()
        {
            using (ProfilingUtility.SampleBlock("Row to option"))
            {
                var optionType = Codebase.DeserializeType(this.optionType);

                IUnitOption option;

                option = (IUnitOption)Activator.CreateInstance(optionType);

                option.Deserialize(this);

                return(option);
            }
        }
Beispiel #10
0
        private static void UpdateCodebase(IEnumerable <Type> typeSet = null)
        {
            using var profilerScope = ProfilingUtility.SampleBlock("UpdateCodebase");
            if (typeSet == null)
            {
                typeSet = Codebase.settingsTypes;
            }
            else
            {
                typeSet = typeSet.Where(t => Codebase.settingsTypes.Contains(t));
            }

            Codebase.UpdateSettings();
            codebase = Codebase.Subset(typeSet, TypeFilter.Any.Configured(), MemberFilter.Any.Configured(), TypeFilter.Any.Configured(false));
            codebase.Cache();
        }
Beispiel #11
0
        public virtual void Deserialize(UnitOptionRow row)
        {
            source = row;

            if (row.sourceScriptGuids != null)
            {
                sourceScriptGuids = row.sourceScriptGuids.Split(',').ToHashSet();
            }

            unitType = Codebase.DeserializeType(row.unitType);

            category           = row.category == null ? null : new UnitCategory(row.category);
            labelHuman         = row.labelHuman;
            labelProgrammer    = row.labelProgrammer;
            order              = row.order;
            haystackHuman      = row.haystackHuman;
            haystackProgrammer = row.haystackProgrammer;
            favoriteKey        = row.favoriteKey;

            controlInputCount  = row.controlInputCount;
            controlOutputCount = row.controlOutputCount;
        }
        public void OnGUI()
        {
            showAssembly = EditorGUILayout.Foldout(showAssembly, new GUIContent(titleAssembly, descriptionAssembly));

            if (showAssembly)
            {
                GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

                float height = LudiqGUI.GetInspectorHeight(null, assemblyOptionsMetadata, Styles.optionsWidth, GUIContent.none);

                EditorGUI.BeginChangeCheck();

                var position = GUILayoutUtility.GetRect(Styles.optionsWidth, height);

                LudiqGUI.Inspector(assemblyOptionsMetadata, position, GUIContent.none);

                if (EditorGUI.EndChangeCheck())
                {
                    assemblyOptionsMetadata.Save();
                    Codebase.UpdateSettings();
                }

                if (GUILayout.Button("Reset to Defaults", Styles.defaultsButton))
                {
                    assemblyOptionsMetadata.Reset(true);
                    assemblyOptionsMetadata.Save();
                }

                LudiqGUI.EndVertical();
            }

            if (GUILayout.Button(completeLabel, Styles.defaultsButton))
            {
                UnitBase.Rebuild();

                EditorUtility.DisplayDialog("Visual Script", "Regenerate Nodes completed", "OK");
            }
        }
 private IFuzzyOptionTree GetTypeOptions()
 {
     return(new TypeOptionTree(Codebase.GetTypeSetFromAttribute(metadata), typeFilter));
 }
Beispiel #14
0
 IFuzzyOptionTree GetTypeOptions()
 {
     return(new TypeOptionTree(Codebase.GetTypeSetFromAttribute(parent.metadata), parent.typeFilter));
 }
 private IFuzzyOptionTree GetOptions()
 {
     return(new MemberOptionTree(Codebase.GetTypeSetFromAttribute(metadata), memberFilter, memberTypeFilter, direction));
 }
        public override void Deserialize(UnitOptionRow row)
        {
            base.Deserialize(row);

            literalType = Codebase.DeserializeType(row.tag1);
        }
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            var text = "Choose the types you want to use for variables and units.\n"
                       + "MonoBehaviour types are always included.";

            GUILayout.Label(text, LudiqStyles.centeredLabel, GUILayout.MaxWidth(370));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            var height = LudiqGUI.GetInspectorHeight(null, typeOptionsMetadata, Styles.optionsWidth, GUIContent.none);

            LudiqGUI.BeginHorizontal();

            LudiqGUI.FlexibleSpace();

            EditorGUI.BeginChangeCheck();

            var position = GUILayoutUtility.GetRect(Styles.optionsWidth, height);

            LudiqGUI.Inspector(typeOptionsMetadata, position, GUIContent.none);

            if (EditorGUI.EndChangeCheck())
            {
                typeOptionsMetadata.Save();
                Codebase.UpdateSettings();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Reset to Defaults", Styles.defaultsButton))
            {
                typeOptionsMetadata.Reset(true);
                typeOptionsMetadata.Save();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Generate", Styles.completeButton))
            {
                Complete();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();
        }
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            var text = "Choose the assemblies in which you want to look for nodes.\n"
                       + "By default, all project and Unity assemblies are included.\n"
                       + "Unless you use a third-party plugin distributed as a DLL, you shouldn't need to change this.";

            GUILayout.Label(text, LudiqStyles.centeredLabel, GUILayout.MaxWidth(370));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            var height = LudiqGUI.GetInspectorHeight(null, assemblyOptionsMetadata, Styles.optionsWidth, GUIContent.none);

            LudiqGUI.BeginHorizontal();

            LudiqGUI.FlexibleSpace();

            EditorGUI.BeginChangeCheck();

            var position = GUILayoutUtility.GetRect(Styles.optionsWidth, height);

            LudiqGUI.Inspector(assemblyOptionsMetadata, position, GUIContent.none);

            if (EditorGUI.EndChangeCheck())
            {
                assemblyOptionsMetadata.Save();
                Codebase.UpdateSettings();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Reset to Defaults", Styles.defaultsButton))
            {
                assemblyOptionsMetadata.Reset(true);
                assemblyOptionsMetadata.Save();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button(completeLabel, Styles.completeButton))
            {
                Complete();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();
        }