Attribute VB_Name = "modChannels"
Public Faves() As New Collection

Public Sub AddFave(Server As String, Channel As String)
On Error Resume Next
    Select Case GetServerName(Server)
        Case "USWest":  Faves(0).Add Channel, Channel
        Case "USEast":  Faves(1).Add Channel, Channel
        Case "Asia":    Faves(2).Add Channel, Channel
        Case "Europe":  Faves(3).Add Channel, Channel
        Case Else:      Faves(4).Add Channel, Channel
    End Select
    SaveFaves
End Sub

Public Sub SaveFaves()
    Dim Serv()
    Serv = Array("USWest", "USEast", "Asia", "Europe", "PvPGN")
    For i = 0 To 4
        Dim Arr() As String, x As Integer
        ReDim Arr(Faves(i).Count)
        For x = 1 To Faves(i).Count
            Arr(x - 1) = Faves(i).Item(x)
        Next
        SaveFile AppData & "Data\Channels\" & Serv(i) & ".dat", CStr(Join(Arr, vbNewLine))
        Erase Arr
    Next i
End Sub

Public Sub LoadFaves()
    Dim Serv()
    ReDim Faves(4)
    Serv = Array("USWest", "USEast", "Asia", "Europe", "PvPGN")
    For i = 0 To 4
        Dim Content As String, Lines() As String, L As Integer
        Set Faves(i) = New Collection
        Content = ReadFile(AppData & "Data\Channels\" & Serv(i) & ".dat")
        Lines = Split(Content, vbNewLine)
        For L = 0 To UBound(Lines)
            If Len(Lines(L)) Then
            On Error Resume Next
                Faves(i).Add Lines(L), Lines(L)
            End If
        Next
        Erase Lines
    Next
End Sub

Public Sub ShowPublic(B As BNCS)
    Dim i As Integer
    For i = frmBot.mnuPublic.ubound To 1 Step -1
        Unload frmBot.mnuPublic(i)
    Next
    frmBot.mnuPublic(0).Caption = vbNS
    For i = 1 To B.BnetChannels.Count
        If LenB(B.BnetChannels(i)) Then
            If Len(frmBot.mnuPublic(0).Caption) Then Load frmBot.mnuPublic(frmBot.mnuPublic.Count)
            frmBot.mnuPublic(frmBot.mnuPublic.ubound).Caption = B.BnetChannels(i)
        End If
    Next i
End Sub

Public Sub ShowPlaces(B As BNCS)
    Dim i As Integer
    For i = frmBot.mnuPlaces.ubound To 1 Step -1
        Unload frmBot.mnuPlaces(i)
    Next
    frmBot.mnuPlaces(0).Caption = vbNS
    For i = 1 To B.Places.Count
        If Len(frmBot.mnuPlaces(0).Caption) Then Load frmBot.mnuPlaces(frmBot.mnuPlaces.Count)
        frmBot.mnuPlaces(frmBot.mnuPlaces.ubound).Caption = B.Places(i)
    Next
End Sub

Public Sub ShowFaves(Server As String)
    Dim col As Collection, i As Integer
    Select Case GetServerName(Server)
        Case "USWest":  Set col = Faves(0)
        Case "USEast":  Set col = Faves(1)
        Case "Asia":    Set col = Faves(2)
        Case "Europe":  Set col = Faves(3)
        Case Else:      Set col = Faves(4)
    End Select
    For i = frmBot.mnuFave.ubound To 1 Step -1
        Unload frmBot.mnuFave(i)
    Next
    For i = 1 To col.Count
        Load frmBot.mnuFave(frmBot.mnuFave.Count)
        frmBot.mnuFave(frmBot.mnuFave.ubound).Caption = col.Item(i) & IIf(i < 10, vbTab & "Ctrl+Shift+" & i, "")
    Next
'    If col.Count > 0 Then
'        Load frmBot.mnuFave(frmBot.mnuFave.Count)
'        frmBot.mnuFave(frmBot.mnuFave.UBound).Caption = "-"
'    End If
End Sub
