public PersonalGuidConfigurationViewModel(IPersonalGuidRangeSettingsService service)
    {
        this.service          = service;
        data                  = service.CurrentData;
        isEnabled             = data.Enabled;
        startCreatureGuid     = data.StartCreature;
        currentCreatureGuid   = data.CurrentCreature;
        creatureGuidCount     = data.CreatureCount;
        startGameObjectGuid   = data.StartGameObject;
        currentGameObjectGuid = data.CurrentGameObject;
        gameObjectGuidCount   = data.GameObjectCount;

        var save = new DelegateCommand(() =>
        {
            data = new PersonalGuidData()
            {
                Enabled           = isEnabled,
                StartCreature     = startCreatureGuid,
                CurrentCreature   = currentCreatureGuid,
                CreatureCount     = creatureGuidCount,
                StartGameObject   = startGameObjectGuid,
                CurrentGameObject = currentGameObjectGuid,
                GameObjectCount   = gameObjectGuidCount
            };
            service.Override(data);
            RaisePropertyChanged(nameof(IsModified));
        });

        Save = save;
        ResetCreatureCounter   = new DelegateCommand(() => CurrentCreatureGuid = startCreatureGuid);
        ResetGameObjectCounter = new DelegateCommand(() => CurrentGameObjectGuid = startGameObjectGuid);
        AutoDispose(this.ToObservable(() => StartCreatureGuid).Skip(1).SubscribeAction(_ => CurrentCreatureGuid     = startCreatureGuid));
        AutoDispose(this.ToObservable(() => StartGameObjectGuid).Skip(1).SubscribeAction(_ => CurrentGameObjectGuid = startGameObjectGuid));
    }
Esempio n. 2
0
    public void TestSettingsAreSaved()
    {
        var settings = Substitute.For <IUserSettings>();

        settings.Get <PersonalGuidData>().ReturnsForAnyArgs(new PersonalGuidData()
        {
            Enabled           = true,
            StartCreature     = 0,
            StartGameObject   = 0,
            CurrentCreature   = 0,
            CreatureCount     = 4,
            CurrentGameObject = 0,
            GameObjectCount   = 4
        });
        PersonalGuidData lastSettings = default;

        settings.WhenForAnyArgs(x => x.Update <PersonalGuidData>(default))
Esempio n. 3
0
 public void Override(PersonalGuidData data)
 {
     this.data = data;
     Save();
 }
Esempio n. 4
0
 public PersonalGuidRangeService(IUserSettings userSettings)
 {
     this.userSettings = userSettings;
     data = userSettings.Get <PersonalGuidData>();
 }