Beispiel #1
0
 private void BuildRecipeModules(ImGui gui, RecipeRow recipe)
 {
     if (recipe.isOverviewMode)
     {
         return;
     }
     if (recipe.entity != null && recipe.entity.moduleSlots > 0 && gui.BuildFactorioObjectWithAmount(recipe.parameters.modules.module, recipe.parameters.modules.count, UnitOfMeasure.None))
     {
         gui.ShowDropDown((ImGui dropGui, ref bool closed) =>
         {
             dropGui.BuildText("Selecting a fixed module will override auto-module filler!", wrap: true);
             closed = dropGui.BuildInlineObejctListAndButton(recipe.recipe.modules, DataUtils.FavouriteModule, sel =>
             {
                 DataUtils.FavouriteModule.AddToFavourite(sel);
                 if (recipe.module == sel)
                 {
                     return;
                 }
                 recipe.RecordUndo().module = sel;
             }, "Select fixed module", allowNone: recipe.parameters.modules.module != null);
         });
     }
     if (recipe.parameters.modules.beacon != null)
     {
         gui.BuildFactorioObjectWithAmount(recipe.parameters.modules.beacon, recipe.parameters.modules.beaconCount, UnitOfMeasure.None);
     }
 }
Beispiel #2
0
        private void BuildTechnology(Technology technology, ImGui gui)
        {
            BuildRecipe(technology, gui);
            if (technology.prerequisites.Length > 0)
            {
                BuildSubHeader(gui, "Prerequisites");
                using (gui.EnterGroup(contentPadding))
                    BuildIconRow(gui, technology.prerequisites, 1);
            }

            if (technology.unlockRecipes.Length > 0)
            {
                BuildSubHeader(gui, "Unlocks recipes");
                using (gui.EnterGroup(contentPadding))
                    BuildIconRow(gui, technology.unlockRecipes, 2);
            }

            var packs = TechnologyScienceAnalysis.Instance.allSciencePacks[technology];

            if (packs.Length > 0)
            {
                BuildSubHeader(gui, "Total science required");
                using (gui.EnterGroup(contentPadding))
                {
                    using (var grid = gui.EnterInlineGrid(3f))
                    {
                        foreach (var pack in packs)
                        {
                            grid.Next();
                            gui.BuildFactorioObjectWithAmount(pack.goods, pack.amount, UnitOfMeasure.None);
                        }
                    }
                }
            }
        }
Beispiel #3
0
 protected override void BuildContent(ImGui gui)
 {
     if (model == null)
     {
         return;
     }
     if (model.tiers == null)
     {
         return;
     }
     foreach (var tier in model.tiers)
     {
         using (var grid = gui.EnterInlineGrid(3f))
         {
             foreach (var recipe in tier)
             {
                 var color = SchemeColor.None;
                 if (gui.isBuilding)
                 {
                     if (selectedRecipe != null && (selectedRecipe.downstream != null && selectedRecipe.downstream.Contains(recipe.recipe) ||
                                                    selectedRecipe.upstream != null && selectedRecipe.upstream.Contains(recipe.recipe)))
                     {
                         color = SchemeColor.Secondary;
                     }
                 }
                 grid.Next();
                 if (gui.BuildFactorioObjectWithAmount(recipe.recipe, recipe.recipesPerSecond, UnitOfMeasure.PerSecond, color))
                 {
                     selectedRecipe = recipe;
                 }
             }
         }
     }
 }
Beispiel #4
0
 private void DrawIngredients(ImGui gui, Recipe recipe)
 {
     if (recipe.ingredients.Length > 8)
     {
         DrawTooManyThings(gui, recipe.ingredients, 8);
         return;
     }
     foreach (var ingredient in recipe.ingredients)
     {
         if (gui.BuildFactorioObjectWithAmount(ingredient.goods, ingredient.amount, UnitOfMeasure.None))
         {
             if (ingredient.variants != null)
             {
                 gui.ShowDropDown((ImGui imGui, ref bool closed) =>
                 {
                     if (imGui.BuildInlineObejctListAndButton <Goods>(ingredient.variants, DataUtils.DefaultOrdering, SetItem, "Accepted fluid variants"))
                     {
                         closed = true;
                     }
                 });
             }
             else
             {
                 changing = ingredient.goods;
             }
         }
     }
 }
Beispiel #5
0
        private void BuildRecipeEntity(ImGui gui, RecipeRow recipe)
        {
            if (recipe.isOverviewMode)
            {
                return;
            }
            if (gui.BuildFactorioObjectWithAmount(recipe.entity, (float)(recipe.recipesPerSecond * recipe.parameters.recipeTime), UnitOfMeasure.None) && recipe.recipe.crafters.Count > 0)
            {
                gui.ShowDropDown(((ImGui dropGui, ref bool closed) =>
                {
                    closed = dropGui.BuildInlineObejctListAndButton(recipe.recipe.crafters, DataUtils.FavouriteCrafter, sel =>
                    {
                        DataUtils.FavouriteCrafter.AddToFavourite(sel);
                        if (recipe.entity == sel)
                        {
                            return;
                        }
                        recipe.RecordUndo().entity = sel;
                        if (!sel.energy.fuels.Contains(recipe.fuel))
                        {
                            recipe.fuel = recipe.entity.energy.fuels.AutoSelect(DataUtils.FavouriteFuel);
                        }
                    }, "Select crafting entity");
                }));
            }

            gui.AllocateSpacing(0.5f);
            BuildGoodsIcon(gui, recipe.fuel, (float)(recipe.parameters.fuelUsagePerSecondPerRecipe * recipe.recipesPerSecond), ProductDropdownType.Fuel, recipe,
                           recipe.linkRoot);
        }
Beispiel #6
0
        private void BuildGoodsIcon(ImGui gui, Goods goods, ProductionLink link, float amount, ProductDropdownType dropdownType, RecipeRow recipe, ProductionTable context, Goods[] variants = null)
        {
            var linkIsError   = link != null && ((link.flags & (ProductionLink.Flags.HasProductionAndConsumption | ProductionLink.Flags.LinkRecursiveNotMatched | ProductionLink.Flags.ChildNotMatched)) != ProductionLink.Flags.HasProductionAndConsumption);
            var linkIsForeign = link != null && link.owner != context;

            if (gui.BuildFactorioObjectWithAmount(goods, amount, goods?.flowUnitOfMeasure ?? UnitOfMeasure.None, link != null ? linkIsError ? SchemeColor.Error : linkIsForeign?SchemeColor.Secondary : SchemeColor.Primary: goods.IsSourceResource() ? SchemeColor.Green : SchemeColor.None) && goods != Database.voidEnergy)
            {
                OpenProductDropdown(gui, gui.lastRect, goods, amount, link, dropdownType, recipe, context, variants);
            }
        }
Beispiel #7
0
 protected override void BuildPageTooltip(ImGui gui, AutoPlanner contents)
 {
     using (var grid = gui.EnterInlineGrid(3f, 1f))
     {
         foreach (var goal in contents.goals)
         {
             grid.Next();
             gui.BuildFactorioObjectWithAmount(goal.item, goal.amount, goal.item.flowUnitOfMeasure);
         }
     }
 }
Beispiel #8
0
        private void BuildGoodsIcon(ImGui gui, Goods goods, float amount, ProductDropdownType dropdownType, RecipeRow recipe, ProductionTable context)
        {
            var hasLink       = context.FindLink(goods, out var link);
            var linkIsError   = hasLink && ((link.flags & (ProductionLink.Flags.HasProductionAndConsumption | ProductionLink.Flags.LinkRecursiveNotMatched)) != ProductionLink.Flags.HasProductionAndConsumption);
            var linkIsForeign = hasLink && link.owner != context;

            if (gui.BuildFactorioObjectWithAmount(goods, amount, goods?.flowUnitOfMeasure ?? UnitOfMeasure.None, hasLink ? linkIsError ? SchemeColor.Error : linkIsForeign?SchemeColor.Secondary : SchemeColor.Primary: SchemeColor.None) && goods != Database.voidEnergy)
            {
                OpenProductDropdown(gui, gui.lastRect, goods, dropdownType, recipe, context);
            }
        }
Beispiel #9
0
        private void BuildSolarPanelAccumulatorView(ImGui gui, RecipeRow recipe)
        {
            var accumulator          = recipe.GetVariant(Database.allAccumulators);
            var requiredMj           = recipe.entity.craftingSpeed * recipe.buildingCount * (70 / 0.7f); // 70 seconds of charge time to last through the night
            var requiredAccumulators = requiredMj / accumulator.accumulatorCapacity;

            if (gui.BuildFactorioObjectWithAmount(accumulator, requiredAccumulators, UnitOfMeasure.None))
            {
                ShowAccumulatorDropdown(gui, recipe, accumulator);
            }
        }
Beispiel #10
0
        private void BuildRecipeModules(ImGui gui, RecipeRow recipe)
        {
            if (recipe.isOverviewMode)
            {
                return;
            }
            using (var grid = gui.EnterInlineGrid(3f))
            {
                if (recipe.entity != null && recipe.entity.allowedEffects != AllowedEffects.None)
                {
                    if (recipe.parameters.modules.modules == null || recipe.parameters.modules.modules.Length == 0)
                    {
                        grid.Next();
                        if (gui.BuildFactorioObjectWithAmount(null, 0, UnitOfMeasure.None))
                        {
                            ShowModuleDropDown(gui, recipe);
                        }
                    }
                    else
                    {
                        foreach (var(module, count) in recipe.parameters.modules.modules)
                        {
                            grid.Next();
                            if (gui.BuildFactorioObjectWithAmount(module, count, UnitOfMeasure.None))
                            {
                                ShowModuleDropDown(gui, recipe);
                            }
                        }
                    }
                }

                if (recipe.parameters.modules.beacon != null)
                {
                    grid.Next();
                    if (gui.BuildFactorioObjectWithAmount(recipe.parameters.modules.beacon, recipe.parameters.modules.beaconCount, UnitOfMeasure.None))
                    {
                        ModuleCustomisationScreen.Show(recipe);
                    }
                }
            }
        }
 private void DrawTooManyThings(ImGui gui, IEnumerable <IFactorioObjectWrapper> list, int maxElemCount)
 {
     using (var grid = gui.EnterInlineGrid(3f, 0f, maxElemCount))
     {
         foreach (var item in list)
         {
             grid.Next();
             if (gui.BuildFactorioObjectWithAmount(item.target, item.amount, UnitOfMeasure.None))
             {
                 changing = item.target as Goods;
             }
         }
     }
 }
 private void DrawIngredients(ImGui gui, Recipe recipe)
 {
     if (recipe.ingredients.Length > 8)
     {
         DrawTooManyThings(gui, recipe.ingredients, 8);
         return;
     }
     foreach (var ingredient in recipe.ingredients)
     {
         if (gui.BuildFactorioObjectWithAmount(ingredient.goods, ingredient.amount, UnitOfMeasure.None))
         {
             changing = ingredient.goods;
         }
     }
 }
 private void DrawProducts(ImGui gui, Recipe recipe)
 {
     if (recipe.products.Length > 7)
     {
         DrawTooManyThings(gui, recipe.products, 7);
         return;
     }
     for (var i = recipe.products.Length - 1; i >= 0; i--)
     {
         var product = recipe.products[i];
         if (gui.BuildFactorioObjectWithAmount(product.goods, product.amount, UnitOfMeasure.None))
         {
             changing = product.goods;
         }
     }
 }
Beispiel #14
0
        private void BuildRecipeEntity(ImGui gui, RecipeRow recipe)
        {
            if (recipe.isOverviewMode)
            {
                return;
            }
            bool clicked;

            if (recipe.fixedBuildings > 0)
            {
                var evt = gui.BuildFactorioObjectWithEditableAmount(recipe.entity, recipe.fixedBuildings, UnitOfMeasure.None, out var newAmount);
                if (evt == GoodsWithAmountEvent.TextEditing)
                {
                    recipe.RecordUndo().fixedBuildings = newAmount;
                }
                clicked = evt == GoodsWithAmountEvent.ButtonClick;
            }
            else
            {
                clicked = gui.BuildFactorioObjectWithAmount(recipe.entity, recipe.buildingCount, UnitOfMeasure.None) && recipe.recipe.crafters.Count > 0;
            }


            if (clicked)
            {
                ShowEntityDropPown(gui, recipe);
            }

            gui.AllocateSpacing(0.5f);
            if (recipe.fuel != Database.voidEnergy)
            {
                BuildGoodsIcon(gui, recipe.fuel, recipe.links.fuel, (float)(recipe.parameters.fuelUsagePerSecondPerRecipe * recipe.recipesPerSecond), ProductDropdownType.Fuel, recipe, recipe.linkRoot);
            }
            else
            {
                if (recipe.recipe == Database.electricityGeneration && recipe.entity.factorioType == "solar-panel")
                {
                    BuildSolarPanelAccumulatorView(gui, recipe);
                }
            }
        }