Exemple #1
0
        public SortMenu(TieredFloatMenu parentWindow, ColonistGroup colonistGroup, Rect originRect, Texture2D backgroundTexture)
            : base(parentWindow, colonistGroup, originRect, backgroundTexture)
        {
            this.options = new List <TieredFloatMenuOption>();

            var noneOption = new TieredFloatMenuOption("None".Translate(), null, Textures.AOMButton, Textures.AOMButtonHover, Textures.AOMButtonPress, TextAnchor.MiddleCenter, MenuOptionPriority.High, 0f);

            noneOption.action = delegate
            {
                TacticDefOf.TG_SortOptionsSFX.PlayOneShotOnCamera();
                this.colonistGroup.activeSortBy = SortBy.None;
            };
            noneOption.bottomIndent = Textures.MenuButton.height + 4;
            options.Add(noneOption);

            var nameOption = new TieredFloatMenuOption("TG.Name".Translate(), null, Textures.AOMButton, Textures.AOMButtonHover, Textures.AOMButtonPress, TextAnchor.MiddleCenter, MenuOptionPriority.High, 0f);

            nameOption.action = delegate
            {
                TacticDefOf.TG_SortOptionsSFX.PlayOneShotOnCamera();
                this.colonistGroup.activeSortBy = SortBy.Name;
                this.colonistGroup.InitSort(this.colonistGroup.activeSortBy);
            };
            nameOption.bottomIndent = Textures.MenuButton.height + 4;
            options.Add(nameOption);

            foreach (var skillDef in DefDatabase <SkillDef> .AllDefs)
            {
                AddSkillSortButton(skillDef);
            }
            for (int i = 0; i < options.Count; i++)
            {
                options[i].SetSizeMode(SizeMode);
            }
        }
Exemple #2
0
        public void AddIconWindow(TieredFloatMenuOption option)
        {
            MarkOptionAsSelected(option);
            TieredFloatMenu floatMenu = new IconMenu(this, colonistGroup, windowRect, Textures.IconMenu);

            OpenNewMenu(floatMenu);
        }
Exemple #3
0
        public WorkMenu(TieredFloatMenu parentWindow, ColonistGroup colonistGroup, Rect originRect, Texture2D backgroundTexture)
            : base(parentWindow, colonistGroup, originRect, backgroundTexture)
        {
            this.options = new List <TieredFloatMenuOption>();

            var takeFive = new TieredFloatMenuOption(Strings.TakeFive, null, Textures.LookBusyButton, Textures.LookBusyButtonHover, null, TextAnchor.MiddleCenter, MenuOptionPriority.High, 0f,
                                                     Textures.LookBusyButton.width - 2f, Strings.TakeFiveTooltip);

            takeFive.action = delegate
            {
                TacticDefOf.TG_ClickSFX.PlayOneShotOnCamera();
                WorkSearchUtility.TakeABreak(BreakType.None, this.colonistGroup.ActivePawns);
            };
            options.Add(takeFive);

            breakIconStates[Textures.ChowHallButton]  = BreakType.ChowHall;
            breakIconStates[Textures.LightsOutButton] = BreakType.LightsOut;

            tooltips[Textures.ChowHallButton]  = Strings.ChowHallToolTip;
            tooltips[Textures.LightsOutButton] = Strings.SleepTooltip;

            for (int i = 0; i < options.Count; i++)
            {
                options[i].SetSizeMode(SizeMode);
            }
        }
Exemple #4
0
        public override void DoWindowContents(Rect rect)
        {
            base.DoWindowContents(rect);
            Vector2 zero          = Vector2.zero;
            Rect    groupNameRect = new Rect(zero.x, zero.y + 20f, rect.width, 30f);

            Text.Anchor = TextAnchor.MiddleCenter;
            var font = Text.Font;

            Text.Font = GameFont.Medium;
            Widgets.Label(groupNameRect, this.colonistGroup.curGroupName);
            Text.Font   = font;
            Text.Anchor = TextAnchor.UpperLeft;
            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;
            }
            DrawExtraGui(rect);
            GUI.color = Color.white;
        }
Exemple #5
0
        public void AddRenameWindow(TieredFloatMenuOption option)
        {
            MarkOptionAsSelected(option);
            TieredFloatMenu floatMenu = new Dialog_RenameColonistGroup(this, this.colonistGroup, windowRect, Textures.RenameTab, option, "OK".Translate());

            OpenNewMenu(floatMenu);
        }
Exemple #6
0
        public void AddOrderWindow(TieredFloatMenuOption option)
        {
            MarkOptionAsSelected(option);
            var             rect      = new Rect(windowRect.x, windowRect.y + 30, windowRect.width, windowRect.height);
            TieredFloatMenu floatMenu = new OrderMenu(this, colonistGroup, rect, Textures.OrdersDropMenu);

            OpenNewMenu(floatMenu);
        }
Exemple #7
0
        public void AddManageWindow(TieredFloatMenuOption option)
        {
            MarkOptionAsSelected(option);
            var             rect      = new Rect(windowRect.x, windowRect.y + 30, windowRect.width, windowRect.height);
            TieredFloatMenu floatMenu = new ManageMenu(this, colonistGroup, rect, (this.colonistGroup.isColonyGroup || this.colonistGroup.isTaskForce) ? Textures.ColonyManageDropMenu : Textures.ManageDropMenu);

            OpenNewMenu(floatMenu);
        }
Exemple #8
0
        public Dialog_RenameColonistGroup(TieredFloatMenu parentWindow, ColonistGroup colonistGroup, Rect originRect, Texture2D backgroundTexture, TieredFloatMenuOption option, string confirmationText)
            : base(parentWindow, colonistGroup, originRect, backgroundTexture, confirmationText)
        {
            this.originRect    = new Rect(originRect.x + originRect.width, originRect.y, originRect.width, originRect.height);
            this.colonistGroup = colonistGroup;

            curName     = colonistGroup.groupName;
            this.option = option;
        }
Exemple #9
0
 public void AddWorkWindow(TieredFloatMenuOption option)
 {
     MarkOptionAsSelected(option);
     if (this.colonistGroup.pawns.Any())
     {
         var             rect      = new Rect(windowRect.x, windowRect.y + 30, windowRect.width, windowRect.height);
         TieredFloatMenu floatMenu = new WorkMenu(this, colonistGroup, rect, Textures.ActionsMenuDrop);
         OpenNewMenu(floatMenu);
     }
 }
Exemple #10
0
        public void AddManageButton()
        {
            var option = new TieredFloatMenuOption(Strings.Manage, null, Textures.AOMButton, Textures.AOMButtonHover, Textures.AOMButtonPress, TextAnchor.MiddleLeft, MenuOptionPriority.High, 5f);

            option.action = delegate
            {
                AddManageWindow(option);
            };
            options.Add(option);
        }
Exemple #11
0
        public void AddDiplomacyButton()
        {
            var option = new TieredFloatMenuOption(Strings.Diplomacy, null, Textures.MenuButton, Textures.MenuButtonHover, Textures.MenuButtonPress, TextAnchor.MiddleCenter, MenuOptionPriority.High, 0f);

            option.action = delegate
            {
                Find.MainTabsRoot.ToggleTab(MainButtonDefOf.Factions);
            };
            option.bottomIndent = Textures.MenuButton.height + 5;
            options.Add(option);
        }
Exemple #12
0
 public void MarkOptionAsSelected(TieredFloatMenuOption option)
 {
     option.selected = true;
     foreach (var otherOption in options)
     {
         if (otherOption != option)
         {
             otherOption.selected = false;
         }
     }
 }
Exemple #13
0
        public void AddOrderButton()
        {
            var option = new TieredFloatMenuOption(Strings.Orders, null, Textures.AOMButton, Textures.AOMButtonHover, Textures.AOMButtonPress, TextAnchor.MiddleLeft, MenuOptionPriority.High, 5f);

            option.action = delegate
            {
                AddOrderWindow(option);
            };
            option.bottomIndent = Textures.AOMButton.height;
            options.Add(option);
        }
Exemple #14
0
        public void AddIconButton()
        {
            var option = new TieredFloatMenuOption(Strings.Icon, null, Textures.MenuButton, Textures.MenuButtonHover, Textures.MenuButtonPress, TextAnchor.MiddleCenter, MenuOptionPriority.High, 0f);

            option.action = delegate
            {
                AddIconWindow(option);
            };
            option.bottomIndent = Textures.MenuButton.height + 17;
            options.Add(option);
        }
Exemple #15
0
        public void AddRallyButton()
        {
            var option = new TieredFloatMenuOption(Strings.Rally, null, Textures.RallyButton, Textures.RallyButtonHover, null, TextAnchor.MiddleCenter, MenuOptionPriority.High, 10f, -1f, Strings.RallyToolTip);

            option.bottomIndent = 41;
            option.action       = delegate
            {
                TacticDefOf.TG_RallySFX.PlayOneShotOnCamera();
                Find.Selector.ClearSelection();
                foreach (var pawn in this.colonistGroup.ActivePawns)
                {
                    Find.Selector.Select(pawn);
                    pawn.drafter.Drafted = true;
                }
                this.CloseAllWindows();
            };
            options.Add(option);
        }
        public void AddPursueFleeingButton()
        {
            var option = new TieredFloatMenuOption(Strings.PursueFleeing, null, Textures.LookBusyButton, Textures.LookBusyButtonHover, Textures.MenuButtonPress, TextAnchor.MiddleCenter,
                                                   MenuOptionPriority.High, 0f, -1f, Strings.PursueFleeingTooltip);

            option.action = delegate
            {
                TacticDefOf.TG_AttackOrdersSFX.PlayOneShotOnCamera();
                this.colonistGroup.Draft();
                this.colonistGroup.SelectAll();
                this.colonistGroup.SwitchToAttackMode();
                this.colonistGroup.RemoveOldLord();
                var targets = this.colonistGroup.Map.attackTargetsCache.GetPotentialTargetsFor(this.colonistGroup.ActivePawns.First()).Where(x => !x.Thing.Fogged()).Select(x => x.Thing).ToList();
                LordMaker.MakeNewLord(Faction.OfPlayer, new LordJob_AssaultThingsPursueFleeing(Faction.OfPlayer, targets, 0, true), this.colonistGroup.Map, this.colonistGroup.ActivePawns);
                this.colonistGroup.SearchForJob();
                this.CloseAllWindows();
            };
            option.bottomIndent = Textures.MenuButton.height;
            options.Add(option);
        }
Exemple #17
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, floatMenuOption.curIcon.width, floatMenuOption.curIcon.height);
                if (floatMenuOption.DoGUI(rect2, this))
                {
                    Find.WindowStack.TryRemove(this);
                    break;
                }
                zero.y += floatMenuOption.bottomIndent;
            }
            DrawExtraGui(rect);
            GUI.color = Color.white;
        }
Exemple #18
0
        public void AddBattleStationsButton()
        {
            var option = new TieredFloatMenuOption(Strings.BattleStations, null, Textures.MenuButton, Textures.MenuButtonHover, Textures.MenuButtonPress, TextAnchor.MiddleCenter, MenuOptionPriority.High, 0f, -1f, Strings.BattleStationsTooltip);

            option.action = delegate
            {
                TacticDefOf.TG_BattleStationsSFX.PlayOneShotOnCamera();
                foreach (var pawn in this.colonistGroup.ActivePawns)
                {
                    this.colonistGroup.Draft();
                    this.colonistGroup.SelectAll();
                    if (this.colonistGroup.activeFormation.formations.TryGetValue(pawn, out IntVec3 cell))
                    {
                        var job = JobMaker.MakeJob(JobDefOf.Goto, cell);
                        job.locomotionUrgency = LocomotionUrgency.Sprint;
                        pawn.jobs.TryTakeOrderedJob(job);
                    }
                }
            };
            option.bottomIndent = Textures.MenuButton.height + 145;
            options.Add(option);
        }
        public void AddFireAtWillButton()
        {
            var option = new TieredFloatMenuOption(Strings.FireAtWill, null, Textures.LookBusyButton, Textures.LookBusyButtonHover, Textures.MenuButtonPress, TextAnchor.MiddleCenter,
                                                   MenuOptionPriority.High, 0f, -1f, Strings.FireAtWillTooltip);

            option.action = delegate
            {
                this.colonistGroup.Draft();
                foreach (var pawn in this.colonistGroup.ActivePawns)
                {
                    if (pawn.drafter != null)
                    {
                        pawn.drafter.FireAtWill = true;
                    }
                }
                this.colonistGroup.SelectAll();
                this.colonistGroup.RemoveOldLord();
                TacticDefOf.TG_AttackOrdersSFX.PlayOneShotOnCamera();
                this.CloseAllWindows();
            };
            option.bottomIndent = Textures.MenuButton.height + 30;
            options.Add(option);
        }
Exemple #20
0
        public void AddRegroupButton()
        {
            var option = new TieredFloatMenuOption(Strings.Regroup, null, Textures.MenuButton, Textures.MenuButtonHover, Textures.MenuButtonPress,
                                                   TextAnchor.MiddleCenter, MenuOptionPriority.High, 0f, -1f, Strings.RegroupTooltip);

            option.action = delegate
            {
                TacticDefOf.TG_RegroupSFX.PlayOneShotOnCamera();
                this.colonistGroup.RemoveOldLord();
                this.colonistGroup.Draft();
                var firstPawn = this.colonistGroup.ActivePawns.First();
                foreach (var pawn in this.colonistGroup.ActivePawns)
                {
                    if (pawn != null)
                    {
                        var job = JobMaker.MakeJob(JobDefOf.Goto, firstPawn);
                        job.locomotionUrgency = LocomotionUrgency.Sprint;
                        pawn.jobs.TryTakeOrderedJob(job);
                    }
                }
            };
            option.bottomIndent = Textures.MenuButton.height + 25;
            options.Add(option);
        }
Exemple #21
0
        public void AddMedicalButton()
        {
            var option = new TieredFloatMenuOption(Strings.ReportToMedical, null, Textures.LookBusyButton, Textures.LookBusyButtonHover, Textures.MenuButtonPress, TextAnchor.MiddleCenter,
                                                   MenuOptionPriority.High, 0f, -1f, Strings.ReportToMedicalTooltip);

            option.action = delegate
            {
                JobGiver_PatientGoToBed jgp = new JobGiver_PatientGoToBed
                {
                    respectTimetable = false
                };
                foreach (var pawn in this.colonistGroup.ActivePawns)
                {
                    ThinkResult thinkResult = jgp.TryIssueJobPackage(pawn, default(JobIssueParams));
                    if (thinkResult.IsValid)
                    {
                        pawn.jobs.TryTakeOrderedJob(thinkResult.Job);
                    }
                }
                TacticDefOf.TG_ClickSFX.PlayOneShotOnCamera();
            };
            option.bottomIndent = Textures.MenuButton.height + 25;
            options.Add(option);
        }
Exemple #22
0
 public virtual void PreOptionChosen(TieredFloatMenuOption opt)
 {
 }
Exemple #23
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 getBreakIconRect = new Rect(rect.x + zero.x, rect.y + 475f, rect.width, rect.height);
            var iconRows         = GetBreakIconRows(2);

            for (var i = 0; i < iconRows.Count; i++)
            {
                for (var j = 0; j < iconRows[i].Count; j++)
                {
                    Rect iconRect = new Rect(getBreakIconRect.x + (j * iconRows[i][j].width) + j * 10, getBreakIconRect.y + (i * iconRows[i][j].height) + i * 7,
                                             iconRows[i][j].width, iconRows[i][j].height);
                    GUI.DrawTexture(iconRect, iconRows[i][j]);
                    TooltipHandler.TipRegion(iconRect, tooltips[iconRows[i][j]]);

                    if (Mouse.IsOver(iconRect))
                    {
                        GUI.DrawTexture(iconRect, Textures.WorkButtonHover);
                        if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                        {
                            if (breakIconStates[iconRows[i][j]] == BreakType.LightsOut)
                            {
                                TacticDefOf.TG_LightsOutSFX.PlayOneShotOnCamera();
                            }
                            else if (breakIconStates[iconRows[i][j]] == BreakType.ChowHall)
                            {
                                TacticDefOf.TG_ChowTimeSFX.PlayOneShotOnCamera();
                            }
                            WorkSearchUtility.TakeABreak(breakIconStates[iconRows[i][j]], this.colonistGroup.ActivePawns);
                            Event.current.Use();
                        }
                    }
                }
            }

            var workRows     = GetWorkTypeRows(2);
            var initialRect  = new Rect(rect.x, rect.y + 75, 320, rect.height - 95);
            var workMenuRect = new Rect(initialRect);

            workMenuRect.height -= 103;
            var resetWorkPriorities = new Rect(workMenuRect.x + 20, rect.y + 32, Textures.ResetIcon.width, Textures.ResetIcon.height);

            GUI.DrawTexture(resetWorkPriorities, Textures.ResetIcon);
            if (Mouse.IsOver(resetWorkPriorities))
            {
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    this.colonistGroup.groupWorkPriorities?.Clear();
                    Event.current.Use();
                }
                TooltipHandler.TipRegion(resetWorkPriorities, Strings.GroupWorkPrioritiesReset);
            }

            var manualPrioritiesRect = new Rect(resetWorkPriorities.xMax + 10, rect.y + 30, 162, 40);

            DoManualPrioritiesCheckbox(manualPrioritiesRect);
            float listHeight   = workRows.Count * 33 + (workRows.Count * 2);
            Rect  workCellRect = new Rect(0f, 0f, workMenuRect.width - 16f, listHeight);

            Widgets.BeginScrollView(workMenuRect, ref scrollPosition, workCellRect);

            for (var i = 0; i < workRows.Count; i++)
            {
                for (var j = 0; j < workRows[i].Count; j++)
                {
                    Rect      workTypeRect = new Rect(workCellRect.x + (j * 72) + (j * 72) + 17.5f, (workCellRect.y + (i * 17) + (i * 17)) + 8, Textures.WorkSelectEmpty.width, Textures.WorkSelectEmpty.height);
                    var       workDictData = this.colonistGroup.activeWorkTypes.FirstOrDefault(x => x.Key.workTypeDef == workRows[i][j]);
                    WorkState workState;
                    if (workDictData.Key != null)
                    {
                        workState = workDictData.Value;
                    }
                    else
                    {
                        workState = WorkState.Inactive;
                    }

                    switch (workState)
                    {
                    case WorkState.Temporary:
                    case WorkState.Inactive:
                        GUI.DrawTexture(workTypeRect, Textures.WorkSelectEmpty);
                        TooltipHandler.TipRegion(workTypeRect, Strings.WorkTypeLeftClickToApply);
                        break;

                    case WorkState.Active:
                        GUI.DrawTexture(workTypeRect, Textures.WorkSelectBlue);
                        TooltipHandler.TipRegion(workTypeRect, Strings.WorkTypeForcedLabor);
                        break;

                    case WorkState.ForcedLabor:
                        GUI.DrawTexture(workTypeRect, Textures.WorkSelectRed);
                        TooltipHandler.TipRegion(workTypeRect, Strings.WorkTypeSlaveLabor);
                        break;
                    }

                    if (Mouse.IsOver(workTypeRect))
                    {
                        if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                        {
                            WorkSearchUtility.SearchForWork(workRows[i][j], this.colonistGroup.pawns);
                            this.colonistGroup.ChangeWorkState(workRows[i][j]);
                            Event.current.Use();
                        }
                    }
                    Rect workRect = new Rect(workTypeRect.xMax + 5, workTypeRect.y - 8, 24, 24);
                    this.DoWorkCell(workRect, workRows[i][j]);
                    this.DoWorkHeader(workRect, workRows[i][j]);
                }
            }
            Widgets.EndScrollView();
            DrawExtraGui(rect);

            var caravanButtonRect = new Rect(manualPrioritiesRect.xMax + 5, rect.y + 23, Textures.CaravanButton.width, Textures.CaravanButton.height);

            GUI.DrawTexture(caravanButtonRect, Textures.CaravanButton);
            if (Mouse.IsOver(caravanButtonRect))
            {
                GUI.DrawTexture(caravanButtonRect, Textures.CaravanHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_WorkSFX.PlayOneShotOnCamera();

                    var floatMenu = new CaravanMenu(this, this.colonistGroup, this.windowRect, Textures.CaravanMenu);
                    this.OpenNewMenu(floatMenu);
                    Event.current.Use();
                }
            }


            var researchMenuRect = new Rect(rect.x + 253, rect.y + 459, Textures.ResearchWorkButton.width, Textures.ResearchWorkButton.height);

            GUI.DrawTexture(researchMenuRect, Textures.ResearchMenuButton);
            if (Mouse.IsOver(researchMenuRect))
            {
                GUI.DrawTexture(researchMenuRect, Textures.ResearchHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_ClickSFX.PlayOneShotOnCamera();
                    Find.MainTabsRoot.ToggleTab(MainButtonDefOf.Research);
                    Event.current.Use();
                }
            }
            TooltipHandler.TipRegion(researchMenuRect, Strings.WorkTaskTooltipResearchMenu);
            GUI.color = Color.white;
        }
Exemple #24
0
        public WorkMenu(TieredFloatMenu parentWindow, ColonistGroup colonistGroup, Rect originRect, Texture2D backgroundTexture)
            : base(parentWindow, colonistGroup, originRect, backgroundTexture)
        {
            this.options = new List <TieredFloatMenuOption>();

            var lookBusy = new TieredFloatMenuOption(Strings.LookBusy, null, Textures.LookBusyButton, Textures.LookBusyButtonHover, null, TextAnchor.MiddleCenter,
                                                     MenuOptionPriority.High, 0f, Textures.LookBusyButton.width - 2f, Strings.LookBusyTooltip);

            lookBusy.action = delegate
            {
                TacticDefOf.TG_WorkSFX.PlayOneShotOnCamera();
                WorkSearchUtility.SearchForWork(WorkType.None, this.colonistGroup.ActivePawns);
            };
            lookBusy.bottomIndent = 400f;
            options.Add(lookBusy);

            var takeFive = new TieredFloatMenuOption(Strings.TakeFive, null, Textures.LookBusyButton, Textures.LookBusyButtonHover, null, TextAnchor.MiddleCenter, MenuOptionPriority.High, 0f,
                                                     Textures.LookBusyButton.width - 2f, Strings.TakeFiveTooltip);

            takeFive.action = delegate
            {
                TacticDefOf.TG_ClickSFX.PlayOneShotOnCamera();
                WorkSearchUtility.TakeABreak(BreakType.None, this.colonistGroup.ActivePawns);
            };
            options.Add(takeFive);

            workIconStates[Textures.ConstructButton] = WorkType.Construction;
            workIconStates[Textures.CraftButton]     = WorkType.Crafting;
            workIconStates[Textures.HaulButton]      = WorkType.Hauling;
            workIconStates[Textures.CleanButton]     = WorkType.Cleaning;
            workIconStates[Textures.HuntButton]      = WorkType.Hunting;
            workIconStates[Textures.CookButton]      = WorkType.Cooking;
            workIconStates[Textures.MineButton]      = WorkType.Mining;
            workIconStates[Textures.ChopWoodButton]  = WorkType.WoodChopping;

            workIconStates[Textures.TailorButton]         = WorkType.Tailor;
            workIconStates[Textures.SmithButton]          = WorkType.Smith;
            workIconStates[Textures.FireExtinguishButton] = WorkType.FireExtinguish;
            workIconStates[Textures.ArtButton]            = WorkType.Art;

            workIconStates[Textures.FarmButton]      = WorkType.Plants;
            workIconStates[Textures.HandleButton]    = WorkType.Handle;
            workIconStates[Textures.WardenButton]    = WorkType.Warden;
            workIconStates[Textures.ClearSnowButton] = WorkType.ClearSnow;

            breakIconStates[Textures.ChowHallButton]  = BreakType.ChowHall;
            breakIconStates[Textures.LightsOutButton] = BreakType.LightsOut;

            tooltips[Textures.ConstructButton] = Strings.WorkTaskTooltipConstruction;
            tooltips[Textures.CraftButton]     = Strings.WorkTaskTooltipCraft;
            tooltips[Textures.HaulButton]      = Strings.WorkTaskTooltipHaul;
            tooltips[Textures.CleanButton]     = Strings.WorkTaskTooltipClean;
            tooltips[Textures.HuntButton]      = Strings.WorkTaskTooltipHunt;
            tooltips[Textures.CookButton]      = Strings.WorkTaskTooltipCook;
            tooltips[Textures.MineButton]      = Strings.WorkTaskTooltipMine;
            tooltips[Textures.ChopWoodButton]  = Strings.WorkTaskTooltipChopWood;
            tooltips[Textures.FarmButton]      = Strings.WorkTaskTooltipFarm;
            tooltips[Textures.ClearSnowButton] = Strings.WorkTaskTooltipClearSnow;
            tooltips[Textures.WardenButton]    = Strings.WorkTaskTooltipWarden;

            tooltips[Textures.TailorButton]         = Strings.WorkTaskTooltipTailor;
            tooltips[Textures.SmithButton]          = Strings.WorkTaskTooltipSmith;
            tooltips[Textures.HandleButton]         = Strings.WorkTaskTooltipHandle;
            tooltips[Textures.FireExtinguishButton] = Strings.WorkTaskTooltipFireExtinguish;
            tooltips[Textures.ArtButton]            = Strings.WorkTaskTooltipArt;

            tooltips[Textures.ChowHallButton]  = Strings.ChowHallToolTip;
            tooltips[Textures.LightsOutButton] = Strings.SleepTooltip;


            for (int i = 0; i < options.Count; i++)
            {
                options[i].SetSizeMode(SizeMode);
            }
        }
Exemple #25
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 rect3    = new Rect(rect.x + zero.x, rect.y + 75f, rect.width, rect.height);
            var iconRows = GetWorkIconRows(2);

            for (var i = 0; i < iconRows.Count; i++)
            {
                for (var j = 0; j < iconRows[i].Count; j++)
                {
                    Rect iconRect = new Rect(rect3.x + (j * iconRows[i][j].width) + j * 10, rect3.y + (i * iconRows[i][j].height) + i * 7,
                                             iconRows[i][j].width, iconRows[i][j].height);
                    GUI.DrawTexture(iconRect, iconRows[i][j]);
                    if (this.colonistGroup.activeWorkTypes.TryGetValue(workIconStates[iconRows[i][j]], out WorkState state2))
                    {
                        if (state2 == WorkState.Active)
                        {
                            GUI.DrawTexture(iconRect, Textures.Clock);
                        }
                        else if (state2 == WorkState.ForcedLabor)
                        {
                            GUI.DrawTexture(iconRect, Textures.ClockSlave);
                        }
                    }
                    TooltipHandler.TipRegion(iconRect, tooltips[iconRows[i][j]] + "\n" + Strings.ForcedLaborTooltip);
                    if (Mouse.IsOver(iconRect))
                    {
                        GUI.DrawTexture(iconRect, Textures.WorkButtonHover);
                        if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                        {
                            this.colonistGroup.RemoveWorkState(workIconStates[iconRows[i][j]]);
                            TacticDefOf.TG_WorkSFX.PlayOneShotOnCamera();
                            WorkSearchUtility.SearchForWork(workIconStates[iconRows[i][j]], this.colonistGroup.ActivePawns);
                            Event.current.Use();
                        }
                        else if (Event.current.type == EventType.MouseDown && Event.current.button == 1 && Event.current.clickCount == 1)
                        {
                            this.colonistGroup.ChangeWorkState(workIconStates[iconRows[i][j]]);
                            if (this.colonistGroup.activeWorkTypes[workIconStates[iconRows[i][j]]] == WorkState.ForcedLabor)
                            {
                                TacticDefOf.TG_SlaveLaborSFX.PlayOneShotOnCamera();
                            }
                            else
                            {
                                TacticDefOf.TG_ClickSFX.PlayOneShotOnCamera();
                            }
                            WorkSearchUtility.SearchForWork(workIconStates[iconRows[i][j]], this.colonistGroup.ActivePawns);
                            Event.current.Use();
                        }
                    }
                }
            }

            var rect4     = new Rect(rect.x + zero.x, rect.y + 475f, rect.width, rect.height);
            var iconRows2 = GetBreakIconRows(2);

            for (var i = 0; i < iconRows2.Count; i++)
            {
                for (var j = 0; j < iconRows2[i].Count; j++)
                {
                    Rect iconRect = new Rect(rect4.x + (j * iconRows2[i][j].width) + j * 10, rect4.y + (i * iconRows2[i][j].height) + i * 7,
                                             iconRows2[i][j].width, iconRows2[i][j].height);
                    GUI.DrawTexture(iconRect, iconRows2[i][j]);
                    TooltipHandler.TipRegion(iconRect, tooltips[iconRows2[i][j]]);

                    if (Mouse.IsOver(iconRect))
                    {
                        GUI.DrawTexture(iconRect, Textures.WorkButtonHover);
                        if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                        {
                            if (breakIconStates[iconRows2[i][j]] == BreakType.LightsOut)
                            {
                                TacticDefOf.TG_LightsOutSFX.PlayOneShotOnCamera();
                            }
                            else if (breakIconStates[iconRows2[i][j]] == BreakType.ChowHall)
                            {
                                TacticDefOf.TG_ChowTimeSFX.PlayOneShotOnCamera();
                            }
                            WorkSearchUtility.TakeABreak(breakIconStates[iconRows2[i][j]], this.colonistGroup.ActivePawns);
                            Event.current.Use();
                        }
                    }
                }
            }

            var workRows     = GetWorkTypeRows(2);
            var initialRect  = new Rect((rect.x + rect.width) - 245, rect.y + 75, 240, rect.height - 95);
            var workMenuRect = new Rect(initialRect);

            workMenuRect.height -= 103;

            DoManualPrioritiesCheckbox(new Rect(workMenuRect.x, rect.y + 30, workMenuRect.width, 40));
            float listHeight = workRows.Count * 33 + (workRows.Count * 2);
            Rect  rect5      = new Rect(0f, 0f, workMenuRect.width - 16f, listHeight);

            Widgets.BeginScrollView(workMenuRect, ref scrollPosition, rect5);

            for (var i = 0; i < workRows.Count; i++)
            {
                for (var j = 0; j < workRows[i].Count; j++)
                {
                    Rect workRect = new Rect(rect5.x + (j * 20) + j * 91.5f, rect5.y + (i * 17) + i * 17, 24, 24);
                    this.DoWorkCell(workRect, workRows[i][j]);
                    this.DoWorkHeader(workRect, workRows[i][j]);
                }
            }
            Widgets.EndScrollView();
            DrawExtraGui(rect);


            var caravanButtonRect = new Rect(initialRect.x + 155, rect.y + 23, Textures.CaravanButton.width, Textures.CaravanButton.height);

            GUI.DrawTexture(caravanButtonRect, Textures.CaravanButton);
            if (Mouse.IsOver(caravanButtonRect))
            {
                GUI.DrawTexture(caravanButtonRect, Textures.CaravanHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_WorkSFX.PlayOneShotOnCamera();

                    var floatMenu = new CaravanMenu(this, this.colonistGroup, this.windowRect, Textures.CaravanMenu);
                    this.OpenNewMenu(floatMenu);
                    Event.current.Use();
                }
            }


            var researchWorkRect = new Rect(rect.x + 253, rect.y + 459, Textures.ResearchWorkButton.width, Textures.ResearchWorkButton.height);

            GUI.DrawTexture(researchWorkRect, Textures.ResearchWorkButton);
            if (this.colonistGroup.activeWorkTypes.TryGetValue(WorkType.Research, out WorkState state))
            {
                if (state == WorkState.Active)
                {
                    GUI.DrawTexture(researchWorkRect, Textures.Clock, ScaleMode.ScaleToFit);
                }
                else if (state == WorkState.ForcedLabor)
                {
                    GUI.DrawTexture(researchWorkRect, Textures.ClockSlave, ScaleMode.ScaleToFit);
                }
            }

            Text.Anchor = TextAnchor.MiddleCenter;
            var researchLabel = new Rect(researchWorkRect.x + 30, researchWorkRect.y - 25, 80, 24);

            Widgets.Label(researchLabel, Strings.WorkTaskTooltipResearch);
            Text.Anchor = TextAnchor.UpperLeft;

            TooltipHandler.TipRegion(researchWorkRect, Strings.WorkTaskTooltipResearch + "\n" + Strings.ForcedLaborTooltip);
            if (Mouse.IsOver(researchWorkRect))
            {
                GUI.DrawTexture(researchWorkRect, Textures.ResearchHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_ResearchSFX.PlayOneShotOnCamera();
                    this.colonistGroup.RemoveWorkState(WorkType.Research);
                    WorkSearchUtility.SearchForWork(WorkType.Research, this.colonistGroup.ActivePawns);
                    Event.current.Use();
                }
                else if (Event.current.type == EventType.MouseDown && Event.current.button == 1 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_ClickSFX.PlayOneShotOnCamera();
                    this.colonistGroup.ChangeWorkState(WorkType.Research);
                    WorkSearchUtility.SearchForWork(WorkType.Research, this.colonistGroup.ActivePawns);
                    Event.current.Use();
                }
            }
            var researchMenuRect = new Rect(researchWorkRect.x + 89, researchWorkRect.y, Textures.ResearchMenuButton.width, Textures.ResearchMenuButton.height);

            GUI.DrawTexture(researchMenuRect, Textures.ResearchMenuButton);
            if (Mouse.IsOver(researchMenuRect))
            {
                GUI.DrawTexture(researchMenuRect, Textures.ResearchHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_ClickSFX.PlayOneShotOnCamera();
                    Find.MainTabsRoot.ToggleTab(MainButtonDefOf.Research);
                    Event.current.Use();
                }
            }
            TooltipHandler.TipRegion(researchMenuRect, Strings.WorkTaskTooltipResearchMenu);
            GUI.color = Color.white;
        }
        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);
        }
        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;
            }
            DrawExtraGui(rect);

            var captureRect = new Rect(rect.x + 27, zero.y + 5, Textures.Arrest.width, Textures.Arrest.height);

            GUI.DrawTexture(captureRect, Textures.Arrest);
            TooltipHandler.TipRegion(captureRect, Strings.CaptureTooltip);
            if (Mouse.IsOver(captureRect))
            {
                GUI.DrawTexture(captureRect, Textures.RescueTendHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    var victims = this.colonistGroup.Map.mapPawns.AllPawns.Where(x => x.RaceProps.Humanlike).ToList();;
                    foreach (var pawn in this.colonistGroup.ActivePawns)
                    {
                        if (!pawn.Dead && !pawn.Downed && pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                        {
                            for (int num = victims.Count - 1; num >= 0; num--)
                            {
                                var victim = victims[num];
                                if (!victim.InBed() && !victim.mindState.WillJoinColonyIfRescued && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, ignoreOtherReservations: true))
                                {
                                    if (victim.InMentalState || victim.Faction != Faction.OfPlayer || (victim.Downed && (victim.guilt.IsGuilty || victim.IsPrisonerOfColony)))
                                    {
                                        var designation = victim.Map.designationManager.DesignationOn(victim);
                                        if (designation is null || designation.def.defName != "FinishOffDesignation")
                                        {
                                            Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, sleeperWillBePrisoner: true, checkSocialProperness: false);
                                            if (building_Bed == null)
                                            {
                                                building_Bed = RestUtility.FindBedFor(victim, pawn, sleeperWillBePrisoner: true, checkSocialProperness: false, ignoreOtherReservations: true);
                                            }
                                            if (building_Bed != null)
                                            {
                                                Job job = JobMaker.MakeJob(JobDefOf.Capture, victim, building_Bed);
                                                job.count = 1;
                                                pawn.jobs.TryTakeOrderedJob(job);
                                                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Capturing, KnowledgeAmount.Total);
                                                if (victim.Faction != null && victim.Faction != Faction.OfPlayer && !victim.Faction.Hidden && !victim.Faction.HostileTo(Faction.OfPlayer) && !victim.IsPrisonerOfColony)
                                                {
                                                    Messages.Message("MessageCapturingWillAngerFaction".Translate(victim.Named("PAWN")).AdjustedFor(victim), victim, MessageTypeDefOf.CautionInput, historical: false);
                                                }
                                                victims.RemoveAt(num);
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    TacticDefOf.TG_ArrestSFX.PlayOneShotOnCamera();
                }
            }

            var executeRect = new Rect(captureRect.xMax + 15, captureRect.y, Textures.Execute.width, Textures.Execute.height);

            GUI.DrawTexture(executeRect, Textures.Execute);
            TooltipHandler.TipRegion(executeRect, Strings.ExecuteTooltip);
            if (Mouse.IsOver(executeRect))
            {
                GUI.DrawTexture(executeRect, Textures.RescueTendHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    var victims = this.colonistGroup.Map.mapPawns.AllPawns.Where(x => x.RaceProps.Humanlike && x.Downed && x.HostileTo(Faction.OfPlayer)).ToList();
                    foreach (var pawn in this.colonistGroup.ActivePawns)
                    {
                        if (!pawn.Dead && !pawn.Downed && pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                        {
                            for (int num = victims.Count - 1; num >= 0; num--)
                            {
                                var victim = victims[num];
                                if (pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, ignoreOtherReservations: true))
                                {
                                    Job job = JobMaker.MakeJob(TacticDefOf.TG_ExecuteDownedRaiders, victim);
                                    job.count = 1;
                                    pawn.jobs.TryTakeOrderedJob(job);
                                    victims.RemoveAt(num);
                                    break;
                                }
                            }
                        }
                    }
                    TacticDefOf.TG_ExecuteSFX.PlayOneShotOnCamera();
                }
                GUI.color = Color.white;
            }
        }