예제 #1
0
    public static bool TabIconSelectable(Rect rect, string iconName, string toolTip = null, bool selected = false,
                                         bool selectable = true)
    {
        if (TabSorting.iconsCache == null || !TabSorting.iconsCache.ContainsKey("wrongsign"))
        {
            return(false);
        }

        var currentIconName = iconName;

        if (TabSorting.iconsCache?.ContainsKey(iconName) == false)
        {
            currentIconName = "wrongsign";
        }

        GUI.DrawTexture(rect.ContractedBy((rect.width - TabSortingMod.tabIconSize.x) / 2),
                        TabSorting.iconsCache?[currentIconName]);

        if (!selectable)
        {
            return(false);
        }

        if (string.IsNullOrEmpty(toolTip))
        {
            toolTip = iconName;
        }

        TooltipHandler.TipRegion(rect, toolTip);

        if (Mouse.IsOver(rect))
        {
            Widgets.DrawBoxSolidWithOutline(rect, new Color(0.1f, 0.1f, 0.1f, 0.0f),
                                            new Color(1f, 1f, 1f, 0.3f));
        }
        else
        {
            if (selected)
            {
                Widgets.DrawBoxSolidWithOutline(rect, new Color(0.1f, 0.1f, 0.1f, 0.0f),
                                                new Color(0.3f, 0.8f, 0.3f, 0.3f));
            }
        }

        if (!Widgets.ButtonInvisible(rect))
        {
            return(false);
        }

        SoundDefOf.Click.PlayOneShotOnCamera();
        return(true);
    }
예제 #2
0
            public void Finish(Rect rect, bool isPanel = false)
            {
                _average = (int)(_average == 0 ? _stopwatch.ElapsedMilliseconds : (_average + _stopwatch.ElapsedMilliseconds) / 2);
                if (_stopwatch.ElapsedMilliseconds > _max)
                {
                    _max = _stopwatch.ElapsedMilliseconds;
                }

                if (isPanel)
                {
                    GUIPlus.DrawText(rect, $"[[Max={_max},Avg={_average},Now={_stopwatch.ElapsedMilliseconds} ms]", Color.cyan, Theme.RegularTextStyle, TextAnchor.MiddleCenter);
                }
                else
                {
                    Widgets.DrawBoxSolidWithOutline(rect, ColorBackground, ColorForeground);
                    GUIPlus.DrawText(rect, $"[M={_max},A={_average},N={_stopwatch.ElapsedMilliseconds}]", Color.yellow, MiniTextStyle, TextAnchor.MiddleCenter);
                }
            }
예제 #3
0
        public override void DoWindowContents(Rect rect)
        {
            base.DoWindowContents(rect);
            Text.Font = GameFont.Small;
            var colorPickerPos = new Vector2(this.windowRect.x + 60, this.windowRect.y + 195);

            Vector2 leftHalf = new Vector2(rect.x + checkBoxesWidth, rect.y + 25f);

            var showAllColonistsRect = new Rect(rect.x + 10, leftHalf.y, Textures.MenuButton.width, 25f);

            GUI.DrawTexture(showAllColonistsRect, Textures.MenuButton);
            if (Mouse.IsOver(showAllColonistsRect))
            {
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticUtils.ShowAllColonists();
                    Event.current.Use();
                }
            }
            Widgets.Label(new Rect(rect.x + 20, leftHalf.y, textFieldWidth, 25f), Strings.ShowAllColonists);
            leftHalf.y += 25f;
            Widgets.Checkbox(leftHalf, ref TacticalGroupsSettings.HidePawnsWhenOffMap);
            Widgets.Label(new Rect(rect.x + 20, leftHalf.y, textFieldWidth, 25f), Strings.HidePawnsWhenOffMap);

            leftHalf.y += 25f;
            Widgets.Checkbox(leftHalf, ref TacticalGroupsSettings.HideGroups);
            Widgets.Label(new Rect(rect.x + 20, leftHalf.y, textFieldWidth, 25f), Strings.HideGroups);

            leftHalf.y += 45f;
            Widgets.Checkbox(leftHalf, ref TacticalGroupsSettings.DisplayFood);
            Widgets.Label(new Rect(rect.x + 20, leftHalf.y, textFieldWidth, 25f), Strings.DisplayFood);

            var displayFoodColor = new Rect(leftHalf.x - 24, leftHalf.y + 5, 12, 12);

            Widgets.DrawBoxSolidWithOutline(displayFoodColor, TacticalGroupsSettings.NeedFoodBarColor, Color.white);
            if (Mouse.IsOver(displayFoodColor) && Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
            {
                Find.WindowStack.Add(new Dialog_ColourPicker(TacticalGroupsSettings.NeedFoodBarColor, (Color x) =>
                {
                    TacticalGroupsSettings.NeedFoodBarColor = x;
                    TacticalGroupsSettings.InitColorBars();
                }, colorPickerPos));
            }


            leftHalf.y += 25f;
            Widgets.Checkbox(leftHalf, ref TacticalGroupsSettings.DisplayRest);
            Widgets.Label(new Rect(rect.x + 20, leftHalf.y, textFieldWidth, 25f), Strings.DisplayRest);

            var displayRestColor = new Rect(displayFoodColor.x, leftHalf.y + 5, 12, 12);

            Widgets.DrawBoxSolidWithOutline(displayRestColor, TacticalGroupsSettings.NeedRestBarColor, Color.white);
            if (Mouse.IsOver(displayRestColor) && Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
            {
                Find.WindowStack.Add(new Dialog_ColourPicker(TacticalGroupsSettings.NeedRestBarColor, (Color x) =>
                {
                    TacticalGroupsSettings.NeedRestBarColor = x;
                    TacticalGroupsSettings.InitColorBars();
                }, colorPickerPos));
            }

            leftHalf.y += 25f;
            Widgets.Checkbox(leftHalf, ref TacticalGroupsSettings.DisplayHealth);
            Widgets.Label(new Rect(rect.x + 20, leftHalf.y, textFieldWidth, 25f), Strings.DisplayHealth);

            var displayHealthColor = new Rect(displayFoodColor.x, leftHalf.y + 5, 12, 12);

            Widgets.DrawBoxSolidWithOutline(displayHealthColor, TacticalGroupsSettings.NeedHealthBarColor, Color.white);
            if (Mouse.IsOver(displayHealthColor) && Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
            {
                Find.WindowStack.Add(new Dialog_ColourPicker(TacticalGroupsSettings.NeedHealthBarColor, (Color x) =>
                {
                    TacticalGroupsSettings.NeedHealthBarColor = x;
                    TacticalGroupsSettings.InitColorBars();
                }, colorPickerPos));
            }

            leftHalf.y += 25f;
            Widgets.Label(new Rect(rect.x + 20, leftHalf.y, textFieldWidth, 25f), Strings.PawnNeedsSize + ": " + TacticalGroupsSettings.PawnNeedsWidth.ToString());
            leftHalf.y += 25f;
            TacticalGroupsSettings.PawnNeedsWidth = (int)Widgets.HorizontalSlider(new Rect(rect.x + 20, leftHalf.y, textFieldWidth, 25f), TacticalGroupsSettings.PawnNeedsWidth, 1f, 25f);

            leftHalf.y += 35f;
            Widgets.Label(new Rect(rect.x + 20, leftHalf.y, textFieldWidth, 25f), Strings.ColonistBarPositionY + ": " + (int)TacticalGroupsSettings.ColonistBarPositionY);
            leftHalf.y += 25f;
            TacticalGroupsSettings.ColonistBarPositionY = Widgets.HorizontalSlider(new Rect(rect.x + 20, leftHalf.y, textFieldWidth, 25f), TacticalGroupsSettings.ColonistBarPositionY, 0f, 500f);

            leftHalf.y += 25f;
            Widgets.Label(new Rect(rect.x + 20, leftHalf.y, textFieldWidth, 25f), Strings.ColonistBarPositionX + ": " + (int)TacticalGroupsSettings.ColonistBarPositionX);
            leftHalf.y += 25f;
            TacticalGroupsSettings.ColonistBarPositionX = Widgets.HorizontalSlider(new Rect(rect.x + 20, leftHalf.y, textFieldWidth, 25f),
                                                                                   TacticalGroupsSettings.ColonistBarPositionX, -400f, 400f);

            leftHalf.y += 25f;
            Widgets.Label(new Rect(rect.x + 20, leftHalf.y, textFieldWidth, 25f), Strings.ColonistBarSpacingX + ": " + (int)TacticalGroupsSettings.ColonistBarSpacingX);
            leftHalf.y += 25f;
            TacticalGroupsSettings.ColonistBarSpacingX = Widgets.HorizontalSlider(new Rect(rect.x + 20, leftHalf.y, textFieldWidth, 25f), TacticalGroupsSettings.ColonistBarSpacingX, 1f, 500f);

            leftHalf.y += 25f;
            Widgets.Label(new Rect(rect.x + 20, leftHalf.y, textFieldWidth, 25f), Strings.ColonistBarSpacingY + ": " + (int)TacticalGroupsSettings.ColonistBarSpacingY);
            leftHalf.y += 25f;
            TacticalGroupsSettings.ColonistBarSpacingY = Widgets.HorizontalSlider(new Rect(rect.x + 20, leftHalf.y, textFieldWidth, 25f), TacticalGroupsSettings.ColonistBarSpacingY, 1f, 500f);


            leftHalf.y += 45f;
            Widgets.Checkbox(leftHalf, ref TacticalGroupsSettings.DisableLabelBackground);
            var disableLabelBackgroundRect = new Rect(rect.x + 20, leftHalf.y, textFieldWidth - 30, 45f);

            Text.Font = GameFont.Tiny;
            Widgets.Label(disableLabelBackgroundRect, Strings.DisableLabelBackground);
            Text.Font = GameFont.Small;

            Vector2 middle     = new Vector2(leftHalf.x + checkBoxesWidth, rect.y + 25f);
            float   xMiddlePos = rect.x + 230;

            Widgets.Checkbox(middle, ref TacticalGroupsSettings.HideCreateGroup);
            Widgets.Label(new Rect(xMiddlePos, middle.y, textFieldWidth, 25f), Strings.HideCreateGroup);

            middle.y += 25f;
            Widgets.Checkbox(middle, ref TacticalGroupsSettings.DisplayBreakRiskOverlay);
            Widgets.Label(new Rect(xMiddlePos, middle.y, textFieldWidth, 25f), Strings.DisplayBreakRiskOverlay);

            middle.y += 70f;
            Widgets.Checkbox(middle, ref TacticalGroupsSettings.DisplayColorBars);
            Widgets.Label(new Rect(xMiddlePos, middle.y, textFieldWidth, 25f), Strings.DisplayColorBars);

            var resetColorBars = new Rect(middle.x + 37, middle.y, 24, 24);

            GUI.DrawTexture(resetColorBars, Textures.ResetIcon);
            if (Mouse.IsOver(resetColorBars) && Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
            {
                TacticalGroupsSettings.ResetColorBars();
                TacticalGroupsSettings.InitColorBars();
            }

            middle.y += 25f;
            var colorBarDefaultRect  = new Rect(xMiddlePos, middle.y, 80f, 30f);
            var colorBarExtendedRect = new Rect(xMiddlePos + 90f, middle.y, 100f, 30f);

            TooltipHandler.TipRegion(colorBarDefaultRect, Strings.ColorBarModeDefaultTooltip);
            TooltipHandler.TipRegion(colorBarExtendedRect, Strings.ColorBarModeExtendedTooltip);

            if (Widgets.RadioButtonLabeled(colorBarDefaultRect, Strings.ColorBarModeDefault, TacticalGroupsSettings.ColorBarMode == ColorBarMode.Default))
            {
                TacticalGroupsSettings.ColorBarMode = ColorBarMode.Default;
            }
            else if (Widgets.RadioButtonLabeled(colorBarExtendedRect, Strings.ColorBarModeExtended, TacticalGroupsSettings.ColorBarMode != ColorBarMode.Default))
            {
                TacticalGroupsSettings.ColorBarMode = ColorBarMode.Extended;
            }

            var defaultBottomColor = new Rect(colorBarDefaultRect.x + 3, colorBarDefaultRect.yMax - 3, 12, 12);

            Widgets.DrawBoxSolidWithOutline(defaultBottomColor, TacticalGroupsSettings.DefaultMoodBarLower, Color.white);
            if (Mouse.IsOver(defaultBottomColor) && Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
            {
                Find.WindowStack.Add(new Dialog_ColourPicker(TacticalGroupsSettings.DefaultMoodBarLower, (Color x) =>
                {
                    TacticalGroupsSettings.DefaultMoodBarLower = x;
                    TacticalGroupsSettings.InitColorBars();
                }, colorPickerPos));
            }

            var defaultMiddleColor = new Rect(defaultBottomColor.xMax, defaultBottomColor.y, 12, 12);

            Widgets.DrawBoxSolidWithOutline(defaultMiddleColor, TacticalGroupsSettings.DefaultMoodBarMiddle, Color.white);
            if (Mouse.IsOver(defaultMiddleColor) && Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
            {
                Find.WindowStack.Add(new Dialog_ColourPicker(TacticalGroupsSettings.DefaultMoodBarMiddle, (Color x) =>
                {
                    TacticalGroupsSettings.DefaultMoodBarMiddle = x;
                    TacticalGroupsSettings.InitColorBars();
                }, colorPickerPos));
            }

            var defaultUpperColor = new Rect(defaultMiddleColor.xMax, defaultBottomColor.y, 12, 12);

            Widgets.DrawBoxSolidWithOutline(defaultUpperColor, TacticalGroupsSettings.DefaultMoodBarUpper, Color.white);
            if (Mouse.IsOver(defaultUpperColor) && Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
            {
                Find.WindowStack.Add(new Dialog_ColourPicker(TacticalGroupsSettings.DefaultMoodBarUpper, (Color x) =>
                {
                    TacticalGroupsSettings.DefaultMoodBarUpper = x;
                    TacticalGroupsSettings.InitColorBars();
                }, colorPickerPos));
            }

            var extendedBottomIIColor = new Rect(defaultUpperColor.xMax + 51, defaultBottomColor.y, 12, 12);

            Widgets.DrawBoxSolidWithOutline(extendedBottomIIColor, TacticalGroupsSettings.ExtendedMoodBarLowerII, Color.white);
            if (Mouse.IsOver(extendedBottomIIColor) && Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
            {
                Find.WindowStack.Add(new Dialog_ColourPicker(TacticalGroupsSettings.ExtendedMoodBarLowerII, (Color x) =>
                {
                    TacticalGroupsSettings.ExtendedMoodBarLowerII = x;
                    TacticalGroupsSettings.InitColorBars();
                }, colorPickerPos));
            }

            var extendedBottomColor = new Rect(extendedBottomIIColor.xMax, defaultBottomColor.y, 12, 12);

            Widgets.DrawBoxSolidWithOutline(extendedBottomColor, TacticalGroupsSettings.ExtendedMoodBarLower, Color.white);
            if (Mouse.IsOver(extendedBottomColor) && Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
            {
                Find.WindowStack.Add(new Dialog_ColourPicker(TacticalGroupsSettings.ExtendedMoodBarLower, (Color x) =>
                {
                    TacticalGroupsSettings.ExtendedMoodBarLower = x;
                    TacticalGroupsSettings.InitColorBars();
                }, colorPickerPos));
            }

            var extendedMiddleColor = new Rect(extendedBottomColor.xMax, defaultBottomColor.y, 12, 12);

            Widgets.DrawBoxSolidWithOutline(extendedMiddleColor, TacticalGroupsSettings.ExtendedMoodBarMiddle, Color.white);
            if (Mouse.IsOver(extendedMiddleColor) && Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
            {
                Find.WindowStack.Add(new Dialog_ColourPicker(TacticalGroupsSettings.ExtendedMoodBarMiddle, (Color x) =>
                {
                    TacticalGroupsSettings.ExtendedMoodBarMiddle = x;
                    TacticalGroupsSettings.InitColorBars();
                }, colorPickerPos));
            }

            var extendedUpperColor = new Rect(extendedMiddleColor.xMax, defaultBottomColor.y, 12, 12);

            Widgets.DrawBoxSolidWithOutline(extendedUpperColor, TacticalGroupsSettings.ExtendedMoodBarUpper, Color.white);
            if (Mouse.IsOver(extendedUpperColor) && Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
            {
                Find.WindowStack.Add(new Dialog_ColourPicker(TacticalGroupsSettings.ExtendedMoodBarUpper, (Color x) =>
                {
                    TacticalGroupsSettings.ExtendedMoodBarUpper = x;
                    TacticalGroupsSettings.InitColorBars();
                }, colorPickerPos));
            }

            var extendedUpperIIColor = new Rect(extendedUpperColor.xMax, defaultBottomColor.y, 12, 12);

            Widgets.DrawBoxSolidWithOutline(extendedUpperIIColor, TacticalGroupsSettings.ExtendedMoodBarUpperII, Color.white);
            if (Mouse.IsOver(extendedUpperIIColor) && Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
            {
                Find.WindowStack.Add(new Dialog_ColourPicker(TacticalGroupsSettings.ExtendedMoodBarUpperII, (Color x) =>
                {
                    TacticalGroupsSettings.ExtendedMoodBarUpperII = x;
                    TacticalGroupsSettings.InitColorBars();
                }, colorPickerPos));
            }

            middle.y += 50f;
            Widgets.Label(new Rect(xMiddlePos, middle.y, textFieldWidth, 25f), Strings.HealthBarSize + ": " + TacticalGroupsSettings.HealthBarWidth.ToString());
            middle.y += 25f;
            TacticalGroupsSettings.HealthBarWidth = (int)Widgets.HorizontalSlider(new Rect(xMiddlePos, middle.y, textFieldWidth, 25f), TacticalGroupsSettings.HealthBarWidth, 1f, 25f);

            middle.y += 35f;
            Widgets.Label(new Rect(xMiddlePos, middle.y, textFieldWidth, 25f), Strings.GroupRowCount + ": " + TacticalGroupsSettings.GroupRowCount.ToString());
            middle.y += 25f;
            TacticalGroupsSettings.GroupRowCount = (int)Widgets.HorizontalSlider(new Rect(xMiddlePos, middle.y, textFieldWidth, 25f), TacticalGroupsSettings.GroupRowCount, 1f, 12f);
            middle.y += 25f;
            Widgets.Label(new Rect(xMiddlePos, middle.y, textFieldWidth, 25f), Strings.ColonyGroupScale + ": " + TacticalGroupsSettings.ColonyGroupScale.ToStringDecimalIfSmall());
            middle.y += 25f;
            TacticalGroupsSettings.ColonyGroupScale = Widgets.HorizontalSlider(new Rect(xMiddlePos, middle.y, textFieldWidth, 25f), TacticalGroupsSettings.ColonyGroupScale, 0.5f, 2f);
            middle.y += 25f;
            Widgets.Label(new Rect(xMiddlePos, middle.y, textFieldWidth, 25f), Strings.GroupScale + ": " + TacticalGroupsSettings.GroupScale.ToStringDecimalIfSmall());
            middle.y += 25f;
            TacticalGroupsSettings.GroupScale = Widgets.HorizontalSlider(new Rect(xMiddlePos, middle.y, textFieldWidth, 25f), TacticalGroupsSettings.GroupScale, 0.5f, 2f);

            middle.y += 100f;
            var resetButtonRect = new Rect(xMiddlePos, middle.y, Textures.MenuButton.width, 25f);

            GUI.DrawTexture(resetButtonRect, Textures.MenuButton);

            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(resetButtonRect, Strings.ResetToDefault);
            if (Mouse.IsOver(resetButtonRect))
            {
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticalGroupsSettings.DoReset();
                    Event.current.Use();
                }
            }

            Vector2 rightHalf = new Vector2(middle.x + checkBoxesWidth + 70, rect.y + 25f);
            float   xRightPos = xMiddlePos + checkBoxesWidth + 50;

            rightHalf.y += 10f;
            var resetPawnViewRect = new Rect(xRightPos, rightHalf.y, Textures.MenuButton.width, 25f);

            GUI.DrawTexture(resetPawnViewRect, Textures.MenuButton);
            Widgets.Label(new Rect(xRightPos + 10, resetPawnViewRect.y, Textures.MenuButton.width - 10, 25f), Strings.ResetPawnView);
            if (Mouse.IsOver(resetPawnViewRect))
            {
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticalGroupsSettings.DoPawnViewReset();
                    Event.current.Use();
                }
            }

            rightHalf.y += 50f;
            Widgets.Label(new Rect(xRightPos, rightHalf.y, textFieldWidth, 25f), Strings.Pawn);

            rightHalf.y += 25f;
            TacticalGroupsSettings.PawnCameraOffsetX = Widgets.HorizontalSlider(new Rect(xRightPos, rightHalf.y, textFieldWidth, 25f), TacticalGroupsSettings.PawnCameraOffsetX, -1f, 1f);
            rightHalf.y += 25f;
            TacticalGroupsSettings.PawnCameraOffsetZ = Widgets.HorizontalSlider(new Rect(xRightPos, rightHalf.y, textFieldWidth, 25f), TacticalGroupsSettings.PawnCameraOffsetZ, -1f, 3f);
            rightHalf.y += 25f;
            TacticalGroupsSettings.PawnScale = Widgets.HorizontalSlider(new Rect(xRightPos, rightHalf.y, textFieldWidth, 25f), TacticalGroupsSettings.PawnScale, 0.1f, 5f);

            rightHalf.y += 15f;
            Widgets.Label(new Rect(xRightPos, rightHalf.y, textFieldWidth, 25f), Strings.Box);
            rightHalf.y += 25f;
            TacticalGroupsSettings.PawnBoxHeight = Widgets.HorizontalSlider(new Rect(xRightPos, rightHalf.y, textFieldWidth, 25f), TacticalGroupsSettings.PawnBoxHeight, 1f, 300f);
            rightHalf.y += 25f;
            TacticalGroupsSettings.PawnBoxWidth = Widgets.HorizontalSlider(new Rect(xRightPos, rightHalf.y, textFieldWidth, 25f), TacticalGroupsSettings.PawnBoxWidth, 5f, 300f);

            rightHalf.y += 25f;
            Text.Anchor  = TextAnchor.MiddleLeft;
            Widgets.Label(new Rect(xRightPos, rightHalf.y, 150, 25f), Strings.PawnRowCount + TacticalGroupsSettings.PawnRowCount);
            var pawnRowCountCheckBox = new Vector2(xRightPos + 150, rightHalf.y);

            Widgets.Checkbox(pawnRowCountCheckBox, ref TacticalGroupsSettings.OverridePawnRowCount);
            rightHalf.y += 25f;
            TacticalGroupsSettings.PawnRowCount = (int)Widgets.HorizontalSlider(new Rect(xRightPos, rightHalf.y, textFieldWidth, 25f), TacticalGroupsSettings.PawnRowCount, 1, 10);

            Text.Anchor  = TextAnchor.UpperLeft;
            rightHalf.y += 50f;
            Widgets.Checkbox(rightHalf, ref TacticalGroupsSettings.DisplayWeapons);
            Widgets.Label(new Rect(xRightPos, rightHalf.y, textFieldWidth, 25f), Strings.DisplayWeapons);

            rightHalf.y += 25f;
            TacticalGroupsSettings.WeaponPlacementOffset = (int)Widgets.HorizontalSlider(new Rect(xRightPos, rightHalf.y, textFieldWidth, 25f),
                                                                                         TacticalGroupsSettings.WeaponPlacementOffset, -200, 200);
            rightHalf.y += 15f;

            if (Widgets.RadioButtonLabeled(new Rect(xRightPos, rightHalf.y, 80f, 30f), Strings.WeaponModeShowDrafted, TacticalGroupsSettings.WeaponShowMode == WeaponShowMode.Drafted))
            {
                TacticalGroupsSettings.WeaponShowMode = WeaponShowMode.Drafted;
            }
            else if (Widgets.RadioButtonLabeled(new Rect(xRightPos + 90f, rightHalf.y, 100f, 30f), Strings.WeaponModeShowAlways, TacticalGroupsSettings.WeaponShowMode != WeaponShowMode.Drafted))
            {
                TacticalGroupsSettings.WeaponShowMode = WeaponShowMode.Always;
            }

            rightHalf.y += 35f;
            Widgets.Label(new Rect(xRightPos, rightHalf.y, textFieldWidth, 25f), Strings.WeaponSizeScale);
            rightHalf.y += 25f;
            TacticalGroupsSettings.WeaponShowScale = Widgets.HorizontalSlider(new Rect(xRightPos, rightHalf.y, textFieldWidth, 25f), TacticalGroupsSettings.WeaponShowScale, 0.1f, 5f);

            TacticUtils.TacticalColonistBar?.UpdateSizes();
            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;

            TacticalGroupsMod.instance.WriteSettings();
            TacticUtils.TacticalColonistBar.MarkColonistsDirty();
        }
        public override void DoWindowContents(Rect inRect)
        {
            base.DoWindowContents(inRect);

            foreach (var data in colorRects)
            {
                var colorOption = GetColorOptionFor(data.Key);
                if (colorOption != null)
                {
                    if (colorOption.pawnFavoriteOnly)
                    {
                        GUI.DrawTexture(data.Value, Textures.PawnFavoriteIcon);
                    }
                    else
                    {
                        Widgets.DrawBoxSolidWithOutline(data.Value, colorOption.color, Color.white);
                    }
                }
                else
                {
                    Widgets.DrawBoxSolidWithOutline(data.Value, Color.clear, Color.white);
                }

                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1 && Mouse.IsOver(data.Value))
                {
                    activeMode = data.Key;
                }
                else if (Event.current.type == EventType.MouseDown && Event.current.button == 1 && Event.current.clickCount == 1 && Mouse.IsOver(data.Value))
                {
                    RemoveColor();
                }
            }
            if (colorRects.ContainsKey(activeMode))
            {
                GUI.DrawTexture(colorRects[activeMode], Textures.GreenSelectionBox);
            }

            foreach (var data in stringRects)
            {
                Widgets.Label(data.Value, data.Key);
            }

            var colorSelectorRect = new Rect(37, 142, 570, 195);
            var oldColor          = curColor;

            Widgets.ColorSelector(colorSelectorRect, ref curColor, ColorUtils.AllColors);
            if (oldColor != curColor)
            {
                SetColor();
            }
            var setIdeoColorRect = new Rect(40, inRect.yMax - 58, 174, 24f);

            if (Widgets.ButtonText(setIdeoColorRect, Strings.SetIdeologyColor))
            {
                curColor = Faction.OfPlayer.ideos.PrimaryIdeo.ApparelColor;
                SetColor();
            }

            var setPawnFavoritesColor = new Rect(setIdeoColorRect.xMax + 15, setIdeoColorRect.y, setIdeoColorRect.width, 24f);

            if (Widgets.ButtonText(setPawnFavoritesColor, Strings.SetPawnFavoritesColor))
            {
                if (this.colonistGroup.groupColor is null)
                {
                    this.colonistGroup.groupColor = new GroupColor();
                }
                if (this.colonistGroup.groupColor.bodyColors is null)
                {
                    this.colonistGroup.groupColor.bodyColors = new Dictionary <BodyColor, ColorOption>();
                }
                this.colonistGroup.groupColor.bodyColors[activeMode] = new ColorOption(true);
                curColor = Color.clear;
            }

            var clearGroupColor = new Rect(setPawnFavoritesColor.xMax + 15, setIdeoColorRect.y, setIdeoColorRect.width, 24f);

            if (Widgets.ButtonText(clearGroupColor, Strings.ClearGroupColor))
            {
                RemoveColor();
            }
        }
예제 #5
0
        public void DrawBodyPartGroup(BodyDef bodyDef, BodyPartGroup group, List <ApparelLayerDef> layers,
                                      ref float curY, List <Rect> columns, List <Tuple <Item, Tag> > wornApparel)
        {
            var groupRect = new Rect(columns[0].x, curY, columns[0].width, ModGUIUtility.SPACED_HEIGHT);

            var def = group.def;

            GUI.color = Color.gray;
            Widgets.Label(groupRect, def.LabelCap);
            GUI.color = Color.white;

            Text.Font = GameFont.Tiny;

            foreach (var column in group.layers.OrderByDescending(d => d.drawOrder))
            {
                var idx         = layers.FirstIndexOf(c => c == column) + 1;
                var columnRect  = new Rect(columns[idx].x, curY, columns[idx].width, ModGUIUtility.SPACED_HEIGHT);
                var loadoutTags = selectedUnit.loadout.tags;

                var(overlappingApparel, overlappingTag) = wornApparel
                                                          .FirstOrDefault(item =>
                                                                          ApparelSlotMaker.Create(bodyDef, item.Item1.Def)
                                                                          .Intersects(def, column)) ??
                                                          new Tuple <Item, Tag>(null, null);

                var possibleDefs = loadoutTags
                                   .SelectMany(t =>
                                               t.ItemsWithTagMatching(item =>
                                                                      item.Def.IsApparel && ApparelSlotMaker.Create(bodyDef, (ThingDef)item.Def).Intersects(def, column)))
                                   .ToList();

                if (overlappingApparel != null)
                {
                    possibleDefs.RemoveAll(tup => tup.Item1 == overlappingTag);
                }

                if (overlappingApparel == null && possibleDefs.EnumerableNullOrEmpty())
                {
                    Widgets.DrawBoxSolidWithOutline(columnRect, Widgets.WindowBGFillColor, Color.gray);
                }
                else
                {
                    if (overlappingApparel != null)
                    {
                        var col = GetColorForTagAtIndex(loadoutTags.IndexOf(overlappingTag));
                        Widgets.DrawBoxSolidWithOutline(columnRect, Widgets.WindowBGFillColor, col);
                        Widgets.DefIcon(columnRect.ContractedBy(3f), overlappingApparel.Def,
                                        overlappingApparel.RandomStuff);

                        if (possibleDefs.Any())
                        {
                            var str = "";
                            foreach (var(pTag, pApparel) in possibleDefs)
                            {
                                str += $"\n - {pApparel.Def.LabelCap} from {pTag.name}";
                            }

                            TooltipHandler.TipRegion(columnRect,
                                                     $"{overlappingApparel.Def.LabelCap} from {overlappingTag.name} blocks:{str}");
                        }
                    }
                    else
                    {
                        var nextHighestPrio = possibleDefs.OrderBy(tup => loadoutTags.IndexOf(tup.Item1)).First().Item2;
                        Widgets.DrawBoxSolidWithOutline(columnRect, Widgets.WindowBGFillColor, Color.red);
                        Widgets.DefIcon(columnRect.ContractedBy(3f),
                                        nextHighestPrio.Def,
                                        color: new Color(0.5f, 0.5f, 0.5f, 0.3f));

                        var str = "Blocked Tags:";
                        foreach (var(pTag, pApparel) in possibleDefs)
                        {
                            str += $"\n - {pApparel.Def.LabelCap} from {pTag.name}";
                        }

                        TooltipHandler.TipRegion(columnRect, str);
                    }
                }
            }

            Text.Font = GameFont.Small;

            curY += ModGUIUtility.SPACED_HEIGHT;

            foreach (var child in group.children)
            {
                DrawBodyPartGroup(bodyDef, child, layers, ref curY, columns, wornApparel);
            }
        }