Exemplo n.º 1
0
        public MainWindow(Mutex mut, WelcomeWindow welWin, INetProto netJungleProto, MapMode selectedMapMode)
        {
            this.m = mut;
            this.currentMapMode = selectedMapMode;

            InitializeComponent();

            rowDefs = new Dictionary<MapMode, RowDefinition>
            {
                { MapMode.SUMMONERS_RIFT, summonersRiftRowDefinition }
            };

            this.welWin = welWin;
            this.netJungleProto = netJungleProto;

            netJungleProto.NewNetworkMessage += new NewNetworkMessageHandler(this.OnNetworkMessage);

            KeyboardManager.Instance.HotKeyPressed += new HotKeyPressedEventHandler(OnHotKeyHandlerWrapper);

            ResetState();

            if (netJungleProto is MockupNetProto)
            {
                nowPlayingRowDefinition.Height = new GridLength(0);
                statusRowDefinition.Height = new GridLength(0);
            }

            // okay, here goes nothing
            foreach (KeyValuePair<MapMode, RowDefinition> rowDefKvp in rowDefs)
            {
                if (rowDefKvp.Key != selectedMapMode)
                {
                    rowDefKvp.Value.Height = new GridLength(0);
                }
            }
        }
Exemplo n.º 2
0
        private void Window_Closing_1(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (mw != null)
            {
                if (NetJungleProto != null)
                    NetJungleProto.Stop();
                NetJungleProto = null;

                RidSelfOfMainWindow();
            }
            NetJungleTimer.Properties.Settings.Default.Save();
        }
Exemplo n.º 3
0
        private void StartMain()
        {
            if (!UseLocalMode)
            {
                String[] remote_server_port_bits = ServerHost.Text.Split(new char[] { ':' }, 2);
                String RemoteServer = remote_server_port_bits[0];
                int RemotePort = (int)uint.Parse(remote_server_port_bits[1]);
                String RemoteRoom = String.Format("{0}:{1}", GameName.Text, ((ComboBoxItem)GameMap.SelectedItem).Tag);

                NetJungleProto = (INetProto)new LiveNetProto(RemoteServer, RemotePort, UserName.Text, ServerPassword.Password, RemoteRoom);
                NetJungleProto.NewNetworkMessage += new NewNetworkMessageHandler(this.OnNetworkMessage);
                NetJungleProto.Go();
            }
            else
            {
                NetJungleProto = (INetProto)new MockupNetProto();
                this.OnNetworkMessage(this, new NewNetworkMessageEventArgs("&CONN")); // mock a connected message
                this.OnNetworkMessage(this, new NewNetworkMessageEventArgs("&LOGGEDIN")); // ...and now logged in
            }
        }
Exemplo n.º 4
0
        public void OnNetworkMessage(object sender, NewNetworkMessageEventArgs e)
        {
            if (!this.Dispatcher.CheckAccess())
            {
                this.Dispatcher.Invoke(new Action<object, NewNetworkMessageEventArgs>(OnNetworkMessage), sender, e);
                return;
            }

            string message = e.NetworkMessage;

            if (message == "&CONN")
            {
                SetStatusLabel("Logging in...");
            }
            else if (message == "&LOGGEDIN")
            {
                mw = new MainWindow(this.m, this, this.NetJungleProto, (MapMode)int.Parse(((ComboBoxItem)this.GameMap.SelectedItem).Tag as string));
                mw.SpectatorModeActive = UseSpectatorMode;
                TextToSpeech.Instance.Enabled = mw.UseSpeechSynth = (SpeechSynth.IsChecked.HasValue && (bool)SpeechSynth.IsChecked);
                App.Current.MainWindow = mw;
                NetJungleProto.NewNetworkMessage -= new NewNetworkMessageHandler(this.OnNetworkMessage);
                mw.Show();

                SaveLastConnectedSettings();
                SetStatusLabel("Ready! The timer UI should now appear in game.\nEnsure you are in BORDERLESS or WINDOWED mode.");

                RunningMain = true;
                // woo

                ActionButton.Content = UseLocalMode ? "Stop" : "Disconnect";
                SetFormFieldsEnabled(false, true);
            }
            else if (message == "&BADPASS")
            {
                RunningMain = false;

                NetJungleProto.Stop();
                NetJungleProto = null;

                SetStatusLabel("Error: password incorrect");
                ActionButton.Content = "Connect";
                SetFormFieldsEnabled(true, true);

                ServerPassword.Background = new SolidColorBrush(Colors.PaleVioletRed);
                ServerPassword.Focus();
            }
            else if (message == "!BADLINEVER")
            {
                RunningMain = false;

                NetJungleProto.Stop();
                NetJungleProto = null;

                SetStatusLabel("Error: that room requires a different client version.");
                ActionButton.Content = "Connect";
                SetFormFieldsEnabled(true, true);
            }
            else if (message == "!RECONNECT 4")
            {
                RunningMain = false;

                NetJungleProto.Stop();
                NetJungleProto = null;

                SetStatusLabel("Error: couldn't connect to server");
                ActionButton.Content = "Connect";
                SetFormFieldsEnabled(true, true);

            }
        }
Exemplo n.º 5
0
        public void GoAway()
        {
            leagueOfLegendsWindowHndl = IntPtr.Zero;

            if (uiTimer != null)
                uiTimer.Stop();
            uiTimer = null;

            if (processingTimer != null)
                processingTimer.Stop();
            processingTimer = null;

            if (uiElements != null)
                uiElements.Clear();
            uiElements = null; // bye ;D

            if (netJungleProto != null)
                netJungleProto.NewNetworkMessage -= new NewNetworkMessageHandler(this.OnNetworkMessage);
            netJungleProto = null;

            KeyboardManager.Instance.HotKeyPressed -= new HotKeyPressedEventHandler(OnHotKeyHandlerWrapper);

            welWin = null;
        }