diff --git a/UI/ViewModels/HistoryViewerViewModel.cs b/UI/ViewModels/HistoryViewerViewModel.cs index ac732b58..a5fd5f39 100644 --- a/UI/ViewModels/HistoryViewerViewModel.cs +++ b/UI/ViewModels/HistoryViewerViewModel.cs @@ -111,7 +111,11 @@ public void InitActions(HistoryViewerWindow wnd) GetScaleMenuItem(wnd, 3), GetScaleMenuItem(wnd, 4), GetScaleMenuItem(wnd, 5), - GetScaleMenuItem(wnd, 6) + GetScaleMenuItem(wnd, 6), + GetScaleMenuItem(wnd, 7), + GetScaleMenuItem(wnd, 8), + GetScaleMenuItem(wnd, 9), + GetScaleMenuItem(wnd, 10) } } }; @@ -195,7 +199,7 @@ private ContextMenuAction GetScaleMenuItem(HistoryViewerWindow wnd, int scale) return new ContextMenuAction() { ActionType = ActionType.Custom, CustomText = scale + "x", - Shortcut = () => new DbgShortKeys(KeyModifiers.Alt, Key.D0 + scale), + Shortcut = () => new DbgShortKeys(KeyModifiers.Alt, scale == 10 ? Key.D0 : Key.D0 + scale), OnClick = () => wnd.SetScale(scale), IsSelected = () => (int)((double)RendererSize.Height / EmuApi.GetBaseScreenSize().Height) == scale }; diff --git a/UI/Windows/HistoryViewerWindow.axaml.cs b/UI/Windows/HistoryViewerWindow.axaml.cs index bebb5c10..41774041 100644 --- a/UI/Windows/HistoryViewerWindow.axaml.cs +++ b/UI/Windows/HistoryViewerWindow.axaml.cs @@ -147,21 +147,20 @@ public void SetScale(double scale) private void InternalSetScale(double scale) { double dpiScale = LayoutHelper.GetLayoutScale(this); - scale /= dpiScale; + double aspectRatio = EmuApi.GetAspectRatio(); FrameInfo screenSize = EmuApi.GetBaseScreenSize(); if(WindowState == WindowState.Normal) { _rendererSize = new Size(); - double aspectRatio = EmuApi.GetAspectRatio(); double menuHeight = _mainMenu.Bounds.Height; - double width = Math.Max(MinWidth, Math.Round(screenSize.Height * aspectRatio) * scale); - double height = Math.Max(MinHeight, screenSize.Height * scale); + double width = Math.Max(MinWidth, Math.Round(screenSize.Height * aspectRatio * scale) / dpiScale); + double height = Math.Max(MinHeight, screenSize.Height * scale / dpiScale); ClientSize = new Size(width, height + menuHeight + _controlBar.Bounds.Height); ResizeRenderer(); } else if(WindowState == WindowState.Maximized || WindowState == WindowState.FullScreen) { - _rendererSize = new Size(Math.Floor(screenSize.Width * scale), Math.Floor(screenSize.Height * scale)); + _rendererSize = new Size(Math.Floor(screenSize.Width * scale * aspectRatio) / dpiScale, Math.Floor(screenSize.Height * scale) / dpiScale); ResizeRenderer(); } } @@ -175,27 +174,24 @@ private void ResizeRenderer() private void RendererPanel_LayoutUpdated(object? sender, EventArgs e) { double aspectRatio = EmuApi.GetAspectRatio(); + double dpiScale = LayoutHelper.GetLayoutScale(this); Size finalSize = _rendererSize == default ? _rendererPanel.Bounds.Size : _rendererSize; double height = finalSize.Height; double width = finalSize.Height * aspectRatio; - if(width > finalSize.Width) { - width = finalSize.Width; - height = width / aspectRatio; - } - + if(ConfigManager.Config.Video.FullscreenForceIntegerScale && VisualRoot is Window wnd && (wnd.WindowState == WindowState.FullScreen || wnd.WindowState == WindowState.Maximized)) { FrameInfo baseSize = EmuApi.GetBaseScreenSize(); - double scale = height * LayoutHelper.GetLayoutScale(this) / baseSize.Height; + double scale = height * dpiScale / baseSize.Height; if(scale != Math.Floor(scale)) { - height = baseSize.Height * Math.Max(1, Math.Floor(scale / LayoutHelper.GetLayoutScale(this))); + height = baseSize.Height * Math.Max(1, Math.Floor(scale / dpiScale)); width = height * aspectRatio; } } _model.RendererSize = new Size( - Math.Round(width * LayoutHelper.GetLayoutScale(this)), - Math.Round(height * LayoutHelper.GetLayoutScale(this)) + Math.Round(width * dpiScale), + Math.Round(height * dpiScale) ); _renderer.Width = width; diff --git a/UI/Windows/MainWindow.axaml.cs b/UI/Windows/MainWindow.axaml.cs index bd771308..687cc3c3 100644 --- a/UI/Windows/MainWindow.axaml.cs +++ b/UI/Windows/MainWindow.axaml.cs @@ -427,23 +427,22 @@ public void SetScale(double scale) private void InternalSetScale(double scale) { double dpiScale = LayoutHelper.GetLayoutScale(this); - scale /= dpiScale; + double aspectRatio = EmuApi.GetAspectRatio(); FrameInfo screenSize = EmuApi.GetBaseScreenSize(); if(WindowState == WindowState.Normal) { _rendererSize = new Size(); - double aspectRatio = EmuApi.GetAspectRatio(); //When menu is set to auto-hide, don't count its height when calculating the window's final size double menuHeight = ConfigManager.Config.Preferences.AutoHideMenu ? 0 : _mainMenu.Bounds.Height; - double width = Math.Max(MinWidth, Math.Round(screenSize.Height * aspectRatio) * scale); - double height = Math.Max(MinHeight, screenSize.Height * scale); + double width = Math.Max(MinWidth, Math.Round(screenSize.Height * aspectRatio * scale) / dpiScale); + double height = Math.Max(MinHeight, screenSize.Height * scale / dpiScale); ClientSize = new Size(width, height + menuHeight + _audioPlayer.Bounds.Height); ResizeRenderer(); } else if(WindowState == WindowState.Maximized || WindowState == WindowState.FullScreen) { - _rendererSize = new Size(Math.Floor(screenSize.Width * scale), Math.Floor(screenSize.Height * scale)); + _rendererSize = new Size(Math.Round(screenSize.Width * scale * aspectRatio) / dpiScale, Math.Round(screenSize.Height * scale) / dpiScale); ResizeRenderer(); } } @@ -457,26 +456,23 @@ private void ResizeRenderer() private void RendererPanel_LayoutUpdated(object? sender, EventArgs e) { double aspectRatio = EmuApi.GetAspectRatio(); + double dpiScale = LayoutHelper.GetLayoutScale(this); Size finalSize = _rendererSize == default ? _rendererPanel.Bounds.Size : _rendererSize; double height = finalSize.Height; double width = finalSize.Height * aspectRatio; - if(width > finalSize.Width) { - width = finalSize.Width; - height = width / aspectRatio; - } if(ConfigManager.Config.Video.FullscreenForceIntegerScale && VisualRoot is Window wnd && (wnd.WindowState == WindowState.FullScreen || wnd.WindowState == WindowState.Maximized)) { FrameInfo baseSize = EmuApi.GetBaseScreenSize(); - double scale = height * LayoutHelper.GetLayoutScale(this) / baseSize.Height; + double scale = height * dpiScale / baseSize.Height; if(scale != Math.Floor(scale)) { - height = baseSize.Height * Math.Max(1, Math.Floor(scale / LayoutHelper.GetLayoutScale(this))); + height = baseSize.Height * Math.Max(1, Math.Floor(scale / dpiScale)); width = height * aspectRatio; } } - uint realWidth = (uint)Math.Round(width * LayoutHelper.GetLayoutScale(this)); - uint realHeight = (uint)Math.Round(height * LayoutHelper.GetLayoutScale(this)); + uint realWidth = (uint)Math.Round(width * dpiScale); + uint realHeight = (uint)Math.Round(height * dpiScale); EmuApi.SetRendererSize(realWidth, realHeight); _model.RendererSize = new Size(realWidth, realHeight);