Exemplo n.º 1
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);
        }
Exemplo n.º 2
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;
        }