Exemple #1
0
        private void ConsoleClicked(object sender, RoutedEventArgs e)
        {
            e.Handled = true;
            if (this.PreGameLobby.Visibility == Visibility.Visible) return;
            if (Player.LocalPlayer.Spectator == true) return;

            if (Program.DeveloperMode)
            {
                var wnd = new DeveloperWindow() { Owner = this };
                wnd.Show();
            }
        }
Exemple #2
0
        public PlayWindow()
            : base()
        {
            GameSettings = Program.GameSettings;
            IsHost       = Program.IsHost;
            if (Program.GameEngine.Spectator)
            {
                CanChat = Program.GameSettings.MuteSpectators == false;
            }
            else
            {
                CanChat = true;
            }
            GameMessages       = new ObservableCollection <IGameMessage>();
            _gameMessageReader = new GameMessageDispatcherReader(Program.GameMess);
            var isLocal = Program.GameEngine.IsLocal;

            //GameLogWindow.Show();
            //GameLogWindow.Visibility = Visibility.Hidden;
            Program.Dispatcher = Dispatcher;
            DataContext        = Program.GameEngine;
            InitializeComponent();

            _isLocal = isLocal;
            //Application.Current.MainWindow = this;
            Version oversion = Assembly.GetExecutingAssembly().GetName().Version;

            Title = "Octgn  version : " + oversion + " : " + Program.GameEngine.Definition.Name;
            Program.GameEngine.ComposeParts(this);
            this.Loaded                += OnLoaded;
            this.chat.MouseEnter       += ChatOnMouseEnter;
            this.chat.MouseLeave       += ChatOnMouseLeave;
            this.playerTabs.MouseEnter += PlayerTabsOnMouseEnter;
            this.playerTabs.MouseLeave += PlayerTabsOnMouseLeave;
            this.PreGameLobby.OnClose  += delegate
            {
                if (this.PreGameLobby.StartingGame)
                {
                    PreGameLobby.Visibility = Visibility.Collapsed;
                    if (Player.LocalPlayer.Spectator == false)
                    {
                        Program.GameEngine.ScriptEngine.SetupEngine(false);
                    }


                    table = new TableControl {
                        DataContext = Program.GameEngine.Table, IsTabStop = true
                    };
                    KeyboardNavigation.SetIsTabStop(table, true);
                    TableHolder.Child = table;

                    table.UpdateSided();
                    Keyboard.Focus(table);

                    Program.GameEngine.Ready();
                    if (Program.DeveloperMode && Player.LocalPlayer.Spectator == false)
                    {
                        MenuConsole.Visibility = Visibility.Visible;
                        var wnd = new DeveloperWindow()
                        {
                            Owner = this
                        };
                        wnd.Show();
                    }
                    Program.GameSettings.PropertyChanged += (sender, args) =>
                    {
                        if (Program.GameEngine.Spectator)
                        {
                            CanChat = Program.GameSettings.MuteSpectators == false;
                        }
                        if (Program.IsHost)
                        {
                            Program.Client.Rpc.Settings(Program.GameSettings.UseTwoSidedTable,
                                                        Program.GameSettings.AllowSpectators,
                                                        Program.GameSettings.MuteSpectators);
                        }
                    };
                    // Select proper player tab
                    if (Player.LocalPlayer.Spectator)
                    {
                        Dispatcher.BeginInvoke(new Action(() =>
                        {
                            playerTabs.SelectedIndex = 0;
                        }));
                    }
                }
                else
                {
                    IsRealClosing = true;
                    this.TryClose();
                }
            };

            this.Loaded += delegate
            {
                Program.OnOptionsChanged += ProgramOnOnOptionsChanged;
                _gameMessageReader.Start(
                    x =>
                {
                    Dispatcher.Invoke(new Action(
                                          () =>
                    {
                        bool gotOne = false;
                        foreach (var m in x)
                        {
                            var b = Octgn.Play.Gui.ChatControl.GameMessageToBlock(m);
                            if (b == null)
                            {
                                continue;
                            }

                            if (m is NotifyBarMessage)
                            {
                                GameMessages.Insert(0, m);
                                gotOne = true;
                                while (GameMessages.Count > 60)
                                {
                                    GameMessages.Remove(GameMessages.Last());
                                }
                            }
                        }
                        if (!gotOne)
                        {
                            return;
                        }

                        if (_showBottomBar != null && _showBottomBar.GetCurrentProgress(BottomBar) > 0)
                        {
                            _showBottomBar.Seek(BottomBar, TimeSpan.FromMilliseconds(500), TimeSeekOrigin.BeginTime);
                        }
                        else
                        {
                            if (_showBottomBar == null)
                            {
                                _showBottomBar = BottomBar.Resources["ShowBottomBar"] as Storyboard;
                            }
                            _showBottomBar.Begin(BottomBar, HandoffBehavior.Compose, true);
                        }
                        if (this.IsActive == false)
                        {
                            this.FlashWindow();
                        }
                        if (this.IsActive == false && Prefs.EnableGameSound && DateTime.Now > lastMessageSoundTime.AddSeconds(10))
                        {
                            Octgn.Utils.Sounds.PlayGameMessageSound();
                            lastMessageSoundTime = DateTime.Now;
                        }
                    }));
                });
            };
            this.Activated += delegate
            {
                this.StopFlashingWindow();
            };
            this.Unloaded += delegate
            {
                Program.OnOptionsChanged -= ProgramOnOnOptionsChanged;
                _gameMessageReader.Stop();
            };

            //this.chat.NewMessage = x =>
            //{
            //    GameMessages.Insert(0, x);
            //};
        }
Exemple #3
0
        public PlayWindow()
            : base()
        {
            GameSettings = Program.GameSettings;
            IsHost = Program.IsHost;
            if (Program.GameEngine.Spectator)
            {
                CanChat = Program.GameSettings.MuteSpectators == false;
            }
            else
            {
                CanChat = true;
            }
            GameMessages = new ObservableCollection<IGameMessage>();
            _gameMessageReader = new GameMessageDispatcherReader(Program.GameMess);
            var isLocal = Program.GameEngine.IsLocal;
            //GameLogWindow.Show();
            //GameLogWindow.Visibility = Visibility.Hidden;
            Program.Dispatcher = Dispatcher;
            DataContext = Program.GameEngine;
            InitializeComponent();

            _isLocal = isLocal;
            //Application.Current.MainWindow = this;
            Version oversion = Assembly.GetExecutingAssembly().GetName().Version;
            Title = "Octgn  version : " + oversion + " : " + Program.GameEngine.Definition.Name;
            Program.GameEngine.ComposeParts(this);
            this.Loaded += OnLoaded;
            this.chat.MouseEnter += ChatOnMouseEnter;
            this.chat.MouseLeave += ChatOnMouseLeave;
            this.playerTabs.MouseEnter += PlayerTabsOnMouseEnter;
            this.playerTabs.MouseLeave += PlayerTabsOnMouseLeave;
            this.PreGameLobby.OnClose += delegate
            {
                if (this.PreGameLobby.StartingGame)
                {
                    PreGameLobby.Visibility = Visibility.Collapsed;
                    if (Player.LocalPlayer.Spectator == false)
                        Program.GameEngine.ScriptEngine.SetupEngine(false);


                    table = new TableControl { DataContext = Program.GameEngine.Table, IsTabStop = true };
                    KeyboardNavigation.SetIsTabStop(table, true);
                    TableHolder.Child = table;

                    table.UpdateSided();
                    Keyboard.Focus(table);

					Dispatcher.BeginInvoke(new Action(Program.GameEngine.Ready), DispatcherPriority.ContextIdle);
                    
                    //Program.GameEngine.Ready();
                    if (Program.DeveloperMode && Player.LocalPlayer.Spectator == false)
                    {
                        MenuConsole.Visibility = Visibility.Visible;
                        var wnd = new DeveloperWindow() { Owner = this };
                        wnd.Show();
                    }
                    Program.GameSettings.PropertyChanged += (sender, args) =>
                        {
                            if (Program.GameEngine.Spectator)
                            {
                                CanChat = Program.GameSettings.MuteSpectators == false;
                            }
                            if (Program.IsHost)
                            {
                                Program.Client.Rpc.Settings(Program.GameSettings.UseTwoSidedTable,
                                                            Program.GameSettings.AllowSpectators,
                                                            Program.GameSettings.MuteSpectators);
                            }
                        };
                    // Select proper player tab
                    if (Player.LocalPlayer.Spectator)
                    {
                        Dispatcher.BeginInvoke(new Action(() =>
                            {
                                playerTabs.SelectedIndex = 0;
                            }));
                    }
                }
                else
                {
                    IsRealClosing = true;
                    this.TryClose();
                }
            };

            this.Loaded += delegate
            {
                Program.OnOptionsChanged += ProgramOnOnOptionsChanged;
                _gameMessageReader.Start(
                    x =>
                    {
                        Dispatcher.Invoke(new Action(
                            () =>
                            {
                                bool gotOne = false;
                                foreach (var m in x)
                                {
                                    var b = Octgn.Play.Gui.ChatControl.GameMessageToBlock(m);
                                    if (b == null) continue;

                                    if (m is NotifyBarMessage)
                                    {
                                        GameMessages.Insert(0, m);
                                        gotOne = true;
                                        while (GameMessages.Count > 60)
                                        {
                                            GameMessages.Remove(GameMessages.Last());
                                        }
                                    }
                                }
                                if (!gotOne) return;

                                if (_showBottomBar != null && _showBottomBar.GetCurrentProgress(BottomBar) > 0)
                                {
                                    _showBottomBar.Seek(BottomBar, TimeSpan.FromMilliseconds(500), TimeSeekOrigin.BeginTime);
                                }
                                else
                                {
                                    if (_showBottomBar == null)
                                    {
                                        _showBottomBar = BottomBar.Resources["ShowBottomBar"] as Storyboard;
                                    }
                                    _showBottomBar.Begin(BottomBar, HandoffBehavior.Compose, true);
                                }
                                if (this.IsActive == false)
                                {
                                    this.FlashWindow();
                                }
                                if (this.IsActive == false && Prefs.EnableGameSound && DateTime.Now > lastMessageSoundTime.AddSeconds(10))
                                {
                                    Octgn.Utils.Sounds.PlayGameMessageSound();
                                    lastMessageSoundTime = DateTime.Now;
                                }
                            }));
                    });
            };
            this.Activated += delegate
            {
                this.StopFlashingWindow();
            };
            this.Unloaded += delegate
            {
                Program.OnOptionsChanged -= ProgramOnOnOptionsChanged;
                _gameMessageReader.Stop();
            };

            
            //this.chat.NewMessage = x =>
            //{
            //    GameMessages.Insert(0, x);
            //};
        }