Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Pespiri committed Jan 13, 2020
1 parent beff053 commit 8162d89
Show file tree
Hide file tree
Showing 68 changed files with 3,200 additions and 0 deletions.
50 changes: 50 additions & 0 deletions CustomWalls-Editor/CustomWalls-Editor.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{33BE4266-3637-4588-A297-688FF17FF023}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CustomWalls_Editor</RootNamespace>
<AssemblyName>CustomWalls</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="UnityEngine">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\CustomWalls\Data\CustomMaterialExtensions\MaterialDescriptor.cs">
<Link>Data\CustomMaterialExtensions\MaterialDescriptor.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
35 changes: 35 additions & 0 deletions CustomWalls-Editor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CustomMaterials-Editor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CustomMaterials-Editor")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("33be4266-3637-4588-a297-688ff17ff023")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
37 changes: 37 additions & 0 deletions CustomWalls.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29102.190
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomWalls", "CustomWalls\CustomWalls.csproj", "{63CE724B-0772-42F6-863D-F3AE19B6E67C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomWalls-Editor", "CustomWalls-Editor\CustomWalls-Editor.csproj", "{33BE4266-3637-4588-A297-688FF17FF023}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution items", "Solution items", "{0490B9B9-35C5-4DDC-B0D6-143EB366FBCB}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{63CE724B-0772-42F6-863D-F3AE19B6E67C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{63CE724B-0772-42F6-863D-F3AE19B6E67C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{63CE724B-0772-42F6-863D-F3AE19B6E67C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{63CE724B-0772-42F6-863D-F3AE19B6E67C}.Release|Any CPU.Build.0 = Release|Any CPU
{33BE4266-3637-4588-A297-688FF17FF023}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33BE4266-3637-4588-A297-688FF17FF023}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33BE4266-3637-4588-A297-688FF17FF023}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33BE4266-3637-4588-A297-688FF17FF023}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F7E82560-8FF3-462F-B05F-5AEFA27006C8}
EndGlobalSection
EndGlobal
123 changes: 123 additions & 0 deletions CustomWalls/CustomWalls.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{63CE724B-0772-42F6-863D-F3AE19B6E67C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CustomWalls</RootNamespace>
<AssemblyName>CustomWalls</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony.1.2.0.1">
<HintPath>$(BeatSaberDir)\Libs\0Harmony.1.2.0.1.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BSML">
<HintPath>$(BeatSaberDir)\Plugins\BSML.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BS_Utils">
<HintPath>$(BeatSaberDir)\Plugins\BS_Utils.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="HMLib">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMLib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="HMUI">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMUI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="MainAssembly">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\MainAssembly.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="IPA.Loader">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Loader.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="SemVer.1.2.0.0">
<HintPath>$(BeatSaberDir)\Libs\SemVer.1.2.0.0.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="Unity.TextMeshPro">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Unity.TextMeshPro.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.AssetBundleModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.AssetBundleModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Data\CustomMaterial.cs" />
<Compile Include="Data\CustomMaterialExtensions\MaterialDescriptor.cs" />
<Compile Include="HarmonyPatches\HarmonyPatches.cs" />
<Compile Include="HarmonyPatches\Patches\WallPatch.cs" />
<Compile Include="Logger.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings\Configuration.cs" />
<Compile Include="Settings\Utilities\PluginConfig.cs" />
<Compile Include="Settings\UI\MaterialDetailsViewController.cs" />
<Compile Include="Settings\UI\MaterialsFlowCoordinator.cs" />
<Compile Include="Settings\UI\MaterialListViewController.cs" />
<Compile Include="Settings\UI\MaterialPreviewViewController.cs" />
<Compile Include="Settings\UI\SettingsUI.cs" />
<Compile Include="Utilities\MaterialAssetLoader.cs" />
<Compile Include="Utilities\MaterialUtils.cs" />
<Compile Include="Utilities\Utils.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="manifest.json" />
<EmbeddedResource Include="Resources\description.md" />
<EmbeddedResource Include="Resources\MysticalSnowWalls.pixie" />
<EmbeddedResource Include="Resources\PixelWalls.pixie" />
<EmbeddedResource Include="Resources\PlainWalls.pixie" />
<EmbeddedResource Include="Settings\UI\Views\materialDetails.bsml" />
<EmbeddedResource Include="Settings\UI\Views\materialList.bsml" />
<EmbeddedResource Include="Settings\UI\Views\materialPreview.bsml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy "$(TargetPath)" "$(BeatSaberDir)\Plugins"</PostBuildEvent>
</PropertyGroup>
<ProjectExtensions />
</Project>
100 changes: 100 additions & 0 deletions CustomWalls/Data/CustomMaterial.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using CustomWalls.Data.CustomMaterialExtensions;
using CustomWalls.Utilities;
using System;
using System.IO;
using UnityEngine;

namespace CustomWalls.Data
{
public class CustomMaterial
{
public string FileName { get; }
public AssetBundle AssetBundle { get; }
public MaterialDescriptor Descriptor { get; }
public GameObject GameObject { get; }
public Renderer MaterialRenderer { get; }

public CustomMaterial(string fileName)
{
FileName = fileName;

if (fileName != "DefaultMaterials")
{
try
{
AssetBundle = AssetBundle.LoadFromFile(Path.Combine(Plugin.PluginAssetPath, fileName));

GameObject = AssetBundle.LoadAsset<GameObject>("Assets/_CustomMaterial.prefab");
Descriptor = GameObject.GetComponent<MaterialDescriptor>();
Descriptor.Description = Utils.SafeUnescape(Descriptor.Description);

MaterialRenderer = MaterialUtils.GetGameObjectRenderer(GameObject, "pixie");
}
catch (Exception ex)
{
Logger.log.Warn($"Something went wrong getting the AssetBundle for '{fileName}'!");
Logger.log.Warn(ex);

Descriptor = new MaterialDescriptor()
{
MaterialName = "Invalid Wall (Delete it!)",
AuthorName = fileName,
Description = $"File: '{fileName}'" +
"\n\nThis file failed to load." +
"\n\nThis may be caused by you having duplicated files or that the custom wall is simply just broken." +
"\n\nThe best thing is probably just to delete it!",
};

FileName = "DefaultMaterials";
}
}
else
{
Descriptor = new MaterialDescriptor
{
MaterialName = "Default",
AuthorName = "Beat Saber",
Description = "This is the default walls. (No preview available)",
};
}
}

public CustomMaterial(byte[] materialObject, string name)
{
if (materialObject != null)
{
try
{
AssetBundle = AssetBundle.LoadFromMemory(materialObject);
GameObject = AssetBundle.LoadAsset<GameObject>("Assets/_CustomMaterial.prefab");

FileName = $@"internalResource\{name}";
Descriptor = GameObject.GetComponent<MaterialDescriptor>();
Descriptor.Description = Utils.SafeUnescape(Descriptor.Description);
MaterialRenderer = MaterialUtils.GetGameObjectRenderer(GameObject, "pixie");
}
catch (Exception ex)
{
Logger.log.Warn($"Something went wrong getting the AssetBundle from resource!");
Logger.log.Warn(ex);

Descriptor = new MaterialDescriptor
{
MaterialName = "Internal Error (Report it!)",
AuthorName = $@"internalResource\{name}",
Description = $@"File: 'internalResource\\{name}'" +
"\n\nAn internal asset has failed to load." +
"\n\nThis shouldn't have happened and should be reported! Remember to include the log related to this incident." +
"\n\nDiscord: Pespiri#5919",
};

FileName = "DefaultMaterials";
}
}
else
{
throw new ArgumentNullException("materialObject cannot be null for the constructor!");
}
}
}
}
12 changes: 12 additions & 0 deletions CustomWalls/Data/CustomMaterialExtensions/MaterialDescriptor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using UnityEngine;

namespace CustomWalls.Data.CustomMaterialExtensions
{
public class MaterialDescriptor : MonoBehaviour
{
public string AuthorName = "Wall Author";
public string MaterialName = "Wall Name";
public string Description = string.Empty;
public Texture2D Icon;
}
}
Loading

0 comments on commit 8162d89

Please sign in to comment.