예제 #1
0
        private void DrawDesiredProduct(ImGui gui, ProductionLink element)
        {
            gui.allocator = RectAllocator.Stretch;
            gui.spacing   = 0f;
            var error = element.flags.HasFlags(ProductionLink.Flags.LinkNotMatched);
            var evt   = gui.BuildFactorioObjectWithEditableAmount(element.goods, element.amount, element.goods.flowUnitOfMeasure, out var newAmount, error ? SchemeColor.Error : SchemeColor.Primary);

            if (evt == GoodsWithAmountEvent.ButtonClick)
            {
                OpenProductDropdown(gui, gui.lastRect, element.goods, element.amount, element, ProductDropdownType.DesiredProduct, null, element.owner);
            }
            else if (evt == GoodsWithAmountEvent.TextEditing && newAmount != 0)
            {
                element.RecordUndo().amount = newAmount;
            }
        }
예제 #2
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);
                }
            }
        }
예제 #3
0
        private void DrawRecipeModules(ImGui gui, EntityBeacon beacon, ref ModuleEffects effects)
        {
            var remainingModules = recipe.entity?.moduleSlots ?? 0;

            using (var grid = gui.EnterInlineGrid(3f, 1f))
            {
                var list = beacon != null ? recipe.modules.beaconList : recipe.modules.list;
                foreach (var module in list)
                {
                    grid.Next();
                    var evt = gui.BuildFactorioObjectWithEditableAmount(module.module, module.fixedCount, UnitOfMeasure.None, out var newAmount);
                    if (evt == GoodsWithAmountEvent.ButtonClick)
                    {
                        SelectObjectPanel.Select(GetModules(beacon), "Select module", sel =>
                        {
                            if (sel == null)
                            {
                                recipe.modules.RecordUndo().list.Remove(module);
                            }
                            else
                            {
                                module.RecordUndo().module = sel;
                            }
                            gui.Rebuild();
                        }, DataUtils.FavouriteModule, true);
                    }
                    else if (evt == GoodsWithAmountEvent.TextEditing)
                    {
                        var amountInt = MathUtils.Floor(newAmount);
                        if (amountInt < 0)
                        {
                            amountInt = 0;
                        }
                        module.RecordUndo().fixedCount = amountInt;
                    }

                    if (beacon == null)
                    {
                        var count = Math.Min(remainingModules, module.fixedCount > 0 ? module.fixedCount : int.MaxValue);
                        if (count > 0)
                        {
                            effects.AddModules(module.module.module, count);
                            remainingModules -= count;
                        }
                    }
                    else
                    {
                        effects.AddModules(module.module.module, module.fixedCount * beacon.beaconEfficiency);
                    }
                }

                grid.Next();
                if (gui.BuildButton(Icon.Plus, SchemeColor.Primary, SchemeColor.PrimalyAlt, size: 2.5f))
                {
                    gui.BuildObjectSelectDropDown(GetModules(beacon), DataUtils.FavouriteModule, sel =>
                    {
                        recipe.modules.RecordUndo();
                        list.Add(new RecipeRowCustomModule(recipe.modules, sel));
                        gui.Rebuild();
                    }, "Select module");
                }
            }
        }