mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Add public control sawmill to UI Manager (#6231)
* Add public control sawmill * Remove static IoCManager in MarkupTagManager * very important comment * release notes * fix merge * fix
This commit is contained in:
@@ -41,7 +41,7 @@ END TEMPLATE-->
|
||||
|
||||
### New features
|
||||
|
||||
*None yet*
|
||||
* Added `IUserInterfaceManager.ControlSawmill` and `Control.Log` properties so that controls can easily use logging without using static methods.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ using Robust.Client.UserInterface.Themes;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Animations;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -74,6 +75,8 @@ namespace Robust.Client.UserInterface
|
||||
// _nameScope = nameScope;
|
||||
//}
|
||||
|
||||
public virtual ISawmill Log => UserInterfaceManager.ControlSawmill;
|
||||
|
||||
public UITheme Theme { get; internal set; }
|
||||
|
||||
private UITheme? _themeOverride;
|
||||
@@ -381,8 +384,6 @@ namespace Robust.Client.UserInterface
|
||||
/// </summary>
|
||||
public event EventHandler? OnShowTooltip;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// If this control is currently showing a tooltip provided via TooltipSupplier,
|
||||
/// returns that tooltip. Do not move this control within the tree, it should remain in PopupRoot.
|
||||
|
||||
@@ -6,6 +6,7 @@ using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Audio.Sources;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
@@ -157,6 +158,14 @@ namespace Robust.Client.UserInterface
|
||||
/// Render a control and all of its children.
|
||||
/// </summary>
|
||||
void RenderControl(IRenderHandle handle, Control control, Vector2i position);
|
||||
|
||||
/// <summary>
|
||||
/// Sawmill for use by controls.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Exists so that control don't have to inject dependencies or otherwise obtain an <see cref="ILogManager"/> instance just to log errors.
|
||||
/// </remarks>
|
||||
ISawmill ControlSawmill { get; }
|
||||
}
|
||||
|
||||
public readonly struct PostDrawUIRootEventArgs
|
||||
|
||||
@@ -12,11 +12,13 @@ public sealed class MarkupTagManager
|
||||
{
|
||||
[Dependency] private readonly IReflectionManager _reflectionManager = default!;
|
||||
[Dependency] private readonly ISandboxHelper _sandboxHelper = default!;
|
||||
[Dependency] private readonly IDependencyCollection _deps = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Tags defined in engine need to be instantiated here because of sandboxing
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, IMarkupTagHandler> _markupTagTypes = new IMarkupTagHandler[] {
|
||||
private readonly Dictionary<string, IMarkupTagHandler> _markupTagTypes = new IMarkupTagHandler[]
|
||||
{
|
||||
new BoldItalicTag(),
|
||||
new BoldTag(),
|
||||
new BulletTag(),
|
||||
@@ -50,13 +52,13 @@ public sealed class MarkupTagManager
|
||||
if (_engineTypes.Contains(type))
|
||||
continue;
|
||||
|
||||
var instance = (IMarkupTagHandler)_sandboxHelper.CreateInstance(type);
|
||||
var instance = (IMarkupTagHandler) _sandboxHelper.CreateInstance(type);
|
||||
_markupTagTypes[instance.Name.ToLower()] = instance;
|
||||
}
|
||||
|
||||
foreach (var (_, tag) in _markupTagTypes)
|
||||
foreach (var tag in _markupTagTypes.Values)
|
||||
{
|
||||
IoCManager.InjectDependencies(tag);
|
||||
_deps.InjectDependencies(tag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@ namespace Robust.Client.UserInterface
|
||||
private Stylesheet? _stylesheet;
|
||||
|
||||
private ISawmill _sawmillUI = default!;
|
||||
public ISawmill ControlSawmill { get; private set; } = default!;
|
||||
|
||||
public event Action<Control>? OnKeyBindDown;
|
||||
|
||||
@@ -147,6 +148,7 @@ namespace Robust.Client.UserInterface
|
||||
private void _initializeCommon()
|
||||
{
|
||||
_sawmillUI = _logManager.GetSawmill("ui");
|
||||
ControlSawmill = _logManager.GetSawmill("ctrl");
|
||||
|
||||
RootControl = CreateWindowRoot(_clyde.MainWindow);
|
||||
RootControl.Name = "MainWindowRoot";
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Robust.Shared.Log
|
||||
/// The instance we're using.
|
||||
/// As it's a direct proxy to IoC this will not work if IoC is not functional.
|
||||
/// </summary>
|
||||
// TODO: Maybe cache this to improve performance.
|
||||
// TODO: Kill
|
||||
private static ILogManager LogManagerSingleton => IoCManager.Resolve<ILogManager>();
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user