Re-organize all projects (#4166)
This commit is contained in:
43
Content.Client/Viewport/ViewportManager.cs
Normal file
43
Content.Client/Viewport/ViewportManager.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.HUD.UI;
|
||||
using Content.Shared;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.Viewport
|
||||
{
|
||||
/// <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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user