コード例 #1
0
        private void loopPane_SelectedFrameChanged(ViewLoop loop, int newSelectedFrame)
        {
            if (newSelectedFrame >= 0)
            {
                _guiController.SetPropertyGridObjectList(ConstructPropertyObjectList(loop));
                _guiController.SetPropertyGridObject(loop.Frames[newSelectedFrame]);
            }
            else
            {
                _guiController.SetPropertyGridObjectList(null);
                _guiController.SetPropertyGridObject(_editingView);
            }

            // deselect all other loops
            foreach (ViewLoopEditor pane in _loopPanes)
            {
                if (pane.Loop != loop)
                {
                    pane.SelectedFrame = -1;
                }
            }

            // the view's Flipped setting might have changed, ensure
            // the preview is updated
            viewPreview.ViewUpdated();
        }
コード例 #2
0
ファイル: NativeProxy.cs プロジェクト: WMProject1217/ags
 public void DrawViewLoop(IntPtr hdc, ViewLoop loop, int x, int y, int sizeInPixels, int selectedFrame)
 {
     lock (_spriteSetLock)
     {
         _native.DrawViewLoop((int)hdc, loop, x, y, sizeInPixels, selectedFrame);
     }
 }
コード例 #3
0
        private Dictionary <string, object> ConstructPropertyObjectList(ViewLoop loop)
        {
            Dictionary <string, object> list = new Dictionary <string, object>();

            foreach (ViewFrame frame in loop.Frames)
            {
                list.Add("Loop " + loop.ID + " frame " + frame.ID + " (View frame)", frame);
            }
            return(list);
        }
コード例 #4
0
 public ViewLoopEditor(ViewLoop loopToEdit, GUIController guiController)
 {
     InitializeComponent();
     _guiController    = guiController;
     _selectedFrame    = -1;
     _loop             = loopToEdit;
     lblLoopTitle.Text = "Loop " + _loop.ID + " (" + _loop.DirectionDescription + ")";
     chkRunNextLoop.DataBindings.Add("Checked", _loop, "RunNextLoop", false, DataSourceUpdateMode.OnPropertyChanged);
     _isLastLoop = false;
     UpdateSize();
 }
コード例 #5
0
        private void btnNewLoop_Click(object sender, EventArgs e)
        {
            if (_loopPanes.Count > 0)
            {
                _loopPanes[_loopPanes.Count - 1].IsLastLoop = false;
            }
            ViewLoop       newLoop = _editingView.AddNewLoop();
            ViewLoopEditor newPane = AddNewLoopPane(newLoop);

            btnNewLoop.Top            = 10 + newPane.Top + newPane.Height;
            btnDeleteLastLoop.Top     = btnNewLoop.Top;
            btnDeleteLastLoop.Visible = true;
            viewPreview.ViewUpdated();
        }
コード例 #6
0
        private static ViewResource CreateTestViewResource(byte resourceIndex)
        {
            var cels = new ViewCel[]
            {
                new ViewCel(4, 8, 0, false, 0, new byte[] { 0 }),
            };

            var loops = new ViewLoop[]
            {
                new ViewLoop(cels, -1),
                new ViewLoop(cels, -1),
                new ViewLoop(cels, -1),
            };

            return(new ViewResource(resourceIndex, loops, "key", 0, 0));
        }
コード例 #7
0
ファイル: ViewLoopEditor.cs プロジェクト: wlads/ags
        public ViewLoopEditor(ViewLoop loopToEdit, GUIController guiController)
        {
            InitializeComponent();
            _selectedFrame    = -1;
            _loop             = loopToEdit;
            lblLoopTitle.Text = "Loop " + _loop.ID + " (" + _loop.DirectionDescription + ")";
            chkRunNextLoop.DataBindings.Add("Checked", _loop, "RunNextLoop", false, DataSourceUpdateMode.OnPropertyChanged);
            _isLastLoop   = false;
            _loopDisplayY = chkRunNextLoop.Top + chkRunNextLoop.Height + 2;

            FRAME_DISPLAY_SIZE = guiController.AdjustSizeFrom96DpiToSystemDpi(FRAME_DISPLAY_SIZE_96DPI);
            btnNewFrame.Width  = FRAME_DISPLAY_SIZE;
            btnNewFrame.Height = FRAME_DISPLAY_SIZE;
            btnNewFrame.Top    = _loopDisplayY;

            _framelessWidth = Math.Max(chkRunNextLoop.Width + 10, Screen.PrimaryScreen.Bounds.Width);
            UpdateControlWidth();
        }
コード例 #8
0
        private ViewLoopEditor AddNewLoopPane(ViewLoop loop)
        {
            ViewLoopEditor loopPane = new ViewLoopEditor(loop, _guiController);

            loopPane.Left = 10;
            loopPane.Top  = 10 + _loopPanes.Count * loopPane.Height + editorPanel.AutoScrollPosition.Y;
            loopPane.SelectedFrameChanged += new ViewLoopEditor.SelectedFrameChangedHandler(loopPane_SelectedFrameChanged);
            loopPane.NewFrameAdded        += new ViewLoopEditor.NewFrameAddedHandler(loopPane_NewFrameAdded);
            if (loop.ID == _editingView.Loops.Count - 1)
            {
                loopPane.IsLastLoop = true;
            }
            loopPane.Enter += new EventHandler(loopPane_GotFocus);
            //loopPane.GotFocus += new EventHandler(loopPane_GotFocus);
            //loopPane.Leave += new EventHandler(loopPane_GotFocus);
            editorPanel.Controls.Add(loopPane);
            _loopPanes.Add(loopPane);
            return(loopPane);
        }
コード例 #9
0
 private void loopPane_NewFrameAdded(ViewLoop loop, int newSelectedFrame)
 {
     if (newSelectedFrame > 0)
     {
         // Attempt to initialize the new frame to the sprite that
         // comes after the previous frame in the sprite manager
         int          previousFrameImage = loop.Frames[newSelectedFrame - 1].Image;
         SpriteFolder parent             = Factory.AGSEditor.CurrentGame.RootSpriteFolder.FindFolderThatContainsSprite(previousFrameImage);
         if ((parent != null) && (previousFrameImage > 0))
         {
             for (int i = 0; i < parent.Sprites.Count; i++)
             {
                 if ((parent.Sprites[i].Number == previousFrameImage) &&
                     (i < parent.Sprites.Count - 1))
                 {
                     loop.Frames[newSelectedFrame].Image = parent.Sprites[i + 1].Number;
                     break;
                 }
             }
         }
     }
 }
コード例 #10
0
 private void copyLoop()
 {
     _copiedLoop = _loop.Clone();
 }
コード例 #11
0
        /// <summary>
        /// Decode the view resource from byte array.
        /// </summary>
        /// <param name="resourceIndex">Resource index.</param>
        /// <param name="viewData">View data.</param>
        /// <returns>View resource.</returns>
        public static ViewResource ReadView(byte resourceIndex, byte[] viewData)
        {
            var mapLoopHeaderPosToLoopNum = new Dictionary <int, int>();

            // View header
            int viewOffset = 0;

            // [0] = unknown
            byte unknown1 = viewData[viewOffset];

            viewOffset += 1;

            // [1] = unknown
            byte unknown2 = viewData[viewOffset];

            viewOffset += 1;

            // [2] = number of loops
            int numLoops = viewData[viewOffset];

            viewOffset += 1;

            // [3][4] = position of description
            int descPos = (viewData[viewOffset + 1] * 0x100) + viewData[viewOffset];

            viewOffset += 2;

            string description = string.Empty;

            if (descPos > 0)
            {
                description = StringDecoder.GetNullTerminatedString(viewData, descPos);
            }

            var loops = new ViewLoop[numLoops];

            for (int loop = 0; loop < numLoops; loop++)
            {
                var cels          = new ViewCel[0];
                int mirrorOfIndex = -1;

                // [0][1] = position of loop header
                int loopHeaderPos = (viewData[viewOffset + 1] * 0x100) + viewData[viewOffset];
                viewOffset += 2;

                if (mapLoopHeaderPosToLoopNum.ContainsKey(loopHeaderPos))
                {
                    // We have already seen this loop, looks like this is a mirror
                    mirrorOfIndex = mapLoopHeaderPosToLoopNum[loopHeaderPos];
                }
                else
                {
                    mapLoopHeaderPosToLoopNum.Add(loopHeaderPos, loop);

                    // Loop header
                    int loopOffset = loopHeaderPos;

                    // [0] = number of cels in loop
                    int numCels = viewData[loopOffset];
                    loopOffset += 1;

                    cels = new ViewCel[numCels];
                    for (int cel = 0; cel < numCels; cel++)
                    {
                        // [0][1] = position of first cel header, relative to start of loop
                        int celHeaderPos = (viewData[loopOffset + 1] * 0x100) + viewData[loopOffset];
                        loopOffset += 2;

                        // Cel header
                        int celOffset = loopHeaderPos + celHeaderPos;

                        // [0] = width of cel in pixels (1 agi pixels = 2 ega pixels)
                        byte celWidth = viewData[celOffset];
                        celOffset += 1;

                        // [1] = height of cel
                        byte celHeight = viewData[celOffset];
                        celOffset += 1;

                        // [2] = transparency and cel mirroring
                        // (high 4 bits are mirror info, low 4 bits are transparent color)
                        byte transparentColor = (byte)(viewData[celOffset] & 0x0f);
                        byte mirrorInfo       = (byte)((viewData[celOffset] & 0xf0) >> 4);
                        bool mirror           = (mirrorInfo & 0x08) != 0;
                        byte mirrorLoopNumber = (byte)(mirrorInfo & 0x07);
                        celOffset += 1;

                        // [+] = RLE encoding of pixels
                        byte[] pixels = RleCompression.Decompress(viewData, celOffset, celWidth, celHeight, transparentColor);

                        cels[cel] = new ViewCel(celWidth, celHeight, transparentColor, mirror, mirrorLoopNumber, pixels);
                    }
                }

                loops[loop] = new ViewLoop(cels, mirrorOfIndex);
            }

            // Go through all the loops and process the ones that are marked as mirrors
            for (int loop = 0; loop < loops.Length; loop++)
            {
                if (loops[loop].IsMirror)
                {
                    // Create the mirrored cels for this loop
                    var originalLoop = loops[loops[loop].MirrorOfIndex];

                    var cels = new ViewCel[originalLoop.Cels.Length];
                    for (int cel = 0; cel < cels.Length; cel++)
                    {
                        ViewCel originalCel = originalLoop.Cels[cel];
                        cels[cel] = new ViewCel(originalCel.Width, originalCel.Height, originalCel.TransparentColor, originalCel.Mirror, originalCel.MirrorLoopNumber, originalCel.MirrorPixels());
                    }

                    loops[loop] = new ViewLoop(cels, -1);
                }
            }

            return(new ViewResource(resourceIndex, loops, description, unknown1, unknown2));
        }