int StatsRowComparer(MyStatsRow x, MyStatsRow y) { if (x.Faction != y.Faction) // First order by factions { if (x.Faction == m_playerFaction) { return(-1); } else if (y.Faction == m_playerFaction) { return(1); } else { return(((int)x.Faction).CompareTo(((int)y.Faction))); } } else if (x.IsFaction != y.IsFaction) // First are factions then players { return(-x.IsFaction.CompareTo(y.IsFaction)); } else if (x.Kills != y.Kills) // Then order by kills { return(-x.Kills.CompareTo(y.Kills)); } else if (x.Deaths != y.Deaths) // Then by deaths { return(x.Deaths.CompareTo(y.Deaths)); } else // Then by name { return(x.Name.ToString().CompareTo(y.Name.ToString())); } }
private void AddStatRowToListbox(MyStatsRow statsRow) { StringBuilder pingText = GetStringBuilderLong(); StringBuilder killsText = GetStringBuilderShort(); StringBuilder deathsText = GetStringBuilderShort(); pingText.Append(statsRow.Ping.HasValue ? statsRow.Ping.Value.ToString() + "ms" : ""); killsText.Append(statsRow.Kills.ToString()); deathsText.Append(statsRow.Deaths.ToString()); Vector4?rowColor = null; if (statsRow.IsFaction) { if (MySession.Static.Player.Faction == statsRow.Faction) { rowColor = new Vector4(0, 1f, 0, 0.07f); } else { rowColor = new Vector4(1f, 0, 0, 0.07f); } } else if (statsRow.Id == (byte)MyClientServer.LoggedPlayer.GetUserId()) { rowColor = new Vector4(1f, 1f, 1f, 0.02f); } int rowIndex = m_statsListbox.AddRow(rowColor); var textColor = Color.White; MyGuiFont textFont; if (MyFactions.GetFactionsRelation(MySession.Static.Player.Faction, statsRow.Faction) == MyFactionRelationEnum.Friend || statsRow.Id == m_playerId) { textFont = MyGuiManager.GetFontMinerWarsGreen(); } else { textFont = MyGuiManager.GetFontMinerWarsRed(); } m_statsListbox.AddItem(new MyGuiControlListboxItem(rowIndex * 4 + 0, new MyColoredText(statsRow.Name, textColor, textFont, GetRowScale(statsRow)), null, new MyToolTips(statsRow.Name)), rowIndex, 0); m_statsListbox.AddItem(new MyGuiControlListboxItem(rowIndex * 4 + 1, new MyColoredText(killsText, textColor, textFont, GetRowScale(statsRow)), null, new MyToolTips(killsText)), rowIndex, 1); m_statsListbox.AddItem(new MyGuiControlListboxItem(rowIndex * 4 + 2, new MyColoredText(deathsText, textColor, textFont, GetRowScale(statsRow)), null, new MyToolTips(deathsText)), rowIndex, 2); m_statsListbox.AddItem(new MyGuiControlListboxItem(rowIndex * 4 + 3, new MyColoredText(pingText, textColor, textFont, GetRowScale(statsRow)), null, new MyToolTips(pingText)), rowIndex, 3); }
private float GetRowScale(MyStatsRow row) { //if(row.Id == m_playerId){ // return 0.7f; //} //else if (row.IsFaction) { return(0.9f); } else { return(0.7f); } }
private float GetRowScale(MyStatsRow row) { //if(row.Id == m_playerId){ // return 0.7f; //} //else if (row.IsFaction) { return 0.9f; } else { return 0.7f; } }
int StatsRowComparer(MyStatsRow x, MyStatsRow y) { if (x.Faction != y.Faction) // First order by factions { if (x.Faction == m_playerFaction) return -1; else if (y.Faction == m_playerFaction) return 1; else return ((int)x.Faction).CompareTo(((int)y.Faction)); } else if (x.IsFaction != y.IsFaction) // First are factions then players { return -x.IsFaction.CompareTo(y.IsFaction); } else if (x.Kills != y.Kills) // Then order by kills { return -x.Kills.CompareTo(y.Kills); } else if (x.Deaths != y.Deaths) // Then by deaths { return x.Deaths.CompareTo(y.Deaths); } else // Then by name { return x.Name.ToString().CompareTo(y.Name.ToString()); } }
private void AddStatRowToListbox(MyStatsRow statsRow) { StringBuilder pingText = GetStringBuilderLong(); StringBuilder killsText = GetStringBuilderShort(); StringBuilder deathsText = GetStringBuilderShort(); pingText.Append(statsRow.Ping.HasValue ? statsRow.Ping.Value.ToString() + "ms" : ""); killsText.Append(statsRow.Kills.ToString()); deathsText.Append(statsRow.Deaths.ToString()); Vector4? rowColor = null; if (statsRow.IsFaction) { if (MySession.Static.Player.Faction == statsRow.Faction) rowColor = new Vector4(0, 1f, 0, 0.07f); else rowColor = new Vector4(1f, 0, 0, 0.07f); } else if (statsRow.Id == (byte)MyClientServer.LoggedPlayer.GetUserId()) rowColor = new Vector4(1f, 1f, 1f, 0.02f); int rowIndex = m_statsListbox.AddRow(rowColor); var textColor = Color.White; MyGuiFont textFont; if (MyFactions.GetFactionsRelation(MySession.Static.Player.Faction, statsRow.Faction) == MyFactionRelationEnum.Friend || statsRow.Id == m_playerId) textFont = MyGuiManager.GetFontMinerWarsGreen(); else textFont = MyGuiManager.GetFontMinerWarsRed(); m_statsListbox.AddItem(new MyGuiControlListboxItem(rowIndex * 4 + 0, new MyColoredText(statsRow.Name, textColor, textFont, GetRowScale(statsRow)), null, new MyToolTips(statsRow.Name)), rowIndex, 0); m_statsListbox.AddItem(new MyGuiControlListboxItem(rowIndex * 4 + 1, new MyColoredText(killsText, textColor, textFont, GetRowScale(statsRow)), null, new MyToolTips(killsText)), rowIndex, 1); m_statsListbox.AddItem(new MyGuiControlListboxItem(rowIndex * 4 + 2, new MyColoredText(deathsText, textColor, textFont, GetRowScale(statsRow)), null, new MyToolTips(deathsText)), rowIndex, 2); m_statsListbox.AddItem(new MyGuiControlListboxItem(rowIndex * 4 + 3, new MyColoredText(pingText, textColor, textFont, GetRowScale(statsRow)), null, new MyToolTips(pingText)), rowIndex, 3); }