コード例 #1
0
        public override ViewElement CreateMainView()
        {
            ViewElement newView      = new ViewElement();
            var         elementsList = new List <IGuiElement>();

            var firstBtnPosition = new Point(0, 100);
            var firstBtnColor    = new MonoGameColor(MyColor.AliceBlue);
            var firstBtnText     = "Clicketh thou mouse pointer here to bombard \n Thine eyes with quotes";

            System.Action firstBtnOnClickAction = () => { GuiManager.currentView = this.CreateLabelView(); };

            elementsList.Add(new ClickableDecorator(new LabelElement(firstBtnPosition, firstBtnColor, firstBtnText),
                                                    firstBtnOnClickAction, firstBtnPosition, 500, 30));


            var exitBtnPosition = new Point(0, 300);
            var exitBtnColor    = new MonoGameColor(MyColor.AliceBlue);
            var exitBtnText     = "Clicketh thou mouse pointer here to leave";

            System.Action exitBtnOnClickAction = () => { exitFunc(); };

            elementsList.Add(new ClickableDecorator(new LabelElement(exitBtnPosition, exitBtnColor, exitBtnText),
                                                    exitBtnOnClickAction, exitBtnPosition, 500, 30));


            newView.elements = new GUIElementsIterator(elementsList);
            return(newView);
        }
コード例 #2
0
        public override ViewElement CreateLabelView()
        {
            ViewElement newView      = new ViewElement();
            var         elementsList = new List <IGuiElement>();


            var firstLabelPosition = new Point(0, 100);
            var firstLabelColor    = new MonoGameColor(MyColor.AliceBlue);
            var firstLabelText     = "I returned, and saw under the sun, that the race is not to the swift, \n" +
                                     "nor the battle to the strong, neither yet bread to the wise, \n" +
                                     "nor yet riches to men of understanding, nor yet favour to men of skill; \n" +
                                     "but time and chance happeneth to them all. \n";

            elementsList.Add(new LabelElement(firstLabelPosition, firstLabelColor, firstLabelText));


            var backBtnPosition = new Point(0, 200);
            var backBtnColor    = new MonoGameColor(MyColor.AliceBlue);
            var backBtnText     = "Clicketh thou mouse pointer here to return from whence thy came";

            System.Action backBtnOnClickAction = () => { GuiManager.currentView = this.CreateMainView(); };

            elementsList.Add(new ClickableDecorator(new LabelElement(backBtnPosition, backBtnColor, backBtnText),
                                                    backBtnOnClickAction, backBtnPosition, 500, 30));


            newView.elements = new GUIElementsIterator(elementsList);
            return(newView);
        }
コード例 #3
0
        internal void drawTexture(MonoGameTexture texture, float x, float y, int srcX, int srcY, int srcWidth,
                                  int srcHeight, float scaleX, float scaleY, float originX, float originY, float rotation, bool flipX,
                                  bool flipY, MonoGameColor tint)
        {
            beginRendering();
            if (texture.getUAddressMode() != _currentUMode || texture.getVAddressMode() != _currentVMode)
            {
                _currentUMode = texture.getUAddressMode();
                _currentVMode = texture.getVAddressMode();
                updateAddressMode();
            }


            _sharedPositionVector.X       = x - originX;
            _sharedPositionVector.Y       = y - originY;
            _sharedSourceRectangle.X      = srcX;
            _sharedSourceRectangle.Y      = srcY;
            _sharedSourceRectangle.Width  = srcWidth;
            _sharedSourceRectangle.Height = srcHeight;
            _sharedOriginVector.X         = originX;
            _sharedOriginVector.Y         = originY;
            _sharedScaleVector.X          = scaleX;
            _sharedScaleVector.Y          = scaleY;

            _spriteBatch.Draw(texture.texture2D, _sharedPositionVector, _sharedSourceRectangle, tint._color,
                              MonoGameMathsUtil.degreeToRadian(rotation), _sharedOriginVector, _sharedScaleVector,
                              (flipX ? SpriteEffects.FlipHorizontally : SpriteEffects.None) |
                              (flipY ? SpriteEffects.FlipVertically : SpriteEffects.None), 0f);
        }
コード例 #4
0
 public MonoGameGraphics(GraphicsDevice graphicsDevice)
 {
     _spriteBatch    = new SpriteBatch(graphicsDevice);
     _graphicsDevice = graphicsDevice;
     _translation    = Vector2.Zero;
     _scale          = Vector2.One;
     _rotationCenter = Vector2.Zero;
     _shapeRenderer  = new MonoGameShapeRenderer(graphicsDevice, MonoGameColor.toArgb(_setColor), _spriteBatch, _rotationCenter, _translation, _scale, _tint);
 }
コード例 #5
0
        public override Pixmap newPixmap(FileHandle file)
        {
            Texture2D texture;

            texture = ((MonoGameTexture)newTexture(file)).texture2D;

            var rawTextureData = new UInt32[texture.Width * texture.Height];

            texture.GetData(rawTextureData);

            var pixmap = new MonoGamePixmap(texture.Width, texture.Height);

            for (int x = 0; x < texture.Width; x++)
            {
                for (int y = 0; y < texture.Height; y++)
                {
                    pixmap.drawPixel(x, y, MonoGameColor.argbToRgba(rawTextureData[x + y * texture.Width]));
                }
            }

            return(pixmap);
        }
コード例 #6
0
        public Pixmap newPixmap(FileHandle file)
        {
            Texture2D texture;

            using (var fileStream = new FileStream(((MonoGameFileHandle)file).fullPath(), FileMode.Open))
            {
                texture = Texture2D.FromStream(_graphicsDevice, fileStream);
            }
            var rawTextureData = new UInt32[texture.Width * texture.Height];

            texture.GetData(rawTextureData);

            var pixmap = new MonoGamePixmap(texture.Width, texture.Height);

            for (int x = 0; x < texture.Width; x++)
            {
                for (int y = 0; y < texture.Height; y++)
                {
                    pixmap.drawPixel(x, y, MonoGameColor.argbToRgba(rawTextureData[x + y * texture.Width]));
                }
            }

            return(pixmap);
        }
コード例 #7
0
 public LabelElement(Point position, MonoGameColor color, string text)
 {
     this.position = position;
     this.color    = color;
     this.text     = text;
 }
コード例 #8
0
 public override Color newReadOnlyColor(int rgba8888)
 {
     return(new MonoGameReadOnlyColor(MonoGameColor.toMonoGameColor((uint)rgba8888)));
 }
コード例 #9
0
        public void DrawString(string text, GUIapp.Point point, MonoGameColor colorAdapter)
        {
            var pointAsVector = new Microsoft.Xna.Framework.Vector2(point.X, point.Y);

            sprite_batch.DrawString(font, text, pointAsVector, colorAdapter.toFrameworkColor());
        }
コード例 #10
0
        public void DrawRectangle(Point topleft, int width, int height, MonoGameColor colorAdapter)
        {
            var rect = new Microsoft.Xna.Framework.Rectangle((int)topleft.X, (int)topleft.Y, width, height);

            sprite_batch.Draw(texture, rect, colorAdapter.toFrameworkColor());
        }
コード例 #11
0
 public Color newColor(int rgba8888)
 {
     return(new MonoGameColor(MonoGameColor.toMonoGameColor((uint)rgba8888)));
 }
コード例 #12
0
 public void setColor(Color color)
 {
     _setColor = color;
     _shapeRenderer.setColor(MonoGameColor.toArgb(_setColor));
 }