コード例 #1
0
        private void OnNewScrollbarvalue(float value)
        {
            GuiElementTextArea textArea = SingleComposer.GetTextArea("text");

            textArea.Bounds.fixedY = 3 + textareaFixedY - value;
            textArea.Bounds.CalcWorldBounds();
        }
コード例 #2
0
        private void ComposeDialog()
        {
            int height        = 200;
            int tableWidth    = 150;
            int textAreaWidth = 200;
            int headerHeight  = 20;
            int labelWidth    = 60;

            var spacer = ElementStdBounds
                         .TitleBar();

            var tableBounds = Fixed(0, 0, tableWidth, height);

            var labelBounds = Fixed(0, 0, labelWidth, headerHeight);

            var nameInputBounds = Fixed(labelWidth, 0, textAreaWidth - labelWidth, headerHeight);

            var headerBounds = Fixed(0, 0, textAreaWidth, headerHeight)
                               .WithChildren(labelBounds, nameInputBounds);

            var textAreaBounds = Fixed(0, 0, textAreaWidth, height)
                                 .FixedUnder(headerBounds, HalfPadding);

            var textContainerBounds = Fill
                                      .WithSizing(ElementSizing.FitToChildren)
                                      .FixedRightOf(tableBounds, HalfPadding)
                                      .WithChildren(textAreaBounds, headerBounds);

            var bodyBounds = Fill
                             .WithSizing(ElementSizing.FitToChildren)
                             .FixedUnder(spacer)
                             .WithChildren(textContainerBounds, tableBounds);

            var bgBounds = Fill
                           .WithFixedPadding(ElementToDialogPadding)
                           .WithChildren(bodyBounds)
                           .WithSizing(ElementSizing.FitToChildren);

            var dialogBounds = ElementStdBounds
                               .AutosizedMainDialog
                               .WithAlignment(EnumDialogArea.CenterMiddle);

            SingleComposer = capi.Gui.CreateCompo("aliaseditor", dialogBounds)
                             .AddShadedDialogBG(bgBounds)
                             .AddDialogTitleBar("Alias Editor", () => TryClose())
                             .AddStaticText("Alias:", CairoFont.WhiteSmallishText(), labelBounds)
                             .AddTextInput(nameInputBounds, OnAliasNameChanged, CairoFont.TextInput(), "aliastextinput")
                             .AddTextArea(textAreaBounds, OnAliasTextChanged, CairoFont.TextInput(), "aliastextarea")
                             .AddCellList(tableBounds,
                                          (cell, elBounds) => new GuiElementCell(capi, cell, elBounds)
            {
                ShowModifyIcons = false
            },
                                          OnMouseDownOnCell, OnMouseDownOnCell,
                                          cellList, "aliascellarea")
                             .Compose();
            textArea         = SingleComposer.GetTextArea("aliastextarea");
            textArea.Enabled = false;
            textInput        = SingleComposer.GetTextInput("aliastextinput");
        }
コード例 #3
0
        private void OnNewCmdScrollbarvalue(float value)
        {
            GuiElementTextArea textArea = SingleComposer.GetTextArea("commands");

            textArea.Bounds.fixedY = 1 - value;
            textArea.Bounds.CalcWorldBounds();
        }
コード例 #4
0
        private void OnTextAreaChanged(string value)
        {
            GuiElementTextArea textArea = SingleComposer.GetTextArea("text");

            SingleComposer.GetScrollbar("scrollbar").SetNewTotalHeight((float)textArea.Bounds.fixedHeight);

            OnTextChanged?.Invoke(textArea.GetText());
        }
コード例 #5
0
        private bool OnButtonSave()
        {
            GuiElementTextArea textArea = SingleComposer.GetTextArea("text");

            byte[] data;

            using (MemoryStream ms = new MemoryStream())
            {
                BinaryWriter writer = new BinaryWriter(ms);
                writer.Write(textArea.GetText());
                data = ms.ToArray();
            }

            capi.Network.SendBlockEntityPacket(blockEntityPos.X, blockEntityPos.Y, blockEntityPos.Z, (int)EnumSignPacketId.SaveText, data);
            didSave = true;
            TryClose();
            return(true);
        }