Пример #1
0
        public override void OnOwnPlayerDataReceived()
        {
            ElementBounds statbarbounds = ElementStdBounds.Statbar(EnumDialogArea.CenterBottom, 347).WithFixedAlignmentOffset(-125, -44);

            statbarbounds.WithFixedHeight(9);

            ElementBounds parentBounds = statbarbounds.ForkBoundingParent();

            SingleComposer = capi.Gui.CreateCompo("airbar", parentBounds)
                             .AddStatbar(statbarbounds, new double[] { 0.2, 0.2, 0.2, 0.5 }, "background")
                             .AddStatbar(statbarbounds, new double[] { 255.0 / 66.0, 255.0 / 134.0, 255.0 / 244.0, 0.5 }, "airbar")
                             .Compose();
            SingleComposer.GetStatbar("background").SetMinMax(0, 1);

            statbar = SingleComposer.GetStatbar("airbar");
            statbar.SetMinMax(0, 1);
            statbar.SetLineInterval(1f / 16f);
            statbar.FlashTime = 4.0f;

            SingleComposer.ReCompose();

            capi.World.Player.Entity.WatchedAttributes.RegisterModifiedListener("health", () => UpdateGUI());

            base.OnOwnPlayerDataReceived();
        }
        public void ComposeBars()
        {
            double elemToDlgPad = GuiStyle.ElementToDialogPadding;
            float  width        = 850;

            ElementBounds bounds = new ElementBounds()
            {
                Alignment   = EnumDialogArea.CenterBottom,
                BothSizing  = ElementSizing.Fixed,
                fixedWidth  = width,
                fixedHeight = 100
            }.WithFixedAlignmentOffset(0, -1);

            ElementBounds bodyheatBounds  = StatbarBounds(EnumDialogArea.LeftTop, width * 0.41).WithFixedAlignmentOffset(-2, 7);
            ElementBounds thirstBarBounds = StatbarBounds(EnumDialogArea.RightTop, width * 0.41).WithFixedAlignmentOffset(-2, 7);

            ElementBounds horBarBounds = ElementStdBounds.SlotGrid(EnumDialogArea.CenterFixed, 0, 38, 10, 1);

            Composers["hudvitals"] =
                capi.Gui
                .CreateCompo("inventory-hudvitals", bounds.FlatCopy().FixedGrow(0, 10))
                .BeginChildElements(bounds)
                .AddStatbar(bodyheatBounds, GuiStyle.XPBarColor, "bodyheatstatbar")
                .AddInvStatbar(thirstBarBounds, GuiStyle.DialogBlueBgColor, "thirststatbar")
                .EndChildElements()
                .Compose();

            bodyheatBar = Composers["hudvitals"].GetStatbar("bodyheatstatbar");
            thirstBar   = Composers["hudvitals"].GetStatbar("thirststatbar");

            bodyheatBar.SetLineInterval((float)2);
            bodyheatBar.FlashTime = 2;
            bodyheatBar.SetMinMax((float)0, (float)12);
            bodyheatBar.ShowValueOnHover = false;


            thirstBar.SetLineInterval((float)100);
            thirstBar.FlashTime = 2;
            thirstBar.SetMinMax((float)0, (float)1500);

            if (entity != null)
            {
                this.UpdateBodyheat();
                this.UpdateThirst();

                TryOpen();
            }
        }