Пример #1
0
        public override void DoWindowContents(Rect inRect)
        {
            //grab before anchor/font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;



            //Settlement Tax Collection Header
            Text.Anchor = TextAnchor.MiddleLeft;
            Text.Font   = GameFont.Medium;
            Widgets.Label(new Rect(2, 0, 300, 60), headerString);



            //settlement buttons

            Text.Anchor = TextAnchor.MiddleCenter;
            Text.Font   = GameFont.Tiny;

            //0 tithe total string
            //1 source - -1
            //2 due/delivery date
            //3 Silver (- || +)
            //4 tithe

            List <String> headerList = new List <String>()
            {
                "Name".Translate(), "Cost".Translate(), "Effect".Translate(), "Enact".Translate()
            };

            for (int i = 0; i < 3; i++)              //-2 to exclude location and ID
            {
                if (i == 0)
                {
                    Widgets.Label(new Rect(xoffset + 2 + i * xspacing, yoffset - yspacing, xspacing + headerSpacing, yspacing), headerList[i]);
                }
                else
                {
                    Widgets.Label(new Rect(xoffset + headerSpacing + 2 + i * xspacing, yoffset - yspacing, xspacing, yspacing), headerList[i]);
                }
            }

            for (int i = 0; i < list.Count(); i++)             //browse through policy list
            {
                if (i * yspacing + scroll >= 0 && i * yspacing + scroll <= height)
                {
                    if (i % 2 == 0)
                    {
                        Widgets.DrawHighlight(new Rect(xoffset, yoffset + i * yspacing + scroll, length, yspacing));
                    }
                    for (int k = 0; k < 4; k++)                                                                                                                      //Browse through thing information
                    {
                        if (k == 0)                                                                                                                                  //name of policy
                        {
                            Widgets.Label(new Rect(xoffset + 2 + k * xspacing, yoffset + i * yspacing + scroll, xspacing + headerSpacing, yspacing), list[i].label); //timedue is date made
                        }
                        else
                        if (k == 1)                         //Cost of policy
                        {
                            Widgets.Label(new Rect(xoffset + headerSpacing + 2 + k * xspacing, yoffset + i * yspacing + scroll, xspacing, yspacing), list[i].cost.ToString());
                        }
                        else
                        if (k == 2)                         // Desc/Effect of policy
                        {
                            if (Widgets.ButtonText(new Rect(xoffset + headerSpacing + 2 + k * xspacing, yoffset + i * yspacing + scroll, xspacing, yspacing), "Info".Translate()))
                            {
                                Find.WindowStack.Add(new descWindowFC(list[i].desc, list[i].label));
                            }
                        }
                        else
                        if (k == 3)                         //Enact button
                        {
                            if (list[i].defName == def.defName && list[i].defName != "Empty")
                            {
                                Widgets.Label(new Rect(xoffset + headerSpacing + 2 + k * xspacing, yoffset + i * yspacing + scroll, xspacing, yspacing), "Enacted".Translate());
                                if (Widgets.ButtonText(new Rect(xoffset + headerSpacing + 2 + (k + 1) * xspacing, yoffset + i * yspacing + scroll, xspacing, yspacing), "Repeal".Translate()))
                                {
                                    Find.World.GetComponent <FactionFC>().repealPolicy(policySlot);
                                    Find.WindowStack.TryRemove(this);
                                }
                            }
                            else
                            {
                                if (Widgets.ButtonText(new Rect(xoffset + headerSpacing + 2 + k * xspacing, yoffset + i * yspacing + scroll, xspacing, yspacing), "Enact".Translate()))
                                {
                                    if (Find.World.GetComponent <FactionFC>().validEnactPolicy(list[i], i))
                                    {
                                        FCEvent tmp = new FCEvent(true);
                                        tmp.def             = FCEventDefOf.enactFactionPolicy;
                                        tmp.policy          = list[i];
                                        tmp.policySlot      = policySlot;
                                        tmp.timeTillTrigger = Find.TickManager.TicksGame + list[i].enactDuration;
                                        //Log.Message(list[i].enactDuration.ToString());
                                        //Log.Message(tmp.timeTillTrigger.ToString());
                                        Find.World.GetComponent <FactionFC>().addEvent(tmp);
                                        PaymentUtil.paySilver(Convert.ToInt32(list[i].cost));
                                        Find.World.GetComponent <FactionFC>().repealPolicy(policySlot);
                                        Find.World.GetComponent <FactionFC>().policies[policySlot] = PolicyFCDefOf.Enacting;
                                        Messages.Message(list[i].label + " " + "WillBeEnactedIn".Translate() + " " + GenDate.ToStringTicksToDays(tmp.timeTillTrigger - Find.TickManager.TicksGame), MessageTypeDefOf.PositiveEvent);
                                        Find.WindowStack.TryRemove(this);
                                    }
                                }
                            }
                        }
                        else                         //Catch all
                        {
                            Widgets.Label(new Rect(xoffset + headerSpacing + 2 + k * xspacing, yoffset + i * yspacing + scroll, xspacing, yspacing), "REPORT THIS listpolicyfc");
                        }
                    }
                }
            }

            Widgets.DrawBox(new Rect(xoffset, yoffset - yspacing, length, height + yspacing * 2));

            //reset anchor/font
            Text.Font   = fontBefore;
            Text.Anchor = anchorBefore;

            if (Event.current.type == EventType.ScrollWheel)
            {
                scrollWindow(Event.current.delta.y);
            }
        }
Пример #2
0
        public override void DoWindowContents(Rect inRect)
        {
            //grab before anchor/font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;



            //Buildings
            int i = 0;

            foreach (BuildingFCDef building in buildingList)
            {
                newBuildingWindow = new Rect(BaseBuildingWindow.x, BaseBuildingWindow.y + (i * (rowHeight)) + scroll, BaseBuildingWindow.width, BaseBuildingWindow.height);
                newBuildingIcon   = new Rect(BaseBuildingIcon.x, BaseBuildingIcon.y + (i * (rowHeight)) + scroll, BaseBuildingIcon.width, BaseBuildingIcon.height);
                newBuildingLabel  = new Rect(BaseBuildingLabel.x, BaseBuildingLabel.y + (i * (rowHeight)) + scroll, BaseBuildingLabel.width, BaseBuildingLabel.height);
                newBuildingDesc   = new Rect(BaseBuildingDesc.x, BaseBuildingDesc.y + (i * (rowHeight)) + scroll, BaseBuildingDesc.width, BaseBuildingDesc.height);

                if (Widgets.ButtonInvisible(newBuildingWindow))
                {
                    //If click on building
                    List <FloatMenuOption> list = new List <FloatMenuOption>();

                    if (building == buildingDef)
                    {
                        //if the same building
                        list.Add(new FloatMenuOption("Destroy".Translate(), delegate
                        {
                            settlement.deconstructBuilding(buildingSlot);
                            Find.WindowStack.TryRemove(this);
                            Find.WindowStack.WindowOfType <SettlementWindowFc>().windowUpdateFc();
                        }));
                    }
                    else
                    {
                        //if not the same building
                        list.Add(new FloatMenuOption("Build".Translate(), delegate
                        {
                            if (!settlement.validConstructBuilding(building, buildingSlot, settlement))
                            {
                                return;
                            }
                            FCEvent tmpEvt      = new FCEvent(true);
                            tmpEvt.def          = FCEventDefOf.constructBuilding;
                            tmpEvt.source       = settlement.mapLocation;
                            tmpEvt.planetName   = settlement.planetName;
                            tmpEvt.building     = building;
                            tmpEvt.buildingSlot = buildingSlot;


                            int triggerTime = building.constructionDuration;
                            if (factionfc.hasPolicy(FCPolicyDefOf.isolationist))
                            {
                                triggerTime /= 2;
                            }

                            tmpEvt.timeTillTrigger = Find.TickManager.TicksGame + triggerTime;
                            Find.World.GetComponent <FactionFC>().addEvent(tmpEvt);

                            PaymentUtil.paySilver(Convert.ToInt32(building.cost));
                            settlement.deconstructBuilding(buildingSlot);
                            Messages.Message(building.label + " " + "WillBeConstructedIn".Translate() + " " + (tmpEvt.timeTillTrigger - Find.TickManager.TicksGame).ToStringTicksToDays(), MessageTypeDefOf.PositiveEvent);
                            settlement.buildings[buildingSlot] = BuildingFCDefOf.Construction;
                            Find.WindowStack.TryRemove(this);
                            Find.WindowStack.WindowOfType <SettlementWindowFc>().windowUpdateFc();
                        }));
                    }



                    FloatMenu menu = new FloatMenu(list);
                    Find.WindowStack.Add(menu);
                }


                Widgets.DrawMenuSection(newBuildingWindow);
                Widgets.DrawMenuSection(newBuildingIcon);
                Widgets.DrawLightHighlight(newBuildingIcon);
                Widgets.ButtonImage(newBuildingIcon, building.icon);

                Text.Font = GameFont.Small;
                Widgets.ButtonTextSubtle(newBuildingLabel, "");
                Widgets.Label(newBuildingLabel, "  " + building.LabelCap + " - " + "Cost".Translate() + ": " + building.cost);

                Text.Font = GameFont.Tiny;
                Widgets.Label(newBuildingDesc, building.desc);



                i++;
            }


            //Top Window
            Widgets.DrawMenuSection(TopWindow);
            Widgets.DrawHighlight(TopWindow);
            Widgets.DrawMenuSection(TopIcon);
            Widgets.DrawLightHighlight(TopIcon);

            Widgets.DrawBox(new Rect(0, 0, 400, 500));
            Widgets.ButtonImage(TopIcon, buildingDef.icon);

            Widgets.ButtonTextSubtle(TopName, "");
            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.UpperLeft;
            Widgets.Label(new Rect(TopName.x + 5, TopName.y, TopName.width, TopName.height), buildingDef.LabelCap);

            Widgets.DrawMenuSection(new Rect(TopDescription.x - 5, TopDescription.y - 5, TopDescription.width, TopDescription.height));
            Text.Font = GameFont.Small;
            Widgets.Label(TopDescription, buildingDef.desc);

            Widgets.DrawLineHorizontal(0, TopWindow.y + TopWindow.height, 400);

            //reset anchor/font
            Text.Font   = fontBefore;
            Text.Anchor = anchorBefore;

            if (Event.current.type == EventType.ScrollWheel)
            {
                scrollWindow(Event.current.delta.y);
            }
        }
Пример #3
0
        public override void DrawTab(Rect rect)
        {
            Rect SettlementBox  = new Rect(5, 45, 535, settlementHeight);
            Rect SettlementName = new Rect(SettlementBox.x + 5, SettlementBox.y + 5, 250, 25);
            Rect MilitaryLevel  = new Rect(SettlementName.x, SettlementName.y + 30, 250, 25);
            Rect AssignedSquad  = new Rect(MilitaryLevel.x, MilitaryLevel.y + 30, 250, 25);
            Rect isBusy         = new Rect(AssignedSquad.x, AssignedSquad.y + 30, 250, 25);

            Rect buttonSetSquad  = new Rect(SettlementBox.x + SettlementBox.width - 265, SettlementBox.y + 5, 100, 25);
            Rect buttonViewSquad = new Rect(buttonSetSquad.x, buttonSetSquad.y + 3 + buttonSetSquad.height,
                                            buttonSetSquad.width, buttonSetSquad.height);
            Rect buttonDeploySquad = new Rect(buttonViewSquad.x, buttonViewSquad.y + 3 + buttonViewSquad.height,
                                              buttonSetSquad.width, buttonSetSquad.height);
            Rect buttonResetPawns = new Rect(buttonDeploySquad.x, buttonDeploySquad.y + 3 + buttonDeploySquad.height,
                                             buttonSetSquad.width, buttonSetSquad.height);
            Rect buttonOrderFireSupport = new Rect(buttonSetSquad.x + 125 + 5, SettlementBox.y + 5, 125, 25);


            //set text anchor and font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;


            int count = 0;

            foreach (SettlementFC settlement in Find.World.GetComponent <FactionFC>().settlements)
            {
                Text.Font = GameFont.Small;

                Widgets.DrawMenuSection(new Rect(SettlementBox.x,
                                                 SettlementBox.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                                 SettlementBox.width, SettlementBox.height));

                //click on settlement name
                if (Widgets.ButtonTextSubtle(
                        new Rect(SettlementName.x,
                                 SettlementName.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                 SettlementName.width, SettlementName.height), settlement.name))
                {
                    Find.WindowStack.Add(new SettlementWindowFc(settlement));
                }

                Widgets.Label(
                    new Rect(MilitaryLevel.x,
                             MilitaryLevel.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                             MilitaryLevel.width, MilitaryLevel.height * 2),
                    "Mil Level: " + settlement.settlementMilitaryLevel + " - Max Squad Cost: " +
                    FactionColonies.calculateMilitaryLevelPoints(settlement.settlementMilitaryLevel));
                if (settlement.militarySquad != null)
                {
                    if (settlement.militarySquad.outfit != null)
                    {
                        Widgets.Label(
                            new Rect(AssignedSquad.x,
                                     AssignedSquad.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                     AssignedSquad.width, AssignedSquad.height),
                            "Assigned Squad: " +
                            settlement.militarySquad.outfit.name); //settlement.militarySquad.name);
                    }
                    else
                    {
                        Widgets.Label(
                            new Rect(AssignedSquad.x,
                                     AssignedSquad.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                     AssignedSquad.width, AssignedSquad.height),
                            "No assigned Squad"); //settlement.militarySquad.name);
                    }
                }
                else
                {
                    Widgets.Label(
                        new Rect(AssignedSquad.x,
                                 AssignedSquad.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                 AssignedSquad.width, AssignedSquad.height), "No assigned Squad");
                }


                Widgets.Label(
                    new Rect(isBusy.x, isBusy.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                             isBusy.width, isBusy.height), "Available: " + (!settlement.isMilitaryBusySilent()));

                Text.Font = GameFont.Tiny;

                //Set Squad Button
                if (Widgets.ButtonText(
                        new Rect(buttonSetSquad.x,
                                 buttonSetSquad.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                 buttonSetSquad.width, buttonSetSquad.height), "Set Squad"))
                {
                    //check null
                    if (util.squads == null)
                    {
                        util.resetSquads();
                    }

                    List <FloatMenuOption> squads = new List <FloatMenuOption>();

                    squads.AddRange(util.squads
                                    .Select(squad => new FloatMenuOption(squad.name + " - Total Equipment Cost: " +
                                                                         squad.equipmentTotalCost, delegate
                    {
                        //Unit is selected
                        util.attemptToAssignSquad(settlement, squad);
                    })));

                    if (!squads.Any())
                    {
                        squads.Add(new FloatMenuOption("No Available Squads", null));
                    }

                    FloatMenu selection = new Searchable_FloatMenu(squads);
                    Find.WindowStack.Add(selection);
                }

                //View Squad
                if (Widgets.ButtonText(
                        new Rect(buttonViewSquad.x,
                                 buttonViewSquad.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                 buttonViewSquad.width, buttonViewSquad.height), "View Squad"))
                {
                    Messages.Message("This is currently not implemented.", MessageTypeDefOf.RejectInput);
                }


                //Deploy Squad
                if (Widgets.ButtonText(
                        new Rect(buttonDeploySquad.x,
                                 buttonDeploySquad.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                 buttonDeploySquad.width, buttonDeploySquad.height), "Deploy Squad"))
                {
                    if (!settlement.isMilitaryBusy(true) && settlement.isMilitarySquadValid())
                    {
                        Find.WindowStack.Add(new FloatMenu(DeploymentOptions(settlement)));
                    }
                    else if (settlement.isMilitaryBusy(true) && settlement.isMilitarySquadValid() && faction.hasPolicy(FCPolicyDefOf.militaristic))
                    {
                        if ((faction.traitMilitaristicTickLastUsedExtraSquad + GenDate.TicksPerDay * 5) <= Find.TickManager.TicksGame)
                        {
                            int cost = (int)Math.Round(settlement.militarySquad.outfit.updateEquipmentTotalCost() * .2);
                            List <FloatMenuOption> options = new List <FloatMenuOption>();

                            options.Add(new FloatMenuOption("Deploy Secondary Squad - $" + cost + " silver",
                                                            delegate
                            {
                                if (PaymentUtil.getSilver() >= cost)
                                {
                                    List <FloatMenuOption> deploymentOptions = new List <FloatMenuOption>();

                                    deploymentOptions.Add(new FloatMenuOption("Walk into map", delegate
                                    {
                                        FactionColonies.CallinExtraForces(settlement, false);
                                        Find.WindowStack.currentlyDrawnWindow.Close();
                                    }));
                                    //check if medieval only
                                    bool medievalOnly = LoadedModManager.GetMod <FactionColoniesMod>()
                                                        .GetSettings <FactionColonies>().medievalTechOnly;
                                    if (!medievalOnly && (DefDatabase <ResearchProjectDef>
                                                          .GetNamed("TransportPod", false)?.IsFinished ?? false))
                                    {
                                        deploymentOptions.Add(new FloatMenuOption("Drop-Pod", delegate
                                        {
                                            FactionColonies.CallinExtraForces(settlement, true);
                                            Find.WindowStack.currentlyDrawnWindow.Close();
                                        }));
                                    }

                                    Find.WindowStack.Add(new FloatMenu(deploymentOptions));
                                }
                                else
                                {
                                    Messages.Message("NotEnoughSilverToDeploySquad".Translate(),
                                                     MessageTypeDefOf.RejectInput);
                                }
                            }));

                            Find.WindowStack.Add(new FloatMenu(options));
                        }
                        else
                        {
                            Messages.Message("XDaysToRedeploy".Translate(Math.Round(
                                                                             ((faction.traitMilitaristicTickLastUsedExtraSquad + GenDate.TicksPerDay * 5) -
                                                                              Find.TickManager.TicksGame).TicksToDays(), 1)), MessageTypeDefOf.RejectInput);
                        }
                    }
                    else
                    {
                        settlement.isMilitaryBusy();
                    }
                }

                //Reset Squad
                if (Widgets.ButtonText(
                        new Rect(buttonResetPawns.x,
                                 buttonResetPawns.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                 buttonResetPawns.width, buttonResetPawns.height), "Reset Pawns"))
                {
                    FloatMenuOption confirm = new FloatMenuOption("Are you sure? Click to confirm", delegate
                    {
                        if (settlement.militarySquad != null)
                        {
                            Messages.Message("Pawns have been regenerated for the squad",
                                             MessageTypeDefOf.NeutralEvent);
                            settlement.militarySquad.initiateSquad();
                        }
                        else
                        {
                            Messages.Message("There is no pawns to reset. Assign a squad first.",
                                             MessageTypeDefOf.RejectInput);
                        }
                    });

                    List <FloatMenuOption> list = new List <FloatMenuOption>();
                    list.Add(confirm);
                    Find.WindowStack.Add(new FloatMenu(list));
                }

                //Order Fire Support
                if (Widgets.ButtonText(
                        new Rect(buttonOrderFireSupport.x,
                                 buttonOrderFireSupport.y + (SettlementBox.height + settlementYSpacing) * count + scroll,
                                 buttonOrderFireSupport.width, buttonOrderFireSupport.height), "Order Fire Support"))
                {
                    List <FloatMenuOption> list = new List <FloatMenuOption>();


                    foreach (MilitaryFireSupport support in util.fireSupportDefs)
                    {
                        float           cost   = support.returnTotalCost();
                        FloatMenuOption option = new FloatMenuOption(support.name + " - $" + cost, delegate
                        {
                            if (support.returnTotalCost() <=
                                FactionColonies.calculateMilitaryLevelPoints(settlement.settlementMilitaryLevel))
                            {
                                if (settlement.buildings.Contains(BuildingFCDefOf.artilleryOutpost))
                                {
                                    if (settlement.artilleryTimer <= Find.TickManager.TicksGame)
                                    {
                                        if (PaymentUtil.getSilver() >= cost)
                                        {
                                            FactionColonies.FireSupport(settlement, support);
                                            Find.WindowStack.TryRemove(typeof(MilitaryCustomizationWindowFc));
                                        }
                                        else
                                        {
                                            Messages.Message(
                                                "You lack the required amount of silver to use that firesupport option!",
                                                MessageTypeDefOf.RejectInput);
                                        }
                                    }
                                    else
                                    {
                                        Messages.Message(
                                            "That firesupport option is on cooldown for another " +
                                            (settlement.artilleryTimer - Find.TickManager.TicksGame)
                                            .ToStringTicksToDays(), MessageTypeDefOf.RejectInput);
                                    }
                                }
                                else
                                {
                                    Messages.Message(
                                        "The settlement requires an artillery outpost to be built to use that firesupport option",
                                        MessageTypeDefOf.RejectInput);
                                }
                            }
                            else
                            {
                                Messages.Message(
                                    "The settlement requires a higher military level to use that fire support!",
                                    MessageTypeDefOf.RejectInput);
                            }
                        });
                        list.Add(option);
                    }

                    if (!list.Any())
                    {
                        list.Add(new FloatMenuOption("No fire supports currently made. Make one", delegate { }));
                    }

                    FloatMenu menu = new Searchable_FloatMenu(list);
                    Find.WindowStack.Add(menu);
                }

                count++;
            }

            //Reset Text anchor and font
            Text.Font   = fontBefore;
            Text.Anchor = anchorBefore;

            if (Event.current.type == EventType.ScrollWheel)
            {
                scrollWindow(Event.current.delta.y, settlementMaxScroll);
            }
        }
Пример #4
0
        public override void DoWindowContents(Rect inRect)
        {
            //grab before anchor/font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;

            //top label
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleCenter;

            //build outline
            Widgets.DrawMenuSection(billsBox);


            //loop through each bill
            //GoTo Here if change
Reset:

            int i = 0;

            Text.Anchor = TextAnchor.MiddleCenter;
            foreach (BillFC bill in bills)
            {
                i++;
                Rect settlement = new Rect();
                Rect date       = new Rect();
                Rect amount     = new Rect();
                Rect tithe      = new Rect();
                Rect resolve    = new Rect();
                Rect highlight  = new Rect();


                settlement = billNameBase;
                date       = billDescBase;
                amount     = billLocationBase;
                tithe      = billTimeRemaining;
                resolve    = billResolveBase;

                settlement.y = scroll + billHeight * i;
                date.y       = scroll + billHeight * i;
                amount.y     = scroll + billHeight * i;
                tithe.y      = scroll + billHeight * i;
                resolve.y    = scroll + billHeight * i;

                highlight = new Rect(settlement.x, settlement.y, resolve.x + resolve.width, billHeight);



                if (i % 2 == 0)
                {
                    Widgets.DrawHighlight(highlight);
                }
                String settlementName;
                if (bill.settlement != null)
                {
                    settlementName = bill.settlement.name;
                }
                else
                {
                    settlementName = "Null";
                }
                if (Widgets.ButtonText(settlement, settlementName))
                {
                    if (bill.settlement != null)
                    {
                        Find.WindowStack.Add(new SettlementWindowFc(bill.settlement));
                    }
                }
                //
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(date, (bill.dueTick - Find.TickManager.TicksGame).ToTimeString());

                //
                Widgets.Label(amount, bill.taxes.silverAmount.ToString());
                //
                bool bul;
                bul = (bill.taxes.itemTithes.Count > 0);
                Widgets.Checkbox(new Vector2(tithe.x + tithe.width / 2 - 12, tithe.y), ref bul);

                if (Widgets.ButtonText(resolve, "ResolveBill".Translate()))
                {
                    if (PaymentUtil.getSilver() >= -1 * (bill.taxes.silverAmount) || bill.taxes.silverAmount >= 0)
                    { //if have enough silver on the current map to pay  & map belongs to player
                        FCEventMaker.createTaxEvent(bill);
                        if (bill.taxes.researchCompleted != 0)
                        {
                            faction.researchPointPool += bill.taxes.researchCompleted;
                            Messages.Message("PointsAddedToResearchPool".Translate(bill.taxes.researchCompleted), MessageTypeDefOf.PositiveEvent);
                        }
                        if (bill.taxes.electricityAllotted != 0)
                        {
                            faction.powerPool += bill.taxes.electricityAllotted;
                        }
                        goto Reset;
                    }

                    Messages.Message("NotEnoughSilverOnMapToPayBill".Translate() + "!", MessageTypeDefOf.RejectInput);
                }
            }



            //Top label
            Widgets.ButtonTextSubtle(billNameBase, "Settlement".Translate());
            Widgets.ButtonTextSubtle(billDescBase, "DueFC".Translate());
            Widgets.ButtonTextSubtle(billLocationBase, "Amount".Translate());
            Widgets.ButtonTextSubtle(billTimeRemaining, "HasTithe".Translate());
            if (Widgets.ButtonTextSubtle(billResolveBase, "Auto-Resolve"))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();

                FloatMenuOption option = new FloatMenuOption("Auto-Resolving : " + faction.autoResolveBills, delegate
                {
                    faction.autoResolveBills = !faction.autoResolveBills;
                    switch (faction.autoResolveBills)
                    {
                    case true:
                        Messages.Message("Bills are now autoresolving!", MessageTypeDefOf.NeutralEvent);
                        PaymentUtil.autoresolveBills(bills);
                        break;

                    case false:
                        Messages.Message("Bills are now not autoresolving.", MessageTypeDefOf.NeutralEvent);
                        break;
                    }
                });
                list.Add(option);


                FloatMenu menu = new FloatMenu(list);
                Find.WindowStack.Add(menu);
            }
            Widgets.Checkbox(new Vector2(billResolveBase.x + billResolveBase.width - 30, billResolveBase.y + 3), ref faction.autoResolveBills, 24, true);

            //Menu Outline
            Widgets.DrawBox(billsBox);


            //reset anchor/font
            Text.Font   = fontBefore;
            Text.Anchor = anchorBefore;


            if (Event.current.type == EventType.ScrollWheel)
            {
                scrollWindow(Event.current.delta.y);
            }
        }
Пример #5
0
        public void DrawProductionHeaderLower(int x, int y, int spacing)
        {
            Text.Anchor = TextAnchor.MiddleRight;
            Text.Font   = GameFont.Small;

            //Assigned workers
            Widgets.Label(new Rect(x, y, 410, 30),
                          "AssignedWorkers".Translate() + ": " + settlement.getTotalWorkers().ToString() + " / " +
                          settlement.workersMax.ToString() + " / " + settlement.workersUltraMax.ToString());


            Text.Anchor = TextAnchor.MiddleCenter;
            Text.Font   = GameFont.Tiny;

            //Item Headers
            Widgets.DrawHighlight(new Rect(x, y + 30, 40, 40));
            Widgets.Label(new Rect(x, y + 30, 40, 40), "IsTithe".Translate() + "?");

            Widgets.DrawHighlight(new Rect(x + 80, y + 30, 100, 40));
            Widgets.Label(new Rect(x + 80, y + 30, 100, 40), "ProductionEfficiency".Translate());

            Widgets.DrawHighlight(new Rect(x + 195, y + 30, 45, 40));
            Widgets.Label(new Rect(x + 195, y + 30, 45, 40), "Base".Translate());

            Widgets.DrawHighlight(new Rect(x + 250, y + 30, 50, 40));
            Widgets.Label(new Rect(x + 250, y + 30, 50, 40), "Modifier".Translate());

            Widgets.DrawHighlight(new Rect(x + 310, y + 30, 45, 40));
            Widgets.Label(new Rect(x + 310, y + 30, 45, 40), "Final".Translate());

            Widgets.DrawHighlight(new Rect(x + 365, y + 30, 45, 40));
            Widgets.Label(new Rect(x + 365, y + 30, 45, 40), "EstimatedProfit".Translate());

            Widgets.DrawHighlight(new Rect(x + 420, y + 30, 45, 40));
            Widgets.Label(new Rect(x + 420, y + 30, 45, 40), "TaxPercentage".Translate());


            //Per resource
            foreach (ResourceType resourceType in ResourceUtils.resourceTypes)
            {
                ResourceFC resource = settlement.getResource(resourceType);
                if ((int)resourceType * ScrollSpacing + scroll < 0)
                {
                    //if outside view
                }
                else
                {
                    //loop through each resource
                    //isTithe
                    bool disabled = false;
                    switch (resourceType)
                    {
                    case ResourceType.Research:
                    case ResourceType.Power:
                        disabled = true;
                        break;

                    default:
                        if (Widgets.ButtonImage(new Rect(x - 15,
                                                         scroll + y + 65 + (int)resourceType * (45 + spacing) + 8,
                                                         20, 20), TexLoad.iconCustomize))
                        {
                            //if click faction customize button
                            if (resource.filter == null)
                            {
                                resource.filter = new ThingFilter();
                                PaymentUtil.resetThingFilter(settlement, resourceType);
                            }

                            List <FloatMenuOption> options = new List <FloatMenuOption>();
                            options.Add(new FloatMenuOption("Enable All",
                                                            delegate
                            {
                                PaymentUtil.resetThingFilter(settlement, resourceType);
                                resource.returnLowestCost();
                            }));
                            options.Add(new FloatMenuOption("Disable All",
                                                            delegate
                            {
                                resource.filter.SetDisallowAll();
                                resource.returnLowestCost();
                            }));
                            List <ThingDef> things = PaymentUtil.debugGenerateTithe(resourceType);

                            foreach (ThingDef thing in things)
                            {
                                FloatMenuOption option;
                                if (!FactionColonies.canCraftItem(thing))
                                {
                                    resource.filter.SetAllow(thing, false);
                                }
                                else
                                {
                                    option = new FloatMenuOption(thing.LabelCap + " - Cost - "
                                                                 + thing.BaseMarketValue + " | Allowed: " + resource.filter.Allows(thing),
                                                                 delegate
                                    {
                                        resource.filter.SetAllow(thing, !resource.filter.Allows(thing));
                                        resource.returnLowestCost();
                                    }, thing);
                                    options.Add(option);
                                }
                            }

                            FloatMenu menu = new FloatMenu(options);
                            Find.WindowStack.Add(menu);
                            //Log.Message("Settlement customize clicked");
                        }

                        break;
                    }

                    Widgets.Checkbox(new Vector2(x + 8, scroll + y + 65 + (int)resourceType * (45 + spacing) + 8),
                                     ref resource.isTithe, 24, disabled);

                    if (resource.isTithe != resource.isTitheBool)
                    {
                        resource.isTitheBool = resource.isTithe;
                        //Log.Message("changed tithe");
                        settlement.updateProfitAndProduction();
                        windowUpdateFc();
                    }

                    //Icon
                    if (Widgets.ButtonImage(new Rect(x + 45, scroll + y + 75 + (int)resourceType * (45 + spacing),
                                                     30, 30), resource.getIcon()))
                    {
                        Find.WindowStack.Add(new DescWindowFc("SettlementProductionOf".Translate() + ": "
                                                              + resource.label,
                                                              char.ToUpper(resource.label[0])
                                                              + resource.label.Substring(1)));
                    }

                    //Production Efficiency
                    Widgets.DrawBox(new Rect(x + 80, scroll + y + 70 + (int)resourceType * (45 + spacing),
                                             100, 20));
                    Widgets.FillableBar(new Rect(x + 80, scroll + y + 70 + (int)resourceType * (45 + spacing),
                                                 100, 20),
                                        (float)Math.Min(resource.baseProductionMultiplier, 1.0));
                    Widgets.Label(new Rect(x + 80, scroll + y + 90 + (int)resourceType * (45 + spacing),
                                           100, 20),
                                  "Workers".Translate() + ": " + resource.assignedWorkers.ToString());
                    if (Widgets.ButtonText(new Rect(x + 80, scroll + y + 90 + (int)resourceType * (45 + spacing),
                                                    20, 20), "<"))
                    {
                        if (settlement.isUnderAttack)
                        {
                            Messages.Message("SettlementUnderAttack".Translate(), MessageTypeDefOf.RejectInput);
                            return;
                        }
                        //if clicked to lower amount of workers
                        settlement.increaseWorkers(resourceType, -1);
                        windowUpdateFc();
                    }

                    if (Widgets.ButtonText(new Rect(x + 160, scroll + y + 90 + (int)resourceType * (45 + spacing),
                                                    20, 20), ">"))
                    {
                        if (settlement.isUnderAttack)
                        {
                            Messages.Message("SettlementUnderAttack".Translate(), MessageTypeDefOf.RejectInput);
                            return;
                        }
                        //if clicked to lower amount of workers
                        settlement.increaseWorkers(resourceType, 1);
                        windowUpdateFc();
                    }

                    //Base Production
                    Widgets.Label(new Rect(x + 195, scroll + y + 70 + (int)resourceType * (45 + spacing), 45, 40),
                                  FactionColonies.FloorStat(resource.baseProduction));

                    //Final Modifier
                    Widgets.Label(new Rect(x + 250, scroll + y + 70 + (int)resourceType * (45 + spacing), 50, 40),
                                  FactionColonies.FloorStat(resource.endProductionMultiplier));

                    //Final Base
                    Widgets.Label(new Rect(x + 310, scroll + y + 70 + (int)resourceType * (45 + spacing), 45, 40),
                                  (FactionColonies.FloorStat(resource.endProduction)));

                    //Est Income
                    Widgets.Label(new Rect(x + 365, scroll + y + 70 + (int)resourceType * (45 + spacing), 45, 40),
                                  (FactionColonies.FloorStat(resource.endProduction * LoadedModManager
                                                             .GetMod <FactionColoniesMod>().GetSettings <FactionColonies>().silverPerResource)));

                    //Tithe Percentage
                    Widgets.Label(new Rect(x + 420, scroll + y + 70 + (int)resourceType * (45 + spacing), 45, 40),
                                  FactionColonies.FloorStat(resource.taxPercentage) + "%");
                }
            }

            //Scroll window for resources
            if (Event.current.type == EventType.ScrollWheel)
            {
                scrollWindow(Event.current.delta.y);
            }
        }