コード例 #1
0
 public UnitCategoryOption(UnitCategory category)
 {
     value = category;
     label = category.name.Split('/').Last().Prettify();
     UnityAPI.Async(() => icon = BoltFlow.Icons.UnitCategory(category));
     parentOnly = true;
 }
コード例 #2
0
        protected virtual void FillFromUnit()
        {
            unit.EnsureDefined();
            unitType = unit.GetType();

            labelHuman    = Label(true);
            haystackHuman = Haystack(true);

            labelProgrammer    = Label(false);
            haystackProgrammer = Haystack(false);

            category    = Category();
            order       = Order();
            favoriteKey = FavoriteKey();
            UnityAPI.Async(() => icon = Icon());

            showControlInputsInFooter  = ShowControlInputsInFooter();
            showControlOutputsInFooter = ShowControlOutputsInFooter();
            showValueInputsInFooter    = ShowValueInputsInFooter();
            showValueOutputsInFooter   = ShowValueOutputsInFooter();

            controlInputCount  = unit.controlInputs.Count;
            controlOutputCount = unit.controlOutputs.Count;
            valueInputTypes    = unit.valueInputs.Select(vi => vi.type).ToHashSet();
            valueOutputTypes   = unit.valueOutputs.Select(vo => vo.type).ToHashSet();

            filled = true;
        }
コード例 #3
0
        public static void BackgroundWork()
        {
            var preloadedAssemblies = new List <Assembly>();

            preloadedAssemblies.AddRange(Codebase.settingsAssemblies);
            preloadedAssemblies.AddRange(Codebase.ludiqEditorAssemblies);

            for (var i = 0; i < preloadedAssemblies.Count; i++)
            {
                var assembly = preloadedAssemblies[i];
                ProgressUtility.DisplayProgressBar($"Documentation ({assembly.GetName().Name})...", null, (float)i / Codebase.settingsAssemblies.Count);
                var documentation = GetDocumentationUncached(assembly);


                lock (@lock)
                {
                    if (!LazyData.Value.documentations.ContainsKey(assembly))
                    {
                        LazyData.Value.documentations.Add(assembly, documentation);
                    }
                }
            }

            UnityAPI.Async(() =>
            {
                loaded = true;
                loadComplete?.Invoke();
            });
        }
コード例 #4
0
 public TypeOption(Type type)
 {
     value = type;
     label = type.DisplayName();
     UnityAPI.Async(() => icon = type.Icon());
     documentation             = type.Documentation();
     zoom = true;
 }
コード例 #5
0
 public EnumOption(Enum @enum)
 {
     value = @enum;
     label = @enum.HumanName();
     UnityAPI.Async(() => icon = @enum.Icon());
     documentation = @enum.Documentation();
     zoom = true;
 }
コード例 #6
0
 public void Run(object assigner, object assignee)
 {
     if (requiresAPI)
     {
         UnityAPI.Async(() => _Run(assigner, assignee));
     }
     else
     {
         _Run(assigner, assignee);
     }
 }
コード例 #7
0
        protected virtual void FillFromData()
        {
            unit.EnsureDefined();
            unitType = unit.GetType();
            UnityAPI.Async(() => icon = Icon());

            showControlInputsInFooter  = ShowControlInputsInFooter();
            showControlOutputsInFooter = ShowControlOutputsInFooter();
            showValueInputsInFooter    = ShowValueInputsInFooter();
            showValueOutputsInFooter   = ShowValueOutputsInFooter();

            filled = true;
        }
コード例 #8
0
        public void Validate()
        {
            if (isDirty)
            {
                isDirty = false;

                description.fallbackLabel = target.key.Filter(symbols: false, punctuation: false).Prettify();

                UnityAPI.Async(() => description.icon = GetIcon(target));

                target.unit?.Descriptor <IUnitDescriptor>().DescribePort(target, description);

                // No DescriptionAssignment is run, so we'll just always assume that the description changes.
                DescriptorProvider.instance.TriggerDescriptionChange(target);
            }
        }
コード例 #9
0
        public static void Update()
        {
            if (!IsUnitOptionsBuilt())
            {
                Build();
                return;
            }

            lock (@lock)
            {
                using (ProfilingUtility.SampleBlock("Update Node Database"))
                {
                    using (NativeUtility.Module("sqlite3.dll"))
                    {
                        var progressTitle = "Updating node database...";

                        SQLiteConnection database = null;

                        try
                        {
                            VersionControlUtility.Unlock(BoltFlow.Paths.unitOptions);

                            var steps = 7f;
                            var step  = 0f;

                            ProgressUtility.DisplayProgressBar(progressTitle, "Connecting to database...", step++ / steps);

                            database = new SQLiteConnection(BoltFlow.Paths.unitOptions);

                            ProgressUtility.DisplayProgressBar(progressTitle, "Updating type mappings...", step++ / steps);

                            UpdateTypeMappings();

                            ProgressUtility.DisplayProgressBar(progressTitle, "Fetching modified scripts...", step++ / steps);

                            var modifiedScriptGuids = GetModifiedScriptGuids().Distinct().ToHashSet();

                            ProgressUtility.DisplayProgressBar(progressTitle, "Fetching deleted scripts...", step++ / steps);

                            var deletedScriptGuids = GetDeletedScriptGuids().Distinct().ToHashSet();

                            ProgressUtility.DisplayProgressBar(progressTitle, "Updating codebase...", step++ / steps);

                            var modifiedScriptTypes = modifiedScriptGuids.SelectMany(GetScriptTypes).ToArray();

                            UpdateCodebase(modifiedScriptTypes);

                            var outdatedScriptGuids = new HashSet <string>();
                            outdatedScriptGuids.UnionWith(modifiedScriptGuids);
                            outdatedScriptGuids.UnionWith(deletedScriptGuids);

                            ProgressUtility.DisplayProgressBar(progressTitle, "Removing outdated node options...", step++ / steps);

                            options?.RemoveWhere(option => outdatedScriptGuids.Overlaps(option.sourceScriptGuids));

                            // We want to use the database level WHERE here for speed,
                            // so we'll run multiple queries, one for each outdated script GUID.

                            foreach (var outdatedScriptGuid in outdatedScriptGuids)
                            {
                                foreach (var outdatedRowId in database.Table <UnitOptionRow>()
                                         .Where(row => row.sourceScriptGuids.Contains(outdatedScriptGuid))
                                         .Select(row => row.id))
                                {
                                    database.Delete <UnitOptionRow>(outdatedRowId);
                                }
                            }

                            ProgressUtility.DisplayProgressBar(progressTitle, "Converting codebase to node options...", step++ / steps);

                            var newOptions = new HashSet <IUnitOption>(modifiedScriptGuids.SelectMany(GetScriptTypes)
                                                                       .Distinct()
                                                                       .SelectMany(GetIncrementalOptions));

                            var rows = new HashSet <UnitOptionRow>();

                            float progress = 0;

                            foreach (var newOption in newOptions)
                            {
                                options?.Add(newOption);

                                try
                                {
                                    ProgressUtility.DisplayProgressBar(progressTitle, newOption.label, (step / steps) + ((1 / step) * (progress / newOptions.Count)));
                                    rows.Add(newOption.Serialize());
                                }
                                catch (Exception ex)
                                {
                                    Debug.LogError($"Failed to serialize option '{newOption.GetType()}'.\n{ex}");
                                }

                                progress++;
                            }

                            ProgressUtility.DisplayProgressBar(progressTitle, "Writing to database...", 1);

                            try
                            {
                                database.InsertAll(rows);
                            }
                            catch (Exception ex)
                            {
                                Debug.LogError($"Failed to write options to database.\n{ex}");
                            }

                            // Make sure the database is touched to the current date,
                            // even if we didn't do any change. This will avoid unnecessary
                            // analysis in future update checks.
                            File.SetLastWriteTimeUtc(BoltFlow.Paths.unitOptions, DateTime.UtcNow);
                        }
                        finally
                        {
                            database?.Close();
                            ProgressUtility.ClearProgressBar();
                            UnityAPI.Async(AssetDatabase.Refresh);
                            //ConsoleProfiler.Dump();
                        }
                    }
                }
            }
        }
コード例 #10
0
 private void CacheEventLinesOnUnityThread()
 {
     UnityAPI.Async(CacheEventLines);
 }