示例#1
0
 /// <summary>
 /// Draw a header button that toggles specific sort types
 /// </summary>
 void DrawRoomListHeaderButton(float x, float width, string text, SortRoomList ascType, SortRoomList descType)
 {
     if (GUI.Button(new Rect(x, 94, width, 40),
                    new GUIContent(text, GetArrowTexture(ascType, descType)),
                    Styles.ButtonServerHeader))
     {
         ToggleSortRoomListType(ascType, descType);
     }
 }
示例#2
0
 /// <summary>
 /// Toggles the type of the sort room list between ascType and descType
 /// </summary>
 void ToggleSortRoomListType(SortRoomList ascType, SortRoomList descType)
 {
     if (m_SortRoomList == ascType)
     {
         m_SortRoomList = descType;
     }
     else
     {
         m_SortRoomList = ascType;
     }
 }
示例#3
0
    /// <summary>
    /// Gets the appropriate arrow texture for the sorting types, depending on which one is active
    /// </summary>
    Texture2D GetArrowTexture(SortRoomList ascType, SortRoomList descType)
    {
        if (m_SortRoomList == ascType)
        {
            return(AscArrowTexture);
        }

        if (m_SortRoomList == descType)
        {
            return(DescArrowTexture);
        }

        return(NoArrowTexture);
    }
示例#4
0
    /// <summary>
    /// Sort the room info list with the selected sorting type
    /// </summary>
    void SortRoomInfoList(ref List <RoomInfo> list, SortRoomList sortType)
    {
        switch (sortType)
        {
        case SortRoomList.NameAsc:
            list.Sort(delegate(RoomInfo room1, RoomInfo room2)
            {
                return(room1.Name.CompareTo(room2.Name));
            });
            break;

        case SortRoomList.NameDesc:
            list.Sort(delegate(RoomInfo room1, RoomInfo room2)
            {
                return(room2.Name.CompareTo(room1.Name));
            });
            break;

        case SortRoomList.PlayersAsc:
            list.Sort(delegate(RoomInfo room1, RoomInfo room2)
            {
                if (room1.PlayerCount == room2.PlayerCount)
                {
                    return(room1.MaxPlayers.CompareTo(room2.MaxPlayers));
                }

                return(room1.PlayerCount.CompareTo(room2.PlayerCount));
            });
            break;

        case SortRoomList.PlayersDesc:
            list.Sort(delegate(RoomInfo room1, RoomInfo room2)
            {
                if (room1.PlayerCount == room2.PlayerCount)
                {
                    return(room2.MaxPlayers.CompareTo(room1.MaxPlayers));
                }

                return(room2.PlayerCount.CompareTo(room1.PlayerCount));
            });
            break;

        case SortRoomList.MapAsc:
            list.Sort(delegate(RoomInfo room1, RoomInfo room2)
            {
                string map1 = (string)room1.CustomProperties[RoomProperty.Map];
                string map2 = (string)room2.CustomProperties[RoomProperty.Map];

                return(map1.CompareTo(map2));
            });
            break;

        case SortRoomList.MapDesc:
            list.Sort(delegate(RoomInfo room1, RoomInfo room2)
            {
                string map1 = (string)room1.CustomProperties[RoomProperty.Map];
                string map2 = (string)room2.CustomProperties[RoomProperty.Map];

                return(map2.CompareTo(map1));
            });
            break;

        case SortRoomList.ModeAsc:
            list.Sort(delegate(RoomInfo room1, RoomInfo room2)
            {
                int mode1 = (int)room1.CustomProperties[RoomProperty.Mode];
                int mode2 = (int)room2.CustomProperties[RoomProperty.Mode];

                return(mode1.CompareTo(mode2));
            });
            break;

        case SortRoomList.ModeDesc:
            list.Sort(delegate(RoomInfo room1, RoomInfo room2)
            {
                int mode1 = (int)room1.CustomProperties[RoomProperty.Mode];
                int mode2 = (int)room2.CustomProperties[RoomProperty.Mode];

                return(mode2.CompareTo(mode1));
            });
            break;
        }
    }
示例#5
0
/// <summary>
	/// Sort the room info list with the selected sorting type
	/// </summary>
	void SortRoomInfoList( ref List<RoomInfo> list, SortRoomList sortType )
	{
		switch( sortType )
		{
		case SortRoomList.NameAsc:
			list.Sort( delegate( RoomInfo room1, RoomInfo room2 )
			{
				return room1.name.CompareTo( room2.name );
			} );
			break;
		case SortRoomList.NameDesc:
			list.Sort( delegate( RoomInfo room1, RoomInfo room2 )
			{
				return room2.name.CompareTo( room1.name );
			} );
			break;

		case SortRoomList.PlayersAsc:
			list.Sort( delegate( RoomInfo room1, RoomInfo room2 )
			{
				if( room1.playerCount == room2.playerCount )
				{
					return room1.maxPlayers.CompareTo( room2.maxPlayers );
				}

				return room1.playerCount.CompareTo( room2.playerCount );
			} );
			break;
		case SortRoomList.PlayersDesc:
			list.Sort( delegate( RoomInfo room1, RoomInfo room2 )
			{
				if( room1.playerCount == room2.playerCount )
				{
					return room2.maxPlayers.CompareTo( room1.maxPlayers );
				}

				return room2.playerCount.CompareTo( room1.playerCount );
			} );
			break;

		case SortRoomList.MapAsc:
			list.Sort( delegate( RoomInfo room1, RoomInfo room2 )
			{
				string map1 = (string)room1.customProperties[ RoomProperty.Map ];
				string map2 = (string)room2.customProperties[ RoomProperty.Map ];

				return map1.CompareTo( map2 );
			} );
			break;
		case SortRoomList.MapDesc:
			list.Sort( delegate( RoomInfo room1, RoomInfo room2 )
			{
				string map1 = (string)room1.customProperties[ RoomProperty.Map ];
				string map2 = (string)room2.customProperties[ RoomProperty.Map ];

				return map2.CompareTo( map1 );
			} );
			break;

		case SortRoomList.ModeAsc:
			list.Sort( delegate( RoomInfo room1, RoomInfo room2 )
			{
				int mode1 = (int)room1.customProperties[ RoomProperty.Mode ];
				int mode2 = (int)room2.customProperties[ RoomProperty.Mode ];

				return mode1.CompareTo( mode2 );
			} );
			break;
		case SortRoomList.ModeDesc:
			list.Sort( delegate( RoomInfo room1, RoomInfo room2 )
			{
				int mode1 = (int)room1.customProperties[ RoomProperty.Mode ];
				int mode2 = (int)room2.customProperties[ RoomProperty.Mode ];

				return mode2.CompareTo( mode1 );
			} );
			break;
		}
	}
示例#6
0
	/// <summary>
	/// Gets the appropriate arrow texture for the sorting types, depending on which one is active
	/// </summary>
	Texture2D GetArrowTexture( SortRoomList ascType, SortRoomList descType )
	{
		if( m_SortRoomList == ascType )
		{
			return AscArrowTexture;
		}

		if( m_SortRoomList == descType )
		{
			return DescArrowTexture;
		}

		return NoArrowTexture;
	}
示例#7
0
	/// <summary>
	/// Toggles the type of the sort room list between ascType and descType
	/// </summary>
	void ToggleSortRoomListType( SortRoomList ascType, SortRoomList descType )
	{
		if( m_SortRoomList == ascType )
		{
			m_SortRoomList = descType;
		}
		else
		{
			m_SortRoomList = ascType;
		}
	}
示例#8
0
	/// <summary>
	/// Draw a header button that toggles specific sort types
	/// </summary>
	void DrawRoomListHeaderButton( float x, float width, string text, SortRoomList ascType, SortRoomList descType )
	{
		if( GUI.Button( new Rect( x, 94, width, 40 ),
						new GUIContent( text, GetArrowTexture( ascType, descType ) ),
						Styles.ButtonServerHeader ) )
		{
			ToggleSortRoomListType( ascType, descType );
		}
	}