예제 #1
0
        public HudElementFloatyDamage(ICoreClientAPI capi, double damage, Vec3d pos) : base(capi)
        {
            this.pos = pos.Clone();

            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialogAtPos(0.0);
            ElementBounds textBounds   = ElementBounds.Fixed(EnumDialogArea.CenterMiddle, 0, 0, 250, 50);

            font = CairoFont.WhiteDetailText();

            color      = new double[4];
            color[3]   = 1.0;
            color[0]   = damage > 0 ? 1.0 : 0.0;
            color[1]   = damage > 0 ? 0.0 : 1.0;
            font.Color = color;

            string dmg = Math.Abs(damage).ToString("F3");

            font = font.WithStroke(new double[] { 0.0, 0.0, 0.0, 1.0 }, 1.0).WithWeight(Cairo.FontWeight.Bold).WithFontSize(15);

            SingleComposer = capi.Gui
                             .CreateCompo("floatyDmg" + damage + capi.Gui.OpenedGuis.Count + 1 + GetHashCode(), dialogBounds)
                             .AddDynamicText(dmg, font, EnumTextOrientation.Center, textBounds, "text")
                             .Compose();

            SingleComposer.Bounds.Alignment    = EnumDialogArea.None;
            SingleComposer.Bounds.fixedOffsetX = 0;
            SingleComposer.Bounds.fixedOffsetY = 0;
            SingleComposer.Bounds.absMarginX   = 0;
            SingleComposer.Bounds.absMarginY   = 0;
            MakeAdjustments(0);
            TryOpen();
        }