示例#1
0
        public override void KeyEvent(Int32 key)
        {
            switch (key)
            {
            case KeysDef.K_ESCAPE:
                LanConfigMenu.Show(Host);
                break;

            case KeysDef.K_SPACE:
                SearchMenu.Show(Host);
                break;

            case KeysDef.K_UPARROW:
            case KeysDef.K_LEFTARROW:
                Host.Sound.LocalSound("misc/menu1.wav");
                _Cursor--;
                if (_Cursor < 0)
                {
                    _Cursor = Host.Network.HostCacheCount - 1;
                }
                break;

            case KeysDef.K_DOWNARROW:
            case KeysDef.K_RIGHTARROW:
                Host.Sound.LocalSound("misc/menu1.wav");
                _Cursor++;
                if (_Cursor >= Host.Network.HostCacheCount)
                {
                    _Cursor = 0;
                }
                break;

            case KeysDef.K_ENTER:
                Host.Sound.LocalSound("misc/menu2.wav");
                Host.Menu.ReturnMenu    = this;
                Host.Menu.ReturnOnError = true;
                _Sorted = false;
                CurrentMenu.Hide( );
                Host.Commands.Buffer.Append(String.Format("connect \"{0}\"\n", Host.Network.HostCache[_Cursor].cname));
                break;

            default:
                break;
            }
        }
示例#2
0
        public override void KeyEvent(Int32 key)
        {
            switch (key)
            {
            case KeysDef.K_ESCAPE:
                MultiPlayerMenu.Show(Host);
                break;

            case KeysDef.K_UPARROW:
                Host.Sound.LocalSound("misc/menu1.wav");
                _Cursor--;
                if (_Cursor < 0)
                {
                    _Cursor = NUM_LANCONFIG_CMDS - 1;
                }
                break;

            case KeysDef.K_DOWNARROW:
                Host.Sound.LocalSound("misc/menu1.wav");
                _Cursor++;
                if (_Cursor >= NUM_LANCONFIG_CMDS)
                {
                    _Cursor = 0;
                }
                break;

            case KeysDef.K_ENTER:
                if (_Cursor == 0)
                {
                    break;
                }

                Host.Menu.EnterSound  = true;
                Host.Network.HostPort = _Port;

                if (_Cursor == 1)
                {
                    if (StartingGame)
                    {
                        GameOptionsMenu.Show(Host);
                    }
                    else
                    {
                        SearchMenu.Show(Host);
                    }
                    break;
                }

                if (_Cursor == 2)
                {
                    Host.Menu.ReturnMenu    = this;
                    Host.Menu.ReturnOnError = true;
                    CurrentMenu.Hide( );
                    Host.Commands.Buffer.Append(String.Format("connect \"{0}\"\n", _JoinName));
                    break;
                }
                break;

            case KeysDef.K_BACKSPACE:
                if (_Cursor == 0)
                {
                    if (!String.IsNullOrEmpty(_PortName))
                    {
                        _PortName = _PortName.Substring(0, _PortName.Length - 1);
                    }
                }

                if (_Cursor == 2)
                {
                    if (!String.IsNullOrEmpty(_JoinName))
                    {
                        _JoinName = _JoinName.Substring(0, _JoinName.Length - 1);
                    }
                }
                break;

            default:
                if (key < 32 || key > 127)
                {
                    break;
                }

                if (_Cursor == 2)
                {
                    if (_JoinName.Length < 21)
                    {
                        _JoinName += ( Char )key;
                    }
                }

                if (key < '0' || key > '9')
                {
                    break;
                }

                if (_Cursor == 0)
                {
                    if (_PortName.Length < 5)
                    {
                        _PortName += ( Char )key;
                    }
                }
                break;
            }

            if (StartingGame && _Cursor == 2)
            {
                if (key == KeysDef.K_UPARROW)
                {
                    _Cursor = 1;
                }
                else
                {
                    _Cursor = 0;
                }
            }

            var k = MathLib.atoi(_PortName);

            if (k > 65535)
            {
                k = _Port;
            }
            else
            {
                _Port = k;
            }
            _PortName = _Port.ToString( );
        }