コード例 #1
0
        protected AbstractMainWindowViewModel(Window view)
        {
            View = view;
            var dummyGame = Game.Init(7, MockUtil.DummyPlayerSpecPair(7));

            GameScreenViewModel         = new GameScreenViewModel(MessengerInstance, dummyGame);
            GameCreationScreenViewModel = new GameCreationScreenViewModel(MessengerInstance);
            StartupScreenViewModel      = new StartupScreenViewModel(MessengerInstance);
            LoadGameScreenViewModel     = new LoadGameScreenViewModel(MessengerInstance);
            SaveManager = new SaveManager(MessengerInstance);

            QuitCommand = new RelayCommand(ShutdownApplication);

            RegisterMessageHandlers();
        }
コード例 #2
0
        private void RegisterMessageHandlers()
        {
            ShowNewGameMessage.Register(MessengerInstance, this, SwitchToGameCreationScreen);
            ShowMainMenuMessage.Register(MessengerInstance, this, SwitchToStartupScreen);
            ShowLoadMenuMessage.Register(MessengerInstance, this, () => {
                SwitchToGameLoadScreen();
                LoadGameScreenViewModel.Refresh(SaveManager.AllSaves());
            });


            void OpenGameAction(((string, GameMemento), ViewMode) payload)
            {
                var((id, memento), mode) = payload;
                GameScreenViewModel.Load(id, Game.FromMemento(memento));
                GameScreenViewModel.ActiveMode = mode;

                SwitchToGameScreen();
            }

            // switch to game screen with a newly created game, assigning it an id
            OpenNewGame.Register(MessengerInstance, this, payload => {
                var(game, mode) = payload;
                OpenGameAction(((SaveManager.NextId(), game.Memento), mode));
            });