Inheritance: IPositionedSizedObject, IRenderable, IVisible
        public void HandleXnaInitialize(SystemManagers managers)
        {
            mManagers = managers;

            mSprite = new Sprite(null);
            mSprite.Visible = false;
            mManagers.SpriteManager.Add(mSprite);

            mOutlineRectangle = new RenderingLibrary.Math.Geometry.LineRectangle(mManagers);
            mOutlineRectangle.Visible = false;
            mManagers.ShapeManager.Add(mOutlineRectangle);
            mOutlineRectangle.Color = new Microsoft.Xna.Framework.Color(
                1.0f, 1.0f, 1.0f, .5f);

            mHighlightRectangle = new RenderingLibrary.Math.Geometry.LineRectangle(mManagers);
            mHighlightRectangle.Visible = false;
            mManagers.ShapeManager.Add(mHighlightRectangle);
            mHighlightRectangle.Color = new Microsoft.Xna.Framework.Color(
                1.0f, 1.0f, 1.0f, 1.0f);

            HandleWindowResize();
            mCursor = new InputLibrary.Cursor();
            mCursor.Initialize(mControl);
            mCameraPanningLogic = new CameraPanningLogic(mControl, managers, mCursor, mKeyboard);
            mManagers.Renderer.SamplerState = Microsoft.Xna.Framework.Graphics.SamplerState.PointClamp;
        }
Example #2
0
        private void CreateVisualRepresentation()
        {
            mOffsetSprite = new RenderingLibrary.Graphics.Sprite(null);

            mRectangle       = new SolidRectangle();
            mRectangle.Color = Color.Yellow;
            mManagers.ShapeManager.Add(mRectangle, mLayer);

            ReactToRulerSides();

            CreateRulerLines();
        }
Example #3
0
        private void UpdateSpriteToAnimationFrame()
        {
            AnimationFrameSave afs = SelectedState.Self.SelectedFrame;

            if (afs != null)
            {
                RenderingLibrary.Graphics.Sprite sprite = mSprite;
                sprite.Visible = true;
                UpdateSpriteToAnimationFrame(afs, sprite);
            }

            UpdateOnionSkinSprites();
        }
Example #4
0
        private void CreateVisualRepresentation()
        {
            mOffsetSprite      = new Sprite(null);
            mOffsetSprite.Name = "Ruler offset sprite";

            mRectangle       = new SolidRectangle();
            mRectangle.Color = Color.Yellow;
            ShapeManager.Add(mRectangle, mLayer);

            ReactToRulerSides();

            CreateRulerLines();
        }
Example #5
0
        void HandleXnaInitialize()
        {
            mManagers = new SystemManagers();
            mManagers.Initialize(mControl.GraphicsDevice);

            mManagers.Renderer.SamplerState = SamplerState.PointClamp;

            mManagers.Name = "Preview Window Managers";
            ShapeManager shapeManager = mManagers.ShapeManager;

            mSprite      = new RenderingLibrary.Graphics.Sprite(null);
            mSprite.Name = "Animation PreviewManager Main Sprite";

            mRectangle = new LineRectangle(mManagers);
            mManagers.ShapeManager.Add(mRectangle);
            // Move it in front of the Sprite
            mRectangle.Z = 1;

            mManagers.SpriteManager.Add(mSprite);

            mControl.Resize    += new EventHandler(HandleResize);
            mControl.XnaUpdate += new Action(HandleXnaUpdate);
            MoveCameraToProperLocation();

            // We'll use Cursor.Self which is initialized and updated elsewhere
            // Actually looks like that's not the case.  We'll make a new one.
            mCursor = new Cursor();
            mCursor.Initialize(mControl);

            mKeyboard = new Keyboard();
            mKeyboard.Initialize(mControl);

            mLeftRuler           = new Ruler(mControl, mManagers, mCursor);
            mLeftRuler.RulerSide = RulerSide.Left;

            mTopRuler           = new Ruler(mControl, mManagers, mCursor);
            mTopRuler.RulerSide = RulerSide.Top;

            mManagers.Renderer.Camera.CameraCenterOnScreen = CameraCenterOnScreen.TopLeft;
            mManagers.Renderer.Camera.X = -50;
            mManagers.Renderer.Camera.Y = -50;

            cameraController = new CameraController(Camera, mManagers, mCursor, mControl, mTopRuler, mLeftRuler);
        }
Example #6
0
        private void MoveSpriteAccordingToAlignmentAndOffset(RenderingLibrary.Graphics.Sprite sprite, AnimationFrameSave frame)
        {
            // Event though we may not be rendering the main Sprite, we want to use the main Sprite's animation:
            IAnimation animation = mSprite.Animation;

            if (sprite != null && sprite.Visible && mSprite.Animation != null)
            {
                int index = sprite.Animation.CurrentFrameIndex;

                float animationXOffset = 0;
                float animationYOffset = 0;

                AnimationChainSave chain = SelectedState.Self.SelectedChain;



                if (chain != null && chain.Frames.Count > index)
                {
                    if (frame == null)
                    {
                        frame = chain.Frames[index];
                    }

                    animationXOffset = frame.RelativeX * OffsetMultiplier;
                    animationYOffset = frame.RelativeY * OffsetMultiplier;
                }

                if (SpriteAlignment == Data.SpriteAlignment.Center)
                {
                    float xOffset = (-sprite.EffectiveWidth) / 2.0f;
                    float yOffset = (-sprite.EffectiveHeight) / 2.0f;

                    sprite.X = xOffset + animationXOffset;
                    sprite.Y = yOffset - animationYOffset;
                }
                else
                {
                    sprite.X = 0 + animationXOffset;
                    sprite.Y = 0 - animationYOffset;
                }
            }
        }
Example #7
0
        private void UpdateSpriteToAnimationFrame(AnimationFrameSave afs, RenderingLibrary.Graphics.Sprite sprite)
        {
            sprite.Animate = false;

            sprite.Texture = WireframeManager.Self.GetTextureForFrame(afs);
            if (sprite.Texture != null)
            {
                sprite.SourceRectangle = GetSourceRetangleForFrame(afs, sprite.Texture);
                if (sprite.SourceRectangle.HasValue)
                {
                    sprite.Width  = sprite.SourceRectangle.Value.Width;
                    sprite.Height = sprite.SourceRectangle.Value.Height;
                }
            }
            sprite.FlipHorizontal = afs.FlipHorizontal;
            sprite.FlipVertical   = afs.FlipVertical;
            sprite.Animation      = mSprite.Animation;

            MoveSpriteAccordingToAlignmentAndOffset(sprite, afs);
        }
Example #8
0
        private void UpdateOnionSkinSprites()
        {
            bool shouldShow = SelectedState.Self.SelectedFrame != null &&
                              SelectedState.Self.SelectedChain.Frames.Count > 1 &&
                              mPreviewControls.IsOnionSkinVisible;

            if (shouldShow)
            {
                if (mOnionSkinSprites.Count == 0)
                {
                    RenderingLibrary.Graphics.Sprite sprite = new RenderingLibrary.Graphics.Sprite(null);
                    sprite.Color = new Microsoft.Xna.Framework.Color(1, 1, 1, .5f);
                    sprite.Z     = -1;
                    mManagers.SpriteManager.Add(sprite);
                    mOnionSkinSprites.Add(sprite);
                }

                int indexToShow = SelectedState.Self.SelectedChain.Frames.IndexOf(SelectedState.Self.SelectedFrame) - 1;
                if (indexToShow == -1)
                {
                    indexToShow = SelectedState.Self.SelectedChain.Frames.Count - 1;
                }

                AnimationFrameSave frame = SelectedState.Self.SelectedChain.Frames[indexToShow];

                UpdateSpriteToAnimationFrame(frame, mOnionSkinSprites[0]);
            }
            else
            {
                while (mOnionSkinSprites.Count != 0)
                {
                    RenderingLibrary.Graphics.Sprite sprite = mOnionSkinSprites[0];
                    mManagers.SpriteManager.Remove(sprite);
                    mOnionSkinSprites.RemoveAt(0);
                }
            }
        }
Example #9
0
        private void CreateVisualRepresentation()
        {
            mOffsetSprite = new Sprite(null);

            mRectangle = new SolidRectangle();
            mRectangle.Color = Color.Yellow;
            ShapeManager.Add(mRectangle, mLayer);

            ReactToRulerSides();

            CreateRulerLines();
        }
        private bool AssignSourceFileOnSprite(object value, Sprite sprite)
        {
            bool handled;
            string valueAsString = value as string;

            if (string.IsNullOrEmpty(valueAsString))
            {
                sprite.Texture = null;
                sprite.AtlasedTexture = null;

                UpdateLayout();
            }
            else
            {
                if (ToolsUtilities.FileManager.IsRelative(valueAsString))
                {
                    valueAsString = ToolsUtilities.FileManager.RelativeDirectory + valueAsString;

                    valueAsString = ToolsUtilities.FileManager.RemoveDotDotSlash(valueAsString);
                }

                // see if an atlas exists:
                var atlasedTexture = global::RenderingLibrary.Content.LoaderManager.Self.TryLoadContent<AtlasedTexture>(valueAsString);

                if (atlasedTexture != null)
                {
                    sprite.AtlasedTexture = atlasedTexture;
                    UpdateLayout();
                }
                else
                {
                    if (ToolsUtilities.FileManager.FileExists(valueAsString))
                    {
                        sprite.Texture = global::RenderingLibrary.Content.LoaderManager.Self.LoadContent<Microsoft.Xna.Framework.Graphics.Texture2D>(valueAsString);
                        UpdateLayout();
                    }
                }
            }
            handled = true;
            return handled;
        }
Example #11
0
        private void UpdateOnionSkinSprites()
        {
            bool shouldShow = SelectedState.Self.SelectedFrame != null &&
                SelectedState.Self.SelectedChain.Frames.Count > 1 &&
                mPreviewControls.IsOnionSkinVisible;

            if (shouldShow)
            {
                if (mOnionSkinSprites.Count == 0)
                {
                    RenderingLibrary.Graphics.Sprite sprite = new RenderingLibrary.Graphics.Sprite(null);
                    sprite.Color = new Microsoft.Xna.Framework.Color(1, 1, 1, .5f);
                    sprite.Z = -1;
                    mManagers.SpriteManager.Add(sprite);
                    mOnionSkinSprites.Add(sprite);
                }

                int indexToShow = SelectedState.Self.SelectedChain.Frames.IndexOf(SelectedState.Self.SelectedFrame) - 1;
                if (indexToShow == -1)
                {
                    indexToShow = SelectedState.Self.SelectedChain.Frames.Count - 1;
                }

                AnimationFrameSave frame = SelectedState.Self.SelectedChain.Frames[indexToShow];

                UpdateSpriteToAnimationFrame(frame, mOnionSkinSprites[0]);
            }
            else
            {
                while (mOnionSkinSprites.Count != 0)
                {
                    RenderingLibrary.Graphics.Sprite sprite = mOnionSkinSprites[0];
                    mManagers.SpriteManager.Remove(sprite);
                    mOnionSkinSprites.RemoveAt(0);
                }
            }

        }
Example #12
0
        void HandleXnaInitialize()
        {
            mManagers = new SystemManagers();
            mManagers.Initialize(mControl.GraphicsDevice);

            mManagers.Renderer.SamplerState = SamplerState.PointClamp;

            mManagers.Name = "Preview Window Managers";
            ShapeManager shapeManager = mManagers.ShapeManager;

            mSprite = new RenderingLibrary.Graphics.Sprite(null);


            mRectangle = new LineRectangle(mManagers);
            mManagers.ShapeManager.Add(mRectangle);
            // Move it in front of the Sprite
            mRectangle.Z = 1;

            mManagers.SpriteManager.Add(mSprite);

            mControl.Resize += new EventHandler(HandleResize);
            mControl.XnaUpdate += new Action(HandleXnaUpdate);
            MoveCameraToProperLocation();

            // We'll use Cursor.Self which is initialized and updated elsewhere
            // Actually looks like that's not the case.  We'll make a new one.
            mCursor = new Cursor();
            mCursor.Initialize(mControl);

            mKeyboard = new Keyboard();
            mKeyboard.Initialize(mControl);

            mLeftRuler = new Ruler(mControl, mManagers, mCursor);
            mLeftRuler.RulerSide = RulerSide.Left;

            mTopRuler = new Ruler(mControl, mManagers, mCursor);
            mTopRuler.RulerSide = RulerSide.Top;

            mManagers.Renderer.Camera.CameraCenterOnScreen = CameraCenterOnScreen.TopLeft;
            mManagers.Renderer.Camera.X = -50;
            mManagers.Renderer.Camera.Y = -50;

            cameraController = new CameraController(Camera, mManagers, mCursor, mControl, mTopRuler, mLeftRuler);

        }