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

                List <object> list = new List <object>()
                {
                    1, 2, 3
                };

                float slotWidth      = rect.width / 3;
                Rect  armourSlotRect = new Rect(slotWidth, rect.height - TotalSlotRectHeight, slotWidth, TotalSlotRectHeight);
                if (bp.HasArmourPlating)
                {
                    List <PartCustomisePack> armour = bp.GetPartCustomisePacks(DroidCustomiseGroupDef.Named("MD3_DroidArmourPlating"), true);
                    var pack = armour.First();
                    DrawSlot(pack, armourSlotRect, bp.ChassisType, state);
                    foreach (var p in armour)
                    {
                        p.Part = pack.Part;
                    }
                    bp.Recache();
                }

                Rect motivator1SlotRect = new Rect(0f, armourSlotRect.y, armourSlotRect.width, armourSlotRect.height);
            }
            finally
            {
                GUI.EndGroup();
            }
        }
Beispiel #2
0
 public List <PartCustomisePack> GetPartCustomisePacks(DroidCustomiseGroupDef group, bool silentFail = false)
 {
     if (!partsGrouped.Keys.Contains(group))
     {
         List <PartCustomisePack> list = new List <PartCustomisePack>();
         foreach (var li in group.Parts)
         {
             //Make a new part customise pack
             var baseParts = GetBasePartAt(li.ChassisPoint, li.BodyPosition).ToList();
             if (baseParts.Count > 0)
             {
                 foreach (var partRecord in baseParts)
                 {
                     if (partRecord is DroidChassisPartRecord)
                     {
                         //Check the body position. If the position passed is undefined, don't care what position the part has
                         DroidChassisPartRecord droidRecord = partRecord as DroidChassisPartRecord;
                         if (li.BodyPosition == BodyPosition.Undefined || droidRecord.bodyPosition == li.BodyPosition)
                         {
                             DroidChassisPartDef dcpd = droidRecord.defAsDroidDef;
                             if (dcpd == null)
                             {
                                 throw new InvalidOperationException($"{partRecord.body.defName} contains a bodypart which is not type DroidChassisPartDef: {partRecord.def.defName}");
                             }
                             var newPCP = new PartCustomisePack(li.ChassisPoint, dcpd, droidRecord.bodyPosition);
                             list.Add(newPCP);
                         }
                     }
                     else
                     {
                         //Otherwise, just make a new part with undefined body position
                         DroidChassisPartDef dcpd = partRecord.GetChassisPartDef();
                         if (dcpd == null)
                         {
                             throw new InvalidOperationException($"{partRecord.body.defName} contains a bodypart which is not type DroidChassisPartDef: {partRecord.def.defName}");
                         }
                         var newPCP = new PartCustomisePack(li.ChassisPoint, dcpd);
                         list.Add(newPCP);
                     }
                 }
             }
             else
             {
                 if (!silentFail)
                 {
                     Log.Error($"Unable to find any base parts at ChassisPoint: {li.ChassisPoint} and BodyPosition: {li.BodyPosition} for BaseBodyDef: {BaseBodyDef.defName}");
                 }
             }
         }
         partsGrouped.Add(group, list);
         return(partsGrouped[group]);
     }
     else
     {
         return(partsGrouped[group]);
     }
 }
        public Dialog_CustomisePartGroup(DroidCustomiseGroupDef group, Blueprint design, Texture2D partTex, BlueprintHandlerState state)
        {
            this.partTex = partTex;
            this.state   = state;

            this.group  = group;
            this.design = design;
            Setup();

            //doCloseX = true;
            forcePause = true;
            absorbInputAroundWindow = true;
        }
Beispiel #4
0
        private static void DrawPartsGroupListing(Rect rect, DroidCustomiseGroupDef group, List <PartCustomisePack> packs)
        {
            try
            {
                GUI.BeginGroup(rect);

                Rect labelRect = new Rect(10f, 0f, rect.width - 10f, PartGroupTitleHeight);
                Text.Anchor = TextAnchor.MiddleLeft;
                Text.Font   = GameFont.Medium;
                Widgets.Label(labelRect, group.LabelCap);
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;

                var   list      = packs.Where(x => x.Part.BasePart == false);
                float curY      = labelRect.yMax;
                bool  alternate = false;
                foreach (var part in list)
                {
                    Rect pRect = new Rect(0f, curY, rect.width, PartEntryHeight);
                    if (Mouse.IsOver(pRect))
                    {
                        Widgets.DrawHighlight(pRect);
                        TooltipHandler.TipRegion(pRect, part.Part.GetTooltip());
                    }
                    else if (alternate)
                    {
                        Widgets.DrawAltRect(pRect);
                    }

                    Text.Anchor = TextAnchor.MiddleLeft;
                    if (part.Part.color != null)
                    {
                        GUI.color = part.Part.color.GetColor();
                    }
                    Widgets.Label(pRect, $"   {part.Part.LabelCap}");
                    Text.Anchor = TextAnchor.UpperLeft;
                    GUI.color   = Color.white;
                    curY       += PartEntryHeight;
                    alternate   = !alternate;
                }
            }
            finally
            {
                GUI.EndGroup();
            }
        }
Beispiel #5
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();
            }
        }
Beispiel #6
0
 public GroupPackPair(DroidCustomiseGroupDef group, PartCustomisePack pack)
 {
     this.group = group;
     this.pack  = pack;
 }