Exemple #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 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;
        }
Exemple #2
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;
        }