public override void DoWindowContents(Rect inRect)
        {
            try
            {
                GUI.BeginGroup(inRect);

                Rect titleRect = new Rect(0f, 0f, inRect.width, TitleBarHeight);
                Text.Anchor = TextAnchor.MiddleCenter;
                Text.Font = GameFont.Medium;
                Widgets.Label(titleRect, "AI Packages");
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font = GameFont.Small;

                Rect availableRect = new Rect(0f, titleRect.yMax + VerticalMargin, ListViewSize.x, inRect.height - titleRect.yMax - AcceptButtonSize.y - VerticalMargin * 2);
                Widgets.DrawBoxSolid(availableRect, BoxColor);
                DrawList(availableRect, AvailablePackagesForDesign, availableScrollPos, ref selAvailable, ref selDesign, true);

                Rect chosenRect = new Rect(inRect.width - ListViewSize.x, availableRect.y, ListViewSize.x, availableRect.height);
                Widgets.DrawBoxSolid(chosenRect, BoxColor);
                DrawList(chosenRect, PackagesTemp, designScrollPos, ref selDesign, ref selAvailable, false);

                float butX = availableRect.xMax + ((chosenRect.x - availableRect.xMax) / 2) - ListButtonSize.x / 2;
                Rect addButtonRect = new Rect(butX, availableRect.center.y - VerticalMargin - ListButtonSize.y, ListButtonSize.x, ListButtonSize.y);
                if (Widgets.ButtonText(addButtonRect, "->"))
                {
                    if (selAvailable != null)
                    {
                        availableTemp.Remove(selAvailable);
                        packagesTemp.Add(selAvailable);
                        selDesign = selAvailable;
                        selAvailable = null;
                    }
                }

                Rect removeButtonRect = new Rect(addButtonRect.x, availableRect.center.y + VerticalMargin, ListButtonSize.x, ListButtonSize.y);
                if (Widgets.ButtonText(removeButtonRect, "<-"))
                {
                    if (selDesign != null)
                    {
                        packagesTemp.Remove(selDesign);
                        availableTemp.Add(selDesign);
                        selAvailable = selDesign;
                        selDesign = null;
                    }
                }

                Rect cancelButtonRect = new Rect(0f, inRect.height - AcceptButtonSize.y, AcceptButtonSize.x, AcceptButtonSize.y);
                if (Widgets.ButtonText(cancelButtonRect, "Cancel"))
                {
                    Find.WindowStack.TryRemove(this);
                }

                Rect acceptButtonRect = new Rect(inRect.width - AcceptButtonSize.x, cancelButtonRect.y, AcceptButtonSize.x, AcceptButtonSize.y);
                if (Widgets.ButtonText(acceptButtonRect, "Accept"))
                {
                    design.AIPackages.Clear();
                    design.AIPackages.AddRange(packagesTemp);
                    BlueprintUIUtil.StatDummy(design).InitialiseFromBlueprint();
                    RimWorld.StatsReportUtility.Reset();
                    Find.WindowStack.TryRemove(this);
                }
            }
            finally
            {
                GUI.EndGroup();
            }
        }
Exemple #2
0
        public void DrawWindow(Rect inRect)
        {
            try
            {
                GUI.BeginGroup(inRect);

                #region Header
                //Header
                Rect headerRect = new Rect(0f, 0f, inRect.width, HeaderRectHeight);
                try
                {
                    GUI.BeginGroup(headerRect);
                    //Draw the label
                    string nameLabelString;
                    float  nameLabelXPos;
                    float  nameLabelWidth;

                    if (state == BlueprintHandlerState.Edit || state == BlueprintHandlerState.New)
                    {
                        nameLabelString = "BlueprintName".Translate();
                        nameLabelWidth  = Text.CalcSize(nameLabelString).x;
                        nameLabelXPos   = headerRect.width / 2 - (nameLabelWidth + 5f + TextBoxWidth) / 2;
                    }
                    else
                    {
                        nameLabelString = "BlueprintName".Translate() + Blueprint.Label;
                        nameLabelWidth  = Text.CalcSize(nameLabelString).x;
                        nameLabelXPos   = headerRect.width / 2 - nameLabelWidth / 2;
                    }

                    Rect nameLabelRect = new Rect(nameLabelXPos, 0f, nameLabelWidth, HeaderRectHeight);
                    Text.Anchor = TextAnchor.MiddleLeft;
                    Widgets.Label(nameLabelRect, nameLabelString);
                    Text.Anchor = TextAnchor.UpperLeft;

                    //if the state is New or Edit, draw the textbox.
                    if (state == BlueprintHandlerState.Edit || state == BlueprintHandlerState.New)
                    {
                        Rect nameRect = new Rect(nameLabelRect.xMax + 5f, HeaderRectHeight / 2 - TextBoxHeight / 2, 200f, TextBoxHeight);
                        Blueprint.Label = Widgets.TextField(nameRect, Blueprint.Label);
                    }
                }
                finally
                {
                    GUI.EndGroup();
                    Text.Anchor = TextAnchor.UpperLeft;
                }
                #endregion

                #region Main Rect
                //MainRect
                Rect mainRect = new Rect(0f, headerRect.yMax + SectionMargin, inRect.width, inRect.height - HeaderRectHeight - FooterRectHeight - SectionMargin * 2);
                try
                {
                    GUI.BeginGroup(mainRect);

                    PartSelectorAreaWidth = (float)Math.Floor(mainRect.width * 0.45);
                    StatsAreaWidth        = (float)Math.Floor(mainRect.width * 0.30);
                    DisplayAreaWidth      = (float)Math.Floor(mainRect.width * 0.25);

                    //Parts list
                    float leftRectsHeight = mainRect.height / 3 - (SectionMargin * 2) / 3;
                    Rect  partsRect       = new Rect(0f, 0f, DisplayAreaWidth, leftRectsHeight);
                    BlueprintUIUtil.DrawPartsList(partsRect, ref partsScrollPos, Blueprint);

                    //AI list
                    Rect aiRect = new Rect(0f, partsRect.yMax + SectionMargin, partsRect.width, leftRectsHeight);
                    BlueprintUIUtil.DrawAIList(aiRect, ref aiScrollPos, Blueprint, state);

                    //Skills
                    Rect skillsRect = new Rect(0f, aiRect.yMax + SectionMargin, partsRect.width, leftRectsHeight);
                    BlueprintUIUtil.DrawSkillsList(skillsRect, ref skillsScrollPos, Blueprint, state);

                    //Droid part selector
                    Rect droidDisplayRect = new Rect(partsRect.xMax + SectionMargin, 0f, PartSelectorAreaWidth, mainRect.height);
                    BlueprintUIUtil.DrawPartSelector(droidDisplayRect, Blueprint, state);

                    //Stats
                    Rect statsRect = new Rect(droidDisplayRect.xMax + SectionMargin, 0f, StatsAreaWidth, leftRectsHeight * 2 + SectionMargin);
                    Widgets.DrawBoxSolid(statsRect, BoxColor);
                    StatsReportUtility.DrawStatsReport(statsRect, BlueprintUIUtil.StatDummy(Blueprint));

                    //Costs
                    Rect costsRect = new Rect(statsRect.x, statsRect.yMax + SectionMargin, statsRect.width, leftRectsHeight);
                    Widgets.DrawBoxSolid(costsRect, BoxColor);
                }
                finally
                {
                    GUI.EndGroup();
                    Text.Anchor = TextAnchor.UpperLeft;
                }
                #endregion

                //Footer area
                Rect footerRect = new Rect(0f, inRect.height - FooterRectHeight, mainRect.width, FooterRectHeight);
                DrawFooter(footerRect);
            }
            finally
            {
                GUI.EndGroup();
                Text.Anchor = TextAnchor.UpperLeft;
            }
        }
        public override void DoWindowContents(Rect inRect)
        {
            try
            {
                GUI.BeginGroup(inRect);

                //Draw label
                Rect labelRect = new Rect(0f, 0f, inRect.width, 40f);
                Text.Anchor = TextAnchor.UpperCenter;
                Text.Font   = GameFont.Medium;
                Widgets.Label(labelRect, group.label);
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;
                Widgets.DrawLine(new Vector2(labelRect.x + 15f, labelRect.yMax - 3f), new Vector2(labelRect.xMax - 15f, labelRect.yMax - 3f), Color.white, 1f);

                Rect texRect = new Rect(inRect.width / 2 - BlueprintUIUtil.TexRectSize.x / 2, inRect.height / 2 - BlueprintUIUtil.TexRectSize.y / 2 - 7f, BlueprintUIUtil.TexRectSize.x, BlueprintUIUtil.TexRectSize.y);
                Widgets.DrawTextureFitted(texRect, partTex, 1f);

                //Draw Left slot boxes
                Rect Slot2Rect = new Rect(0f, (texRect.y + texRect.height / 2) - BlueprintUIUtil.SlotRectSize.y / 2, inRect.width - texRect.xMax, BlueprintUIUtil.TotalSlotRectHeight);
                if (Slot2 != null)
                {
                    BlueprintUIUtil.DrawSlot(Slot2Temp, Slot2Rect, design.ChassisType, state);
                }

                Rect Slot1Rect = new Rect(Slot2Rect.x, Slot2Rect.y - BlueprintUIUtil.TotalSlotRectHeight, Slot2Rect.width, Slot2Rect.height);
                if (Slot1 != null)
                {
                    BlueprintUIUtil.DrawSlot(Slot1Temp, Slot1Rect, design.ChassisType, state);
                }

                Rect Slot3Rect = new Rect(Slot2Rect.x, Slot2Rect.yMax, Slot2Rect.width, Slot2Rect.height);
                if (Slot3 != null)
                {
                    BlueprintUIUtil.DrawSlot(Slot3Temp, Slot3Rect, design.ChassisType, state);
                }

                //Draw right slot boxes
                Rect Slot4Rect = new Rect(texRect.xMax, Slot1Rect.y, inRect.width - texRect.xMax, Slot2Rect.height);
                if (Slot4 != null)
                {
                    BlueprintUIUtil.DrawSlot(Slot4Temp, Slot4Rect, design.ChassisType, state);
                }

                Rect Slot5Rect = new Rect(Slot4Rect.x, Slot2Rect.y, Slot4Rect.width, Slot2Rect.height);
                if (Slot5 != null)
                {
                    BlueprintUIUtil.DrawSlot(Slot5Temp, Slot5Rect, design.ChassisType, state);
                }

                Rect Slot6Rect = new Rect(Slot4Rect.x, Slot3Rect.y, Slot4Rect.width, Slot2Rect.height);
                if (Slot6 != null)
                {
                    BlueprintUIUtil.DrawSlot(Slot6Temp, Slot6Rect, design.ChassisType, state);
                }

                //Draw Buttons
                if (state == BlueprintHandlerState.New || state == BlueprintHandlerState.Edit)
                {
                    //Accept
                    Rect acceptButtonRect = new Rect(inRect.width - ButtonSize.x, inRect.height - ButtonSize.y, ButtonSize.x, ButtonSize.y);
                    if (Widgets.ButtonText(acceptButtonRect, "Accept".Translate()))
                    {
                        if (Slot1 != null)
                        {
                            Slot1.CopyFrom(Slot1Temp);
                        }
                        if (Slot2 != null)
                        {
                            Slot2.CopyFrom(Slot2Temp);
                        }
                        if (Slot3 != null)
                        {
                            Slot3.CopyFrom(Slot3Temp);
                        }
                        if (Slot4 != null)
                        {
                            Slot4.CopyFrom(Slot4Temp);
                        }
                        if (Slot5 != null)
                        {
                            Slot5.CopyFrom(Slot5Temp);
                        }
                        if (Slot6 != null)
                        {
                            Slot6.CopyFrom(Slot6Temp);
                        }
                        BlueprintUIUtil.StatDummy(design).InitialiseFromBlueprint();
                        RimWorld.StatsReportUtility.Reset();
                        Find.WindowStack.TryRemove(this);
                    }
                    //Cancel
                    Rect cancelButtonRect = new Rect(0f, inRect.height - ButtonSize.y, ButtonSize.x, ButtonSize.y);
                    if (Widgets.ButtonText(cancelButtonRect, "Cancel".Translate()))
                    {
                        Find.WindowStack.TryRemove(this);
                    }
                }
                else
                {
                    Rect closeButtonRect = new Rect(inRect.width / 2 - ButtonSize.x / 2, inRect.height - ButtonSize.y, ButtonSize.x, ButtonSize.y);
                    if (Widgets.ButtonText(closeButtonRect, "Close".Translate()))
                    {
                        Find.WindowStack.TryRemove(this);
                    }
                }
            }
            finally
            {
                GUI.EndGroup();
            }
        }