Skip to content

Commit

Permalink
chore: Add BepInEx 5 project
Browse files Browse the repository at this point in the history
  • Loading branch information
Repflez committed May 24, 2022
1 parent b21cabb commit d3fb19a
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 74 deletions.
8 changes: 4 additions & 4 deletions OfflineSaveLoad.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using HarmonyLib;

namespace TaikoModStuff
{
using HarmonyLib;

namespace TaikoModStuff
{
[HarmonyPatch]
public class OfflineSaveLoad
{
Expand Down
154 changes: 84 additions & 70 deletions Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,60 +1,70 @@
using BepInEx;
using BepInEx.IL2CPP;
using BepInEx.Configuration;
using HarmonyLib;

namespace TaikoModStuff
{
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
public class Plugin : BasePlugin
{
public static ConfigEntry<bool> configForceFontChange;

public static ConfigEntry<int> configCustomWindowedWidth;
public static ConfigEntry<int> configCustomWindowedHeight;

public static ConfigEntry<int> configCustomFramerate;
public static ConfigEntry<bool> configToggleVSync;

using BepInEx;
#if !BEPIN_5
using BepInEx.IL2CPP;
#endif
using BepInEx.Configuration;
using HarmonyLib;

namespace TaikoModStuff
{
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
#if !BEPIN_5
public class Plugin : BasePlugin
#else
public class Plugin : BaseUnityPlugin
#endif
{
public static ConfigEntry<bool> configForceFontChange;

public static ConfigEntry<int> configCustomWindowedWidth;
public static ConfigEntry<int> configCustomWindowedHeight;

public static ConfigEntry<int> configCustomFramerate;
public static ConfigEntry<bool> configToggleVSync;

public static ConfigEntry<bool> configEnableRecording;

public static ConfigEntry<bool> configOfflineSaveLoad;
public static ConfigEntry<bool> configQuickRestart;
public static ConfigEntry<bool> configQuickQuitSong;

public override void Load()
{
// Add configurations
configForceFontChange = Config.Bind("General.Toggles",
"ForceFontChange",
false,
"Force the game font to the JP font");

configCustomWindowedWidth = Config.Bind("General.Resolution",
"CustomWidth",
1920,
"Custom width to use. Set to 0 to disable setting the custom resolution");

configCustomWindowedHeight = Config.Bind("General.Resolution",
"CustomHeight",
1080,
"Custom height to use");

configCustomFramerate = Config.Bind("General.Framerate",
"CustomFramerate",
60,
"Custom framerate.");

configToggleVSync = Config.Bind("General.Graphics",
"EnableVSync",
true,
"Enable VSync.");

configEnableRecording = Config.Bind("General.Toggles",
"EnableGameBarRecording",
true,
"Enables Game Recording from the Xbox Game Bar where it was previously disabled.");

public static ConfigEntry<bool> configOfflineSaveLoad;
public static ConfigEntry<bool> configQuickRestart;
public static ConfigEntry<bool> configQuickQuitSong;

#if !BEPIN_5
public override void Load()
#else
private void Awake()
#endif
{
// Add configurations
configForceFontChange = Config.Bind("General.Toggles",
"ForceFontChange",
false,
"Force the game font to the JP font");

configCustomWindowedWidth = Config.Bind("General.Resolution",
"CustomWidth",
1920,
"Custom width to use. Set to 0 to disable setting the custom resolution");

configCustomWindowedHeight = Config.Bind("General.Resolution",
"CustomHeight",
1080,
"Custom height to use");

configCustomFramerate = Config.Bind("General.Framerate",
"CustomFramerate",
60,
"Custom framerate.");

configToggleVSync = Config.Bind("General.Graphics",
"EnableVSync",
true,
"Enable VSync.");

configEnableRecording = Config.Bind("General.Toggles",
"EnableGameBarRecording",
true,
"Enables Game Recording from the Xbox Game Bar where it was previously disabled.");

configOfflineSaveLoad = Config.Bind("General.Toggles",
"OfflineSaveLoad",
false,
Expand All @@ -63,17 +73,17 @@ public override void Load()
configQuickRestart = Config.Bind("General.Toggles",
"QuickRestart",
false,
"Hit \"Backspace\" on your keyboard to quickly restart a song.");

"Hit \"Backspace\" on your keyboard to quickly restart a song.");

configQuickQuitSong = Config.Bind("General.Toggles",
"QuickQuitSong",
false,
"Hit \"Escape\" on your keyboard to quickly quit a song and return to Song Select.");


var instance = new Harmony(PluginInfo.PLUGIN_NAME);
instance.PatchAll(typeof(FontChanger));
instance.PatchAll(typeof(CustomResolution));
"Hit \"Escape\" on your keyboard to quickly quit a song and return to Song Select.");


var instance = new Harmony(PluginInfo.PLUGIN_NAME);
instance.PatchAll(typeof(FontChanger));
instance.PatchAll(typeof(CustomResolution));
instance.PatchAll(typeof(ForceFramerate));
instance.PatchAll(typeof(RecordingEnable));

Expand All @@ -84,10 +94,14 @@ public override void Load()
instance.PatchAll(typeof(QuickRestart));

if (Plugin.configQuickQuitSong.Value)
instance.PatchAll(typeof(QuickQuitSong));

// Plugin startup logic
Log.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
}
}
}
instance.PatchAll(typeof(QuickQuitSong));

// Plugin startup logic
#if !BEPIN_5
Log.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
#else
Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
#endif
}
}
}
4 changes: 4 additions & 0 deletions RecordingEnable.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using HarmonyLib;
#if !BEPIN_5
using Il2CppMicrosoft.Xbox;
#else
using Microsoft.Xbox;
#endif

namespace TaikoModStuff
{
Expand Down
35 changes: 35 additions & 0 deletions TaikoModStuff-Bepin5.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net46</TargetFramework>
<AssemblyName>TaikoModStuff</AssemblyName>
<Description>My first plugin</Description>
<Version>1.3.0</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<PackageId>TaikoModStuff</PackageId>
<Authors>TaikoModStuff</Authors>
<Product>TaikoModStuff</Product>
<RootNamespace>TaikoModStuff</RootNamespace>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>$(DefineConstants)TRACE;BEPIN_5</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>$(DefineConstants)TRACE;BEPIN_5</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
<PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="UnityEngine.Modules" Version="2020.3.19" IncludeAssets="compile" />
<PackageReference Include="Taiko.GameLibs" Version="1.2.2-r.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
</ItemGroup>
</Project>

0 comments on commit d3fb19a

Please sign in to comment.