Ejemplo n.º 1
0
        public AnimationListItem(Bitmap image, string text, string desc, int index, Pat.Action obj)
        {
            if (image != null)
            {
                float ratio = 1.0f * image.Width / image.Height;

                if (ratio > 1.0f)
                {
                    _Image    = image.GetThumbnailImage(FrameGridSize, (int)(FrameGridSize / ratio), null, IntPtr.Zero);
                    _Position = new PointF(0, (FrameGridSize - (FrameGridSize / ratio)) / 2);
                }
                else
                {
                    _Image    = image.GetThumbnailImage((int)(FrameGridSize * ratio), FrameGridSize, null, IntPtr.Zero);
                    _Position = new PointF((FrameGridSize - (FrameGridSize * ratio)) / 2, 0);
                }
            }

            _Text  = text;
            _Desc  = desc;
            _Index = index;
            _Obj   = obj;

            CanSelect = true;
        }
Ejemplo n.º 2
0
        public void SetMotion(Pat.Action action, int segment)
        {
            if (action == null)
            {
                World.OnError();
                return;
            }

            bool resetLabels = action != CurrentAction;

            CurrentAction       = action;
            CurrentSegmentIndex = segment;
            CurrentFrameIndex   = 0;
            CurrentFrameCounter = 0;

            if (resetLabels)
            {
                ActionSetup.SetupActorForAction(this, CurrentAction, false);
            }

            if (StartKeyFrameLabel != null && CurrentSegmentIndex < StartKeyFrameLabel.Length)
            {
                StartKeyFrameLabel[CurrentSegmentIndex](this);
            }
            _LastSegmentIndex = CurrentSegmentIndex;
        }
Ejemplo n.º 3
0
        public void AddNew()
        {
            //find an available name
            int id = 1;
            {
                var list = _Parent.Project.Actions;
                while (list.Any(a => a.ActionID == "New Action " + id.ToString()))
                {
                    ++id;
                }
            }

            var action = new Pat.Action()
            {
                ActionID = "New Action " + id.ToString(),
            };

            _Parent.Project.Actions.Add(action);

            if (_SelectedItem != null)
            {
                _SelectedItem.IsSelected = false;
                _SelectedItem            = null;
            }

            RefreshList();

            _SelectedItem            = _Items.Last();
            _SelectedItem.IsSelected = true;
            OnSelectChange();
        }
Ejemplo n.º 4
0
        public static void ExportAnimation(GSPat.GSPatFile file, ImageListExporter images,
                                           Pat.Action action, int id)
        {
            {
                var eAnimation = new GSPat.Animation()
                {
                    AnimationID = id,
                    AttackLevel = 0,
                    CancelLevel = ExportCancelLevel(action.Segments[0].CancelLevel),
                    IsLoop      = action.Segments[0].IsLoop,
                    Type        = GSPat.AnimationType.Normal,
                };
                ExportFrames(eAnimation, action.Segments[0], images);
                file.Animations.Add(eAnimation);
            }

            for (int i = 1; i < action.Segments.Count; ++i)
            {
                var eAnimation = new GSPat.Animation()
                {
                    AnimationID = -2,
                    AttackLevel = 0,
                    CancelLevel = ExportCancelLevel(action.Segments[i].CancelLevel),
                    IsLoop      = action.Segments[i].IsLoop,
                    Type        = GSPat.AnimationType.Normal,
                };
                ExportFrames(eAnimation, action.Segments[i], images);
                file.Animations.Add(eAnimation);
            }
        }
Ejemplo n.º 5
0
        public ActionEditForm(Pat.Project proj, Pat.Action action)
        {
            InitializeComponent();

            _Project = proj;
            _Action  = action;

            AdjustListSize();
            RefreshList();
        }
Ejemplo n.º 6
0
        public AnimationListItem(string displayName, string desc, string catName)
        {
            _Text  = displayName;
            _Desc  = desc;
            _Index = -1;
            _Obj   = null;

            CategoryName = catName;
            CanSelect    = false;
        }
Ejemplo n.º 7
0
        private AnimationListItem CreateItemForAnimation(Pat.Action action, int index)
        {
            var img = action.ImageID != null?
                      _Parent.Project.ImageList.GetImage(action.ImageID) :
                          null;

            var frameCount = action.Segments.Sum(s => s.Frames.Count);
            var desc       = action.Segments.Count.ToString() + " segment(s), " +
                             frameCount.ToString() + " frame(s).";

            return(new AnimationListItem(img, action.ActionID, desc, index, action));
        }
Ejemplo n.º 8
0
        public ActionBehaviorEditForm(Pat.Project proj, Pat.Action action)
        {
            InitializeComponent();

            treeView1.LinkedPropertyGrid   = propertyGrid1;
            treeView1.LinkedDeleteButton   = button1;
            treeView1.LinkedResetButton    = button2;
            treeView1.LinkedMoveDownButton = button3;
            treeView1.LinkedMoveUpButton   = button4;

            treeView1.Nodes.AddEditableList(new EditableEnvironment(proj), action.Behaviors);
        }
 private string FindFrame(Pat.Action a, Pat.Frame f)
 {
     for (int i = 0; i < a.Segments.Count; ++i)
     {
         var s = a.Segments[i];
         for (int j = 0; j < s.Frames.Count; ++j)
         {
             if (s.Frames[j] == f)
             {
                 return("Segment " + i.ToString() + " Frame " + j.ToString());
             }
         }
     }
     return("Unknown");
 }
Ejemplo n.º 10
0
        //set labels, run init effects (if specified)
        public static void SetupActorForAction(Actor actor, Pat.Action action, bool runInit)
        {
            var ae = new Pat.ActionEffects(action);

            foreach (var b in action.Behaviors)
            {
                b.MakeEffects(ae);
            }
            if (runInit)
            {
                ae.InitEffects.RunEffects(actor);
            }
            actor.UpdateLabel        = ae.UpdateEffects.RunEffects;
            actor.StartKeyFrameLabel = ae.SegmentStartEffects.Select(list => (ActorLabel)list.RunEffects).ToArray();
            actor.EndKeyFrameLabel   = ae.SegmentFinishEffects.Select(list => (ActorLabel)list.RunEffects).ToArray();
        }
Ejemplo n.º 11
0
        private void toolStripButtonImport_Click(object sender, EventArgs e)
        {
            var dialog = new ImportPatAnimationForm(_Editor.Project);

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                var segments = dialog.ImportedSegments;
                if (segments != null)
                {
                    int id = 1;
                    {
                        var list = _Editor.Project.Actions;
                        while (list.Any(a => a.ActionID == "Imported " + id))
                        {
                            ++id;
                        }
                    }
                    var action = new Pat.Action()
                    {
                        ActionID = "Imported " + id,
                        ImageID  = null,
                        Segments = segments,
                    };

                    //TODO move to action
                    if (action.Segments.Count > 0 && action.Segments[0].Frames.Count > 0)
                    {
                        action.ImageID = action.Segments[0].Frames[0].ImageID;
                    }

                    _Editor.Project.Actions.Add(action);

                    _Editor.Project.ImageList.ReloadAllResources();
                    _Editor.AnimationListUI.Activate();
                }
            }
        }
Ejemplo n.º 12
0
        private void ExportReviveLightAction(int id)
        {
            var light = Animations.ReviveLight;
            var dark  = Animations.ReviveDark;

            if (light == null || dark == null)
            {
                return;
            }

            var action = new Pat.Action
            {
                Segments = new List <Pat.AnimationSegment>()
                {
                    //segment 0
                    new Pat.AnimationSegment
                    {
                        CancelLevel = Pat.CancelLevel.Highest,
                        IsLoop      = true,
                        Frames      = new List <Pat.Frame>()
                        {
                            CreateFrame(light, 255, 100, 64, 113, 3, true),
                            CreateFrame(light, 255, 75, 64, 129, 3, true),
                        },
                    },
                    //segment 1
                    new Pat.AnimationSegment
                    {
                        CancelLevel = Pat.CancelLevel.Highest,
                        IsLoop      = true,
                        Frames      = new List <Pat.Frame>()
                        {
                            CreateFrame(dark, 255, 100, 64, 64, 3, false),
                            CreateFrame(dark, 192, 100, 64, 64, 3, false),
                        },
                    },
                    //segment 2
                    new Pat.AnimationSegment
                    {
                        CancelLevel = Pat.CancelLevel.Highest,
                        IsLoop      = true,
                        Frames      = new List <Pat.Frame>()
                        {
                            CreateFrame(light, 255, 200, 64, 89, 3, false),
                            CreateFrame(light, 255, 190, 64, 91, 3, false),
                        },
                    },
                    //segment 3
                    new Pat.AnimationSegment
                    {
                        CancelLevel = Pat.CancelLevel.Highest,
                        IsLoop      = true,
                        Frames      = new List <Pat.Frame>()
                        {
                            CreateFrame(light, 255, 25, 64, 64, 4, false),
                            CreateFrame(light, 255, 22, 64, 64, 4, false),
                        },
                    },
                },
            };

            base.AddNormalAnimation(action, id + BaseIndex);
        }
Ejemplo n.º 13
0
 protected void AddNormalAnimation(Pat.Action action, int id)
 {
     ExportHelper.ExportAnimation(_OutputData, _ImageList, action, id);
 }