private void SetupDialog()
        {
            // Auto-sized dialog at the center of the screen
            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle);
            ElementBounds testBounds   = ElementBounds.Fixed(0, 20, 200, 100);

            // Restart Button Bounds
            ElementBounds oneplayerBounds = ElementBounds.Fixed(20, 40, 200, 50);

            // Restart Button Bounds
            ElementBounds twoPlayerBounds = ElementBounds.Fixed(20, 100, 200, 50);

            // Background boundaries. Again, just make it fit it's child elements, then add the text as a child element
            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(testBounds);

            // Lastly, create the dialog
            SingleComposer = capi.Gui.CreateCompo("dialog-" + DialogTitle, dialogBounds)
                             .AddShadedDialogBG(bgBounds)
                             .AddDialogTitleBar("Start New Game", OnTitleBarCloseClicked)
                             .AddButton("Single Player", OnOnePlayerButtonClicked, oneplayerBounds, EnumButtonStyle.Normal, EnumTextOrientation.Center, "oneplayerbutton")
                             .AddButton("Two Player", OnTwoPlayerButtonClicked, twoPlayerBounds, EnumButtonStyle.Normal, EnumTextOrientation.Center, "twoplayerbutton")
                             .EndChildElements()
                             .Compose()
            ;
        }
        private void OnNewScrollbarValue(float value)
        {
            ElementBounds bounds = SingleComposer.GetContainer("stacklist").Bounds;

            bounds.fixedY = 3 - value;
            bounds.CalcWorldBounds();
        }
Beispiel #3
0
        void ComposeDialog()
        {
            double elemToDlgPad = ElementGeometrics.ElementToDialogPadding;

            ElementBounds button = ElementBounds.Fixed(15, 40, 290, 30).WithFixedPadding(10, 2);

            ElementBounds dialogBounds =
                ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 30, 0, 250, 500)
                .ForkBoundingParent(elemToDlgPad, elemToDlgPad, elemToDlgPad, elemToDlgPad)
            ;

            ClearComposers();

            DialogComposers["loreList"] =
                capi.Gui
                .CreateCompo("loreList", dialogBounds, false)
                .AddDialogBG(ElementBounds.Fill)
                .AddDialogTitleBar("Journal Inventory", CloseIconPressed)
            ;

            for (int i = 0; i < journalitems.Count; i++)
            {
                int page = i;
                DialogComposers["loreList"].AddButton(journalitems[i].Title, () => { return(onClickItem(page)); }, button, CairoFont.WhiteSmallText(), EnumButtonStyle.None, EnumTextOrientation.Left, "button-" + i);

                DialogComposers["loreList"].GetButton("button-" + i).PlaySound = false;

                button = button.BelowCopy();
            }


            DialogComposers["loreList"]
            .Compose()
            ;
        }
        private void OnBgDraw(Context ctx, ImageSurface surface, ElementBounds currentBounds)
        {
            double top = 30;

            // Arrow Right
            ctx.Save();
            Matrix m = ctx.Matrix;

            m.Translate(GuiElement.scaled(63), GuiElement.scaled(top + 2));
            m.Scale(GuiElement.scaled(0.6), GuiElement.scaled(0.6));
            ctx.Matrix = m;
            capi.Gui.Icons.DrawArrowRight(ctx, 2);

            double dx = inputGrindTime / maxGrindTime;


            ctx.Rectangle(GuiElement.scaled(5), 0, GuiElement.scaled(125 * dx), GuiElement.scaled(100));
            ctx.Clip();
            LinearGradient gradient = new LinearGradient(0, 0, GuiElement.scaled(200), 0);

            gradient.AddColorStop(0, new Color(0, 0.4, 0, 1));
            gradient.AddColorStop(1, new Color(0.2, 0.6, 0.2, 1));
            ctx.SetSource(gradient);
            capi.Gui.Icons.DrawArrowRight(ctx, 0, false, false);
            gradient.Dispose();
            ctx.Restore();
        }
Beispiel #5
0
        public GuiDialogCarcassContents(InventoryGeneric inv, EntityAgent owningEntity, ICoreClientAPI capi) : base(capi)
        {
            this.inv          = inv;
            this.owningEntity = owningEntity;


            double pad = GuiElementItemSlotGrid.unscaledSlotPadding;

            int rows = (int)Math.Ceiling(inv.Count / 4f);

            ElementBounds slotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, pad, 40 + pad, 4, rows).FixedGrow(2 * pad, 2 * pad);

            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;

            ElementBounds dialogBounds = ElementStdBounds
                                         .AutosizedMainDialog.WithAlignment(EnumDialogArea.RightMiddle)
                                         .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, 0);


            SingleComposer =
                capi.Gui
                .CreateCompo("carcasscontents" + owningEntity.EntityId, dialogBounds)
                .AddShadedDialogBG(bgBounds, true)
                .AddDialogTitleBar(Lang.Get("carcass-contents"), OnTitleBarClose)
                .BeginChildElements(bgBounds)
                .AddItemSlotGrid(inv, DoSendPacket, 4, slotBounds, "slots")
                .EndChildElements()
                .Compose()
            ;
        }
        private IGuiElementCell createCell(Auction auction, ElementBounds bounds)
        {
            bounds.fixedPaddingY = 0;
            var cellElem = new AuctionCellEntry(capi, bounds, auction, didClickAuctionElem);

            return(cellElem);
        }
        void SetupDialog()
        {
            int cnt = Math.Max(1, skillItems.Count);

            int cols = Math.Min(cnt, 7);

            int rows = (int)Math.Ceiling(cnt / (float)cols);

            double        size            = GuiElementPassiveItemSlot.unscaledSlotSize + GuiElementItemSlotGrid.unscaledSlotPadding;
            double        innerWidth      = Math.Max(300, cols * size);
            ElementBounds skillGridBounds = ElementBounds.Fixed(0, 30, innerWidth, rows * size);

            ElementBounds textBounds = ElementBounds.Fixed(0, rows * size + 50, innerWidth, 33);

            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;


            SingleComposer =
                capi.Gui
                .CreateCompo("toolmodeselect" + blockEntityPos, ElementStdBounds.AutosizedMainDialog)
                .AddShadedDialogBG(bgBounds, true)
                .AddDialogTitleBar(Lang.Get("Select Recipe"), OnTitleBarClose)
                .BeginChildElements(bgBounds)
                .AddSkillItemGrid(skillItems, cols, rows, OnSlotClick, skillGridBounds, "skillitemgrid")
                .AddDynamicText("", CairoFont.WhiteSmallishText(), textBounds, "name")
                .AddDynamicText("", CairoFont.WhiteDetailText(), textBounds.BelowCopy(0, 10, 0, 0), "desc")
                .EndChildElements()
                .Compose()
            ;

            SingleComposer.GetSkillItemGrid("skillitemgrid").OnSlotOver = OnSlotOver;
        }
Beispiel #8
0
        void SetupDialog()
        {
            int           rows            = (int)Math.Ceiling(skillItems.Count / 5f);
            int           cols            = Math.Min(skillItems.Count, 5);
            double        size            = GuiElementPassiveItemSlot.unscaledSlotSize + GuiElementItemSlotGrid.unscaledSlotPadding;
            double        innerWidth      = Math.Max(300, cols * size);
            ElementBounds skillGridBounds = ElementBounds.Fixed(0, 30, innerWidth, rows * size);

            ElementBounds textBounds = ElementBounds.Fixed(0, rows * size + 50, innerWidth, 33);

            SingleComposer =
                capi.Gui
                .CreateCompo("toolmodeselect", ElementStdBounds.AutosizedMainDialog, false)
                .AddDialogTitleBar("Select Recipe", OnTitleBarClose)
                .AddDialogBG(ElementStdBounds.DialogBackground(), false, ElementGeometrics.TitleBarHeight - 1)
                .BeginChildElements()
                .AddSkillItemGrid(skillItems, cols, rows, OnSlotClick, skillGridBounds, "skillitemgrid")
                .AddDynamicText("", CairoFont.WhiteSmallishText(), EnumTextOrientation.Left, textBounds, 1, "name")
                .AddDynamicText("", CairoFont.WhiteDetailText(), EnumTextOrientation.Left, textBounds.BelowCopy(0, 10, 0, 0), 1, "desc")
                .EndChildElements()
                .Compose()
            ;

            SingleComposer.GetSkillItemGrid("skillitemgrid").OnSlotOver = OnSlotOver;
        }
Beispiel #9
0
        private void SetupDialog()
        {
            try
            {
                IAsset maxEssences = capi.Assets.TryGet("alchemy:config/essences.json");
                imageLocation = capi.Assets.TryGet("alchemy:textures/hud/alchemyhud.png").Location;
                if (maxEssences != null)
                {
                    maxEssenceDic = maxEssences.ToObject <Dictionary <string, float> >();
                }
                maxEssenceDic.Remove("recall");
                maxEssenceDic.Remove("duration");
                maxEssenceDic.Remove("health");
            }
            catch (Exception e)
            {
                capi.World.Logger.Error("Failed loading potion effects for potion {0}. Will ignore. Exception: {1}", e);
            }

            ElementBounds textBounds = ElementBounds.Fixed(EnumDialogArea.RightBottom, 0, 0, 100, 100);
            CairoFont     font       = CairoFont.WhiteSmallText().WithLineHeightMultiplier(1.2);

            SingleComposer = capi.Gui.CreateCompo("inactive", textBounds)
                             .AddDynamicCustomDraw(textBounds.ForkChild(), new DrawDelegateWithBounds(OnDraw), "potioninactive")
                             .AddHoverText("shouldn't see this!", font, 400, textBounds.ForkChild(), "potionstatus")
            ;

            id = capi.World.RegisterGameTickListener(dt => UpdateText(), 100);
        }
Beispiel #10
0
        public GuiDialogRenameTeleport(string DialogTitle, BlockPos blockEntityPos, ICoreClientAPI capi, CairoFont font)
            : base(DialogTitle, capi)
        {
            this.font           = font;
            this.blockEntityPos = blockEntityPos;

            if (blockEntityPos == null || TPNetManager.GetTeleport(blockEntityPos) == null)
            {
                capi.Logger.ModError("Unable to rename an unregistered teleport");
                Dispose();
                return;
            }

            ElementBounds elementBounds  = ElementBounds.Fixed(0.0, 0.0, 150.0, 20.0);
            ElementBounds elementBounds2 = ElementBounds.Fixed(0.0, 15.0, 150.0, 25.0);
            ElementBounds elementBounds3 = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            elementBounds3.BothSizing = ElementSizing.FitToChildren;
            ElementBounds bounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle).WithFixedAlignmentOffset(60.0 + GuiStyle.DialogToScreenPadding, GuiStyle.DialogToScreenPadding);

            float num3 = 250f;

            base.SingleComposer = capi.Gui.CreateCompo("blockentitytexteditordialog", bounds).AddShadedDialogBG(elementBounds3).AddDialogTitleBar(DialogTitle, OnTitleBarClose)
                                  .BeginChildElements(elementBounds3)
                                  .AddTextInput(elementBounds2 = elementBounds2.BelowCopy().WithFixedWidth(num3), null, CairoFont.WhiteSmallText(), "text")
                                  .AddSmallButton(Lang.Get("Cancel"), OnButtonCancel, elementBounds2 = elementBounds2.BelowCopy(0.0, 20.0).WithFixedSize(100.0, 20.0).WithAlignment(EnumDialogArea.LeftFixed)
                                                                                                       .WithFixedPadding(10.0, 2.0))
                                  .AddSmallButton(Lang.Get("Save"), OnButtonSave, elementBounds2 = elementBounds2.FlatCopy().WithFixedSize(100.0, 20.0).WithAlignment(EnumDialogArea.RightFixed)
                                                                                                   .WithFixedPadding(10.0, 2.0))
                                  .EndChildElements()
                                  .Compose();

            base.SingleComposer.GetTextInput("text").SetValue(TPNetManager.GetTeleport(blockEntityPos).Name);
        }
Beispiel #11
0
        private void SetupGui()
        {
            // Stolen from base implementation
            var mainBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterFixed).WithFixedPosition(0.0, 100.0);
            var bkgrBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);
            var listBounds = ElementBounds.Fixed(GuiStyle.ElementToDialogPadding - 2.0, 50.0, 500.0, 580);
            var clipBounds = listBounds.ForkBoundingParent();
            var sideBounds = listBounds.FlatCopy().FixedGrow(6.0).WithFixedOffset(-3.0, -3.0);
            var scrlBounds = sideBounds.CopyOffsetedSibling(3.0 + listBounds.fixedWidth + 7.0).WithFixedWidth(20.0);
            var quitBounds = ElementBounds.FixedSize(0.0, 0.0).FixedUnder(clipBounds, 18.0).WithAlignment(EnumDialogArea.RightFixed).WithFixedPadding(20.0, 4.0).WithFixedAlignmentOffset(2.0, 0.0);

            bkgrBounds.BothSizing = ElementSizing.FitToChildren;
            bkgrBounds.WithChildren(sideBounds, listBounds, scrlBounds, quitBounds);

            // Compose the window
            mainWindow = capi.Gui.CreateCompo("svgTest", mainBounds)
                         .AddShadedDialogBG(bkgrBounds)
                         .AddDialogTitleBar("SVG Sample", OnTitleBarClose)
                         .BeginChildElements(bkgrBounds)
                         .BeginClip(clipBounds)
                         .AddInset(sideBounds, 3)
                         .AddHandbookStackList(listBounds, OnLeftClickListElement, listItems, "stackList")
                         .EndClip()
                         .AddVerticalScrollbar(OnNewScrollbarValueOverviewPage, scrlBounds, "scrollbar")
                         .AddSmallButton(Lang.Get("general-close"), TryClose, quitBounds)
                         .EndChildElements()
                         .Compose();

            mainWindow.GetScrollbar("scrollbar")
            .SetHeights(580, (float)mainWindow.GetHandbookStackList("stackList").insideBounds.fixedHeight);
        }
        public virtual void ComposeEnvGui()
        {
            ElementBounds leftDlgBounds = Composers["playercharacter"].Bounds;
            CairoFont     font          = CairoFont.WhiteSmallText().WithLineHeightMultiplier(1.2);

            string envText  = getEnvText();
            int    cntlines = 1 + Regex.Matches(envText, "\n").Count;
            double height   = font.GetFontExtents().Height *font.LineHeightMultiplier *cntlines / RuntimeEnv.GUIScale;

            ElementBounds textBounds = ElementBounds.Fixed(0, 25, (int)(leftDlgBounds.InnerWidth / RuntimeEnv.GUIScale - 40), height);

            textBounds.Name = "textbounds";

            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.Name       = "bgbounds";
            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(textBounds);

            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.None).WithFixedPosition(leftDlgBounds.renderX / RuntimeEnv.GUIScale, leftDlgBounds.renderY / RuntimeEnv.GUIScale + leftDlgBounds.OuterHeight / RuntimeEnv.GUIScale + 10);

            dialogBounds.Name = "dialogbounds";

            Composers["environment"] = capi.Gui
                                       .CreateCompo("environment", dialogBounds)
                                       .AddShadedDialogBG(bgBounds, true)
                                       .AddDialogTitleBar(Lang.Get("Environment"), () => dlg.OnTitleBarClose())
                                       .BeginChildElements(bgBounds)
                                       .AddDynamicText(envText, font, textBounds, "dyntext")
                                       .EndChildElements()
                                       .Compose()
            ;
        }
Beispiel #13
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();
        }
Beispiel #14
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();
        }
Beispiel #15
0
        public static Image CropImage(Image source, ElementBounds bounds)
        {
            Bitmap   nb = new Bitmap(bounds.Size.Width, bounds.Size.Height);
            Graphics g  = Graphics.FromImage(nb);

            g.DrawImage(source, -bounds.Location.X, -bounds.Location.Y);
            return(nb);
        }
        public GuiElementMap(List <MapLayer> mapLayers, ICoreClientAPI capi, ElementBounds bounds, bool snapToPlayer) : base(capi, bounds)
        {
            this.mapLayers    = mapLayers;
            this.snapToPlayer = snapToPlayer;

            prevPlayerPos.X = api.World.Player.Entity.Pos.X;
            prevPlayerPos.Z = api.World.Player.Entity.Pos.Z;
        }
Beispiel #17
0
        public void Recompose(ICoreClientAPI capi)
        {
            Texture?.Dispose();
            Texture = new TextTextureUtil(capi).GenTextTexture(Stack.GetName(), CairoFont.WhiteSmallText());

            scissorBounds = ElementBounds.FixedSize(50, 50);
            scissorBounds.ParentBounds = capi.Gui.WindowBounds;
        }
Beispiel #18
0
        public static GuiComposer AddFlatList(this GuiComposer composer, ElementBounds bounds, Action <int> onleftClick = null, List <IFlatListItem> stacks = null, string key = null)
        {
            if (!composer.Composed)
            {
                composer.AddInteractiveElement(new GuiElementFlatList(composer.Api, bounds, onleftClick, stacks), key);
            }

            return(composer);
        }
        private void ComposeDialog()
        {
            ElementBounds leftColumn  = ElementBounds.Fixed(0, 28, 120, 25);
            ElementBounds rightColumn = leftColumn.RightCopy();

            ElementBounds buttonRow = ElementBounds.Fixed(0, 28, 360, 25);

            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(leftColumn, rightColumn);

            ElementBounds dialogBounds =
                ElementStdBounds.AutosizedMainDialog
                .WithAlignment(EnumDialogArea.CenterMiddle)
                .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, 0);


            if (SingleComposer != null)
            {
                SingleComposer.Dispose();
            }

            SingleComposer = capi.Gui
                             .CreateCompo("worldmap-addwp", dialogBounds)
                             .AddShadedDialogBG(bgBounds, false)
                             .AddDialogTitleBar(Lang.Get("Add waypoint"), () => TryClose())
                             .BeginChildElements(bgBounds)
                             .AddStaticText(Lang.Get("Name"), CairoFont.WhiteSmallText(), leftColumn = leftColumn.FlatCopy())
                             .AddTextInput(rightColumn = rightColumn.FlatCopy().WithFixedWidth(200), onNameChanged, CairoFont.TextInput(), "nameInput")

                             .AddRichtext(Lang.Get("waypoint-color"), CairoFont.WhiteSmallText(), leftColumn = leftColumn.BelowCopy(0, 5))
                             .AddTextInput(rightColumn = rightColumn.BelowCopy(0, 5).WithFixedWidth(150), onColorChanged, CairoFont.TextInput(), "colorInput")
                             .AddDynamicCustomDraw(rightColumn.FlatCopy().WithFixedWidth(30).WithFixedOffset(160, 0), onDrawColorRect, "colorRect")

                             .AddStaticText(Lang.Get("Icon"), CairoFont.WhiteSmallText(), leftColumn = leftColumn.BelowCopy(0, 9))
                             .AddDropDown(
                new string[] { "circle", "bee", "cave", "home", "ladder", "pick", "rocks", "ruins", "spiral", "star1", "star2", "trader", "vessel" },
                new string[] { "<icon name=\"wpCircle\">", "<icon name=\"wpBee\">", "<icon name=\"wpCave\">", "<icon name=\"wpHome\">", "<icon name=\"wpLadder\">", "<icon name=\"wpPick\">", "<icon name=\"wpRocks\">", "<icon name=\"wpRuins\">", "<icon name=\"wpSpiral\">", "<icon name=\"wpStar1\">", "<icon name=\"wpStar2\">", "<icon name=\"wpTrader\">", "<icon name=\"wpVessel\">" },
                0,
                onIconSelectionChanged,
                rightColumn = rightColumn.BelowCopy(0, 5).WithFixedWidth(60),
                CairoFont.WhiteSmallishText(),
                "iconInput"
                )

                             .AddStaticText(Lang.Get("Pinned"), CairoFont.WhiteSmallText(), leftColumn = leftColumn.BelowCopy(0, 9))
                             .AddSwitch(onPinnedToggled, rightColumn = rightColumn.BelowCopy(0, 5).WithFixedWidth(200), "pinnedSwitch")

                             .AddSmallButton(Lang.Get("Cancel"), onCancel, buttonRow.FlatCopy().FixedUnder(leftColumn, 0).WithFixedWidth(100), EnumButtonStyle.Normal)
                             .AddSmallButton(Lang.Get("Save"), onSave, buttonRow.FlatCopy().FixedUnder(leftColumn, 0).WithFixedWidth(100).WithAlignment(EnumDialogArea.RightFixed), EnumButtonStyle.Normal, key: "saveButton")
                             .EndChildElements()
                             .Compose()
            ;

            SingleComposer.GetButton("saveButton").Enabled = false;
        }
        public GuiDialogLogViewer(string text, ICoreClientAPI capi) : base("Log Viewer", capi)
        {
            ElementBounds topTextBounds = ElementBounds.Fixed(ElementGeometrics.ElementToDialogPadding, 40, 900, 30);

            ElementBounds logtextBounds = ElementBounds.Fixed(0, 0, 900, 300).FixedUnder(topTextBounds, 5);

            // Clipping bounds for textarea
            ElementBounds clippingBounds = logtextBounds.ForkBoundingParent();

            ElementBounds insetBounds = logtextBounds.FlatCopy().FixedGrow(6).WithAddedFixedPosition(-3, -3);

            ElementBounds scrollbarBounds = insetBounds.CopyOffsetedSibling(logtextBounds.fixedWidth + 7).WithFixedWidth(20);

            ElementBounds closeButtonBounds = ElementBounds
                                              .FixedSize(0, 0)
                                              .FixedUnder(clippingBounds, 2 * 5)
                                              .WithAlignment(EnumDialogArea.RightFixed)
                                              .WithFixedPadding(20, 4)
            ;


            // 2. Around all that is 10 pixel padding
            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(ElementGeometrics.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(insetBounds, clippingBounds, scrollbarBounds, closeButtonBounds);

            // 3. Finally Dialog
            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle);


            SingleComposer = capi.Gui
                             .CreateCompo("blockentitytexteditordialog", dialogBounds, false)
                             .AddDialogBG(bgBounds, true)
                             .AddDialogTitleBar(DialogTitle, OnTitleBarClose)
                             .AddStaticText("The following warnings and errors were reported during startup:", CairoFont.WhiteDetailText(), topTextBounds)
                             .BeginChildElements(bgBounds)
                             .BeginClip(clippingBounds)
                             .AddInset(insetBounds, 3)
                             .AddDynamicText("", CairoFont.WhiteDetailText(), EnumTextOrientation.Left, logtextBounds, 1, "text")
                             .EndClip()
                             .AddVerticalScrollbar(OnNewScrollbarvalue, scrollbarBounds, "scrollbar")
                             .AddSmallButton("Close", OnButtonClose, closeButtonBounds)
                             .EndChildElements()
                             .Compose()
            ;

            GuiElementDynamicText logtextElem = SingleComposer.GetDynamicText("text");

            logtextElem.AutoHeight();
            logtextElem.SetNewText(text);

            SingleComposer.GetScrollbar("scrollbar").SetHeights(
                (float)300, (float)logtextBounds.fixedHeight
                );
        }
Beispiel #21
0
        private void onDrawColorRect(Context ctx, ImageSurface surface, ElementBounds currentBounds)
        {
            ctx.Rectangle(0, 0, 25, 25);
            ctx.SetSourceRGBA(ColorUtil.ToRGBADoubles(color));

            ctx.FillPreserve();

            ctx.SetSourceRGBA(GuiStyle.DialogBorderColor);
            ctx.Stroke();
        }
 public GuiElementHandbookListWithTooltips(
     ICoreClientAPI capi,
     ElementBounds bounds,
     Vintagestory.API.Common.Action <int> onLeftClick,
     List <GuiHandbookPage> elements = null
     ) : base(capi, bounds, onLeftClick, elements)
 {
     tooltipProvider = new ItemstackComponentBase(capi);
     dummySlot       = new DummySlot();
 }
        public GuiDialogBlockEntityTextInput(string DialogTitle, BlockPos blockEntityPos, string text, ICoreClientAPI capi, int maxwidth = 130, int maxLines = 4) : base(DialogTitle, capi)
        {
            this.blockEntityPos = blockEntityPos;

            ElementBounds textAreaBounds = ElementBounds.Fixed(0, 0, 300, 150);

            textareaFixedY = textAreaBounds.fixedY;

            // Clipping bounds for textarea
            ElementBounds clippingBounds = textAreaBounds.ForkBoundingParent().WithFixedPosition(0, 30);

            ElementBounds scrollbarBounds = clippingBounds.CopyOffsetedSibling(textAreaBounds.fixedWidth + 3).WithFixedWidth(20);

            ElementBounds cancelButtonBounds = ElementBounds.FixedSize(0, 0).FixedUnder(clippingBounds, 2 * 5).WithAlignment(EnumDialogArea.LeftFixed).WithFixedPadding(10, 2);
            ElementBounds saveButtonBounds   = ElementBounds.FixedSize(0, 0).FixedUnder(clippingBounds, 2 * 5).WithAlignment(EnumDialogArea.RightFixed).WithFixedPadding(10, 2);


            // 2. Around all that is 10 pixel padding
            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(clippingBounds, scrollbarBounds, cancelButtonBounds, saveButtonBounds); //textAreaBounds,

            // 3. Finally Dialog
            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.RightMiddle)
                                         .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, 0);


            SingleComposer = capi.Gui
                             .CreateCompo("blockentitytexteditordialog", dialogBounds)
                             .AddShadedDialogBG(bgBounds)
                             .AddDialogTitleBar(DialogTitle, OnTitleBarClose)
                             .BeginChildElements(bgBounds)
                             .BeginClip(clippingBounds)
                             .AddTextArea(textAreaBounds, OnTextAreaChanged, CairoFont.TextInput().WithFontSize(20), "text")
                             .EndClip()
                             .AddVerticalScrollbar(OnNewScrollbarvalue, scrollbarBounds, "scrollbar")
                             .AddSmallButton(Lang.Get("Cancel"), OnButtonCancel, cancelButtonBounds)
                             .AddSmallButton(Lang.Get("Save"), OnButtonSave, saveButtonBounds)
                             .EndChildElements()
                             .Compose()
            ;

            SingleComposer.GetTextArea("text").SetMaxLines(maxLines);
            SingleComposer.GetTextArea("text").SetMaxWidth((int)(maxwidth * RuntimeEnv.GUIScale));

            SingleComposer.GetScrollbar("scrollbar").SetHeights(
                (float)textAreaBounds.fixedHeight, (float)textAreaBounds.fixedHeight
                );

            if (text.Length > 0)
            {
                SingleComposer.GetTextArea("text").SetValue(text);
            }
        }
Beispiel #24
0
 public GuiElementLuaInput(ICoreClientAPI capi, ElementBounds bounds,
                           Action <GuiElementLuaInput, Lua> OnLuaChanged, Action <GuiElementLuaInput, Lua> OnLuaError, CairoFont font
                           ) : base(capi, font, bounds)
 {
     ClientAPI             = capi;
     LuaState["ClientAPI"] = ClientAPI;
     LuaState["element"]   = this;
     this.OnLuaChanged     = OnLuaChanged;
     this.OnLuaError       = OnLuaError;
     OnTextChanged         = UpdateLua;
 }
Beispiel #25
0
        private void OnDraw(Context ctx, ImageSurface surface, ElementBounds currentBounds)
        {
            BitmapRef bmp = capi.Assets.Get("alchemy:textures/hud/alchemyhud.png").ToBitmap(capi);

            if (inactive)
            {
                bmp.MulAlpha(30);
            }
            Vintagestory.API.Common.SurfaceDrawImage.Image(surface, ((Vintagestory.API.Common.BitmapExternal)bmp), (int)currentBounds.drawX, (int)currentBounds.drawY, (int)currentBounds.InnerWidth, (int)currentBounds.InnerHeight);
            bmp.Dispose();
        }
Beispiel #26
0
 public GuiElementSubtitleList(ICoreClientAPI capi, ElementBounds bounds)
     : base(capi, bounds)
 {
     textTexture = new LoadedTexture(capi);
     Font        = CairoFont.WhiteSmallText();
     textUtil    = new TextDrawUtil();
     for (int i = 0; i < MAX_SOUNDS; i++)
     {
         soundList[i] = new Sound();
     }
 }
        protected void SetupDialog()
        {
            _isSetup = true;

            var dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.RightBottom)
                               .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, -GuiStyle.DialogToScreenPadding);

            const int switchSize    = 20;
            const int switchPadding = 10;
            var       font          = CairoFont.WhiteSmallText();

            var switchBounds = ElementBounds.Fixed(210.0, GuiStyle.TitleBarHeight,
                                                   switchSize, switchSize);

            var textBounds = ElementBounds.Fixed(0, GuiStyle.TitleBarHeight + 1.0,
                                                 200.0, switchSize);

            var advancedButtonBounds = ElementBounds.Fixed(240.0, GuiStyle.TitleBarHeight,
                                                           110.0, switchSize);

            var bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;

            var composer = capi.Gui.CreateCompo("volumetricShadingConfigure", dialogBounds)
                           .AddShadedDialogBG(bgBounds)
                           .AddDialogTitleBar("Volumetric Shading Configuration", OnTitleBarCloseClicked)
                           .BeginChildElements(bgBounds);

            foreach (var option in ConfigOptions)
            {
                composer.AddStaticText(option.Text, font, textBounds);
                if (option.Tooltip != null)
                {
                    composer.AddHoverText(option.Tooltip, font, 250, textBounds.FlatCopy());
                }

                if (option.SwitchKey != null)
                {
                    composer.AddSwitch(option.ToggleAction, switchBounds, option.SwitchKey, switchSize);
                }

                if (option.AdvancedAction != null)
                {
                    composer.AddSmallButton("Advanced...", option.AdvancedAction, advancedButtonBounds);
                }

                switchBounds         = switchBounds.BelowCopy(fixedDeltaY: switchPadding);
                textBounds           = textBounds.BelowCopy(fixedDeltaY: switchPadding);
                advancedButtonBounds = advancedButtonBounds.BelowCopy(fixedDeltaY: switchPadding);
            }

            SingleComposer = composer.EndChildElements().Compose();
        }
Beispiel #28
0
        protected void SetupDialog()
        {
            _isSetup = true;

            var dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.RightBottom)
                               .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, -GuiStyle.DialogToScreenPadding);

            const int    switchSize    = 20;
            const int    switchPadding = 10;
            const double sliderWidth   = 200.0;
            var          font          = CairoFont.WhiteSmallText();

            var switchBounds = ElementBounds.Fixed(250, GuiStyle.TitleBarHeight, switchSize, switchSize);
            var textBounds   = ElementBounds.Fixed(0, GuiStyle.TitleBarHeight + 1.0, 240.0, switchSize);

            var bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;

            var composer = capi.Gui.CreateCompo(DialogKey, dialogBounds)
                           .AddShadedDialogBG(bgBounds)
                           .AddDialogTitleBar(DialogTitle, OnTitleBarCloseClicked)
                           .BeginChildElements(bgBounds);

            foreach (var option in ConfigOptions)
            {
                composer.AddStaticText(option.Text, font, textBounds);
                if (option.Tooltip != null)
                {
                    composer.AddHoverText(option.Tooltip, font, 260, textBounds);
                }

                if (option.SliderKey != null)
                {
                    composer.AddSlider(option.SlideAction, switchBounds.FlatCopy().WithFixedWidth(sliderWidth),
                                       option.SliderKey);
                }
                else if (option.SwitchKey != null)
                {
                    composer.AddSwitch(option.ToggleAction, switchBounds, option.SwitchKey, switchSize);
                }

                textBounds   = textBounds.BelowCopy(fixedDeltaY: switchPadding);
                switchBounds = switchBounds.BelowCopy(fixedDeltaY: switchPadding);
            }

            SingleComposer = composer.EndChildElements().Compose();

            foreach (var option in ConfigOptions.Where(option => option.SliderKey != null && !option.InstantSlider))
            {
                SingleComposer.GetSlider(option.SliderKey).TriggerOnlyOnMouseUp();
            }
        }
        private ElementBounds BoundsForIndex(int index, bool external)
        {
            // Calculate the bounds
            double        width  = SlotSize;
            double        height = SlotSize;
            ElementBounds result = ElementBounds.Fixed(
                RawPosX(index, external) - (width / 2),
                RawPosY(index, external) - (height / 2),
                width,
                height);

            return(result);
        }
        void SetupDialog()
        {
            ItemSlot hoveredSlot = capi.World.Player.InventoryManager.CurrentHoveredSlot;

            if (hoveredSlot != null && hoveredSlot.Inventory == inventory)
            {
                capi.Input.TriggerOnMouseLeaveSlot(hoveredSlot);
            }
            else
            {
                hoveredSlot = null;
            }

            ElementBounds quernBounds = ElementBounds.Fixed(0, 0, 250, 90);

            ElementBounds inputSlotBounds  = ElementStdBounds.SlotGrid(EnumDialogArea.None, 20, 30, 1, 1);
            ElementBounds outputSlotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, 173, 30, 1, 1);

            // 2. Around all that is 10 pixel padding
            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(ElementGeometrics.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(quernBounds);

            // 3. Finally Dialog
            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.RightMiddle)
                                         .WithFixedAlignmentOffset(-ElementGeometrics.DialogToScreenPadding, 0);

            ClearComposers();
            SingleComposer = capi.Gui
                             .CreateCompo("blockentitymillstone", dialogBounds, false)
                             .AddDialogBG(bgBounds)
                             .AddDialogTitleBar(DialogTitle, OnTitleBarClose)
                             .BeginChildElements(bgBounds)
                             .AddDynamicCustomDraw(quernBounds, OnBgDraw, "symbolDrawer")
                             .AddItemSlotGrid(inventory, SendInvPacket, 1, new int[] { 0 }, inputSlotBounds, "inputSlot")
                             .AddItemSlotGrid(inventory, SendInvPacket, 1, new int[] { 1 }, outputSlotBounds, "outputslot")
                             .EndChildElements()
                             .Compose()
            ;

            lastRedrawMs = capi.ElapsedMilliseconds;

            if (hoveredSlot != null)
            {
                SingleComposer.OnMouseMove(capi, new MouseEvent()
                {
                    X = capi.Input.MouseX, Y = capi.Input.MouseY
                });
            }
        }