Пример #1
0
    /// <summary>
    /// Sets up the basic GMCM (does not include PFM machines).
    /// </summary>
    private void SetUpBasicConfig()
    {
        if (this.gmcmHelper?.HasGottenAPI == true)
        {
            if (this.Helper.ModRegistry.IsLoaded("Digus.ProducerFrameworkMod"))
            {
                this.gmcmHelper.Register(
                    reset: static () =>
                {
                    Config = new();
                    PFMMachineHandler.RefreshValidityList(Game1.currentLocation);
                },
                    save: () =>
                {
                    this.Helper.WriteConfig(Config);
                    PFMMachineHandler.RefreshValidityList(Game1.currentLocation);
                });
            }
            else
            {
                this.gmcmHelper.Register(
                    reset: static () => Config = new(),
                    save: () => this.Helper.WriteConfig(Config));
            }
            this.gmcmHelper.AddParagraph(I18n.ModDescription)
            .AddColorPicker(
                name: I18n.EmptyColor_Title,
                getValue: static () => Config.EmptyColor,
                setValue: static (val) => Config.EmptyColor = val,
                tooltip: I18n.EmptyColor_Description,
                showAlpha: true,
                colorPickerStyle: (uint)IGMCMOptionsAPI.ColorPickerStyle.Default,
                defaultColor: Color.Red)
            .AddColorPicker(
                name: I18n.InvalidColor_Title,
                getValue: static () => Config.InvalidColor,
                setValue: static (val) => Config.InvalidColor = val,
                tooltip: I18n.InvalidColor_Description,
                showAlpha: true,
                colorPickerStyle: (uint)IGMCMOptionsAPI.ColorPickerStyle.Default,
                defaultColor: Color.Gray)
            .AddPageHere(
                pageId: "individual-machines",
                linkText: I18n.IndividualMachines_Title,
                tooltip: I18n.IndividualMachines_Description,
                pageTitle: I18n.IndividualMachines_Title);

            foreach (VanillaMachinesEnum machine in Config.VanillaMachines.Keys)
            {
                this.gmcmHelper.AddBoolOption(
                    name: () => machine.GetBestTranslatedString(),
                    getValue: () => Config.VanillaMachines[machine],
                    setValue: (bool val) => Config.VanillaMachines[machine] = val);
            }
        }
    }
Пример #2
0
    private void OnSaveLoaded(object?sender, SaveLoadedEventArgs e)
    {
        this.migrator = new(this.ModManifest, this.Helper, this.Monitor);
        this.migrator.ReadVersionInfo();
        this.Helper.Events.GameLoop.Saved += this.WriteMigrationData;

        if (this.Helper.ModRegistry.IsLoaded("Digus.ProducerFrameworkMod"))
        {
            PFMMachineHandler.ProcessPFMRecipes();

            foreach (int machineID in PFMMachineHandler.PFMMachines)
            {
                // Prepopulate the machine list.
                _ = Config.ProducerFrameworkModMachines.TryAdd(machineID.GetBigCraftableName(), true);
            }

            if (this.gmcmHelper?.HasGottenAPI == true)
            {
                this.gmcmHelper.Unregister();
                this.SetUpBasicConfig();

                this.gmcmHelper.AddSectionTitle(I18n.PFM_Section)
                .AddParagraph(I18n.PFM_Description);

                foreach (int machineID in PFMMachineHandler.PFMMachines)
                {
                    // Add an option for it.
                    this.gmcmHelper.AddBoolOption(
                        name: () => machineID.GetBigCraftableTranslatedName(),
                        getValue: () => !Config.ProducerFrameworkModMachines.TryGetValue(machineID.GetBigCraftableName(), out bool val) || val,
                        setValue: (val) => Config.ProducerFrameworkModMachines[machineID.GetBigCraftableName()] = val);
                }
            }

            this.Monitor.Log("PFM compat set up!", LogLevel.Trace);
            this.Helper.WriteConfig(Config);
        }
        else
        {
            this.Monitor.Log("PFM not installed, integration unnecessary", LogLevel.Trace);
        }
    }
Пример #3
0
    private void OnGameLaunched(object?sender, GameLaunchedEventArgs e)
    {
        this.ApplyPatches(new Harmony(this.ModManifest.UniqueID));

        PFMMachineHandler.TryGetAPI(this.Helper.ModRegistry);
        this.gmcmHelper = new(this.Monitor, this.Helper.Translation, this.Helper.ModRegistry, this.ModManifest);
        if (this.gmcmHelper.TryGetAPI())
        {
            this.gmcmHelper.TryGetOptionsAPI();
            this.SetUpBasicConfig();
        }
        if (this.Helper.ModRegistry.IsLoaded("Digus.ProducerFrameworkMod"))
        {
            this.Helper.Events.Player.Warped       += this.OnPlayerWarp;
            this.Helper.Events.GameLoop.DayStarted += this.OnDayStarted;

            this.Helper.ConsoleCommands.Add(
                name: "av.hem.list_pfm_machines",
                documentation: "Prints info about PFM machines...",
                callback: PFMMachineHandler.PrintPFMRecipes);
        }
    }
Пример #4
0
 private void OnPlayerWarp(object?sender, WarpedEventArgs e)
 => PFMMachineHandler.RefreshValidityList(e.NewLocation);
Пример #5
0
 private void OnDayStarted(object?sender, DayStartedEventArgs e)
 => PFMMachineHandler.RefreshValidityList(Game1.currentLocation);