예제 #1
0
        public MeterBar(SurfaceMath sm, MeterDefinition def, Dictionary <Data, IData> shipData)
        {
            this.sm = sm;
            sm.PostionInterpreter(def);
            this.def      = def;
            this.shipData = shipData;
            def.position += sm.Center;

            if (def.min == 0 && def.max == 0)
            {
                UseDataMinMax = true;
            }
            else
            {
                total = def.max - def.min;
            }

            sprite                 = new MySprite(SpriteType.TEXTURE, "SquareSimple", color: def.color);
            sprite.Position        = sm.AdjustToRotation(sm.AdjustToAnchor(def.anchor, def.position, def.size), def.position, def.rotation);
            spriteSize.Y           = def.size.Y;
            sprite.RotationOrScale = def.rotation;

            if (def.backgroundSet)
            {
                background                 = new MySprite(SpriteType.TEXTURE, "SquareSimple", color: def.background);
                background.Position        = sm.AdjustToRotation(sm.AdjustToAnchor(def.anchor, def.position, def.size), def.position, def.rotation);
                background.Size            = def.size;
                background.RotationOrScale = def.rotation;
            }
        }
        public MeterThreeQuaterMeter(SurfaceMath sm, MeterDefinition def, Dictionary <Data, IData> shipData, Color background)
        {
            this.sm = sm;
            sm.PostionInterpreter(def);
            this.def        = def;
            this.shipData   = shipData;
            this.background = background;
            def.position   += sm.Center;


            if (def.min == 0 && def.max == 0)
            {
                UseDataMinMax = true;
            }
            else
            {
                total = def.max - def.min;
            }

            float innerSize = MathHelper.Clamp(1 - def.stroke, 0, 1);

            def.size.Y = def.size.X;             //Make square. Y is used for cicle thickness.

            full     = new MySprite(SpriteType.TEXTURE, "Circle", def.position, color: def.color);
            semi     = new MySprite(SpriteType.TEXTURE, "SemiCircle", def.position, def.size);
            top      = new MySprite(SpriteType.TEXTURE, "SemiCircle", def.position, color: def.color);
            bottom   = new MySprite(SpriteType.TEXTURE, "SemiCircle", def.position, def.size);
            inner    = new MySprite(SpriteType.TEXTURE, "Circle", def.position, def.size * innerSize, color: background);
            triangle = new MySprite(SpriteType.TEXTURE, "RightTriangle", def.position, def.size * innerSize, color: background);

            triangle.RotationOrScale = MathHelper.ToRadians(135) + def.rotation;
            triangle.Position        = sm.AdjustToRotation(new Vector2(def.position.X, def.position.Y + def.size.Y * 0.51f), def.position, def.rotation);

            if (def.backgroundSet)
            {
                semi.Color   = def.background;
                bottom.Color = def.background;
                full.Size    = def.size;
                top.Size     = def.size;
            }
            else
            {
                semi.Color   = background;
                bottom.Color = background;
                full.Size    = def.size * 0.97f;              //Shrinking to prevent color shining through. Looks weird with background so skipping it there.
                top.Size     = def.size * 0.97f;
            }

            top.RotationOrScale    = def.rotation + MathHelper.ToRadians(-90);
            bottom.RotationOrScale = MathHelper.ToRadians(180 - 90) + def.rotation;
        }
예제 #3
0
        public MeterText(SurfaceMath sm, MeterDefinition def, Dictionary <Data, IData> shipData)
        {
            sm.PostionInterpreter(def);
            this.def      = def;
            this.shipData = shipData;

            if (def.min == 0 && def.max == 0)
            {
                UseDataMinMax = true;
            }
            else
            {
                total = def.max - def.min;
            }

            if (def.size.X == 0)
            {
                def.size.X = 1;
            }

            def.position   += sm.Center;
            def.position.Y -= sm.TextHeight(def.size.X) * 0.5f;

            sprite          = MySprite.CreateText(def.textData, "Debug", def.color, def.size.X);
            sprite.Position = def.position;
            switch (def.anchor)
            {
            case Anchor.Left:
                sprite.Alignment = TextAlignment.LEFT;
                break;

            case Anchor.Right:
                sprite.Alignment = TextAlignment.RIGHT;
                break;

            case Anchor.Center:
            default:
                sprite.Alignment = TextAlignment.CENTER;
                break;
            }
        }
예제 #4
0
        public MeterSprite(SurfaceMath sm, MeterDefinition def, Dictionary <Data, IData> shipData)
        {
            sm.PostionInterpreter(def);
            this.def      = def;
            this.shipData = shipData;
            def.position += sm.Center;

            if (def.min == 0 && def.max == 0)
            {
                UseDataMinMax = true;
            }
            else
            {
                total = def.max - def.min;
            }

            sprite                 = new MySprite(SpriteType.TEXTURE, def.textData, color: def.color);
            sprite.Size            = def.size;
            sprite.Position        = sm.AdjustToRotation(sm.AdjustToAnchor(def.anchor, def.position, def.size), def.position, def.rotation);
            sprite.RotationOrScale = def.rotation;
        }
예제 #5
0
        public MeterLineGraph(SurfaceMath sm, MeterDefinition def, Dictionary <Data, IData> shipData)
        {
            this.sm = sm;
            sm.PostionInterpreter(def);
            this.def      = def;
            this.shipData = shipData;
            def.position += sm.Center;


            if (def.min == 0 && def.max == 0)
            {
                UseDataMinMax = true;
            }
            else
            {
                total = def.max - def.min;
            }

            for (int i = 0; i < LINES; i++)
            {
                sprites[i] = new MySprite(SpriteType.TEXTURE, "SquareSimple", color: def.color);
            }

            pos = def.position;

            pos.X      -= def.size.X * 0.5f - (def.size.X * SECTION * 0.5f);
            pos.Y      += def.size.Y * 0.5f - (thickness * 0.5f);
            def.size.Y -= thickness;

            valueIndex = LINES - 1;

            if (def.backgroundSet)
            {
                background                 = new MySprite(SpriteType.TEXTURE, "SquareSimple", color: def.background);
                background.Position        = sm.AdjustToRotation(sm.AdjustToAnchor(def.anchor, def.position, def.size), def.position, def.rotation);
                background.Size            = def.size;
                background.RotationOrScale = def.rotation;
            }
        }