SetLeftBadge() public method

Set the left badge. Set it to None to remove the badge.
public SetLeftBadge ( BadgeStyle badge ) : void
badge BadgeStyle
return void
Esempio n. 1
0
 public void AddMenuCook(UIMenu menu)
 {
     var newitem = new UIMenuItem("Cook!", "Cook the dish with the appropiate ingredients and ketchup.");
     newitem.SetLeftBadge(UIMenuItem.BadgeStyle.Star);
     newitem.SetRightBadge(UIMenuItem.BadgeStyle.Tick);
     menu.AddItem(newitem);
     menu.OnItemSelect += (sender, item, index) =>
     {
         if (item == newitem)
         {
             string output = ketchup ? "You have ordered ~b~{0}~w~ ~r~with~w~ ketchup." : "You have ordered ~b~{0}~w~ ~r~without~w~ ketchup.";
             UI.ShowSubtitle(String.Format(output, dish));
         }
     };
     menu.OnIndexChange += (sender, index) =>
     {
         if (sender.MenuItems[index] == newitem)
             newitem.SetLeftBadge(UIMenuItem.BadgeStyle.None);
     };
 }
Esempio n. 2
0
    public MenuExample()
    {
        Tick += OnTick;
        KeyDown += OnKeyDown;
        _menuPool = new MenuPool();

        mainMenu = new UIMenu("Native UI", "~b~NATIVEUI SHOWCASE");
        _menuPool.Add(mainMenu);

        mainMenu.AddItem(ketchupCheckbox = new UIMenuCheckboxItem("Add ketchup?", false, "Do you wish to add ketchup?"));
        var foods = new List<dynamic>
        {
            "Banana",
            "Apple",
            "Pizza",
            "Quartilicious",
            0xF00D, // Dynamic!
        };
        mainMenu.AddItem(dishesListItem = new UIMenuListItem("Food", foods, 0));
        mainMenu.AddItem(cookItem = new UIMenuItem("Cook!", "Cook the dish with the appropiate ingredients and ketchup."));

        var menuItem = new UIMenuItem("Go to another menu.");
        mainMenu.AddItem(menuItem);
        cookItem.SetLeftBadge(UIMenuItem.BadgeStyle.Star);
        cookItem.SetRightBadge(UIMenuItem.BadgeStyle.Tick);
        mainMenu.RefreshIndex();

        mainMenu.OnItemSelect += OnItemSelect;
        mainMenu.OnListChange += OnListChange;
        mainMenu.OnCheckboxChange += OnCheckboxChange;
        mainMenu.OnIndexChange += OnItemChange;

        newMenu = new UIMenu("Native UI", "~r~NATIVEUI SHOWCASE");
        _menuPool.Add(newMenu);
        for (int i = 0; i < 20; i++)
        {
            newMenu.AddItem(new UIMenuItem("PageFiller", "Sample description that takes more than one line. Moreso, it takes way more than two lines since it's so long. Wow, check out this length!"));
        }
        newMenu.RefreshIndex();
        mainMenu.BindMenuToItem(newMenu, menuItem);
    }
Esempio n. 3
0
 public void AddActorActionToMenu(UIMenu menu, String name, Action<UIMenuItem, int> action, Func<int, bool> ticked)
 {
     var submenu = AddSubMenu(menu, name);
     for (int i = 0; i < 10; i++)
     {
         var subsubmenu = AddSubMenu(submenu, String.Format("Actors {0}-{1}", 1 + i * 10, 10 + i * 10));
         for (int j = 0; j < 10; j++)
         {
             var slot = 1 + j + i * 10;
             var slotitem = new UIMenuItem(String.Format("Actor {0}", slot));
             subsubmenu.AddItem(slotitem);
             if (ticked(slot)) slotitem.SetLeftBadge(UIMenuItem.BadgeStyle.Tick);
             subsubmenu.OnItemSelect += (sender, item, index) =>
             {
                 if (item == slotitem) action(slotitem, slot);
             };
         }
     }
 }
Esempio n. 4
0
        private void RedrawFilepickerMenu(string folder = null)
        {
            if (folder == null) folder = Directory.GetCurrentDirectory();
            _filepicker.Clear();
            _filepicker.Subtitle.Caption = "~b~" + GetSafeShortReverseString(folder, 30);

            var backup = new UIMenuItem("..");
            backup.SetLeftBadge(UIMenuItem.BadgeStyle.Franklin);
            backup.Activated += (sender, item) =>
            {
                RedrawFilepickerMenu(Directory.GetParent(folder).ToString());
            };

            if (Directory.GetParent(folder) == null)
                backup.Enabled = false;

            _filepicker.AddItem(backup);

            foreach (var directory in Directory.EnumerateDirectories(folder))
            {
                var dirItem = new UIMenuItem(GetSafeShortString(Path.GetFileName(directory), 40));
                dirItem.SetLeftBadge(UIMenuItem.BadgeStyle.Franklin);
                dirItem.Activated += (sender, item) =>
                {
                    RedrawFilepickerMenu(directory);
                };

                _filepicker.AddItem(dirItem);
            }

            foreach (var file in Directory.EnumerateFiles(folder))
            {
                var item = new UIMenuItem(GetSafeShortString(Path.GetFileName(file), 40));
                _filepicker.FormatDescriptions = false;

                MapSerializer.Format mapFormat = MapSerializer.Format.NormalXml;
                string description = "";

                if (file.EndsWith(".ini"))
                {
                    mapFormat = MapSerializer.Format.SimpleTrainer;
                }
                else if (file.EndsWith(".SP00N"))
                {
                    mapFormat = MapSerializer.Format.SpoonerLegacy;
                }
                else if (file.EndsWith(".xml"))
                {
                    mapFormat = MapSerializer.Format.NormalXml;
                    Map map = null;

                    try
                    {
                        var ser = new XmlSerializer(typeof(Map));
                        using (var stream = File.OpenRead(file))
                            map = (Map) ser.Deserialize(stream);
                    }
                    catch (Exception) {}

                    if (map == null)
                    {
                        try
                        {
                            var spReader = new XmlSerializer(typeof(MenyooCompatibility.SpoonerPlacements));
                            MenyooCompatibility.SpoonerPlacements newMap = null;
                            using (var stream = File.OpenRead(file))
                                newMap = (MenyooCompatibility.SpoonerPlacements)spReader.Deserialize(stream);

                            if (newMap != null)
                            {
                                description = "~h~Format:~h~ Menyoo Trainer";
                                mapFormat = MapSerializer.Format.Menyoo;
                            }
                        }
                        catch (Exception) { }
                    }

                    if (map != null && map.Metadata != null)
                    {
                        description = "~h~Format:~h~ Map Editor\n~h~Name:~h~ " + map.Metadata.Name + "\n~h~Author:~h~ " +
                                      map.Metadata.Creator + "\n" + FormatDescription("~h~Description:~h~ " + map.Metadata.Description);
                    }
                }
                else
                {
                    continue;
                }

                item.Description = description;

                item.Activated += (sender, selectedItem) =>
                {
                    _filepicker.Visible = false;
                    LoadMap(file, mapFormat);
                };

                _filepicker.AddItem(item);
            }

            _filepicker.RefreshIndex();
        }