Add scaling filter option (Nearest/Bilinear) (#39111)
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
<CheckBox Name="IntegerScalingCheckBox"
|
<CheckBox Name="IntegerScalingCheckBox"
|
||||||
Text="{Loc 'ui-options-vp-integer-scaling'}"
|
Text="{Loc 'ui-options-vp-integer-scaling'}"
|
||||||
ToolTip="{Loc 'ui-options-vp-integer-scaling-tooltip'}" />
|
ToolTip="{Loc 'ui-options-vp-integer-scaling-tooltip'}" />
|
||||||
|
<ui:OptionDropDown Name="DropDownFilterMode" Title="{Loc 'ui-options-filter-label'}" />
|
||||||
<CheckBox Name="ViewportVerticalFitCheckBox"
|
<CheckBox Name="ViewportVerticalFitCheckBox"
|
||||||
Text="{Loc 'ui-options-vp-vertical-fit'}"
|
Text="{Loc 'ui-options-vp-vertical-fit'}"
|
||||||
ToolTip="{Loc 'ui-options-vp-vertical-fit-tooltip'}" />
|
ToolTip="{Loc 'ui-options-vp-vertical-fit-tooltip'}" />
|
||||||
|
|||||||
@@ -39,6 +39,14 @@ public sealed partial class GraphicsTab : Control
|
|||||||
new OptionDropDownCVar<float>.ValueOption(2.00f, Loc.GetString("ui-options-scale-200")),
|
new OptionDropDownCVar<float>.ValueOption(2.00f, Loc.GetString("ui-options-scale-200")),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
Control.AddOptionDropDown(
|
||||||
|
CCVars.ViewportScalingFilterMode,
|
||||||
|
DropDownFilterMode,
|
||||||
|
[
|
||||||
|
new OptionDropDownCVar<string>.ValueOption("nearest", Loc.GetString("ui-options-filter-nearest")),
|
||||||
|
new OptionDropDownCVar<string>.ValueOption("bilinear", Loc.GetString("ui-options-filter-bilinear")),
|
||||||
|
]);
|
||||||
|
|
||||||
var vpStretch = Control.AddOptionCheckBox(CCVars.ViewportStretch, ViewportStretchCheckBox);
|
var vpStretch = Control.AddOptionCheckBox(CCVars.ViewportStretch, ViewportStretchCheckBox);
|
||||||
var vpVertFit = Control.AddOptionCheckBox(CCVars.ViewportVerticalFit, ViewportVerticalFitCheckBox);
|
var vpVertFit = Control.AddOptionCheckBox(CCVars.ViewportVerticalFit, ViewportVerticalFitCheckBox);
|
||||||
Control.AddOptionSlider(
|
Control.AddOptionSlider(
|
||||||
@@ -50,6 +58,7 @@ public sealed partial class GraphicsTab : Control
|
|||||||
|
|
||||||
vpStretch.ImmediateValueChanged += _ => UpdateViewportSettingsVisibility();
|
vpStretch.ImmediateValueChanged += _ => UpdateViewportSettingsVisibility();
|
||||||
vpVertFit.ImmediateValueChanged += _ => UpdateViewportSettingsVisibility();
|
vpVertFit.ImmediateValueChanged += _ => UpdateViewportSettingsVisibility();
|
||||||
|
IntegerScalingCheckBox.OnToggled += _ => UpdateViewportSettingsVisibility();
|
||||||
|
|
||||||
Control.AddOptionSlider(
|
Control.AddOptionSlider(
|
||||||
CCVars.ViewportWidth,
|
CCVars.ViewportWidth,
|
||||||
@@ -77,6 +86,7 @@ public sealed partial class GraphicsTab : Control
|
|||||||
IntegerScalingCheckBox.Visible = ViewportStretchCheckBox.Pressed;
|
IntegerScalingCheckBox.Visible = ViewportStretchCheckBox.Pressed;
|
||||||
ViewportVerticalFitCheckBox.Visible = ViewportStretchCheckBox.Pressed;
|
ViewportVerticalFitCheckBox.Visible = ViewportStretchCheckBox.Pressed;
|
||||||
ViewportWidthSlider.Visible = !ViewportStretchCheckBox.Pressed || !ViewportVerticalFitCheckBox.Pressed;
|
ViewportWidthSlider.Visible = !ViewportStretchCheckBox.Pressed || !ViewportVerticalFitCheckBox.Pressed;
|
||||||
|
DropDownFilterMode.Visible = !IntegerScalingCheckBox.Pressed && ViewportStretchCheckBox.Pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateViewportWidthRange()
|
private void UpdateViewportWidthRange()
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ namespace Content.Client.UserInterface.Controls
|
|||||||
};
|
};
|
||||||
|
|
||||||
AddChild(Viewport);
|
AddChild(Viewport);
|
||||||
|
|
||||||
|
_cfg.OnValueChanged(CCVars.ViewportScalingFilterMode, _ => UpdateCfg(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void EnteredTree()
|
protected override void EnteredTree()
|
||||||
@@ -52,6 +54,7 @@ namespace Content.Client.UserInterface.Controls
|
|||||||
var renderScaleUp = _cfg.GetCVar(CCVars.ViewportScaleRender);
|
var renderScaleUp = _cfg.GetCVar(CCVars.ViewportScaleRender);
|
||||||
var fixedFactor = _cfg.GetCVar(CCVars.ViewportFixedScaleFactor);
|
var fixedFactor = _cfg.GetCVar(CCVars.ViewportFixedScaleFactor);
|
||||||
var verticalFit = _cfg.GetCVar(CCVars.ViewportVerticalFit);
|
var verticalFit = _cfg.GetCVar(CCVars.ViewportVerticalFit);
|
||||||
|
var filterMode = _cfg.GetCVar(CCVars.ViewportScalingFilterMode);
|
||||||
|
|
||||||
if (stretch)
|
if (stretch)
|
||||||
{
|
{
|
||||||
@@ -60,7 +63,11 @@ namespace Content.Client.UserInterface.Controls
|
|||||||
{
|
{
|
||||||
// Did not find a snap, enable stretching.
|
// Did not find a snap, enable stretching.
|
||||||
Viewport.FixedStretchSize = null;
|
Viewport.FixedStretchSize = null;
|
||||||
Viewport.StretchMode = ScalingViewportStretchMode.Bilinear;
|
Viewport.StretchMode = filterMode switch
|
||||||
|
{
|
||||||
|
"nearest" => ScalingViewportStretchMode.Nearest,
|
||||||
|
"bilinear" => ScalingViewportStretchMode.Bilinear
|
||||||
|
};
|
||||||
Viewport.IgnoreDimension = verticalFit ? ScalingViewportIgnoreDimension.Horizontal : ScalingViewportIgnoreDimension.None;
|
Viewport.IgnoreDimension = verticalFit ? ScalingViewportIgnoreDimension.Horizontal : ScalingViewportIgnoreDimension.None;
|
||||||
|
|
||||||
if (renderScaleUp)
|
if (renderScaleUp)
|
||||||
|
|||||||
@@ -30,4 +30,7 @@ public sealed partial class CCVars
|
|||||||
|
|
||||||
public static readonly CVarDef<bool> ViewportVerticalFit =
|
public static readonly CVarDef<bool> ViewportVerticalFit =
|
||||||
CVarDef.Create("viewport.vertical_fit", true, CVar.CLIENTONLY | CVar.ARCHIVE);
|
CVarDef.Create("viewport.vertical_fit", true, CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||||
|
|
||||||
|
public static readonly CVarDef<string> ViewportScalingFilterMode =
|
||||||
|
CVarDef.Create("viewport.scaling_filter", "nearest", CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,9 @@ ui-options-vp-integer-scaling-tooltip = If this option is enabled, the viewport
|
|||||||
at specific resolutions. While this results in crisp textures, it also often
|
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
|
means that black bars appear at the top/bottom of the screen or that part
|
||||||
of the viewport is not visible.
|
of the viewport is not visible.
|
||||||
|
ui-options-filter-label = Scaling filter:
|
||||||
|
ui-options-filter-nearest = Nearest (no smoothing)
|
||||||
|
ui-options-filter-bilinear = Bilinear (smoothed)
|
||||||
ui-options-vp-vertical-fit = Vertical viewport fitting
|
ui-options-vp-vertical-fit = Vertical viewport fitting
|
||||||
ui-options-vp-vertical-fit-tooltip = When enabled, the main viewport will ignore the horizontal axis entirely when
|
ui-options-vp-vertical-fit-tooltip = When enabled, the main viewport will ignore the horizontal axis entirely when
|
||||||
fitting to your screen. If your screen is smaller than the viewport, then this
|
fitting to your screen. If your screen is smaller than the viewport, then this
|
||||||
|
|||||||
Reference in New Issue
Block a user