Beispiel #1
0
        void UpdateViewportZooms(bool resetCurrentZoom = true)
        {
            lastViewportDistance = graphicSettings.ViewportDistance;

            var vd = graphicSettings.ViewportDistance;

            if (viewportSizes.AllowNativeZoom && vd == WorldViewport.Native)
            {
                minZoom = 1;
            }
            else
            {
                var range = viewportSizes.GetSizeRange(vd);
                minZoom = CalculateMinimumZoom(range.X, range.Y);
            }

            maxZoom = Math.Min(minZoom * viewportSizes.MaxZoomScale, Game.Renderer.NativeResolution.Height * 1f / viewportSizes.MaxZoomWindowHeight);

            if (unlockMinZoom)
            {
                // Specators and the map editor support zooming out by an extra factor of two.
                // TODO: Allow zooming out until the full map is visible
                // We need to improve our viewport scroll handling to center the map as we zoom out
                // before this will work well enough to enable
                unlockedMinZoom = minZoom * unlockedMinZoomScale;
            }

            if (resetCurrentZoom)
            {
                Zoom = minZoom;
            }
            else
            {
                Zoom = Zoom.Clamp(minZoom, maxZoom);
            }

            foreach (var t in worldRenderer.World.WorldActor.TraitsImplementing <INotifyViewportZoomExtentsChanged>())
            {
                t.ViewportZoomExtentsChanged(minZoom, maxZoom);
            }
        }
Beispiel #2
0
        public void Update()
        {
            DelayedMouseScreenPosition = MouseScreenPosition;
            if (Math.Abs(ZoomVelocity) > 0.02f)
            {
                float oldzoom = Zoom;
                ZoomVelocity *= 0.9f;
                Zoom         += ZoomVelocity * 0.01f * Zoom;
                Zoom          = Zoom.Clamp(0.01f, 500);

                Vector2 oldimage = MouseStartZoomScreen / oldzoom;
                Vector2 newimage = MouseStartZoomScreen / Zoom;

                Offset -= newimage - oldimage;
            }

            if (Math.Abs(OffsetVelocity) > 0.1f)
            {
                OffsetVelocity *= 0.9f;

                Offset -= OffsetDirection * OffsetVelocity * 5 / Zoom;
            }
        }