Exemple #1
0
        /// <summary>
        /// Builds an appropriate tooltip for a PrimaryWork object.
        /// </summary>
        public static string PrimaryTooltip(PrimaryWork primary, bool compareSkillsWindow)
        {
            StringBuilder tooltip = new StringBuilder(primary.def.labelShort);

            tooltip.AppendLine();
            tooltip.AppendLine();
            tooltip.Append(primary.def.description);

            if (!compareSkillsWindow)
            {
                tooltip.Append("DD_WorkTab_Tooltip_Primary".CachedTranslation());
            }

            else
            {
                tooltip.Append("ClickToSortByThisColumn".CachedTranslation());
            }

            return(tooltip.ToString());
        }
Exemple #2
0
        public override void DoWindowContents(Rect inRect)
        {
            this.SetSizeAndPosition();

            List <PrimaryWork> primariesList = Controller.GetPrimaries.PrimaryWorkList;

            //Build rects
            Rect toggleButtonRect = new Rect(inRect.x - this.horizontalOffset, inRect.y + Utilities.TinyTextLineHeight, Utilities.ShortSpacing + Utilities.SpaceForPawnLabel, Utilities.SmallRowHeight);
            Rect primariesRect    = new Rect(toggleButtonRect.xMax, toggleButtonRect.y, inRect.width - toggleButtonRect.width, Utilities.SmallRowHeight);

            Rect scrollViewBox       = new Rect(inRect.x, primariesRect.yMax, inRect.width, inRect.height - Utilities.SmallRowHeight - Utilities.TinyTextLineHeight);
            Rect scrollViewOuterRect = scrollViewBox.ContractedBy(Utilities.ShortSpacing);
            Rect scrollViewInnerRect = new Rect(scrollViewOuterRect.x, scrollViewOuterRect.y, Utilities.SpaceForPawnLabel + Utilities.SmallSurfaceWidth, this.cachedPawnSurfaces.Count * Utilities.SmallRowHeight);

            if (scrollViewInnerRect.width > scrollViewOuterRect.width)
            {
                scrollViewInnerRect.yMax += Utilities.SpaceForScrollBar;
            }

            //Draw window title and list outline
            if (Event.current.type == EventType.Repaint)
            {
                this.DrawWindowTitle(inRect);

                Utilities.BoxOutline(scrollViewBox);
            }

            //Toggle Displayed Pawns button
            if (Widgets.ButtonText(toggleButtonRect.ContractedBy(Utilities.ShortSpacing), this.ToggleButtonText, true, false, true))
            {
                Controller.ColonistSkillsVisibleMap = !Controller.ColonistSkillsVisibleMap;

                this.mustRecacheColonists = true;

                Utilities.UserFeedbackChain(WorkSound.CompareSkillsMapChanged);
            }

            //Draw primaries
            Vector2 positionSetter = new Vector2(primariesRect.x + Utilities.ShortSpacing + Utilities.SmallDraggableDiameter / 2f, primariesRect.center.y);

            for (int i = 0; i < primariesList.Count; i++)
            {
                PrimaryWork primary = primariesList[i];

                this.primariesPositions[primary.def] = positionSetter.x;

                Rect drawRect = positionSetter.ToWorkRect(Utilities.SmallDraggableDiameter);

                if (Event.current.type == EventType.Repaint)
                {
                    primary.DrawTexture(drawRect);

                    if (drawRect.Contains(Event.current.mousePosition))
                    {
                        primary.OnHover(drawRect, true);
                    }

                    //Draw little arrow indicator below work type
                    if (this.sortingOrder != SortOrder.Undefined && this.sortingDef == primary.def)
                    {
                        Texture2D icon          = this.sortingOrder == SortOrder.Descending ? Utilities.SortingDescendingIcon : Utilities.SortingAscendingIcon;
                        Rect      iconRect      = new Rect(drawRect.xMax - icon.width, drawRect.yMax + 1f, icon.width, icon.height);
                        Rect      highlightRect = new Rect(drawRect.xMin - 3f, drawRect.yMin - 3f, drawRect.width + 6f, drawRect.height + 6f);

                        GUI.DrawTexture(iconRect, icon);

                        Widgets.DrawHighlight(highlightRect);
                    }
                }

                else if (Event.current.type == EventType.MouseDown && drawRect.Contains(Event.current.mousePosition))
                {
                    this.DoSortingChecks(primary.def);
                }

                positionSetter.x += Utilities.SmallDraggableDiameter + Utilities.ShortSpacing;
            }

            Widgets.BeginScrollView(scrollViewOuterRect, ref this.scrollPosition, scrollViewInnerRect, true);

            float dynamicVerticalY = scrollViewInnerRect.yMin;

            //Determine which surfaces will actually be seen
            DingoUtils.CacheScrollview(false, this.scrollPosition.y, scrollViewOuterRect.height, Utilities.SmallRowHeight, this.cachedPawnSurfaces.Count, ref dynamicVerticalY, out int firstItem, out int lastItem);

            for (int j = firstItem; j <= lastItem; j++)
            {
                PawnSurface surface = this.cachedPawnSurfaces[j];

                Rect  nameRect           = new Rect(scrollViewInnerRect.x, dynamicVerticalY, Utilities.SpaceForPawnLabel, Utilities.SmallRowHeight);
                Rect  surfaceRect        = new Rect(nameRect.xMax, dynamicVerticalY, Utilities.SmallSurfaceWidth, Utilities.SmallRowHeight);
                float surfaceRectCenterY = surfaceRect.center.y;

                if (Event.current.type == EventType.Repaint)
                {
                    if (j != 0)
                    {
                        Utilities.ListSeparator(scrollViewInnerRect, dynamicVerticalY);
                    }

                    //Draw surface
                    for (int p = 0; p < primariesList.Count; p++)
                    {
                        WorkTypeDef   def               = primariesList[p].def;
                        DraggableWork draggable         = surface.childByDef[def];
                        Vector2       draggablePosition = new Vector2(this.primariesPositions[def], surfaceRectCenterY);
                        Rect          drawRect          = draggablePosition.ToWorkRect(Utilities.SmallDraggableDiameter);

                        draggable.DrawTexture(drawRect);

                        if (drawRect.Contains(Event.current.mousePosition))
                        {
                            draggable.OnHover(drawRect, true);
                        }
                    }
                }

                Utilities.PawnLabel(nameRect, surface.pawn);

                dynamicVerticalY += Utilities.SmallRowHeight;
            }

            Widgets.EndScrollView();
        }