generated from Distance-Modding/Template.CSharp
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
619 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"FriendlyName": "Menu Utilities", | ||
"Description": "Extends the default distance menus with additional features.", | ||
"Author": "Reherc", | ||
"Contact": "Github: @REHERC", | ||
"ModuleFileName": "Distance.MenuUtilities.dll", | ||
"RequiredGSLs": [ | ||
"com.github.reherc/Centrifuge.Distance" | ||
], | ||
"SkipLoad": false, | ||
"Priority": 10 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using Reactor.API.Configuration; | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace Distance.MenuUtilities | ||
{ | ||
public class ConfigurationLogic : MonoBehaviour | ||
{ | ||
#region Properties | ||
public bool EnableDeletePlaylistButton | ||
{ | ||
get => Get<bool>("EnableDeletePlaylistButton"); | ||
set => Set("EnableDeletePlaylistButton", value); | ||
} | ||
|
||
public bool EnableHexColorInput | ||
{ | ||
get => Get<bool>("EnableHexColorInput"); | ||
set => Set("EnableHexColorInput", value); | ||
} | ||
#endregion | ||
|
||
internal Settings Config; | ||
|
||
public event Action<ConfigurationLogic> OnChanged; | ||
|
||
private void Load() | ||
{ | ||
Config = new Settings("Config"); | ||
} | ||
|
||
public void Awake() | ||
{ | ||
Load(); | ||
|
||
Get("EnableDeletePlaylistButton", true); | ||
Get("EnableHexColorInput", true); | ||
|
||
Save(); | ||
} | ||
|
||
public T Get<T>(string key, T @default = default) | ||
{ | ||
return Config.GetOrCreate(key, @default); | ||
} | ||
|
||
public void Set<T>(string key, T value) | ||
{ | ||
Config[key] = value; | ||
Save(); | ||
} | ||
|
||
public void Save() | ||
{ | ||
Config?.Save(); | ||
OnChanged?.Invoke(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="15.0"> | ||
<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>{7BCB2908-B003-45D9-BE68-50CBA5217603}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Distance.MenuUtilities</RootNamespace> | ||
<AssemblyName>Distance.MenuUtilities</AssemblyName> | ||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</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="0Harmony, Version=2.5.1.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\HarmonyX.2.5.1\lib\net35\0Harmony.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Assembly-CSharp, Version=9.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Centrifuge.GameSupport.Distance.3.0.7868.41513\lib\net35\Assembly-CSharp.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Centrifuge.Distance, Version=3.0.7868.41513, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Centrifuge.GameSupport.Distance.3.0.7868.41513\lib\net35\Centrifuge.Distance.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Mono.Cecil, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Mono.Cecil.Mdb, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.Mdb.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Mono.Cecil.Pdb, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.Pdb.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Mono.Cecil.Rocks, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.Rocks.dll</HintPath> | ||
</Reference> | ||
<Reference Include="MonoMod.RuntimeDetour, Version=21.7.8.3, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\MonoMod.RuntimeDetour.21.7.8.3\lib\net35\MonoMod.RuntimeDetour.dll</HintPath> | ||
</Reference> | ||
<Reference Include="MonoMod.Utils, Version=21.7.8.3, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\MonoMod.Utils.21.7.8.3\lib\net35\MonoMod.Utils.dll</HintPath> | ||
</Reference> | ||
<Reference Include="NAudio, Version=1.7.3.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Centrifuge.GameSupport.Distance.3.0.7868.41513\lib\net35\NAudio.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Json.Net.Unity3D.9.0.1\lib\net35\Newtonsoft.Json.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Reactor.API, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Centrifuge.Mod.SDK.3.2.0\lib\net35\Reactor.API.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Centrifuge.GameSupport.Distance.3.0.7868.41513\lib\net35\UnityEngine.dll</HintPath> | ||
</Reference> | ||
<Reference Include="UnityEngine.Networking, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Centrifuge.GameSupport.Distance.3.0.7868.41513\lib\net35\UnityEngine.Networking.dll</HintPath> | ||
</Reference> | ||
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Centrifuge.GameSupport.Distance.3.0.7868.41513\lib\net35\UnityEngine.UI.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="ConfigurationLogic.cs" /> | ||
<Compile Include="Mod.cs" /> | ||
<Compile Include="Extensions\Assembly-CSharp\CustomizeCarColorsMenuLogic.cs" /> | ||
<Compile Include="Extensions\Assembly-CSharp\LevelPlaylist.cs" /> | ||
<Compile Include="Extensions\mscorlib\System\String.cs" /> | ||
<Compile Include="Harmony\Assembly-CSharp\CustomizeCarColorsMenuLogic\Awake.cs" /> | ||
<Compile Include="Harmony\Assembly-CSharp\CustomizeCarColorsMenuLogic\OnColorPickerPop.cs" /> | ||
<Compile Include="Harmony\Assembly-CSharp\CustomizeCarColorsMenuLogic\PickColorForType.cs" /> | ||
<Compile Include="Harmony\Assembly-CSharp\CustomizeCarColorsMenuLogic\UpdateColorPickerInput.cs" /> | ||
<Compile Include="Harmony\Assembly-CSharp\LevelGridGrid\PushGrid.cs" /> | ||
<Compile Include="Harmony\Assembly-CSharp\LevelGridGrid\Update.cs" /> | ||
<Compile Include="Harmony\Assembly-CSharp\LevelPlaylist\Load.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Resources\Constants.cs" /> | ||
<Compile Include="Resources\Strings.cs" /> | ||
<Compile Include="Scripts\CustomizeMenuCompoundData.cs" /> | ||
<Compile Include="Scripts\LevelPlaylistCompoundData.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<PropertyGroup> | ||
<!-- 15.0 is for VS2017, adjust if necessary --> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
<!-- This is what will cause the templates to be transformed when the project is built (default is false) --> | ||
<TransformOnBuild>true</TransformOnBuild> | ||
<!-- Set to true to force overwriting of read-only output files, e.g. if they're not checked out (default is false) --> | ||
<OverwriteReadOnlyOutputFiles>true</OverwriteReadOnlyOutputFiles> | ||
<!-- Set to false to transform files even if the output appears to be up-to-date (default is true) --> | ||
<TransformOutOfDateOnly>false</TransformOutOfDateOnly> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\TextTemplating\Microsoft.TextTemplating.targets" /> | ||
<Import Project="$(SolutionDir)Tool.BuildTargets\Distance.Modding.props" /> | ||
<Import Project="$(SolutionDir)Tool.BuildTargets\Distance.Modding.targets" /> | ||
</Project> |
28 changes: 28 additions & 0 deletions
28
Distance.MenuUtilities/Extensions/Assembly-CSharp/CustomizeCarColorsMenuLogic.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma warning disable RCS1110 | ||
using Distance.MenuUtilities.Scripts; | ||
using System; | ||
|
||
public static class CustomizeCarColorsMenuLogicExtensions | ||
{ | ||
public static void SetThirdAction(this CustomizeCarColorsMenuLogic menu, string text, InputAction input, Action callback) | ||
{ | ||
CustomizeMenuCompoundData data = menu.GetComponent<CustomizeMenuCompoundData>(); | ||
|
||
if (data) | ||
{ | ||
data.OnButtonClick = callback; | ||
|
||
menu.deleteButton_.GetComponentInChildren<UILabel>().text = text; | ||
ControlsBasedUITexture texture = menu.deleteButton_.GetComponent<ControlsBasedUITexture>(); | ||
|
||
texture.inputAction_ = input; | ||
texture.EvaluateLatestUsedDevice(); | ||
} | ||
} | ||
|
||
public static void SetThirdActionEnabled(this CustomizeCarColorsMenuLogic menu, bool value) | ||
{ | ||
menu.deleteButton_.gameObject.SetActive(value); | ||
menu.deleteButton_.enabled = value; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
Distance.MenuUtilities/Extensions/Assembly-CSharp/LevelPlaylist.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma warning disable RCS1110 | ||
using Distance.MenuUtilities.Scripts; | ||
using System; | ||
using System.IO; | ||
using UnityEngine; | ||
|
||
public static class LevelPlaylistExtensions | ||
{ | ||
public static bool IsResourcesPlaylist(this LevelPlaylist playlist) | ||
{ | ||
LevelPlaylistCompoundData data = playlist.gameObject.GetComponent<LevelPlaylistCompoundData>(); | ||
|
||
if (!data) | ||
{ | ||
return true; | ||
} | ||
|
||
string path = new FileInfo(data.FilePath).FullName.UniformPathName(); | ||
string resourcesPath = new DirectoryInfo(Path.Combine(Application.dataPath, "Resources")).FullName.UniformPathName(); | ||
|
||
return path.StartsWith(resourcesPath, StringComparison.InvariantCultureIgnoreCase); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Distance.MenuUtilities/Extensions/mscorlib/System/String.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma warning disable RCS1110 | ||
using System.IO; | ||
|
||
public static class StringExtensions | ||
{ | ||
public static string UniformPathName(this string source) | ||
{ | ||
string result = source.ToLowerInvariant(); | ||
|
||
result = result.Replace(Path.DirectorySeparatorChar, '/'); | ||
result = result.Replace(Path.AltDirectorySeparatorChar, '/'); | ||
result = result.Replace('\\', '/'); | ||
|
||
return result; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Distance.MenuUtilities/Harmony/Assembly-CSharp/CustomizeCarColorsMenuLogic/Awake.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Distance.MenuUtilities.Scripts; | ||
using HarmonyLib; | ||
|
||
namespace Distance.MenuUtilities.Harmony | ||
{ | ||
[HarmonyPatch(typeof(CustomizeCarColorsMenuLogic), "Awake")] | ||
internal static class CustomizeCarColorsMenuLogic__Awake | ||
{ | ||
[HarmonyPostfix] | ||
internal static void Postfix(CustomizeCarColorsMenuLogic __instance) | ||
{ | ||
CustomizeMenuCompoundData data = __instance.gameObject.AddComponent<CustomizeMenuCompoundData>(); | ||
data.Menu = __instance; | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...nce.MenuUtilities/Harmony/Assembly-CSharp/CustomizeCarColorsMenuLogic/OnColorPickerPop.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Distance.MenuUtilities.Scripts; | ||
using HarmonyLib; | ||
|
||
namespace Distance.MenuUtilities.Harmony | ||
{ | ||
[HarmonyPatch(typeof(CustomizeCarColorsMenuLogic), "OnColorPickerPop")] | ||
internal static class CustomizeCarColorsMenuLogic__OnColorPickerPop | ||
{ | ||
[HarmonyPostfix] | ||
internal static void Postfix(CustomizeCarColorsMenuLogic __instance) | ||
{ | ||
CustomizeMenuCompoundData data = __instance.GetComponent<CustomizeMenuCompoundData>(); | ||
|
||
if (data) | ||
{ | ||
data.ColorType = ColorChanger.ColorType.Size_; | ||
|
||
__instance.SetThirdActionEnabled(false); | ||
__instance.SetThirdAction(string.Empty, InputAction.MenuDoNotUse, null); | ||
} | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...nce.MenuUtilities/Harmony/Assembly-CSharp/CustomizeCarColorsMenuLogic/PickColorForType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Distance.MenuUtilities.Scripts; | ||
using HarmonyLib; | ||
|
||
namespace Distance.MenuUtilities.Harmony | ||
{ | ||
[HarmonyPatch(typeof(CustomizeCarColorsMenuLogic), "PickColorForType")] | ||
internal static class CustomizeCarColorsMenuLogic__PickColorForType | ||
{ | ||
[HarmonyPostfix] | ||
internal static void Postfix(CustomizeCarColorsMenuLogic __instance, ColorChanger.ColorType colorType) | ||
{ | ||
CustomizeMenuCompoundData data = __instance.GetComponent<CustomizeMenuCompoundData>(); | ||
|
||
if (data && Mod.Instance.Config.EnableHexColorInput) | ||
{ | ||
data.ColorType = colorType; | ||
|
||
__instance.SetThirdActionEnabled(true); | ||
__instance.SetThirdAction("EDIT", InternalResources.Constants.INPUT_EDIT_COLOR, data.EditHexClick); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.