Пример #1
0
        public void NewAutomatron(string path, string name)
        {
            Name = name;
            Path = path;

            entryPoint = new InternalQueueStart()
            {
                Position = WindowRect.center
            };
            AddControl(entryPoint);

            EntryId        = entryPoint.ID;
            Globals.Camera = new Vector2();

            Save();
        }
Пример #2
0
        protected override void OnAfterSerialized()
        {
            var entries = GetControls <InternalQueueStart>();

            foreach (var item in entries)
            {
                if (item.ID == EntryId)
                {
                    entryPoint = item;
                    break;
                }
            }

            WindowSettings.IsFullscreen = true;
            Globals.Camera = camera;

            CreateIcons();
            templator = new AutomationTemplator(this);
        }
Пример #3
0
        public void LoadAutomatron(string path)
        {
            var a = AutomatronSerializer.Load(path);

            if (a == null)
            {
                return;
            }

            Globals.Camera = a.Camera;
            Name           = a.Name;
            Path           = a.Path;

            foreach (var item in a.Automations)
            {
                var type = Globals.Types.Where(t => t.FullName == item.Type).FirstOrDefault();
                if (type == null)
                {
                    type = Type.GetType(item.Type);
                }
                if (type == null)
                {
                    continue;
                }

                var pos = item.Position;

                var instance = (Automation)Activator.CreateInstance(type);
                instance.Position = pos;

                AddControl(instance);
                instance.ID = item.ID;
                instance.LoadFields();

                foreach (var f in item.Fields)
                {
                    var fid = instance.GetField(f.ID);
                    if (fid != null)
                    {
                        fid.SetValue(f.Value);
                    }
                }

                if (item.ID == a.EntryID)
                {
                    entryPoint = (InternalQueueStart)instance;
                    EntryId    = entryPoint.ID;
                }
            }

            var automations = GetControls <Automation>();

            foreach (var item in a.Lines)
            {
                if (item.LineType == ELineType.FieldLine)
                {
                    var left  = automations.Where(auto => auto.HasField(item.IdLeft)).FirstOrDefault();
                    var right = automations.Where(auto => auto.HasField(item.IdRight)).FirstOrDefault();

                    if (left == null || right == null)
                    {
                        continue;
                    }

                    var line = new FieldLine(left.GetField(item.IdLeft), right.GetField(item.IdRight));
                    AddControl(line);
                }
                else
                {
                    var left  = automations.Where(auto => auto.ID == item.IdLeft).FirstOrDefault();
                    var right = automations.Where(auto => auto.ID == item.IdRight).FirstOrDefault();

                    if (left == null || right == null)
                    {
                        continue;
                    }

                    BezierLine line = null;

                    switch (item.LineType)
                    {
                    case ELineType.AutomationLine:
                        line = new AutomationLine(left, right);
                        break;

                    case ELineType.ConditionalLine:
                        line = new ConditionalLine((ConditionalAutomation)left, right);
                        break;

                    case ELineType.LoopableLine:
                        line = new LoopableLine((LoopableAutomation)left, right);
                        break;
                    }

                    if (line != null)
                    {
                        AddControl(line);
                        line.ID = item.ID;
                    }
                }
            }

            var id = GetControlID();

            if (id < a.ControlID)
            {
                var amount = a.ControlID - id;
                for (int i = 0; i < amount; i++)
                {
                    GetControlID();
                }
            }

            if (entryPoint == null)
            {
                entryPoint = new InternalQueueStart()
                {
                    Position = WindowRect.center
                };
                AddControl(entryPoint);

                EntryId = entryPoint.ID;
            }
        }