Esempio n. 1
0
        /// <summary>
        ///     The initialize.
        /// </summary>
        private void Initialize()
        {
            this.AddItem(new MenuItem("EnsageSharp.Common.BlockKeys", "Block player inputs for KeyBinds: ")
                         .SetValue(false))
            .SetTooltip("When a assembly uses a key, dota will ignore it");

            Config.DisableDrawings = false;
            this.AddItem(
                new MenuItem("disableDrawings", "Disable Drawings").SetValue(Config.DisableDrawings)
                .DontSave()
                .SetTooltip(
                    "This option will HIDE menu and all other drawings and particles. This option will get disabled after you press F5",
                    Color.Red)).ValueChanged +=
                (sender, args) => { Config.DisableDrawings = args.GetNewValue <bool>(); };
            this.Item("disableDrawings").SetValue(false);
            Events.OnLoad += this.Events_OnLoad;

            Composer.ComposeParts(this);

            var themes      = this.Themes.Select(theme => theme.Value.ThemeName);
            var themeSelect =
                new MenuItem("Common.Menu.Themes", "Theme").SetValue(new StringList(themes.OrderBy(x => x).ToArray()));

            themeSelect.ValueChanged += (sender, args) =>
            {
                var theme =
                    this.Themes.FirstOrDefault(
                        x => x.Value.ThemeName == args.GetNewValue <StringList>().SelectedValue);
                if (theme == null)
                {
                    return;
                }

                foreach (var rootMenu in RootMenus)
                {
                    foreach (var menuItem in rootMenu.Value.Items)
                    {
                        if (menuItem.FontColor != this.SelectedTheme.ItemDefaultTextColor)
                        {
                            continue;
                        }

                        menuItem.SetFontColor(theme.Value.ItemDefaultTextColor);
                    }

                    foreach (var child in rootMenu.Value.Children)
                    {
                        if (child.Color == this.SelectedTheme.ItemDefaultTextColor)
                        {
                            child.SetFontColor(theme.Value.MenuDefaultTextColor);
                        }

                        foreach (var menuItem in child.Items)
                        {
                            if (menuItem.FontColor != this.SelectedTheme.ItemDefaultTextColor)
                            {
                                continue;
                            }

                            menuItem.SetFontColor(theme.Value.ItemDefaultTextColor);
                        }
                    }
                }

                this.SelectedTheme = theme.Value;
            };

            var defaultTheme =
                this.Themes.FirstOrDefault(x => x.Value.ThemeName == themeSelect.GetValue <StringList>().SelectedValue);

            if (defaultTheme != null)
            {
                this.SelectedTheme = defaultTheme.Value;
            }

            this.settings.AddItem(themeSelect);

            this.SetFontColor(this.SelectedTheme.MenuDefaultTextColor);

            // if (Game.IsInGame)
            // {
            // this.Events_OnLoad(null, null);
            // }
            foreach (var menuItem in this.Items)
            {
                menuItem.SetFontColor(this.SelectedTheme.ItemDefaultTextColor);
            }

            foreach (var child in this.Children)
            {
                child.SetFontColor(this.SelectedTheme.MenuDefaultTextColor);
                foreach (var menuItem in child.Items)
                {
                    menuItem.SetFontColor(this.SelectedTheme.ItemDefaultTextColor);
                }
            }
        }