Esempio n. 1
0
 private void OnInsChanged(long id, int hash)
 {
     //screen refresh is only needed when an GPS applies to this player
     if (id == MySession.Static.LocalPlayerId)
     {
         FillRight();
         //color/name in table:
         int i = 0;
         while (i < m_tableIns.RowsCount)
         {
             if (((MyGps)m_tableIns.GetRow(i).UserData).GetHashCode() == hash)
             {
                 Sandbox.Graphics.GUI.MyGuiControlTable.Cell cell = m_tableIns.GetRow(i).GetCell(0);
                 if (cell != null)
                 {
                     MyGps ins = (MyGps)m_tableIns.GetRow(i).UserData;
                     cell.TextColor = (ins.DiscardAt != null ? Color.Gray : (ins.ShowOnHud ? ITEM_SHOWN_COLOR : Color.White));
                     cell.Text.Clear().Append(((MyGps)m_tableIns.GetRow(i).UserData).Name);
                     //FillRight((MyIns)m_tableIns.SelectedRow.UserData);
                 }
                 break;
             }
             ++i;
         }
     }
 }
 public void OnNameChanged(MyGuiControlTextbox sender)
 {
     m_needsSyncName = true;
     //":" is not valid:
     if (IsNameOk(sender.Text))
     {
         m_nameOk = true;
         sender.ColorMask = Vector4.One;
         //propagate new name into table and re-sort:
         Sandbox.Graphics.GUI.MyGuiControlTable.Row selected = m_tableIns.SelectedRow;
         Sandbox.Graphics.GUI.MyGuiControlTable.Cell cell = selected.GetCell(0);
         if (cell != null)
             cell.Text.Clear().Append(sender.Text);
         m_tableIns.SortByColumn(0, MyGuiControlTable.SortStateEnum.Ascending);
         //select same entry:
         for (int i=0;i<m_tableIns.RowsCount;i++)
             if (selected == m_tableIns.GetRow(i))
             {
                 m_tableIns.SelectedRowIndex = i;
                 break;
             }
         m_tableIns.ScrollToSelection();
     }
     else
     {
         m_nameOk = false;
         sender.ColorMask = Color.Red.ToVector4();
     }
     updateWarningLabel();
 }