Example #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            MainWindow = Shell.Instance;
            MainWindow.Show();
            ShutdownMode = ShutdownMode.OnMainWindowClose;

            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    using (var engine = CreateEngine())
                        using (var watcher = new WatcherThread(engine))
                        {
                            Shell.Instance.IsAttached = true;
                            Minimap minimap           = null;
                            OverlayWindow overlay     = null;
                            Execute.OnUIThread(() =>
                            {
                                Canvas canvas = new Canvas();
                                overlay       = OverlayWindow.Create(engine.Process, canvas);
                                overlay.Show();
                                minimap = new Minimap(canvas);
                            });
                            watcher.AddTask(minimap.Update);
                            watcher.Start();
                            engine.Process.WaitForExit();
                            Execute.OnUIThread(() => overlay.Close());
                        }
                    Shell.Instance.IsAttached = false;
                    //Execute.OnUIThread(() => MainWindow.Close());
                }
            }, TaskCreationOptions.LongRunning);
        }
        private bool CreateOverlay()
        {
            if (_isOverlayInitialized && !_isOverlayReady && _gameMemory.Process.WindowHandle != IntPtr.Zero)
            {
                _window.Create();

                _graphics.Width        = _window.Width;
                _graphics.Height       = _window.Height;
                _graphics.WindowHandle = _window.Handle;
                _graphics.Setup();

                _window.SizeChanged += (object sender, OverlaySizeEventArgs e) =>
                                       _graphics.Resize(_window.Width, _window.Height);

                _window.FitTo(_gameMemory.Process.WindowHandle, true);

                if (_windowEventDispatcher != null)
                {
                    _windowEventDispatcher.Invoke(delegate
                    {
                        WinEventHook.WinEventDelegate windowEventDelegate = new WinEventHook.WinEventDelegate(MoveGameWindowEventCallback);
                        _windowEventGCHandle = GCHandle.Alloc(windowEventDelegate);
                        _windowEventHook     = WinEventHook.WinEventHookOne(WinEventHook.SWEH_Events.EVENT_OBJECT_LOCATIONCHANGE,
                                                                            windowEventDelegate,
                                                                            (uint)_gameMemory.Process.Id,
                                                                            WinEventHook.GetWindowThread(_gameMemory.Process.WindowHandle));
                    });
                }

                //Get a refernence to the underlying RenderTarget from SharpDX. This'll be used to draw portions of images.
                _device = (SharpDX.Direct2D1.WindowRenderTarget) typeof(Graphics)
                          .GetField("_device", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)
                          .GetValue(_graphics);

                _consolas14Bold = _graphics.CreateFont("Consolas", 14, true);
                _consolas16Bold = _graphics.CreateFont("Consolas", 16, true);
                _consolas32Bold = _graphics.CreateFont("Consolas", 32, true);

                _black      = _graphics.CreateSolidBrush(0, 0, 0, Config.Opacity);
                _white      = _graphics.CreateSolidBrush(255, 255, 255, Config.Opacity);
                _green      = _graphics.CreateSolidBrush(0, 128, 0, Config.Opacity);
                _lawngreen  = _graphics.CreateSolidBrush(124, 252, 0, Config.Opacity);
                _red        = _graphics.CreateSolidBrush(255, 0, 0, Config.Opacity);
                _darkred    = _graphics.CreateSolidBrush(139, 0, 0, Config.Opacity);
                _grey       = _graphics.CreateSolidBrush(128, 128, 128, Config.Opacity);
                _darkergrey = _graphics.CreateSolidBrush(60, 60, 60, Config.Opacity);
                _gold       = _graphics.CreateSolidBrush(255, 215, 0, Config.Opacity);
                _goldenrod  = _graphics.CreateSolidBrush(218, 165, 32, Config.Opacity);
                _violet     = _graphics.CreateSolidBrush(238, 130, 238, Config.Opacity);

                _characterSheet = ImageLoader.LoadBitmap(_device, Properties.Resources.portraits);
                _inventorySheet = ImageLoader.LoadBitmap(_device, Properties.Resources.objects);

                _isOverlayReady = true;
            }

            return(_isOverlayReady);
        }
Example #3
0
 public void Initialize()
 {
     _window.Create();
     _graphics.WindowHandle = _window.Handle;
     _graphics.Setup();
     _font  = _graphics.CreateFont("Arial", 16);
     _black = _graphics.CreateSolidBrush(0, 0, 0);
     _red   = _graphics.CreateSolidBrush(Color.Red);
 }
Example #4
0
        public AmeisenBotOverlay(IntPtr mainWindowHandle)
        {
            LinesToRender      = new();
            RectanglesToRender = new();

            OverlayWindow = new(mainWindowHandle)
            {
                IsTopmost = true,
                IsVisible = true,
                FPS       = 30
            };

            OverlayWindow.Create();

            Gfx = new(OverlayWindow.Handle, OverlayWindow.Width, OverlayWindow.Height);
            Gfx.Setup();
        }
Example #5
0
        public AmeisenBotOverlay(XMemory xMemory)
        {
            XMemory            = xMemory;
            LinesToRender      = new();
            RectanglesToRender = new();

            OverlayWindow = new(xMemory.Process.MainWindowHandle)
            {
                IsTopmost = true,
                IsVisible = true,
                FPS       = 30
            };

            OverlayWindow.Create();

            Gfx = new(OverlayWindow.Handle, OverlayWindow.Width, OverlayWindow.Height);
            Gfx.Setup();
        }