Skip to content

Commit

Permalink
fix c# 12 stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
0ceal0t committed Feb 24, 2024
1 parent 8fb59a6 commit e59c22a
Show file tree
Hide file tree
Showing 243 changed files with 668 additions and 665 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dotnet_style_qualification_for_field=false:suggestion
dotnet_style_qualification_for_method=false:suggestion
dotnet_style_qualification_for_property=false:suggestion
dotnet_style_require_accessibility_modifiers=for_non_interface_members:suggestion
csharp_style_prefer_primary_constructors=false

# ReSharper properties
resharper_autodetect_indent_settings=true
Expand Down
2 changes: 1 addition & 1 deletion VFXEditor/Data/Command/CommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static void Paste( ICommand command ) {

private readonly FileManagerFile File;

private readonly List<ICommand> PasteCommands = [];
private readonly List<ICommand> PasteCommands = new();

public CommandManager( FileManagerFile file ) {
File = file;
Expand Down
2 changes: 1 addition & 1 deletion VFXEditor/Data/Command/CompoundCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace VfxEditor {
public class CompoundCommand : ICommand {
private readonly Action OnChangeAction;
private readonly List<ICommand> Commands = [];
private readonly List<ICommand> Commands = new();

public CompoundCommand( IEnumerable<ICommand> commands, Action onChangeAction = null ) {
Commands.AddRange( commands );
Expand Down
32 changes: 16 additions & 16 deletions VFXEditor/Data/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
namespace VfxEditor {
[Serializable]
public unsafe class ManagerConfiguration {
public List<SelectResult> RecentItems = [];
public List<SelectResult> Favorites = [];
public List<SelectResult> RecentItems = new();
public List<SelectResult> Favorites = new();
public bool UseCustomWindowColor = false;
public Vector4 TitleBg = *ImGui.GetStyleColorVec4( ImGuiCol.TitleBg );
public Vector4 TitleBgActive = *ImGui.GetStyleColorVec4( ImGuiCol.TitleBgActive );
Expand Down Expand Up @@ -59,24 +59,24 @@ public class Configuration : DalamudWindow, IPluginConfiguration {
"VFXEditor",
} );

public List<(string, string)> RecentWorkspaces = [];
public List<(string, string)> RecentWorkspaces = new();

public bool VfxSpawnLoop = false;
public float VfxSpawnDelay = 0.1f;
public bool VfxSpawnSplit = false;

// ===== [ OBSOLETE ] =======
public List<SelectResult> RecentSelects = [];
public List<SelectResult> RecentSelectsTMB = [];
public List<SelectResult> RecentSelectsPAP = [];
public List<SelectResult> RecentSelectsScd = [];
public List<SelectResult> FavoriteVfx = [];
public List<SelectResult> FavoriteTmb = [];
public List<SelectResult> FavoritePap = [];
public List<SelectResult> FavoriteScd = [];
public List<SelectResult> RecentSelects = new();
public List<SelectResult> RecentSelectsTMB = new();
public List<SelectResult> RecentSelectsPAP = new();
public List<SelectResult> RecentSelectsScd = new();
public List<SelectResult> FavoriteVfx = new();
public List<SelectResult> FavoriteTmb = new();
public List<SelectResult> FavoritePap = new();
public List<SelectResult> FavoriteScd = new();
// ===========================

public Dictionary<string, ManagerConfiguration> ManagerConfigs = [];
public Dictionary<string, ManagerConfiguration> ManagerConfigs = new();

public KeybindConfiguration SaveKeybind = new();
public KeybindConfiguration SaveAsKeybind = new();
Expand All @@ -90,8 +90,8 @@ public class Configuration : DalamudWindow, IPluginConfiguration {
public KeybindConfiguration SpawnOnGroundKeybind = new();
public KeybindConfiguration SpawnOnTargetKeybind = new();

public List<LibraryProps> VFXNodeLibraryItems = [];
public List<LibraryProps> VfxTextureLibraryItems = [];
public List<LibraryProps> VFXNodeLibraryItems = new();
public List<LibraryProps> VfxTextureLibraryItems = new();
public bool VfxTextureDefaultLoaded = false;

public bool LoopMusic = true;
Expand All @@ -103,7 +103,7 @@ public class Configuration : DalamudWindow, IPluginConfiguration {
public Vector4 CurveEditorPointColor = new( 1 );
public Vector4 CurveEditorSelectedColor = new( 1.000f, 0.884f, 0.561f, 1f );
public Vector4 CurveEditorPrimarySelectedColor = new( 0.984f, 0.726f, 0.011f, 1.0f );
public List<Vector4> CurveEditorPalette = [];
public List<Vector4> CurveEditorPalette = new();
public int CurveEditorLineWidth = 2;
public int CurveEditorColorRingSize = 3;
public int CurveEditorGrabbingDistance = 25;
Expand Down Expand Up @@ -148,7 +148,7 @@ public class Configuration : DalamudWindow, IPluginConfiguration {
public Vector4 LuaLiteralColor = new( 0.639f, 0.207f, 0.933f, 1f );
public Vector4 LuaVariableColor = new( 0.125f, 0.67058f, 0.45098f, 1f );

public List<ExcludedBonesConfiguration> ExcludedBones = [];
public List<ExcludedBonesConfiguration> ExcludedBones = new();

public int PngMips = 9;
public TextureFormat PngFormat = TextureFormat.DXT5;
Expand Down
4 changes: 2 additions & 2 deletions VFXEditor/Data/Copy/CopyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public static bool TryGetAssigned<R>( R item, string name, out bool value ) {
protected bool Copying = false;
protected bool Pasting = false;

protected readonly Dictionary<(Type, string), bool> AvfxAssigned = [];
protected readonly Dictionary<(Type, string), object> Data = [];
protected readonly Dictionary<(Type, string), bool> AvfxAssigned = new();
protected readonly Dictionary<(Type, string), object> Data = new();

public CopyManager() { }

Expand Down
2 changes: 1 addition & 1 deletion VFXEditor/Data/KeybindConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public enum KeybindModifierKeys {
[NonSerialized]
private static readonly KeybindModifierKeys[] ValidKeybindModifiers = ( KeybindModifierKeys[] )Enum.GetValues( typeof( KeybindModifierKeys ) );
[NonSerialized]
private static readonly Dictionary<VirtualKey, bool> LastState = [];
private static readonly Dictionary<VirtualKey, bool> LastState = new();

public KeybindModifierKeys Modifier = KeybindModifierKeys.Ctrl;
public VirtualKey Key = VirtualKey.NONCONVERT;
Expand Down
6 changes: 3 additions & 3 deletions VFXEditor/Data/SheetData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static class SheetData {
// ==== UI COLORS =====

private static bool UiColorsInitialized = false;
public static readonly Dictionary<uint, Vector4> UiColors = [];
public static readonly Dictionary<uint, Vector4> UiColors = new();

public static void InitUiColors() {
if( UiColorsInitialized ) return;
Expand All @@ -23,7 +23,7 @@ public static void InitUiColors() {
// ==== WEAPON TIMELINES ====

private static bool WeaponTimelinesInitialized = false;
public static readonly Dictionary<ushort, string> WeaponTimelines = [];
public static readonly Dictionary<ushort, string> WeaponTimelines = new();

public static void InitWeaponTimelines() {
if( WeaponTimelinesInitialized ) return;
Expand All @@ -37,7 +37,7 @@ public static void InitWeaponTimelines() {
// ==== MOTION TIMELINES ====

private static bool MotionTimelinesInitialized = false;
public static readonly Dictionary<string, MotionTimelineData> MotionTimelines = [];
public static readonly Dictionary<string, MotionTimelineData> MotionTimelines = new();

public struct MotionTimelineData {
public int Group;
Expand Down
2 changes: 1 addition & 1 deletion VFXEditor/DirectX/Bone/BoneNamePreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void LoadEmpty( int renderId, FileManagerFile file ) {
CurrentRenderId = renderId;
IsSklb = file is SklbFile;
NumWireframe = 0;
BoneList = [];
BoneList = new();
WireframeVertices?.Dispose();
Model.ClearVertexes();
UpdateDraw();
Expand Down
6 changes: 3 additions & 3 deletions VFXEditor/DirectX/DirectXManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class DirectXManager {
public readonly MaterialPreview MaterialPreview;
public readonly MeshPreview MeshPreview;

private readonly List<ModelRenderer> Renderers = [];
private readonly List<ModelRenderer> Renderers = new();

public static Include IncludeHandler { get; private set; }

Expand All @@ -39,15 +39,15 @@ public DirectXManager() {
MaterialPreview = new( Device, Ctx, shaderPath );
MeshPreview = new( Device, Ctx, shaderPath );

Renderers = [
Renderers = new() {
ModelPreview,
PapPreview,
PhybPreview,
SklbPreview,
EidPreview,
MaterialPreview,
MeshPreview,
];
};
}

public void RedrawMaterials() {
Expand Down
8 changes: 4 additions & 4 deletions VFXEditor/DirectX/Drawable/D3dDrawable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class D3dDrawable {
public Buffer Instances { get; protected set; }
public Buffer Data { get; protected set; }

private readonly Dictionary<PassType, D3dPass> Passes = [];
private readonly Dictionary<PassType, D3dPass> Passes = new();
private readonly InputElement[] Layout;

public bool DoDraw => !ShaderError && Count > 0 && ( !UseInstances || InstanceCount > 0 );
Expand Down Expand Up @@ -82,7 +82,7 @@ public void SetupPass( DeviceContext ctx, PassType type ) {
if( pass == null ) return;
pass.Setup( ctx );
}
public void SetConstantBuffers( DeviceContext ctx, Buffer vertex, Buffer pixel ) => SetConstantBuffers( ctx, [vertex], [pixel] );
public void SetConstantBuffers( DeviceContext ctx, Buffer vertex, Buffer pixel ) => SetConstantBuffers( ctx, new List<Buffer>() { vertex }, new List<Buffer>() { pixel } );

public virtual void SetConstantBuffers( DeviceContext ctx, List<Buffer> vertex, List<Buffer> pixel ) {
if( !DoDraw ) return;
Expand All @@ -95,9 +95,9 @@ public virtual void SetConstantBuffers( DeviceContext ctx, List<Buffer> vertex,
}
}

public void Draw( DeviceContext ctx, PassType type ) => Draw( ctx, type, [], [] );
public void Draw( DeviceContext ctx, PassType type ) => Draw( ctx, type, new List<Buffer>(), new List<Buffer>() );

public void Draw( DeviceContext ctx, PassType type, Buffer vertex, Buffer pixel ) => Draw( ctx, type, [vertex], [pixel] );
public void Draw( DeviceContext ctx, PassType type, Buffer vertex, Buffer pixel ) => Draw( ctx, type, new List<Buffer>() { vertex }, new List<Buffer>() { pixel } );

public void Draw( DeviceContext ctx, PassType type, List<Buffer> vertex, List<Buffer> pixel ) {
if( !DoDraw ) return;
Expand Down
2 changes: 1 addition & 1 deletion VFXEditor/DirectX/HLSLFileIncludeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class HLSLFileIncludeHandler : CallbackBase, Include {


public HLSLFileIncludeHandler( string initialDirectory ) {
IncludeDirectories = [];
IncludeDirectories = new();
CurrentDirectory = new Stack<string>();
CurrentDirectory.Push( initialDirectory );
}
Expand Down
13 changes: 7 additions & 6 deletions VFXEditor/DirectX/Material/MaterialPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using SharpDX;
using SharpDX.Direct3D11;
using SharpDX.DXGI;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using VfxEditor.DirectX.Drawable;
Expand Down Expand Up @@ -79,13 +80,13 @@ public MaterialPreview( Device device, DeviceContext ctx, string shaderPath ) :
VSBufferData = new() { };

Model = new( 5, false,
[
new InputElement[] {
new( "POSITION", 0, Format.R32G32B32A32_Float, 0, 0 ),
new( "TANGENT", 0, Format.R32G32B32A32_Float, 16, 0 ),
new( "BITANGENT", 0, Format.R32G32B32A32_Float, 32, 0 ),
new( "UV", 0, Format.R32G32B32A32_Float, 48, 0 ),
new( "NORMAL", 0, Format.R32G32B32A32_Float, 64, 0 )
] );
} );
Model.AddPass( Device, PassType.GBuffer, Path.Combine( shaderPath, "MaterialGBuffer.fx" ), ShaderPassFlags.Pixel );

var builder = new MeshBuilder( true, true, true );
Expand Down Expand Up @@ -156,15 +157,15 @@ protected override void GBufferPass() {

Model.Draw(
Ctx, PassType.GBuffer,
[VertexShaderBuffer, MaterialVertexShaderBuffer],
[PixelShaderBuffer, MaterialPixelShaderBuffer] );
new List<Buffer>() { VertexShaderBuffer, MaterialVertexShaderBuffer },
new List<Buffer>() { PixelShaderBuffer, MaterialPixelShaderBuffer } );
}

protected override void QuadPass() {
Quad.Draw(
Ctx, PassType.Final,
[VertexShaderBuffer, MaterialVertexShaderBuffer],
[PixelShaderBuffer, MaterialPixelShaderBuffer] );
new List<Buffer>() { VertexShaderBuffer, MaterialVertexShaderBuffer },
new List<Buffer>() { PixelShaderBuffer, MaterialPixelShaderBuffer } );
}

private ShaderResourceView GetTexture( byte[] data, int height, int width, out Texture2D texture ) {
Expand Down
14 changes: 7 additions & 7 deletions VFXEditor/DirectX/Mesh/MeshPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace VfxEditor.DirectX.Mesh {
public class MeshPreview : ModelDeferredRenderer {
private readonly D3dDrawable Model;

private readonly HashSet<Buffer> ToCleanUp = [];
private readonly HashSet<Buffer> ToCleanUp = new();

protected Buffer MaterialPixelShaderBuffer;
protected PSMaterialBuffer PSBufferData;
Expand All @@ -27,13 +27,13 @@ public MeshPreview( Device device, DeviceContext ctx, string shaderPath ) : base
VSBufferData = new() { };

Model = new( 5, false,
[
new InputElement[] {
new( "POSITION", 0, Format.R32G32B32A32_Float, 0, 0 ),
new( "TANGENT", 0, Format.R32G32B32A32_Float, 16, 0 ),
new( "UV", 0, Format.R32G32B32A32_Float, 32, 0 ),
new( "NORMAL", 0, Format.R32G32B32A32_Float, 48, 0 ),
new( "COLOR", 0, Format.R32G32B32A32_Float, 64, 0 )
] );
} );
Model.AddPass( Device, PassType.GBuffer, Path.Combine( shaderPath, "MeshGBuffer.fx" ), ShaderPassFlags.Pixel );

// ===== QUAD =========
Expand Down Expand Up @@ -77,15 +77,15 @@ protected override void OnDrawUpdate() {
protected override void GBufferPass() {
Model.Draw(
Ctx, PassType.GBuffer,
[VertexShaderBuffer, MaterialVertexShaderBuffer],
[PixelShaderBuffer, MaterialPixelShaderBuffer] );
new List<Buffer>() { VertexShaderBuffer, MaterialVertexShaderBuffer },
new List<Buffer>() { PixelShaderBuffer, MaterialPixelShaderBuffer } );
}

protected override void QuadPass() {
Quad.Draw(
Ctx, PassType.Final,
[VertexShaderBuffer, MaterialVertexShaderBuffer],
[PixelShaderBuffer, MaterialPixelShaderBuffer] );
new List<Buffer>() { VertexShaderBuffer, MaterialVertexShaderBuffer },
new List<Buffer>() { PixelShaderBuffer, MaterialPixelShaderBuffer } );
}

public override void Dispose() {
Expand Down
12 changes: 6 additions & 6 deletions VFXEditor/DirectX/Model/ModelPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ public enum RenderMode {

public ModelPreview( Device device, DeviceContext ctx, string shaderPath ) : base( device, ctx, shaderPath ) {
Model = new( 3, false,
[
new InputElement[] {
new( "POSITION", 0, Format.R32G32B32A32_Float, 0, 0 ),
new( "COLOR", 0, Format.R32G32B32A32_Float, 16, 0 ),
new( "NORMAL", 0, Format.R32G32B32A32_Float, 32, 0 )
] );
} );
Model.AddPass( device, PassType.Final, Path.Combine( shaderPath, "Model.fx" ), ShaderPassFlags.Pixel | ShaderPassFlags.Geometry );

Emitters = new( 2, true,
[
new InputElement[] {
new( "POSITION", 0, Format.R32G32B32A32_Float, 0, 0, InputClassification.PerVertexData, 0 ),
new( "NORMAL", 0, Format.R32G32B32A32_Float, 16, 0, InputClassification.PerVertexData, 0 ),
new( "INSTANCE", 0, Format.R32G32B32A32_Float, 0, 1, InputClassification.PerInstanceData, 1 ),
new( "INSTANCE", 1, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1 ),
new( "INSTANCE", 2, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1 ),
new( "INSTANCE", 3, Format.R32G32B32A32_Float, InputElement.AppendAligned, 1, InputClassification.PerInstanceData, 1 )
] );
} );
Emitters.AddPass( device, PassType.Final, Path.Combine( shaderPath, "Emitter.fx" ), ShaderPassFlags.Pixel );

var builder = new MeshBuilder( true, false );
Expand Down Expand Up @@ -79,7 +79,7 @@ public void LoadModel( List<AvfxIndex> modelIndexes, List<AvfxVertex> modelVerte
}
}

Model.SetVertexes( Device, [.. data], modelIndexes.Count * 3 );
Model.SetVertexes( Device, data.ToArray(), modelIndexes.Count * 3 );
}

// ========= EMITTERS =====
Expand All @@ -97,7 +97,7 @@ public void LoadModel( List<AvfxIndex> modelIndexes, List<AvfxVertex> modelVerte
data.Add( Matrix.AffineTransformation( 1f, rot, pos ) );
}

Emitters.SetInstances( Device, [.. data], modelEmitters.Count );
Emitters.SetInstances( Device, data.ToArray(), modelEmitters.Count );
}

UpdateDraw();
Expand Down
2 changes: 1 addition & 1 deletion VFXEditor/DirectX/Renderers/ModelDeferredRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public abstract class ModelDeferredRenderer : ModelRenderer {
protected readonly DeferredTexture Color = new();
protected readonly DeferredTexture UV = new();

protected List<DeferredTexture> DeferredTextures = [];
protected List<DeferredTexture> DeferredTextures = new();

protected ModelDeferredRenderer( Device device, DeviceContext ctx, string shaderPath ) : base( device, ctx, shaderPath ) {
// https://github.com/justinstenning/Direct3D-Rendering-Cookbook/blob/672312ae7545c388387a8fec92d8db41cc326804/Ch10_01DeferredRendering/ScreenAlignedQuadRenderer.cs#L20
Expand Down
6 changes: 3 additions & 3 deletions VFXEditor/FileBrowser/FileBrowserDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public partial class FileBrowserDialog {
private string FileNameInput = "";

private FileBrowserFile Selected;
private readonly List<FileBrowserFile> Files = [];
private readonly List<FileBrowserFile> SearchedFiles = [];
private readonly List<FileBrowserFile> Files = new();
private readonly List<FileBrowserFile> SearchedFiles = new();
private SortingField CurrentSortingField = SortingField.FileName;
private readonly bool[] SortDescending = new bool[] { false, false, false, false };

Expand All @@ -56,7 +56,7 @@ public partial class FileBrowserDialog {
private string CurrentPath;
private readonly UndoRedoStack<(string, string)> PathHistory = new( 25 );

private readonly List<string> PathParts = [];
private readonly List<string> PathParts = new();
private bool JustDrive => PathParts.Count == 1;
private bool PathEditing = false;
private string PathInput = "";
Expand Down
2 changes: 1 addition & 1 deletion VFXEditor/FileBrowser/FileBrowserManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static class FileBrowserManager {
private static FileBrowserDialog Dialog;
private static string SavedPath = ".";
private static Action<bool, string> Callback;
private static readonly List<FileBrowserSidebarItem> Recent = [];
private static readonly List<FileBrowserSidebarItem> Recent = new();

public static void Dispose() {
Reset();
Expand Down
Loading

0 comments on commit e59c22a

Please sign in to comment.