Esempio n. 1
0
 protected void AddDefaultInputBinding(string childName, string interfaceTriggerName, string deviceActionName)
 {
     DefaultInputBindings.Add(new DefaultInputBinding(
                                  childName: childName,
                                  interfaceTriggerName: interfaceTriggerName,
                                  deviceActionName: deviceActionName
                                  ));
 }
Esempio n. 2
0
        /// <summary>
        /// A-10C UHF Radio Load Button.
        /// This includes binding the hidden action to the switch positions of the cover which sits beneath the button to make them reversed visually.
        /// This is also the first use case of DefaultInputBinding's deviceTriggerName & deviceTriggerBindingValue in composite visual
        /// </summary>
        /// <param name="name">name of element</param>
        /// <param name="x">Horizontal coordinate of the button</param>
        /// <param name="y">Vertical coordinate of the button</param>
        /// <param name="size">Size of the button</param>
        /// <param name="interfaceElementName">Name of the corresponding trigger</param>
        private void AddLoadButton(string name, double x, double y, Size size, string interfaceElementName)
        {
            string     componentName = _interfaceDeviceName + "_" + name;
            PushButton newButton     = new PushButton
            {
                Top         = y,
                Left        = x,
                Width       = size.Width,
                Height      = size.Height,
                Image       = _imageLocation + "A-10C_UHF_Radio_Red_Button_Unpressed.png",
                PushedImage = _imageLocation + "A-10C_UHF_Radio_Red_Button_Pressed.png",
                Text        = "",
                Name        = componentName,
                IsHidden    = true
            };

            Children.Add(newButton);

            AddTrigger(newButton.Triggers["pushed"], componentName);
            AddTrigger(newButton.Triggers["released"], componentName);
            AddAction(newButton.Actions["set.hidden"], componentName);
            AddAction(newButton.Actions["set.physical state"], componentName);

            AddDefaultOutputBinding(
                childName: componentName,
                deviceTriggerName: "position.changed",
                interfaceActionName: _interfaceDeviceName + ".set." + interfaceElementName
                );

            AddDefaultInputBinding(
                childName: componentName,
                interfaceTriggerName: _interfaceDeviceName + "." + interfaceElementName + ".changed",
                deviceActionName: "set.physical state");

            DefaultInputBindings.Add(new DefaultInputBinding(
                                         childName: componentName,
                                         interfaceTriggerName: "",
                                         deviceTriggerName: "UHF Radio_Cover.position two.entered",
                                         deviceActionName: "set.hidden",
                                         deviceTriggerBindingValue: new BindingValue(false)));

            DefaultInputBindings.Add(new DefaultInputBinding(
                                         childName: componentName,
                                         interfaceTriggerName: "",
                                         deviceTriggerName: "UHF Radio_Cover.position one.entered",
                                         deviceActionName: "set.hidden",
                                         deviceTriggerBindingValue: new BindingValue(true)));
        }
Esempio n. 3
0
        private void ConfigureKeyBinds()
        {
            Engine.InputBinder.ResetBinds();

            DefaultInputBindings.Populate(Engine.InputBinder);

            var keybindsFile     = Lookup.GetFilePath("keybinds.cfg");
            var keybindsFileInfo = new FileInfo(keybindsFile);

            if (keybindsFileInfo.Exists)
            {
                if (!Engine.InputBinder.LoadBindings(
                        new FileStream(keybindsFile, FileMode.Open, FileAccess.Read)))
                {
                    Logger.Write("Unable to load keybindings - removing and re-creating");
                }
            }

            Engine.InputBinder.SaveBindings(
                new FileStream(keybindsFile, FileMode.OpenOrCreate, FileAccess.Write));

            Engine.InputBinder
            .Register(InputActions.MoveUp.ToString(), @event => MoveChange(Direction.North, @event))
            .Register(InputActions.MoveDown.ToString(), @event => MoveChange(Direction.South, @event))
            .Register(InputActions.MoveLeft.ToString(), @event => MoveChange(Direction.West, @event))
            .Register(InputActions.MoveRight.ToString(), @event => MoveChange(Direction.East, @event))
            .Register(InputActions.Reload.ToString(), Reload)
            .Register(InputActions.Walk.ToString(), AlterMovementSpeed)
            .Register(InputActions.ZoomIn.ToString(), ZoomIn)
            .Register(InputActions.Zoomout.ToString(), ZoomOut)
            .Register(InputActions.LevelDown.ToString(), LevelDown)
            .Register(InputActions.LevelUp.ToString(), LevelUp)
            .Register(InputActions.Fire.ToString(), Fire)
            .Register(InputActions.Interact.ToString(), Interact)
            .Register(InputActions.Inventory.ToString(), ToggleInventory)
            .Register(InputActions.Chat.ToString(), ShowChatWindow)
            .Register(InputActions.DebugView.ToString(), ToggleDebugView)
            .Register(InputActions.HotAction1.ToString(), @event => PerformHotAction(1, @event))
            .Register(InputActions.HotAction2.ToString(), @event => PerformHotAction(2, @event))
            .Register(InputActions.HotAction3.ToString(), @event => PerformHotAction(3, @event))
            .Register(InputActions.HotAction4.ToString(), @event => PerformHotAction(4, @event))
            .Register(InputActions.HotAction5.ToString(), @event => PerformHotAction(5, @event))
            .Register(InputActions.HotAction6.ToString(), @event => PerformHotAction(6, @event))
            .Register(InputActions.HotAction7.ToString(), @event => PerformHotAction(7, @event))
            .Register(InputActions.HotAction8.ToString(), @event => PerformHotAction(8, @event))
            .Register(InputActions.HotAction9.ToString(), @event => PerformHotAction(9, @event));
        }