예제 #1
0
            internal static void AddToMainMenu()
            {
                Menu = TargetSelector.Menu.AddSubMenu(new Menu("Weights", TargetSelector.Menu.Name + ".weights"));

                Heroes.AddToWeightMenu();

                Menu.AddItem(
                    new MenuItem(Menu.Name + ".caching", "Caching %").SetShared()
                    .SetValue(new Slider(ItemCache.MaxAge, MinCaching, MaxCaching)))
                .SetTooltip("0 = Real Time Calculations | Milliseconds")
                .ValueChanged += (sender, args) => ItemCache.MaxAge = args.GetNewValue <Slider>().Value;

                foreach (var item in Items)
                {
                    var localItem  = item;
                    var weightItem =
                        new MenuItem(Menu.Name + "." + item.UniqueName, GetDisplayNamePrefix(item) + item.DisplayName)
                        .SetShared().SetValue(new Slider(localItem.Weight, MinWeight, MaxWeight));
                    if (!string.IsNullOrWhiteSpace(item.Tooltip))
                    {
                        weightItem.SetTooltip(item.Tooltip);
                    }
                    Menu.AddItem(weightItem);
                    Menu.Item(Menu.Name + "." + item.UniqueName).ValueChanged +=
                        delegate(object sender, OnValueChangeEventArgs args)
                    {
                        localItem.OnWeightChange(args.GetNewValue <Slider>().Value);
                    };
                    item.Weight = TargetSelector.Menu.Item(Menu.Name + "." + item.UniqueName).GetValue <Slider>().Value;
                }

                ItemCache.MaxAge = Utils.GetMenuItemValue <int>(Menu, ".caching");

                Game.OnInput += OnGameInput;
            }