Skip to content

Commit

Permalink
add editorconfig and reformat all code
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyOThan committed Feb 22, 2025
1 parent b5c2a9f commit e244141
Show file tree
Hide file tree
Showing 115 changed files with 17,045 additions and 10,471 deletions.
123 changes: 123 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
[*.cs]
indent_style = tab
csharp_new_line_before_catch = true
csharp_new_line_before_else = true
csharp_new_line_before_open_brace = all

csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true

csharp_prefer_braces = true:warning
csharp_indent_labels = one_less_than_current
csharp_space_around_binary_operators = before_and_after
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_throw_expression = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
csharp_prefer_static_local_function = true:suggestion
csharp_prefer_static_anonymous_function = true:suggestion
csharp_style_prefer_readonly_struct = true:suggestion
csharp_style_prefer_readonly_struct_member = true:suggestion
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
csharp_style_conditional_delegate_call = true:suggestion
[*.{cs,vb}]
#### Naming styles ####

# Naming rules

dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
end_of_line = crlf
dotnet_style_coalesce_expression = false:suggestion
dotnet_style_null_propagation = false:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_readonly_field = true:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_predefined_type_for_member_access = true:silent
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
dotnet_style_allow_multiple_blank_lines_experimental = true:silent
dotnet_code_quality_unused_parameters = all:suggestion
2 changes: 1 addition & 1 deletion SCANmechjeb/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@

// ideally this should get generated from KSPBuildTools
// https://github.com/KSPModdingLibs/KSPBuildTools/issues/46
[assembly: KSPAssemblyDependency ("SCANsat", 21, 0)]
[assembly: KSPAssemblyDependency("SCANsat", 21, 0)]
2 changes: 2 additions & 0 deletions SCANmechjeb/SCANmechStarter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ private void Start()
SCANmechjebInt = gameObject.AddComponent<SCANmechjeb>();
}
else
{
Destroy(gameObject);
}
}
}
}
38 changes: 38 additions & 0 deletions SCANmechjeb/SCANmechjeb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,16 @@ private IEnumerator WaitForReady()
shutdown = true;

while (!FlightGlobals.ready || FlightGlobals.ActiveVessel == null)
{
yield return null;
}

vessel = FlightGlobals.ActiveVessel;

if (vessel == null)
{
yield break;
}

VesselChange(vessel);

Expand All @@ -65,9 +69,13 @@ private IEnumerator WaitForReady()
data = SCANUtil.getData(body);

if (data == null)
{
shutdown = true;
}
else
{
shutdown = false;
}
}

private void OnDestroy()
Expand All @@ -81,36 +89,54 @@ private void OnDestroy()
private void LateUpdate()
{
if (shutdown || !mjOnboard || mjTechTreeLocked || body == null || vessel == null || data == null)
{
return;
}

if (!HighLogic.LoadedSceneIsFlight || !FlightGlobals.ready)
{
return;
}

way = null;

if (!SCAN_Settings_Config.Instance.MechJebTarget)
{
return;
}

if (SCANcontroller.controller == null)
{
return;
}

if (!SCANcontroller.controller.MechJebLoaded)
{
SCANcontroller.controller.MechJebLoaded = true;
}

if (target.Target == null)
{
return;
}

if (target.targetBody != body)
{
return;
}

if ((target.Target is DirectionTarget))
{
return;
}

coords.x = target.targetLongitude;
coords.y = target.targetLatitude;

if (SCANcontroller.controller.LandingTarget != null)
{
way = SCANcontroller.controller.LandingTarget;
}

if (way != null)
{
Expand All @@ -132,31 +158,41 @@ private void LateUpdate()
private void OnTargetSet(Vector2d pos, CelestialBody b)
{
if (!mjOnboard || target == null)
{
return;
}

target.SetPositionTarget(b, pos.y, pos.x);
}

private void SOIChange(GameEvents.HostedFromToAction<Vessel, CelestialBody> action)
{
if (vessel == null)
{
return;
}

if (vessel != action.host)
{
return;
}

body = action.to;

data = SCANUtil.getData(body);

if (data == null)
{
shutdown = true;
}
}

private void VesselChange(Vessel v)
{
if (vessel != v)
{
return;
}

body = v.mainBody;

Expand Down Expand Up @@ -192,7 +228,9 @@ private void VesselChange(Vessel v)
if (HighLogic.CurrentGame.Mode != Game.Modes.SANDBOX)
{
if (guidanceModule == null)
{
guidanceModule = (DisplayModule)mjCore.GetComputerModule("MechJebModuleLandingGuidance");
}

if (guidanceModule == null)
{
Expand Down
12 changes: 12 additions & 0 deletions SCANmechjeb/SCANmechjebMainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,42 @@ private bool checkLoaded()
var SCANassembly = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.assembly.GetName().Name == SCANsatName);

if (SCANassembly == null)
{
return false;
}

var infoV = Attribute.GetCustomAttribute(SCANassembly.assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;

if (infoV == null)
{
return false;
}

var SCANmechjebAssembly = Assembly.GetExecutingAssembly();

if (SCANmechjebAssembly == null)
{
return false;
}

var SMinfoV = Attribute.GetCustomAttribute(SCANmechjebAssembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;

if (SMinfoV == null)
{
return false;
}

if (infoV.InformationalVersion != SMinfoV.InformationalVersion)
{
return false;
}

var MechJebAssembly = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.assembly.GetName().Name == MechJeb);

if (MechJebAssembly == null)
{
return false;
}

if (MechJebAssembly.assembly.GetName().Version == MechJebVersion)
{
Expand Down
10 changes: 10 additions & 0 deletions SCANsat.Unity/CanvasFader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,19 @@ protected virtual void Awake()
protected void Fade(float to, bool fast, Action call = null, bool interrupt = true, bool overrule = false)
{
if (canvas == null)
{
return;
}

Fade(canvas.alpha, to, fast ? FastRate : SlowRate, call, interrupt, overrule);
}

protected void Alpha(float to)
{
if (canvas == null)
{
return;
}

to = Mathf.Clamp01(to);
canvas.alpha = to;
Expand All @@ -55,10 +59,14 @@ protected void Alpha(float to)
private void Fade(float from, float to, float duration, Action call, bool interrupt, bool overrule)
{
if (!allowInterrupt && !overrule)
{
return;
}

if (fader != null)
{
StopCoroutine(fader);
}

fader = FadeRoutine(from, to, duration, call, interrupt);
StartCoroutine(fader);
Expand All @@ -80,7 +88,9 @@ private IEnumerator FadeRoutine(float from, float to, float duration, Action cal
}

if (call != null)
{
call.Invoke();
}

allowInterrupt = true;

Expand Down
2 changes: 1 addition & 1 deletion SCANsat.Unity/HSVPicker/Events/ColorChangedEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ namespace SCANsat.Unity.HSVPicker.Events
[Serializable]
public class ColorChangedEvent : UnityEvent<Color>
{

}
}
2 changes: 2 additions & 0 deletions SCANsat.Unity/HSVPicker/UI/ColorImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ private void OnDestroy()
private void ColorChanged(Color newColor)
{
if (_isActive)
{
image.color = newColor;
}
}

public void SetColor(Color newColor)
Expand Down
Loading

0 comments on commit e244141

Please sign in to comment.