Exemple #1
0
        protected override void FillTab()
        {
            if (selBlueprint == null)
            {
                size = SmallSize;
            }
            else
            {
                size = LargeSize;
            }

            Rect baseRect = new Rect(0f, 20f, size.x, size.y - 20f);
            Rect mainRect = baseRect.ContractedBy(10f);

            try
            {
                GUI.BeginGroup(mainRect);

                //Designs list area
                Rect designsListRect = new Rect(0f, 0f, 240f, mainRect.height - CreateButtonSize.y - SectionMargin);
                Widgets.DrawBoxSolid(designsListRect, BoxColor);
                DrawDesignList(designsListRect);

                //DEBUG:: Spawn droid button
                Rect spawnButtonRect = new Rect(designsListRect.xMax - 70f, designsListRect.yMax - 30f, 50f, 30f);
                if (Widgets.ButtonText(spawnButtonRect, "spawn"))
                {
                    if (selBlueprint != null)
                    {
                        Droid d = DroidGenerator.GenerateDroid(DefDatabase <PawnKindDef> .GetNamed("MD3_Droid"), selBlueprint, Faction.OfPlayer);
                        GenSpawn.Spawn(d, ((Building)SelObject).InteractionCell, ((Building)SelObject).Map);
                    }
                }

                //Create button
                Rect createButtonRect = new Rect(designsListRect.xMax - CreateButtonSize.x, designsListRect.yMax + SectionMargin, CreateButtonSize.x, CreateButtonSize.y);
                if (Widgets.ButtonText(createButtonRect, "New".Translate()))
                {
                    Find.WindowStack.Add(new Dialog_NewBlueprint(new Blueprint()));
                }

                //Delete button
                if (selBlueprint != null)
                {
                    Rect deleteButtonRect = new Rect(0f, createButtonRect.y, createButtonRect.x - 2f, CreateButtonSize.y);
                    if (Widgets.ButtonText(deleteButtonRect, "Delete".Translate()) && selBlueprint != null)
                    {
                        Dialog_Confirm confirm = new Dialog_Confirm("ConfirmDeleteBlueprint".Translate(), delegate
                        {
                            DroidManager.Instance.Blueprints.Remove(selBlueprint);
                            selBlueprint = null;
                        });
                        Find.WindowStack.Add(confirm);
                    }
                }

                if (selBlueprint != null)
                {
                    Rect blueprintRect = new Rect(designsListRect.xMax + SectionMargin, 0f, mainRect.width - designsListRect.width - SectionMargin, mainRect.height);
                    bpHandler?.DrawWindow(blueprintRect);
                }
            }
            finally
            {
                GUI.EndGroup();
            }
        }