示例#1
0
        public WorldViewportGump(GameScene scene) : base(0, 0)
        {
            AcceptMouseInput       = false;
            CanMove                = !Engine.Profile.Current.GameWindowLock;
            CanCloseWithEsc        = false;
            CanCloseWithRightClick = false;
            ControlInfo.Layer      = UILayer.Under;
            X            = Engine.Profile.Current.GameWindowPosition.X;
            Y            = Engine.Profile.Current.GameWindowPosition.Y;
            _worldWidth  = Engine.Profile.Current.GameWindowSize.X;
            _worldHeight = Engine.Profile.Current.GameWindowSize.Y;
            _button      = new Button(0, 0x837, 0x838, 0x838);

            _button.MouseDown += (sender, e) =>
            {
                if (!Engine.Profile.Current.GameWindowLock)
                {
                    _clicked = true;
                }
            };

            _button.MouseUp += (sender, e) =>
            {
                if (!Engine.Profile.Current.GameWindowLock)
                {
                    Point n = ResizeWindow(_lastSize);

                    OptionsGump options = Engine.UI.GetGump <OptionsGump>();
                    options?.UpdateVideo();

                    if (FileManager.ClientVersion >= ClientVersions.CV_200)
                    {
                        NetClient.Socket.Send(new PGameWindowSize((uint)n.X, (uint)n.Y));
                    }

                    _clicked = false;
                }
            };

            _button.SetTooltip("Resize game window");
            Width            = _worldWidth + BORDER_WIDTH * 2;
            Height           = _worldHeight + BORDER_HEIGHT * 2;
            _border          = new GameBorder(0, 0, Width, Height, 4);
            _border.DragEnd += (sender, e) =>
            {
                OptionsGump options = Engine.UI.GetGump <OptionsGump>();
                options?.UpdateVideo();
            };
            _viewport = new WorldViewport(scene, BORDER_WIDTH, BORDER_HEIGHT, _worldWidth, _worldHeight);

            Engine.UI.SystemChat = _systemChatControl = new SystemChatControl(BORDER_WIDTH, BORDER_HEIGHT, _worldWidth, _worldHeight);

            Add(_border);
            Add(_button);
            Add(_viewport);
            Add(_systemChatControl);
            Resize();

            _savedSize = _lastSize = Engine.Profile.Current.GameWindowSize;
        }
示例#2
0
 private void OnResize()
 {
     if (Service.Has <ChatControl>())
     {
         Service.Remove <ChatControl>();
     }
     ClearControls();
     Size = new Vector2Int(_worldWidth + BorderWidth * 2, _worldHeight + BorderHeight * 2);
     AddControl(_border     = new ResizePic(this, 0, 0, 0xa3c, Width, Height));
     AddControl(_viewport   = new WorldViewport(this, BorderWidth, BorderHeight, _worldWidth, _worldHeight));
     AddControl(_chatWindow = new ChatControl(this, BorderWidth, BorderHeight, _worldWidth, _worldHeight));
     Service.Add <ChatControl>(_chatWindow);
 }
示例#3
0
        private void OnResize()
        {
            if (Service.Has <ChatControl>())
            {
                Service.Remove <ChatControl>();
            }

            ClearControls();

            Size = new Point(m_WorldWidth + BorderWidth * 2, m_WorldHeight + BorderHeight * 2);
            AddControl(m_Border     = new ResizePic(this, 0, 0, 0xa3c, Width, Height));
            AddControl(m_Viewport   = new WorldViewport(this, BorderWidth, BorderHeight, m_WorldWidth, m_WorldHeight));
            AddControl(m_ChatWindow = new ChatControl(this, BorderWidth, BorderHeight, m_WorldWidth, m_WorldHeight));
            Service.Add <ChatControl>(m_ChatWindow);
        }
示例#4
0
        private void OnResize()
        {
            if (ServiceRegistry.ServiceExists <ChatControl>())
            {
                ServiceRegistry.Unregister <ChatControl>();
            }

            ClearControls();

            Size = new Point(m_WorldWidth + BorderWidth * 2, m_WorldHeight + BorderHeight * 2);
            AddControl(m_Border     = new ResizePic(this, 0, 0, 0xa3c, Width, Height));
            AddControl(m_Viewport   = new WorldViewport(this, BorderWidth, BorderHeight, m_WorldWidth, m_WorldHeight));
            AddControl(m_ChatWindow = new ChatControl(this, BorderWidth, BorderHeight, 400, m_WorldHeight));
            ServiceRegistry.Register <ChatControl>(m_ChatWindow);
        }
示例#5
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);
            }
        }
示例#6
0
        public WorldViewportGump(GameScene scene) : base(0, 0)
        {
            _scene                 = scene;
            AcceptMouseInput       = false;
            CanMove                = !ProfileManager.Current.GameWindowLock;
            CanCloseWithEsc        = false;
            CanCloseWithRightClick = false;
            ControlInfo.Layer      = UILayer.Under;
            X            = ProfileManager.Current.GameWindowPosition.X;
            Y            = ProfileManager.Current.GameWindowPosition.Y;
            _worldWidth  = ProfileManager.Current.GameWindowSize.X;
            _worldHeight = ProfileManager.Current.GameWindowSize.Y;
            _savedSize   = _lastSize = ProfileManager.Current.GameWindowSize;

            _button = new Button(0, 0x837, 0x838, 0x838);

            //Upscale resize button on mobile
            if (UnityEngine.Application.isMobilePlatform)
            {
                _button.Width           *= 2;
                _button.Height          *= 2;
                _button.ContainsByBounds = true;
            }

            _button.MouseDown += (sender, e) =>
            {
                if (!ProfileManager.Current.GameWindowLock)
                {
                    _clicked = true;
                }
            };

            _button.MouseUp += (sender, e) =>
            {
                if (!ProfileManager.Current.GameWindowLock)
                {
                    Point n = ResizeGameWindow(_lastSize);

                    UIManager.GetGump <OptionsGump>()?.UpdateVideo();

                    if (Client.Version >= ClientVersion.CV_200)
                    {
                        NetClient.Socket.Send(new PGameWindowSize((uint)n.X, (uint)n.Y));
                    }

                    _clicked = false;
                }
            };

            _button.SetTooltip("Resize game window");
            Width                   = _worldWidth + BORDER_WIDTH * 2;
            Height                  = _worldHeight + BORDER_HEIGHT * 2;
            _borderControl          = new BorderControl(0, 0, Width, Height, 4);
            _borderControl.DragEnd += (sender, e) =>
            {
                UIManager.GetGump <OptionsGump>()?.UpdateVideo();
            };
            _viewport = new WorldViewport(_scene, BORDER_WIDTH, BORDER_HEIGHT, _worldWidth, _worldHeight);

            UIManager.SystemChat = _systemChatControl = new SystemChatControl(BORDER_WIDTH, BORDER_HEIGHT, _worldWidth, _worldHeight);

            Add(_borderControl);
            Add(_button);
            Add(_viewport);
            Add(_systemChatControl);
            Resize();
        }
示例#7
0
 public int2 GetSizeRange(WorldViewport distance)
 {
     return(distance == WorldViewport.Close ? CloseWindowHeights
                         : distance == WorldViewport.Medium ? MediumWindowHeights
                         : FarWindowHeights);
 }