Adds integer scaling option (#4300)

* Adds integer scaling option

* RobustToolbox

* Update option name and tooltip
This commit is contained in:
Visne
2021-07-21 13:30:50 +02:00
committed by GitHub
parent dbaa7585cb
commit 8ee312f2d4
3 changed files with 17 additions and 2 deletions

View File

@@ -30,6 +30,9 @@
MinWidth="200" /> MinWidth="200" />
</BoxContainer> </BoxContainer>
</BoxContainer> </BoxContainer>
<CheckBox Name="IntegerScalingCheckBox"
Text="{Loc 'ui-options-vp-integer-scaling'}"
ToolTip="{Loc 'ui-options-vp-integer-scaling-tooltip'}" />
<CheckBox Name="ViewportLowResCheckBox" Text="{Loc 'ui-options-vp-low-res'}" /> <CheckBox Name="ViewportLowResCheckBox" Text="{Loc 'ui-options-vp-low-res'}" />
</BoxContainer> </BoxContainer>
<hudUi:StripeBack HasBottomEdge="False" HasMargins="False"> <hudUi:StripeBack HasBottomEdge="False" HasMargins="False">

View File

@@ -73,6 +73,7 @@ namespace Content.Client.EscapeMenu.UI.Tabs
UpdateViewportScale(); UpdateViewportScale();
}; };
IntegerScalingCheckBox.OnToggled += OnCheckBoxToggled;
ViewportLowResCheckBox.OnToggled += OnCheckBoxToggled; ViewportLowResCheckBox.OnToggled += OnCheckBoxToggled;
ApplyButton.OnPressed += OnApplyButtonPressed; ApplyButton.OnPressed += OnApplyButtonPressed;
VSyncCheckBox.Pressed = _cfg.GetCVar(CVars.DisplayVSync); VSyncCheckBox.Pressed = _cfg.GetCVar(CVars.DisplayVSync);
@@ -82,6 +83,7 @@ namespace Content.Client.EscapeMenu.UI.Tabs
HudThemeOption.SelectId(_cfg.GetCVar(CCVars.HudTheme)); HudThemeOption.SelectId(_cfg.GetCVar(CCVars.HudTheme));
ViewportScaleSlider.Value = _cfg.GetCVar(CCVars.ViewportFixedScaleFactor); ViewportScaleSlider.Value = _cfg.GetCVar(CCVars.ViewportFixedScaleFactor);
ViewportStretchCheckBox.Pressed = _cfg.GetCVar(CCVars.ViewportStretch); ViewportStretchCheckBox.Pressed = _cfg.GetCVar(CCVars.ViewportStretch);
IntegerScalingCheckBox.Pressed = _cfg.GetCVar(CCVars.ViewportSnapToleranceMargin) != 0;
ViewportLowResCheckBox.Pressed = !_cfg.GetCVar(CCVars.ViewportScaleRender); ViewportLowResCheckBox.Pressed = !_cfg.GetCVar(CCVars.ViewportScaleRender);
UpdateViewportScale(); UpdateViewportScale();
@@ -114,6 +116,8 @@ namespace Content.Client.EscapeMenu.UI.Tabs
_cfg.SetCVar(CVars.DisplayUIScale, UIScaleOptions[UIScaleOption.SelectedId]); _cfg.SetCVar(CVars.DisplayUIScale, UIScaleOptions[UIScaleOption.SelectedId]);
_cfg.SetCVar(CCVars.ViewportStretch, ViewportStretchCheckBox.Pressed); _cfg.SetCVar(CCVars.ViewportStretch, ViewportStretchCheckBox.Pressed);
_cfg.SetCVar(CCVars.ViewportFixedScaleFactor, (int) ViewportScaleSlider.Value); _cfg.SetCVar(CCVars.ViewportFixedScaleFactor, (int) ViewportScaleSlider.Value);
_cfg.SetCVar(CCVars.ViewportSnapToleranceMargin,
IntegerScalingCheckBox.Pressed ? CCVars.ViewportSnapToleranceMargin.DefaultValue : 0);
_cfg.SetCVar(CCVars.ViewportScaleRender, !ViewportLowResCheckBox.Pressed); _cfg.SetCVar(CCVars.ViewportScaleRender, !ViewportLowResCheckBox.Pressed);
_cfg.SaveToFile(); _cfg.SaveToFile();
UpdateApplyButton(); UpdateApplyButton();
@@ -139,6 +143,7 @@ namespace Content.Client.EscapeMenu.UI.Tabs
var isUIScaleSame = MathHelper.CloseTo(UIScaleOptions[UIScaleOption.SelectedId], ConfigUIScale); var isUIScaleSame = MathHelper.CloseTo(UIScaleOptions[UIScaleOption.SelectedId], ConfigUIScale);
var isVPStretchSame = ViewportStretchCheckBox.Pressed == _cfg.GetCVar(CCVars.ViewportStretch); var isVPStretchSame = ViewportStretchCheckBox.Pressed == _cfg.GetCVar(CCVars.ViewportStretch);
var isVPScaleSame = (int) ViewportScaleSlider.Value == _cfg.GetCVar(CCVars.ViewportFixedScaleFactor); var isVPScaleSame = (int) ViewportScaleSlider.Value == _cfg.GetCVar(CCVars.ViewportFixedScaleFactor);
var isIntegerScalingSame = IntegerScalingCheckBox.Pressed == (_cfg.GetCVar(CCVars.ViewportSnapToleranceMargin) != 0);
var isVPResSame = ViewportLowResCheckBox.Pressed == !_cfg.GetCVar(CCVars.ViewportScaleRender); var isVPResSame = ViewportLowResCheckBox.Pressed == !_cfg.GetCVar(CCVars.ViewportScaleRender);
ApplyButton.Disabled = isVSyncSame && ApplyButton.Disabled = isVSyncSame &&
@@ -147,6 +152,7 @@ namespace Content.Client.EscapeMenu.UI.Tabs
isUIScaleSame && isUIScaleSame &&
isVPStretchSame && isVPStretchSame &&
isVPScaleSame && isVPScaleSame &&
isIntegerScalingSame &&
isVPResSame && isVPResSame &&
isHudThemeSame; isHudThemeSame;
} }
@@ -217,6 +223,7 @@ namespace Content.Client.EscapeMenu.UI.Tabs
private void UpdateViewportScale() private void UpdateViewportScale()
{ {
ViewportScaleBox.Visible = !ViewportStretchCheckBox.Pressed; ViewportScaleBox.Visible = !ViewportStretchCheckBox.Pressed;
IntegerScalingCheckBox.Visible = ViewportStretchCheckBox.Pressed;
ViewportScaleText.Text = Loc.GetString("ui-options-vp-scale", ("scale", ViewportScaleSlider.Value)); ViewportScaleText.Text = Loc.GetString("ui-options-vp-scale", ("scale", ViewportScaleSlider.Value));
} }
} }

View File

@@ -37,9 +37,14 @@ ui-options-hud-theme = HUD Theme:
ui-options-hud-theme-default = Default ui-options-hud-theme-default = Default
ui-options-hud-theme-modernized = Modernized ui-options-hud-theme-modernized = Modernized
ui-options-hud-theme-classic = Classic ui-options-hud-theme-classic = Classic
ui-options-vp-stretch = Stretch viewport to fit game window? ui-options-vp-stretch = Stretch viewport to fit game window
ui-options-vp-scale = Fixed viewport scale: x{ $scale } ui-options-vp-scale = Fixed viewport scale: x{ $scale }
ui-options-vp-low-res = Low-resolution viewport? ui-options-vp-integer-scaling = Prefer integer scaling (might cause black bars/clipping)
ui-options-vp-integer-scaling-tooltip = If this option is enabled, the viewport will be scaled using an integer value
at specific resolutions. While this results in crisp textures, it also often
means that black bars appear at the top/bottom of the screen or that part
of the viewport is not visible.
ui-options-vp-low-res = Low-resolution viewport
## Controls menu ## Controls menu