using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using BBModMenu;
using HarmonyLib;
using MelonLoader;
using MelonLoader.Preferences;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UIElements;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BBModMenu")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BBModMenu")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: MelonInfo(typeof(BBModMenuMod), "Beton Brutal ModMenu", "1.0.5", "MiaouZart", null)]
[assembly: MelonGame("", "Beton Brutal")]
[assembly: ComVisible(false)]
[assembly: Guid("74d627f7-39ff-4f90-b198-4a365e702f78")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BBModMenu;
public class BBModMenuMod : MelonMod
{
[HarmonyPatch(typeof(GameUI), "Awake")]
private static class PatchGameUIAwake
{
[HarmonyPrefix]
private static void Prefix(GameUI __instance)
{
((Component)__instance).gameObject.AddComponent<BBModMenuComponent>();
}
}
}
internal class BBModMenuComponent : MonoBehaviour
{
private GameUI _gameUI;
private List<UIScreen> _screens;
public ModMenu ModMenu;
public void Start()
{
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Expected O, but got Unknown
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Expected O, but got Unknown
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Expected O, but got Unknown
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Expected O, but got Unknown
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
MelonPreferences.Save();
GameObject val = GameObject.Find("GameUI");
_gameUI = val.GetComponent<GameUI>();
_screens = typeof(GameUI)?.GetField("screens", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(_gameUI) as List<UIScreen>;
ModMenu = new ModMenu(_gameUI);
_screens?.Add((UIScreen)(object)ModMenu);
MainScreen obj = _gameUI.FindScreen<MainScreen>();
FieldInfo field = typeof(UIScreen).GetField("<Screen>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
object? value = field.GetValue(obj);
VisualElement val2 = (VisualElement)((value is VisualElement) ? value : null);
VisualElement val3 = ((val2 != null) ? val2[0] : null);
Button val4 = new Button
{
text = "Mod Menu"
};
VisualElement val5 = new VisualElement();
val5.style.backgroundColor = StyleColor.op_Implicit(ModMenu._BBBackGround);
val5.Add((VisualElement)(object)val4);
if (val3 != null)
{
val3.Add(val5);
}
val4.clicked += delegate
{
_gameUI.SwitchToScreen<ModMenu>();
};
}
CustomMapPauseScreen obj2 = _gameUI.FindScreen<CustomMapPauseScreen>();
if (field != null)
{
object? value2 = field.GetValue(obj2);
VisualElement val6 = (VisualElement)((value2 is VisualElement) ? value2 : null);
VisualElement val7 = ((val6 != null) ? val6[0] : null);
Button val8 = new Button
{
text = "Mod Menu"
};
VisualElement val9 = new VisualElement();
val9.style.backgroundColor = StyleColor.op_Implicit(ModMenu._BBBackGround);
val9.Add((VisualElement)(object)val8);
if (val7 != null)
{
val7.Add(val9);
}
val8.clicked += delegate
{
_gameUI.SwitchToScreen<ModMenu>();
};
}
}
}
public class ModMenu : UIScreen
{
private VisualElement _root;
private ScrollView _menu;
private VisualElement _settings;
private VisualElement _menuItems;
private ScrollView _scrollView;
public static Color _BBgreen = new Color(0.41568628f, 48f / 85f, 0.16862746f);
public static Color _BBBackGround = new Color(0f, 0f, 0f, 0.7f);
private Button backButton;
private bool _added = false;
public ModMenu(GameUI ui)
: base(ui, "Intro")
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Expected O, but got Unknown
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Expected O, but got Unknown
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_0260: Expected O, but got Unknown
PropertyInfo property = typeof(UIScreen).GetProperty("Screen", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
FieldInfo field = typeof(UIScreen).GetField("<Screen>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic);
_root = new VisualElement();
_root.name = "SettingsMenu";
if (field != null)
{
field.SetValue(this, _root);
}
else
{
property?.GetSetMethod(nonPublic: true)?.Invoke(this, new object[1] { _root });
}
_menu = new ScrollView();
_settings = new VisualElement();
_scrollView = new ScrollView();
_root.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
_root.style.height = StyleLength.op_Implicit(new Length(100f, (LengthUnit)1));
((VisualElement)_menu).name = "Menu";
((VisualElement)_menu).style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)0);
((VisualElement)_menu).style.flexBasis = StyleLength.op_Implicit(new Length(20f, (LengthUnit)1));
_settings.name = "Settings";
_settings.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)0);
_settings.style.flexGrow = StyleFloat.op_Implicit(1f);
_settings.style.marginLeft = StyleLength.op_Implicit(100f);
((VisualElement)_scrollView).style.height = StyleLength.op_Implicit(new Length(100f, (LengthUnit)1));
_settings.Add((VisualElement)(object)_scrollView);
_root.Add((VisualElement)(object)_menu);
_root.Add(_settings);
VisualElement val = CreateGroup("BackButton");
val.style.marginTop = StyleLength.op_Implicit(10f);
backButton = CreateButton("Back");
backButton.clicked += delegate
{
((UIScreen)this).UI.SwitchToPreviousScreen();
};
val.Add((VisualElement)(object)backButton);
_menuItems = new VisualElement();
((VisualElement)_menu).Add(_menuItems);
((VisualElement)_menu).Add(val);
Debug.Log((object)"ModMenu Created");
}
public override void OnUpdate()
{
((UIScreen)this).OnUpdate();
if (PlayerInput.BackPressed)
{
((UIScreen)this).UI.SwitchToPreviousScreen();
}
}
public VisualElement getRootVisualElement()
{
return _root;
}
public override void OnEnter()
{
if (!_added)
{
((UIScreen)this).Root.Add(_root);
_added = true;
}
((UIScreen)this).OnEnter();
}
public VisualElement AddSetting(string setting)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
VisualElement groupVisualElement = CreateGroup(setting);
AddToScrollView(groupVisualElement);
BBSettings.AddCategory(setting);
Button val = CreateButton(setting);
((VisualElement)val).style.color = StyleColor.op_Implicit(_BBgreen);
val.clicked += delegate
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
ScrollView scrollView = _scrollView;
Rect layout = groupVisualElement.layout;
scrollView.scrollOffset = new Vector2(0f, ((Rect)(ref layout)).position.y);
};
groupVisualElement.Add((VisualElement)(object)CreateTitleLabel(setting));
AddToScrollView(groupVisualElement);
AddToMenu((VisualElement)(object)val);
return groupVisualElement;
}
public void AddToScrollView(VisualElement element)
{
((VisualElement)_scrollView).Add(element);
}
public void AddToMenu(VisualElement element)
{
_menuItems.Add(element);
}
public VisualElement CreateGroup(string groupName)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
VisualElement val = new VisualElement();
val.name = groupName;
return val;
}
public VisualElement CreateWrapper()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
VisualElement val = new VisualElement();
val.style.marginBottom = StyleLength.op_Implicit(5f);
val.style.paddingBottom = StyleLength.op_Implicit(7f);
val.style.backgroundColor = StyleColor.op_Implicit(_BBBackGround);
return val;
}
public void AddToGroup(VisualElement group, VisualElement element)
{
group.Add(element);
}
public Label CreateLabel(string text)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
Label val = new Label();
((TextElement)val).text = text;
((VisualElement)val).style.fontSize = StyleLength.op_Implicit(20f);
return val;
}
public Label CreateTitleLabel(string text)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
Label val = new Label();
((TextElement)val).text = text;
((VisualElement)val).style.backgroundColor = StyleColor.op_Implicit(_BBBackGround);
((VisualElement)val).style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)4);
((VisualElement)val).style.fontSize = StyleLength.op_Implicit(50f);
((VisualElement)val).style.color = StyleColor.op_Implicit(_BBgreen);
return val;
}
public Button CreateButton(string text)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
Button val = new Button
{
text = text
};
((VisualElement)val).style.alignSelf = StyleEnum<Align>.op_Implicit((Align)1);
((VisualElement)val).style.width = new StyleLength((StyleKeyword)2);
((VisualElement)val).style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)3);
return val;
}
public Slider CreateSlider(string category, string name, float min, float max, float defaultValue = 0f, bool onlyInt = false)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
//IL_008c: Expected O, but got Unknown
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Expected O, but got Unknown
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Expected O, but got Unknown
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
BBSettings.AddEntry(category, name, defaultValue);
float entryValue = BBSettings.GetEntryValue<float>(category, name);
Slider val = new Slider(min, max, (SliderDirection)0, 0f);
((BaseField<float>)val).value = entryValue;
((VisualElement)val).name = name;
((BaseSlider<float>)val).showInputField = false;
Slider newSlider = val;
TextField val2 = new TextField();
((BaseField<string>)val2).value = (onlyInt ? ((int)entryValue).ToString() : entryValue.ToString("0.##", CultureInfo.InvariantCulture));
((TextInputBaseField<string>)val2).isReadOnly = false;
((Focusable)val2).focusable = true;
TextField valueField = val2;
((VisualElement)valueField).style.width = StyleLength.op_Implicit(42f);
((VisualElement)valueField).style.marginLeft = StyleLength.op_Implicit(10f);
((VisualElement)newSlider).Add((VisualElement)(object)valueField);
((VisualElement)newSlider)[0][0][2].style.backgroundColor = StyleColor.op_Implicit(Color.gray);
((VisualElement)newSlider)[0][0][2].style.paddingBottom = StyleLength.op_Implicit(20f);
((VisualElement)newSlider)[0][0].style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)4);
INotifyValueChangedExtensions.RegisterValueChangedCallback<float>((INotifyValueChanged<float>)(object)newSlider, (EventCallback<ChangeEvent<float>>)delegate(ChangeEvent<float> evt)
{
float num2 = (onlyInt ? Mathf.Round(evt.newValue) : evt.newValue);
((BaseField<float>)(object)newSlider).SetValueWithoutNotify(num2);
((BaseField<string>)(object)valueField).SetValueWithoutNotify(onlyInt ? ((int)num2).ToString() : num2.ToString("0.##", CultureInfo.InvariantCulture));
BBSettings.SetEntryValue(category, name, num2);
BBSettings.SavePref();
});
((CallbackEventHandler)valueField).RegisterCallback<FocusOutEvent>((EventCallback<FocusOutEvent>)delegate
{
string s = ((BaseField<string>)(object)valueField).value.Replace(',', '.');
if (float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
{
result = Mathf.Clamp(result, min, max);
if (onlyInt)
{
result = Mathf.Round(result);
}
((BaseField<float>)(object)newSlider).value = result;
}
else
{
((BaseField<string>)(object)valueField).SetValueWithoutNotify(onlyInt ? ((int)((BaseField<float>)(object)newSlider).value).ToString() : ((BaseField<float>)(object)newSlider).value.ToString("0.##", CultureInfo.InvariantCulture));
}
}, (TrickleDown)0);
((CallbackEventHandler)valueField).RegisterCallback<InputEvent>((EventCallback<InputEvent>)delegate(InputEvent evt)
{
string newData = evt.newData;
if (!char.IsDigit(newData, 0) && !(newData == ".") && !(newData == ",") && !(newData == "-"))
{
((EventBase)evt).PreventDefault();
}
}, (TrickleDown)0);
((CallbackEventHandler)newSlider).RegisterCallback<KeyDownEvent>((EventCallback<KeyDownEvent>)delegate(KeyDownEvent evt)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Invalid comparison between Unknown and I4
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected I4, but got Unknown
float num = (onlyInt ? 1f : ((max - min) / 100f));
float value = ((BaseField<float>)(object)newSlider).value;
KeyCode keyCode = ((KeyboardEventBase<KeyDownEvent>)(object)evt).keyCode;
KeyCode val3 = keyCode;
if ((int)val3 != 13)
{
switch (val3 - 271)
{
default:
return;
case 2:
case 4:
value = Mathf.Clamp(value + num, min, max);
goto IL_00a4;
case 3:
case 5:
value = Mathf.Clamp(value - num, min, max);
goto IL_00a4;
case 0:
break;
case 1:
return;
IL_00a4:
((EventBase)evt).StopPropagation();
((BaseField<float>)(object)newSlider).value = (onlyInt ? Mathf.Round(value) : value);
return;
}
}
((Focusable)valueField).Blur();
}, (TrickleDown)0);
return newSlider;
}
public Toggle CreateToggle(string category, string name, bool defaultValue = false)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
BBSettings.AddEntry(category, name, defaultValue);
Toggle val = new Toggle();
((VisualElement)val).name = name;
VisualElement checkBoxCheckMark = UQueryExtensions.Q((VisualElement)(object)val, "unity-checkmark", (string)null);
((BaseField<bool>)(object)val).value = BBSettings.GetEntryValue<bool>(category, name);
checkBoxCheckMark.style.unityBackgroundImageTintColor = StyleColor.op_Implicit(((BaseField<bool>)(object)val).value ? Color.white : Color.clear);
INotifyValueChangedExtensions.RegisterValueChangedCallback<bool>((INotifyValueChanged<bool>)(object)val, (EventCallback<ChangeEvent<bool>>)delegate(ChangeEvent<bool> b)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
checkBoxCheckMark.style.unityBackgroundImageTintColor = StyleColor.op_Implicit(b.newValue ? Color.white : Color.clear);
BBSettings.SetEntryValue(category, name, b.newValue);
BBSettings.SavePref();
});
return val;
}
public Utils.CarouselEntry CreateCarousel(string category, string name, List<string> card, Action<string> onValueChanged = null, string defaultValue = "")
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Expected O, but got Unknown
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
Utils.CarouselEntry carouselEntry = new Utils.CarouselEntry();
VisualElement val = new VisualElement();
val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
val.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
val.style.justifyContent = StyleEnum<Justify>.op_Implicit((Justify)1);
string text = card.Aggregate((string max, string cur) => (max.Length > cur.Length) ? max : cur);
if (!BBSettings.HasEntry(category, name))
{
BBSettings.AddEntry(category, name, (defaultValue != "") ? defaultValue : card[0]);
}
string entryValue = BBSettings.GetEntryValue<string>(category, name);
int currentIndex = card.IndexOf(entryValue);
if (currentIndex < 0)
{
currentIndex = 0;
}
Label lbl = CreateLabel(card[currentIndex]);
((VisualElement)lbl).style.fontSize = StyleLength.op_Implicit(20f);
((VisualElement)lbl).style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)4);
Label textElement = new Label(text);
((VisualElement)textElement).style.fontSize = StyleLength.op_Implicit(20f);
((VisualElement)textElement).style.visibility = StyleEnum<Visibility>.op_Implicit((Visibility)1);
val.Add((VisualElement)(object)textElement);
((CallbackEventHandler)lbl).RegisterCallback<GeometryChangedEvent>((EventCallback<GeometryChangedEvent>)delegate
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
IStyle style = ((VisualElement)lbl).style;
Rect contentRect = ((VisualElement)textElement).contentRect;
style.width = StyleLength.op_Implicit(((Rect)(ref contentRect)).width);
((VisualElement)textElement).RemoveFromHierarchy();
}, (TrickleDown)0);
Button val2 = CreateButton("<");
Button val3 = CreateButton(">");
val.Add((VisualElement)(object)val2);
val.Add((VisualElement)(object)lbl);
val.Add((VisualElement)(object)val3);
val3.clicked += NavigateNext;
val2.clicked += NavigatePrevious;
carouselEntry.Value = entryValue;
carouselEntry.Root = val;
return carouselEntry;
void NavigateNext()
{
currentIndex = (currentIndex + 1) % card.Count;
UpdateLabel();
}
void NavigatePrevious()
{
currentIndex = (currentIndex - 1 + card.Count) % card.Count;
UpdateLabel();
}
void UpdateLabel()
{
string text2 = card[currentIndex];
((TextElement)lbl).text = text2;
BBSettings.SetEntryValue(category, name, text2);
BBSettings.SavePref();
onValueChanged?.Invoke(text2);
}
}
public Utils.HotKeyEntry CreateHotKey(string category, string name, KeyCode defaultKey)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
Utils.HotKeyEntry entry = new Utils.HotKeyEntry();
VisualElement val = new VisualElement();
val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
if (!BBSettings.HasEntry(category, name))
{
BBSettings.AddEntry(category, name, ((object)(KeyCode)(ref defaultKey)).ToString());
}
string entryValue = BBSettings.GetEntryValue<string>(category, name);
Label labelKey = CreateLabel(entryValue);
((VisualElement)labelKey).style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)4);
((VisualElement)labelKey).style.marginLeft = StyleLength.op_Implicit(10f);
Button val2 = CreateButton("Unbind");
val2.clicked += UnbindControl;
((VisualElement)val2).style.scale = new StyleScale(new Vector2(0.75f, 0.75f));
IStyle style = ((VisualElement)labelKey).style;
StyleLength fontSize = ((VisualElement)labelKey).style.fontSize;
Length value = ((StyleLength)(ref fontSize)).value;
style.fontSize = StyleLength.op_Implicit(10f + ((Length)(ref value)).value);
((Focusable)labelKey).focusable = true;
entry.Root = val;
entry.Value = entryValue;
bool isListening = false;
((CallbackEventHandler)labelKey).RegisterCallback<ClickEvent>((EventCallback<ClickEvent>)delegate
{
if (!isListening)
{
isListening = true;
((TextElement)labelKey).text = "Press a key or mouse button...";
ListenMouseButtons();
if (_root == null)
{
isListening = false;
}
else
{
((CallbackEventHandler)_root).RegisterCallback<KeyDownEvent>((EventCallback<KeyDownEvent>)OnKeyDown, (TrickleDown)1);
}
}
}, (TrickleDown)0);
val.Add((VisualElement)(object)labelKey);
val.Add((VisualElement)(object)val2);
return entry;
async void ListenMouseButtons()
{
while (isListening)
{
if (Mouse.current != null)
{
string combo2 = "";
if (Keyboard.current.ctrlKey.isPressed)
{
combo2 += "Ctrl+";
}
if (Keyboard.current.shiftKey.isPressed)
{
combo2 += "Shift+";
}
if (Keyboard.current.altKey.isPressed)
{
combo2 += "Alt+";
}
if (Mouse.current.leftButton.wasPressedThisFrame)
{
SaveCombo(combo2 + "Mouse0");
}
else if (Mouse.current.rightButton.wasPressedThisFrame)
{
SaveCombo(combo2 + "Mouse1");
}
else if (Mouse.current.middleButton.wasPressedThisFrame)
{
SaveCombo(combo2 + "Mouse2");
}
else if (Mouse.current.backButton.wasPressedThisFrame)
{
SaveCombo(combo2 + "Mouse3");
}
else if (Mouse.current.forwardButton.wasPressedThisFrame)
{
SaveCombo(combo2 + "Mouse4");
}
await Task.Yield();
}
}
}
void OnKeyDown(KeyDownEvent keyEvt)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Invalid comparison between Unknown and I4
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Invalid comparison between Unknown and I4
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Invalid comparison between Unknown and I4
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Invalid comparison between Unknown and I4
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Invalid comparison between Unknown and I4
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Invalid comparison between Unknown and I4
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Invalid comparison between Unknown and I4
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Invalid comparison between Unknown and I4
bool ctrlKey = ((KeyboardEventBase<KeyDownEvent>)(object)keyEvt).ctrlKey;
bool shiftKey = ((KeyboardEventBase<KeyDownEvent>)(object)keyEvt).shiftKey;
bool altKey = ((KeyboardEventBase<KeyDownEvent>)(object)keyEvt).altKey;
string text = "";
if (!char.IsControl(((KeyboardEventBase<KeyDownEvent>)(object)keyEvt).character) && ((KeyboardEventBase<KeyDownEvent>)(object)keyEvt).character != 0)
{
text = ((KeyboardEventBase<KeyDownEvent>)(object)keyEvt).character.ToString().ToUpper();
}
else
{
KeyCode keyCode = ((KeyboardEventBase<KeyDownEvent>)(object)keyEvt).keyCode;
text = ((object)(KeyCode)(ref keyCode)).ToString();
}
if ((int)((KeyboardEventBase<KeyDownEvent>)(object)keyEvt).keyCode != 306 && (int)((KeyboardEventBase<KeyDownEvent>)(object)keyEvt).keyCode != 305 && (int)((KeyboardEventBase<KeyDownEvent>)(object)keyEvt).keyCode != 304 && (int)((KeyboardEventBase<KeyDownEvent>)(object)keyEvt).keyCode != 303 && (int)((KeyboardEventBase<KeyDownEvent>)(object)keyEvt).keyCode != 308 && (int)((KeyboardEventBase<KeyDownEvent>)(object)keyEvt).keyCode != 307 && (int)((KeyboardEventBase<KeyDownEvent>)(object)keyEvt).keyCode != 310 && (int)((KeyboardEventBase<KeyDownEvent>)(object)keyEvt).keyCode != 309)
{
string text2 = "";
if (ctrlKey)
{
text2 += "Ctrl+";
}
if (shiftKey)
{
text2 += "Shift+";
}
if (altKey)
{
text2 += "Alt+";
}
text2 += text;
SaveCombo(text2);
}
}
void SaveCombo(string combo)
{
((TextElement)labelKey).text = combo;
entry.Value = combo;
BBSettings.SetEntryValue(category, name, combo);
BBSettings.SavePref();
entry.OnChanged?.Invoke(combo);
((CallbackEventHandler)_root).UnregisterCallback<KeyDownEvent>((EventCallback<KeyDownEvent>)OnKeyDown, (TrickleDown)1);
isListening = false;
}
void UnbindControl()
{
((TextElement)labelKey).text = "Not Bound";
BBSettings.SetEntryValue(category, name, "Unbind");
entry.Value = "Not Bound";
entry.OnChanged?.Invoke("Not Bound");
}
}
}
public static class BBSettings
{
public static void AddCategory(string categoryName)
{
MelonPreferences.CreateCategory(categoryName);
}
public static void AddEntry<T>(string categoryName, string entryName, T defaultValue)
{
MelonPreferences.CreateCategory(categoryName).CreateEntry<T>(entryName, defaultValue, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
}
public static T GetEntryValue<T>(string categoryName, string entryName)
{
return MelonPreferences.GetEntryValue<T>(categoryName, entryName);
}
public static void SetEntryValue<T>(string categoryName, string entryName, T newValue)
{
MelonPreferences.SetEntryValue<T>(categoryName, entryName, newValue);
}
public static void SavePref()
{
MelonPreferences.Save();
}
public static bool HasEntry(string categoryName, string entryName)
{
return MelonPreferences.HasEntry(categoryName, entryName);
}
}
public static class Utils
{
public class HotKeyEntry
{
public VisualElement Root;
public string Value;
public Action<string> OnChanged;
}
public class CarouselEntry
{
public VisualElement Root;
public string Value;
}
public static bool IsHotkeyPressed(string combo)
{
return CheckHotkey(combo, pressedThisFrame: true);
}
public static bool IsHotkeyHeld(string combo)
{
return CheckHotkey(combo, pressedThisFrame: false);
}
private static bool CheckHotkey(string combo, bool pressedThisFrame)
{
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Invalid comparison between Unknown and I4
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
if (string.IsNullOrEmpty(combo) || Keyboard.current == null)
{
return false;
}
Keyboard current = Keyboard.current;
Mouse current2 = Mouse.current;
bool flag = combo.Contains("Ctrl+");
bool flag2 = combo.Contains("Shift+");
bool flag3 = combo.Contains("Alt+");
string text = combo.Replace("Ctrl+", "").Replace("Shift+", "").Replace("Alt+", "")
.Trim();
bool flag4 = !flag || ((ButtonControl)current.leftCtrlKey).isPressed || ((ButtonControl)current.rightCtrlKey).isPressed;
bool flag5 = !flag2 || ((ButtonControl)current.leftShiftKey).isPressed || ((ButtonControl)current.rightShiftKey).isPressed;
bool flag6 = !flag3 || ((ButtonControl)current.leftAltKey).isPressed || ((ButtonControl)current.rightAltKey).isPressed;
bool flag7 = false;
if (text.StartsWith("Mouse"))
{
switch (text)
{
case "Mouse0":
flag7 = (pressedThisFrame ? current2.leftButton.wasPressedThisFrame : current2.leftButton.isPressed);
break;
case "Mouse1":
flag7 = (pressedThisFrame ? current2.rightButton.wasPressedThisFrame : current2.rightButton.isPressed);
break;
case "Mouse2":
flag7 = (pressedThisFrame ? current2.middleButton.wasPressedThisFrame : current2.middleButton.isPressed);
break;
case "Mouse3":
{
int num2;
if (!pressedThisFrame)
{
ButtonControl backButton = current2.backButton;
num2 = ((backButton != null && backButton.isPressed) ? 1 : 0);
}
else
{
ButtonControl backButton2 = current2.backButton;
num2 = ((backButton2 != null && backButton2.wasPressedThisFrame) ? 1 : 0);
}
flag7 = (byte)num2 != 0;
break;
}
case "Mouse4":
{
int num;
if (!pressedThisFrame)
{
ButtonControl forwardButton = current2.forwardButton;
num = ((forwardButton != null && forwardButton.isPressed) ? 1 : 0);
}
else
{
ButtonControl forwardButton2 = current2.forwardButton;
num = ((forwardButton2 != null && forwardButton2.wasPressedThisFrame) ? 1 : 0);
}
flag7 = (byte)num != 0;
break;
}
default:
flag7 = false;
break;
}
}
else
{
Key result = (Key)0;
KeyControl val = current.FindKeyOnCurrentKeyboardLayout(text.ToLower());
if (val != null)
{
result = val.keyCode;
}
else
{
Enum.TryParse<Key>(text, ignoreCase: true, out result);
}
if ((int)result > 0)
{
flag7 = (pressedThisFrame ? ((ButtonControl)current[result]).wasPressedThisFrame : ((ButtonControl)current[result]).isPressed);
}
}
return flag4 && flag5 && flag6 && flag7;
}
}