示例#1
0
        private static void DrawParts(Rect rect, Blueprint bp, BlueprintHandlerState state)
        {
            try
            {
                GUI.BeginGroup(rect);

                //TODO:: draw gradient background
                float multiplier = Math.Min(rect.width / 328f, rect.height / 404f);
                if (multiplier > 1.2f)
                {
                    multiplier = 1.2f;
                }

                //Body rect
                Vector2 bodyRectAdjusted = new Vector2(BodyRectSize.x * multiplier, BodyRectSize.y * multiplier);
                Rect    bodyRect         = new Rect(rect.width / 2 - bodyRectAdjusted.x / 2, rect.height / 2 - bodyRectAdjusted.y / 2, bodyRectAdjusted.x, bodyRectAdjusted.y);
                Widgets.DrawHighlightIfMouseover(bodyRect);
                if (bp.BodyGraphic == null)
                {
                    bp.BodyGraphicDef = DroidGraphics.GetFirstBody(bp.ChassisType);
                }
                Widgets.DrawTextureFitted(bodyRect, bp.BodyGraphic.MatSouth.mainTexture, 1.6f);

                if (Widgets.ButtonInvisible(bodyRect))
                {
                    Dialog_CustomisePartGroup cp = new Dialog_CustomisePartGroup(DroidCustomiseGroupDef.Named("MD3_MediumDroidChassis"), bp, BodyTex, state);
                    Find.WindowStack.Add(cp);
                }

                //Head rect
                Vector2 headRectAdjusted = new Vector2(HeadRectSize.x * multiplier, HeadRectSize.y * multiplier);
                Rect    headRect         = new Rect(rect.width / 2 - headRectAdjusted.x / 2, bodyRect.y - PartSelectorMargin - headRectAdjusted.y, headRectAdjusted.x, headRectAdjusted.y);
                Widgets.DrawHighlightIfMouseover(headRect);
                if (bp.HeadGraphic == null)
                {
                    bp.HeadGraphicDef = DroidGraphics.GetFirstHead(bp.ChassisType);
                }
                Widgets.DrawTextureFitted(headRect, bp.HeadGraphic.MatSouth.mainTexture, 1.7f);

                if (Widgets.ButtonInvisible(headRect))
                {
                    Dialog_CustomisePartGroup cp = new Dialog_CustomisePartGroup(DroidCustomiseGroupDef.Named("MD3_MediumDroidHead"), bp, HeadTex, state);
                    Find.WindowStack.Add(cp);
                }

                //Left arm rect
                Vector2 armRectAdjusted = new Vector2(ArmRectSize.x * multiplier, ArmRectSize.y * multiplier);
                Rect    leftArmRect     = new Rect(bodyRect.x - PartSelectorMargin - armRectAdjusted.x, bodyRect.y, armRectAdjusted.x, armRectAdjusted.y);
                if (Mouse.IsOver(leftArmRect))
                {
                    Widgets.DrawTextureFitted(leftArmRect, LeftArmHoverTex, 1);
                }
                else
                {
                    Widgets.DrawTextureFitted(leftArmRect, LeftArmTex, 1);
                }
                if (Widgets.ButtonInvisible(leftArmRect))
                {
                    Dialog_CustomisePartGroup cp = new Dialog_CustomisePartGroup(DroidCustomiseGroupDef.Named("MD3_MediumDroidLeftArm"), bp, LeftArmTex, state);
                    Find.WindowStack.Add(cp);
                }

                //Right arm rect
                Rect rightArmRect = new Rect(bodyRect.xMax + PartSelectorMargin, bodyRect.y, armRectAdjusted.x, armRectAdjusted.y);
                if (Mouse.IsOver(rightArmRect))
                {
                    Widgets.DrawTextureFitted(rightArmRect, RightArmHoverTex, 1);
                }
                else
                {
                    Widgets.DrawTextureFitted(rightArmRect, RightArmTex, 1);
                }
                if (Widgets.ButtonInvisible(rightArmRect))
                {
                    Dialog_CustomisePartGroup cp = new Dialog_CustomisePartGroup(DroidCustomiseGroupDef.Named("MD3_MediumDroidRightArm"), bp, RightArmTex, state);
                    Find.WindowStack.Add(cp);
                }

                //Left leg rect
                Vector2 legRectAdjusted = new Vector2(LegRectSize.x * multiplier, LegRectSize.y * multiplier);
                Rect    leftLegRect     = new Rect(leftArmRect.x + legRectAdjusted.x / 2, bodyRect.yMax + PartSelectorMargin, legRectAdjusted.x, legRectAdjusted.y);
                if (Mouse.IsOver(leftLegRect))
                {
                    Widgets.DrawTextureFitted(leftLegRect, LeftLegHoverTex, 1);
                }
                else
                {
                    Widgets.DrawTextureFitted(leftLegRect, LeftLegTex, 1);
                }
                if (Widgets.ButtonInvisible(leftLegRect))
                {
                    Dialog_CustomisePartGroup cp = new Dialog_CustomisePartGroup(DroidCustomiseGroupDef.Named("MD3_MediumDroidLeftLeg"), bp, LeftLegTex, state);
                    Find.WindowStack.Add(cp);
                }

                //Right leg rect
                Rect rightLegRect = new Rect(rightArmRect.x - legRectAdjusted.x / 2, leftLegRect.y, legRectAdjusted.x, legRectAdjusted.y);
                if (Mouse.IsOver(rightLegRect))
                {
                    Widgets.DrawTextureFitted(rightLegRect, RightLegHoverTex, 1);
                }
                else
                {
                    Widgets.DrawTextureFitted(rightLegRect, RightLegTex, 1);
                }
                if (Widgets.ButtonInvisible(rightLegRect))
                {
                    Dialog_CustomisePartGroup cp = new Dialog_CustomisePartGroup(DroidCustomiseGroupDef.Named("MD3_MediumDroidRightLeg"), bp, RightLegTex, state);
                    Find.WindowStack.Add(cp);
                }
            }
            finally
            {
                GUI.EndGroup();
            }
        }
示例#2
0
        public static void DrawPartSelector(Rect mainRect, Blueprint bp, BlueprintHandlerState state)
        {
            try
            {
                Rect inRect = mainRect.ContractedBy(10f);

                Widgets.DrawBoxSolid(mainRect, BoxColor);
                Widgets.DrawBox(mainRect);

                GUI.BeginGroup(inRect);

                #region Header
                Rect headerRect = new Rect(0f, 0f, inRect.width, PartSelectorHeaderHeight);
                try
                {
                    GUI.BeginGroup(headerRect);
                    if (state == BlueprintHandlerState.New)
                    {
                        Rect chassisTypeRect = new Rect(headerRect.width / 2 - ButtonSize.x / 2, headerRect.height / 2 - ButtonSize.y / 2, ButtonSize.x, ButtonSize.y);
                        if (Widgets.ButtonText(chassisTypeRect, GetChassisString(bp.ChassisType)))
                        {
                            Func <List <FloatMenuOption> > chassisTypeOptionsMaker = delegate
                            {
                                List <FloatMenuOption> list = new List <FloatMenuOption>();
                                if (bp.ChassisType != ChassisType.Small)
                                {
                                    list.Add(new FloatMenuOption("SmallChassis".Translate(), delegate
                                    {
                                        bp.ChassisType = ChassisType.Small;
                                    }));
                                }
                                if (bp.ChassisType != ChassisType.Medium)
                                {
                                    list.Add(new FloatMenuOption("MediumChassis".Translate(), delegate
                                    {
                                        bp.ChassisType = ChassisType.Medium;
                                    }));
                                }
                                if (bp.ChassisType != ChassisType.Large)
                                {
                                    list.Add(new FloatMenuOption("LargeChassis".Translate(), delegate
                                    {
                                        bp.ChassisType = ChassisType.Large;
                                    }));
                                }
                                return(list);
                            };
                            Find.WindowStack.Add(new FloatMenu(chassisTypeOptionsMaker()));
                        }
                    }
                    else
                    {
                        string headerLabelString = GetChassisString(bp.ChassisType);
                        Rect   headerLabelRect   = new Rect(0f, 0f, headerRect.width, headerRect.height);
                        Text.Anchor = TextAnchor.MiddleCenter;
                        Widgets.Label(headerLabelRect, headerLabelString);
                        Text.Anchor = TextAnchor.UpperLeft;
                    }
                }
                finally
                {
                    GUI.EndGroup();
                    Text.Anchor = TextAnchor.UpperLeft;
                }
                #endregion

                //Footer
                Rect footerRect = new Rect(0f, inRect.height - PartSelectorFooterHeight, inRect.width, PartSelectorFooterHeight);
                DrawBottomSlots(footerRect, bp, state);

                #region Side Arrows
                //Side arrows
                if (state == BlueprintHandlerState.Edit || state == BlueprintHandlerState.New)
                {
                    Rect leftSideRect = new Rect(0f, headerRect.height, PartSelectorSideBarWidth, inRect.height - headerRect.height - footerRect.height);
                    try
                    {
                        GUI.BeginGroup(leftSideRect);
                        Rect headArrowRect = new Rect(0f, leftSideRect.height / 6 - PartSelectorArrowHeight / 2f, leftSideRect.width, PartSelectorArrowHeight);
                        Widgets.DrawHighlightIfMouseover(headArrowRect);
                        Widgets.DrawTextureFitted(headArrowRect, TexUI.ArrowTexLeft, 1f);
                        if (Widgets.ButtonInvisible(headArrowRect))
                        {
                            bp.HeadGraphicDef = DroidGraphics.GetPreviousHead(bp.ChassisType);
                        }

                        Rect bodyArrowRect = new Rect(0f, leftSideRect.height / 2, leftSideRect.width, PartSelectorArrowHeight);
                        Widgets.DrawHighlightIfMouseover(bodyArrowRect);
                        Widgets.DrawTextureFitted(bodyArrowRect, TexUI.ArrowTexLeft, 1f);
                        if (Widgets.ButtonInvisible(bodyArrowRect))
                        {
                            bp.BodyGraphicDef = DroidGraphics.GetPreviousBody(bp.ChassisType);
                        }
                    }
                    finally
                    {
                        GUI.EndGroup();
                    }
                    Rect rightSideRect = new Rect(inRect.width - PartSelectorSideBarWidth, headerRect.height, PartSelectorSideBarWidth, leftSideRect.height);
                    try
                    {
                        GUI.BeginGroup(rightSideRect);
                        Rect headArrowRect = new Rect(0f, leftSideRect.height / 6 - PartSelectorArrowHeight / 2f, leftSideRect.width, PartSelectorArrowHeight);
                        Widgets.DrawHighlightIfMouseover(headArrowRect);
                        Widgets.DrawTextureFitted(headArrowRect, TexUI.ArrowTexRight, 1f);
                        if (Widgets.ButtonInvisible(headArrowRect))
                        {
                            bp.HeadGraphicDef = DroidGraphics.GetNextHead(bp.ChassisType);
                        }

                        Rect bodyArrowRect = new Rect(0f, leftSideRect.height / 2, leftSideRect.width, PartSelectorArrowHeight);
                        Widgets.DrawHighlightIfMouseover(bodyArrowRect);
                        Widgets.DrawTextureFitted(bodyArrowRect, TexUI.ArrowTexRight, 1f);
                        if (Widgets.ButtonInvisible(bodyArrowRect))
                        {
                            bp.BodyGraphicDef = DroidGraphics.GetNextBody(bp.ChassisType);
                        }
                    }
                    finally
                    {
                        GUI.EndGroup();
                    }
                }
                #endregion

                //Draw selector
                Rect selectorRect = new Rect(PartSelectorSideBarWidth + 5f, headerRect.yMax, inRect.width - 10f - PartSelectorSideBarWidth * 2f, inRect.height - headerRect.height - footerRect.height - PartSelectorMargin);
                DrawParts(selectorRect, bp, state);
            }
            finally
            {
                GUI.EndGroup();
            }
        }