Skip to content

Commit

Permalink
Remove BepInEx4 compatibility (#46)
Browse files Browse the repository at this point in the history
Remove obsolete classes and BepIn4Patcher dependency
Use nuget for packages instead of local libs
Closes #42
  • Loading branch information
ManlyMarco committed Jun 4, 2022
1 parent 9b65805 commit 9fb7cf6
Show file tree
Hide file tree
Showing 21 changed files with 71 additions and 716 deletions.
20 changes: 2 additions & 18 deletions ConfigurationManager/ConfigurationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,6 @@ private void BuildFilteredSettingList()
}

const string shortcutsCatName = "Keyboard shortcuts";
string GetCategory(SettingEntryBase eb)
{
#pragma warning disable 618 // Disable obsolete warning
// Legacy behavior
if (eb.SettingType == typeof(BepInEx.KeyboardShortcut)) return shortcutsCatName;
#pragma warning restore 618
return eb.Category;
}

var settingsAreCollapsed = _pluginConfigCollapsedDefault.Value;

Expand All @@ -210,7 +202,7 @@ string GetCategory(SettingEntryBase eb)
.Select(pluginSettings =>
{
var categories = pluginSettings
.GroupBy(GetCategory)
.GroupBy(eb => eb.Category)
.OrderBy(x => string.Equals(x.Key, shortcutsCatName, StringComparison.Ordinal))
.ThenBy(x => x.Key)
.Select(x => new PluginSettingsData.PluginSettingsGroupData { Name = x.Key, Settings = x.OrderByDescending(set => set.Order).ThenBy(set => set.DispName).ToList() });
Expand All @@ -231,9 +223,7 @@ string GetCategory(SettingEntryBase eb)

private static bool IsKeyboardShortcut(SettingEntryBase x)
{
#pragma warning disable 618 // Disable obsolete warning
return x.SettingType == typeof(BepInEx.KeyboardShortcut) || x.SettingType == typeof(BepInEx.Configuration.KeyboardShortcut);
#pragma warning restore 618
return x.SettingType == typeof(KeyboardShortcut);
}

private static bool ContainsSearchString(SettingEntryBase setting, string[] searchStrings)
Expand Down Expand Up @@ -591,12 +581,6 @@ bool DrawDefaultButton()
if (DrawDefaultButton())
setting.Set(setting.DefaultValue);
}
else if (setting is LegacySettingEntry legacySetting && legacySetting.Wrapper != null)
{
var method = legacySetting.Wrapper.GetType().GetMethod("Clear", BindingFlags.Instance | BindingFlags.Public);
if (method != null && DrawDefaultButton())
method.Invoke(legacySetting.Wrapper, null);
}
else if (setting.SettingType.IsClass)
{
if (DrawDefaultButton())
Expand Down
35 changes: 14 additions & 21 deletions ConfigurationManager/ConfigurationManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<AssemblyName>ConfigurationManager</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -32,43 +34,34 @@
<DocumentationFile>..\bin\BepInEx\plugins\ConfigurationManager.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="BepInEx">
<HintPath>..\lib\BepInEx.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BepInEx.BepIn4Patcher">
<HintPath>..\lib\BepInEx.BepIn4Patcher.dll</HintPath>
<Private>False</Private>
<Reference Include="BepInEx, Version=5.4.15.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\BepInEx.BaseLib.5.4.15\lib\net35\BepInEx.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="UnityEngine">
<HintPath>..\lib\UnityEngine.dll</HintPath>
<Private>False</Private>
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\UnityEngine.5.6.1\lib\net35\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ConfigSettingEntry.cs" />
<Compile Include="Obsolete\LegacySettingSearcher.cs" />
<Compile Include="Obsolete\Interface\AcceptableValueBaseAttribute.cs" />
<Compile Include="Obsolete\Interface\AcceptableValueListAttribute.cs" />
<Compile Include="Obsolete\Interface\AcceptableValueRangeAttribute.cs" />
<Compile Include="Obsolete\Interface\AdvancedAttribute.cs" />
<Compile Include="Obsolete\Interface\CustomSettingDrawAttribute.cs" />
<Compile Include="PropertySettingEntry.cs" />
<Compile Include="SettingSearcher.cs" />
<Compile Include="Utilities\ComboBox.cs" />
<Compile Include="ConfigurationManager.cs" />
<Compile Include="Obsolete\Interface\KeyboardShortcut.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Obsolete\Interface\SavedKeyboardShortcut.cs" />
<Compile Include="Obsolete\LegacySettingEntry.cs" />
<Compile Include="SettingEntryBase.cs" />
<Compile Include="SettingFieldDrawer.cs" />
<Compile Include="Obsolete\FieldToPropertyInfoWrapper.cs" />
<Compile Include="Utilities\Utilities.cs" />
<Compile Include="ValueChangedEventArgs.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\BepInEx.Analyzers.1.0.8\analyzers\dotnet\cs\BepInEx.Analyzers.CodeFixes.dll" />
<Analyzer Include="..\packages\BepInEx.Analyzers.1.0.8\analyzers\dotnet\cs\BepInEx.Analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>IF EXIST $(SolutionDir)PostBuild.bat CALL "$(SolutionDir)PostBuild.bat" $(TargetPath) KK
Expand Down
43 changes: 0 additions & 43 deletions ConfigurationManager/Obsolete/FieldToPropertyInfoWrapper.cs

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions ConfigurationManager/Obsolete/Interface/AdvancedAttribute.cs

This file was deleted.

This file was deleted.

Loading

0 comments on commit 9fb7cf6

Please sign in to comment.
  翻译: