예제 #1
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);
                    }
                }
            }
        }
예제 #2
0
 private void ShowModuleDropDown(ImGui gui, RecipeRow recipe)
 {
     if (InputSystem.Instance.control)
     {
         if (recipe.entity != null && ModuleCustomisationScreen.copiedModuleSettings != null)
         {
             var result = JsonUtils.LoadFromJson(ModuleCustomisationScreen.copiedModuleSettings, recipe, recipe.modules);
             foreach (var module in result.list)
             {
                 if (!recipe.recipe.modules.Contains(module.module) && recipe.entity.CanAcceptModule(module.module.module))
                 {
                     MessageBox.Show("Module mismatch", "This module cannot be used: " + module.module.locName, "OK");
                     return;
                 }
             }
             recipe.RecordUndo().modules = JsonUtils.LoadFromJson(ModuleCustomisationScreen.copiedModuleSettings, recipe, recipe.modules);
         }
     }
     else if (recipe.entity?.moduleSlots == 0 || recipe.modules != null && (recipe.modules.list.Count > 1 || recipe.modules.beacon != null))
     {
         ModuleCustomisationScreen.Show(recipe);
     }
     else
     {
         var modules = recipe.recipe.modules.Where(x => recipe.entity?.CanAcceptModule(x.module) ?? false).ToArray();
         gui.ShowDropDown((ImGui dropGui, ref bool closed) =>
         {
             dropGui.BuildText("Selecting a fixed module will override auto-module filler!", wrap: true);
             closed = dropGui.BuildInlineObejctListAndButton(modules, DataUtils.FavouriteModule, recipe.SetFixedModule, "Select fixed module", allowNone: recipe.modules != null);
             if (dropGui.BuildButton("Customize modules") && (closed = true))
             {
                 ModuleCustomisationScreen.Show(recipe);
             }
         });
     }
 }