Esempio n. 1
0
 /// <summary>
 /// Adds a vertex to the mesh data.
 /// </summary>
 /// <param name="model">The mesh data.</param>
 /// <param name="x">X position of the vertex.</param>
 /// <param name="y">Y position of the vertex.</param>
 /// <param name="z">Z position of the vertex.</param>
 /// <param name="color">The color of the vertex.</param>
 public static void AddVertex(MeshData model, float x, float y, float z, int color)
 {
     model.xyz[model.XyzCount + 0]   = x;
     model.xyz[model.XyzCount + 1]   = y;
     model.xyz[model.XyzCount + 2]   = z;
     model.Rgba[model.RgbaCount + 0] = (byte)(ColorUtil.ColorR(color));
     model.Rgba[model.RgbaCount + 1] = (byte)(ColorUtil.ColorG(color));
     model.Rgba[model.RgbaCount + 2] = (byte)(ColorUtil.ColorB(color));
     model.Rgba[model.RgbaCount + 3] = (byte)(ColorUtil.ColorA(color));
     model.VerticesCount++;
 }
Esempio n. 2
0
        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();
            }

            string[] names = new string[] { "circle", "bee", "cave", "home", "ladder", "pick", "rocks", "ruins", "spiral", "star1", "star2", "trader", "vessel" };
            int      index = names.IndexOf(waypoint.Icon);

            if (index < 0)
            {
                index = 0;
            }

            SingleComposer = capi.Gui
                             .CreateCompo("worldmap-modwp", dialogBounds)
                             .AddShadedDialogBG(bgBounds, false)
                             .AddDialogTitleBar("Modify waypoint", () => TryClose())
                             .BeginChildElements(bgBounds)
                             .AddRichtext("Color (<a href=\"https://www.99colors.net/dot-net-colors\">List</a>)", CairoFont.WhiteSmallText(), leftColumn = leftColumn.FlatCopy())
                             .AddTextInput(rightColumn = rightColumn.FlatCopy().WithFixedWidth(150), onColorChanged, CairoFont.TextInput(), "colorInput")
                             .AddDynamicCustomDraw(rightColumn.FlatCopy().WithFixedWidth(30).WithFixedOffset(160, 0), onDrawColorRect, "colorRect")
                             .AddStaticText("Name", CairoFont.WhiteSmallText(), leftColumn = leftColumn.BelowCopy(0, 5))
                             .AddTextInput(rightColumn = rightColumn.BelowCopy(0, 5).WithFixedWidth(200), onNameChanged, CairoFont.TextInput(), "nameInput")

                             .AddStaticText("Icon", CairoFont.WhiteSmallText(), leftColumn = leftColumn.BelowCopy(0, 5))
                             .AddDropDown(
                names,
                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\">" },
                index,
                onIconSelectionChanged,
                rightColumn = rightColumn.BelowCopy(0, 5).WithFixedWidth(60),
                CairoFont.WhiteSmallishText(),
                "iconInput"
                )

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


            var col = System.Drawing.Color.FromArgb(0, ColorUtil.ColorR(waypoint.Color), ColorUtil.ColorG(waypoint.Color), ColorUtil.ColorB(waypoint.Color));

            if (col.IsKnownColor)
            {
                SingleComposer.GetTextInput("colorInput").SetValue(col.ToKnownColor().ToString().ToLowerInvariant());
            }
            else
            {
                SingleComposer.GetTextInput("colorInput").SetValue(ColorUtil.Int2Hex(waypoint.Color));
            }

            SingleComposer.GetTextInput("nameInput").SetValue(waypoint.Title);
        }