Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Official support for macOS #403

Merged
merged 7 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
"stopAtEntry": false
},
{
"name": "EndlessClient - Mac",
"name": "EndlessClient - Mac (arm64)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-client-mac",
"program": "${workspaceFolder}/bin/Debug/client/net6.0-macos/osx-x64/EndlessClient.app/Contents/MacOS/EndlessClient",
"preLaunchTask": "build-client-mac-arm",
"program": "${workspaceFolder}/bin/Debug/client/net8.0-macos/osx-arm64/EndlessClient.app/Contents/MacOS/EndlessClient",
"args": [],
"cwd": "${workspaceFolder}/bin/Debug/client/net6.0-macos/osx-x64/EndlessClient.app",
"cwd": "${workspaceFolder}/bin/Debug/client/net8.0-macos/osx-arm64/EndlessClient.app",
"console": "internalConsole",
"stopAtEntry": false
},
Expand Down
6 changes: 3 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
"problemMatcher": "$msCompile"
},
{
"label": "build-client-mac",
"label": "build-client-mac-arm",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/EndlessClient/EndlessClient.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
"-r",
"osx-arm64"
],
"problemMatcher": "$msCompile"
},
Expand Down
3 changes: 1 addition & 2 deletions EOBot/BotBase.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using EOLib;
using EOLib.Config;
using EOLib.Domain.Protocol;
using EOLib.Net.Communication;
using EOLib.Net.Connection;
using EOLib.Net.PacketProcessing;
using EOLib.Shared;
using Moffat.EndlessOnline.SDK.Packet;
using Moffat.EndlessOnline.SDK.Protocol.Net.Server;

Expand Down
2 changes: 1 addition & 1 deletion EOBot/Interpreter/BuiltInIdentifierConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Threading.Tasks;
using EOBot.Interpreter.States;
using EOBot.Interpreter.Variables;
using EOLib;
using EOLib.Config;
using EOLib.Domain.Character;
using EOLib.Domain.Chat;
Expand All @@ -17,6 +16,7 @@
using EOLib.Net.Communication;
using EOLib.Net.Connection;
using EOLib.Net.PacketProcessing;
using EOLib.Shared;
using Moffat.EndlessOnline.SDK.Packet;
using Moffat.EndlessOnline.SDK.Protocol.Net;
using Moffat.EndlessOnline.SDK.Protocol.Net.Server;
Expand Down
13 changes: 7 additions & 6 deletions EOLib.Config.Test/ConfigFileLoadActionsTest.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using EOLib.Shared;
using NUnit.Framework;

namespace EOLib.Config.Test
{
[TestFixture, ExcludeFromCodeCoverage]
public class ConfigFileLoadActionsTest
{
private const string ConfigDirectory = "config";
private static readonly string _configDirectory = PathResolver.GetModifiablePath("config");

private IConfigFileLoadActions _configFileLoadActions;
private IConfigurationRepository _configurationRepository;
Expand All @@ -23,8 +24,8 @@ public void SetUp()
[TearDown]
public static void TearDown()
{
if (Directory.Exists(ConfigDirectory))
Directory.Delete(ConfigDirectory, true);
if (Directory.Exists(_configDirectory))
Directory.Delete(_configDirectory, true);
}

[Test]
Expand Down Expand Up @@ -127,10 +128,10 @@ public void ValidConfigFile_LoadsSpecifiedSettings()

private static void CreateTestConfigurationInDirectory(string contents)
{
if (!Directory.Exists(ConfigDirectory))
Directory.CreateDirectory(ConfigDirectory);
if (!Directory.Exists(_configDirectory))
Directory.CreateDirectory(_configDirectory);

File.WriteAllText(ConfigStrings.Default_Config_File, contents);
File.WriteAllText(Constants.Default_Config_File, contents);
}
}
}
5 changes: 4 additions & 1 deletion EOLib.Config/ConfigFileLoadActions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using AutomaticTypeMapper;
using EOLib.Shared;

namespace EOLib.Config
{
Expand All @@ -15,7 +18,7 @@ public ConfigFileLoadActions(IConfigurationRepository configRepository)

public void LoadConfigFile()
{
var configFile = new IniReader(ConfigStrings.Default_Config_File);
var configFile = new IniReader(Constants.Default_Config_File);
if (!configFile.Load())
throw new ConfigLoadException();

Expand Down
3 changes: 2 additions & 1 deletion EOLib.Config/ConfigLoadException.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using EOLib.Shared;

namespace EOLib.Config
{
public class ConfigLoadException : Exception
{
public ConfigLoadException()
: base("Unable to load the configuration file! Make sure there is a file in " + ConfigStrings.Default_Config_File) { }
: base("Unable to load the configuration file! Make sure there is a file in " + Constants.Default_Config_File) { }
}
}
2 changes: 0 additions & 2 deletions EOLib.Config/ConfigStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace EOLib.Config
[ExcludeFromCodeCoverage]
public static class ConfigStrings
{
public const string Default_Config_File = "config/settings.ini";

public const string Connection = "CONNECTION";
public const string Host = "Host";
public const string Port = "Port";
Expand Down
3 changes: 3 additions & 0 deletions EOLib.Config/EOLib.Config.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@
<ItemGroup>
<PackageReference Include="AutomaticTypeMapper" Version="1.4.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EOLib.Shared\EOLib.Shared.csproj" />
</ItemGroup>
</Project>
20 changes: 13 additions & 7 deletions EOLib.Graphics.Test/PEFileCollectionTest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using EOLib.Shared;
using Moq;
using NUnit.Framework;
using PELoaderLib;
Expand All @@ -11,7 +11,8 @@ namespace EOLib.Graphics.Test
[TestFixture, ExcludeFromCodeCoverage]
public class PEFileCollectionTest
{
private const string ExpectedDirectory = "gfx";
private static readonly string _expectedDirectory = PathResolver.GetPath("gfx");
private static readonly string _expectedDirectoryRoot = _expectedDirectory.Split(Path.DirectorySeparatorChar)[0];

private IPEFileCollection _collection;

Expand All @@ -26,8 +27,8 @@ public void TearDown()
{
_collection.Dispose();

if (Directory.Exists(ExpectedDirectory))
Directory.Delete(ExpectedDirectory, true);
if (Directory.Exists(_expectedDirectoryRoot))
Directory.Delete(_expectedDirectoryRoot, recursive: true);
}

[Test]
Expand Down Expand Up @@ -67,11 +68,16 @@ public void Dispose_DisposesAllFiles()
Mock.Get(file).Verify(x => x.Dispose(), Times.Once);
}

private void CreateExpectedDirectoryWithFiles(int numFiles = 0, string fileNameFormat = "gfx{0:D3}.egf")
private static void CreateExpectedDirectoryWithFiles(int numFiles = 0, string fileNameFormat = "gfx{0:D3}.egf")
{
Directory.CreateDirectory(ExpectedDirectory);
var components = _expectedDirectory.Split(Path.DirectorySeparatorChar);
foreach (var component in components)
Directory.CreateDirectory(_expectedDirectory);

for (int i = 1; i <= numFiles; ++i)
File.WriteAllText(string.Format(Path.Combine(ExpectedDirectory, fileNameFormat), i), "test contents");
{
File.WriteAllText(string.Format(Path.Combine(_expectedDirectory, fileNameFormat), i), "test contents");
}
}
}
}
1 change: 1 addition & 0 deletions EOLib.Graphics/EOLib.Graphics.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EOLib.Config\EOLib.Config.csproj" />
<ProjectReference Include="..\EOLib.Shared\EOLib.Shared.csproj" />
</ItemGroup>
</Project>
6 changes: 2 additions & 4 deletions EOLib.Graphics/PEFileCollection.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using AutomaticTypeMapper;
using EOLib.Shared;
using PELoaderLib;

namespace EOLib.Graphics
Expand All @@ -18,9 +18,7 @@ public void PopulateCollectionWithStandardGFX()

private IPEFile CreateGFXFile(GFXTypes file)
{
var number = ((int)file).ToString("D3");
var fName = Path.Combine("gfx", "gfx" + number + ".egf");

var fName = string.Format(Constants.GFXFormat, (int)file);
#if LINUX || OSX
return new PEFile(fName);
#else
Expand Down
2 changes: 1 addition & 1 deletion EOLib.IO/Actions/MapFileLoadActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class MapFileLoadActions : IMapFileLoadActions
private readonly IMapFileLoadService _mapFileLoadService;

public MapFileLoadActions(IMapFileRepository mapFileRepository,
IMapFileLoadService mapFileLoadService)
IMapFileLoadService mapFileLoadService)
{
_mapFileRepository = mapFileRepository;
_mapFileLoadService = mapFileLoadService;
Expand Down
3 changes: 3 additions & 0 deletions EOLib.IO/EOLib.IO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
<PackageReference Include="Moffat.EndlessOnline.SDK" Version="1.0.0" />
<PackageReference Include="System.Memory" Version="4.5.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EOLib.Shared\EOLib.Shared.csproj" />
</ItemGroup>
</Project>
2 changes: 0 additions & 2 deletions EOLib.IO/Map/MapFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ namespace EOLib.IO.Map
{
public class MapFile : IMapFile
{
public const string MapFileFormatString = "maps/{0,5:D5}.emf";

public IMapFileProperties Properties { get; private set; }

public IReadOnlyMatrix<TileSpec> Tiles => _mutableTiles;
Expand Down
15 changes: 0 additions & 15 deletions EOLib.IO/NumericConstants.cs

This file was deleted.

19 changes: 0 additions & 19 deletions EOLib.IO/PubFileNameConstants.cs

This file was deleted.

3 changes: 2 additions & 1 deletion EOLib.IO/Services/BasePubLoadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using EOLib.IO.Pub;
using EOLib.IO.Services.Serializers;
using EOLib.Shared;

namespace EOLib.IO.Services
{
Expand All @@ -20,7 +21,7 @@ protected BasePubLoadService(IPubFileDeserializer pubFileDeserializer)

public IEnumerable<IPubFile<TRecord>> LoadPubFromDefaultFile()
{
return LoadPubFromExplicitFile(PubFileNameConstants.PubDirectory, FileFilter);
return LoadPubFromExplicitFile(Constants.PubDirectory, FileFilter);
}

public IEnumerable<IPubFile<TRecord>> LoadPubFromExplicitFile(string directory, string searchPattern)
Expand Down
3 changes: 2 additions & 1 deletion EOLib.IO/Services/ClassFileLoadService.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using AutomaticTypeMapper;
using EOLib.IO.Pub;
using EOLib.IO.Services.Serializers;
using EOLib.Shared;

namespace EOLib.IO.Services
{
[AutoMappedType]
public class ClassFileLoadService : BasePubLoadService<ECFRecord>
{
protected override string FileFilter => PubFileNameConstants.ECFFilter;
protected override string FileFilter => Constants.ECFFilter;

public ClassFileLoadService(IPubFileDeserializer pubFileDeserializer)
: base(pubFileDeserializer)
Expand Down
3 changes: 2 additions & 1 deletion EOLib.IO/Services/ItemFileLoadService.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using AutomaticTypeMapper;
using EOLib.IO.Pub;
using EOLib.IO.Services.Serializers;
using EOLib.Shared;

namespace EOLib.IO.Services
{
[AutoMappedType]
public class ItemFileLoadService : BasePubLoadService<EIFRecord>
{
protected override string FileFilter => PubFileNameConstants.EIFFilter;
protected override string FileFilter => Constants.EIFFilter;

public ItemFileLoadService(IPubFileDeserializer pubFileDeserializer)
: base(pubFileDeserializer)
Expand Down
7 changes: 5 additions & 2 deletions EOLib.IO/Services/MapFileLoadService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System.IO;
using System;
using System.IO;
using System.Runtime.InteropServices;
using AutomaticTypeMapper;
using EOLib.IO.Map;
using EOLib.IO.Services.Serializers;
using EOLib.Shared;

namespace EOLib.IO.Services
{
Expand All @@ -17,7 +20,7 @@ public MapFileLoadService(IMapDeserializer<IMapFile> mapFileSerializer)

public IMapFile LoadMapByID(int mapID)
{
var mapFileBytes = File.ReadAllBytes(string.Format(MapFile.MapFileFormatString, mapID));
var mapFileBytes = File.ReadAllBytes(string.Format(Constants.MapFileFormatString, mapID));

var mapFile = _mapFileSerializer
.DeserializeFromByteArray(mapFileBytes)
Expand Down
5 changes: 3 additions & 2 deletions EOLib.IO/Services/MapFileSaveService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using AutomaticTypeMapper;
using EOLib.IO.Map;
using EOLib.IO.Services.Serializers;
using EOLib.Shared;

namespace EOLib.IO.Services
{
Expand All @@ -18,11 +19,11 @@ public MapFileSaveService(IMapFileSerializer mapFileSerializer)

public void SaveFileToDefaultDirectory(IMapFile mapFile, bool rewriteChecksum = true)
{
var directoryName = Path.GetDirectoryName(string.Format(MapFile.MapFileFormatString, 1)) ?? "";
var directoryName = Constants.MapDirectory;
if (!Directory.Exists(directoryName))
Directory.CreateDirectory(directoryName);

File.WriteAllBytes(string.Format(MapFile.MapFileFormatString, mapFile.Properties.MapID),
File.WriteAllBytes(string.Format(Constants.MapFileFormatString, mapFile.Properties.MapID),
_mapFileSerializer.SerializeToByteArray(mapFile, rewriteChecksum));
}

Expand Down
Loading