Skip to content

Commit

Permalink
.editorconfig aligned and code format applied to all the code
Browse files Browse the repository at this point in the history
  • Loading branch information
kaczy93 committed Nov 9, 2023
1 parent 95dcd68 commit 2e7b9d4
Show file tree
Hide file tree
Showing 107 changed files with 4,265 additions and 2,887 deletions.
19 changes: 11 additions & 8 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ tab_width = 2

# Microsoft .NET properties
csharp_preferred_modifier_order = public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion
csharp_style_var_elsewhere = false:none
csharp_style_var_for_built_in_types = false:none
csharp_style_var_when_type_is_apparent = false:none
csharp_style_var_elsewhere = true
csharp_style_var_for_built_in_types = true
csharp_style_var_when_type_is_apparent = true
dotnet_naming_rule.constants_rule.severity = warning
dotnet_naming_rule.constants_rule.style = all_upper_style
dotnet_naming_rule.constants_rule.symbols = constants_symbols
Expand Down Expand Up @@ -66,23 +66,26 @@ resharper_align_multiline_for_stmt = true
resharper_align_multline_type_parameter_constrains = true
resharper_align_multline_type_parameter_list = true
resharper_align_tuple_components = true
resharper_blank_lines_after_multiline_statements = 1
resharper_blank_lines_around_multiline_case_section = 1
resharper_blank_lines_after_block_statements = 0
resharper_blank_lines_after_control_transfer_statements = 0
resharper_blank_lines_after_multiline_statements = 0
resharper_blank_lines_around_multiline_case_section = 0
resharper_blank_lines_around_single_line_type = 0
resharper_blank_lines_before_control_transfer_statements = 1
resharper_blank_lines_before_multiline_statements = 1
resharper_blank_lines_before_control_transfer_statements = 0
resharper_blank_lines_before_multiline_statements = 0
resharper_braces_for_for = required
resharper_braces_for_foreach = required
resharper_braces_for_ifelse = required
resharper_braces_for_while = required
resharper_csharp_align_multiline_parameter = true
resharper_csharp_align_multiple_declaration = true
resharper_csharp_blank_lines_around_field = 0
resharper_csharp_max_line_length = 180
resharper_csharp_max_line_length = 120
resharper_csharp_naming_rule.enum_member = AA_BB
resharper_csharp_stick_comment = false
resharper_csharp_wrap_after_declaration_lpar = true
resharper_csharp_wrap_after_invocation_lpar = true
resharper_csharp_wrap_arguments_style = chop_if_long
resharper_csharp_wrap_before_declaration_lpar = true
resharper_csharp_wrap_before_invocation_lpar = true
resharper_csharp_wrap_before_ternary_opsigns = false
Expand Down
17 changes: 10 additions & 7 deletions CentrED/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
using CentrED.Client;
using CentrED.Server;

namespace CentrED;
namespace CentrED;

public class Application {
public class Application
{
static private AssemblyLoadContext _loadContext;
static private string? _rootDir;

Expand Down Expand Up @@ -87,7 +87,7 @@ static private IntPtr ResolveUnmanagedDll(Assembly assembly, string unmanagedDll
public static CentrEDGame CEDGame { get; private set; } = null!;
public static CEDServer? CEDServer;
public static readonly CentrEDClient CEDClient = new();

[STAThread]
public static void Main(string[] args)
{
Expand All @@ -100,11 +100,14 @@ public static void Main(string[] args)
_loadContext.ResolvingUnmanagedDll += ResolveUnmanagedDll;
_loadContext.Resolving += ResolveAssembly;

using (CEDGame = new CentrEDGame()) {
try {
using (CEDGame = new CentrEDGame())
{
try
{
CEDGame.Run();
}
catch (Exception e) {
catch (Exception e)
{
Console.WriteLine(e.ToString());
File.WriteAllText("Crash.log", e.ToString());
}
Expand Down
16 changes: 7 additions & 9 deletions CentrED/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@ public class Camera
private Vector3 _up = new(-1, -1, 0);

/* This takes the coordinates (x, y, z) and turns it into the screen point (x, y + z, z) */
private Matrix _oblique = new Matrix(
1, 0, 0, 0,
0, 1, 0, 0,
0, 1, 1, 0,
0, 0, 0, 1);
private Matrix _oblique = new Matrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1);

private Matrix _translation = Matrix.CreateTranslation(new Vector3(0, 128 * 4, 0));

public Vector3 Position = new(0, 0, 128 * 4);

//Look directly below camera
public Vector3 LookAt => new(Position.X, Position.Y, 0);

Expand All @@ -38,13 +34,15 @@ public class Camera

public bool Moved;

public void Move(float xDelta, float yDelta) {
public void Move(float xDelta, float yDelta)
{
Position.X += xDelta;
Position.Y += yDelta;
Moved = true;
}

public void ZoomIn(float delta) {
public void ZoomIn(float delta)
{
Zoom += delta;
Moved = true;
}
Expand All @@ -61,7 +59,7 @@ public void Update()
Matrix ortho = Matrix.CreateOrthographic(ScreenSize.Width, ScreenSize.Height, 0, 128 * 8);

Matrix scale = Matrix.CreateScale(Zoom, Zoom, 1f);

proj = _mirrorX * _oblique * _translation * ortho * scale;

Matrix.Multiply(ref world, ref view, out var worldView);
Expand Down
122 changes: 61 additions & 61 deletions CentrED/CentrED.csproj
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<Platforms>x64</Platforms>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<Platforms>x64</Platforms>

<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>

<EnableSingleFileAnalysis>true</EnableSingleFileAnalysis>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<EnableSingleFileAnalysis>true</EnableSingleFileAnalysis>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>

<OutDir>../output</OutDir>
<PublishDir>../publish</PublishDir>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<OutDir>../output</OutDir>
<PublishDir>../publish</PublishDir>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Client\Client.csproj" />
<ProjectReference Include="..\Server\Server.csproj" />
<ProjectReference Include="..\Shared\Shared.csproj" />
<ProjectReference Include="..\external\FNA\FNA.Core.csproj" />
<ProjectReference Include="..\external\ImGui.NET\src\ImGui.NET\ImGui.NET.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Client\Client.csproj"/>
<ProjectReference Include="..\Server\Server.csproj"/>
<ProjectReference Include="..\Shared\Shared.csproj"/>
<ProjectReference Include="..\external\FNA\FNA.Core.csproj"/>
<ProjectReference Include="..\external\ImGui.NET\src\ImGui.NET\ImGui.NET.csproj"/>
</ItemGroup>

<ItemGroup>
<Content Include="..\external\ImGui.NET\deps\cimgui\win-x64\cimgui.dll" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Renderer\Effects\Shaders\*.fxc" />
</ItemGroup>

<ItemGroup>
<DataFiles_libs Include="..\external\fna-libs\**" />
<DataFiles_libs Include="..\lib\**" />
<DataFiles_libs Remove="..\external\fna-libs\.github\**" />
<DataFiles_libs Remove="..\external\fna-libs\.git" />
<DataFiles_libs Remove="..\external\fna-libs\README.txt" />
</ItemGroup>

<ItemGroup>
<Reference Include="ClassicUO.Assets">
<HintPath>..\lib\x64\ClassicUO.Assets.dll</HintPath>
</Reference>
<Reference Include="ClassicUO.IO">
<HintPath>..\lib\x64\ClassicUO.IO.dll</HintPath>
</Reference>
<Reference Include="ClassicUO.Utility">
<HintPath>..\lib\x64\ClassicUO.Utility.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
<None Update="background.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="..\external\ImGui.NET\deps\cimgui\win-x64\cimgui.dll" CopyToOutputDirectory="PreserveNewest"/>
</ItemGroup>

<Target Name="CopyExternalDeps_build" AfterTargets="Build">
<Copy SourceFiles="@(DataFiles_libs)" DestinationFiles="@(DataFiles_libs->'$(OutDir)/%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target>
<ItemGroup>
<EmbeddedResource Include="Renderer\Effects\Shaders\*.fxc"/>
</ItemGroup>

<Target Name="CopyExternalDeps_publish" AfterTargets="Publish">
<Copy SourceFiles="@(DataFiles_libs)" DestinationFiles="@(DataFiles_libs->'$(PublishDir)/%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target>
<ItemGroup>
<DataFiles_libs Include="..\external\fna-libs\**"/>
<DataFiles_libs Include="..\lib\**"/>
<DataFiles_libs Remove="..\external\fna-libs\.github\**"/>
<DataFiles_libs Remove="..\external\fna-libs\.git"/>
<DataFiles_libs Remove="..\external\fna-libs\README.txt"/>
</ItemGroup>

<ItemGroup>
<Reference Include="ClassicUO.Assets">
<HintPath>..\lib\x64\ClassicUO.Assets.dll</HintPath>
</Reference>
<Reference Include="ClassicUO.IO">
<HintPath>..\lib\x64\ClassicUO.IO.dll</HintPath>
</Reference>
<Reference Include="ClassicUO.Utility">
<HintPath>..\lib\x64\ClassicUO.Utility.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
<None Update="background.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<Target Name="CopyExternalDeps_build" AfterTargets="Build">
<Copy SourceFiles="@(DataFiles_libs)" DestinationFiles="@(DataFiles_libs->'$(OutDir)/%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true"/>
</Target>

<Target Name="CopyExternalDeps_publish" AfterTargets="Publish">
<Copy SourceFiles="@(DataFiles_libs)" DestinationFiles="@(DataFiles_libs->'$(PublishDir)/%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true"/>
</Target>

</Project>
21 changes: 13 additions & 8 deletions CentrED/CentrEDGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public CentrEDGame()
PreferredDepthStencilFormat = DepthFormat.Depth24
};

_gdm.PreparingDeviceSettings += (sender, e) => { e.GraphicsDeviceInformation.PresentationParameters.RenderTargetUsage = RenderTargetUsage.DiscardContents; };
_gdm.PreparingDeviceSettings += (sender, e) =>
{
e.GraphicsDeviceInformation.PresentationParameters.RenderTargetUsage =
RenderTargetUsage.DiscardContents;
};

IsMouseVisible = true;
Window.AllowUserResizing = true;
Expand All @@ -35,7 +39,7 @@ protected override void Initialize()
{
_gdm.GraphicsProfile = GraphicsProfile.HiDef;
}

_gdm.ApplyChanges();

NativeLibrary.Load(Path.Combine(AppContext.BaseDirectory, "x64", "zlib.dll"));
Expand Down Expand Up @@ -68,18 +72,19 @@ protected override void Update(GameTime gameTime)
protected override void Draw(GameTime gameTime)
{
// if (!IsActive)
// return;
// return;

MapManager.Draw();
UIManager.Draw(gameTime);

base.Draw(gameTime);
}


private void OnWindowResized(object? sender, EventArgs e) {


private void OnWindowResized(object? sender, EventArgs e)
{
GameWindow window = sender as GameWindow;
if (window != null)
if (window != null)
MapManager.OnWindowsResized(window);
}
}
30 changes: 18 additions & 12 deletions CentrED/Config.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
using System.Text.Json;

namespace CentrED;
namespace CentrED;

public class ConfigRoot {
public class ConfigRoot
{
public string ActiveProfile { get; set; } = "";
public string ServerConfigPath { get; set; } = "cedserver.xml";
}

public static class Config {

public static class Config
{
private static ConfigRoot _configRoot;
private static string _configFilePath = "settings.json";

static Config() {
if (!File.Exists(_configFilePath)) {

static Config()
{
if (!File.Exists(_configFilePath))
{
var newConfig = new ConfigRoot();
File.WriteAllText(_configFilePath, JsonSerializer.Serialize(newConfig));
}

var jsonText = File.ReadAllText(_configFilePath);
_configRoot = JsonSerializer.Deserialize<ConfigRoot>(jsonText);
_configRoot = JsonSerializer.Deserialize<ConfigRoot>(jsonText);
}

public static void Save() {
public static void Save()
{
File.WriteAllText(_configFilePath, JsonSerializer.Serialize(_configRoot));
}

public static string ActiveProfile {
public static string ActiveProfile
{
get => _configRoot.ActiveProfile;
set => _configRoot.ActiveProfile = value;
}

public static string ServerConfigPath {

public static string ServerConfigPath
{
get => _configRoot.ServerConfigPath;
set => _configRoot.ServerConfigPath = value;
}
Expand Down
Loading

0 comments on commit 2e7b9d4

Please sign in to comment.