/// <summary>
        /// Initializes a new instance of the <see cref="InputImp"/> class.
        /// </summary>
        /// <param name="renderCanvas">The render canvas.</param>
        /// <exception cref="System.ArgumentNullException">renderCanvas</exception>
        /// <exception cref="System.ArgumentException">renderCanvas must be of type RenderCanvasImp;renderCanvas</exception>
        public InputImp(IRenderCanvasImp renderCanvas)
        {
            if (renderCanvas == null)
                throw new ArgumentNullException("renderCanvas");

            if (!(renderCanvas is RenderCanvasImp))
                throw new ArgumentException("renderCanvas must be of type RenderCanvasImp", "renderCanvas");

            _gameWindow = ((RenderCanvasImp) renderCanvas)._gameWindow;
            if (_gameWindow != null)
            {
                _gameWindow.Keyboard.KeyDown += OnGameWinKeyDown;
                _gameWindow.Keyboard.KeyUp += OnGameWinKeyUp;
                _gameWindow.Mouse.ButtonDown += OnGameWinMouseDown;
                _gameWindow.Mouse.ButtonUp += OnGameWinMouseUp;
                _gameWindow.Mouse.Move += OnGameWinMouseMove;
            }
            else
            {
                // Todo

            }

            KeyMapper = new Keymapper();
        }
    /// <summary>
    /// Initialize Player Controller
    /// </summary>
    void Init()
    {
        Keymapper.Configure(
            new Keymapper.Key("left", KeyCode.LeftArrow),
            new Keymapper.Key("right", KeyCode.RightArrow),
            new Keymapper.Key("up", KeyCode.UpArrow),
            new Keymapper.Key("down", KeyCode.DownArrow),
            new Keymapper.Key("boost", KeyCode.Space));

        //Start getting input from player
        StartCoroutine(InputCycle());
    }
Пример #3
0
        private void MetroWindow_Closed(object sender, EventArgs e)
        {
            Keymapper.Stop();
            ProcessWatcher.Stop();
            HapticManager.Stop();

            var aC = ControllerManager.GetActiveController();

            aC?.SetLightbar(0, 0, 0);
            aC?.Stop();
            ControllerManager.Stop();

            _notifyIcon.Visible = false;
            _notifyIcon.Dispose();
            WindowClosing?.Invoke();
        }
Пример #4
0
        public MainWindow()
        {
            InitializeComponent();

            var currentVersion = Assembly.GetExecutingAssembly().GetName().Version;

            Logger.Write("------------------------------------------");
            Logger.Write("WoWmapper {0} initializing...", currentVersion);
            Logger.Write("Operating System: Windows {0}, {1}", Environment.OSVersion, Environment.Is64BitOperatingSystem ? "x64" : "x86");
            Logger.Write("Application Path: {0}", System.AppDomain.CurrentDomain.BaseDirectory);

            var dxKey     = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\DirectX");
            var dxVersion = new Version();

            var dxVersionString = (string)dxKey?.GetValue("Version");

            if (dxVersionString != null)
            {
                dxVersion = new Version(dxVersionString);
            }

            if (dxVersion < new Version("4.09.00.0904"))
            {
                var downloadDXnow = System.Windows.MessageBox.Show(
                    "DirectX 9.0c is required for Xbox controller support. Would you like to download it now?",
                    "DirectX not found", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                if (downloadDXnow == MessageBoxResult.Yes)
                {
                    Process.Start("https://www.microsoft.com/en-us/download/confirmation.aspx?id=8109");
                }
                Settings.Default.EnableXbox = false;
                Settings.Default.Save();
            }


            if (new Version(Settings.Default.LastRunVersion) < currentVersion)
            {
                Logger.Write("Upgrading application settings");
                Settings.Default.Upgrade();
            }

            Settings.Default.LastRunVersion = currentVersion.ToString();
            Settings.Default.Save();

            AppDataDir = Path.Combine(Environment.GetEnvironmentVariable("LocalAppData"), "WoWmapper");
            if (!Directory.Exists(AppDataDir))
            {
                Logger.Write("App data dir not found\nCreating{0}", AppDataDir);
                Directory.CreateDirectory(AppDataDir);
            }

            // Add notification menu items
            ((MenuItem)_notifyMenu.Items[0]).Click += NotifyMenu_Open_WoWmapper;
            ((MenuItem)_notifyMenu.Items[2]).Click += NotifyMenu_Controllers;
            ((MenuItem)_notifyMenu.Items[3]).Click += NotifyMenu_Keybinds;
            ((MenuItem)_notifyMenu.Items[5]).Click += NotifyMenu_Exit;
            _notifyIcon              = new NotifyIcon();
            _notifyIcon.Click       += NotifyIcon_Click;
            _notifyIcon.DoubleClick += NotifyIcon_DoubleClick;
            _notifyIcon.Visible      = true;
            _notifyIcon.Icon         = Properties.Resources.WoWmapper_Icon;


            // Add custom accents
            ThemeManager.AddAccent("DeathKnight", new Uri("pack://application:,,,/Resources/Accents/DeathKnight.xaml"));
            ThemeManager.AddAccent("Druid", new Uri("pack://application:,,,/Resources/Accents/Druid.xaml"));
            ThemeManager.AddAccent("Hunter", new Uri("pack://application:,,,/Resources/Accents/Hunter.xaml"));
            ThemeManager.AddAccent("Mage", new Uri("pack://application:,,,/Resources/Accents/Mage.xaml"));
            ThemeManager.AddAccent("Monk", new Uri("pack://application:,,,/Resources/Accents/Monk.xaml"));
            ThemeManager.AddAccent("Paladin", new Uri("pack://application:,,,/Resources/Accents/Paladin.xaml"));
            ThemeManager.AddAccent("Priest", new Uri("pack://application:,,,/Resources/Accents/Priest.xaml"));
            ThemeManager.AddAccent("Rogue", new Uri("pack://application:,,,/Resources/Accents/Rogue.xaml"));
            ThemeManager.AddAccent("Shaman", new Uri("pack://application:,,,/Resources/Accents/Shaman.xaml"));
            ThemeManager.AddAccent("Warlock", new Uri("pack://application:,,,/Resources/Accents/Warlock.xaml"));
            ThemeManager.AddAccent("Warrior", new Uri("pack://application:,,,/Resources/Accents/Warrior.xaml"));

            // Load saved theme and accent
            var appTheme  = ThemeManager.AppThemes.FirstOrDefault(theme => theme.Name == Settings.Default.AppTheme);
            var appAccent = ThemeManager.Accents.FirstOrDefault(accent => accent.Name == Settings.Default.AppAccent);

            // Load defaults if invalid
            if (appTheme == null)
            {
                appTheme = ThemeManager.GetAppTheme("BaseLight");
                Settings.Default.AppTheme = "BaseLight";
                Settings.Default.Save();
            }
            if (appAccent == null)
            {
                appAccent = ThemeManager.GetAccent("Blue");
                Settings.Default.AppAccent = "Blue";
                Settings.Default.Save();
            }

            // Set drop shadow
            if (Settings.Default.AppDropShadow)
            {
                BorderThickness = new Thickness(0);
                GlowBrush       = Brushes.Black;
            }

            // Apply theme
            ThemeManager.ChangeAppStyle(Application.Current, appAccent, appTheme);

            // Hook events
            AdvancedSettings.ShowFeedbackWarning += AdvancedSettings_ShowFeedbackWarning;
            AdvancedSettings.DoResetAll          += AdvancedSettings_DoResetAll;
            ShowMessage            += MainWindow_ShowMessage;
            ShowKeybindDialogEvent += OnShowKeybindDialog;

            // Initialize UI timer
            _timerUpdateUi.Elapsed += Timer_UpdateUI;
            _timerUpdateUi.Interval = 100;
            _timerUpdateUi.Start();

            // Initialize controllers
            BindingManager.LoadKeybinds();

            // Initialize process watcher
            ProcessWatcher.Start();
            ControllerManager.Start();
            HapticManager.Start();
            Keymapper.Start();
        }