internal ValueContainer AddMenu(Button button, string addonId, string uniqueMenuId, string longTitle = null, int index = -1) { if (button == null) { throw new ArgumentNullException("button"); } if (uniqueMenuId == null) { throw new ArgumentNullException("uniqueMenuId"); } // Add button to Children if (!Children.Contains(button)) { button.SetParent(this); Children.Insert(index >= 0 ? index : Children.Count, button); RecalculateAlignOffsets(); } // TODO: Improve button.TextHandle.Size = button.Size - new Vector2(button.TextHandle.Padding.X * 2f, 0); // Listen to state changes button.OnActiveStateChanged += OnActiveStateChanged; // Create a new control container for the button var container = new ValueContainer(addonId, uniqueMenuId) { IsVisible = false }; MainMenu.Instance.Add(container); // Create a new emtpry control for the text handle var textHolder = new EmptyControl(ThemeManager.SpriteType.FormContentHeader) { IsVisible = false }; textHolder.TextObjects.Add(new Text(longTitle ?? button.TextValue, new FontDescription { FaceName = "Gill Sans MT Pro Medium", Height = 20, Quality = FontQuality.Antialiased, Weight = FontWeight.ExtraBold }) { TextAlign = Text.Align.Left, TextOrientation = Text.Orientation.Center, Color = System.Drawing.Color.FromArgb(255, 143, 122, 72) }); MainMenu.Instance.Add(textHolder); // Associate button with container and long title text handle LinkedContainers.Add(button, new Tuple <Control, ControlContainer <ValueBase> >(textHolder, container)); // Return container return(container); }
internal static void Initialize() { // Initialize properties SavedValues = new Dictionary <string, Dictionary <string, List <Dictionary <string, object> > > >(); Instance = new SimpleControlContainer(ThemeManager.SpriteType.FormComplete, false, true, false) { IsVisible = false }; Sprite = new Sprite(() => ThemeManager.CurrentTheme.Texture); // Control containers Instance.Add(AddonButtonContainer = new AddonContainer()); // Empty controls Instance.Add(TitleBar = new EmptyControl(ThemeManager.SpriteType.FormHeader)); // Buttons Instance.Add(ExitButton = new Button(Button.ButtonType.Exit)); // Text types TitleBar.TextObjects.Add(TitleText = new Text("ELOBUDDY", new FontDescription { FaceName = "Gill Sans MT Pro Medium", Height = 28, Quality = FontQuality.Antialiased, Weight = FontWeight.ExtraBold, Width = 12, }) { TextAlign = Text.Align.Center, TextOrientation = Text.Orientation.Center, Color = Color.FromArgb(255, 143, 122, 72), Padding = new Vector2(0, 3) }); // Simple event hooks ExitButton.OnActiveStateChanged += delegate { if (ExitButton.IsActive) { IsVisible = false; ExitButton.IsActive = false; } }; TitleBar.OnLeftMouseDown += delegate { MoveOffset = Position - Game.CursorPos2D; }; TitleBar.OnLeftMouseUp += delegate { MoveOffset = Vector2.Zero; }; // Don't pass anything through the menu to the game if the mouse is inside of the menu Messages.OnMessage += delegate(Messages.WindowMessage args) { if (IsMouseInside) { args.Process = false; } }; // Center menu position Position = (new Vector2(Drawing.Width, Drawing.Height) - Instance.Size) / 2; // Setup save timer SaveTimer = new Timer(60000); SaveTimer.Elapsed += OnSaveTimerElapsed; SaveTimer.Start(); OnSaveTimerElapsed(null, null); // Listen to events ThemeManager.OnThemeChanged += OnThemeChanged; Sprite.OnMenuDraw += OnMenuDraw; Messages.OnMessage += OnWndMessage; AppDomain.CurrentDomain.DomainUnload += OnUnload; AppDomain.CurrentDomain.ProcessExit += OnUnload; #if DEBUG var debugMenu = AddMenu("Debug", "debugging"); debugMenu.AddGroupLabel("Menu outline (skeleton)"); debugMenu.Add("drawOutline", new CheckBox("Draw outline", false)).CurrentValue = false; debugMenu.AddGroupLabel("Load Bootstrap"); debugMenu.Add("targetselector", new CheckBox("TargetSelector", false)).CurrentValue = false; debugMenu.Add("orbwalker", new CheckBox("Orbwalker", false)).CurrentValue = false; debugMenu.Add("prediction", new CheckBox("Prediction", false)).CurrentValue = false; debugMenu.Add("damagelibrary", new CheckBox("DamageLibrary", false)).CurrentValue = false; debugMenu["drawOutline"].Cast <CheckBox>().OnValueChange += delegate(ValueBase <bool> sender, ValueBase <bool> .ValueChangeArgs args) { ControlContainerBase.DrawOutline = args.NewValue; }; debugMenu["targetselector"].Cast <CheckBox>().OnValueChange += delegate { TargetSelector.Initialize(); Core.DelayAction(() => debugMenu.Remove("targetselector"), 25); }; debugMenu["orbwalker"].Cast <CheckBox>().OnValueChange += delegate { Orbwalker.Initialize(); Core.DelayAction(() => debugMenu.Remove("orbwalker"), 25); }; debugMenu["prediction"].Cast <CheckBox>().OnValueChange += delegate { Prediction.Initialize(); Core.DelayAction(() => debugMenu.Remove("prediction"), 25); }; debugMenu["damagelibrary"].Cast <CheckBox>().OnValueChange += delegate { DamageLibrary.Initialize(); Core.DelayAction(() => debugMenu.Remove("damagelibrary"), 25); }; #endif // Indicate that the menu has finished loading IsLoaded = true; }