Esempio 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());
            }
        }
Esempio n. 2
0
 /// <summary>
 /// If <paramref name="isClicked"/>, changes the <paramref name="resource"/>'s tithe status and updates some necessary things
 /// </summary>
 /// <param name="isClicked"></param>
 /// <param name="resource"></param>
 private void DoTitheCheckboxAction(bool isClicked, ResourceFC resource)
 {
     if (isClicked)
     {
         resource.isTitheBool = resource.isTithe;
         settlement.updateProfitAndProduction();
         windowUpdateFc();
     }
 }
Esempio 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)));
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Handles the tithe cutomization FloatMenuOptions for any given <paramref name="resource"/> with <paramref name="resourceType"/>
        /// </summary>
        /// <param name="resource"></param>
        /// <param name="resourceType"></param>
        private void TitheCustomizationClicked(ResourceFC resource, ResourceType resourceType)
        {
            //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("FCTitheEnableAll".Translate(),
                                    delegate
                {
                    PaymentUtil.resetThingFilter(settlement, resourceType);
                    resource.returnLowestCost();
                }),
                new FloatMenuOption("FCTitheDisableAll".Translate(),
                                    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);
                    continue;
                }

                FloatMenuOption option = new FloatMenuOption("FCTitheSingleOption".Translate(thing.LabelCap, thing.BaseMarketValue, IsAllowedTranslation(resource.filter.Allows(thing))), null, thing);

                //Seperated because the label needs to be modified on press
                option.action = delegate
                {
                    resource.filter.SetAllow(thing, !resource.filter.Allows(thing));
                    resource.returnLowestCost();
                    option.Label = "FCTitheSingleOption".Translate(thing.LabelCap, thing.BaseMarketValue, IsAllowedTranslation(resource.filter.Allows(thing)));
                    SoundDefOf.Click.PlayOneShotOnCamera();
                };

                options.Add(option);
            }

            Find.WindowStack.Add(new Searchable_FloatMenu(options, true));
        }
Esempio n. 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
            for (int i = 0; i < settlement.getNumberResource(); i++)
            {
                ResourceFC resource = settlement.returnResourceByInt(i);
                if ((i * scrollSpacing) + scroll < 0)
                {
                    //if outside view
                }
                else
                {
                    //loop through each resource
                    //isTithe
                    bool disabled = false;
                    switch (i)
                    {
                    case 6:
                    case 7:
                        disabled = true;
                        break;
                    }
                    switch (i)
                    {
                    case 0:                             //food
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 8:
                        if (Widgets.ButtonImage(new Rect(x - 15, scroll + y + 65 + (i * (45 + spacing)) + 8, 20, 20), texLoad.iconCustomize))
                        {                                 //if click faction customize button
                            int k = i;
                            if (resource.filter == null)
                            {
                                resource.filter = new ThingFilter();
                                PaymentUtil.resetThingFilter(settlement, i);
                            }
                            List <FloatMenuOption> options = new List <FloatMenuOption>();
                            options.Add(new FloatMenuOption("Enable All", delegate { PaymentUtil.resetThingFilter(settlement, k); resource.returnLowestCost(); }));
                            options.Add(new FloatMenuOption("Disable All", delegate { resource.filter.SetDisallowAll(); resource.returnLowestCost(); }));
                            List <ThingDef> things = PaymentUtil.debugGenerateTithe(i);
                            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 + (i * (45 + spacing)) + 8), ref settlement.returnResourceByInt(i).isTithe, 24, disabled);

                    if (settlement.returnResourceByInt(i).isTithe != settlement.returnResourceByInt(i).isTitheBool)
                    {
                        settlement.returnResourceByInt(i).isTitheBool = settlement.returnResourceByInt(i).isTithe;
                        //Log.Message("changed tithe");
                        settlement.updateProfitAndProduction();
                        WindowUpdateFC();
                    }

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

                    //Production Efficiency
                    Widgets.DrawBox(new Rect(x + 80, scroll + y + 70 + (i * (45 + spacing)), 100, 20));
                    Widgets.FillableBar(new Rect(x + 80, scroll + y + 70 + (i * (45 + spacing)), 100, 20), (float)Math.Min(settlement.returnResourceByInt(i).baseProductionMultiplier, 1.0));
                    Widgets.Label(new Rect(x + 80, scroll + y + 90 + (i * (45 + spacing)), 100, 20), "Workers".Translate() + ": " + settlement.returnResourceByInt(i).assignedWorkers.ToString());
                    if (Widgets.ButtonText(new Rect(x + 80, scroll + y + 90 + (i * (45 + spacing)), 20, 20), "<"))
                    {                     //if clicked to lower amount of workers
                        settlement.increaseWorkers(i, -1);
                        WindowUpdateFC();
                    }
                    if (Widgets.ButtonText(new Rect(x + 160, scroll + y + 90 + (i * (45 + spacing)), 20, 20), ">"))
                    {                     //if clicked to lower amount of workers
                        settlement.increaseWorkers(i, 1);
                        WindowUpdateFC();
                    }

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

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

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

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

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

            //Scroll window for resources
            if (Event.current.type == EventType.ScrollWheel)
            {
                scrollWindow(Event.current.delta.y);
            }
        }
Esempio n. 6
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);
            }
        }
Esempio n. 7
0
        private void DrawResources(int x, int y, int spacing)
        {
            foreach (ResourceType resourceType in ResourceUtils.resourceTypes)
            {
                ResourceFC resource = settlement.getResource(resourceType);
                float      rectY    = scroll + y + 70 + (int)resourceType * (45 + spacing);

                //Don't draw if outside view
                if ((int)resourceType * ScrollSpacing + scroll < 0)
                {
                    continue;
                }

                bool titheDisabled = false;
                if (ShouldTitheBeLockedForResouceType(resourceType))
                {
                    titheDisabled = true;
                }
                else if (Widgets.ButtonImage(new Rect(x - 15, scroll + y + 65 + (int)resourceType * (45 + spacing) + 8, 20, 20), TexLoad.iconCustomize))
                {
                    TitheCustomizationClicked(resource, resourceType);
                }

                Widgets.Checkbox(new Vector2(x + 8, scroll + y + 65 + (int)resourceType * (45 + spacing) + 8), ref resource.isTithe, 24, titheDisabled);
                DoTitheCheckboxAction(resource.isTithe != resource.isTitheBool, resource);
                DoResourceDescriptionButton(resource, resourceType, x, y, spacing);

                //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);
                if (Widgets.ButtonText(new Rect(x + 80, scroll + y + 90 + (int)resourceType * (45 + spacing), 20, 20), "<"))
                {
                    IncreaseWorkers(resourceType, true);
                }
                if (Widgets.ButtonText(new Rect(x + 160, scroll + y + 90 + (int)resourceType * (45 + spacing), 20, 20), ">"))
                {
                    IncreaseWorkers(resourceType);
                }

                //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);
            }
        }