public override void WorldComponentUpdate()
        {
            base.WorldComponentUpdate();
            if (Event.current.keyCode == TacticDefOf.TG_SlaveMenu.defaultKeyCodeB && Event.current.control)
            {
                if (Find.CurrentMap != null && colonyGroups.TryGetValue(Find.CurrentMap, out var colonyGroup))
                {
                    if (Find.WindowStack.WindowOfType <SlaveMenu>() is null)
                    {
                        Vector2 initialSize = new Vector2(Textures.SlaveMenu.width, Textures.SlaveMenu.height);
                        var     windowRect  = new Rect(((float)UI.screenWidth - initialSize.x) / 2f, ((float)UI.screenHeight - initialSize.y) / 2f, initialSize.x, initialSize.y);
                        windowRect = windowRect.Rounded();

                        SlaveMenu floatMenu = new SlaveMenu(null, colonyGroup, windowRect, Textures.SlaveMenu, Strings.Slaves);
                        Find.WindowStack.Add(floatMenu);
                    }
                }
            }
        }
Example #2
0
        public override void DoWindowContents(Rect rect)
        {
            base.DoWindowContents(rect);
            var prisonerButtonRect = new Rect(rect.x, rect.yMax - Textures.PrisonerButton.height, Textures.PrisonerButton.width, Textures.PrisonerButton.height);

            GUI.DrawTexture(prisonerButtonRect, Textures.PrisonerButton);
            TooltipHandler.TipRegion(prisonerButtonRect, Strings.PrisonerMenuTooltip);
            if (Mouse.IsOver(prisonerButtonRect))
            {
                GUI.DrawTexture(prisonerButtonRect, Textures.RescueTendHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_SlideMenuOptionSFX.PlayOneShotOnCamera();
                    if (this.childWindows?.Any() ?? false)
                    {
                        for (int num = this.childWindows.Count - 1; num >= 0; num--)
                        {
                            if (this.childWindows[num] is PrisonerMenu)
                            {
                                this.childWindows[num].Close();
                            }
                            else
                            {
                                this.childWindows[num].Close();
                                PrisonerMenu floatMenu = new PrisonerMenu(this, this.colonistGroup, windowRect, Textures.PrisonerMenu, Strings.Prisoners);
                                OpenNewMenu(floatMenu);
                            }
                        }
                    }
                    else
                    {
                        PrisonerMenu floatMenu = new PrisonerMenu(this, this.colonistGroup, windowRect, Textures.PrisonerMenu, Strings.Prisoners);
                        OpenNewMenu(floatMenu);
                    }
                }
            }

            var slaveButtonRect = new Rect(prisonerButtonRect.xMax + 5, rect.yMax - Textures.SlaveButton.height, Textures.SlaveButton.width, Textures.SlaveButton.height);

            GUI.DrawTexture(slaveButtonRect, Textures.SlaveButton);
            TooltipHandler.TipRegion(slaveButtonRect, Strings.SlaveMenuTooltip);
            if (Mouse.IsOver(slaveButtonRect))
            {
                GUI.DrawTexture(slaveButtonRect, Textures.RescueTendHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_SlideMenuOptionSFX.PlayOneShotOnCamera();
                    if (this.childWindows?.Any() ?? false)
                    {
                        for (int num = this.childWindows.Count - 1; num >= 0; num--)
                        {
                            if (this.childWindows[num] is SlaveMenu)
                            {
                                this.childWindows[num].Close();
                            }
                            else
                            {
                                this.childWindows[num].Close();
                                SlaveMenu floatMenu = new SlaveMenu(this, this.colonistGroup, windowRect, Textures.SlaveMenu, Strings.Slaves);
                                OpenNewMenu(floatMenu);
                            }
                        }
                    }
                    else
                    {
                        SlaveMenu floatMenu = new SlaveMenu(this, this.colonistGroup, windowRect, Textures.SlaveMenu, Strings.Slaves);
                        OpenNewMenu(floatMenu);
                    }
                }
            }

            var animalButtonRect = new Rect(slaveButtonRect.xMax + 5, rect.yMax - Textures.AnimalButton.height, Textures.AnimalButton.width, Textures.AnimalButton.height);

            GUI.DrawTexture(animalButtonRect, Textures.AnimalButton);
            TooltipHandler.TipRegion(animalButtonRect, Strings.AnimalMenuTooltip);
            if (Mouse.IsOver(animalButtonRect))
            {
                GUI.DrawTexture(animalButtonRect, Textures.RescueTendHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_SlideMenuOptionSFX.PlayOneShotOnCamera();
                    if (this.childWindows?.Any() ?? false)
                    {
                        for (int num = this.childWindows.Count - 1; num >= 0; num--)
                        {
                            if (this.childWindows[num] is AnimalMenu)
                            {
                                this.childWindows[num].Close();
                            }
                            else
                            {
                                this.childWindows[num].Close();
                                AnimalMenu floatMenu = new AnimalMenu(this, this.colonistGroup, windowRect, Textures.AnimalMenu, Strings.Animals);
                                OpenNewMenu(floatMenu);
                            }
                        }
                    }
                    else
                    {
                        AnimalMenu floatMenu = new AnimalMenu(this, this.colonistGroup, windowRect, Textures.AnimalMenu, Strings.Animals);
                        OpenNewMenu(floatMenu);
                    }
                }
            }

            var guestsButtonRect = new Rect(animalButtonRect.xMax + 5, rect.yMax - Textures.GuestButton.height, Textures.GuestButton.width, Textures.GuestButton.height);

            GUI.DrawTexture(guestsButtonRect, Textures.GuestButton);
            TooltipHandler.TipRegion(guestsButtonRect, Strings.GuestMenuTooltip);
            if (Mouse.IsOver(guestsButtonRect))
            {
                GUI.DrawTexture(guestsButtonRect, Textures.RescueTendHover);
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.clickCount == 1)
                {
                    TacticDefOf.TG_SlideMenuOptionSFX.PlayOneShotOnCamera();
                    if (this.childWindows?.Any() ?? false)
                    {
                        for (int num = this.childWindows.Count - 1; num >= 0; num--)
                        {
                            if (this.childWindows[num] is GuestMenu)
                            {
                                this.childWindows[num].Close();
                            }
                            else
                            {
                                this.childWindows[num].Close();
                                GuestMenu floatMenu = new GuestMenu(this, this.colonistGroup, windowRect, Textures.GuestMenu, Strings.Guests);
                                OpenNewMenu(floatMenu);
                            }
                        }
                    }
                    else
                    {
                        GuestMenu floatMenu = new GuestMenu(this, this.colonistGroup, windowRect, Textures.GuestMenu, Strings.Guests);
                        OpenNewMenu(floatMenu);
                    }
                }
            }
        }