Skip to content

Commit 9fb7cf6

Browse files
authored
Remove BepInEx4 compatibility (#46)
Remove obsolete classes and BepIn4Patcher dependency Use nuget for packages instead of local libs Closes #42
1 parent 9b65805 commit 9fb7cf6

21 files changed

Lines changed: 71 additions & 716 deletions

ConfigurationManager/ConfigurationManager.cs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,6 @@ private void BuildFilteredSettingList()
185185
}
186186

187187
const string shortcutsCatName = "Keyboard shortcuts";
188-
string GetCategory(SettingEntryBase eb)
189-
{
190-
#pragma warning disable 618 // Disable obsolete warning
191-
// Legacy behavior
192-
if (eb.SettingType == typeof(BepInEx.KeyboardShortcut)) return shortcutsCatName;
193-
#pragma warning restore 618
194-
return eb.Category;
195-
}
196188

197189
var settingsAreCollapsed = _pluginConfigCollapsedDefault.Value;
198190

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

232224
private static bool IsKeyboardShortcut(SettingEntryBase x)
233225
{
234-
#pragma warning disable 618 // Disable obsolete warning
235-
return x.SettingType == typeof(BepInEx.KeyboardShortcut) || x.SettingType == typeof(BepInEx.Configuration.KeyboardShortcut);
236-
#pragma warning restore 618
226+
return x.SettingType == typeof(KeyboardShortcut);
237227
}
238228

239229
private static bool ContainsSearchString(SettingEntryBase setting, string[] searchStrings)
@@ -591,12 +581,6 @@ bool DrawDefaultButton()
591581
if (DrawDefaultButton())
592582
setting.Set(setting.DefaultValue);
593583
}
594-
else if (setting is LegacySettingEntry legacySetting && legacySetting.Wrapper != null)
595-
{
596-
var method = legacySetting.Wrapper.GetType().GetMethod("Clear", BindingFlags.Instance | BindingFlags.Public);
597-
if (method != null && DrawDefaultButton())
598-
method.Invoke(legacySetting.Wrapper, null);
599-
}
600584
else if (setting.SettingType.IsClass)
601585
{
602586
if (DrawDefaultButton())

ConfigurationManager/ConfigurationManager.csproj

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<AssemblyName>ConfigurationManager</AssemblyName>
1212
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
14+
<NuGetPackageImportStamp>
15+
</NuGetPackageImportStamp>
1416
</PropertyGroup>
1517
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1618
<DebugSymbols>true</DebugSymbols>
@@ -32,43 +34,34 @@
3234
<DocumentationFile>..\bin\BepInEx\plugins\ConfigurationManager.xml</DocumentationFile>
3335
</PropertyGroup>
3436
<ItemGroup>
35-
<Reference Include="BepInEx">
36-
<HintPath>..\lib\BepInEx.dll</HintPath>
37-
<Private>False</Private>
38-
</Reference>
39-
<Reference Include="BepInEx.BepIn4Patcher">
40-
<HintPath>..\lib\BepInEx.BepIn4Patcher.dll</HintPath>
41-
<Private>False</Private>
37+
<Reference Include="BepInEx, Version=5.4.15.0, Culture=neutral, processorArchitecture=MSIL">
38+
<HintPath>..\packages\BepInEx.BaseLib.5.4.15\lib\net35\BepInEx.dll</HintPath>
4239
</Reference>
4340
<Reference Include="System" />
4441
<Reference Include="System.Core" />
45-
<Reference Include="UnityEngine">
46-
<HintPath>..\lib\UnityEngine.dll</HintPath>
47-
<Private>False</Private>
42+
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
43+
<HintPath>..\packages\UnityEngine.5.6.1\lib\net35\UnityEngine.dll</HintPath>
4844
</Reference>
4945
</ItemGroup>
5046
<ItemGroup>
5147
<Compile Include="ConfigSettingEntry.cs" />
52-
<Compile Include="Obsolete\LegacySettingSearcher.cs" />
53-
<Compile Include="Obsolete\Interface\AcceptableValueBaseAttribute.cs" />
54-
<Compile Include="Obsolete\Interface\AcceptableValueListAttribute.cs" />
55-
<Compile Include="Obsolete\Interface\AcceptableValueRangeAttribute.cs" />
56-
<Compile Include="Obsolete\Interface\AdvancedAttribute.cs" />
57-
<Compile Include="Obsolete\Interface\CustomSettingDrawAttribute.cs" />
48+
<Compile Include="PropertySettingEntry.cs" />
5849
<Compile Include="SettingSearcher.cs" />
5950
<Compile Include="Utilities\ComboBox.cs" />
6051
<Compile Include="ConfigurationManager.cs" />
61-
<Compile Include="Obsolete\Interface\KeyboardShortcut.cs" />
6252
<Compile Include="Properties\AssemblyInfo.cs" />
63-
<Compile Include="Obsolete\Interface\SavedKeyboardShortcut.cs" />
64-
<Compile Include="Obsolete\LegacySettingEntry.cs" />
6553
<Compile Include="SettingEntryBase.cs" />
6654
<Compile Include="SettingFieldDrawer.cs" />
67-
<Compile Include="Obsolete\FieldToPropertyInfoWrapper.cs" />
6855
<Compile Include="Utilities\Utilities.cs" />
6956
<Compile Include="ValueChangedEventArgs.cs" />
7057
</ItemGroup>
71-
<ItemGroup />
58+
<ItemGroup>
59+
<None Include="packages.config" />
60+
</ItemGroup>
61+
<ItemGroup>
62+
<Analyzer Include="..\packages\BepInEx.Analyzers.1.0.8\analyzers\dotnet\cs\BepInEx.Analyzers.CodeFixes.dll" />
63+
<Analyzer Include="..\packages\BepInEx.Analyzers.1.0.8\analyzers\dotnet\cs\BepInEx.Analyzers.dll" />
64+
</ItemGroup>
7265
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
7366
<PropertyGroup>
7467
<PostBuildEvent>IF EXIST $(SolutionDir)PostBuild.bat CALL "$(SolutionDir)PostBuild.bat" $(TargetPath) KK

ConfigurationManager/Obsolete/FieldToPropertyInfoWrapper.cs

Lines changed: 0 additions & 43 deletions
This file was deleted.

ConfigurationManager/Obsolete/Interface/AcceptableValueBaseAttribute.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

ConfigurationManager/Obsolete/Interface/AcceptableValueListAttribute.cs

Lines changed: 0 additions & 58 deletions
This file was deleted.

ConfigurationManager/Obsolete/Interface/AcceptableValueRangeAttribute.cs

Lines changed: 0 additions & 42 deletions
This file was deleted.

ConfigurationManager/Obsolete/Interface/AdvancedAttribute.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

ConfigurationManager/Obsolete/Interface/CustomSettingDrawAttribute.cs

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)