Skip to content

Commit

Permalink
Remove debug stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Nytra committed Dec 24, 2024
1 parent b7c5109 commit 4b73f5a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 23 deletions.
16 changes: 0 additions & 16 deletions MonkeyLoader.Resonite.Integration/FieldExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,13 @@ public static Action<IChangeable> SyncWithNullableConfigKeyHasValue<T>(this IFie
IDefiningConfigKey<T?> configKey, string? eventLabel = null, bool allowWriteBack = true)
where T : struct
{
configKey.FindNearestParent<Mod>().Logger.Trace(() => $"Syncing with nullable config key HasValue: {configKey.Id}");

field.Value = configKey.GetValue().HasValue;
eventLabel ??= field.GetWriteBackEventLabel();

var parent = field.FindNearestParent<Component>();

void ParentDestroyedHandler(IDestroyable _)
{
//configKey.FindNearestParent<Mod>().Logger.Trace(() => $"Parent destroyed: {configKey.Id}");

parent.Destroyed -= ParentDestroyedHandler;

field.Changed -= FieldChangedHandler;
Expand All @@ -142,8 +138,6 @@ void ParentDestroyedHandler(IDestroyable _)

void FieldChangedHandler(IChangeable _)
{
//configKey.FindNearestParent<Mod>().Logger.Trace(() => $"Field changed: {configKey.Id} {field.Value} {configKey.GetValue().HasValue} {allowWriteBack}");

T? newValue = field.Value ? default(T) : null;

if (field.Value != configKey.GetValue().HasValue && (!allowWriteBack || !configKey.TrySetValue(newValue, eventLabel)))
Expand All @@ -152,8 +146,6 @@ void FieldChangedHandler(IChangeable _)

void ConfigKeyChangedHandler(object sender, ConfigKeyChangedEventArgs<T?> args)
{
//configKey.FindNearestParent<Mod>().Logger.Trace(() => $"Config key changed: {configKey.Id} {field.Value} {configKey.GetValue().HasValue}");

if (field.Value != configKey.GetValue().HasValue)
field.World.RunSynchronously(() => field.Value = configKey.GetValue().HasValue);
}
Expand All @@ -168,8 +160,6 @@ void ConfigKeyChangedHandler(object sender, ConfigKeyChangedEventArgs<T?> args)
public static Action<IChangeable> SyncWithEnumFlag<T>(this IField<bool> field,
IDefiningConfigKey configKey, long longValue, string? eventLabel = null, bool allowWriteBack = true)
{
configKey.FindNearestParent<Mod>().Logger.Trace(() => $"Syncing with enum flag: {configKey.Id} {longValue}");

Type enumType = typeof(T);
if (typeof(T).IsNullable())
{
Expand All @@ -187,19 +177,13 @@ public static Action<IChangeable> SyncWithEnumFlag<T>(this IField<bool> field,

void FieldChanged(IChangeable changeable)
{
//configKey.FindNearestParent<Mod>().Logger.Trace(() => $"Field changed: {configKey.Id} {field.Value} {configKey.GetValue() ?? default} {longValue}");

configKey.TrySetValue(Enum.ToObject(enumType, field.Value ? Convert.ToInt64(configKey.GetValue() ?? default(T)) | longValue : Convert.ToInt64(configKey.GetValue() ?? default(T)) & ~longValue));
}

void KeyChanged(object sender, IConfigKeyChangedEventArgs changedEvent)
{
//configKey.FindNearestParent<Mod>().Logger.Trace(() => $"Config key changed: {configKey.Id} {field.Value} {configKey.GetValue()} {longValue}");

if (field.FilterWorldElement() is null)
{
//configKey.FindNearestParent<Mod>().Logger.Trace(() => $"Field was destroyed: {configKey.Id} {longValue}");

configKey.Changed -= KeyChanged;
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ public sealed class TooltipConfig : SingletonConfigSection<TooltipConfig>
new ConfigKeyRange<float>(.5f, 4)
};

private static readonly DefiningConfigKey<ShadowType> _testKey0 = new("testKey0", "Test key0.", () => ShadowType.Hard);
private static readonly DefiningConfigKey<ShadowType?> _testKey = new("testKey", "Test key.", () => ShadowType.Soft);
private static readonly DefiningConfigKey<MappingTarget> _testKey3 = new("testKey3", "Test key3.", () => MappingTarget.NONE);
private static readonly DefiningConfigKey<MappingTarget?> _testKey2 = new("testKey2", "Test key2.", () => null);
private static readonly DefiningConfigKey<float?> _testKey4 = new("testKey4", "Test key4.", () => null);
private static readonly DefiningConfigKey<bool?> _testKey5 = new("testKey5", "Test key5.", () => null);

/// <summary>
/// Gets the background color for tooltips.
/// </summary>
Expand Down

0 comments on commit 4b73f5a

Please sign in to comment.