Skip to content

Commit c2dd024

Browse files
authored
Merge pull request #1 from NullScope/development
Initial Code Commit (#1)
2 parents 05ab4bb + ccfa32e commit c2dd024

File tree

10 files changed

+163
-104
lines changed

10 files changed

+163
-104
lines changed

Assets/example_item.png

-883 Bytes
Binary file not shown.
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<AssemblyName>CotLTemplateMod</AssemblyName>
4+
<AssemblyName>CotLAutoGraphicsSettings</AssemblyName>
55
<AssemblyVersion>1.0.0</AssemblyVersion>
66
<ReleaseVersion>1.0.0</ReleaseVersion>
77
<TargetFramework>netstandard2.0</TargetFramework>
@@ -12,6 +12,11 @@
1212
<OutputPath Condition=" '$(SolutionDir)' != '' ">$(SolutionDir)bin\$(Configuration)\$(MSBuildProjectName)\</OutputPath>
1313
<OutputPath Condition=" '$(SolutionDir)' == '' ">$(ProjectDir)bin\$(Configuration)\$(MSBuildProjectName)\</OutputPath>
1414
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
15+
<RootNamespace>CotLAutoGraphicsSettings</RootNamespace>
16+
</PropertyGroup>
17+
<PropertyGroup>
18+
<!-- Disable "Forced Access" warning -->
19+
<NoWarn>Publicizer001</NoWarn>
1520
</PropertyGroup>
1621

1722
<ItemGroup>
@@ -25,13 +30,13 @@
2530
</ItemGroup>
2631

2732
<ItemGroup>
28-
<PackageReference Include="CultOfTheLamb.GameLibs" Version="1.0.12-*" />
33+
<PackageReference Include="CultOfTheLamb.GameLibs" Version="*-*" />
2934
</ItemGroup>
30-
35+
3136
<ItemGroup>
32-
<Reference Include="COTL_API" Private="false">
33-
<HintPath>lib\COTL_API.dll</HintPath>
34-
</Reference>
37+
<Folder Include="Assets\" />
38+
<Folder Include="FollowerCommands\" />
39+
<Folder Include="Items\" />
3540
</ItemGroup>
3641

3742
</Project>
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 17
4-
VisualStudioVersion = 17.1.32414.318
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.33529.622
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CotLTemplateMod", "CotLTemplateMod.csproj", "{ECC3B42E-48E6-451D-8C3D-CF20182CCF9F}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CotLAutoGraphicsSettings", "CotLAutoGraphicsSettings.csproj", "{A65804E0-144B-491F-AD36-959EBCE352EC}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{ECC3B42E-48E6-451D-8C3D-CF20182CCF9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{ECC3B42E-48E6-451D-8C3D-CF20182CCF9F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{ECC3B42E-48E6-451D-8C3D-CF20182CCF9F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{ECC3B42E-48E6-451D-8C3D-CF20182CCF9F}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{A65804E0-144B-491F-AD36-959EBCE352EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{A65804E0-144B-491F-AD36-959EBCE352EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{A65804E0-144B-491F-AD36-959EBCE352EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{A65804E0-144B-491F-AD36-959EBCE352EC}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE
2121
EndGlobalSection
2222
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {C4E102CA-CDBE-4092-BBFE-DADC4BE1D863}
23+
SolutionGuid = {5B2B3098-224B-48BE-B4BC-4B62A54B1905}
2424
EndGlobalSection
2525
EndGlobal

FollowerCommands/ExampleFollowerCommand.cs

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

Items/ExampleItem.cs

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

Patches/ExamplePatch.cs

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

Patches/GraphicsSettingsPatches.cs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using HarmonyLib;
2+
using Lamb.UI;
3+
4+
namespace CotLAutoGraphicsSettings.Patches
5+
{
6+
[HarmonyPatch]
7+
class GraphicsSettingsPatches
8+
{
9+
[HarmonyPostfix]
10+
[HarmonyPatch(typeof(UIManager), nameof(UIManager.Start))]
11+
public static void UIManager_Start()
12+
{
13+
Plugin.SetupConfig();
14+
Plugin.ApplySettings();
15+
}
16+
17+
[HarmonyPostfix]
18+
[HarmonyPatch(typeof(SettingsManager), nameof(SettingsManager.SaveSettings))]
19+
public static void SettingsManager_SaveSettings()
20+
{
21+
if (!LocationManager._Instance)
22+
{
23+
Plugin.SaveDefaultGraphics();
24+
return;
25+
}
26+
27+
switch(LocationManager._Instance.Location)
28+
{
29+
case FollowerLocation.Base:
30+
case FollowerLocation.DoorRoom:
31+
Plugin.SaveBaseGraphics();
32+
break;
33+
default:
34+
Plugin.SaveDefaultGraphics();
35+
break;
36+
}
37+
}
38+
39+
[HarmonyPostfix]
40+
[HarmonyPatch(typeof(LocationManager), nameof(LocationManager.EndLoadLocation))]
41+
public static void LocationManager_EndLoadLocation(FollowerLocation location)
42+
{
43+
Plugin.Log.LogError(location);
44+
switch(location)
45+
{
46+
// These are all called during loading of the Cult Base,
47+
// so we can ignore these in favor of FollowerLocation.Base which is called last.
48+
case FollowerLocation.Church:
49+
case FollowerLocation.Lumberjack:
50+
case FollowerLocation.DoorRoom:
51+
return;
52+
53+
default:
54+
Plugin.ApplySettings(location);
55+
break;
56+
57+
}
58+
}
59+
}
60+
61+
}

Plugin.cs

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,38 @@
1+
using System.IO;
12
using BepInEx;
3+
using BepInEx.Configuration;
24
using BepInEx.Logging;
35
using HarmonyLib;
4-
using COTL_API.CustomInventory;
5-
using CotLTemplateMod.Items;
6-
using System.IO;
7-
using static InventoryItem;
8-
using COTL_API.CustomFollowerCommand;
9-
using CotLTemplateMod.CustomFollowerCommands;
6+
using Newtonsoft.Json;
107

11-
namespace CotLTemplateMod
8+
namespace CotLAutoGraphicsSettings
129
{
1310
[BepInPlugin(PluginGuid, PluginName, PluginVer)]
14-
[BepInDependency("io.github.xhayper.COTL_API")]
1511
[HarmonyPatch]
1612
public class Plugin : BaseUnityPlugin
1713
{
18-
public const string PluginGuid = "IngoH.cotl.CotLTemplateMod";
19-
public const string PluginName = "CotLTemplateMod";
14+
public const string PluginGuid = "io.github.NullScope.CotLAutoGraphicsSettings";
15+
public const string PluginName = "CotLAutoGraphicsSettings";
2016
public const string PluginVer = "1.0.0";
2117

2218
internal static ManualLogSource Log;
2319
internal readonly static Harmony Harmony = new(PluginGuid);
2420

2521
internal static string PluginPath;
22+
internal static ConfigFile Cfg;
2623

27-
internal static ITEM_TYPE ExampleItem;
24+
internal static ConfigEntry<string> DefaultGraphicsConfig = null!;
25+
internal static ConfigEntry<string> CultBaseGraphicsConfig = null!;
2826

29-
internal static FollowerCommands FollowerCommand;
27+
internal static SettingsData.GraphicsSettings DefaultGraphics = null!;
28+
internal static SettingsData.GraphicsSettings CultBaseGraphics = null!;
3029

3130
private void Awake()
3231
{
3332
Plugin.Log = base.Logger;
33+
Plugin.Cfg = base.Config;
3434

35-
PluginPath = Path.GetDirectoryName(Info.Location);
36-
37-
ExampleItem = CustomItemManager.Add(new ExampleItem());
38-
FollowerCommand = CustomFollowerCommandManager.Add(new ExampleFollowerCommand());
35+
Plugin.PluginPath = Path.GetDirectoryName(Info.Location);
3936
}
4037

4138
private void OnEnable()
@@ -49,5 +46,48 @@ private void OnDisable()
4946
Harmony.UnpatchSelf();
5047
Logger.LogInfo($"Unloaded {PluginName}!");
5148
}
49+
50+
public static SettingsData.GraphicsSettings CloneSettings (SettingsData.GraphicsSettings settings)
51+
{
52+
var newSettings = new SettingsData.GraphicsSettings(settings);
53+
// For some reason the constructor does not copy over the AntiAliasing option, so we set it here.
54+
newSettings.AntiAliasing = settings.AntiAliasing;
55+
56+
return newSettings;
57+
}
58+
59+
public static void SetupConfig()
60+
{
61+
DefaultGraphicsConfig = Cfg.Bind("Graphics", "Default", JsonConvert.SerializeObject(SettingsManager.Settings.Graphics), "Default Graphics Settings");
62+
CultBaseGraphicsConfig = Cfg.Bind("Graphics", "Base", JsonConvert.SerializeObject(SettingsManager.Settings.Graphics), "Cult Base Graphics Settings");
63+
DefaultGraphics = JsonConvert.DeserializeObject<SettingsData.GraphicsSettings>(DefaultGraphicsConfig.Value);
64+
CultBaseGraphics = JsonConvert.DeserializeObject<SettingsData.GraphicsSettings>(CultBaseGraphicsConfig.Value);
65+
}
66+
67+
public static void SaveDefaultGraphics()
68+
{
69+
DefaultGraphicsConfig.BoxedValue = JsonConvert.SerializeObject(SettingsManager.Settings.Graphics);
70+
DefaultGraphics = CloneSettings(SettingsManager.Settings.Graphics);
71+
}
72+
73+
public static void SaveBaseGraphics()
74+
{
75+
CultBaseGraphicsConfig.BoxedValue = JsonConvert.SerializeObject(SettingsManager.Settings.Graphics);
76+
CultBaseGraphics = CloneSettings(SettingsManager.Settings.Graphics);
77+
}
78+
79+
public static void ApplySettings(FollowerLocation location = FollowerLocation.None)
80+
{
81+
if (location == FollowerLocation.Base)
82+
{
83+
SettingsManager.Settings.Graphics = CloneSettings(CultBaseGraphics);
84+
}
85+
else
86+
{
87+
SettingsManager.Settings.Graphics = CloneSettings(DefaultGraphics);
88+
}
89+
90+
SettingsManager.Instance.ApplySettings();
91+
}
5292
}
5393
}

README.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
1-
# CotLTemplateMod
2-
Cult of the Lamb Template Mod
1+
# CotLAutoGraphicsSettings
32

4-
**This is the Full Template Branch** (including template code for the API and patches)
5-
**!! When using this template with Visual Studio, make sure to run `dotnet restore` from the terminal (View -> Terminal)**
3+
Cult of the Lamb Auto Graphics Settings Mod is a mod that allows you to set different graphics settings for your Cult Base and for the rest of the game. When moving between between places (e.g between your Cult Base and going into a Crusade or vice-versa), this mod will automatically set the predefined graphics settings for that place.
4+
5+
## Why?
6+
7+
The Cult Base can become very resource heavy as you progress in the game. As such, low power or portable devices (such as the Steam Deck) will begin to slow down and heat up. While I played on my Steam Deck I was constantly swapping to the low preset at 30 fps while in the base to prevent the Steam Deck fan from going full blast and to preserve battery life.
8+
This mod was born to do this automatically for me and anyone interested in doing the same.
9+
10+
# Requirements
11+
12+
- [BepInEx](https://docs.bepinex.dev/articles/user_guide/installation/index.html) (As of writing v5.4.21)
13+
14+
## How to Install
15+
16+
- Extract BepInEx into the Cult of the Lamb's directory (e.g `steamapps/common/Cult of the Lamb`).
17+
- Launch the game once so that BepInEx can create the necessary files and folders.
18+
- Place the DLL from the latest [release](https://github.com/NullScope/CotLAutoGraphicsSettings/releases) into BepInEx's plugins folder (e.g `steamapps/common/Cult of the Lamb/BepInEx/plugins`).
19+
20+
## How to Use
21+
22+
On the first run, the mod will automatically save the settings currently used as both the default and the Cult Base settings.
23+
24+
To change the Cult Base settings, go to your Cult Base and change the Graphics Settings in the Game's UI as usual, to the settings you prefer.
25+
26+
To change the Default settings (i.e the settings used outside of the Cult Base) simply go to somewhere outside of the Cult Base (e.g Start a crusade or go to the Lighthouse) and change your Graphics Settings in the Game's UI.
27+
28+
**Note:** Both the Church and the room where you select which Crusade to start (the room with the 4 doors) count as part of the Cult Base.

lib/COTL_API.dll

-122 KB
Binary file not shown.

0 commit comments

Comments
 (0)