Skip to content

Commit

Permalink
Updated for Beat Saber 0.11.2
Browse files Browse the repository at this point in the history
  • Loading branch information
xyonico committed Aug 20, 2018
1 parent f49d476 commit 5c1745a
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 106 deletions.
6 changes: 0 additions & 6 deletions CustomAvatar.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@ Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
0_11_2|Any CPU = 0_11_2|Any CPU
0_11_1|Any CPU = 0_11_1|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8207B0AC-FCA6-47AA-B634-795271F4E5D0}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{8207B0AC-FCA6-47AA-B634-795271F4E5D0}.Debug|Any CPU.Build.0 = Release|Any CPU
{8207B0AC-FCA6-47AA-B634-795271F4E5D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8207B0AC-FCA6-47AA-B634-795271F4E5D0}.Release|Any CPU.Build.0 = Release|Any CPU
{8207B0AC-FCA6-47AA-B634-795271F4E5D0}.0_11_2|Any CPU.ActiveCfg = 0_11_2|Any CPU
{8207B0AC-FCA6-47AA-B634-795271F4E5D0}.0_11_2|Any CPU.Build.0 = 0_11_2|Any CPU
{8207B0AC-FCA6-47AA-B634-795271F4E5D0}.0_11_1|Any CPU.ActiveCfg = 0_11_1|Any CPU
{8207B0AC-FCA6-47AA-B634-795271F4E5D0}.0_11_1|Any CPU.Build.0 = 0_11_1|Any CPU
EndGlobalSection
EndGlobal
89 changes: 0 additions & 89 deletions CustomAvatar/AvatarLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace CustomAvatar
{
#if BS_0_11_2
public class AvatarLoader
{
private static readonly string[] AvatarExtensions =
Expand Down Expand Up @@ -46,92 +45,4 @@ private static void GetAvatarsInPath(string path, Action<FileBrowserItem[]> call
FileBrowserModel.GetContentOfDirectory(path, AvatarExtensions, callback);
}
}
#elif BS_0_11_1
public class AvatarLoader
{
private readonly List<CustomAvatar> _avatars = new List<CustomAvatar>();

public IReadOnlyList<CustomAvatar> Avatars
{
get { return _avatars; }
}

public AvatarLoader(string customAvatarsPath, Action<IReadOnlyList<CustomAvatar>> loadedCallback)
{
void AvatarPathsLoaded(FileBrowserItem[] items)
{
foreach (var item in items)
{
if (Directory.Exists(item.fullPath)) continue;
var newAvatar = new CustomAvatar(item.fullPath);
_avatars.Add(newAvatar);
}

loadedCallback(_avatars.ToArray());
}

GetAvatarsInPath(customAvatarsPath, AvatarPathsLoaded);
}

public int IndexOf(CustomAvatar customAvatar)
{
return _avatars.IndexOf(customAvatar);
}

private static void GetAvatarsInPath(string path, Action<FileBrowserItem[]> callback)
{
AvatarFileBrowserModel.Instance.GetContentOfDirectory(path, callback);
}

public class AvatarFileBrowserModel : FileBrowserModel
{
public static readonly AvatarFileBrowserModel Instance = new AvatarFileBrowserModel();

protected override FileBrowserItem[] GetContentOfDirectory(string path)
{
var list = new List<FileBrowserItem>();
var path2 = path + "\\..";
if (Path.GetFullPath(path2) != Path.GetFullPath(path))
{
list.Add(new DirectoryBrowserItem("..", Path.GetFullPath(path2)));
}
if (!CanOpenDirectory(path))
{
return list.ToArray();
}
path = Path.GetFullPath(path);
var directories = Directory.GetDirectories(path);
foreach (var path3 in directories)
{
list.Add(new DirectoryBrowserItem(Path.GetFileName(path3), Path.GetFullPath(path3)));
}
var files = Directory.GetFiles(path);
foreach (var path4 in files)
{
var a = Path.GetExtension(path4).ToLower();
if (a == ".avatar")
{
list.Add(new FileBrowserItem(Path.GetFileName(path4), Path.GetFullPath(path4)));
}
}
return list.ToArray();
}

private static bool CanOpenDirectory(string path)
{
bool result;
try
{
Directory.GetDirectories(path);
result = true;
}
catch
{
result = false;
}
return result;
}
}
}
#endif
}
8 changes: 0 additions & 8 deletions CustomAvatar/CustomAvatar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == '0.11.2|AnyCPU' ">
<OutputPath>bin\0.11.2\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == '0_11_2|AnyCPU' ">
<OutputPath>bin\0_11_2\</OutputPath>
<DefineConstants>BS_0_11_2</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == '0_11_1|AnyCPU' ">
<OutputPath>bin\0_11_1\</OutputPath>
<DefineConstants>BS_0_11_1</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion CustomAvatar/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public string Name

public string Version
{
get { return "3.1.0-beta"; }
get { return "3.1.1-beta"; }
}

public static void Log(string message)
Expand Down
4 changes: 2 additions & 2 deletions CustomAvatar/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.1.0.0")]
[assembly: AssemblyFileVersion("3.1.0.0")]
[assembly: AssemblyVersion("3.1.1.0")]
[assembly: AssemblyFileVersion("3.1.1.0")]

0 comments on commit 5c1745a

Please sign in to comment.