예제 #1
0
 /// <summary>
 /// Quick method to create a new ElementBounds instance that uses fixed element sizing. The X/Y Coordinates are left at 0.
 /// </summary>
 /// <param name="alignment"></param>
 /// <param name="fixedWidth"></param>
 /// <param name="fixedHeight"></param>
 /// <returns></returns>
 public static ElementBounds FixedSize(EnumDialogArea alignment, double fixedWidth, double fixedHeight)
 {
     return(new ElementBounds()
     {
         Alignment = alignment, fixedWidth = fixedWidth, fixedHeight = fixedHeight, BothSizing = ElementSizing.Fixed
     });
 }
예제 #2
0
 public static ElementBounds FixedPos(EnumDialogArea alignment, double fixedX, double fixedY)
 {
     return(new ElementBounds()
     {
         Alignment = alignment, BothSizing = ElementSizing.Fixed, fixedX = fixedX, fixedY = fixedY
     });
 }
 public static ElementBounds StatbarBounds(EnumDialogArea alignment, double width)
 {
     return(new ElementBounds()
     {
         Alignment = alignment,
         fixedWidth = width,
         fixedHeight = GuiElementStatbar.DefaultHeight,
         BothSizing = ElementSizing.Fixed
     });
 }
예제 #4
0
 /// <summary>
 /// Quick method to create new ElementsBounds instance that uses percentual element sizing, e.g. setting percentWidth to 0.5 will set the width of the bounds to 50% of its parent width
 /// </summary>
 /// <param name="alignment"></param>
 /// <param name="percentWidth"></param>
 /// <param name="percentHeight"></param>
 /// <returns></returns>
 public static ElementBounds Percentual(EnumDialogArea alignment, double percentWidth, double percentHeight)
 {
     return(new ElementBounds()
     {
         Alignment = alignment,
         percentWidth = percentWidth,
         percentHeight = percentHeight,
         BothSizing = ElementSizing.Percentual
     });
 }
예제 #5
0
 /// <summary>
 /// Quick Method to create a new ElementBounds instance to create a menu consiting of one ore more vertically arranged and horizontally centered buttons in a grid. The y position is calculated using rowIndex * 80.
 /// </summary>
 /// <param name="rowIndex"></param>
 /// <param name="alignment"></param>
 /// <returns></returns>
 public static ElementBounds MenuButton(float rowIndex, EnumDialogArea alignment = EnumDialogArea.CenterFixed)
 {
     return(new ElementBounds()
     {
         Alignment = alignment,
         BothSizing = ElementSizing.Fixed,
         fixedY = 80 * rowIndex,
         fixedPaddingX = 2,
         fixedPaddingY = 2
     });
 }
예제 #6
0
 /// <summary>
 /// Quick Method to create a new ElementBounds instance to create a menu consiting of one ore more vertically arranged and horizontally centered buttons in a grid. The y position is calculated using rowIndex * 80.
 /// </summary>
 /// <param name="rowIndex"></param>
 /// <param name="padding"></param>
 /// <param name="alignment"></param>
 /// <returns></returns>
 public static ElementBounds Rowed(float rowIndex, double padding, EnumDialogArea alignment = EnumDialogArea.None)
 {
     return(new ElementBounds()
     {
         Alignment = alignment,
         BothSizing = ElementSizing.Fixed,
         fixedY = 70 * rowIndex,
         fixedPaddingX = padding,
         fixedPaddingY = padding
     });
 }
예제 #7
0
 public static ElementBounds SlotGrid(EnumDialogArea alignment, double x, double y, int cols, int rows)
 {
     return(new ElementBounds()
     {
         Alignment = alignment,
         BothSizing = ElementSizing.Fixed,
         fixedX = x,
         fixedY = y,
         fixedWidth = cols * (GuiElementPassiveItemSlot.unscaledSlotSize + GuiElementItemSlotGrid.unscaledSlotPadding),
         fixedHeight = rows * (GuiElementPassiveItemSlot.unscaledSlotSize + GuiElementItemSlotGrid.unscaledSlotPadding)
     });
 }
예제 #8
0
        void buildBoundsFromChildren()
        {
            if (ChildBounds == null || ChildBounds.Count == 0)
            {
                throw new Exception("Cant build bounds from children elements, there are no children!");
            }

            double width  = 0;
            double height = 0;

            foreach (ElementBounds bounds in ChildBounds)
            {
                if (bounds == this)
                {
                    throw new Exception("Endless loop detected. Bounds instance is contained itself in its ChildBounds List. Fix your code please :P");
                }

                // Alignment can only happen once the max size is known, so ignore it for now
                EnumDialogArea prevAlign = bounds.Alignment;
                bounds.Alignment = EnumDialogArea.None;

                bounds.CalcWorldBounds();

                if (bounds.horizontalSizing != ElementSizing.Percentual)
                {
                    width = Math.Max(width, bounds.OuterWidth + bounds.relX);
                }
                if (bounds.verticalSizing != ElementSizing.Percentual)
                {
                    height = Math.Max(height, bounds.OuterHeight + bounds.relY);
                }

                // Reassign actual alignment, now as we can calculate the alignment
                bounds.Alignment = prevAlign;
            }

            if (width == 0 || height == 0)
            {
                throw new Exception("Couldn't build bounds from children, there were probably no child elements using fixed sizing! (or they were size 0)");
            }

            if (horizontalSizing != ElementSizing.Fixed)
            {
                this.absInnerWidth = width;
            }

            if (verticalSizing != ElementSizing.Fixed)
            {
                this.absInnerHeight = height;
            }
        }
예제 #9
0
 /// <summary>
 /// Reads the content to the dialog.
 /// </summary>
 /// <param name="reader">The reader to read from.</param>
 public void FromBytes(BinaryReader reader)
 {
     Code      = reader.ReadString();
     Alignment = (EnumDialogArea)reader.ReadInt32();
     PosX      = reader.ReadSingle();
     PosY      = reader.ReadSingle();
     Rows      = new DialogRow[reader.ReadInt32()];
     for (int i = 0; i < Rows.Length; i++)
     {
         Rows[i] = new DialogRow();
         Rows[i].FromBytes(reader);
     }
     SizeMultiplier = reader.ReadSingle();
 }
예제 #10
0
 public ElementBounds WithAlignment(EnumDialogArea alignment)
 {
     this.Alignment = alignment;
     return(this);
 }