Ejemplo n.º 1
0
 private void UpdatePeoples(List <ManyPeopleName> manyPeopleList, bool isShow2Name)
 {
     if (null == manyPeopleList || manyPeopleList.Count <= 0)
     {
         return;
     }
     for (int i = 0; i < manyPeopleList.Count; i++)
     {
         ManyPeopleName names = manyPeopleList[i];
         ManyPeopleItem item  = GetNewManyPeopleItem(names.NameList.Count, isShow2Name);
         item.name = "ManyPeopleName_" + i.ToString("D4");
         item.UpdateNames(names.NameList.ToArray());
     }
     this.m_Grid.cellHeight = this.CellHeight;
     this.m_Grid.Reposition();
 }
Ejemplo n.º 2
0
 private void ShowCurContent()
 {
     if (null != m_TeamsInfo && m_TeamsInfo.Count > 0)
     {
         if (m_CurShowIndex >= 0 && m_CurShowIndex < m_TeamsInfo.Count)
         {
             TeamInfo curTeamInfo = m_TeamsInfo[m_CurShowIndex];
             m_TitleLabel.text = curTeamInfo.TitleStr;
             m_TitleLabel.MakePixelPerfect();
             List <string> peoplesName = curTeamInfo.PeoplesStr;
             if (null != peoplesName && peoplesName.Count > 0)
             {
                 for (int i = 0; i < peoplesName.Count; i += m_ColumnCount)
                 {
                     ManyPeopleItem item = GetNewKickstarterItem();
                     item.UpdateNames(peoplesName.GetRange(i, (i + m_ColumnCount >= peoplesName.Count)? (peoplesName.Count - i):m_ColumnCount));
                 }
                 RepositionVertical();
             }
         }
     }
 }
Ejemplo n.º 3
0
    //lz-2016.06.13 这种方法可以使可以更便捷的调整每一块,每一条上下左右的间距,和对齐问题
    void XmlModeFillContent()
    {
        //lz-2016.08.02 这里不能用全路径Load
        TextAsset   textAsset = Resources.Load("Credits/CreditsXml", typeof(TextAsset)) as TextAsset;
        XmlDocument xmlDoc    = new XmlDocument();

        xmlDoc.LoadXml(textAsset.text);

        //root
        XmlNode rootNode = xmlDoc.SelectSingleNode("Root");

        //title
        XmlElement     titleNode = (XmlElement)rootNode.SelectSingleNode("Title");
        ManyPeopleItem titleItem = GetNewParticipantItem();

        titleItem.UpdateNames(titleNode.GetAttribute("Name"));
        //Participant
        XmlNode participantNode = rootNode.SelectSingleNode("Participant");

        for (int i = 0; i < participantNode.ChildNodes.Count; i++)
        {
            XmlElement professionNode = (XmlElement)participantNode.ChildNodes[i];


            //lz-2016.08.15 Kickstarter Backers人员较多,所以结构不一样
            if (professionNode.GetAttribute("Name").Equals("Kickstarter Backers") ||
                (professionNode.GetAttribute("Name").Equals("Other Contributors")))
            {
                List <string> kBNames = new List <string>();
                for (int k = 0; k < professionNode.ChildNodes.Count; k++)
                {
                    XmlElement peopleNode = (XmlElement)professionNode.ChildNodes[k];
                    string     tempStr    = string.Empty;
                    for (int aIndex = 0; aIndex < this.m_MaxCol; aIndex++)
                    {
                        tempStr = peopleNode.GetAttribute("Name" + aIndex);
                        if (string.IsNullOrEmpty(tempStr))
                        {
                            continue;
                        }
                        kBNames.Add(tempStr);
                    }
                }
                List <string> shotNames = new List <string> ();
                List <string> longNames = new List <string> ();
                kBNames.ForEach(name => { if (name.Length <= this.m_MaxNameWidth)
                                          {
                                              shotNames.Add(name);
                                          }
                                          else
                                          {
                                              longNames.Add(name);
                                          } });
                shotNames = shotNames.OrderBy(a => a.Length).ToList();
                //lz-2016.08.16 如果名字短的不是整行数,就把不够一行的那个几个元素放到长名字里面去
                if (shotNames.Count % this.m_MaxCol != 0 && longNames.Count > 0)
                {
                    int startIndex = shotNames.Count - (shotNames.Count % this.m_MaxCol);
                    longNames.AddRange(shotNames.GetRange(startIndex, shotNames.Count - startIndex));
                    shotNames.RemoveRange(startIndex, shotNames.Count - startIndex);
                }
                longNames = longNames.OrderBy(a => a.Length).ToList();
                if (shotNames.Count > 0)
                {
                    int                   professionCount    = 0;
                    ProfessionItem        professionItem     = null;
                    List <ManyPeopleName> manyPeopleNameList = new List <ManyPeopleName> ();
                    string                professionName     = professionNode.GetAttribute("Name");
                    for (int j = 0; j < shotNames.Count; j += this.m_MaxCol)
                    {
                        professionCount++;
                        int      count = j + this.m_MaxCol < shotNames.Count?this.m_MaxCol:shotNames.Count - j;
                        string[] names = shotNames.GetRange(j, count).ToArray();
                        manyPeopleNameList.Add(new ManyPeopleName(names));
                        if (professionCount % this.m_ProfessionItemMaxCapacity == 0 || j + this.m_MaxCol >= shotNames.Count)
                        {
                            professionItem = this.GetNewProfessionItem();
                            professionItem.UpdateInfo(new ProfessionInfo(professionName, manyPeopleNameList), false);
                            manyPeopleNameList.Clear();
                            professionName = "";
                        }
                    }
                }
                if (longNames.Count > 0)
                {
                    ProfessionItem        professionItem = null;
                    List <ManyPeopleName> namelist       = new List <ManyPeopleName>();
                    int    professionCount = 0;
                    string professionName  = shotNames.Count > 0?"":professionNode.GetAttribute("Name");
                    for (int m = 0; m < longNames.Count; m += 2)
                    {
                        professionCount++;
                        namelist.Add(new ManyPeopleName(longNames[m], m + 1 < longNames.Count ? longNames[m + 1] : ""));
                        if (professionCount % this.m_ProfessionItemMaxCapacity == 0 || m + 2 >= longNames.Count)
                        {
                            professionItem = this.GetNewProfessionItem();
                            professionItem.UpdateInfo(new ProfessionInfo(professionName, namelist));
                            namelist.Clear();
                        }
                    }
                }
            }
            else
            {
                ProfessionItem        professionItem = this.GetNewProfessionItem();
                List <ManyPeopleName> namelist       = new List <ManyPeopleName>();
                for (int j = 0; j < professionNode.ChildNodes.Count; j++)
                {
                    XmlElement peopleNode = (XmlElement)professionNode.ChildNodes[j];
                    namelist.Add(new ManyPeopleName(peopleNode.GetAttribute("EnglishName"), peopleNode.GetAttribute("ChineseName")));
                }
                professionItem.UpdateInfo(new ProfessionInfo(professionNode.GetAttribute("Name"), namelist));
            }
        }
        //End
        XmlElement endNode = (XmlElement)rootNode.SelectSingleNode("End");

        this.m_EndManyPeopleItem = GetNewParticipantItem();
        this.m_EndManyPeopleItem.UpdateNames(endNode.GetAttribute("Name"));
    }