Exemplo n.º 1
0
        private void DrawFactionResourceIcons(Rect inRect, int x, int y, int resourceSize)         //Used to draw a list of resources from the faction
        {
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleCenter;
            int   k;
            int   j;
            float resourcesPerRow = 7;
            int   ySpacing        = 30;

            foreach (ResourceType resourceType in ResourceUtils.resourceTypes)
            {
                ResourceFC resource = faction.returnResource(resourceType);
                k = (int)Math.Floor((int)resourceType / resourcesPerRow);
                j = (int)((int)resourceType % resourcesPerRow);
                if (Widgets.ButtonImage(new Rect(5 + x + (j * (resourceSize + 5)), y - 5 + ySpacing * k, resourceSize,
                                                 resourceSize), resource.getIcon()))
                {
                    Find.WindowStack.Add(new DescWindowFc("TotalFactionProduction".Translate() + ": " +
                                                          resource.name,
                                                          char.ToUpper(resource.name[0]) +
                                                          resource.name.Substring(1)));
                }
                Widgets.Label(new Rect(5 + x + j * (resourceSize + 5), y + resourceSize - 10 + ySpacing * k,
                                       resourceSize, resourceSize), resource.amount.ToString());
            }
        }
Exemplo n.º 2
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);
                float      rectY    = scroll + y + 70 + (int)resourceType * (45 + spacing);
                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>
                            {
                                new FloatMenuOption("Enable All",
                                                    delegate
                                {
                                    PaymentUtil.resetThingFilter(settlement, resourceType);
                                    resource.returnLowestCost();
                                }),
                                new FloatMenuOption("Disable All",
                                                    delegate
                                {
                                    resource.filter.SetDisallowAll();
                                    resource.returnLowestCost();
                                })
                            };
                            List <ThingDef> things = PaymentUtil.debugGenerateTithe(resourceType);

                            foreach (ThingDef thing in things.Where(thing => thing.race?.animalType != AnimalType.Dryad))
                            {
                                if (!FactionColonies.canCraftItem(thing))
                                {
                                    resource.filter.SetAllow(thing, false);
                                }
                                else
                                {
                                    FloatMenuOption 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);
                                }
                            }

                            Find.WindowStack.Add(new FloatMenuSearchable(options));
                            //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, rectY,
                                             100, 20));
                    Widgets.FillableBar(new Rect(x + 80, rectY,
                                                 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, rectY, 45, 40),
                                  FactionColonies.FloorStat(resource.baseProduction));

                    //Final Modifier
                    Widgets.Label(new Rect(x + 250, rectY, 50, 40),
                                  FactionColonies.FloorStat(resource.endProductionMultiplier));

                    //Final Base
                    Widgets.Label(new Rect(x + 310, rectY, 45, 40),
                                  (FactionColonies.FloorStat(resource.endProduction)));

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

                    //Tithe Percentage
                    resource.returnTaxPercentage();
                    string taxPercentage = FactionColonies.FloorStat(resource.taxPercentage) + "%";
                    Widgets.Label(new Rect(x + 420, rectY, 45, 40), taxPercentage);
                }
            }

            //Scroll window for resources
            if (Event.current.type == EventType.ScrollWheel)
            {
                scrollWindow(Event.current.delta.y);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Draws a <paramref name="resource"/>'s description window
 /// </summary>
 /// <param name="resource"></param>
 /// <param name="resourceType"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="spacing"></param>
 private void DoResourceDescriptionButton(ResourceFC resource, ResourceType resourceType, int x, int y, int spacing)
 {
     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)));
     }
 }