Skip to content

Commit

Permalink
Merge pull request #17 from Ottermandias/SmallFixes
Browse files Browse the repository at this point in the history
Small fixes
  • Loading branch information
NotAdam authored Feb 16, 2021
2 parents 5a8051e + 801d9e2 commit 7d23505
Show file tree
Hide file tree
Showing 43 changed files with 2,667 additions and 2,153 deletions.
152 changes: 85 additions & 67 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,67 +1,85 @@

[*]
charset=utf-8
end_of_line=lf
trim_trailing_whitespace=false
insert_final_newline=false
indent_style=space
indent_size=4

# Microsoft .NET properties
csharp_new_line_before_members_in_object_initializers=false
csharp_preferred_modifier_order=public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion
csharp_space_after_cast=false
csharp_space_after_keywords_in_control_flow_statements=false
csharp_space_between_method_call_parameter_list_parentheses=true
csharp_space_between_method_declaration_parameter_list_parentheses=true
csharp_space_between_parentheses=control_flow_statements,expressions,type_casts
csharp_style_var_elsewhere=true:suggestion
csharp_style_var_for_built_in_types=true:suggestion
csharp_style_var_when_type_is_apparent=true:suggestion
dotnet_style_parentheses_in_arithmetic_binary_operators=never_if_unnecessary:none
dotnet_style_parentheses_in_other_binary_operators=never_if_unnecessary:none
dotnet_style_parentheses_in_relational_binary_operators=never_if_unnecessary:none
dotnet_style_predefined_type_for_locals_parameters_members=true:suggestion
dotnet_style_predefined_type_for_member_access=true:suggestion
dotnet_style_qualification_for_event=false:suggestion
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

# ReSharper properties
resharper_autodetect_indent_settings=true
resharper_csharp_space_within_array_access_brackets=true
resharper_enforce_line_ending_style=true
resharper_place_attribute_on_same_line=false
resharper_space_after_cast=false
resharper_space_within_checked_parentheses=true
resharper_space_within_default_parentheses=true
resharper_space_within_nameof_parentheses=true
resharper_space_within_single_line_array_initializer_braces=true
resharper_space_within_sizeof_parentheses=true
resharper_space_within_typeof_parentheses=true
resharper_space_within_type_argument_angles=true
resharper_space_within_type_parameter_angles=true
resharper_use_indent_from_vs=false
resharper_wrap_lines=true

# ReSharper inspection severities
resharper_arrange_redundant_parentheses_highlighting=hint
resharper_arrange_this_qualifier_highlighting=hint
resharper_arrange_type_member_modifiers_highlighting=hint
resharper_arrange_type_modifiers_highlighting=hint
resharper_built_in_type_reference_style_for_member_access_highlighting=hint
resharper_built_in_type_reference_style_highlighting=hint
resharper_redundant_base_qualifier_highlighting=warning
resharper_suggest_var_or_type_built_in_types_highlighting=hint
resharper_suggest_var_or_type_elsewhere_highlighting=hint
resharper_suggest_var_or_type_simple_types_highlighting=hint
resharper_web_config_module_not_resolved_highlighting=warning
resharper_web_config_type_not_resolved_highlighting=warning
resharper_web_config_wrong_module_highlighting=warning

[*.{appxmanifest,asax,ascx,aspx,build,cg,cginc,compute,cs,cshtml,dtd,hlsl,hlsli,hlslinc,master,nuspec,razor,resw,resx,shader,skin,usf,ush,vb,xaml,xamlx,xoml,xsd}]
indent_style=space
indent_size=4
tab_width=4

[*]
charset=utf-8
end_of_line=lf
trim_trailing_whitespace=true
insert_final_newline=false
indent_style=space
indent_size=4

# Microsoft .NET properties
csharp_new_line_before_members_in_object_initializers=false
csharp_preferred_modifier_order=public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion
csharp_prefer_braces=true:none
csharp_space_after_cast=false
csharp_space_after_keywords_in_control_flow_statements=false
csharp_space_between_method_call_parameter_list_parentheses=true
csharp_space_between_method_declaration_parameter_list_parentheses=true
csharp_space_between_parentheses=control_flow_statements,expressions,type_casts
csharp_style_var_elsewhere=true:suggestion
csharp_style_var_for_built_in_types=true:suggestion
csharp_style_var_when_type_is_apparent=true:suggestion
dotnet_style_parentheses_in_arithmetic_binary_operators=never_if_unnecessary:none
dotnet_style_parentheses_in_other_binary_operators=never_if_unnecessary:none
dotnet_style_parentheses_in_relational_binary_operators=never_if_unnecessary:none
dotnet_style_predefined_type_for_locals_parameters_members=true:suggestion
dotnet_style_predefined_type_for_member_access=true:suggestion
dotnet_style_qualification_for_event=false:suggestion
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

# ReSharper properties
resharper_align_multiline_binary_expressions_chain=false
resharper_align_multiline_calls_chain=false
resharper_autodetect_indent_settings=true
resharper_braces_redundant=true
resharper_constructor_or_destructor_body=expression_body
resharper_csharp_empty_block_style=together
resharper_csharp_max_line_length=144
resharper_csharp_space_within_array_access_brackets=true
resharper_enforce_line_ending_style=true
resharper_int_align_assignments=true
resharper_int_align_comments=true
resharper_int_align_fields=true
resharper_int_align_invocations=false
resharper_int_align_nested_ternary=true
resharper_int_align_properties=false
resharper_int_align_switch_expressions=true
resharper_int_align_switch_sections=true
resharper_int_align_variables=true
resharper_local_function_body=expression_body
resharper_method_or_operator_body=expression_body
resharper_place_attribute_on_same_line=false
resharper_space_after_cast=false
resharper_space_within_checked_parentheses=true
resharper_space_within_default_parentheses=true
resharper_space_within_nameof_parentheses=true
resharper_space_within_single_line_array_initializer_braces=true
resharper_space_within_sizeof_parentheses=true
resharper_space_within_typeof_parentheses=true
resharper_space_within_type_argument_angles=true
resharper_space_within_type_parameter_angles=true
resharper_use_indent_from_vs=false
resharper_wrap_lines=true

# ReSharper inspection severities
resharper_arrange_redundant_parentheses_highlighting=hint
resharper_arrange_this_qualifier_highlighting=hint
resharper_arrange_type_member_modifiers_highlighting=hint
resharper_arrange_type_modifiers_highlighting=hint
resharper_built_in_type_reference_style_for_member_access_highlighting=hint
resharper_built_in_type_reference_style_highlighting=hint
resharper_redundant_base_qualifier_highlighting=warning
resharper_suggest_var_or_type_built_in_types_highlighting=hint
resharper_suggest_var_or_type_elsewhere_highlighting=hint
resharper_suggest_var_or_type_simple_types_highlighting=hint
resharper_web_config_module_not_resolved_highlighting=warning
resharper_web_config_type_not_resolved_highlighting=warning
resharper_web_config_wrong_module_highlighting=warning

[*.{appxmanifest,asax,ascx,aspx,build,cg,cginc,compute,cs,cshtml,dtd,hlsl,hlsli,hlslinc,master,nuspec,razor,resw,resx,shader,skin,usf,ush,vb,xaml,xamlx,xoml,xsd}]
indent_style=space
indent_size=4
tab_width=4
7 changes: 2 additions & 5 deletions Penumbra/API/ModsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ public class ModsController : WebApiController
{
private readonly Plugin _plugin;

public ModsController( Plugin plugin )
{
_plugin = plugin;
}
public ModsController( Plugin plugin ) => _plugin = plugin;

[Route( HttpVerbs.Get, "/mods" )]
public object GetMods()
Expand All @@ -24,7 +21,7 @@ public object GetMods()
x.FolderName,
x.Mod.Meta,
BasePath = x.Mod.ModBasePath.FullName,
Files = x.Mod.ModFiles.Select( fi => fi.FullName )
Files = x.Mod.ModFiles.Select( fi => fi.FullName )
} );
}

Expand Down
6 changes: 3 additions & 3 deletions Penumbra/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Dalamud.Configuration;
using Dalamud.Plugin;
using System;
using System.Collections.Generic;
using Dalamud.Configuration;
using Dalamud.Plugin;

namespace Penumbra
{
Expand All @@ -13,7 +13,7 @@ public class Configuration : IPluginConfiguration
public bool IsEnabled { get; set; } = true;

public bool ShowAdvanced { get; set; }

public bool DisableFileSystemNotifications { get; set; }

public bool EnableHttpApi { get; set; }
Expand Down
23 changes: 10 additions & 13 deletions Penumbra/DialogExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static Task< DialogResult > ShowDialogAsync( this CommonDialog form )
public static Task< DialogResult > ShowDialogAsync( this CommonDialog form, IWin32Window owner )
{
var taskSource = new TaskCompletionSource< DialogResult >();
var th = new Thread( () => DialogThread( form, owner, taskSource ) );
var th = new Thread( () => DialogThread( form, owner, taskSource ) );
th.Start();
return taskSource.Task;
}
Expand All @@ -38,28 +38,25 @@ public class DialogHandle : IWin32Window
{
public IntPtr Handle { get; set; }

public DialogHandle( IntPtr handle )
{
Handle = handle;
}
public DialogHandle( IntPtr handle ) => Handle = handle;
}

public class HiddenForm : Form
{
private readonly CommonDialog _form;
private readonly IWin32Window _owner;
private readonly CommonDialog _form;
private readonly IWin32Window _owner;
private readonly TaskCompletionSource< DialogResult > _taskSource;

public HiddenForm( CommonDialog form, IWin32Window owner, TaskCompletionSource< DialogResult > taskSource )
{
this._form = form;
this._owner = owner;
this._taskSource = taskSource;
_form = form;
_owner = owner;
_taskSource = taskSource;

Opacity = 0;
Opacity = 0;
FormBorderStyle = FormBorderStyle.None;
ShowInTaskbar = false;
Size = new Size( 0, 0 );
ShowInTaskbar = false;
Size = new Size( 0, 0 );

Shown += HiddenForm_Shown;
}
Expand Down
3 changes: 2 additions & 1 deletion Penumbra/Extensions/FuckedExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public static class FuckedExtensions
/// <typeparam name="TField">The type of the underlying field</typeparam>
/// <returns>A delegate that will return a reference to a particular field - zero copy</returns>
/// <exception cref="MissingFieldException"></exception>
private static RefGet< TObject, TField > CreateRefGetter< TObject, TField >( string fieldName ) where TField : unmanaged
private static RefGet< TObject, TField > CreateRefGetter< TObject, TField >( string fieldName )
where TField : unmanaged
{
const BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;

Expand Down
8 changes: 4 additions & 4 deletions Penumbra/Game/GameUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public class GameUtils
public unsafe delegate void* UnloadPlayerResourcesPrototype( IntPtr pResourceManager );


public LoadPlayerResourcesPrototype LoadPlayerResources { get; private set; }
public UnloadPlayerResourcesPrototype UnloadPlayerResources { get; private set; }
public LoadPlayerResourcesPrototype LoadPlayerResources { get; }
public UnloadPlayerResourcesPrototype UnloadPlayerResources { get; }

// Object addresses
private IntPtr _playerResourceManagerAddress;
private readonly IntPtr _playerResourceManagerAddress;
public IntPtr PlayerResourceManagerPtr => Marshal.ReadIntPtr( _playerResourceManagerAddress );

public GameUtils( DalamudPluginInterface pluginInterface )
Expand All @@ -33,7 +33,7 @@ public GameUtils( DalamudPluginInterface pluginInterface )

_playerResourceManagerAddress = scanner.GetStaticAddressFromSig( "0F 44 FE 48 8B 0D ?? ?? ?? ?? 48 85 C9 74 05" );

LoadPlayerResources = Marshal.GetDelegateForFunctionPointer< LoadPlayerResourcesPrototype >( loadPlayerResourcesAddress );
LoadPlayerResources = Marshal.GetDelegateForFunctionPointer< LoadPlayerResourcesPrototype >( loadPlayerResourcesAddress );
UnloadPlayerResources = Marshal.GetDelegateForFunctionPointer< UnloadPlayerResourcesPrototype >( unloadPlayerResourcesAddress );
}

Expand Down
107 changes: 57 additions & 50 deletions Penumbra/Game/RefreshActors.cs
Original file line number Diff line number Diff line change
@@ -1,54 +1,61 @@
using System.Runtime.InteropServices;
using Dalamud.Game.ClientState.Actors;
using Dalamud.Game.ClientState.Actors.Types;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Dalamud.Game.ClientState.Actors;
using Dalamud.Game.ClientState.Actors.Types;

namespace Penumbra
namespace Penumbra.Game
{
public static class RefreshActors
{
private const int RenderModeOffset = 0x0104;
private const int RenderTaskPlayerDelay = 75;
private const int RenderTaskOtherDelay = 25;
private const int ModelInvisibilityFlag = 0b10;

private static async void Redraw(Actor actor)
{
var ptr = actor.Address;
var renderModePtr = ptr + RenderModeOffset;
var renderStatus = Marshal.ReadInt32(renderModePtr);

async void DrawObject(int delay)
{
Marshal.WriteInt32(renderModePtr, renderStatus | ModelInvisibilityFlag);
await Task.Delay(delay);
Marshal.WriteInt32(renderModePtr, renderStatus & ~ModelInvisibilityFlag);
}

if (actor.ObjectKind == Dalamud.Game.ClientState.Actors.ObjectKind.Player)
{
DrawObject(RenderTaskPlayerDelay);
await Task.Delay(RenderTaskPlayerDelay);
}
else
DrawObject(RenderTaskOtherDelay);

}

public static void RedrawSpecific(ActorTable actors, string name)
{
if (name?.Length == 0)
RedrawAll(actors);

foreach (var actor in actors)
if (actor.Name == name)
Redraw(actor);
}

public static void RedrawAll(ActorTable actors)
{
foreach (var actor in actors)
Redraw(actor);
}
public static class RefreshActors
{
private const int RenderModeOffset = 0x0104;
private const int RenderTaskPlayerDelay = 75;
private const int RenderTaskOtherDelay = 25;
private const int ModelInvisibilityFlag = 0b10;

private static async void Redraw( Actor actor )
{
var ptr = actor.Address;
var renderModePtr = ptr + RenderModeOffset;
var renderStatus = Marshal.ReadInt32( renderModePtr );

async void DrawObject( int delay )
{
Marshal.WriteInt32( renderModePtr, renderStatus | ModelInvisibilityFlag );
await Task.Delay( delay );
Marshal.WriteInt32( renderModePtr, renderStatus & ~ModelInvisibilityFlag );
}

if( actor.ObjectKind == ObjectKind.Player )
{
DrawObject( RenderTaskPlayerDelay );
await Task.Delay( RenderTaskPlayerDelay );
}
else
{
DrawObject( RenderTaskOtherDelay );
}
}

public static void RedrawSpecific( ActorTable actors, string name )
{
if( name?.Length == 0 )
{
RedrawAll( actors );
}

foreach( var actor in actors.Where( A => A.Name == name ) )
{
Redraw( actor );
}
}

public static void RedrawAll( ActorTable actors )
{
foreach( var actor in actors )
{
Redraw( actor );
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ public class MagicTempFileStreamManagerAndDeleterFuckery : SqPackStream, IDispos
{
private readonly FileStream _fileStream;

public MagicTempFileStreamManagerAndDeleterFuckery( FileStream stream ) : base( stream )
{
_fileStream = stream;
}
public MagicTempFileStreamManagerAndDeleterFuckery( FileStream stream ) : base( stream ) => _fileStream = stream;

public new void Dispose()
{
Expand Down
Loading

0 comments on commit 7d23505

Please sign in to comment.