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

ResourcePack Refactor/Abstraction #119

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
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
23 changes: 5 additions & 18 deletions src/Alex.ResourcePackLib/MCBedrockResourcePack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,9 @@ public class MCBedrockResourcePack : ResourcePack, ITextureProvider, IAnimationP
public IDictionary<string, RenderController> RenderControllers { get; private set; } = new ConcurrentDictionary<string, RenderController>();
public IDictionary<string, AnimationController> AnimationControllers { get; private set; } = new ConcurrentDictionary<string, AnimationController>();
public IDictionary<string, Animation> Animations { get; private set; } = new ConcurrentDictionary<string, Animation>();

public IReadOnlyDictionary<string, ParticleDefinition> Particles { get; private set; } =
new ConcurrentDictionary<string, ParticleDefinition>();

public IReadOnlyDictionary<string, JToken> GlobalUiVariables { get; private set; } =
new Dictionary<string, JToken>();

public IReadOnlyDictionary<string, ParticleDefinition> Particles { get; private set; } = new ConcurrentDictionary<string, ParticleDefinition>();
public IReadOnlyDictionary<string, JToken> GlobalUiVariables { get; private set; } = new Dictionary<string, JToken>();
public SoundDefinitionFormat SoundDefinitions { get; private set; } = null;

public SoundBindingsCollection SoundBindings { get; private set; } = null;

private readonly IFilesystem _archive;
Expand Down Expand Up @@ -87,7 +81,6 @@ private string NormalisePath(string path)
private static readonly Regex IsFontFile = new Regex(@"^font[\\\/](?'filename'.*)\.png$", RegexOpts);
private static readonly Regex IsParticleFile = new Regex(@"^particles[\\\/](?'filename'.*)\.json$", RegexOpts);
private static readonly Regex IsAttachableFile = new Regex(@"^attachables[\\\/](?'filename'.*)\.json$", RegexOpts);

private static readonly Regex IsUiTexture = new Regex(@"^textures[\\\/]ui[\\\/](?'filename'.*)\.png", RegexOpts);
private static readonly Regex IsUiDefinition = new Regex(@"^ui[\\\/](?'filename'.*)\.json", RegexOpts);

Expand All @@ -96,16 +89,10 @@ private void Load(ResourcePack.LoadProgress progressReporter)
Dictionary<string, EntityDescription> entityDefinitions = new Dictionary<string, EntityDescription>();
Dictionary<string, EntityModel> entityModels = new Dictionary<string, EntityModel>(StringComparer.Ordinal);
Dictionary<string, RenderController> renderControllers = new Dictionary<string, RenderController>(StringComparer.Ordinal);

Dictionary<string, AnimationController>
animationControllers = new Dictionary<string, AnimationController>(StringComparer.Ordinal);

Dictionary<string, AnimationController> animationControllers = new Dictionary<string, AnimationController>(StringComparer.Ordinal);
Dictionary<string, ParticleDefinition> particleDefinitions = new Dictionary<string, ParticleDefinition>(StringComparer.Ordinal);

Dictionary<string, AttachableDefinition> attachableDefinitions =
new Dictionary<string, AttachableDefinition>(StringComparer.Ordinal);
Dictionary<string, Animation>
animations = new Dictionary<string, Animation>(StringComparer.Ordinal);
Dictionary<string, AttachableDefinition> attachableDefinitions = new Dictionary<string, AttachableDefinition>(StringComparer.Ordinal);
Dictionary<string, Animation> animations = new Dictionary<string, Animation>(StringComparer.Ordinal);

TryAddBitmap("textures/ui/title");

Expand Down
70 changes: 70 additions & 0 deletions src/Alex.sln
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiNET.Console", "..\submodu
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Alex.ECS", "Alex.ECS\Alex.ECS.csproj", "{6FB2730B-78B0-4AE5-9E48-E901D2E6DD54}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ResourcePackLib", "ResourcePackLib", "{7993E92A-6DD1-4F64-A654-D3ED0ACF0C6E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourcePackLib.Core", "ResourcePackLib\ResourcePackLib.Core\ResourcePackLib.Core.csproj", "{27DB8A4A-DE08-449E-AF1C-9DD64EEE485E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourcePackLib.Loader.Bedrock", "ResourcePackLib\ResourcePackLib.Loader.Bedrock\ResourcePackLib.Loader.Bedrock.csproj", "{801C2903-C3E5-4B8D-9D04-AF2B0719FBE2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourcePackLib.Loader.Java", "ResourcePackLib\ResourcePackLib.Loader.Java\ResourcePackLib.Loader.Java.csproj", "{C8511536-2B73-4C40-9F04-64389D50E6E8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shaders", "Shaders", "{A1B11EA5-36F6-45A3-B9CF-0DDB43DEACA9}"
ProjectSection(SolutionItems) = preProject
Shaders\Blockshader.fx = Shaders\Blockshader.fx
Expand All @@ -55,6 +63,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shaders", "Shaders", "{A1B1
Shaders\ShawowMap.fx = Shaders\ShawowMap.fx
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourcePackLib.ModelExplorer", "ResourcePackLib\ResourcePackLib.ModelExplorer\ResourcePackLib.ModelExplorer.csproj", "{75B8EC0E-D606-4886-BFF5-C5B70D2DD066}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Appveyor|Any CPU = Appveyor|Any CPU
Expand Down Expand Up @@ -242,6 +252,62 @@ Global
{6FB2730B-78B0-4AE5-9E48-E901D2E6DD54}.Release|x64.Build.0 = Release|Any CPU
{6FB2730B-78B0-4AE5-9E48-E901D2E6DD54}.DirectX|x64.ActiveCfg = Debug|Any CPU
{6FB2730B-78B0-4AE5-9E48-E901D2E6DD54}.DirectX|x64.Build.0 = Debug|Any CPU
{27DB8A4A-DE08-449E-AF1C-9DD64EEE485E}.Appveyor|Any CPU.ActiveCfg = Debug|Any CPU
{27DB8A4A-DE08-449E-AF1C-9DD64EEE485E}.Appveyor|Any CPU.Build.0 = Debug|Any CPU
{27DB8A4A-DE08-449E-AF1C-9DD64EEE485E}.Appveyor|x64.ActiveCfg = Debug|Any CPU
{27DB8A4A-DE08-449E-AF1C-9DD64EEE485E}.Appveyor|x64.Build.0 = Debug|Any CPU
{27DB8A4A-DE08-449E-AF1C-9DD64EEE485E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{27DB8A4A-DE08-449E-AF1C-9DD64EEE485E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27DB8A4A-DE08-449E-AF1C-9DD64EEE485E}.Debug|x64.ActiveCfg = Debug|Any CPU
{27DB8A4A-DE08-449E-AF1C-9DD64EEE485E}.Debug|x64.Build.0 = Debug|Any CPU
{27DB8A4A-DE08-449E-AF1C-9DD64EEE485E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27DB8A4A-DE08-449E-AF1C-9DD64EEE485E}.Release|Any CPU.Build.0 = Release|Any CPU
{27DB8A4A-DE08-449E-AF1C-9DD64EEE485E}.Release|x64.ActiveCfg = Release|Any CPU
{27DB8A4A-DE08-449E-AF1C-9DD64EEE485E}.Release|x64.Build.0 = Release|Any CPU
{27DB8A4A-DE08-449E-AF1C-9DD64EEE485E}.DirectX|x64.ActiveCfg = Debug|Any CPU
{27DB8A4A-DE08-449E-AF1C-9DD64EEE485E}.DirectX|x64.Build.0 = Debug|Any CPU
{801C2903-C3E5-4B8D-9D04-AF2B0719FBE2}.Appveyor|Any CPU.ActiveCfg = Debug|Any CPU
{801C2903-C3E5-4B8D-9D04-AF2B0719FBE2}.Appveyor|Any CPU.Build.0 = Debug|Any CPU
{801C2903-C3E5-4B8D-9D04-AF2B0719FBE2}.Appveyor|x64.ActiveCfg = Debug|Any CPU
{801C2903-C3E5-4B8D-9D04-AF2B0719FBE2}.Appveyor|x64.Build.0 = Debug|Any CPU
{801C2903-C3E5-4B8D-9D04-AF2B0719FBE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{801C2903-C3E5-4B8D-9D04-AF2B0719FBE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{801C2903-C3E5-4B8D-9D04-AF2B0719FBE2}.Debug|x64.ActiveCfg = Debug|Any CPU
{801C2903-C3E5-4B8D-9D04-AF2B0719FBE2}.Debug|x64.Build.0 = Debug|Any CPU
{801C2903-C3E5-4B8D-9D04-AF2B0719FBE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{801C2903-C3E5-4B8D-9D04-AF2B0719FBE2}.Release|Any CPU.Build.0 = Release|Any CPU
{801C2903-C3E5-4B8D-9D04-AF2B0719FBE2}.Release|x64.ActiveCfg = Release|Any CPU
{801C2903-C3E5-4B8D-9D04-AF2B0719FBE2}.Release|x64.Build.0 = Release|Any CPU
{801C2903-C3E5-4B8D-9D04-AF2B0719FBE2}.DirectX|x64.ActiveCfg = Debug|Any CPU
{801C2903-C3E5-4B8D-9D04-AF2B0719FBE2}.DirectX|x64.Build.0 = Debug|Any CPU
{C8511536-2B73-4C40-9F04-64389D50E6E8}.Appveyor|Any CPU.ActiveCfg = Debug|Any CPU
{C8511536-2B73-4C40-9F04-64389D50E6E8}.Appveyor|Any CPU.Build.0 = Debug|Any CPU
{C8511536-2B73-4C40-9F04-64389D50E6E8}.Appveyor|x64.ActiveCfg = Debug|Any CPU
{C8511536-2B73-4C40-9F04-64389D50E6E8}.Appveyor|x64.Build.0 = Debug|Any CPU
{C8511536-2B73-4C40-9F04-64389D50E6E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8511536-2B73-4C40-9F04-64389D50E6E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8511536-2B73-4C40-9F04-64389D50E6E8}.Debug|x64.ActiveCfg = Debug|Any CPU
{C8511536-2B73-4C40-9F04-64389D50E6E8}.Debug|x64.Build.0 = Debug|Any CPU
{C8511536-2B73-4C40-9F04-64389D50E6E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8511536-2B73-4C40-9F04-64389D50E6E8}.Release|Any CPU.Build.0 = Release|Any CPU
{C8511536-2B73-4C40-9F04-64389D50E6E8}.Release|x64.ActiveCfg = Release|Any CPU
{C8511536-2B73-4C40-9F04-64389D50E6E8}.Release|x64.Build.0 = Release|Any CPU
{C8511536-2B73-4C40-9F04-64389D50E6E8}.DirectX|x64.ActiveCfg = Debug|Any CPU
{C8511536-2B73-4C40-9F04-64389D50E6E8}.DirectX|x64.Build.0 = Debug|Any CPU
{75B8EC0E-D606-4886-BFF5-C5B70D2DD066}.Appveyor|Any CPU.ActiveCfg = Debug|Any CPU
{75B8EC0E-D606-4886-BFF5-C5B70D2DD066}.Appveyor|Any CPU.Build.0 = Debug|Any CPU
{75B8EC0E-D606-4886-BFF5-C5B70D2DD066}.Appveyor|x64.ActiveCfg = Debug|Any CPU
{75B8EC0E-D606-4886-BFF5-C5B70D2DD066}.Appveyor|x64.Build.0 = Debug|Any CPU
{75B8EC0E-D606-4886-BFF5-C5B70D2DD066}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{75B8EC0E-D606-4886-BFF5-C5B70D2DD066}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75B8EC0E-D606-4886-BFF5-C5B70D2DD066}.Debug|x64.ActiveCfg = Debug|Any CPU
{75B8EC0E-D606-4886-BFF5-C5B70D2DD066}.Debug|x64.Build.0 = Debug|Any CPU
{75B8EC0E-D606-4886-BFF5-C5B70D2DD066}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75B8EC0E-D606-4886-BFF5-C5B70D2DD066}.Release|Any CPU.Build.0 = Release|Any CPU
{75B8EC0E-D606-4886-BFF5-C5B70D2DD066}.Release|x64.ActiveCfg = Release|Any CPU
{75B8EC0E-D606-4886-BFF5-C5B70D2DD066}.Release|x64.Build.0 = Release|Any CPU
{75B8EC0E-D606-4886-BFF5-C5B70D2DD066}.DirectX|x64.ActiveCfg = Debug|Any CPU
{75B8EC0E-D606-4886-BFF5-C5B70D2DD066}.DirectX|x64.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -255,6 +321,10 @@ Global
{18E484B8-B625-45CD-92DD-52B9CA6A8838} = {56040BCF-D80D-4435-B420-BF8B29A5B4B1}
{09378720-C7F2-4AE4-9111-B0D64F0D9496} = {66F9179F-DEB1-45B9-B067-D613A2857D5C}
{A1B11EA5-36F6-45A3-B9CF-0DDB43DEACA9} = {5339DA92-BA8E-441B-AF71-27B75FEEC760}
{27DB8A4A-DE08-449E-AF1C-9DD64EEE485E} = {7993E92A-6DD1-4F64-A654-D3ED0ACF0C6E}
{801C2903-C3E5-4B8D-9D04-AF2B0719FBE2} = {7993E92A-6DD1-4F64-A654-D3ED0ACF0C6E}
{C8511536-2B73-4C40-9F04-64389D50E6E8} = {7993E92A-6DD1-4F64-A654-D3ED0ACF0C6E}
{75B8EC0E-D606-4886-BFF5-C5B70D2DD066} = {7993E92A-6DD1-4F64-A654-D3ED0ACF0C6E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {32B4D997-4F97-43FC-9636-1E35A79AA844}
Expand Down
4 changes: 3 additions & 1 deletion src/Alex/Entities/PlayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,9 @@ private void UpdateMouseInput(GameTime gt)
{
var e = MouseInputListener.GetCursorPosition();

if (e.X < 10 || e.X > Graphics.Viewport.Width - 10 || e.Y < 10
if (e.X < 10
|| e.X > Graphics.Viewport.Width - 10
|| e.Y < 10
|| e.Y > Graphics.Viewport.Height - 10)
{
CenterCursor();
Expand Down
2 changes: 1 addition & 1 deletion src/Alex/Gamestates/InGame/PlayingState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class PlayingState : GuiGameStateBase

public World World { get; private set; }

private WorldProvider WorldProvider { get; set; }
private WorldProvider WorldProvider { get; set; }
private NetworkProvider NetworkProvider { get; set; }

private readonly PlayingHud _playingHud;
Expand Down
3 changes: 2 additions & 1 deletion src/Alex/Utils/Assets/MCJavaAssetsUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ public async Task<string> EnsureTargetReleaseAsync(string targetRelease, IProgre
{
foreach (var file in dir.EnumerateFiles("*", SearchOption.AllDirectories))
{
zip.CreateEntryFromFile(file.FullName, Path.GetRelativePath(dir.FullName, file.FullName));
// Zip file entries MUST use '/' as directory separator
zip.CreateEntryFromFile(file.FullName, Path.GetRelativePath(dir.FullName, file.FullName).Replace(Path.DirectorySeparatorChar, '/'));
}
}

Expand Down
Loading