Ejemplo n.º 1
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="pSelected"></param>
    /// <returns>是否点击</returns>
    public bool drawGUI(ref zzGUILibTreeElement pSelected)
    {
        //if (treeNode.changed)
        //    setTreeNode(treeNode);
        bool lOut = false;
        GUILayout.BeginVertical();
        {
            GUILayout.BeginHorizontal();
            {
                foreach (var lTitleInfo in titleList)
                {
                    GUILayout.Label(lTitleInfo.showName, titleStyle,
                        GUILayout.Width(lTitleInfo.width));
                }
            }
            GUILayout.EndHorizontal();
            foreach (var lElement in treeNode.elements)
            {
                var lStyle = getStyle(pSelected, lElement);
                var lShowData = lElement.stringInfo;
                bool lIsClick = false;
                GUILayout.BeginHorizontal();
                {
                    if (lShowData == null)
                    {
                        foreach (var lTitleInfo in titleList)
                            lIsClick |= GUILayout.Button("", lStyle, GUILayout.Width(lTitleInfo.width));
                    }
                    else
                    {
                        foreach (var lTitleInfo in titleList)
                        {
                            string lData;
                            if (!lShowData.TryGetValue(lTitleInfo.name, out lData))
                                lData = "";
                            lIsClick |= GUILayout.Button(lData, lStyle, GUILayout.Width(lTitleInfo.width));
                        }
                    }
                }
                if (lIsClick)
                {
                    pSelected = lElement;
                    lOut = true;
                }
                GUILayout.EndHorizontal();
            }

        }
        GUILayout.EndVertical();

        return lOut;
    }
Ejemplo n.º 2
0
 zzGUILibTreeElement[] getLevelInFolder(string pLevelRootFolder)
 {
     DirectoryInfo lDirectory = new DirectoryInfo(pLevelRootFolder);
     var lLevelDirectorise =  lDirectory.GetDirectories();
     var lLevelElement = new List<zzGUILibTreeElement>(lLevelDirectorise.Length);
     foreach (var lLevelDir in lLevelDirectorise)
     {
         var lMainFileName = lLevelDir.FullName + "/" + mainFileName;
         if (File.Exists(lMainFileName))
         {
             var lGUIElement = new zzGUILibTreeElement();
             lGUIElement.name = lLevelDir.Name;
             lGUIElement.image = defaultLevelImage;
             lGUIElement.stringData = lLevelDir.Name;
             //lGUIElement.objectData = lInfoElement.data;
             lLevelElement.Add( lGUIElement );
         }
     }
     return lLevelElement.ToArray();
 }
Ejemplo n.º 3
0
    public void drawTree()
    {
        if (Application.isPlaying)
        {
            viewScroll = GUILayout.BeginScrollView(viewScroll);
            var lNewSelected = selectedElement;
            rootTreeView.imageSize = imageSize;

            if (rootTreeView.drawGUI(ref lNewSelected))
            {
                selectedElement = lNewSelected;
                if (lNewSelected is zzGUILibTreeNode)
                    nodeClickedEvent(selectedElement.stringData);
                else// (lNewSelected is zzGUILibTreeElement)
                {
                    elementClickedEvent(selectedElement.stringData);
                    elementClickedObjectEvent(selectedElement.objectData);
                }
            }
            GUILayout.EndScrollView();
        }
    }
Ejemplo n.º 4
0
    public static zzGUILibTreeNode getGUITreeNode(this GameSystem.InfoNode pInfoNode,
        Texture2D pDefaultCollapsedNodeImg, Texture2D pDefaultExpandedNodeImg)
    {
        var elements = pInfoNode.elements;
        var image = pInfoNode.image;
        var nodes = pInfoNode.nodes;
        var showName = pInfoNode.showName;
        zzGUILibTreeNode lOut = new zzGUILibTreeNode();
        lOut.name = showName;
        lOut.image = image ? image : pDefaultCollapsedNodeImg;
        lOut.expandedImage = pInfoNode.expandedImage ? pInfoNode.expandedImage : pDefaultExpandedNodeImg;

        var lGUIElements = new List<zzGUILibTreeElement>(elements.Length);
        for (int i = 0; i < elements.Length; ++i)
        {
            var lInfoElement = elements[i];
            if (!lInfoElement.isShow)
                continue;
            var lGUIElement = new zzGUILibTreeElement();
            lGUIElement.name = lInfoElement.showName;
            lGUIElement.image = lInfoElement.image;
            lGUIElement.stringData = lInfoElement.name;
            lGUIElement.objectData = lInfoElement.data;
            //lGUIElements[i] = lGUIElement;
            lGUIElements.Add(lGUIElement);
        }
        lOut.elements = lGUIElements.ToArray();

        var lGUINode = new zzGUILibTreeNode[nodes.Length];
        for (int i = 0; i < nodes.Length; ++i)
        {
            lGUINode[i] = nodes[i].getGUITreeNode(pDefaultCollapsedNodeImg, pDefaultExpandedNodeImg);
        }
        lOut.nodes = lGUINode;

        return lOut;
    }
Ejemplo n.º 5
0
 public void updateHostList()
 {
     var lServerList = serverList.serverList;
     var lElements = new zzGUILibTreeElement[lServerList.Count];
     int i = 0;
     Dictionary<string, zzGUILibTreeElement> lIdToElement
         = new Dictionary<string, zzGUILibTreeElement>();
     foreach (var lElement in treeInfo.treeInfo.elements)
     {
         //var lInfo = lElement.stringInfo;
         lIdToElement[lElement.stringData] = lElement;
     }
     foreach (var lServerDic in lServerList)
     {
         var lServer = lServerDic.Value;
         Hashtable lTableData = (Hashtable)zzSerializeString.Singleton
             .unpackToData(lServer.comment);
         zzGUILibTreeElement lElement;
         if (lIdToElement.TryGetValue(lServerDic.Key, out lElement))
         {
             lIdToElement.Remove(lServerDic.Key);
         }
         else
         {
             lElement = new zzGUILibTreeElement();
             lElement.stringData = lServerDic.Key;
         }
         //string lHostPlayName = (string)lTableData["playerName"];
         //string lHostMap = (string)lTableData["map"];
         var lStringInfo =new Dictionary<string, string>();
         lStringInfo["mapName"] = (string)lTableData["map"];
         lStringInfo["playerName"] = (string)lTableData["playerName"];
         lStringInfo["IP"] = lServer.IP;
         lElement.stringInfo = lStringInfo;
         lElements[i] = lElement;
         ++i;
     }
     zzGUILibTreeNode lNode = new zzGUILibTreeNode();
     lNode.elements = lElements;
     treeInfo.treeInfo.setData(lNode);
 }
Ejemplo n.º 6
0
 bool drawSubElement(ref zzGUILibTreeElement pSelected)
 {
     return false;
 }
Ejemplo n.º 7
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="pSelected"></param>
    /// <returns>是否点击</returns>
    bool drawSubElement(ref zzGUILibTreeElement pSelected)
    {
        zzGUILibTreeElement lNewSelected = null;
        foreach (var lElement in treeNode.elements)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(imageSize * (TreeDepth + 1));
            if (GUILayout.Button(lElement.content,
                    getStyle(pSelected, lElement),
                    GUILayout.Height(imageSize))
                )
                lNewSelected = lElement;
            GUILayout.EndHorizontal();
        }

        if (lNewSelected != null)
        {
            pSelected = lNewSelected;
            return true;
        }
        return false;
    }
Ejemplo n.º 8
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="pSelected"></param>
    /// <returns>是否点击</returns>
    bool drawSelfNode(ref zzGUILibTreeElement pSelected)
    {
        GUILayout.BeginHorizontal();
        GUILayout.Space(imageSize * TreeDepth);
        bool lNewExpanded = GUILayout.Toggle(
            expanded,
            expanded ? treeNode.expandedNodeContent : treeNode.collapsedNodeContent,
            getStyle(pSelected, treeNode),
            GUILayout.Height(imageSize));
        GUILayout.EndHorizontal();

        if (expanded != lNewExpanded)
        {
            pSelected = treeNode;
            expanded = lNewExpanded;
            return true;
        }
        return false;
    }
Ejemplo n.º 9
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="pSelected"></param>
    /// <returns>是否点击</returns>
    public bool drawGUI(ref zzGUILibTreeElement pSelected)
    {
        if (treeNode.changed)
            setTreeNode(treeNode);

        //zzGUILibTreeElement lNewSelected = null;

        //print("TreeDepth:" + TreeDepth);
        //print(directoryInfo.Name+Folders.Count);
        bool lIsClick = false;
        GUILayout.BeginVertical();
        {
            foreach (var lView in subViews)
            {
                //执行drawSelfNode时会改变expanded,所以先将其保存
                bool lPreExpanded = lView.expanded;
                lView.imageSize = imageSize;
                lIsClick |= lView.drawSelfNode(ref pSelected);
                if (lPreExpanded)
                    lIsClick|=lView.drawGUI(ref pSelected);
            }
            lIsClick |= drawSubElement(ref pSelected);
        }
        GUILayout.EndVertical();
        return lIsClick;
    }