Exemplo n.º 1
0
        public override bool AddMenuItem(MenuItem item, ItemCallback callback)
        {
            if (root.transform.Find(item.name) == null)
            {
                int i        = menuInfo.count++;
                int tabIndex = i / menuInfo.itemsPerTab;

                Transform tab = GetTab(tabIndex).transform;

                Vector3    pos      = menuInfo.start - new Vector3(0, (i % menuInfo.itemsPerTab) * menuInfo.height, 0);
                GameObject currText = GameObject.Instantiate(textBox);

                // Set attributes.
                currText.transform.SetParent(tab);
                currText.transform.localPosition = pos;
                currText.transform.localRotation = Quaternion.identity;
                currText.transform.localScale    = new Vector3(1, 1, 1);
                currText.name  = item.name;
                currText.layer = Menu.menuLayer;
                currText.GetComponent <RectTransform>().sizeDelta = new Vector2(menuInfo.width, menuInfo.height);
                currText.GetComponent <BoxCollider>().size        = new Vector3(menuInfo.width, menuInfo.height, 0);

                // Add callback.
                SetCallback(item.name, callback);

                // Set text.
                TextMeshPro tmp = currText.GetComponent <TextMeshPro>();
                tmp.text = item.name;
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        public static unsafe void ConvertItem(Item item, ItemCallback callback)
        {
            var newItem = Item.GetThreadLocalItem();

            newItem->ItemUnion = new CEventTrace.Item.Union();
            newItem->ItemType  = (CEventTrace.ItemType)item.ItemType;
            switch (item.ItemType)
            {
            case ItemType.Span:
                var spanItem = item.Span.Value;
                newItem->ItemUnion.Span            = new CEventTrace.Span();
                newItem->ItemUnion.Span.Id         = ConvertSpanId(spanItem.Id);
                newItem->ItemUnion.Span.CauseCount = (uint)spanItem.Causes.Length;
                var causesPointer = stackalloc CEventTrace.SpanId[spanItem.Causes.Length];
                newItem->ItemUnion.Span.Causes = causesPointer;
                for (var i = 0; i < newItem->ItemUnion.Span.CauseCount; i++)
                {
                    newItem->ItemUnion.Span.Causes[i] = ConvertSpanId(spanItem.Causes[i]);
                }

                callback(newItem);

                break;

            case ItemType.Event:
                var eventItem = item.Event.Value;
                ConvertEvent(eventItem, internalEvent =>
                {
                    newItem->ItemUnion.Event = internalEvent;
                    callback(newItem);
                });

                break;
            }
        }
Exemplo n.º 3
0
        public override bool AddMenuItem(MenuItem item, ItemCallback callback)
        {
            int       i        = panelInfo.count++;
            int       tabIndex = i / panelInfo.itemsPerTab;
            Transform tab      = GetTab(tabIndex).transform;

            // Create and append panel.
            Vector3 pos = new Vector3((i % panelInfo.itemsPerRow), -i / panelInfo.itemsPerRow, 0);

            pos.Scale(panelInfo.scale);
            GameObject currPanel = GameObject.Instantiate(panel);

            currPanel.transform.SetParent(tab);
            currPanel.transform.localPosition = panelInfo.start + pos;
            currPanel.transform.localRotation = Quaternion.identity;
            currPanel.transform.localScale    = panelInfo.scale;
            currPanel.name  = item.name;
            currPanel.layer = Menu.menuLayer;

            // Add callback.
            SetCallback(item.name, callback);

            // Set Texture.
            currPanel.GetComponent <Renderer>().material.SetTexture("_MainTex", item.texture);
            return(true);
        }
Exemplo n.º 4
0
 public new void Process(ItemCallback callback)
 {
     Assert.IsNotNull(Database, "database");
     Assert.IsNotNull(Path, "path");
     var item = Factory.GetDatabase(Database).GetItem(Path);
     if (item != null)
     {
         callback(item);
     }
 }
Exemplo n.º 5
0
        public new void Process(ItemCallback callback)
        {
            Assert.IsNotNull(Database, "database");
            Assert.IsNotNull(Path, "path");
            var item = Factory.GetDatabase(Database).GetItem(Path);

            if (item != null)
            {
                callback(item);
            }
        }
Exemplo n.º 6
0
        public void UpdateItem(object i)
        {
            DownloadQueueItem it = i as DownloadQueueItem;

            if (InvokeRequired)
            {
                ItemCallback d = new ItemCallback(DoUpdateItem);
                Invoke(d, it);
            }
            else
            {
                DoUpdateItem(it);
            }
        }
Exemplo n.º 7
0
        void IContainerUI.InsertItem(object i)
        {
            SharedFileItem it = i as SharedFileItem;

            if (InvokeRequired)
            {
                ItemCallback d = new ItemCallback(DoInsertItem);
                Invoke(d, it);
            }
            else
            {
                DoInsertItem(it);
            }
        }
Exemplo n.º 8
0
    public void show(IEnumerable <Item> items, ItemCallback callback)
    {
        _callback = callback;

        deleteItems();

        show();

        //TODO: Filter

        foreach (Item item in items)
        {
            ItemSelectWindowItem uiItem = Instantiate(ItemPrefab, ItemsContainer);
            uiItem.setItem(item, this);
        }
    }
Exemplo n.º 9
0
        public override bool AddMenuItem(MenuItem item, ItemCallback callback)
        {
            int       i        = panelInfo.count++;
            int       tabIndex = i / panelInfo.itemsPerCol;
            int       rowIndex = i % panelInfo.itemsPerCol;
            Transform tab      = GetTab(tabIndex).transform;

            float   height = 1.0f / (panelInfo.itemsPerCol * 3);
            Vector3 pos    = new Vector3(0, -rowIndex * (1.0f / panelInfo.itemsPerCol), 0);

            pos += panelInfo.start;

            // Profile image.
            GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad);

            PositionItem(quad.transform, tab.gameObject, pos, Quaternion.identity, panelInfo.imageScale);
            quad.GetComponent <Renderer>().material.SetTexture("_MainTex", item.texture);

            // Name
            GameObject name = GameObject.Instantiate(textobj);

            PositionItem(name.transform, tab.gameObject, pos + new Vector3(panelInfo.imageScale.x / 2.0f + panelInfo.nameDim.x / 2.0f, 0, 0), Quaternion.identity, new Vector3(1, 1, 1));
            name.GetComponent <RectTransform>().sizeDelta = panelInfo.nameDim;
            name.GetComponent <BoxCollider>().size        = new Vector3(panelInfo.nameDim.x, panelInfo.nameDim.y, 0);
            name.GetComponent <TextMeshPro>().text        = (string)item.fields[0];
            name.GetComponent <TextMeshPro>().fontSize    = 0.5f;

            // Status
            GameObject status = GameObject.Instantiate(textobj);

            PositionItem(status.transform, tab.gameObject, new Vector3(0, pos.y - (panelInfo.imageScale.y / 2.0f + panelInfo.statusDim.y / 2.0f), 0), Quaternion.identity, new Vector3(1, 1, 1));
            status.GetComponent <RectTransform>().sizeDelta = panelInfo.statusDim;
            status.GetComponent <BoxCollider>().size        = new Vector3(panelInfo.statusDim.x, panelInfo.statusDim.y, 0);
            status.GetComponent <TextMeshPro>().text        = (string)item.fields[1];
            status.GetComponent <TextMeshPro>().fontSize    = 0.35f;

            // Add callback.
            SetCallback(item.name, callback);

            return(true);
        }
Exemplo n.º 10
0
 public void show(ItemsCollection itemsCollection, ItemCallback callback)
 {
     show(itemsCollection.getItems(), callback);
 }
Exemplo n.º 11
0
 /// <summary>
 ///     Adds a new item to the menu.
 /// </summary>
 /// <param name="item"> The item to add. </param>
 /// <param name="callback"> The callback associated with that item. </param>
 /// <returns></returns>
 public abstract bool AddMenuItem(MenuItem item, ItemCallback callback);
Exemplo n.º 12
0
 // Methods.
 /// <summary>
 ///     Sets a callback for a given item of that menu. The function is called when
 ///     the item is selected from the menu.
 /// </summary>
 /// <param name="name"> The name of the item. </param>
 /// <param name="callback"> The callback for the item. </param>
 protected void SetCallback(string name, ItemCallback callback)
 {
     callbacks.Add(name, callback);
 }
        public void ItemASync(string itemId, ItemCallback callback)
        {
            var query = GetQueryTranslator().Translate(itemId);
            var dlgt = new LoadJsonDelegate(_service.LoadContent);

            dlgt.BeginInvoke(query,
                ItemAsyncCallback,
                new AsyncItemCallbackParameter { Delegate = dlgt, CallbackFunction = callback });
        }
Exemplo n.º 14
0
 internal static extern int ForeachItem(ItemCallback callback, IntPtr userData);