diff --git a/Compatible/Compatible.csproj b/Compatible/Compatible.csproj index f46784f..fc38c1a 100644 --- a/Compatible/Compatible.csproj +++ b/Compatible/Compatible.csproj @@ -9,6 +9,6 @@ - + diff --git a/Qwilight/Qwilight.csproj b/Qwilight/Qwilight.csproj index d0ba61f..5917af6 100644 --- a/Qwilight/Qwilight.csproj +++ b/Qwilight/Qwilight.csproj @@ -36,10 +36,6 @@ - - - - @@ -52,7 +48,7 @@ - + all @@ -66,7 +62,7 @@ - + diff --git a/Qwilight/System/BaseUI/BasePaintProperty.cs b/Qwilight/System/BaseUI/BasePaintProperty.cs index 925d22d..951c7f9 100644 --- a/Qwilight/System/BaseUI/BasePaintProperty.cs +++ b/Qwilight/System/BaseUI/BasePaintProperty.cs @@ -278,7 +278,7 @@ if (hasAvatarTitle) { var avatarTitleValue = avatarTitle.Value; - targetSession.PaintVisibleText(PoolSystem.Instance.GetTextItem(avatarTitleValue.Title, Font), ref r, avatarTitleValue.TitleColor); + targetSession.PaintVisibleText(PoolSystem.Instance.GetTextItem(avatarTitleValue.Title, Font), ref r, avatarTitleValue.TitlePaints[100], DrawingSystem.Instance.FaintFilledPaints[100]); } } break; diff --git a/Qwilight/System/DrawingSystem/DrawingSystem.cs b/Qwilight/System/DrawingSystem/DrawingSystem.cs index ed82422..eab44b6 100644 --- a/Qwilight/System/DrawingSystem/DrawingSystem.cs +++ b/Qwilight/System/DrawingSystem/DrawingSystem.cs @@ -1103,6 +1103,7 @@ var textBound4 = textItem4.LayoutBounds; var textBound4Length = textBound4.Width; var textBound4Height = textBound4.Height; + var titlePaint = hasAvatarTitle ? avatarTitle.Value.TitlePaints[netItemFaintInt] : null; defaultComputer.HighestNetHeight = (float)Math.Max(defaultComputer.HighestNetHeight, Levels.StandardMargin + Math.Max(textBound0Height, textBound1Height) + Levels.StandardMargin + Utility.Max(textBound2Height, textBound3Height, textBound4Height) + Levels.StandardMarginFloat32); var highestNetHeight = defaultComputer.HighestNetHeight; @@ -1150,7 +1151,7 @@ if (hasAvatarTitle) { var position0 = Levels.StandardMargin + textBound0Length; - targetSession.PaintText(textItem0, ref r, avatarTitle.Value.TitleColor); + targetSession.PaintText(textItem0, ref r, titlePaint); r.Position0 += position0; targetSession.PaintText(textItem1, ref r, netTextPaint); r.Position0 -= position0; diff --git a/Qwilight/System/PoolSystem/PoolSystem.cs b/Qwilight/System/PoolSystem/PoolSystem.cs index a3fc6b9..1d3d4b2 100644 --- a/Qwilight/System/PoolSystem/PoolSystem.cs +++ b/Qwilight/System/PoolSystem/PoolSystem.cs @@ -1,4 +1,5 @@ using Microsoft.Graphics.Canvas; +using Microsoft.Graphics.Canvas.Brushes; using Microsoft.Graphics.Canvas.Text; using Microsoft.IO; using Qwilight.Utilities; @@ -6,8 +7,10 @@ using System.Globalization; using System.IO; using System.Windows; -using System.Windows.Media; using Windows.Graphics.DirectX; +using Windows.UI; +using Brush = System.Windows.Media.Brush; +using FormattedText = System.Windows.Media.FormattedText; namespace Qwilight { @@ -28,35 +31,40 @@ readonly ConcurrentDictionary _textItems = new(); readonly ConcurrentDictionary _defaultTextItems = new(); readonly ConcurrentDictionary _targetItems = new(); + readonly ConcurrentDictionary _faintPaints = new(); readonly ConcurrentDictionary, string> _valueIntTexts = new(); readonly ConcurrentDictionary, string> _valueFloat64Texts = new(); readonly ConcurrentDictionary _formattedTexts = new(); readonly ConcurrentDictionary _formattedUnitTexts = new(); readonly ConcurrentQueue _pendingClosables = new(); - public void Wipe(bool isWPFViewVisible) + public void Wipe() { - if (isWPFViewVisible) + foreach (var textID in _textItems.Keys) { - foreach (var (defaultTextID, defaultTextItem) in _defaultTextItems) + if (_textItems.TryRemove(textID, out var textItem)) { - _defaultTextItems.TryRemove(defaultTextID, out _); + _pendingClosables.Enqueue(textItem); } } - else + foreach (var (defaultTextID, defaultTextItem) in _defaultTextItems) { - foreach (var textID in _textItems.Keys) + _defaultTextItems.TryRemove(defaultTextID, out _); + } + foreach (var targetID in _targetItems.Keys) + { + if (_targetItems.TryRemove(targetID, out var targetItem)) { - if (_textItems.TryRemove(textID, out var textItem)) - { - _pendingClosables.Enqueue(textItem); - } + _pendingClosables.Enqueue(targetItem); } - foreach (var targetID in _targetItems.Keys) + } + foreach (var faintColor in _faintPaints.Keys) + { + if (_faintPaints.TryRemove(faintColor, out var faintPaints)) { - if (_targetItems.TryRemove(targetID, out var targetItem)) + foreach (var faintPaint in faintPaints) { - _pendingClosables.Enqueue(targetItem); + _pendingClosables.Enqueue(faintPaint); } } } @@ -68,6 +76,10 @@ { _valueFloat64Texts.TryRemove(valueTextID, out _); } + foreach (var (value, text) in _formattedTexts) + { + _formattedTexts.TryRemove(value, out _); + } foreach (var (value, text) in _formattedUnitTexts) { _formattedUnitTexts.TryRemove(value, out _); @@ -107,6 +119,16 @@ return _targetItems.GetOrAdd(targetID, targetID => new(CanvasDevice.GetSharedDevice(), targetID.targetLength, targetID.targetHeight, 96F, DirectXPixelFormat.B8G8R8A8UIntNormalized, CanvasAlphaMode.Ignore)); } + public ICanvasBrush[] GetFaintPaint(Color faintColor) + { + if (!_faintPaints.TryGetValue(faintColor, out var faintPaints)) + { + faintPaints = new ICanvasBrush[101]; + DrawingSystem.Instance.SetFaintPaints(null, faintPaints, faintColor); + } + return faintPaints; + } + public CanvasTextLayout GetTextItem(string text, CanvasTextFormat font, float textLength = 0F, float textHeight = 0F) { var textID = new TextID diff --git a/Qwilight/UIComponent/AvatarTitle.cs b/Qwilight/UIComponent/AvatarTitle.cs index d35d097..928bf1f 100644 --- a/Qwilight/UIComponent/AvatarTitle.cs +++ b/Qwilight/UIComponent/AvatarTitle.cs @@ -1,4 +1,6 @@ -using Windows.UI; +using Microsoft.Graphics.Canvas.Brushes; +using System.Collections.Concurrent; +using Windows.UI; using Brush = System.Windows.Media.Brush; namespace Qwilight.UIComponent @@ -11,13 +13,13 @@ public Brush TitlePaint { get; init; } - public Color TitleColor { get; init; } + public ICanvasBrush[] TitlePaints { get; init; } public AvatarTitle(string title, Brush titlePaint, Color titleColor) { Title = title; TitlePaint = titlePaint; - TitleColor = titleColor; + TitlePaints = PoolSystem.Instance.GetFaintPaint(titleColor); } } } diff --git a/Qwilight/ViewModel/MainViewModel.cs b/Qwilight/ViewModel/MainViewModel.cs index 28191df..f4d0c2f 100644 --- a/Qwilight/ViewModel/MainViewModel.cs +++ b/Qwilight/ViewModel/MainViewModel.cs @@ -236,7 +236,6 @@ { DrawingSystem.Instance.OnModified(); } - PoolSystem.Instance.Wipe(value); StrongReferenceMessenger.Default.Send(new SetD2DViewVisibility { IsVisible = !value