示例#1
0
        public ContextMenu(ContextMenuTemplate contextMenuTemplate1, ContextMenuTemplate contextMenuTemplate2, Vector2 position, GameObject parent = null, bool leftSide = false, bool destroyOnOtherClick = false) : base(position, null, parent)
        {
            this.texts = new List <string>(contextMenuTemplate1.texts);
            this.tags  = new List <List <string> >(contextMenuTemplate1.tags);
            this.texts.AddRange(contextMenuTemplate2.texts);
            this.tags.AddRange(contextMenuTemplate2.tags);
            this.font                 = contextMenuTemplate1.font;
            this.textures             = contextMenuTemplate1.textures;
            this.transform.LayerDepth = EngManager.layerDepths[LayerDepths.ContextMenu];

            this.destroyOnOtherClick = destroyOnOtherClick;

            this.columns = contextMenuTemplate1.numberOfColumns;
            if (columns < 1)
            {
                columns = 1;
            }

            if (leftSide)
            {
                this.leftSide = -1;
            }
            else
            {
                this.leftSide = 1;
            }

            GenerateButtons(contextMenuTemplate1.ButtonSize);
            GenerateHitbox();
            SetInactives(contextMenuTemplate1);
            SetInactives(contextMenuTemplate2, contextMenuTemplate1.texts.Count);
            GenerateTemplateChildMenus(contextMenuTemplate1);
            GenerateTemplateChildMenus(contextMenuTemplate2, contextMenuTemplate1.texts.Count);
        }
示例#2
0
 public void GiveChildMenus(string tag, ContextMenuTemplate contextMenuTemplate)
 {
     foreach (ContextMenuItem cmi in menuItems)
     {
         if (cmi.tags.Contains(tag))
         {
             cmi.GiveChildMenu(contextMenuTemplate);
         }
     }
 }
        public ContextMenuTemplate Copy()
        {
            ContextMenuTemplate copy = new ContextMenuTemplate();

            copy.textures   = textures;
            copy.texts      = new List <string>(texts);
            copy.font       = font;
            copy.tags       = new List <List <string> >(tags);
            copy.childMenus = new List <ContextMenuTemplate>(childMenus);
            copy.inactives  = new List <bool>(inactives);

            return(copy);
        }
        public ScrollMenuTemplate(ContextMenuTemplate menuTemplate)
        {
            normalButtonsTemplate = menuTemplate;

            upArrow             = null;
            upArrowPosition     = null;
            upArrowSize         = null;
            downArrow           = null;
            downArrowPosition   = null;
            downArrowSize       = null;
            scroller            = null;
            scrollBarBackground = null;
        }
示例#5
0
 public void SetInactives(ContextMenuTemplate template, int append = 0)
 {
     if (template.inactives == null || template.inactives.Count < 1)
     {
         return;
     }
     for (int i = append; i < append + template.inactives.Count; i++)
     {
         if (template.inactives[i - append])
         {
             menuItems[i].Inactivate();
         }
     }
 }
示例#6
0
 public void GenerateTemplateChildMenus(ContextMenuTemplate template, int append = 0)
 {
     if (template.childMenus == null || template.childMenus.Count < 1)
     {
         return;
     }
     for (int i = append; i < append + template.childMenus.Count; i++)
     {
         if (template.childMenus[i - append] != null)
         {
             ContextMenuTemplate nonnull = template.childMenus[i - append] ?? default(ContextMenuTemplate);
             menuItems[i].GiveChildMenu(nonnull);
         }
     }
 }
示例#7
0
        public OldScrollArea(ContextMenuTemplate menuTemplate, List <Vector2> positions, List <ButtonTextures> textures, Vector2 arrowSize, Vector2 buttonSize, int numberOfButtons, int columns = 1, Vector2?sizeScrollBar = null, GameObject parent = null) : base(menuTemplate, positions[(int)ScrollAreaPositions.Body], parent)
        {
            scrollTextureSets  = textures;
            scrollPositionList = positions;
            scrollPosition     = new Vector2(0, 0);
            this.arrowSize     = arrowSize;

            size.X           = (buttonSize.X);
            size.Y           = (numberOfButtons / columns) * buttonSize.Y;
            hitbox.shapeVars = new Vector3(size, 0);
            //MoveTo(hitbox.transform.GlobalPosition);

            Debug.WriteLine(hitbox.RectangleHB());

            MakeArrowButtons();
            MakeScroller();

            foreach (ContextMenuItem menuItem in menuItems)
            {
                menuItem.transform.localPosition += new Vector2(0, (int)(numberOfButtons / 2)) * buttonSize;
            }
        }
示例#8
0
 public void GiveChildMenu(ContextMenuTemplate hoverMenuTemplate)
 {
     this.hoverMenuTemplate = hoverMenuTemplate;
     childMenu = true;
 }