Viewport improvements (#3765)

This commit is contained in:
Pieter-Jan Briers
2021-04-19 09:52:40 +02:00
committed by GitHub
parent 8e2fc49357
commit 147a54c642
40 changed files with 1173 additions and 418 deletions

View File

@@ -0,0 +1,42 @@
using System.Collections.Generic;
using Content.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.IoC;
namespace Content.Client.UserInterface
{
/// <summary>
/// Event proxy for <see cref="MainViewport"/> to listen to config events.
/// </summary>
// ReSharper disable once ClassNeverInstantiated.Global
public sealed class ViewportManager
{
[Dependency] private readonly IConfigurationManager _cfg = default!;
private readonly List<MainViewport> _viewports = new();
public void Initialize()
{
_cfg.OnValueChanged(CCVars.ViewportStretch, _ => UpdateCfg());
_cfg.OnValueChanged(CCVars.ViewportSnapToleranceClip, _ => UpdateCfg());
_cfg.OnValueChanged(CCVars.ViewportSnapToleranceMargin, _ => UpdateCfg());
_cfg.OnValueChanged(CCVars.ViewportScaleRender, _ => UpdateCfg());
_cfg.OnValueChanged(CCVars.ViewportFixedScaleFactor, _ => UpdateCfg());
}
private void UpdateCfg()
{
_viewports.ForEach(v => v.UpdateCfg());
}
public void AddViewport(MainViewport vp)
{
_viewports.Add(vp);
}
public void RemoveViewport(MainViewport vp)
{
_viewports.Remove(vp);
}
}
}