private static Color AssignmentColor(StatPriority statPriority)
 {
     return(statPriority.IsManual ? Color.white :
            statPriority.IsDefault?Color.grey:
            statPriority.IsOverride ? new Color(0.75f, 0.69f, 0.33f) : Color.cyan);
 }
コード例 #2
0
        public static void DrawStatRow( ref Vector2 cur, float width, StatPriority stat, Pawn pawn, out bool stop_ui )
        {
            // sent a signal if the statlist has changed
            stop_ui = false;

            // set up rects
            Rect labelRect = new Rect( cur.x, cur.y, (width - 24) / 2f, 30f );
            Rect sliderRect = new Rect( labelRect.xMax + 4f, cur.y + 5f, labelRect.width, 25f );
            Rect buttonRect = new Rect( sliderRect.xMax + 4f, cur.y + 3f, 16f, 16f );

            // draw label
            Text.Font = Text.CalcHeight( stat.Stat.LabelCap, labelRect.width ) > labelRect.height
                ? GameFont.Tiny
                : GameFont.Small;
            Widgets.Label( labelRect, stat.Stat.LabelCap );
            Text.Font = GameFont.Small;

            // draw button
            // if manually added, delete the priority
            string buttonTooltip = String.Empty;
            if ( stat.Assignment == StatAssignment.Manual )
            {
                buttonTooltip = "StatPriorityDelete".Translate( stat.Stat.LabelCap );
                if( Widgets.ImageButton( buttonRect, ITab_Pawn_Outfitter.deleteButton ) )
                {
                    stat.Delete( pawn );
                    stop_ui = true;
                }
            }
            // if overridden auto assignment, reset to auto
            if ( stat.Assignment == StatAssignment.Override )
            {
                buttonTooltip = "StatPriorityReset".Translate( stat.Stat.LabelCap );
                if ( Widgets.ImageButton( buttonRect, ITab_Pawn_Outfitter.resetButton ) )
                {
                    stat.Reset( pawn );
                    stop_ui = true;
                }
            }

            // draw line behind slider
            GUI.color = new Color( .3f, .3f, .3f );
            for ( int y = (int)cur.y; y < cur.y + 30; y += 5 )
            {
                Widgets.DrawLineVertical( ( sliderRect.xMin + sliderRect.xMax ) / 2f, y, 3f );
            }

            // draw slider 
            GUI.color = stat.Assignment == StatAssignment.Automatic ? Color.grey : Color.white;
            float weight = GUI.HorizontalSlider( sliderRect, stat.Weight, - 10f, 10f );
            if ( Mathf.Abs( weight - stat.Weight ) > 1e-4 )
            {
                stat.Weight = weight;
                if ( stat.Assignment == StatAssignment.Automatic )
                {
                    stat.Assignment = StatAssignment.Override;
                }
            }
            GUI.color = Color.white;

            // tooltips
            TooltipHandler.TipRegion( labelRect, stat.Stat.LabelCap + "\n\n" + stat.Stat.description );
            if (buttonTooltip != String.Empty)
                TooltipHandler.TipRegion( buttonRect, buttonTooltip );
            TooltipHandler.TipRegion( sliderRect, stat.Weight.ToStringByStyle( ToStringStyle.FloatTwo ) );

            // advance row
            cur.y += 30f;
        }
        private static void DrawStatRow(ExtendedOutfit selectedOutfit, StatPriority statPriority, ref Vector2 cur,
                                        float width)
        {
            // set up rects
            var labelRect  = new Rect(cur.x, cur.y, (width - 24) / 2f, 30f);
            var sliderRect = new Rect(labelRect.xMax + 4f, cur.y + 5f, labelRect.width, 25f);
            var buttonRect = new Rect(sliderRect.xMax + 4f, cur.y + 3f, 16f, 16f);

            // draw label
            Text.Font = Text.CalcHeight(statPriority.Stat.LabelCap, labelRect.width) > labelRect.height
                ? GameFont.Tiny
                : GameFont.Small;
            GUI.color = AssignmentColor(statPriority);
            Verse.Widgets.Label(labelRect, statPriority.Stat.LabelCap);
            Text.Font = GameFont.Small;

            // draw button
            // if manually added, delete the priority
            var buttonTooltip = string.Empty;

            if (statPriority.IsManual)
            {
                buttonTooltip = ResourceBank.Strings.StatPriorityDelete(statPriority.Stat.LabelCap);
                if (Verse.Widgets.ButtonImage(buttonRect, ResourceBank.Textures.DeleteButton))
                {
                    selectedOutfit.RemoveStatPriority(statPriority.Stat);
                }
            }
            // if overridden auto assignment, reset to auto
            else if (statPriority.IsOverride)
            {
                buttonTooltip = ResourceBank.Strings.StatPriorityReset(statPriority.Stat.LabelCap);
                if (Verse.Widgets.ButtonImage(buttonRect, ResourceBank.Textures.ResetButton))
                {
                    statPriority.Weight = statPriority.Default;
                }
            }

            // draw line behind slider
            GUI.color = new Color(.3f, .3f, .3f);
            for (var y = (int)cur.y; y < cur.y + 30; y += 5)
            {
                Verse.Widgets.DrawLineVertical((sliderRect.xMin + sliderRect.xMax) / 2f, y, 3f);
            }

            // draw slider
            GUI.color = AssignmentColor(statPriority);
            var weight = GUI.HorizontalSlider(sliderRect, statPriority.Weight, -DefaultWorkTypePriorities.MaxStatWeight,
                                              DefaultWorkTypePriorities.MaxStatWeight);

            if (Mathf.Abs(weight - statPriority.Weight) > 1e-4)
            {
                statPriority.Weight = weight;
            }
            GUI.color = Color.white;
            // tooltips
            TooltipHandler.TipRegion(labelRect, statPriority.Stat.LabelCap + "\n\n" + statPriority.Stat.description);
            if (!string.IsNullOrEmpty(buttonTooltip))
            {
                TooltipHandler.TipRegion(buttonRect, buttonTooltip);
            }
            TooltipHandler.TipRegion(sliderRect, statPriority.Weight.ToStringByStyle(ToStringStyle.FloatTwo));

            // advance row
            cur.y += 30f;
        }