コード例 #1
0
        public void ResizeTiles(int tileWidth, int tileHeight)
        {
            var cols = TileConfiguration.MapWidth / TileConfiguration.TileWidth;
            var rows = TileConfiguration.MapHeight / TileConfiguration.TileHeight;

            TileConfiguration = new TileConfiguration(cols * tileWidth, rows * tileHeight, tileWidth, tileHeight);


            var newCollisionLayer = new TileLayer <CollisionTile>(0, TileConfiguration);

            foreach (var collisionTile in CollisionLayer)
            {
                var bounds = new RectangleF(
                    collisionTile.Column * TileConfiguration.TileWidth,
                    collisionTile.Row * TileConfiguration.TileHeight,
                    TileConfiguration.TileWidth,
                    TileConfiguration.TileHeight
                    );

                newCollisionLayer.Add(new CollisionTile(collisionTile.Row, collisionTile.Column, bounds));
            }

            CollisionLayer = newCollisionLayer;

            Resized?.Invoke();
        }
コード例 #2
0
        public void Run()
        {
            m_factory = new DisposeCollectorResourceFactory(m_gd.ResourceFactory);
            GraphicsDeviceCreated?.Invoke(m_gd, m_factory, m_gd.MainSwapchain);

            Stopwatch sw = Stopwatch.StartNew();
            double    previousElapsed = sw.Elapsed.TotalSeconds;

            while (m_window.Exists)
            {
                double newElapsed   = sw.Elapsed.TotalSeconds;
                float  deltaSeconds = (float)(newElapsed - previousElapsed);

                InputSnapshot inputSnapshot = m_window.PumpEvents();
                InputTracker.UpdateFrameInput(inputSnapshot);

                if (m_window.Exists)
                {
                    previousElapsed = newElapsed;
                    if (m_windowResized)
                    {
                        m_windowResized = false;
                        m_gd.ResizeMainWindow((uint)m_window.Width, (uint)m_window.Height);
                        Resized?.Invoke();
                    }

                    Rendering?.Invoke(deltaSeconds);
                }
            }

            m_gd.WaitForIdle();
            m_factory.DisposeCollector.DisposeAll();
            m_gd.Dispose();
            GraphicsDeviceDestroyed?.Invoke();
        }
コード例 #3
0
 /// <summary>
 /// Handler for the resized event.
 /// </summary>
 /// <param name="control">Event source.</param>
 protected virtual void OnResized(ControlBase control)
 {
     if (Resized != null)
     {
         Resized.Invoke(this);
     }
 }
コード例 #4
0
 private void HandleDisplayLinkOutputCallback()
 {
     try
     {
         if (_paused)
         {
             return;
         }
         if (GraphicsDevice != null)
         {
             if (_resized)
             {
                 _resized = false;
                 MainSwapchain.Resize(_width / 2, _height);
                 Resized?.Invoke();
             }
             Rendering?.Invoke();
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine("Encountered an error while rendering: " + e);
         throw;
     }
 }
コード例 #5
0
 private void OnPanelSizeChanged(object sender, SizeChangedEventArgs e)
 {
     if (_graphicsDevice != null)
     {
         Resized?.Invoke();
     }
 }
コード例 #6
0
 private void OnPanelScaleChanged(SwapChainPanel sender, object args)
 {
     if (_graphicsDevice != null)
     {
         Resized?.Invoke();
     }
 }
コード例 #7
0
 /// <summary>
 /// Handler for the resized event.
 /// </summary>
 /// <param name="control">Event source.</param>
 protected virtual void OnResized(ControlBase control, EventArgs args)
 {
     if (Resized != null)
     {
         Resized.Invoke(this, EventArgs.Empty);
     }
 }
コード例 #8
0
        public void OnConfigured()
        {
            int w, h;

            if (!OverrideRedirect)
            {
                Native.GtkWindowGetSize(GtkWidget, out w, out h);
                var size = ClientSize = new Size(w, h);
                if (_lastSize != size)
                {
                    Resized?.Invoke(size);
                    _lastSize = size;
                }
            }
            var pos = Position;

            if (_lastPosition != pos)
            {
                PositionChanged?.Invoke(pos);
                _lastPosition = pos;
            }
            var scaling = Scaling;

            if (_lastScaling != scaling)
            {
                ScalingChanged?.Invoke(scaling);
                _lastScaling = scaling;
            }
        }
コード例 #9
0
 private CVReturn HandleDisplayLinkOutputCallback(CVDisplayLink displayLink, ref CVTimeStamp inNow, ref CVTimeStamp inOutputTime, CVOptionFlags flagsIn, ref CVOptionFlags flagsOut)
 {
     try
     {
         if (_paused)
         {
             return(CVReturn.Success);
         }
         if (GraphicsDevice != null)
         {
             if (_resized)
             {
                 _resized = false;
                 MainSwapchain.Resize(_width, _height);
                 Resized?.Invoke();
             }
             Rendering?.Invoke();
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine("Encountered an error while rendering: " + e);
         throw;
     }
     return(CVReturn.Success);
 }
コード例 #10
0
 internal void _fireWindowResized()
 {
     if (Resized != null)
     {
         Resized.Invoke(this);
     }
 }
コード例 #11
0
ファイル: WindowBaseImpl.cs プロジェクト: isra60/Avalonia
        private bool OnConfigured(IntPtr gtkwidget, IntPtr ev, IntPtr userdata)
        {
            var size = ClientSize;

            if (_lastSize != size)
            {
                Resized?.Invoke(size);
                _lastSize = size;
            }
            var pos = Position;

            if (_lastPosition != pos)
            {
                PositionChanged?.Invoke(pos);
                _lastPosition = pos;
            }
            var scaling = Scaling;

            if (_lastScaling != scaling)
            {
                ScalingChanged?.Invoke(scaling);
                _lastScaling = scaling;
            }
            return(false);
        }
コード例 #12
0
        private bool OnConfigured(IntPtr gtkwidget, IntPtr ev, IntPtr userdata)
        {
            int w, h;

            Native.GtkWindowGetSize(GtkWidget, out w, out h);
            var size = ClientSize = new Size(w, h);

            if (_lastSize != size)
            {
                Resized?.Invoke(size);
                _lastSize = size;
            }
            var pos = Position;

            if (_lastPosition != pos)
            {
                PositionChanged?.Invoke(pos);
                _lastPosition = pos;
            }
            var scaling = Scaling;

            if (_lastScaling != scaling)
            {
                ScalingChanged?.Invoke(scaling);
                _lastScaling = scaling;
            }
            return(false);
        }
コード例 #13
0
        public override void OnMouseButton(MouseButton button, Vector2 currentPosition, ButtonState state)
        {
            if (state == ButtonState.Pressed)
            {
                this.isDraggingSomething = true;
            }
            else
            {
                this.isDraggingSomething = false;
            }

            if (button == MouseButton.Left)
            {
                if (state == ButtonState.Pressed)
                {
                    this.grabState = new GrabState(GetEdgeAtPoint(currentPosition), currentPosition,
                                                   this.boundingRect.Rect, this.minSize, this.maxSize);
                }
                else
                {
                    if (this.grabState.edge != RectEdge.None)
                    {
                        Resized?.Invoke(this, new ResizeEventArgs
                        {
                            PositionOffset = this.grabState.GetPositionDelta(this.currentMousePosition),
                            NewSize        = this.boundingRect.Size.ToVector2() +
                                             this.grabState.GetSizeDelta(this.currentMousePosition)
                        });
                    }

                    this.grabState = new GrabState(RectEdge.None, Vector2.Zero, Rectangle.Empty, Point.Zero, null);
                }
            }
        }
コード例 #14
0
 private void resize()
 {
     if (Resized != null)
     {
         Resized.Invoke(this);
     }
 }
コード例 #15
0
    /// <summary>
    /// Called when the container was resized.
    /// </summary>
    /// <param name="newSize"></param>
    protected virtual void OnContainerResized(DOMRect newSize)
    {
        Width  = newSize.Width;
        Height = newSize.Height;

        Resized?.Invoke(this);
    }
コード例 #16
0
        public void Run()
        {
            GraphicsDeviceOptions options = new GraphicsDeviceOptions(
                debug: false,
                swapchainDepthFormat: PixelFormat.R16_UNorm,
                syncToVerticalBlank: true,
                resourceBindingModel: ResourceBindingModel.Improved,
                preferDepthRangeZeroToOne: true,
                preferStandardClipSpaceYDirection: true);

#if DEBUG
            options.Debug = true;
#endif

            // construct a graphics device using the default backend.
            _gd = VeldridStartup.CreateGraphicsDevice(_window, options);

            // to determine what the default backend is you can run:
            //VeldridStartup.GetPlatformDefaultBackend()

            // to specify a specific backend use:
            //_gd = VeldridStartup.CreateGraphicsDevice(_window, options, GraphicsBackend.Metal);



            _factory = new DisposeCollectorResourceFactory(_gd.ResourceFactory);
            GraphicsDeviceCreated?.Invoke(_gd, _factory, _gd.MainSwapchain);

            Stopwatch sw = Stopwatch.StartNew();
            double    previousElapsed = sw.Elapsed.TotalSeconds;
            while (IsWindowOpen())
            {
                double newElapsed   = sw.Elapsed.TotalSeconds;
                float  deltaSeconds = (float)(newElapsed - previousElapsed);

                InputSnapshot inputSnapshot = _window.PumpEvents();
                InputTracker.UpdateFrameInput(inputSnapshot);

                if (_window.Exists)
                {
                    previousElapsed = newElapsed;
                    if (_windowResized)
                    {
                        _windowResized = false;
                        _gd.ResizeMainWindow((uint)_window.Width, (uint)_window.Height);
                        Resized?.Invoke();
                    }

                    Rendering?.Invoke(deltaSeconds);
                }
            }

            Shutdown?.Invoke();

            _gd.WaitForIdle();
            _factory.DisposeCollector.DisposeAll();
            _gd.Dispose();
            GraphicsDeviceDestroyed?.Invoke();
        }
コード例 #17
0
 private static void Window_Resize(object sender, EventArgs e)
 {
     GL.ViewportIndexed(0, 0, 0, Window.ClientSize.Width, Window.ClientSize.Height);
     GL.ClipControl(ClipOrigin.LowerLeft, ClipDepthMode.ZeroToOne);
     //Input.LowLevel.InputLL.SetWinXY(game.Location.X, game.Location.Y, game.ClientSize.Width, game.ClientSize.Height);
     Framebuffer.RecreateDefaultFramebuffer();
     Resized?.Invoke(Window.ClientSize.Width, Window.ClientSize.Height);
 }
コード例 #18
0
 public void OnWindowResized()
 {
     if (DebugStartUp)
     {
         Debug.WriteLine(Name + " resized");
     }
     UpdateConfig();
     Resized?.Invoke(this);
 }
コード例 #19
0
        protected virtual void OnSize(int width, int height)
        {
            var rect = new Rectangle(0, 0, width, height);

            PerformanceProfiler.Instance.ComputeContentRect(ref rect);

            MainView.Bounds = rect;
            Resized?.Invoke(rect.Width, rect.Height);
        }
コード例 #20
0
 void DoResize(Size clientSize)
 {
     // Uncomment this check and experience a weird bug in layout engine
     if (ClientSize != clientSize)
     {
         ClientSize = clientSize;
         Resized?.Invoke(clientSize);
     }
 }
コード例 #21
0
 void DoResize(Size clientSize)
 {
     // Uncomment this check and experience a weird bug in layout engine
     if (ClientSize != clientSize)
     {
         ClientSize = clientSize;
         Resized?.Invoke(clientSize, PlatformResizeReason.Unspecified);
     }
 }
コード例 #22
0
        public void Run()
        {
            var options = new GraphicsDeviceOptions(
                false,
                PixelFormat.R16_UNorm,
                true,
                ResourceBindingModel.Improved,
                true,
                true);

#if DEBUG
            options.Debug = true;
#endif
            GraphicsDevice gd;
            if (_options.GraphicsBackend.HasValue)
            {
                gd = VeldridStartup.CreateGraphicsDevice(_window, options, _options.GraphicsBackend.Value);
            }
            else
            {
                gd = VeldridStartup.CreateGraphicsDevice(_window, options);
            }
            var factory = new DisposeCollectorResourceFactory(gd.ResourceFactory);

            _veldrid = new VeldridContext(gd, factory, gd.MainSwapchain);
            GraphicsDeviceCreated?.Invoke(_veldrid);

            var sw = Stopwatch.StartNew();
            var previousElapsed = sw.Elapsed.TotalSeconds;

            while (_window.Exists)
            {
                var newElapsed   = sw.Elapsed.TotalSeconds;
                var deltaSeconds = (float)(newElapsed - previousElapsed);

                var inputSnapshot = _window.PumpEvents();

                if (_window.Exists)
                {
                    previousElapsed = newElapsed;
                    if (_windowResized)
                    {
                        _windowResized = false;
                        gd.ResizeMainWindow((uint)_window.Width, (uint)_window.Height);
                        Resized?.Invoke();
                    }

                    Rendering?.Invoke(deltaSeconds);
                }
            }

            gd.WaitForIdle();
            factory.DisposeCollector.DisposeAll();
            gd.Dispose();
            GraphicsDeviceDestroyed?.Invoke();
        }
コード例 #23
0
ファイル: SdlWindow.cs プロジェクト: limocute/yak2d
        public SdlWindow(Sdl2Window window)
        {
            RawWindow = window;

            RawWindow.Closed      += () => { Closed?.Invoke(); };
            RawWindow.Resized     += () => { Resized?.Invoke(); };
            RawWindow.FocusLost   += () => { FocusLost?.Invoke(); };
            RawWindow.FocusGained += () => { FocusGained?.Invoke(); };
            RawWindow.Closing     += () => { Closing?.Invoke(); };
        }
コード例 #24
0
 public void SetWindowSize(Point windowSize)
 {
     MachinaClient.Print("Window size changed to", windowSize);
     if (!GamePlatform.IsAndroid)
     {
         this.graphics.PreferredBackBufferWidth  = windowSize.X;
         this.graphics.PreferredBackBufferHeight = windowSize.Y;
         this.graphics.ApplyChanges();
         Resized?.Invoke(windowSize);
     }
 }
コード例 #25
0
        async void Attach(IntPtr rpHandle)
        {
            BrowserControl = new BrowserHost(rpHandle);
            OnPropertyChanged(nameof(BrowserControl));

            Attached?.Invoke();

            BrowserControl.SizeChanged += (s, e) => Resized?.Invoke(this, e.NewSize);

            await Task.Delay(2000);

            Navigator.Navigate(Preference.Instance.Browser.Homepage);
        }
コード例 #26
0
ファイル: WindowImpl.cs プロジェクト: Serg2DFX/Perspex
        void ISurfaceHolderCallback.SurfaceChanged(ISurfaceHolder holder, Format format, int width, int height)
        {
            var newSize = new Size(width, height);

            if (newSize != ClientSize)
            {
                MaxClientSize = newSize;
                ClientSize    = newSize;
                Resized?.Invoke(ClientSize);
            }

            base.SurfaceChanged(holder, format, width, height);
        }
コード例 #27
0
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);

            const double dpiScale = 1;
            uint         width    = (uint)(Width < 0 ? 0 : Math.Ceiling(Width * dpiScale));
            uint         height   = (uint)(Height < 0 ? 0 : Math.Ceiling(Height * dpiScale));

            NativeMethods.MoveWindow(HWND, 0, 0, Width, Height, true);
            MainSwapchain.Resize(width, height);

            Resized?.Invoke();
        }
コード例 #28
0
ファイル: VeldridHost.cs プロジェクト: erictuvesson/CSG
        public void Run()
        {
            var options = new GraphicsDeviceOptions(
                debug: false,
                swapchainDepthFormat: PixelFormat.R16_UNorm,
                syncToVerticalBlank: true,
                resourceBindingModel: ResourceBindingModel.Improved,
                preferDepthRangeZeroToOne: true,
                preferStandardClipSpaceYDirection: true);

#if DEBUG
            options.Debug = true;
#endif

            graphicsDevice  = VeldridStartup.CreateGraphicsDevice(window, options);
            resourceFactory = new DisposeCollectorResourceFactory(graphicsDevice.ResourceFactory);

            this.DrawingContext = new DrawingContext(graphicsDevice, resourceFactory);
            DrawingContextCreated?.Invoke(DrawingContext);

            var sw = Stopwatch.StartNew();
            var previousElapsed = sw.Elapsed.TotalSeconds;

            while (window.Exists)
            {
                double newElapsed   = sw.Elapsed.TotalSeconds;
                float  deltaSeconds = (float)(newElapsed - previousElapsed);

                this.InputSnapshot = window.PumpEvents();
                //InputTracker.UpdateFrameInput(inputSnapshot);

                if (window.Exists)
                {
                    previousElapsed = newElapsed;
                    if (windowResized)
                    {
                        windowResized = false;
                        graphicsDevice.ResizeMainWindow((uint)window.Width, (uint)window.Height);
                        Resized?.Invoke();
                    }

                    Rendering?.Invoke(deltaSeconds);
                }
            }

            graphicsDevice.WaitForIdle();
            resourceFactory.DisposeCollector.DisposeAll();
            graphicsDevice.Dispose();

            DrawingContextDestroyed?.Invoke();
        }
コード例 #29
0
        /// <summary>
        /// Makes a new instance of <see cref="GlfwWindow"/> class.
        /// This class manage a crossplatform window.
        /// </summary>
        /// <param name="size">Initial window size.</param>
        /// <param name="title">Initial window title.</param>
        public GlfwWindow(Vector2i size, string title)
        {
            // - Initialize properties
            Size     = new Notify <Vector2i>(size);
            Position = new Notify <Vector2i>();
            Title    = new Notify <string>(title);

            // - Bind properties events
            Size.Changing     += SizeChanging;
            Position.Changing += PositionChanging;
            Title.Changing    += TitleChanging;

            // - Initialize callback store
            pSizeCallback = new SizeCallback((hnd, w, h) => Resized?.Invoke(this, new Vector2(w, h)));
        }
コード例 #30
0
        public void Run()
        {
            GraphicsDeviceOptions options = new GraphicsDeviceOptions(
                debug: false,
                swapchainDepthFormat: PixelFormat.R16_UNorm,
                syncToVerticalBlank: true,
                resourceBindingModel: ResourceBindingModel.Improved,
                preferDepthRangeZeroToOne: true,
                preferStandardClipSpaceYDirection: true);

#if DEBUG
            options.Debug = true;
#endif
            GD      = VeldridStartup.CreateGraphicsDevice(Window, options, GraphicsBackend.Direct3D11);
            Factory = new DisposeCollectorResourceFactory(GD.ResourceFactory);
            GraphicsDeviceCreated?.Invoke(GD, Factory, GD.MainSwapchain);

            Stopwatch sw = Stopwatch.StartNew();
            double    previousElapsed = sw.Elapsed.TotalSeconds;
            long      ticks           = 0;

            while (Window.Exists)
            {
                double newElapsed   = sw.Elapsed.TotalSeconds;
                float  deltaSeconds = (float)(newElapsed - previousElapsed);

                InputSnapshot inputSnapshot = Window.PumpEvents();
                InputTracker.UpdateFrameInput(inputSnapshot);

                if (Window.Exists)
                {
                    previousElapsed = newElapsed;
                    if (WindowResized)
                    {
                        WindowResized = false;
                        GD.ResizeMainWindow((uint)Window.Width, (uint)Window.Height);
                        Resized?.Invoke();
                    }

                    Rendering?.Invoke(deltaSeconds, ticks++);
                }
            }

            GD.WaitForIdle();
            Factory.DisposeCollector.DisposeAll();
            GD.Dispose();
            GraphicsDeviceDestroyed?.Invoke();
        }