示例#1
0
        public static void SavePosition()
        {
            // Get the object for the local player controller.
            var controller = BLObject.GetPlayerController();
            // If we could not, stop and present an error.
            if (controller == null)
                goto Failed;

            // Get the object for the pawn from the player controller.
            var pawn = controller["Pawn"] as BLObject;
            // If we could not, stop and present an error.
            if (pawn == null || pawn.Class != "WillowPlayerPawn")
                goto Failed;

            pawn.UsePropertyMode = BLObject.PropertyMode.GetAll;

            // Save the rotation and location for our controller and pawn.
            SavedRotation = controller["Rotation"] as string;
            SavedLocation = pawn["Location"] as string;

            // Provide feedback to the player.
            if (ShowFeedback)
                BLIO.RunCommand("say Saved position");

            return;
            Failed:
            RunCommand("say Failed to save position");
        }
示例#2
0
        public static void SavePosition()
        {
            // Get the object for the local player controller.
            var controller = BLObject.GetPlayerController();

            // If we could not, stop and present an error.
            if (controller == null)
            {
                goto Failed;
            }

            // Get the object for the pawn from the player controller.
            var pawn = controller["Pawn"] as BLObject;

            // If we could not, stop and present an error.
            if (pawn == null || pawn.Class != "WillowPlayerPawn")
            {
                goto Failed;
            }

            pawn.UsePropertyMode = BLObject.PropertyMode.GetAll;


            // Save the rotation and location for our controller and pawn.
            SavedRotation = controller["Rotation"] as string;
            SavedLocation = pawn["Location"] as string;

            // Traverse object tree...
            var info = pawn["WorldInfo"] as BLObject;

            info.UsePropertyMode = BLObject.PropertyMode.GetAll;
            var mapLevel = info["CommittedPersistentLevel"] as BLObject;

            // ... until we can get the map name
            SavedPositionMap = mapLevel.Name;

            // Provide feedback to the player.
            if (ShowFeedback)
            {
                BLIO.RunCommand("say Saved position");
            }

            return;


Failed:
            RunCommand("say Failed to save position");
            SavedPositionMap = null;
        }
        // Perform our own initilization when the window initilizes.
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);

            F7Binding = new KeyBinding(Key.F7, ToggleHotkeys);

            var controlUpBinding    = new KeyBinding(Key.Up, Modifier.Control, () => App.MoveForwardBackward(500));
            var controlDownBinding  = new KeyBinding(Key.Down, Modifier.Control, () => App.MoveForwardBackward(-500));
            var controlLeftBinding  = new KeyBinding(Key.Left, Modifier.Control, () => App.MoveLeftRight(-500));
            var controlRightBinding = new KeyBinding(Key.Right, Modifier.Control, () => App.MoveLeftRight(500));

            var controlEndBinding = new KeyBinding(Key.End, Modifier.Control, () => BLIO.RunCommand("disconnect"));

            SymbolBindings = new KeyBinding[]
            {
                new KeyBinding(Key.Equals, App.ToggleThirdPerson),
                new KeyBinding(Key.LeftBracket, App.HalveSpeed),
                new KeyBinding(Key.RightBracket, App.DoubleSpeed),
                new KeyBinding(Key.Backslash, App.ResetSpeed),
                new KeyBinding(Key.Comma, App.RestorePosition),
                new KeyBinding(Key.Period, App.SavePosition),
                new KeyBinding(Key.Semicolon, () => BLIO.RunCommand("togglehud")),
                new KeyBinding(Key.Quote, App.ToggleDamageNumbers),
                new KeyBinding(Key.Slash, App.TogglePlayersOnly),
                controlUpBinding,
                controlDownBinding,
                controlLeftBinding,
                controlRightBinding,
                controlEndBinding,
            };

            NumpadBindings = new KeyBinding[]
            {
                new KeyBinding(Key.NumOne, App.HalveSpeed),
                new KeyBinding(Key.NumTwo, App.DoubleSpeed),
                new KeyBinding(Key.NumThree, App.ResetSpeed),
                new KeyBinding(Key.NumFour, App.RestorePosition),
                new KeyBinding(Key.NumFive, App.SavePosition),
                new KeyBinding(Key.NumSix, App.TogglePlayersOnly),
                new KeyBinding(Key.NumSeven, () => BLIO.RunCommand("togglehud")),
                new KeyBinding(Key.NumEight, App.ToggleDamageNumbers),
                new KeyBinding(Key.NumNine, App.ToggleThirdPerson),
                controlUpBinding,
                controlDownBinding,
                controlLeftBinding,
                controlRightBinding,
                controlEndBinding,
            };

            if (Properties.Settings.Default.NumpadBindings)
            {
                NumpadBindingsMenuItem.Checked = true;
                // Set up the dictionary entires for our keybindings and their callbacks.
                KeyBindings = NumpadBindings;
            }
            else
            {
                SymbolBindingsMenuItem.Checked = true;
                // Set up the dictionary entires for our keybindings and their callbacks.
                KeyBindings = SymbolBindings;
            }

            // Set up the handle variables for binding hotkeys, and set up our
            // callback method as the hook for receiving hotkey events.
            Handle = new WindowInteropHelper(this).Handle;
            source = HwndSource.FromHwnd(Handle);
            source.AddHook(OnHotkeyPressed);

            // Create the delegate to handle notifications of foreground window
            // changes, and register it with the system.
            ForegroundWindowDelegate = (_0, _1, windowHandle, _3, _4, _5, _6) => HandleForegroundWindow(windowHandle);
            SetWinEventHook(0x0003, 0x0003, IntPtr.Zero, ForegroundWindowDelegate, 0, 0, 0);

            // Set up bindings if the foreground window is already Borderlands.
            HandleForegroundWindow(GetForegroundWindow());
        }
        public static KeyBinding[] ToKeyBindings(this List <KeybindInfo> kbis)
        {
            var bindingList = new List <KeyBinding>();

            foreach (var kbi in kbis)
            {
                try
                {
                    uint modifier = 0;
                    if (kbi.bUseCTRLModifier)
                    {
                        modifier |= 2;
                    }
                    if (kbi.bUseALTModifier)
                    {
                        modifier |= 1;
                    }
                    if (kbi.bUseSHIFTModifier)
                    {
                        modifier |= 4;
                    }
                    if (kbi.OwnerName == "textBoxHalveSpeed")
                    {
                        bindingList.Add(new KeyBinding((Keys)Enum.Parse(typeof(Keys), kbi.Key), modifier, App.HalveSpeed));
                    }
                    if (kbi.OwnerName == "textBoxDoubleSpeed")
                    {
                        bindingList.Add(new KeyBinding((Keys)Enum.Parse(typeof(Keys), kbi.Key), modifier, App.DoubleSpeed));
                    }
                    if (kbi.OwnerName == "textBoxResetSpeed")
                    {
                        bindingList.Add(new KeyBinding((Keys)Enum.Parse(typeof(Keys), kbi.Key), modifier, App.ResetSpeed));
                    }
                    if (kbi.OwnerName == "textBoxRestorePosition")
                    {
                        bindingList.Add(new KeyBinding((Keys)Enum.Parse(typeof(Keys), kbi.Key), modifier, App.RestorePosition));
                    }
                    if (kbi.OwnerName == "textBoxSavePosition")
                    {
                        bindingList.Add(new KeyBinding((Keys)Enum.Parse(typeof(Keys), kbi.Key), modifier, App.SavePosition));
                    }
                    if (kbi.OwnerName == "textBoxTogglePlayersOnly")
                    {
                        bindingList.Add(new KeyBinding((Keys)Enum.Parse(typeof(Keys), kbi.Key), modifier, App.TogglePlayersOnly));
                    }
                    if (kbi.OwnerName == "textBoxToggleHUD")
                    {
                        bindingList.Add(new KeyBinding((Keys)Enum.Parse(typeof(Keys), kbi.Key), modifier, () => BLIO.RunCommand("togglehud")));
                    }
                    if (kbi.OwnerName == "textBoxToggleDamageNumbers")
                    {
                        bindingList.Add(new KeyBinding((Keys)Enum.Parse(typeof(Keys), kbi.Key), modifier, App.ToggleDamageNumbers));
                    }
                    if (kbi.OwnerName == "textBoxToggleThirdperson")
                    {
                        bindingList.Add(new KeyBinding((Keys)Enum.Parse(typeof(Keys), kbi.Key), modifier, App.ToggleThirdPerson));
                    }
                    if (kbi.OwnerName == "textBoxDisconnect")
                    {
                        bindingList.Add(new KeyBinding((Keys)Enum.Parse(typeof(Keys), kbi.Key), modifier, () => BLIO.RunCommand("disconnect")));
                    }
                    if (kbi.OwnerName == "textBoxToggleHotkeys")
                    {
                        bindingList.Add(new KeyBinding((Keys)Enum.Parse(typeof(Keys), kbi.Key), modifier, MainWindow.mainWindow.ToggleHotkeys));
                    }
                    if (kbi.OwnerName == "textBoxTeleportForward")
                    {
                        bindingList.Add(new KeyBinding((Keys)Enum.Parse(typeof(Keys), kbi.Key), modifier, () => App.MoveForwardBackward(500)));
                    }
                    if (kbi.OwnerName == "textBoxTeleportLeft")
                    {
                        bindingList.Add(new KeyBinding((Keys)Enum.Parse(typeof(Keys), kbi.Key), modifier, () => App.MoveLeftRight(-500)));
                    }
                    if (kbi.OwnerName == "textBoxTeleportRight")
                    {
                        bindingList.Add(new KeyBinding((Keys)Enum.Parse(typeof(Keys), kbi.Key), modifier, () => App.MoveLeftRight(500)));
                    }
                    if (kbi.OwnerName == "textBoxTeleportBackward")
                    {
                        bindingList.Add(new KeyBinding((Keys)Enum.Parse(typeof(Keys), kbi.Key), modifier, () => App.MoveForwardBackward(-500)));
                    }
                    if (kbi.OwnerName == null)
                    {
                        bindingList.Add(new KeyBinding((Keys)Enum.Parse(typeof(Keys), kbi.Key), modifier, () => BLIO.RunCommand(kbi.Command)));
                    }
                }
                catch (ArgumentException) { }
            }
            return(bindingList.ToArray());
        }