Exemple #1
0
        public override void DoWindowContents(Rect _rect)
        {
            string str;
            float  floTopY = _rect.y;
            float  floInnerTopY;

            if (!title.NullOrEmpty())
            {
                Text.Font = GameFont.Medium;
                Widgets.Label(new Rect(0f, floTopY, _rect.width, 42f), title);
                floInnerTopY = floTopY + 42f;
            }
            else
            {
                floInnerTopY = floTopY;
            }

            Text.Font = GameFont.Small;

            Rect innerRect = new Rect(_rect.x, floInnerTopY, _rect.width, _rect.height);

            float floInnerContentWidth  = innerRect.width - 16f;
            float floInnerContentHeight = innerRect.height - 35f;

            GUI.color = baseColor;

            Vector2 vector2       = Vector2.zero;
            float   maxViewHeight = MaxViewHeight;
            float   columnWidth   = ColumnWidth;

            Widgets.BeginScrollView(innerRect, ref scrollPosition, new Rect(0f, 0f, floInnerContentWidth, floInnerContentHeight), true);

            IEnumerator <FloatMenuOption> enumerator = (
                from op in options
                orderby op.Priority descending
                select op).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    FloatMenuOption current        = enumerator.Current;
                    float           requiredHeight = current.RequiredHeight;
                    if (vector2.y + requiredHeight + -1f > maxViewHeight)
                    {
                        vector2.y = 0f;
                        vector2.x = vector2.x + (columnWidth + -1f);
                    }
                    Rect rect1 = new Rect(vector2.x, vector2.y, columnWidth, requiredHeight);
                    vector2.y = vector2.y + (requiredHeight + -1f);
                    if (!current.DoGUI(rect1, givesColonistOrders))
                    {
                        continue;
                    }
                    Find.WindowStack.TryRemove(this, true);
                    break;
                }
            }
            finally
            {
                if (enumerator == null)
                {
                }
                enumerator.Dispose();
            }

            Widgets.EndScrollView();

            if (Event.current.type == EventType.MouseDown)
            {
                Event.current.Use();
            }
            GUI.color = Color.white;

            if (buttonADestructive)
            {
                GUI.color = new Color(1f, 0.3f, 0.35f);
            }
            if (!InteractionDelayExpired)
            {
                string str1    = buttonAText;
                float  single2 = Mathf.Ceil(TimeUntilInteractive);
                str = string.Concat(str1, "(", single2.ToString("F0"), ")");
            }
            else
            {
                str = buttonAText;
            }
            string str2    = str;
            float  single3 = _rect.width / 2f - 20f;

            if (Widgets.ButtonText(new Rect(_rect.width / 2f + 20f, _rect.height - 35f, single3, 35f), str2, true, false, true) /*&& InteractionDelayExpired*/)
            {
                if (buttonAAction != null)
                {
                    buttonAAction();
                }
                Close(true);
            }
            GUI.color = Color.white;
            if (this.buttonBText != null && Widgets.ButtonText(new Rect(0f, _rect.height - 35f, single3, 35f), this.buttonBText, true, false, true))
            {
                if (buttonBAction != null)
                {
                    buttonBAction();
                }
                Close(true);
            }
        }