void TextChange()
 {
     if (Size != null && Font.get() != null)
     {
         Size.set(Font.get().MeasureString(Text.get()) * SizeMult.get());
     }
 }
Exemple #2
0
        public override void DrawAsForm(Vector2 Position, Vector2 Size)
        {
            Render.DrawSprite(HudItem.GlowTexture, Position, Size * 32, 0, Color.Black * (Alpha - 0.5f) * 2);

            Arrow1.Draw(Position, Size);
            Arrow2.Draw(Position, Size);

            Render.DrawShadowedText(Font.get(), Text.get(), Position + new Vector2(0, -Size.Y) - Font.get().MeasureString(Text.get()) / 2,
                                    Vector2.Zero, MyColor.getAsColor() * Alpha, Color.Black * Alpha);

            float MinX          = Position.X - Size.X / 2 + Size.Y / 2;
            float MaxX          = Position.X + Size.X / 2 - Size.Y / 2;
            float InterpolatedX = MinX;

            if (SliderValue != null)
            {
                InterpolatedX += (MaxX - MinX) * (SliderValue.get() - MinValue.get()) / (MaxValue.get() - MinValue.get());
            }

            Render.DrawSprite(SliderCircleTexture, Position, new Vector2(Size.Y / 2), 0, Color.Red * Alpha);
            Render.DrawSprite(SliderCircleTexture, new Vector2(InterpolatedX, Position.Y), new Vector2(Size.Y * 0.75f), 0, Color.White * Alpha);
            Render.DrawSprite(SliderBarTexture, Position, Size, 0, Color.White * Alpha);

            base.DrawAsForm(Position, Size);
        }
        public override void DrawAsForm(Vector2 Position, Vector2 Size)
        {
            Vector2 FormSize  = Size * Alpha * 1.5f;
            float   FormAlpha = Alpha * DistanceAlpha;

            Render.DrawSprite(WaveCard.UnitPicker, Position, Size * new Vector2((Rand.F() + 6) / 7 * 4, 2.5f), Rotation.get(), MyColor * FormAlpha * 2);

            Render.DrawSprite(WaveCard.UnitBox, Position, FormSize * 1.25f, Rotation.get(), MyColor * (FormAlpha * FormAlpha * 0.3f * (4 + Rand.F())));
            Render.DrawSprite(WaveCard.UnitPicker, Position, FormSize * new Vector2((Rand.F() + 6) / 7, 1), Rotation.get(), MyColor * (FormAlpha * FormAlpha * 0.3f * (4 + Rand.F())));
            Render.DrawSprite(MyTexture, Position, FormSize, Rotation.get(), Color.White * FormAlpha);


            if (FlashAlpha > 0)
            {
                Render.DrawSprite(HudItem.GlowTexture, Position, FormSize * 2, Rotation.get(), MyColor * 1.5f * FlashAlpha * FormAlpha);
            }
            if (ErrorAlpha > 0)
            {
                Render.DrawSprite(HudItem.GlowTexture, Position, FormSize * 2, Rotation.get(), Color.Red * 1.5f * ErrorAlpha * FormAlpha);
                Render.DrawSprite(FactionEvent.LossTexture, Position, FormSize, Rotation.get(), Color.Red * 1.5f * ErrorAlpha * FormAlpha);
            }
            if (SelectedAlpha > 0)
            {
                Render.DrawSprite(FactionEvent.ReadyTexture, Position, FormSize * SelectedAlpha, Rotation.get(), MyColor * SelectedAlpha * 2 * FormAlpha);
                Render.DrawSprite(HudItem.GlowTexture, Position, FormSize, Rotation.get(), MyColor * SelectedAlpha * FormAlpha * 1.5f);
            }

            if (FormAlpha > 0.5 && Font.get() != null)
            {
                float DrawHeight = Position.Y - Size.Y / 2;
                float FontHeight = Font.get().MeasureString(Name.get()).Y;
                DrawHeight -= FontHeight * 2;

                string CostString = "";
                if (MyCard.FactionCostIncreases.ContainsKey(ParentShip.FactionNumber))
                {
                    CostString = "$" + (MyCard.CardCellsCost + MyCard.CardCellsCostIncrease * MyCard.FactionCostIncreases[ParentShip.FactionNumber]).ToString();
                }
                else
                {
                    CostString = "$" + (MyCard.CardCellsCost).ToString();
                }

                Render.DrawShadowedText(Font.get(), Text.get(), new Vector2(Position.X - Font.get().MeasureString(Text.get()).X / 2, DrawHeight),
                                        Vector2.One * 2, Color.White * (FormAlpha - 0.5f) * 2, Color.Black * (FormAlpha - 0.5f) * 2);
                DrawHeight -= FontHeight;
                Render.DrawShadowedText(Font.get(), CostString, new Vector2(Position.X - Font.get().MeasureString(CostString).X / 2, DrawHeight),
                                        Vector2.One * 2, Color.White * (FormAlpha - 0.5f) * 2, Color.Black * (FormAlpha - 0.5f) * 2);
                if (FactionManager.GetFaction(ParentShip.FactionNumber).PickingCards)
                {
                    Vector2 s = Font.get().MeasureString(MyCard.Caption);
                    DrawHeight -= s.Y + 20;
                    //DrawHeight += 2 * FontHeight;
                    Render.DrawSprite(HudItem.GlowTexture, new Vector2(Position.X, DrawHeight + s.Y / 2), s * 6,
                                      0, Color.Black * (FormAlpha - 0.5f) * 2);
                    Render.DrawShadowedText(Font.get(), MyCard.Caption, new Vector2(Position.X - Font.get().MeasureString(MyCard.Caption).X / 2, DrawHeight),
                                            Vector2.One * 2, Color.White * (FormAlpha - 0.5f) * 2, Color.Black * (FormAlpha - 0.5f) * 2);
                }

                if (!MyCard.StrongVs.Equals(""))
                {
                    Render.DrawSprite(MyCard.GetStrongTexture(), Position - Size * 3 / 8 * new Vector2(1, -1), Size / 2, 0, Color.White * (FormAlpha * FormAlpha));
                    Render.DrawShadowedText(Font.get(), MyCard.StrongVs,
                                            new Vector2(Position.X - Size.X * 1 / 8, Position.Y - Font.get().MeasureString(MyCard.StrongVs).Y * 3 / 4 + Size.Y / 2),
                                            Vector2.One * 2, Color.White * (FormAlpha - 0.5f) * 2, Color.Black * (FormAlpha - 0.5f) * 2);
                }
            }

            Render.DrawOutlineRect(Position - FormSize * (FormAlpha - 0.5f), Position + FormSize * (FormAlpha - 0.5f), 2 * FormAlpha, Color.White * (FormAlpha * FormAlpha * FormAlpha));

            base.DrawAsForm(Position, FormSize);
        }