示例#1
0
        public void CenterPointsTo(CenterMode mode)
        {
            float3 center = Vector3.zero;

            switch (mode)
            {
            case CenterMode.Bounds:
                Vector3 min = Vector3.one * Mathf.Infinity;
                Vector3 max = Vector3.one * Mathf.NegativeInfinity;
                foreach (Vector3 point in points)
                {
                    min = Vector3.Min(min, point);
                    max = Vector3.Max(max, point);
                }
                center = min + (max - min) * 0.5f;
                break;

            case CenterMode.Average:
                center = Vector3.zero;
                foreach (float3 point in points)
                {
                    center += point;
                }
                center /= points.Length;
                break;
            }

            for (int i = 0; i < points.Length; i++)
            {
                points[i] -= center;
            }
        }
示例#2
0
        public void FadeInOut(GameObject parent, int duration = 1400, OnTransition onTransition = null,
                              OnFinished onFinished           = null, CenterMode centerMode = CenterMode.Min)
        {
            parent.AddChild(this);

            if (centerMode == CenterMode.Center)
            {
                SetXY(-width * 0.5f, -height * 0.5f);
            }
            else
            {
                SetXY(0, 0);
            }

            SetActive(true);

            SpriteTweener.TweenAlpha(this, 0, 1, duration / 2, o =>
            {
                onTransition?.Invoke();

                SpriteTweener.TweenAlpha(this, 1, 0, duration / 2, go =>
                {
                    onFinished?.Invoke();

                    SetActive(false);

                    this.parent.RemoveChild(this);
                });
            });

            //CoroutineManager.StartCoroutine(instance.FadeInOutRoutine(time, onFinished));
        }
示例#3
0
        /// <summary>
        /// Center a control on its parent
        /// </summary>
        /// <param name="control">The control to center</param>
        /// <param name="mode">The mode to center, vertically, horizontally or both</param>
        public static void Center(this Control control, CenterMode mode = CenterMode.Both)
        {
            int x;
            int y;

            switch (mode)
            {
            case CenterMode.Horizontal:
                y = control.Location.Y;
                x = (control.Parent.ClientSize.Width - control.Width) / 2;
                break;

            case CenterMode.Verical:
                x = control.Location.X;
                y = (control.Parent.ClientSize.Height - control.Height) / 2;
                break;

            default:
                x = (control.Parent.ClientSize.Width - control.Width) / 2;
                y = (control.Parent.ClientSize.Height - control.Height) / 2;
                break;
            }

            control.Location = new System.Drawing.Point(x, y);
        }
示例#4
0
        /// <summary>
        /// Center a control on its parent
        /// </summary>
        /// <param name="control">The control to center</param>
        /// <param name="mode">The mode to center, vertically, horizontally or both</param>
        public static void Center(this Control control, CenterMode mode = CenterMode.Both)
        {
            int x;
            int y;

            switch (mode)
            {
                case CenterMode.Horizontal:
                    y = control.Location.Y;
                    x = (control.Parent.ClientSize.Width - control.Width) / 2;
                    break;

                case CenterMode.Verical:
                    x = control.Location.X;
                    y = (control.Parent.ClientSize.Height - control.Height) / 2;
                    break;

                default:
                    x = (control.Parent.ClientSize.Width - control.Width) / 2;
                    y = (control.Parent.ClientSize.Height - control.Height) / 2;
                    break;
            }

            control.Location = new System.Drawing.Point(x, y);
        }
        public DebugTextBox(string pText, int pWidth, int pHeight, uint textColor = 0xffffffff, uint bgColor = 0xff000000, CenterMode hor = CenterMode.Min, CenterMode ver = CenterMode.Center, bool addCollider = false) : base(pWidth, pHeight, addCollider)
        {
            _bgColor   = Color.FromArgb((int)bgColor);
            _color     = Color.FromArgb((int)textColor);
            _textValue = pText;

            _horAlign = hor;
            _verAlign = ver;
        }
示例#6
0
        public HudTextBoard(string pText, float px, float py, int width, int height, int textSize,
                            CenterMode hor = CenterMode.Min,
                            CenterMode ver = CenterMode.Min)
        {
            this.x     = px;
            this.y     = py;
            this._text = pText;

            _easyDraw = new EasyDraw(width, height, false);
            _easyDraw.TextFont("data/Gaiatype.ttf", 12);

            if (!string.IsNullOrEmpty(pText))
            {
                _easyDraw.TextSize(textSize);
                _easyDraw.TextDimensions(_text, out var w, out var h);
                var wr = Mathf.Round(w);
                var hr = Mathf.Round(h);

                if (wr <= 0)
                {
                    wr = 10;
                }

                if (hr <= 0)
                {
                    hr = 10;
                }

                _easyDraw = new EasyDraw(wr, hr, false);
            }
            _easyDraw.TextFont("data/Gaiatype.ttf", 12);
            _easyDraw.TextSize(textSize);
            _easyDraw.TextAlign(hor, ver);

            AddChild(_easyDraw);

            if (hor == CenterMode.Center)
            {
                _textX = _easyDraw.width * 0.5f;
            }
            else if (hor == CenterMode.Max)
            {
                _textX = _easyDraw.width;
            }

            if (ver == CenterMode.Center)
            {
                _textY = _easyDraw.height * 0.5f;
            }
            else if (ver == CenterMode.Max)
            {
                _textY = _easyDraw.height;
            }


            SetText(_text);
        }
 /// <summary>
 /// Get utility window instance and create if not already shown.
 /// </summary>
 /// <typeparam name="T">Type of <see cref="RotorzWindow"/> to get.</typeparam>
 /// <param name="title">Title text for window.</param>
 /// <param name="focus">Indicates whether window should be focused.</param>
 /// <returns>
 /// The <see cref="RotorzWindow"/> instance.
 /// </returns>
 internal static T GetUtilityWindow <T>(string title, bool focus) where T : RotorzWindow
 {
     try {
         s_ShouldAssignCenterOnEnable = true;
         s_AssignCenterOnEnable       = RtsPreferences.AlwaysCenterUtilityWindows
             ? CenterMode.Always
             : CenterMode.Once;
         return(GetWindow <T>(true, title, focus));
     }
     finally {
         s_ShouldAssignCenterOnEnable = false;
     }
 }
示例#8
0
 public HudTextBoard(string pText, int px, int py, int textSize, CenterMode hor = CenterMode.Min,
                     CenterMode ver = CenterMode.Min) : this(pText, px, py, 10, 10, textSize, hor,
                                                             ver)
 {
 }
示例#9
0
 public HudTextBoard(int width, int height, int textSize, CenterMode hor = CenterMode.Min,
                     CenterMode ver = CenterMode.Min) : this("", 0, 0, width, height, textSize, hor,
                                                             ver)
 {
 }
示例#10
0
 public void ShapeAlign(CenterMode horizontal, CenterMode vertical)
 {
     HorizontalShapeAlign = horizontal;
     VerticalShapeAlign   = vertical;
 }
示例#11
0
        //////////// Setting Alignment for text, ellipses and rects

        public void TextAlign(CenterMode horizontal, CenterMode vertical)
        {
            HorizontalTextAlign = horizontal;
            VerticalTextAlign   = vertical;
        }
 public InputDescription(string name, string parameter, CenterMode centerMode)
 {
     Name             = name;
     CurrentParameter = parameter;
     CenterMode       = centerMode;
 }