public async void ApplySetting()
        {
            if (!changed)
            {
                return;
            }
            changed = false;
            bool success = await manager.Apply(key, ControlCheckBox.IsChecked);

            if (!success)
            {
                CheckValue();
            }
        }
        public async void ApplySetting()
        {
            if (!changed)
            {
                return;
            }
            changed = false;
            bool success = await manager.Apply(key, InputField.Text);

            if (!success)
            {
                CheckValue();
            }
        }
예제 #3
0
        public async void ApplySetting()
        {
            if (!changed)
            {
                return;
            }
            changed = false;
            try
            {
                var  value   = double.Parse(InputField.Text);
                bool success = await manager.Apply(key, value);

                if (!success)
                {
                    CheckValue();
                }
            }
            catch
            {
                CheckValue();
            }
        }
 /// <summary>
 /// Set the specified preference to the given value
 /// </summary>
 /// <remarks>
 /// Calls <code>SetNeedsPreferencesSave()</code> to queue a save after a timeout.
 /// </remarks>
 /// <param name="key">The preference lookup key</param>
 /// <param name="value">The preference value</param>
 /// <returns>Whether the preference was successfully applied to the system</returns>
 public async Task <bool> Apply(Preferences.Key key, object?value)
 {
     return(await SettingsManager.Apply(key, value));
 }
예제 #5
0
파일: Fez.cs 프로젝트: conankzhang/fez
        protected override void Initialize()
        {
            if (Logger.ErrorEncountered)
            {
                this.Exit();
                this.IsDisposed = true;
                int num = (int)MessageBox.Show("FEZ has encountered one or more error(s) and could not continue operation.\r\nPlease check the 'Debug Log.txt' file in the application folder for more information about the error.", "Error", MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand);
            }
            DriveInfo[] drives = DriveInfo.GetDrives();
            string      str1   = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).Substring(0, 3);

            foreach (DriveInfo driveInfo in drives)
            {
                if (!(driveInfo.Name != str1))
                {
                    if (driveInfo.IsReady && driveInfo.AvailableFreeSpace < 202928128L)
                    {
                        this.Exit();
                        this.IsDisposed = true;
                        int num = (int)MessageBox.Show("You need at least 200Mb of free space on your main hard drive for FEZ to run.\r\nThis is required for music decompression. Please free some space and try again!", "Error", MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand);
                        break;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            this.deviceManager.SynchronizeWithVerticalRetrace = true;
            this.IsFixedTimeStep   = !Fez.VariableTimeStep;
            this.TargetElapsedTime = TimeSpan.FromSeconds(1.0 / 60.0);
            if (Fez.Force60Hz)
            {
                this.AssumeTargetElapsedTime = true;
            }
            SettingsManager.Apply();
            ServiceHelper.AddService((object)new KeyboardStateManager());
            ServiceHelper.AddService((object)new MouseStateManager());
            ServiceHelper.AddService((object)new PlayerManager());
            ServiceHelper.AddService((object)new CollisionManager());
            ServiceHelper.AddService((object)new DebuggingBag());
            ServiceHelper.AddService((object)new PhysicsManager());
            ServiceHelper.AddService((object)new TimeManager());
            ServiceHelper.AddService((object)new GameStateManager());
            ServiceHelper.AddComponent((IGameComponent) new GamepadsManager((Game)this, !Fez.NoGamePad), true);
            ServiceHelper.AddComponent((IGameComponent)(this.InputManager = new InputManager((Game)this, true, true, !Fez.NoGamePad)), true);
            ServiceHelper.AddComponent((IGameComponent) new ContentManagerProvider((Game)this), true);
            ServiceHelper.AddComponent((IGameComponent) new GameCameraManager((Game)this), true);
            ServiceHelper.AddComponent((IGameComponent) new GameLevelMaterializer((Game)this), true);
            ServiceHelper.AddComponent((IGameComponent) new GameLevelManager((Game)this), true);
            ServiceHelper.AddComponent((IGameComponent) new FogManager((Game)this), true);
            ServiceHelper.AddComponent((IGameComponent) new TargetRenderingManager((Game)this), true);
            ServiceHelper.AddComponent((IGameComponent) new SoundManager((Game)this), true);
            ServiceHelper.AddComponent((IGameComponent) new PersistentThreadPool((Game)this), true);
            ServiceHelper.AddComponent((IGameComponent) new TrixelParticleSystems((Game)this), true);
            ServiceHelper.AddComponent((IGameComponent) new TrialAndAwards((Game)this), true);
            ServiceHelper.AddComponent((IGameComponent) new SpeechBubble((Game)this), true);
            ServiceHelper.AddComponent((IGameComponent) new PlaneParticleSystems((Game)this), true);
            ServiceHelper.AddComponent((IGameComponent) new FontManager((Game)this), true);
            ServiceHelper.AddComponent((IGameComponent) new ScriptingHost((Game)this), true);
            ServiceHelper.AddComponent((IGameComponent) new DotHost((Game)this), true);
            ServiceHelper.AddComponent((IGameComponent) new RotatingGroupsHost((Game)this), true);
            ServiceHelper.AddComponent((IGameComponent) new BigWaterfallHost((Game)this), true);
            ServiceHelper.AddComponent((IGameComponent) new BlackHolesHost((Game)this), true);
            ServiceHelper.AddService((object)new CameraService());
            ServiceHelper.AddService((object)new GomezService());
            ServiceHelper.AddService((object)new LevelService());
            ServiceHelper.AddService((object)new SoundService());
            ServiceHelper.AddService((object)new TimeService());
            ServiceHelper.AddService((object)new VolumeService());
            ServiceHelper.AddService((object)new ArtObjectService());
            ServiceHelper.AddService((object)new GroupService());
            ServiceHelper.AddService((object)new PlaneService());
            ServiceHelper.AddService((object)new NpcService());
            ServiceHelper.AddService((object)new ScriptService());
            ServiceHelper.AddService((object)new SwitchService());
            ServiceHelper.AddService((object)new BitDoorService());
            ServiceHelper.AddService((object)new SuckBlockService());
            ServiceHelper.AddService((object)new PathService());
            ServiceHelper.AddService((object)new SpinBlockService());
            ServiceHelper.AddService((object)new WarpGateService());
            ServiceHelper.AddService((object)new TombstoneService());
            ServiceHelper.AddService((object)new PivotService());
            ServiceHelper.AddService((object)new ValveService());
            ServiceHelper.AddService((object)new CodePatternService());
            ServiceHelper.AddService((object)new LaserEmitterService());
            ServiceHelper.AddService((object)new LaserReceiverService());
            ServiceHelper.AddService((object)new TimeswitchService());
            ServiceHelper.AddService((object)new DotService());
            ServiceHelper.AddService((object)new OwlService());
            ServiceHelper.InitializeServices();
            ServiceHelper.InjectServices((object)this);
            this.GameState.SaveData = new SaveData();
            this.Window.Title       = "FEZ";
            if (Fez.LevelChooser)
            {
                OpenFileDialog openFileDialog1 = new OpenFileDialog();
                openFileDialog1.Title            = "Choose a level!";
                openFileDialog1.InitialDirectory = Path.Combine(Path.Combine(Application.StartupPath, "Content"), "Levels");
                openFileDialog1.Filter           = "Fez Compiled Level (*.xnb)|*.xnb";
                openFileDialog1.Multiselect      = false;
                using (OpenFileDialog openFileDialog2 = openFileDialog1)
                {
                    if (openFileDialog2.ShowDialog((IWin32Window)Control.FromHandle(this.Window.Handle)) == DialogResult.OK)
                    {
                        Fez.LoadComponents(this);
                        base.Initialize();
                        string fileName = openFileDialog2.FileName;
                        string str2     = fileName.Substring(fileName.LastIndexOf("\\Levels\\") + "\\Levels\\".Length);
                        Fez.ForcedLevelName = str2.Substring(0, str2.LastIndexOf(".xnb"));
                        this.GameState.SignInAndChooseStorage(new Action(Common.Util.NullAction));
                        this.GameState.StartNewGame(new Action(Common.Util.NullAction));
                        this.GameState.SaveData.CanOpenMap = true;
                        this.GameState.SaveData.IsNew      = false;
                    }
                    else
                    {
                        this.Exit();
                    }
                }
            }
            else if (Fez.SkipIntro)
            {
                Fez.LoadComponents(this);
                base.Initialize();
                this.GameState.SaveSlot = 0;
                this.GameState.SignInAndChooseStorage(new Action(Common.Util.NullAction));
                this.GameState.LoadSaveFile((Action)(() => this.GameState.LoadLevelAsync(new Action(Common.Util.NullAction))));
                this.GameState.SaveData.CanOpenMap = true;
                this.GameState.SaveData.IsNew      = false;
            }
            else
            {
                ServiceHelper.AddComponent((IGameComponent) new Intro((Game)this));
                base.Initialize();
            }
        }