Skip to content

Commit

Permalink
Merge pull request #110 from seionmoya/rework-resx
Browse files Browse the repository at this point in the history
Rework resx
  • Loading branch information
seionmoya authored Jan 7, 2025
2 parents 881cb64 + e003892 commit f632d2e
Show file tree
Hide file tree
Showing 212 changed files with 168 additions and 159 deletions.
4 changes: 2 additions & 2 deletions Documentation/fuyu-version-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ The process is roughtly:
#### 2. Updating existing database

1. In `HTTP_DATA/Responses/`, copy-paste from each response that also exists in
`Fuyu.Backend.EFT/embedded/database/` into that folder. In case you got
`Fuyu.Backend.EFT/Resources/database/` into that folder. In case you got
multiple dumps for the same file (exp. `client.items.json`), copy a single
file.
2. Delete the original files from `Fuyu.Backend.EFT/embedded/database/`
2. Delete the original files from `Fuyu.Backend.EFT/Resources/database/`
(the ones without a timestamp at the end of the file).
3. Remove the timestamp from the filenames
4. For locale files, change the last `.` to a `-`
Expand Down
38 changes: 19 additions & 19 deletions Fuyu.Backend.Arena/Fuyu.Backend.Arena.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="embedded/database/locales/client.languages.json" />
<EmbeddedResource Include="embedded/database/locales/client.locale-ch.json" />
<EmbeddedResource Include="embedded/database/locales/client.locale-cz.json" />
<EmbeddedResource Include="embedded/database/locales/client.locale-en.json" />
<EmbeddedResource Include="embedded/database/locales/client.locale-es.json" />
<EmbeddedResource Include="embedded/database/locales/client.locale-es-mx.json" />
<EmbeddedResource Include="embedded/database/locales/client.locale-fr.json" />
<EmbeddedResource Include="embedded/database/locales/client.locale-ge.json" />
<EmbeddedResource Include="embedded/database/locales/client.locale-hu.json" />
<EmbeddedResource Include="embedded/database/locales/client.locale-it.json" />
<EmbeddedResource Include="embedded/database/locales/client.locale-jp.json" />
<EmbeddedResource Include="embedded/database/locales/client.locale-kr.json" />
<EmbeddedResource Include="embedded/database/locales/client.locale-pl.json" />
<EmbeddedResource Include="embedded/database/locales/client.locale-po.json" />
<EmbeddedResource Include="embedded/database/locales/client.locale-ro.json" />
<EmbeddedResource Include="embedded/database/locales/client.locale-ru.json" />
<EmbeddedResource Include="embedded/database/locales/client.locale-sk.json" />
<EmbeddedResource Include="embedded/database/locales/client.locale-tu.json" />
<EmbeddedResource Include="embedded/database/client.game.token.issue.json" />
<EmbeddedResource Include="Resources/database/locales/client.languages.json" />
<EmbeddedResource Include="Resources/database/locales/client.locale-ch.json" />
<EmbeddedResource Include="Resources/database/locales/client.locale-cz.json" />
<EmbeddedResource Include="Resources/database/locales/client.locale-en.json" />
<EmbeddedResource Include="Resources/database/locales/client.locale-es.json" />
<EmbeddedResource Include="Resources/database/locales/client.locale-es-mx.json" />
<EmbeddedResource Include="Resources/database/locales/client.locale-fr.json" />
<EmbeddedResource Include="Resources/database/locales/client.locale-ge.json" />
<EmbeddedResource Include="Resources/database/locales/client.locale-hu.json" />
<EmbeddedResource Include="Resources/database/locales/client.locale-it.json" />
<EmbeddedResource Include="Resources/database/locales/client.locale-jp.json" />
<EmbeddedResource Include="Resources/database/locales/client.locale-kr.json" />
<EmbeddedResource Include="Resources/database/locales/client.locale-pl.json" />
<EmbeddedResource Include="Resources/database/locales/client.locale-po.json" />
<EmbeddedResource Include="Resources/database/locales/client.locale-ro.json" />
<EmbeddedResource Include="Resources/database/locales/client.locale-ru.json" />
<EmbeddedResource Include="Resources/database/locales/client.locale-sk.json" />
<EmbeddedResource Include="Resources/database/locales/client.locale-tu.json" />
<EmbeddedResource Include="Resources/database/client.game.token.issue.json" />
</ItemGroup>

</Project>
248 changes: 124 additions & 124 deletions Fuyu.Backend.EFT/Fuyu.Backend.EFT.csproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Fuyu.Common/Fuyu.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 1 addition & 4 deletions Fuyu.Common/IO/Resx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ public static Stream GetStream(string id, string path)
}

// find target

// NOTE: replacing ".Resources" is, ideally, a temporary solution
// -- nexus4880, 2024-12-11
var target = $"{assembly.GetName().Name.Replace(".Resources", string.Empty)}.embedded.{path}";
var target = $"{assembly.GetName().Name}.Resources.{path}";

foreach (var fullpath in fullpaths)
{
Expand Down
4 changes: 2 additions & 2 deletions Fuyu.Common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ public class Program

A simple wrapper around loading embedded files from assemblies.

It assumes the file is located in the `embedded/` folder of your csproj.
It assumes the file is located in the `Resources/` folder of your csproj.

```xml
<ItemGroup>
<EmbeddedResource Include="embedded/path/to/file.txt" />
<EmbeddedResource Include="Resources/path/to/file.txt" />
</ItemGroup>
```

Expand Down
2 changes: 1 addition & 1 deletion Fuyu.DependencyInjection/Fuyu.DependencyInjection.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion Fuyu.Modding/Fuyu.Modding.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
Expand Down
20 changes: 16 additions & 4 deletions Fuyu.Modding/ModManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ public static ModManager Instance
}
}

private string GetResourcePath(string resourceRootPath, string resourcePath)
{
return resourcePath
.Replace(resourceRootPath + "\\", string.Empty) // exp. Fuyu/Mods/Launcher
.Replace("../", string.Empty) // relative path ./
.Replace("./", string.Empty) // relative path ./
.Replace("\\", ".") // windows \
.Replace("/", "."); // unix /
}

private CSharpCompilation CreateCompilation(
string assemblyName,
IEnumerable<SyntaxTree> syntaxTrees,
Expand Down Expand Up @@ -153,10 +163,11 @@ private void ProcessSourceFiles(string directory)
syntaxTrees.Add(syntaxTree);
}

var resourcePaths = VFS.GetFiles(Path.Combine(directory, "res"), "*.*", SearchOption.AllDirectories);
var resourceRootPath = Path.Combine(directory, "res");
var resourcePaths = VFS.GetFiles(resourceRootPath, "*.*", SearchOption.AllDirectories);
var resources = resourcePaths.Select(resourcePath =>
{
var fileName = $"{assemblyName}.embedded.{Path.GetFileName(resourcePath)}";
var fileName= $"{assemblyName}.Resources.{GetResourcePath(resourceRootPath, resourcePath)}";

return new ResourceDescription(
fileName,
Expand Down Expand Up @@ -291,11 +302,12 @@ private async Task UnloadMod(Mod mod)
private Assembly GenerateResourceAssembly(Assembly sourceAssembly)
{
var assemblyName = sourceAssembly.GetName().Name;
var resourceRootPath = Path.Combine(Path.GetDirectoryName(sourceAssembly.Location), "res");
string[] resourcePaths;

try
{
resourcePaths = VFS.GetFiles(Path.Combine(Path.GetDirectoryName(sourceAssembly.Location), "res"), "*.*", SearchOption.AllDirectories);
resourcePaths = VFS.GetFiles(resourceRootPath, "*.*", SearchOption.AllDirectories);
}
catch (DirectoryNotFoundException)
{
Expand All @@ -309,7 +321,7 @@ private Assembly GenerateResourceAssembly(Assembly sourceAssembly)

var resources = resourcePaths.Select(resourcePath =>
{
var fileName = $"{assemblyName}.embedded.{Path.GetFileName(resourcePath)}";
var fileName = $"{assemblyName}.Resources.{GetResourcePath(resourceRootPath, resourcePath)}";

return new ResourceDescription(
fileName,
Expand Down
2 changes: 1 addition & 1 deletion Tests/Fuyu.Tests.Common/Fuyu.Tests.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="embedded/test.txt" />
<EmbeddedResource Include="Resources/test.txt" />
</ItemGroup>

<Target Name="PostClean" AfterTargets="Clean">
Expand Down
File renamed without changes.

0 comments on commit f632d2e

Please sign in to comment.