Example #1
0
 public override void Build(ImGui gui)
 {
     BuildHeader(gui, header);
     if (gui.BuildTextInput(list.filter, out var changedFilter, "Start typing for search", icon: Icon.Search))
     {
         list.filter = changedFilter;
     }
     searchBox = gui.lastRect;
     list.Build(gui);
 }
Example #2
0
        private void BuildUnitPerTime(ImGui gui, bool fluid, ProjectPreferences preferences)
        {
            var unit    = fluid ? preferences.fluidUnit : preferences.itemUnit;
            var newUnit = unit;

            if (gui.BuildRadioButton("Simple Amount" + preferences.GetPerTimeUnit().suffix, unit == 0f))
            {
                newUnit = 0f;
            }
            using (gui.EnterRow())
            {
                if (gui.BuildRadioButton("Custom: 1 unit equals", unit != 0f))
                {
                    newUnit = 1f;
                }
                gui.AllocateSpacing();
                gui.allocator = RectAllocator.RightRow;
                if (!fluid)
                {
                    if (gui.BuildButton("Set from belt"))
                    {
                        gui.ShowDropDown((ImGui dropGui, ref bool closed) =>
                        {
                            closed = dropGui.BuildInlineObejctListAndButton <Entity>(Database.entities.all.Where(x => x.beltItemsPerSecond > 0f).ToArray(), DataUtils.DefaultOrdering, setBelt =>
                            {
                                preferences.RecordUndo(true);
                                preferences.itemUnit = setBelt.beltItemsPerSecond;
                            }, "Select belt", extra: b => DataUtils.FormatAmount(b.beltItemsPerSecond, UnitOfMeasure.PerSecond));
                            gui.Rebuild();
                        });
                    }
                }
                gui.BuildText("per second");
                if (gui.BuildTextInput(DataUtils.FormatAmount(unit, UnitOfMeasure.None), out var updated, null, Icon.None, true) &&
                    DataUtils.TryParseAmount(updated, out var parsed, UnitOfMeasure.None))
                {
                    newUnit = parsed;
                }
            }
            gui.AllocateSpacing(1f);

            if (newUnit != unit)
            {
                preferences.RecordUndo(true);
                if (fluid)
                {
                    preferences.fluidUnit = newUnit;
                }
                else
                {
                    preferences.itemUnit = newUnit;
                }
            }
        }
Example #3
0
        public static void Build(ImGui gui, ref string name, FactorioObject icon, Action <FactorioObject> setIcon)
        {
            gui.BuildTextInput(name, out name, "Input name");
            if (gui.BuildFactorioObjectButton(icon, 4f, MilestoneDisplay.None, SchemeColor.Grey))
            {
                SelectObjectPanel.Select(Database.objects.all, "Select icon", setIcon);
            }

            if (icon == null && gui.isBuilding)
            {
                gui.DrawText(gui.lastRect, "And select icon", RectAlignment.Middle);
            }
        }
Example #4
0
        public override void Build(ImGui gui)
        {
            BuildHeader(gui, "Units of measure");
            gui.BuildText("Unit of time:", Font.subheader);
            var prefs = Project.current.preferences;

            using (gui.EnterRow())
            {
                if (gui.BuildRadioButton("Second", prefs.time == 1))
                {
                    prefs.RecordUndo(true).time = 1;
                }
                if (gui.BuildRadioButton("Minute", prefs.time == 60))
                {
                    prefs.RecordUndo(true).time = 60;
                }
                if (gui.BuildRadioButton("Hour", prefs.time == 3600))
                {
                    prefs.RecordUndo(true).time = 3600;
                }
                if (gui.BuildRadioButton("Custom", prefs.time != 1 && prefs.time != 60 && prefs.time != 3600))
                {
                    prefs.RecordUndo(true).time = 0;
                }
                if (gui.BuildTextInput(prefs.time.ToString(), out var newTime, null, delayed: true) && int.TryParse(newTime, out var parsed))
                {
                    prefs.RecordUndo(true).time = parsed;
                }
            }
            gui.AllocateSpacing(1f);
            gui.BuildText("Item production/consumption:", Font.subheader);
            BuildUnitPerTime(gui, false, prefs);
            gui.BuildText("Fluid production/consumption:", Font.subheader);
            BuildUnitPerTime(gui, true, prefs);
            if (gui.BuildButton("Done"))
            {
                Close();
            }
            if (prefs.justChanged)
            {
                MainScreen.Instance.RebuildProjectView();
            }
        }
Example #5
0
        public override void Build(ImGui gui)
        {
            BuildHeader(gui, "Module autofill parameters");
            BuildSimple(gui, modules);
            if (gui.BuildCheckBox("Fill modules in miners", modules.fillMiners, out var newFill))
            {
                modules.RecordUndo().fillMiners = newFill;
            }
            gui.AllocateSpacing();
            gui.BuildText("Filler module:", Font.subheader);
            gui.BuildText("Use this module when aufofill doesn't add anything (for example when productivity modules doesn't fit)", wrap: true);
            if (gui.BuildFactorioObjectButtonWithText(modules.fillerModule))
            {
                SelectObjectPanel.Select(Database.allModules, "Select filler module", select => { modules.RecordUndo().fillerModule = select; }, true);
            }

            gui.AllocateSpacing();
            gui.BuildText("Beacons & beacon modules:", Font.subheader);
            if (gui.BuildFactorioObjectButtonWithText(modules.beacon))
            {
                SelectObjectPanel.Select(Database.allBeacons, "Select beacon", select =>
                {
                    modules.RecordUndo();
                    modules.beacon = select;
                    if (modules.beaconModule != null && (modules.beacon == null || !modules.beacon.CanAcceptModule(modules.beaconModule.module)))
                    {
                        modules.beaconModule = null;
                    }
                    gui.Rebuild();
                }, true);
            }

            if (gui.BuildFactorioObjectButtonWithText(modules.beaconModule))
            {
                SelectObjectPanel.Select(Database.allModules.Where(x => modules.beacon?.CanAcceptModule(x.module) ?? false), "Select module for beacon", select => { modules.RecordUndo().beaconModule = select; }, true);
            }

            using (gui.EnterRow())
            {
                gui.BuildText("Beacons per building: ");
                if (gui.BuildTextInput(modules.beaconsPerBuilding.ToString(), out var newText, null, Icon.None, true, new Padding(0.5f, 0f)) &&
                    int.TryParse(newText, out var newAmount) && newAmount > 0)
                {
                    modules.RecordUndo().beaconsPerBuilding = newAmount;
                }
            }
            gui.BuildText("Please note that beacons themself are not part of the calculation", wrap: true);

            using (gui.EnterRow())
            {
                gui.BuildText("Mining productivity bonus (project-wide setting): ");
                if (gui.BuildTextInput(DataUtils.FormatAmount(Project.current.settings.miningProductivity, UnitOfMeasure.Percent), out var newText, null, Icon.None, true, new Padding(0.5f, 0f)) &&
                    DataUtils.TryParseAmount(newText, out var newAmount, UnitOfMeasure.Percent))
                {
                    Project.current.settings.RecordUndo().miningProductivity = newAmount;
                }
            }

            if (gui.BuildButton("Done"))
            {
                Close();
            }
        }
Example #6
0
        public override void Build(ImGui gui)
        {
            BuildHeader(gui, "Preferences");
            gui.BuildText("Unit of time:", Font.subheader);
            var prefs = Project.current.preferences;

            using (gui.EnterRow())
            {
                if (gui.BuildRadioButton("Second", prefs.time == 1))
                {
                    prefs.RecordUndo(true).time = 1;
                }
                if (gui.BuildRadioButton("Minute", prefs.time == 60))
                {
                    prefs.RecordUndo(true).time = 60;
                }
                if (gui.BuildRadioButton("Hour", prefs.time == 3600))
                {
                    prefs.RecordUndo(true).time = 3600;
                }
                if (gui.BuildRadioButton("Custom", prefs.time != 1 && prefs.time != 60 && prefs.time != 3600))
                {
                    prefs.RecordUndo(true).time = 0;
                }
                if (gui.BuildTextInput(prefs.time.ToString(), out var newTime, null, delayed: true) && int.TryParse(newTime, out var parsed))
                {
                    prefs.RecordUndo(true).time = parsed;
                }
            }
            gui.AllocateSpacing(1f);
            gui.BuildText("Item production/consumption:", Font.subheader);
            BuildUnitPerTime(gui, false, prefs);
            gui.BuildText("Fluid production/consumption:", Font.subheader);
            BuildUnitPerTime(gui, true, prefs);

            ChoiceObject(gui, "Default belt:", Database.allBelts, prefs.defaultBelt, s =>
            {
                prefs.RecordUndo().defaultBelt = s;
                gui.Rebuild();
            });
            ChoiceObject(gui, "Default inserter:", Database.allInserters, prefs.defaultInserter, s =>
            {
                prefs.RecordUndo().defaultInserter = s;
                gui.Rebuild();
            });

            using (gui.EnterRow())
            {
                gui.BuildText("Inserter capacity:", topOffset: 0.5f);
                if (gui.BuildTextInput(prefs.inserterCapacity.ToString(), out var newText2, null, Icon.None, true) && int.TryParse(newText2, out var capacity2))
                {
                    prefs.RecordUndo().inserterCapacity = capacity2;
                }
            }

            if (gui.BuildButton("Done"))
            {
                Close();
            }
            if (prefs.justChanged)
            {
                MainScreen.Instance.RebuildProjectView();
            }
        }