Exemple #1
0
 void LoadEyeButtons()
 {
     Button[] eyeButtons = new Button[animGroup.Animations.Length];
     for (int i = 0; i < eyeButtons.Length; i++)
     {
         if (animGroup.NameFields[i] != null)
         {
             eyeButtons[i] = new EyeButton(cursorTexture, new Rectangle((int)animGroup.NameFields[i].Position.X - 20, (int)animGroup.NameFields[i].Position.Y - 1, 16, 16), currentAnimation);
         }
     }
     eyeButtonPanel = new ButtonPanel(eyeButtons);
     eyeButtonPanel.Load();
 }
Exemple #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch   = new SpriteBatch(GraphicsDevice);
            spriteBatchUI = new SpriteBatch(GraphicsDevice);
            camera        = new Camera2D(GraphicsDevice);
            camera.Zoom   = 1.0f;

            partTextures = new Texture2D[32];

            pixelTexture = new Texture2D(GraphicsDevice, 1, 1);
            pixelTexture.SetData(new Color[] { Color.White });

            transparentTexture = Content.Load <Texture2D>("gfx/transparency");
            cursorTexture      = Content.Load <Texture2D>("gfx/cursors");
            consolas           = Content.Load <SpriteFont>("consolas");
            leelawadee         = Content.Load <SpriteFont>("leelawadee");

            animGroup        = new AnimationGroup(new Animation(pixelTexture), consolas, leelawadee);
            currentAnimation = animGroup.CurrentAnimation;
            currentAnimation.AddFrame(new Frame());
            currentFrame = currentAnimation.CurrentFrame;

            textFields = new TextField[32];

            Vector2 animGroupTextPos = new Vector2(16, 128);

            textAnimGroupName = new TextField(consolas, leelawadee, animGroupTextPos, "newgroup", "Animation Group:", 12, pixelTexture);

            for (int i = 0; i < animGroup.Animations.Length; i++)
            {
                Vector2 textPosition = new Vector2(animGroupTextPos.X + 20, 152 + ((consolas.LineSpacing + 2) * (i + 1)));
                animGroup.AddNewTextField(textPosition, "animation" + animGroup.Animations.Length);
            }

            cursor = new Cursor(cursorTexture, graphics, currentFrame, leelawadee, pixelTexture);
            cursor.Load();

            input = new InputManager(animGroup, camera);

            deleteFrameButton = new DeleteFrameButton(cursorTexture, new Rectangle(16, 16, 24, 24), currentAnimation);
            newFrameButton    = new NewFrameButton(cursorTexture, new Rectangle(48, 16, 24, 24), currentAnimation);
            tweenButton       = new TweenButton(cursorTexture, new Rectangle(80, 16, 24, 24), currentAnimation);

            plusTicksButton  = new PlusTicksButton(cursorTexture, new Rectangle(112, 60, 16, 16), currentAnimation);
            minusTicksButton = new MinusTicksButton(cursorTexture, new Rectangle(88, 60, 16, 16), currentAnimation);

            addAnimButton    = new AddAnimButton(cursorTexture, new Rectangle(96, 144, 16, 16), currentAnimation);
            removeAnimButton = new RemoveAnimButton(cursorTexture, new Rectangle(72, 144, 16, 16), currentAnimation);
            dupAnimButton    = new DuplicateAnimButton(cursorTexture, new Rectangle(120, 144, 16, 16), currentAnimation);
            animUpButton     = new UpButton(cursorTexture, new Rectangle(40, 144, 16, 16), currentAnimation);
            animDownButton   = new DownButton(cursorTexture, new Rectangle(16, 144, 16, 16), currentAnimation);

            paletteLeftButton  = new PaletteLeftButton(cursorTexture, new Rectangle(0, GraphicsDevice.Viewport.Height - 44, 24, 24), currentAnimation);
            paletteRightButton = new PaletteRightButton(cursorTexture, new Rectangle(GraphicsDevice.Viewport.Width - 24, GraphicsDevice.Viewport.Height - 44, 24, 24), currentAnimation);

            onionSkinButton = new OnionSkinButton(cursorTexture, new Rectangle((graphics.GraphicsDevice.Viewport.Width / 2) - 96, 16, 24, 24), currentAnimation);
            prevButton      = new PrevButton(cursorTexture, new Rectangle((graphics.GraphicsDevice.Viewport.Width / 2) - 64, 16, 24, 24), currentAnimation);
            pauseButton     = new PauseButton(cursorTexture, new Rectangle((graphics.GraphicsDevice.Viewport.Width / 2) - 32, 16, 24, 24), currentAnimation);
            playButton      = new PlayButton(cursorTexture, new Rectangle((graphics.GraphicsDevice.Viewport.Width / 2), 16, 24, 24), currentAnimation);
            nextButton      = new NextButton(cursorTexture, new Rectangle((graphics.GraphicsDevice.Viewport.Width / 2) + 32, 16, 24, 24), currentAnimation);

            saveButton = new SaveButton(cursorTexture, new Rectangle((graphics.GraphicsDevice.Viewport.Width) - 64, 16, 24, 24), currentAnimation);
            loadButton = new LoadButton(cursorTexture, new Rectangle((graphics.GraphicsDevice.Viewport.Width) - 32, 16, 24, 24), currentAnimation);

            Button[] buttons = { prevButton, pauseButton, playButton, nextButton, newFrameButton, deleteFrameButton, plusTicksButton, minusTicksButton, tweenButton, saveButton, onionSkinButton, loadButton, addAnimButton, removeAnimButton, dupAnimButton, animUpButton, animDownButton, paletteLeftButton, paletteRightButton };
            buttonPanel = new ButtonPanel(buttons);
            buttonPanel.Load();

            LoadEyeButtons();

            int textureCounter = 0;

            while (textureCounter != -1)
            {
                textureCounter = LoadPartTextures(textureCounter);
            }

            partsPalette = new PartsPalette(partTextures, transparentTexture, graphics);
            partsPalette.Load();

            textFields[0] = textBoundsX = new TextField(consolas, leelawadee, new Vector2(16, GraphicsDevice.Viewport.Height - (partsPalette.GridSize + 16)), currentAnimation.Bounds.X.ToString(), "Bounds X:", 12, pixelTexture);
            textFields[1] = textBoundsY = new TextField(consolas, leelawadee, new Vector2(128, GraphicsDevice.Viewport.Height - (partsPalette.GridSize + 16)), currentAnimation.Bounds.Y.ToString(), "Bounds Y:", 12, pixelTexture);
            textFields[2] = textBoundsWidth = new TextField(consolas, leelawadee, new Vector2(240, GraphicsDevice.Viewport.Height - (partsPalette.GridSize + 16)), currentAnimation.Bounds.Y.ToString(), "Bounds Width:", 12, pixelTexture);
            textFields[3] = textBoundsHeight = new TextField(consolas, leelawadee, new Vector2(352, GraphicsDevice.Viewport.Height - (partsPalette.GridSize + 16)), currentAnimation.Bounds.Y.ToString(), "Bounds Height:", 12, pixelTexture);
            textFields[4] = textTweenFrames = new TextField(consolas, leelawadee, new Vector2(112, 32), "1", "Tween Frames:", 12, pixelTexture);
            textFields[5] = textScript = new TextField(consolas, leelawadee, new Vector2(GraphicsDevice.Viewport.Width / 2 + 128, 32), currentFrame.Script, "Script:", 120, pixelTexture);

            groupAnimCount = animGroup.Animations.Length;
            mouseCoords    = new Label(leelawadee, "Mouse Coords: " + cursor.MouseState.X + ", " + cursor.MouseState.Y, new Vector2((graphics.GraphicsDevice.Viewport.Width - 16) - (leelawadee.MeasureString("Mouse Coords: 0000, 0000").X), GraphicsDevice.Viewport.Height - (partsPalette.GridSize + 16)), Color.White);
            camZoom        = new Label(leelawadee, "Zoom: ", new Vector2((graphics.GraphicsDevice.Viewport.Width - 16) - (leelawadee.MeasureString("Mouse Coords: 0000, 0000").X), GraphicsDevice.Viewport.Height - (partsPalette.GridSize + 32)), Color.White);
        }