Пример #1
0
        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;
        }