StyleCop: everything else

This commit is contained in:
Raymond Lynch 2021-05-30 07:10:00 -04:00
parent f64c9b8321
commit 595fd3f1e4
134 changed files with 16346 additions and 6202 deletions

View file

@ -1,8 +1,8 @@
using Lumina.Excel.GeneratedSheets;
using System;
using System.Collections.Generic;
using System.IO;
using Dalamud.Data;
using Lumina.Excel.GeneratedSheets;
using Newtonsoft.Json;
namespace Dalamud.Game.Text.SeStringHandling.Payloads
@ -12,83 +12,86 @@ namespace Dalamud.Game.Text.SeStringHandling.Payloads
/// </summary>
public class UIForegroundPayload : Payload
{
/// <summary>
/// Payload representing disabling foreground color on following text.
/// </summary>
// TODO Make this work with DI
public static UIForegroundPayload UIForegroundOff => new UIForegroundPayload(null, 0);
public override PayloadType Type => PayloadType.UIForeground;
/// <summary>
/// Whether or not this payload represents applying a foreground color, or disabling one.
/// </summary>
public bool IsEnabled => ColorKey != 0;
private UIColor color;
/// <summary>
/// A Lumina UIColor object representing this payload. The actual color data is at UIColor.UIForeground
/// </summary>
/// <remarks>
/// Value is evaluated lazily and cached.
/// </remarks>
[JsonIgnore]
public UIColor UIColor
{
get
{
this.color ??= this.DataResolver.GetExcelSheet<UIColor>().GetRow(this.colorKey);
return this.color;
}
}
/// <summary>
/// The color key used as a lookup in the UIColor table for this foreground color.
/// </summary>
[JsonIgnore]
public ushort ColorKey
{
get { return this.colorKey; }
set
{
this.colorKey = value;
this.color = null;
Dirty = true;
}
}
/// <summary>
/// The Red/Green/Blue values for this foreground color, encoded as a typical hex color.
/// </summary>
[JsonIgnore]
public uint RGB
{
get
{
return (UIColor.UIForeground & 0xFFFFFF);
}
}
[JsonProperty]
private ushort colorKey;
internal UIForegroundPayload() { }
/// <summary>
/// Initializes a new instance of the <see cref="UIForegroundPayload"/> class.
/// Creates a new UIForegroundPayload for the given UIColor key.
/// </summary>
/// <param name="data">DataManager instance needed to resolve game data.</param>
/// <param name="colorKey"></param>
public UIForegroundPayload(DataManager data, ushort colorKey) {
/// <param name="colorKey">A UIColor key.</param>
public UIForegroundPayload(DataManager data, ushort colorKey)
{
this.DataResolver = data;
this.colorKey = colorKey;
}
public override string ToString()
/// <summary>
/// Initializes a new instance of the <see cref="UIForegroundPayload"/> class.
/// Creates a new UIForegroundPayload for the given UIColor key.
/// </summary>
internal UIForegroundPayload()
{
return $"{Type} - UIColor: {colorKey} color: {(IsEnabled ? RGB : 0)}";
}
/// <summary>
/// Gets a payload representing disabling foreground color on following text.
/// </summary>
// TODO Make this work with DI
public static UIForegroundPayload UIForegroundOff => new(null, 0);
/// <inheritdoc/>
public override PayloadType Type => PayloadType.UIForeground;
/// <summary>
/// Gets a value indicating whether or not this payload represents applying a foreground color, or disabling one.
/// </summary>
public bool IsEnabled => this.ColorKey != 0;
/// <summary>
/// Gets a Lumina UIColor object representing this payload. The actual color data is at UIColor.UIForeground.
/// </summary>
/// <remarks>
/// The value is evaluated lazily and cached.
/// </remarks>
[JsonIgnore]
public UIColor UIColor => this.color ??= this.DataResolver.GetExcelSheet<UIColor>().GetRow(this.colorKey);
/// <summary>
/// Gets or sets the color key used as a lookup in the UIColor table for this foreground color.
/// </summary>
[JsonIgnore]
public ushort ColorKey
{
get
{
return this.colorKey;
}
set
{
this.colorKey = value;
this.color = null;
this.Dirty = true;
}
}
/// <summary>
/// Gets the Red/Green/Blue values for this foreground color, encoded as a typical hex color.
/// </summary>
[JsonIgnore]
public uint RGB => this.UIColor.UIForeground & 0xFFFFFF;
/// <inheritdoc/>
public override string ToString()
{
return $"{this.Type} - UIColor: {this.colorKey} color: {(this.IsEnabled ? this.RGB : 0)}";
}
/// <inheritdoc/>
protected override byte[] EncodeImpl()
{
var colorBytes = MakeInteger(this.colorKey);
@ -96,7 +99,7 @@ namespace Dalamud.Game.Text.SeStringHandling.Payloads
var bytes = new List<byte>(new byte[]
{
START_BYTE, (byte)SeStringChunkType.UIForeground, (byte)chunkLen
START_BYTE, (byte)SeStringChunkType.UIForeground, (byte)chunkLen,
});
bytes.AddRange(colorBytes);
@ -105,6 +108,7 @@ namespace Dalamud.Game.Text.SeStringHandling.Payloads
return bytes.ToArray();
}
/// <inheritdoc/>
protected override void DecodeImpl(BinaryReader reader, long endOfStream)
{
this.colorKey = (ushort)GetInteger(reader);