Exemplo n.º 1
0
 /// <summary>
 /// Sets the checkmark state for the specified menu item. Note that this flag
 /// will be ignored if the item didn't originally have its 'checkable' flag set.
 /// If this item is part of a mutex group, then the other items in the group
 /// will be unchecked when this item is checked.
 /// </summary>
 /// <param name='id'>
 /// The menu item id number.
 /// </param>
 /// <param name='isChecked'>
 /// The desired checkmark state.
 /// </param>
 public void SetChecked(int id, bool isChecked)
 {
     CtxHelper.SetChecked(menuItems, id, isChecked);
     if (contextMenu != null)
     {
         contextMenu.UpdateVisibleState();
     }
 }
Exemplo n.º 2
0
    public void OnShowMenu(CtxObject obj)
    {
        if (menuItems == null)
        {
            int cnt = (int)MenuItemID.Count;
            menuItems = new CtxMenu.Item[cnt];
            for (int i = 0; i < cnt; i++)
            {
                MenuItemID itemID = (MenuItemID)i;

                menuItems[i]      = new CtxMenu.Item();
                menuItems[i].text = ItemText(itemID);
                if (menuItems[i].text.StartsWith("Separator"))
                {
                    menuItems[i].isSeparator = true;
                }
                else
                {
                    menuItems[i].id = i;
                }
            }

            menuItems[(int)MenuItemID.Small].isCheckable  = true;
            menuItems[(int)MenuItemID.Medium].isCheckable = true;
            menuItems[(int)MenuItemID.Large].isCheckable  = true;

            menuItems[(int)MenuItemID.Small].mutexGroup  = 0;
            menuItems[(int)MenuItemID.Medium].mutexGroup = 0;
            menuItems[(int)MenuItemID.Large].mutexGroup  = 0;

            menuItems[(int)MenuItemID.Stealth].isCheckable = true;
            menuItems[(int)MenuItemID.Shield].isCheckable  = true;
        }

        if (transform.localScale.x == 1f)
        {
            CtxHelper.SetChecked(menuItems, (int)MenuItemID.Small, true);
        }
        else if (transform.localScale.x == 2f)
        {
            CtxHelper.SetChecked(menuItems, (int)MenuItemID.Medium, true);
        }
        else
        {
            CtxHelper.SetChecked(menuItems, (int)MenuItemID.Large, true);
        }

        menuItems[(int)MenuItemID.Stealth].isChecked = stealthOn;
        menuItems[(int)MenuItemID.Shield].isChecked  = shieldOn;

        obj.menuItems = menuItems;
    }