Skip to content

Commit

Permalink
etc
Browse files Browse the repository at this point in the history
  • Loading branch information
aedenthorn committed Mar 28, 2021
1 parent d0a2345 commit 7b236db
Show file tree
Hide file tree
Showing 20 changed files with 657 additions and 130 deletions.
2 changes: 1 addition & 1 deletion AutoStore/BepInExPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static void Postfix(Container __instance, ZNetView ___m_nview)
continue;

Dbgl($"auto storing {item.m_itemData.m_dropPrefab.name} from ground");

item.GetComponent<ZNetView>().ClaimOwnership();

while (item.m_itemData.m_stack > 1 && __instance.GetInventory().CanAddItem(item.m_itemData, 1))
{
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ConfigurationManager/ConfigurationManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ConfigSettingEntry.cs" />
<Compile Include="ConfigurationManager.cs" />
<Compile Include="BepInExPlugin.cs" />
<Compile Include="LegacySettingEntry.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SettingEntryBase.cs" />
Expand Down
6 changes: 3 additions & 3 deletions ConfigurationManager/LegacySettingEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static LegacySettingEntry FromConfigWrapper(object instance, PropertyInfo

if (wrapper == null)
{
ConfigurationManager.Logger.Log(LogLevel.Debug, $"Skipping ConfigWrapper entry because it's null : {instance} | {settingProp.Name} | {pluginInfo?.Name}");
BepInExPlugin.Logger.Log(LogLevel.Debug, $"Skipping ConfigWrapper entry because it's null : {instance} | {settingProp.Name} | {pluginInfo?.Name}");
return null;
}

Expand All @@ -57,7 +57,7 @@ public static LegacySettingEntry FromConfigWrapper(object instance, PropertyInfo

if (innerProp == null)
{
ConfigurationManager.Logger.Log(LogLevel.Error, "Failed to find property Value of ConfigWrapper");
BepInExPlugin.Logger.Log(LogLevel.Error, "Failed to find property Value of ConfigWrapper");
return null;
}

Expand Down Expand Up @@ -106,7 +106,7 @@ public static LegacySettingEntry FromConfigWrapper(object instance, PropertyInfo
}
catch (SystemException ex)
{
ConfigurationManager.Logger.Log(LogLevel.Error,
BepInExPlugin.Logger.Log(LogLevel.Error,
$"Failed to create ConfigWrapper entry : {instance} | {settingProp?.Name} | {pluginInfo?.Name} | Error: {ex.Message}");
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion ConfigurationManager/SettingEntryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ internal void SetFromAttributes(object[] attribs, BaseUnityPlugin pluginInstance
}
catch (Exception ex)
{
ConfigurationManager.Logger.LogWarning($"Failed to copy value {propertyPair.my.Name} from provided tag object {attrType.FullName} - " + ex.Message);
BepInExPlugin.Logger.LogWarning($"Failed to copy value {propertyPair.my.Name} from provided tag object {attrType.FullName} - " + ex.Message);
}
}
break;
Expand Down
53 changes: 28 additions & 25 deletions ConfigurationManager/SettingFieldDrawer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Based on code made by MarC0 / ManlyMarco
// Copyright 2018 GNU General Public License v3.0

using BepInEx.Configuration;
using ConfigurationManager.Utilities;
using System;
using System.Collections;
Expand All @@ -21,7 +22,7 @@ internal class SettingFieldDrawer
private static readonly Dictionary<SettingEntryBase, ComboBox> _comboBoxCache = new Dictionary<SettingEntryBase, ComboBox>();
private static readonly Dictionary<SettingEntryBase, ColorCacheEntry> _colorCache = new Dictionary<SettingEntryBase, ColorCacheEntry>();

private readonly ConfigurationManager _instance;
private readonly BepInExPlugin _instance;

private static SettingEntryBase _currentKeyboardShortcutToSet;
public static bool SettingKeyboardShortcut => _currentKeyboardShortcutToSet != null;
Expand All @@ -32,6 +33,7 @@ static SettingFieldDrawer()
{
{typeof(bool), DrawBoolField},
{typeof(BepInEx.Configuration.KeyboardShortcut), DrawKeyboardShortcut},
{typeof(KeyCode), DrawKeyboardShortcut},
{typeof(Color), DrawColor },
{typeof(Vector2), DrawVector2 },
{typeof(Vector3), DrawVector3 },
Expand All @@ -40,14 +42,14 @@ static SettingFieldDrawer()
};
}

public SettingFieldDrawer(ConfigurationManager instance)
public SettingFieldDrawer(BepInExPlugin instance)
{
_instance = instance;
}

public void DrawSettingValue(SettingEntryBase setting)
{
GUI.backgroundColor = ConfigurationManager._widgetBackgroundColor.Value;
GUI.backgroundColor = BepInExPlugin._widgetBackgroundColor.Value;

if (setting.CustomDrawer != null)
setting.CustomDrawer(setting is ConfigSettingEntry newSetting ? newSetting.Entry : null);
Expand Down Expand Up @@ -79,21 +81,21 @@ public static void DrawCenteredLabel(string text, params GUILayoutOption[] optio
{
GUILayout.BeginHorizontal(options);
GUILayout.FlexibleSpace();
GUILayout.Label(text, ConfigurationManager.labelStyle);
GUILayout.Label(text, BepInExPlugin.labelStyle);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}

public static void DrawCategoryHeader(string text)
{
GUILayout.Label(text, ConfigurationManager.categoryHeaderSkin);
GUILayout.Label(text, BepInExPlugin.categoryHeaderSkin);
}

public static bool DrawPluginHeader(GUIContent content, bool isCollapsed)
{

//if (isCollapsed) content.text += "\n...";
return GUILayout.Button(content, ConfigurationManager.pluginHeaderSkin, GUILayout.ExpandWidth(true));
return GUILayout.Button(content, BepInExPlugin.pluginHeaderSkin, GUILayout.ExpandWidth(true));
}

public static bool DrawCurrentDropdown()
Expand Down Expand Up @@ -129,9 +131,9 @@ private void DrawFieldBasedOnValueType(SettingEntryBase setting)

private static void DrawBoolField(SettingEntryBase setting)
{
GUI.backgroundColor = ConfigurationManager._widgetBackgroundColor.Value;
GUI.backgroundColor = BepInExPlugin._widgetBackgroundColor.Value;
var boolVal = (bool)setting.Get();
var result = GUILayout.Toggle(boolVal, boolVal ? "Enabled" : "Disabled", ConfigurationManager.toggleStyle, GUILayout.ExpandWidth(true));
var result = GUILayout.Toggle(boolVal, boolVal ? "Enabled" : "Disabled", BepInExPlugin.toggleStyle, GUILayout.ExpandWidth(true));
if (result != boolVal)
setting.Set(result);
}
Expand Down Expand Up @@ -165,7 +167,7 @@ private static void DrawFlagsField(SettingEntryBase setting, IList enumValues, i
GUI.changed = false;


var newVal = GUILayout.Toggle((currentValue & value.val) == value.val, value.name, ConfigurationManager.toggleStyle,
var newVal = GUILayout.Toggle((currentValue & value.val) == value.val, value.name, BepInExPlugin.toggleStyle,
GUILayout.ExpandWidth(false));
if (GUI.changed)
{
Expand All @@ -192,7 +194,7 @@ private static void DrawComboboxField(SettingEntryBase setting, IList list, floa

if (!_comboBoxCache.TryGetValue(setting, out var box))
{
box = new ComboBox(dispRect, buttonText, list.Cast<object>().Select(ObjectToGuiContent).ToArray(), ConfigurationManager.boxStyle, windowYmax);
box = new ComboBox(dispRect, buttonText, list.Cast<object>().Select(ObjectToGuiContent).ToArray(), BepInExPlugin.boxStyle, windowYmax);
_comboBoxCache[setting] = box;
}
else
Expand Down Expand Up @@ -229,7 +231,7 @@ private static void DrawRangeField(SettingEntryBase setting)
var leftValue = (float)Convert.ToDouble(setting.AcceptableValueRange.Key, CultureInfo.InvariantCulture);
var rightValue = (float)Convert.ToDouble(setting.AcceptableValueRange.Value, CultureInfo.InvariantCulture);

var result = GUILayout.HorizontalSlider(converted, leftValue, rightValue, ConfigurationManager.sliderStyle, ConfigurationManager.thumbStyle, GUILayout.ExpandWidth(true));
var result = GUILayout.HorizontalSlider(converted, leftValue, rightValue, BepInExPlugin.sliderStyle, BepInExPlugin.thumbStyle, GUILayout.ExpandWidth(true));
if (Math.Abs(result - converted) > Mathf.Abs(rightValue - leftValue) / 1000)
{
var newValue = Convert.ChangeType(result, setting.SettingType, CultureInfo.InvariantCulture);
Expand Down Expand Up @@ -268,7 +270,7 @@ private void DrawUnknownField(SettingEntryBase setting, int rightColumnWidth)
if (setting.ObjToStr != null && setting.StrToObj != null)
{
var text = setting.ObjToStr(setting.Get()).AppendZeroIfFloat(setting.SettingType);
var result = GUILayout.TextField(text, ConfigurationManager.buttonStyle, GUILayout.MaxWidth(rightColumnWidth));
var result = GUILayout.TextField(text, BepInExPlugin.textStyle, GUILayout.MaxWidth(rightColumnWidth));
if (result != text)
setting.Set(setting.StrToObj(result));
}
Expand All @@ -279,13 +281,13 @@ private void DrawUnknownField(SettingEntryBase setting, int rightColumnWidth)
var value = rawValue == null ? "NULL" : rawValue.ToString().AppendZeroIfFloat(setting.SettingType);
if (CanCovert(value, setting.SettingType))
{
var result = GUILayout.TextField(value, ConfigurationManager.buttonStyle, GUILayout.MaxWidth(rightColumnWidth));
var result = GUILayout.TextField(value, BepInExPlugin.textStyle, GUILayout.MaxWidth(rightColumnWidth));
if (result != value)
setting.Set(Convert.ChangeType(result, setting.SettingType, CultureInfo.InvariantCulture));
}
else
{
GUILayout.TextArea(value, ConfigurationManager.buttonStyle, GUILayout.MaxWidth(rightColumnWidth));
GUILayout.TextArea(value, BepInExPlugin.textStyle, GUILayout.MaxWidth(rightColumnWidth));
}
}

Expand Down Expand Up @@ -314,12 +316,14 @@ private bool CanCovert(string value, Type type)

private static void DrawKeyboardShortcut(SettingEntryBase setting)
{
#pragma warning disable 618 // Disable obsolete warning
var value = setting.Get();
if (value.GetType() == typeof(KeyCode)){
value = new KeyboardShortcut((KeyCode)value);
}

if (_currentKeyboardShortcutToSet == setting)
{
GUILayout.Label("Press any key combination", ConfigurationManager.labelStyle, GUILayout.ExpandWidth(true));
GUILayout.Label("Press any key combination", BepInExPlugin.labelStyle, GUILayout.ExpandWidth(true));
GUIUtility.keyboardControl = -1;

foreach (var key in _keysToCheck)
Expand All @@ -332,21 +336,20 @@ private static void DrawKeyboardShortcut(SettingEntryBase setting)
}
}

if (GUILayout.Button("Cancel", ConfigurationManager.buttonStyle, GUILayout.ExpandWidth(false)))
if (GUILayout.Button("Cancel", BepInExPlugin.buttonStyle, GUILayout.ExpandWidth(false)))
_currentKeyboardShortcutToSet = null;
}
else
{
if (GUILayout.Button(value.ToString(), GUILayout.ExpandWidth(true)))
_currentKeyboardShortcutToSet = setting;

if (GUILayout.Button("Clear", ConfigurationManager.buttonStyle, GUILayout.ExpandWidth(false)))
if (GUILayout.Button("Clear", BepInExPlugin.buttonStyle, GUILayout.ExpandWidth(false)))
{
setting.Set(BepInEx.Configuration.KeyboardShortcut.Empty);
_currentKeyboardShortcutToSet = null;
}
}
#pragma warning restore 618
}

private static void DrawVector2(SettingEntryBase obj)
Expand Down Expand Up @@ -392,7 +395,7 @@ private static void DrawQuaternion(SettingEntryBase obj)

private static float DrawSingleVectorSlider(float setting, string label)
{
GUILayout.Label(label, ConfigurationManager.labelStyle, GUILayout.ExpandWidth(false));
GUILayout.Label(label, BepInExPlugin.labelStyle, GUILayout.ExpandWidth(false));
float.TryParse(GUILayout.TextField(setting.ToString("F", CultureInfo.InvariantCulture), GUILayout.ExpandWidth(true)), NumberStyles.Any, CultureInfo.InvariantCulture, out var x);
return x;
}
Expand All @@ -408,13 +411,13 @@ private static void DrawColor(SettingEntryBase obj)
_colorCache[obj] = cacheEntry;
}

GUILayout.Label("R", ConfigurationManager.labelStyle, GUILayout.ExpandWidth(false));
GUILayout.Label("R", BepInExPlugin.labelStyle, GUILayout.ExpandWidth(false));
setting.r = GUILayout.HorizontalSlider(setting.r, 0f, 1f, GUILayout.ExpandWidth(true));
GUILayout.Label("G", ConfigurationManager.labelStyle, GUILayout.ExpandWidth(false));
GUILayout.Label("G", BepInExPlugin.labelStyle, GUILayout.ExpandWidth(false));
setting.g = GUILayout.HorizontalSlider(setting.g, 0f, 1f, GUILayout.ExpandWidth(true));
GUILayout.Label("B", ConfigurationManager.labelStyle, GUILayout.ExpandWidth(false));
GUILayout.Label("B", BepInExPlugin.labelStyle, GUILayout.ExpandWidth(false));
setting.b = GUILayout.HorizontalSlider(setting.b, 0f, 1f, GUILayout.ExpandWidth(true));
GUILayout.Label("A", ConfigurationManager.labelStyle, GUILayout.ExpandWidth(false));
GUILayout.Label("A", BepInExPlugin.labelStyle, GUILayout.ExpandWidth(false));
setting.a = GUILayout.HorizontalSlider(setting.a, 0f, 1f, GUILayout.ExpandWidth(true));

GUILayout.Space(4);
Expand All @@ -426,7 +429,7 @@ private static void DrawColor(SettingEntryBase obj)
cacheEntry.Last = setting;
}

GUILayout.Label(cacheEntry.Tex, ConfigurationManager.labelStyle, GUILayout.ExpandWidth(false));
GUILayout.Label(cacheEntry.Tex, BepInExPlugin.labelStyle, GUILayout.ExpandWidth(false));
}

private sealed class ColorCacheEntry
Expand Down
7 changes: 6 additions & 1 deletion ConfigurationManager/SettingSearcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ public static void CollectSettings(out IEnumerable<SettingEntryBase> results, ou
catch (Exception ex)
{
results = Enumerable.Empty<SettingEntryBase>();
ConfigurationManager.Logger.LogError(ex);
BepInExPlugin.Logger.LogError(ex);
}

foreach (var plugin in Utils.FindPlugins())
{
if (plugin.Info.Metadata.GUID == "com.bepis.bepinex.configurationmanager" || plugin.enabled == false)
{
BepInExPlugin.Dbgl($"plugin: {plugin.Info.Metadata.Name} enabled {plugin.enabled}");
}

var type = plugin.GetType();

var pluginInfo = plugin.Info.Metadata;
Expand Down
2 changes: 1 addition & 1 deletion ConfigurationManager/Utilities/ComboBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void Show(Action<int> onItemSelected)
var outerRectLocal = new Rect(scrpos.x, scrpos.y, outerRectScreen.width, outerRectScreen.height);

GUI.Box(outerRectLocal, GUIContent.none,
new GUIStyle { normal = new GUIStyleState { background = ConfigurationManager.WindowBackground } });
new GUIStyle { normal = new GUIStyleState { background = BepInExPlugin.WindowBackground } });

_scrollPosition = GUI.BeginScrollView(outerRectLocal, _scrollPosition, innerRect, false, false);
{
Expand Down
34 changes: 33 additions & 1 deletion CustomAudio/BepInExPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace CustomAudio
{
[BepInPlugin("aedenthorn.CustomAudio", "Custom Audio", "0.8.0")]
[BepInPlugin("aedenthorn.CustomAudio", "Custom Audio", "0.9.0")]
public class BepInExPlugin: BaseUnityPlugin
{
public static ConfigEntry<bool> isDebug;
Expand Down Expand Up @@ -382,6 +382,38 @@ static void Prefix(ref float ___m_queuedAmbientVol, ref float ___m_ambientVol, r
}
}

[HarmonyPatch(typeof(Fireplace), "Start")]
static class Fireplace_Start_Patch
{
static void Postfix(Fireplace __instance)
{
if (__instance.name.Contains("groundtorch") && customSFX.ContainsKey("groundtorch"))
{
Dbgl("Replacing ground torch audio");
__instance.m_enabledObjectHigh.GetComponentInChildren<AudioSource>().clip = customSFX["groundtorch"];
}
else if(__instance.name.Contains("walltorch") && customSFX.ContainsKey("walltorch"))
{
Dbgl("Replacing walltorch audio");
__instance.m_enabledObjectHigh.GetComponentInChildren<AudioSource>().clip = customSFX["walltorch"];
}
else if (__instance.name.Contains("fire_pit") && customSFX.ContainsKey("fire_pit"))
{
Dbgl("Replacing fire_pit audio");
__instance.m_enabledObjectHigh.GetComponentInChildren<AudioSource>().clip = customSFX["fire_pit"];
}
else if (__instance.name.Contains("bonfire") && customSFX.ContainsKey("bonfire"))
{
Dbgl("Replacing bonfire audio");
__instance.m_enabledObjectHigh.GetComponentInChildren<AudioSource>().clip = customSFX["bonfire"];
}
else if (__instance.name.Contains("hearth") && customSFX.ContainsKey("hearth"))
{
Dbgl("Replacing hearth audio");
__instance.m_enabledObjectHigh.GetComponentInChildren<AudioSource>().clip = customSFX["hearth"];
}
}
}

[HarmonyPatch(typeof(Console), "InputText")]
static class InputText_Patch
Expand Down
3 changes: 1 addition & 2 deletions CustomAudio/CustomAudio.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
<PostBuildEvent>call $(SolutionDir)copyDll.bat $(ProjectName)</PostBuildEvent>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion CustomTextures/BepInExPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace CustomTextures
{
[BepInPlugin("aedenthorn.CustomTextures", "Custom Textures", "2.0.1")]
[BepInPlugin("aedenthorn.CustomTextures", "Custom Textures", "2.0.3")]
public partial class BepInExPlugin: BaseUnityPlugin
{
public static ConfigEntry<bool> modEnabled;
Expand Down
2 changes: 1 addition & 1 deletion CustomTextures/CustomTextures.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="TextureLoading.cs" />
<Compile Include="Replacement.cs" />
<Compile Include="DoReplacement.cs" />
<Compile Include="TextureReplacement.cs" />
<Compile Include="BepInExPlugin.cs" />
<Compile Include="Patches.cs" />
Expand Down
Loading

0 comments on commit 7b236db

Please sign in to comment.