Example #1
0
        private static void TryRestore()
        {
            On.Celeste.SaveData.Start -= SaveDataOnStart;

            if (origSettings != null)
            {
                Settings.Instance.CopyAllFields(origSettings, true);
                Settings.Instance.ApplyVolumes();
                Settings.Instance.ApplyScreen();
                Settings.Instance.ApplyLanguage();
                (Engine.Scene as Overworld)?.GetUI <OuiMainMenu>()?.CreateButtons();
                origSettings = null;
            }

            if (origAssists != null)
            {
                SaveData.Instance.Assists = origAssists.Value;
                SetCommandHandler.ResetVariants(origAssists.Value);
                origAssists = null;
            }

            if (origModSettings != null)
            {
                foreach (EverestModule module in Everest.Modules)
                {
                    try {
                        if (module?._Settings != null && origModSettings.TryGetValue(module, out object modSettings) && modSettings != null)
                        {
                            bool showHitbox = CelesteTasModule.Settings.ShowHitboxes;

                            if (modSettings is CelesteTasModuleSettings backupTasSettings)
                            {
                                CelesteTasModuleSettings tasSettings = CelesteTasModule.Settings;
                                backupTasSettings.HideTriggerHitboxes       = tasSettings.HideTriggerHitboxes;
                                backupTasSettings.ShowActualCollideHitboxes = tasSettings.ShowActualCollideHitboxes;
                                backupTasSettings.SimplifiedGraphics        = tasSettings.SimplifiedGraphics;
                                backupTasSettings.HideGameplay       = tasSettings.HideGameplay;
                                backupTasSettings.CenterCamera       = tasSettings.CenterCamera;
                                backupTasSettings.InfoHud            = tasSettings.InfoHud;
                                backupTasSettings.InfoCustomTemplate = tasSettings.InfoCustomTemplate;
                                backupTasSettings.RoundPosition      = tasSettings.RoundPosition;
                                backupTasSettings.RoundSpeed         = tasSettings.RoundSpeed;
                                backupTasSettings.RoundVelocity      = tasSettings.RoundVelocity;
                                backupTasSettings.RoundCustomInfo    = tasSettings.RoundCustomInfo;
                            }

                            module._Settings.CopyAllProperties(modSettings);
                            module._Settings.CopyAllFields(modSettings, true);

                            CelesteTasModule.Settings.ShowHitboxes = showHitbox;
                        }
                    } catch (NullReferenceException) {
                        // maybe caused by hot reloading
                    }
                }

                origModSettings = null;
            }
        }
Example #2
0
        public async Task SetCommandHandlerDefaultConfigurationHasDefinedVariables()
        {
            var definedVariables = new[] { "border", "topkmap" };
            var setCommand = new SetCommand();
            var setCommandHandler = new SetCommandHandler(this.notificationService);

            (await setCommandHandler.Execute(setCommand)).Should().BeTrue();

            var output = this.notificationService.InfoString;
            foreach (var variable in definedVariables)
            {
                output.Should().Contain(variable);
            }

            // Set command appends a new line by default to end of output, hence + 1
            output.Split('\r').Length.Should().Be(definedVariables.Length + 1);
        }
Example #3
0
        public async Task SetCommandHandlerHasDefaultValueForBorderVariable()
        {
            var setCommand = new SetCommand { Args = "border" };
            var setCommandHandler = new SetCommandHandler(this.notificationService);

            (await setCommandHandler.Execute(setCommand)).Should().BeTrue();

            this.notificationService.InfoString.Should().Be("border = 1\r\n");
        }