using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BBModMenu;
using HarmonyLib;
using MelonLoader;
using MelonLoader.Preferences;
using UnityEngine;
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.0", "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_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Expected O, but got Unknown
//IL_0071: Expected O, but got Unknown
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Expected O, but got Unknown
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Expected O, but got Unknown
//IL_00e7: Expected O, but got Unknown
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
BBSettings.AddEntry(category, name, defaultValue);
Slider val = new Slider(min, max, (SliderDirection)0, 0f);
((BaseField<float>)val).value = BBSettings.GetEntryValue<float>(category, name);
((VisualElement)val).name = "Slider";
((BaseSlider<float>)val).showInputField = false;
Slider newSlider = val;
((VisualElement)newSlider).name = name;
TextField val2 = new TextField();
((BaseField<string>)val2).value = (onlyInt ? ((int)BBSettings.GetEntryValue<float>(category, name)).ToString() : BBSettings.GetEntryValue<float>(category, name).ToString("0.##"));
((Focusable)val2).focusable = false;
((TextInputBaseField<string>)val2).isReadOnly = 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);
INotifyValueChangedExtensions.RegisterValueChangedCallback<float>((INotifyValueChanged<float>)(object)newSlider, (EventCallback<ChangeEvent<float>>)delegate(ChangeEvent<float> evt)
{
float num = (onlyInt ? Mathf.Round(evt.newValue) : evt.newValue);
((BaseField<float>)(object)newSlider).value = num;
((BaseField<string>)(object)valueField).value = (onlyInt ? ((int)num).ToString() : num.ToString("0.##"));
BBSettings.SetEntryValue(category, name, evt.newValue);
BBSettings.SavePref();
});
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 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);
}
}