예제 #1
0
 public override void FinalizeInit()
 {
     base.FinalizeInit();
     TacticUtils.ResetTacticGroups();
     PreInit();
     MedicalCareUtilityGroup.Reset();
 }
예제 #2
0
        private float FindBestScale(out bool onlyOneRow, out int maxPerGlobalRow)
        {
            float num = 1f;
            List <TacticalColonistBar.Entry> entries = TacticUtils.TacticalColonistBar.Entries;
            int num2 = CalculateGroupsCount();

            while (true)
            {
                float scaleMultiplier = 1f;
                if (!TacticalGroupsSettings.HideGroups)
                {
                    var count = TacticUtils.AllColonyGroups.Count;
                    count += TacticUtils.AllCaravanGroups.Count;
                    if (!WorldRendererUtility.WorldRenderedNow && count > 0)
                    {
                        var activeColony = TacticUtils.AllColonyGroups.Where(x => x.Map == Find.CurrentMap).FirstOrDefault();
                        if (activeColony != null)
                        {
                            count += TacticUtils.GetAllPawnGroupFor(activeColony).Take(TacticalGroupsSettings.GroupRowCount).Count();
                            count += TacticUtils.GetAllSubGroupFor(activeColony).Take(TacticalGroupsSettings.SubGroupRowCount).Count();
                        }
                    }
                    scaleMultiplier += (float)count / 10f;
                }

                float num3 = ((TacticalColonistBar.BaseSize.x + TacticalGroupsSettings.ColonistBarSpacing) * num);
                float num4 = (MaxColonistBarWidth - (float)(num2 - 1) * 25f * num) / scaleMultiplier;
                maxPerGlobalRow = Mathf.FloorToInt(num4 / num3);
                onlyOneRow      = true;
                if (TryDistributeHorizontalSlotsBetweenGroups(maxPerGlobalRow))
                {
                    int  allowedRowsCountForScale = GetAllowedRowsCountForScale(num);
                    bool flag = true;
                    int  num5 = -1;
                    for (int i = 0; i < entries.Count; i++)
                    {
                        if (num5 != entries[i].group)
                        {
                            num5 = entries[i].group;
                            int num6 = Mathf.CeilToInt((float)entriesInGroup[entries[i].group] / (float)horizontalSlotsPerGroup[entries[i].group]);
                            if (num6 > 1)
                            {
                                onlyOneRow = false;
                            }
                            if (num6 > allowedRowsCountForScale)
                            {
                                flag = false;
                                break;
                            }
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                }
                num *= 0.95f;
            }
            return(num);
        }
예제 #3
0
 public override void Disband(Pawn pawn)
 {
     base.Disband(pawn);
     if (this.pawns.Count == 0 && this.formerPawns.Count == 0 && this.autoDisbandWithoutPawns)
     {
         TacticUtils.TacticalGroups.pawnGroups.Remove(this);
         TacticUtils.RemoveReferencesFor(this);
     }
     TacticUtils.TacticalColonistBar.MarkColonistsDirty();
 }
예제 #4
0
 public void Disband(List <Pawn> pawns, bool permanent = true)
 {
     foreach (var pawn in pawns)
     {
         if (this.pawns.Contains(pawn))
         {
             this.Disband(pawn);
             if (this.formerPawns.Contains(pawn))
             {
                 this.formerPawns.Remove(pawn);
             }
         }
         if (!permanent)
         {
             this.formerPawns.Add(pawn);
         }
     }
     if (this.pawns.Count == 0 && this.formerPawns.Count == 0 && this.autoDisbandWithoutPawns)
     {
         TacticUtils.TacticalGroups.pawnGroups.Remove(this);
         TacticUtils.RemoveReferencesFor(this);
     }
     TacticUtils.TacticalColonistBar.MarkColonistsDirty();
 }
예제 #5
0
        private void CheckRecacheEntries()
        {
            if (!entriesDirty)
            {
                return;
            }
            entriesDirty = false;
            cachedEntries.Clear();
            if (Find.PlaySettings.showColonistBar)
            {
                tmpMaps.Clear();
                tmpMaps.AddRange(Find.Maps);
                tmpMaps.SortBy((Map x) => !x.IsPlayerHome, (Map x) => x.uniqueID);
                int num = 0;
                for (int i = 0; i < tmpMaps.Count; i++)
                {
                    tmpPawns.Clear();
                    tmpPawns.AddRange(tmpMaps[i].mapPawns.FreeColonistsAndPrisoners.Where(x => x.Faction == Faction.OfPlayer));
                    List <Thing> list = tmpMaps[i].listerThings.ThingsInGroup(ThingRequestGroup.Corpse);
                    for (int j = 0; j < list.Count; j++)
                    {
                        if (!list[j].IsDessicated())
                        {
                            Pawn innerPawn = ((Corpse)list[j]).InnerPawn;
                            if (innerPawn != null && innerPawn.IsColonist)
                            {
                                tmpPawns.Add(innerPawn);
                            }
                        }
                    }
                    List <Pawn> allPawnsSpawned = tmpMaps[i].mapPawns.AllPawnsSpawned;
                    for (int k = 0; k < allPawnsSpawned.Count; k++)
                    {
                        Corpse corpse = allPawnsSpawned[k].carryTracker.CarriedThing as Corpse;
                        if (corpse != null && !corpse.IsDessicated() && corpse.InnerPawn.IsColonist)
                        {
                            tmpPawns.Add(corpse.InnerPawn);
                        }
                    }
                    tmpPawns = GetNonHiddenPawns(tmpPawns);
                    PlayerPawnsDisplayOrderUtility.Sort(tmpPawns);
                    for (int l = 0; l < tmpPawns.Count; l++)
                    {
                        if (TacticUtils.TacticalGroups.colonyGroups.TryGetValue(tmpMaps[i], out ColonyGroup colonyGroup))
                        {
                            cachedEntries.Add(new Entry(tmpPawns[l], tmpMaps[i], num, null, colonyGroup));
                        }
                        else
                        {
                            cachedEntries.Add(new Entry(tmpPawns[l], tmpMaps[i], num, null, null));
                        }
                    }
                    if (!tmpPawns.Any())
                    {
                        try
                        {
                            var colonyGroup = TacticUtils.AllColonyGroups.Where(x => x.Map == tmpMaps[i]).FirstOrDefault();
                            cachedEntries.Add(new Entry(null, tmpMaps[i], num, null, colonyGroup));
                        }
                        catch { };
                    }
                    num++;
                }

                tmpCaravans.Clear();
                tmpCaravans.AddRange(Find.WorldObjects.Caravans);
                tmpCaravans.SortBy((Caravan x) => x.ID);
                for (int m = 0; m < tmpCaravans.Count; m++)
                {
                    if (!tmpCaravans[m].IsPlayerControlled)
                    {
                        continue;
                    }
                    tmpPawns.Clear();
                    tmpPawns.AddRange(tmpCaravans[m].PawnsListForReading);
                    tmpPawns = GetNonHiddenPawns(tmpPawns);
                    PlayerPawnsDisplayOrderUtility.Sort(tmpPawns);
                    for (int n = 0; n < tmpPawns.Count; n++)
                    {
                        if (tmpPawns[n].IsColonist)
                        {
                            if (TacticUtils.TacticalGroups.caravanGroups.TryGetValue(tmpCaravans[m], out CaravanGroup value))
                            {
                                cachedEntries.Add(new Entry(tmpPawns[n], null, num, value, null));
                            }
                            else
                            {
                                var caravanGroup = TacticUtils.TacticalGroups.AddCaravanGroup(tmpCaravans[m]);
                                cachedEntries.Add(new Entry(tmpPawns[n], null, num, caravanGroup, null));
                            }
                        }
                    }

                    if (!tmpPawns.Any())
                    {
                        var caravanGroup = TacticUtils.TacticalGroups.caravanGroups.Where(x => x.Key == tmpCaravans[m]).FirstOrDefault();
                        if (caravanGroup.Value != null)
                        {
                            cachedEntries.Add(new Entry(null, null, num, caravanGroup.Value, null));
                        }
                    }
                    num++;
                }
            }

            drawer.Notify_RecachedEntries();
            tmpPawns.Clear();
            tmpMaps.Clear();
            tmpCaravans.Clear();
            GenMapUIOptimized.ForceUpdateLabels();
            TacticUtils.ForceUpdateGroups();
            drawLocsFinder.CalculateDrawLocs(cachedDrawLocs, out cachedScale);
        }
예제 #6
0
        public override void DoWindowContents(Rect rect)
        {
            base.DoWindowContents(rect);
            var colonyHideButtonRect = new Rect(rect.x + 13, rect.y + 13, Textures.ColonyHideButton.width, Textures.ColonyHideButton.height);

            if (this.colonistGroup.isColonyGroup || this.colonistGroup.isTaskForce)
            {
                GUI.DrawTexture(colonyHideButtonRect, Textures.ColonyHideButton);
                TooltipHandler.TipRegion(colonyHideButtonRect, Strings.GroupHideOptionsTooltip);
                if (this.colonistGroup.hideGroupIcon)
                {
                    GUI.DrawTexture(colonyHideButtonRect, Textures.ManageOptionsX);
                }
                if (Mouse.IsOver(colonyHideButtonRect))
                {
                    GUI.DrawTexture(colonyHideButtonRect, Textures.RescueTendHover);
                    if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                    {
                        var value = !this.colonistGroup.hideGroupIcon;
                        this.colonistGroup.hideGroupIcon = value;
                        if (this.colonistGroup is ColonyGroup colonyGroup)
                        {
                            foreach (var subGroup in TacticUtils.GetAllSubGroupFor(colonyGroup))
                            {
                                subGroup.hideGroupIcon = value;
                            }
                        }
                        TacticDefOf.TG_SlideMenuOptionSFX.PlayOneShotOnCamera();
                    }
                }
            }
            else if (this.colonistGroup.isPawnGroup && this.colonistGroup is PawnGroup pawnGroup)
            {
                var subgroupButton = new Rect(colonyHideButtonRect);
                GUI.DrawTexture(subgroupButton, Textures.SubGroupButton);
                if (this.colonistGroup.isSubGroup)
                {
                    GUI.DrawTexture(subgroupButton, Textures.ManageOptionsX);
                }
                TooltipHandler.TipRegion(subgroupButton, Strings.HidePawnGroupOptionsTooltip);
                if (Mouse.IsOver(subgroupButton))
                {
                    GUI.DrawTexture(subgroupButton, Textures.RescueTendHover);
                    if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                    {
                        if (pawnGroup.isSubGroup)
                        {
                            pawnGroup.ConvertToPawnGroup();
                        }
                        else
                        {
                            pawnGroup.ConvertToSubGroup();
                        }
                        pawnGroup.ResetDrawOptions();
                        this.CloseAllWindows();
                        TacticUtils.TacticalColonistBar.MarkColonistsDirty();
                        TacticDefOf.TG_SubGroupSFX.PlayOneShotOnCamera();
                    }
                }
            }

            var hidePawnDotsRect = new Rect(colonyHideButtonRect.xMax + 10, colonyHideButtonRect.y, Textures.PawnDotsButton.width, Textures.PawnDotsButton.height);

            GUI.DrawTexture(hidePawnDotsRect, Textures.PawnDotsButton);
            TooltipHandler.TipRegion(hidePawnDotsRect, Strings.HideGroupPawnDotsOptionsTooltip);
            if (this.colonistGroup.hidePawnDots)
            {
                GUI.DrawTexture(hidePawnDotsRect, Textures.ManageOptionsX);
            }
            if (Mouse.IsOver(hidePawnDotsRect))
            {
                GUI.DrawTexture(hidePawnDotsRect, Textures.RescueTendHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_SlideMenuOptionSFX.PlayOneShotOnCamera();
                    this.colonistGroup.hidePawnDots = !this.colonistGroup.hidePawnDots;
                }
            }

            var hideLifeOverlayRect = new Rect(colonyHideButtonRect.x, colonyHideButtonRect.yMax + 14, Textures.GroupOverlayButton.width, Textures.GroupOverlayButton.height);

            GUI.DrawTexture(hideLifeOverlayRect, Textures.GroupOverlayButton);
            if (this.colonistGroup.hideLifeOverlay)
            {
                GUI.DrawTexture(hideLifeOverlayRect, Textures.ManageOptionsX);
            }
            TooltipHandler.TipRegion(hideLifeOverlayRect, Strings.HideGroupHealthAlertOverlayOptionsTooltip);
            if (Mouse.IsOver(hideLifeOverlayRect))
            {
                GUI.DrawTexture(hideLifeOverlayRect, Textures.RescueTendHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_SlideMenuOptionSFX.PlayOneShotOnCamera();
                    this.colonistGroup.hideLifeOverlay = !this.colonistGroup.hideLifeOverlay;
                }
            }

            var hideWeaponOverlayRect = new Rect(colonyHideButtonRect.xMax + 10, hideLifeOverlayRect.y, Textures.ShowWeaponButton.width, Textures.ShowWeaponButton.height);

            GUI.DrawTexture(hideWeaponOverlayRect, Textures.ShowWeaponButton);
            if (this.colonistGroup.hideWeaponOverlay)
            {
                GUI.DrawTexture(hideWeaponOverlayRect, Textures.ManageOptionsX);
            }
            TooltipHandler.TipRegion(hideWeaponOverlayRect, Strings.HideWeaponOverlayOptionsTooltip);
            if (Mouse.IsOver(hideWeaponOverlayRect))
            {
                GUI.DrawTexture(hideWeaponOverlayRect, Textures.RescueTendHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_SlideMenuOptionSFX.PlayOneShotOnCamera();
                    this.colonistGroup.hideWeaponOverlay = !this.colonistGroup.hideWeaponOverlay;
                }
            }

            var presetButtonRect = new Rect(hideLifeOverlayRect.x + 5, hideLifeOverlayRect.yMax + 17, Textures.PresetButton.width, Textures.PresetButton.height);

            GUI.DrawTexture(presetButtonRect, Textures.PresetButton);
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(presetButtonRect, Strings.PresetLabel);
            Text.Anchor = TextAnchor.UpperLeft;

            TooltipHandler.TipRegion(presetButtonRect, Strings.PresetMenuOverlayOptionsTooltip);
            if (Mouse.IsOver(presetButtonRect))
            {
                GUI.DrawTexture(presetButtonRect, Textures.RescueTendHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_SlideMenuOptionSFX.PlayOneShotOnCamera();
                    var presetMenu = this.childWindows?.FirstOrDefault(x => x is PresetMenu);
                    if (presetMenu != null)
                    {
                        presetMenu.Close();
                        this.childWindows.Remove(presetMenu);
                    }
                    else
                    {
                        TieredFloatMenu floatMenu = new PresetMenu(this, colonistGroup, windowRect, Textures.PresetMenu);
                        OpenNewMenu(floatMenu);
                    }
                }
            }

            //var banishPawnRect = new Rect(hideWeaponOverlayRect.x, hideWeaponOverlayRect.yMax + 14, Textures.BanishPawnButton.width, Textures.BanishPawnButton.height);
            //if (this.colonistGroup.isColonyGroup || this.colonistGroup.isTaskForce)
            //{
            //      GUI.DrawTexture(banishPawnRect, Textures.BanishPawnButton);
            //      TooltipHandler.TipRegion(banishPawnRect, Strings.BanishPawnTooltip);
            //      if (Mouse.IsOver(banishPawnRect))
            //      {
            //              GUI.DrawTexture(banishPawnRect, Textures.RescueTendHover);
            //              if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
            //              {
            //                      foreach (var pawn in Find.Selector.SelectedPawns)
            //            {
            //                              this.colonistGroup.Disband(pawn);
            //            }
            //                      TacticDefOf.TG_SlideMenuOptionSFX.PlayOneShotOnCamera();
            //              }
            //      }
            //}
        }
예제 #7
0
        public override void DoWindowContents(Rect rect)
        {
            base.DoWindowContents(rect);
            Vector2 zero = Vector2.zero;

            zero += InitialFloatOptionPositionShift;
            for (int i = 0; i < options.Count; i++)
            {
                TieredFloatMenuOption floatMenuOption = options[i];
                Rect rect2 = new Rect(zero.x, zero.y, (this.backgroundTexture.width - InitialFloatOptionPositionShift.x) / 1.2f, floatMenuOption.curIcon.height);
                if (floatMenuOption.DoGUI(rect2, this))
                {
                    Find.WindowStack.TryRemove(this);
                    break;
                }
                zero.y += floatMenuOption.bottomIndent;
            }

            var pawnBox = new Rect(rect.x + 10f, rect.y + 23f, 130f, 180f);

            GUI.DrawTexture(pawnBox, PortraitsCache.Get(pawn, pawnBox.size, Rot4.South, PawnTextureCameraOffset, 1.15f));
            Widgets.InfoCardButton(pawnBox.x + pawnBox.width - 18f, pawnBox.x + pawnBox.height - 23f, pawn);
            Text.Anchor = TextAnchor.MiddleLeft;

            //var pawnTabsRect = new Rect(pawnBox.x, pawnBox.yMax + 10, 120, 120);
            //Widgets.DrawBox(pawnTabsRect);

            //MainTabWindow_Inspect mainTabWindow_Inspect = (MainTabWindow_Inspect)MainButtonDefOf.Inspect.TabWindow;
            //
            //TacticInspectPaneUtility.UpdateTabs(mainTabWindow_Inspect);

            var armorValue = pawn.apparel.WornApparel != null?TacticUtils.OverallArmorValue(pawn) : 0f;

            var armorValueLabel = new Rect(pawnBox.xMax + 5, pawnBox.y, 27, 26);

            Widgets.Label(armorValueLabel, armorValue.ToStringDecimalIfSmall());
            var armorValueRect = new Rect(armorValueLabel.xMax, pawnBox.y, Textures.CrossHairs.width, Textures.CrossHairs.height);

            GUI.DrawTexture(armorValueRect, Textures.ArmorIcon);


            var dpsValue = pawn.equipment.Primary != null?TacticUtils.WeaponScoreGain(pawn.equipment.Primary) : pawn.GetStatValue(StatDefOf.MeleeDPS);

            var dpsValueLabel = new Rect(pawnBox.xMax + 5, armorValueLabel.yMax, 27, 26);

            Widgets.Label(dpsValueLabel, dpsValue.ToStringDecimalIfSmall());
            var dpsValueRect = new Rect(dpsValueLabel.xMax, dpsValueLabel.y, Textures.CrossHairs.width, Textures.CrossHairs.height);

            GUI.DrawTexture(dpsValueRect, Textures.CrossHairs);
            var pawnInfoRect = new Rect(dpsValueRect.xMax - 30, rect.y + 90f, rect.width - 170f, rect.height - 110f);

            TacticCharacterCardUtility.DrawCharacterCard(pawnInfoRect, pawn, null, rect);

            Text.Anchor = TextAnchor.MiddleCenter;

            var moodTexture = GetMoodTexture(out string moodLabel);
            var moodRect    = new Rect(rect.x + 425f, rect.y + 90, moodTexture.width, moodTexture.height);

            GUI.DrawTexture(moodRect, moodTexture);
            var moodLabelRect = new Rect(moodRect.x, moodRect.y + moodTexture.height, 45, 24);

            Widgets.Label(moodLabelRect, moodLabel);
            TooltipHandler.TipRegion(moodRect, Strings.MoodIconTooltip);

            var healthTexture = GetHealthTexture(out string healthPercent);
            var healthRect    = new Rect(moodRect.x + 45f, moodRect.y, healthTexture.width, healthTexture.height);

            GUI.DrawTexture(healthRect, healthTexture);
            var healthLabelRect = new Rect(healthRect.x, healthRect.y + healthRect.height, 40, 24);

            Widgets.Label(healthLabelRect, healthPercent);
            TooltipHandler.TipRegion(healthRect, Strings.HealthIconTooltip);

            var restTexture = GetRestTexture(out string restPercent);
            var restRect    = new Rect(healthRect.x + 45f, healthRect.y, restTexture.width, restTexture.height);

            GUI.DrawTexture(restRect, restTexture);
            var restLabelRect = new Rect(restRect.x, restRect.y + restRect.height, 40, 24);

            Widgets.Label(restLabelRect, restPercent);
            TooltipHandler.TipRegion(restRect, Strings.RestIconTooltip);

            var foodTexture  = GetFoodTexture(out string foodPercent);
            var foodStatRect = new Rect(restRect.x + 45f, restRect.y, foodTexture.width, foodTexture.height);

            GUI.DrawTexture(foodStatRect, foodTexture);
            var foodLabelRect = new Rect(foodStatRect.x, foodStatRect.y + foodStatRect.height, 40, 24);

            Widgets.Label(foodLabelRect, foodPercent);
            TooltipHandler.TipRegion(foodStatRect, Strings.HungerIconTooltip);

            var needRect = new Rect(moodRect.x - 5f, moodLabelRect.yMax, 180f, rect.height - 160);

            TacticNeedsCardUtility.DoNeeds(needRect, pawn);

            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;

            var skillRect = new Rect(needRect.xMax + 10, moodRect.y - 1f, 164, rect.height - 110);

            TacticSkillUI.DrawSkillsOf(pawn, new Vector2(skillRect.x, skillRect.y), TacticSkillUI.SkillDrawMode.Gameplay);
        }
예제 #8
0
 public override void Disband()
 {
     TacticUtils.TacticalGroups.pawnGroups.Remove(this);
     TacticUtils.RemoveReferencesFor(this);
     TacticUtils.TacticalColonistBar.MarkColonistsDirty();
 }
예제 #9
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();
        }
예제 #10
0
        public override void DrawExtraGui(Rect rect)
        {
            base.DrawExtraGui(rect);
            Vector2 zero        = Vector2.zero + InitialFloatOptionPositionShift;
            var     tendWounded = new Rect(zero.x + 10, rect.y + 407, Textures.TendWounded.width, Textures.TendWounded.height);

            GUI.DrawTexture(tendWounded, Textures.TendWounded);
            if (this.colonistGroup.activeWorkTypes.TryGetValue(WorkType.TendWounded, out WorkState state))
            {
                if (state == WorkState.Active)
                {
                    GUI.DrawTexture(tendWounded, Textures.Clock);
                }
                else if (state == WorkState.ForcedLabor)
                {
                    GUI.DrawTexture(tendWounded, Textures.ClockSlave);
                }
            }
            if (Mouse.IsOver(tendWounded))
            {
                GUI.DrawTexture(tendWounded, Textures.RescueTendHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    this.colonistGroup.RemoveWorkState(WorkType.TendWounded);
                    TacticDefOf.TG_ClickSFX.PlayOneShotOnCamera();
                    WorkSearchUtility.SearchForWork(WorkType.TendWounded, this.colonistGroup.ActivePawns);
                    Event.current.Use();
                }
                else if (Event.current.type == EventType.MouseDown && Event.current.button == 1 && Event.current.clickCount == 1)
                {
                    this.colonistGroup.ChangeWorkState(WorkType.TendWounded);
                    if (this.colonistGroup.activeWorkTypes[WorkType.TendWounded] == WorkState.ForcedLabor)
                    {
                        TacticDefOf.TG_SlaveLaborSFX.PlayOneShotOnCamera();
                    }
                    else
                    {
                        TacticDefOf.TG_WorkSFX.PlayOneShotOnCamera();
                    }
                    WorkSearchUtility.SearchForWork(WorkType.TendWounded, this.colonistGroup.ActivePawns);
                    Event.current.Use();
                }
                TooltipHandler.TipRegion(tendWounded, Strings.ForcedLaborTooltip);
            }
            TooltipHandler.TipRegion(tendWounded, Strings.TendWoundedTooltip);
            var rescureFallen = new Rect(((zero.x + Textures.LookBusyButton.width) - (Textures.RescueFallen.width + 11f)) - 10f, tendWounded.y, Textures.RescueFallen.width, Textures.RescueFallen.height);

            GUI.DrawTexture(rescureFallen, Textures.RescueFallen);
            if (this.colonistGroup.activeWorkTypes.TryGetValue(WorkType.RescueFallen, out WorkState state2))
            {
                if (state2 == WorkState.Active)
                {
                    GUI.DrawTexture(rescureFallen, Textures.Clock);
                }
                else if (state2 == WorkState.ForcedLabor)
                {
                    GUI.DrawTexture(rescureFallen, Textures.ClockSlave);
                }
            }
            if (Mouse.IsOver(rescureFallen))
            {
                GUI.DrawTexture(rescureFallen, Textures.RescueTendHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    this.colonistGroup.RemoveWorkState(WorkType.RescueFallen);
                    TacticDefOf.TG_ClickSFX.PlayOneShotOnCamera();
                    WorkSearchUtility.SearchForWork(WorkType.RescueFallen, this.colonistGroup.ActivePawns);
                    Event.current.Use();
                }
                else if (Event.current.type == EventType.MouseDown && Event.current.button == 1 && Event.current.clickCount == 1)
                {
                    this.colonistGroup.ChangeWorkState(WorkType.RescueFallen);
                    if (this.colonistGroup.activeWorkTypes[WorkType.RescueFallen] == WorkState.ForcedLabor)
                    {
                        TacticDefOf.TG_SlaveLaborSFX.PlayOneShotOnCamera();
                    }
                    else
                    {
                        TacticDefOf.TG_WorkSFX.PlayOneShotOnCamera();
                    }
                    WorkSearchUtility.SearchForWork(WorkType.RescueFallen, this.colonistGroup.ActivePawns);
                    Event.current.Use();
                }
                GUI.DrawTexture(rescureFallen, Textures.RescueTendHover);
                TooltipHandler.TipRegion(rescureFallen, Strings.ForcedLaborTooltip);
            }
            TooltipHandler.TipRegion(rescureFallen, Strings.RescueDownedTooltip);
            var shooterIconRect = new Rect(rect.x + 10, rect.y + 25f, Textures.ShootingIcon.width, Textures.ShootingIcon.height);

            GUI.DrawTexture(shooterIconRect, Textures.ShootingIcon);
            if (Mouse.IsOver(shooterIconRect))
            {
                GUI.DrawTexture(shooterIconRect, Textures.ShootingMeleeHover);
            }
            var shooters         = this.colonistGroup.ActivePawns.Where(x => x.equipment?.Primary?.def.IsRangedWeapon ?? false);
            var shooterCountRect = new Rect(shooterIconRect.x + shooterIconRect.width + 2f, shooterIconRect.y, 30, shooterIconRect.height);

            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(shooterCountRect, shooters.Count().ToString());
            var totalShooterRect = new Rect(shooterIconRect.x, shooterIconRect.y, Textures.ShootingIcon.width + 25, shooterIconRect.height).ExpandedBy(5f);

            TooltipHandler.TipRegion(totalShooterRect, Strings.ShootersToolTip);
            if (Mouse.IsOver(totalShooterRect))
            {
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_ClickSFX.PlayOneShotOnCamera();
                    Find.Selector.ClearSelection();
                    foreach (var shooter in shooters)
                    {
                        Find.Selector.Select(shooter);
                    }
                    Event.current.Use();
                }
            }
            Text.Anchor = TextAnchor.MiddleCenter;
            var middlePawnCountRect = new Rect(totalShooterRect.x + totalShooterRect.width, totalShooterRect.y, 70, totalShooterRect.height);
            var capablePawns        = this.colonistGroup.ActivePawns.Where(x => !x.IsDownedOrIncapable());

            Widgets.Label(middlePawnCountRect, capablePawns.Count() + " / " + this.colonistGroup.ActivePawns.Count);

            TooltipHandler.TipRegion(middlePawnCountRect, Strings.MiddlePawnCountToolTip);
            if (Mouse.IsOver(middlePawnCountRect))
            {
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_ClickSFX.PlayOneShotOnCamera();
                    Find.Selector.ClearSelection();
                    foreach (var pawn in capablePawns)
                    {
                        Find.Selector.Select(pawn);
                    }
                    Event.current.Use();
                }
            }

            var meleeIconRect = new Rect((rect.x + rect.width) - 35, rect.y + 25f, Textures.MeleeIcon.width, Textures.MeleeIcon.height);

            GUI.DrawTexture(meleeIconRect, Textures.MeleeIcon);
            if (Mouse.IsOver(meleeIconRect))
            {
                GUI.DrawTexture(meleeIconRect, Textures.ShootingMeleeHover);
            }

            var melees         = this.colonistGroup.ActivePawns.Where(x => x.equipment?.Primary?.def.IsMeleeWeapon ?? false);
            var meleeCountRect = new Rect(meleeIconRect.x - (Textures.MeleeIcon.width + 5f), meleeIconRect.y, 30, meleeIconRect.height);

            Text.Anchor = TextAnchor.MiddleRight;
            Widgets.Label(meleeCountRect, melees.Count().ToString());

            var totalMeleeRect = new Rect(meleeCountRect.x, meleeIconRect.y, meleeIconRect.width + meleeCountRect.width, meleeIconRect.height).ExpandedBy(5f);

            TooltipHandler.TipRegion(totalMeleeRect, Strings.MeleeToolTip);

            if (Mouse.IsOver(totalMeleeRect))
            {
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_ClickSFX.PlayOneShotOnCamera();
                    Find.Selector.ClearSelection();
                    foreach (var melee in melees)
                    {
                        Find.Selector.Select(melee);
                    }
                    Event.current.Use();
                }
            }
            Text.Anchor = TextAnchor.MiddleCenter;

            var rectY   = (rect.height / 2f) - 30f;
            var setRect = new Rect(zero.x, rectY, Textures.SetClearButton.width, Textures.SetClearButton.height);

            GUI.DrawTexture(setRect, Textures.SetClearButton);
            Widgets.Label(setRect, Strings.Set);
            TooltipHandler.TipRegion(setRect, Strings.BattleStationsSetTooltip);

            if (Mouse.IsOver(setRect))
            {
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_ClickSFX.PlayOneShotOnCamera();
                    this.colonistGroup.SetBattleStations();
                    Event.current.Use();
                }
                GUI.DrawTexture(setRect, Textures.WorkButtonHover);
            }
            var clearRect = new Rect((zero.x + (Textures.MenuButton.width - Textures.SetClearButton.width)) - 12f, rectY, Textures.SetClearButton.width, Textures.SetClearButton.height);

            GUI.DrawTexture(clearRect, Textures.SetClearButton);
            Widgets.Label(clearRect, Strings.Clear);
            TooltipHandler.TipRegion(clearRect, Strings.BattleStationsClearTooltip);
            if (Mouse.IsOver(clearRect))
            {
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_ClickSFX.PlayOneShotOnCamera();
                    this.colonistGroup.ClearBattleStations();
                    Event.current.Use();
                }
                GUI.DrawTexture(clearRect, Textures.WorkButtonHover);
            }

            var upgradeArmorRect = new Rect(zero.x - 8f, rect.height / 1.76f, Textures.UpgradeArmorIcon.width, Textures.UpgradeArmorIcon.height);

            GUI.DrawTexture(upgradeArmorRect, Textures.UpgradeArmorIcon);
            TooltipHandler.TipRegion(upgradeArmorRect, Strings.UpgradeArmorTooltip);

            if (Mouse.IsOver(upgradeArmorRect))
            {
                GUI.DrawTexture(upgradeArmorRect, Textures.UpgradeIconHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_UpgradeArmorWeaponsSFX.PlayOneShotOnCamera();
                    foreach (var pawn in this.colonistGroup.ActivePawns)
                    {
                        var thing = TacticUtils.PickBestArmorFor(pawn);
                        if (thing != null)
                        {
                            var job = JobMaker.MakeJob(JobDefOf.Wear, thing);
                            job.locomotionUrgency = LocomotionUrgency.Sprint;
                            pawn.jobs.TryTakeOrderedJob(job);
                        }
                    }
                    Event.current.Use();
                }
            }

            var takeBuffRect = new Rect(upgradeArmorRect.x + 56, upgradeArmorRect.y, Textures.TakeBuffButton.width, Textures.TakeBuffButton.height);

            GUI.DrawTexture(takeBuffRect, Textures.TakeBuffButton);
            TooltipHandler.TipRegion(takeBuffRect, Strings.TakeBuffTooltip);
            if (Mouse.IsOver(takeBuffRect))
            {
                GUI.DrawTexture(takeBuffRect, Textures.TakeBuffButtonHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_TakeBuffSFX.PlayOneShotOnCamera();
                    foreach (var pawn in this.colonistGroup.ActivePawns)
                    {
                        var jbg    = new JobGiver_TakeCombatEnhancingDrug();
                        var result = jbg.TryIssueJobPackage(pawn, default(JobIssueParams));
                        if (result.Job != null)
                        {
                            pawn.jobs.TryTakeOrderedJob(result.Job);
                        }
                    }
                    Event.current.Use();
                }
            }

            var upgradeWeaponRect = new Rect((rect.x + rect.width) - (20 + Textures.UpgradeWeaponIcon.width), upgradeArmorRect.y, Textures.UpgradeWeaponIcon.width, Textures.UpgradeWeaponIcon.height);

            GUI.DrawTexture(upgradeWeaponRect, Textures.UpgradeWeaponIcon);
            TooltipHandler.TipRegion(upgradeWeaponRect, Strings.UpgradeWeaponTooltip);
            if (Mouse.IsOver(upgradeWeaponRect))
            {
                GUI.DrawTexture(upgradeWeaponRect, Textures.UpgradeIconHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_UpgradeWeaponSFX.PlayOneShotOnCamera();
                    foreach (var pawn in this.colonistGroup.ActivePawns)
                    {
                        var thing = TacticUtils.PickBestWeaponFor(pawn);
                        if (thing != null)
                        {
                            if (pawn.inventory?.innerContainer?.InnerListForReading?.Contains(thing) ?? false)
                            {
                                TacticUtils.TrySwitchToWeapon(thing as ThingWithComps, pawn);
                            }
                            else if (thing != pawn.equipment?.Primary)
                            {
                                var job = JobMaker.MakeJob(JobDefOf.Equip, thing);
                                job.locomotionUrgency = LocomotionUrgency.Sprint;
                                pawn.jobs.TryTakeOrderedJob(job);
                            }
                        }
                    }
                    Event.current.Use();
                }
            }

            var totalArmorRect = new Rect(rect.x + 10f, rect.height - 43, Textures.ArmorIcon.width, Textures.ArmorIcon.height);

            GUI.DrawTexture(totalArmorRect, Textures.ArmorIcon);
            Text.Anchor = TextAnchor.LowerLeft;
            var totalArmorLabel = new Rect(totalArmorRect.x + totalArmorRect.width + 2, totalArmorRect.y - 3, 30, 24);
            var armorValues     = new List <float>();

            foreach (var pawn in this.colonistGroup.ActivePawns)
            {
                if (pawn.apparel.WornApparel != null)
                {
                    var armorValue = TacticUtils.OverallArmorValue(pawn);
                    armorValues.Add(armorValue);
                }
            }
            var averageArmor = armorValues.Sum() / this.colonistGroup.ActivePawns.Count();

            Widgets.Label(totalArmorLabel, averageArmor.ToStringDecimalIfSmall());
            TooltipHandler.TipRegion(totalArmorLabel, Strings.ArmorTooltip);

            Text.Anchor = TextAnchor.MiddleCenter;
            var totalDPSLabel = new Rect(totalArmorRect.x + totalArmorRect.width + 50, totalArmorRect.y - 3, 30, 24);
            var dpsValues     = new List <float>();

            foreach (var pawn in this.colonistGroup.ActivePawns)
            {
                if (pawn.equipment.Primary != null)
                {
                    dpsValues.Add(TacticUtils.WeaponScoreGain(pawn.equipment.Primary));
                }
                else
                {
                    dpsValues.Add(pawn.GetStatValue(StatDefOf.MeleeDPS));
                }
            }

            var averageDPS = dpsValues.Average();

            Widgets.Label(totalDPSLabel, averageDPS.ToStringDecimalIfSmall());
            TooltipHandler.TipRegion(totalDPSLabel, Strings.DPSTooltip);
            var rankTexture = GetCurRank(averageDPS + averageArmor);
            var rankRect    = new Rect((rect.x + rect.width) - (rankTexture.width + 12f), totalArmorRect.y - 10f, rankTexture.width, rankTexture.height);

            GUI.DrawTexture(rankRect, rankTexture);
            TooltipHandler.TipRegion(rankRect, Strings.RankTooltip);
            Text.Anchor = TextAnchor.UpperLeft;
        }
예제 #11
0
        public override void DoWindowContents(Rect rect)
        {
            base.DoWindowContents(rect);
            Text.Font = GameFont.Small;
            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);

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

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

            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 += 30f;
            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, 100f);

            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.ColonistBarSpacing + ": " + (int)TacticalGroupsSettings.ColonistBarSpacing);
            leftHalf.y += 25f;
            TacticalGroupsSettings.ColonistBarSpacing = Widgets.HorizontalSlider(new Rect(rect.x + 20, leftHalf.y, textFieldWidth, 25f), TacticalGroupsSettings.ColonistBarSpacing, 0f, 100f);

            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 += 95f;
            Widgets.Checkbox(middle, ref TacticalGroupsSettings.DisplayColorBars);
            Widgets.Label(new Rect(xMiddlePos, middle.y, textFieldWidth, 25f), Strings.DisplayColorBars);

            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;
            }

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


            middle.y += 70f;
            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 += 50f;
            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, 1f);
            rightHalf.y += 25f;
            TacticalGroupsSettings.PawnScale = Widgets.HorizontalSlider(new Rect(xRightPos, rightHalf.y, textFieldWidth, 25f), TacticalGroupsSettings.PawnScale, 0f, 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, 0f, 300f);
            rightHalf.y += 25f;
            TacticalGroupsSettings.PawnBoxWidth = Widgets.HorizontalSlider(new Rect(xRightPos, rightHalf.y, textFieldWidth, 25f), TacticalGroupsSettings.PawnBoxWidth, 0f, 300f);

            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, 0, 100);
            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;
            }

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

            TacticalGroupsMod.instance.WriteSettings();
            TacticUtils.TacticalColonistBar.MarkColonistsDirty();
        }
예제 #12
0
        private void CalculateDrawLocs(List <Rect> outDrawLocs, float scale, bool onlyOneRow, int maxPerGlobalRow)
        {
            outDrawLocs.Clear();
            int num = maxPerGlobalRow;

            if (onlyOneRow)
            {
                for (int i = 0; i < horizontalSlotsPerGroup.Count; i++)
                {
                    horizontalSlotsPerGroup[i] = Mathf.Min(horizontalSlotsPerGroup[i], entriesInGroup[i]);
                }
                num = TacticUtils.TacticalColonistBar.Entries.Count;
            }
            int   num2 = CalculateGroupsCount();
            float num3 = (TacticalColonistBar.BaseSize.x + TacticalGroupsSettings.ColonistBarSpacingX) * scale;
            float num4 = ((float)num * num3 + (float)(num2 - 1) * 25f * scale);

            if (!TacticalGroupsSettings.HideGroups)
            {
                if (!WorldRendererUtility.WorldRenderedNow)
                {
                    var activeColony = TacticUtils.AllColonyGroups.FirstOrDefault(x => x.Map == Find.CurrentMap);
                    if (activeColony != null)
                    {
                        num4 += TacticUtils.GetAllPawnGroupFor(activeColony).Take(TacticalGroupsSettings.GroupRowCount).Sum(x => x.GroupIconWidth + x.GroupIconMargin);
                        num4 += TacticUtils.GetAllSubGroupFor(activeColony).Take(TacticalGroupsSettings.SubGroupRowCount).Sum(x => x.GroupIconWidth + x.GroupIconMargin);
                    }
                }
            }

            List <TacticalColonistBar.Entry> entries = TacticUtils.TacticalColonistBar.Entries;
            int   num5 = -1;
            int   num6 = -1;
            float num7 = ((float)UI.screenWidth - num4) / 2f;

            num7 += TacticalGroupsSettings.ColonistBarPositionX;
            bool createGroupAssigned = false;

            for (int j = 0; j < entries.Count; j++)
            {
                if (num5 != entries[j].group)
                {
                    if (num5 >= 0)
                    {
                        num7 += 25f * scale;
                        num7 += ((float)GetHorizontalSlotsPerGroup(num5)) * scale * (TacticalColonistBar.BaseSize.x + TacticalGroupsSettings.ColonistBarSpacingX);
                    }
                    if (!TacticalGroupsSettings.HideGroups)
                    {
                        if (entries[j].caravanGroup != null)
                        {
                            caravanGroupDrawLoc.Add(new MappedValue(entries[j].caravanGroup, new Rect(num7 - (25f * scale), TacticalGroupsSettings.ColonistBarPositionY,
                                                                                                      entries[j].caravanGroup.GroupIconWidth, entries[j].caravanGroup.GroupIconHeight)));
                            num7 += entries[j].caravanGroup.GroupIconWidth;
                        }
                        else if (entries[j].colonyGroup != null)
                        {
                            if (entries[j].colonyGroup.Map == Find.CurrentMap)
                            {
                                if (!WorldRendererUtility.WorldRenderedNow)
                                {
                                    var list = TacticUtils.GetAllSubGroupFor(entries[j].colonyGroup);
                                    if (list.Any())
                                    {
                                        list.Reverse();
                                        var initPos = num7;
                                        var xPos    = num7;
                                        var yPos    = TacticalGroupsSettings.ColonistBarPositionY;
                                        for (var groupID = 0; groupID < list.Count(); groupID++)
                                        {
                                            if (groupID > 0 && groupID % TacticalGroupsSettings.SubGroupRowCount == 0)
                                            {
                                                xPos  = initPos;
                                                yPos += list[groupID].GroupIconHeight + 7;
                                            }
                                            pawnGroupDrawLoc.Add(new MappedValue(list[groupID], new Rect(xPos, yPos, list[groupID].GroupIconWidth, list[groupID].GroupIconHeight)));
                                            xPos += list[groupID].GroupIconWidth + 5;
                                        }
                                        list  = list.Take(TacticalGroupsSettings.SubGroupRowCount).ToList();
                                        num7 += list.Sum(x => x.GroupIconWidth + 5);
                                    }
                                }
                            }

                            colonyGroupDrawLoc.Add(new MappedValue(entries[j].colonyGroup, new Rect(num7, TacticalGroupsSettings.ColonistBarPositionY,
                                                                                                    entries[j].colonyGroup.GroupIconWidth, entries[j].colonyGroup.GroupIconHeight)));

                            num7 += entries[j].colonyGroup.GroupIconWidth + entries[j].colonyGroup.GroupIconMargin;
                            if (entries[j].colonyGroup.Map == Find.CurrentMap)
                            {
                                if (!WorldRendererUtility.WorldRenderedNow)
                                {
                                    var list = TacticUtils.GetAllPawnGroupFor(entries[j].colonyGroup);
                                    if (list.Any())
                                    {
                                        list.Reverse();
                                        var initPos = num7;
                                        var xPos    = num7;
                                        var yPos    = TacticalGroupsSettings.ColonistBarPositionY;
                                        for (var groupID = 0; groupID < list.Count(); groupID++)
                                        {
                                            if (groupID > 0 && groupID % TacticalGroupsSettings.GroupRowCount == 0)
                                            {
                                                xPos  = initPos;
                                                yPos += list[groupID].GroupIconHeight + 25;
                                            }
                                            pawnGroupDrawLoc.Add(new MappedValue(list[groupID], new Rect(xPos, yPos, list[groupID].GroupIconWidth, list[groupID].GroupIconHeight)));
                                            xPos += list[groupID].GroupIconWidth + list[groupID].GroupIconMargin;
                                        }
                                        list  = list.Take(TacticalGroupsSettings.GroupRowCount).ToList();
                                        num7 += list.Sum(x => x.GroupIconWidth + x.GroupIconMargin);
                                    }
                                }
                            }
                        }
                    }
                    if (entries[j].colonyGroup != null)
                    {
                        if (entries[j].colonyGroup?.Map == Find.CurrentMap)
                        {
                            createGroupRect     = new Rect(num7, TacticalGroupsSettings.ColonistBarPositionY, Textures.CreateGroupIcon.width, Textures.CreateGroupIcon.height);
                            num7               += Textures.CreateGroupIcon.width + 20f;
                            createGroupAssigned = true;
                        }
                    }
                    else if (!createGroupAssigned)
                    {
                        createGroupRect = new Rect(num7, TacticalGroupsSettings.ColonistBarPositionY, Textures.CreateGroupIcon.width, Textures.CreateGroupIcon.height);
                        num7           += Textures.CreateGroupIcon.width + 20f;
                    }
                    num6 = 0;
                    num5 = entries[j].group;
                }
                else
                {
                    num6++;
                }
                Vector2 drawLoc = GetDrawLoc(num7, TacticalGroupsSettings.ColonistBarPositionY, entries[j].group, num6, scale);
                outDrawLocs.Add(new Rect(drawLoc.x, drawLoc.y, TacticUtils.TacticalColonistBar.Size.x, TacticUtils.TacticalColonistBar.Size.y));
            }
        }