public override bool HandlesKeyDown(Key key)
        {
            if (key == Key.Escape)
            {
                game.SetNewScreen(null);
            }
            else if (curWidget != null)
            {
                int        index   = Array.IndexOf <ButtonWidget>(buttons, curWidget);
                KeyBinding mapping = (KeyBinding)(index + (int)originKey);
                KeyMap     map     = game.InputHandler.Keys;
                Key        oldKey  = map[mapping];
                string     reason;

                if (!map.IsKeyOkay(oldKey, key, out reason))
                {
                    const string format = "&eFailed to change mapping \"{0}\". &c({1})";
                    statusWidget.SetText(String.Format(format, descriptions[index], reason));
                }
                else
                {
                    const string format = "&eChanged mapping \"{0}\" from &7{1} &eto &7{2}&e.";
                    statusWidget.SetText(String.Format(format, descriptions[index], oldKey, key));
                    string text = descriptions[index] + " : " + keyNames[(int)key];

                    curWidget.SetText(text);
                    map[mapping] = key;
                }
                curWidget = null;
            }
            return(key < Key.F1 || key > Key.F35);
        }
Esempio n. 2
0
 public InputHandler( Game game )
 {
     this.game = game;
     RegisterInputHandlers();
     LoadMouseToKeyMappings();
     Keys = new KeyMap();
 }
Esempio n. 3
0
 public InputHandler(Game game)
 {
     this.game = game;
     RegisterInputHandlers();
     Keys    = new KeyMap();
     picking = new PickingHandler(game, this);
     HotkeyList.LoadSavedHotkeys();
 }
Esempio n. 4
0
 public InputHandler(Game game)
 {
     this.game = game;
     RegisterInputHandlers();
     Keys    = new KeyMap();
     Hotkeys = new HotkeyList();
     Hotkeys.LoadSavedHotkeys();
 }
Esempio n. 5
0
 public InputHandler( Game game )
 {
     this.game = game;
     RegisterInputHandlers();
     LoadMouseToKeyMappings();
     Keys = new KeyMap();
     Hotkeys = new HotkeyList();
     Hotkeys.LoadSavedHotkeys();
 }
 public InputHandler( Game game )
 {
     this.game = game;
     RegisterInputHandlers();
     Keys = new KeyMap();
     Hotkeys = new HotkeyList();
     Hotkeys.LoadSavedHotkeys();
     picking = new PickingHandler( game, this );
 }
Esempio n. 7
0
        public InputHandler(Game game)
        {
            this.game = game;
            RegisterInputHandlers();
            Keys    = new KeyMap();
            picking = new PickingHandler(game, this);

                        #if !ANDROID
            Hotkeys = new HotkeyList();
            Hotkeys.LoadSavedHotkeys();
                        #endif
        }
Esempio n. 8
0
        internal bool HandleKeyDown(Key key)
        {
            KeyMap keys = game.InputHandler.Keys;

            if (key == keys[KeyBinding.Respawn] && CanRespawn && HacksEnabled)
            {
                Vector3I p = Vector3I.Floor(SpawnPoint);
                if (game.Map.IsValidPos(p))
                {
                    // Spawn player at highest valid position.
                    for (int y = p.Y; y <= game.Map.Height; y++)
                    {
                        byte block1 = GetPhysicsBlockId(p.X, y, p.Z);
                        byte block2 = GetPhysicsBlockId(p.X, y + 1, p.Z);
                        if (info.CollideType[block1] != BlockCollideType.Solid &&
                            info.CollideType[block2] != BlockCollideType.Solid)
                        {
                            p.Y = y;
                            break;
                        }
                    }
                }
                Vector3        spawn  = (Vector3)p + new Vector3(0.5f, 0.01f, 0.5f);
                LocationUpdate update = LocationUpdate.MakePos(spawn, false);
                SetLocation(update, false);
            }
            else if (key == keys[KeyBinding.SetSpawn] && CanRespawn && HacksEnabled)
            {
                SpawnPoint = Position;
            }
            else if (key == keys[KeyBinding.Fly] && CanFly && HacksEnabled)
            {
                flying = !flying;
            }
            else if (key == keys[KeyBinding.NoClip] && CanNoclip && HacksEnabled)
            {
                noClip = !noClip;
            }
            else
            {
                return(false);
            }
            return(true);
        }
Esempio n. 9
0
        protected override void OnLoad( EventArgs e )
        {
            #if !USE_DX
            Graphics = new OpenGLApi();
            #else
            Graphics = new Direct3D9Api( this );
            #endif
            try {
                Options.Load();
            } catch( IOException ) {
                Utils.LogWarning( "Unable to load options.txt" );
            }
            ViewDistance = Options.GetInt( "viewdist", 16, 8192, 512 );
            Keys = new KeyMap();
            InputHandler = new InputHandler( this );
            Chat = new ChatLog( this );
            Drawer2D = new GdiPlusDrawer2D( Graphics );
            defaultIb = Graphics.MakeDefaultIb();

            ModelCache = new ModelCache( this );
            ModelCache.InitCache();
            AsyncDownloader = new AsyncDownloader( skinServer );
            Graphics.PrintGraphicsInfo();
            TerrainAtlas1D = new TerrainAtlas1D( Graphics );
            TerrainAtlas = new TerrainAtlas2D( Graphics, Drawer2D );
            Animations = new Animations( this );
            TexturePackExtractor extractor = new TexturePackExtractor();
            extractor.Extract( defaultTexPack, this );
            Inventory = new Inventory( this );

            BlockInfo = new BlockInfo();
            BlockInfo.Init();
            BlockInfo.SetDefaultBlockPermissions( Inventory.CanPlace, Inventory.CanDelete );
            Map = new Map( this );
            LocalPlayer = new LocalPlayer( this );
            Players[255] = LocalPlayer;
            width = Width;
            height = Height;
            MapRenderer = new MapRenderer( this );
            MapEnvRenderer = new MapEnvRenderer( this );
            EnvRenderer = new StandardEnvRenderer( this );
            if( IPAddress == null ) {
                Network = new Singleplayer.SinglePlayerServer( this );
            } else {
                Network = new NetworkProcessor( this );
            }
            Graphics.LostContextFunction = Network.Tick;

            firstPersonCam = new FirstPersonCamera( this );
            thirdPersonCam = new ThirdPersonCamera( this );
            Camera = firstPersonCam;
            CommandManager = new CommandManager();
            CommandManager.Init( this );
            SelectionManager = new SelectionManager( this );
            ParticleManager = new ParticleManager( this );
            WeatherRenderer = new WeatherRenderer( this );
            WeatherRenderer.Init();

            Graphics.SetVSync( this, true );
            Graphics.DepthTest = true;
            Graphics.DepthTestFunc( CompareFunc.LessEqual );
            //Graphics.DepthWrite = true;
            Graphics.AlphaBlendFunc( BlendFunc.SourceAlpha, BlendFunc.InvSourceAlpha );
            Graphics.AlphaTestFunc( CompareFunc.Greater, 0.5f );
            Title = Utils.AppName;
            fpsScreen = new FpsScreen( this );
            fpsScreen.Init();
            Culling = new FrustumCulling();
            EnvRenderer.Init();
            MapEnvRenderer.Init();
            Picking = new PickingRenderer( this );

            string connectString = "Connecting to " + IPAddress + ":" + Port +  "..";
            SetNewScreen( new LoadingMapScreen( this, connectString, "Reticulating splines" ) );
            Network.Connect( IPAddress, Port );
        }
Esempio n. 10
0
        internal bool HandleKeyDown(Key key)
        {
            KeyMap keys = game.InputHandler.Keys;

            if (key == keys[KeyBinding.Respawn] && Hacks.CanRespawn)
            {
                Vector3I p = Vector3I.Floor(SpawnPoint);
                if (game.Map.IsValidPos(p))
                {
                    // Spawn player at highest valid position.
                    for (int y = p.Y; y <= game.Map.Height; y++)
                    {
                        byte block1 = physics.GetPhysicsBlockId(p.X, y, p.Z);
                        byte block2 = physics.GetPhysicsBlockId(p.X, y + 1, p.Z);
                        if (info.CollideType[block1] != BlockCollideType.Solid &&
                            info.CollideType[block2] != BlockCollideType.Solid)
                        {
                            p.Y = y;
                            break;
                        }
                    }
                }
                Vector3        spawn  = (Vector3)p + new Vector3(0.5f, 0.01f, 0.5f);
                LocationUpdate update = LocationUpdate.MakePosAndOri(spawn, SpawnYaw, SpawnPitch, false);
                SetLocation(update, false);
            }
            else if (key == keys[KeyBinding.SetSpawn] && Hacks.CanRespawn)
            {
                SpawnPoint = Position;
                SpawnYaw   = HeadYawDegrees;
                SpawnPitch = PitchDegrees;
            }
            else if (key == keys[KeyBinding.Fly] && Hacks.CanFly && Hacks.Enabled)
            {
                flying = !flying;
            }
            else if (key == keys[KeyBinding.NoClip] && Hacks.CanNoclip && Hacks.Enabled)
            {
                if (noClip)
                {
                    Velocity.Y = 0;
                }
                noClip = !noClip;
            }
            else if (key == keys[KeyBinding.Jump] && !onGround && !(flying || noClip))
            {
                if (!firstJump && Hacks.CanDoubleJump && Hacks.DoubleJump)
                {
                    DoNormalJump();
                    firstJump = true;
                }
                else if (!secondJump && Hacks.CanDoubleJump && Hacks.DoubleJump)
                {
                    DoNormalJump();
                    secondJump = true;
                }
            }
            else
            {
                return(false);
            }
            return(true);
        }