Exemple #1
0
    public void SetModel(int scenario, IChildScenarioWarriorService childScenarioWarriorService)
    {
        Items.Clear();
        foreach (int id in childScenarioWarriorService.ValidIds())
        {
            var    sw             = childScenarioWarriorService.Retrieve(id);
            string pokemon        = "Default";
            string pokemonAbility = "Default";

            if (!sw.ScenarioPokemonIsDefault(0))
            {
                var spid = sw.GetScenarioPokemon(0);
                var childScenarioPokemonService = _scenarioPokemonService.Retrieve(scenario);
                if (childScenarioPokemonService.ValidateId(spid))
                {
                    var sp        = childScenarioPokemonService.Retrieve(spid);
                    int pokemonId = (int)sp.Pokemon;
                    int abilityId = (int)sp.Ability;
                    if (_pokemonService.ValidateId(pokemonId))
                    {
                        pokemon = _pokemonService.IdToName(pokemonId);
                    }
                    if (_abilityService.ValidateId(abilityId))
                    {
                        pokemonAbility = _abilityService.IdToName(abilityId);
                    }
                }
            }

            Items.Add(new ScenarioWarriorGridItemViewModel(id, sw, pokemon, pokemonAbility));
        }
    }
Exemple #2
0
    public override void Initialise(IServiceGetter modServices)
    {
        base.Initialise(modServices);
        _scenarioPokemonService = modServices.Get <IScenarioPokemonService>();
        var vm = modServices.Get <IScenarioWarriorViewModel>();

        _childScenarioWarriorService = _service.Retrieve(0);
        var innerSelector = new SelectorViewModel(_childScenarioWarriorService, vm, id => vm.SetModel((ScenarioId)_scenario, id, _childScenarioWarriorService.Retrieve(id)));

        _viewModel = new SelectorViewModelWithoutScroll(_service, innerSelector, id =>
        {
            _scenario = id;
            _childScenarioWarriorService = _service.Retrieve(id);
            innerSelector.SetDisplayItems(_childScenarioWarriorService.GetComboBoxItemsExceptDefault());
            vm.SetModel((ScenarioId)_scenario, innerSelector.Selected, _childScenarioWarriorService.Retrieve(innerSelector.Selected));
        });
    }