Skip to content

Commit

Permalink
Move PublicChannels to BotVars
Browse files Browse the repository at this point in the history
- PublicChannels, QuickChannels, and Home Channel/Last Channel menus are all updated on changes, and never when opening menus.
- That is, the menus (and visibility) are recalculated from scratch when QuickChannels are saved, receiving PublicChannels, or changing channel, affecting the relevant menus only.
- Scripting: Event_ChannelList(Channels()) no longer receives two additional empty channel names at the end of the array.
- Fixes #22: Event_ChannelList does not clear the channel list menus
  • Loading branch information
nmbook committed May 3, 2016
1 parent 31c0759 commit 64a93de
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 194 deletions.
9 changes: 9 additions & 0 deletions trunk/clsBotVars.cls
Expand Up @@ -64,6 +64,7 @@ Private m_bClientBans As Boolean
Private m_byTSSetting As Byte
Private m_sHomeChannel As String
Private m_sLastChannel As String
Private m_colPublicChannels As Collection
Private m_bQuietTime As Boolean
Private m_bUseBackupChan As Boolean
Private m_sBackupChan As String
Expand Down Expand Up @@ -486,6 +487,14 @@ Public Property Let LastChannel(ByVal sLastChannel As String)
m_sLastChannel = sLastChannel
End Property

Public Property Get PublicChannels() As Collection
Set PublicChannels = m_colPublicChannels
End Property

Public Property Set PublicChannels(ByVal colPublicChannels As Collection)
Set m_colPublicChannels = colPublicChannels
End Property

Public Property Get QuietTime() As Boolean
QuietTime = m_bQuietTime
End Property
Expand Down
86 changes: 18 additions & 68 deletions trunk/frmChat.frm
Expand Up @@ -1078,7 +1078,6 @@ Begin VB.Form frmChat
_ExtentY = 2990
_Version = 393217
BackColor = 0
Enabled = -1 'True
ReadOnly = -1 'True
ScrollBars = 2
AutoVerbMenu = -1 'True
Expand All @@ -1104,7 +1103,6 @@ Begin VB.Form frmChat
_ExtentY = 11668
_Version = 393217
BackColor = 0
Enabled = -1 'True
ReadOnly = -1 'True
ScrollBars = 2
AutoVerbMenu = -1 'True
Expand Down Expand Up @@ -1187,12 +1185,15 @@ Begin VB.Form frmChat
Caption = "Channel &List"
Begin VB.Menu mnuHomeChannel
Caption = "&Bot Home"
Visible = 0 'False
End
Begin VB.Menu mnuLastChannel
Caption = "&Last Channel"
Visible = 0 'False
End
Begin VB.Menu mnuQCDash
Caption = "-"
Visible = 0 'False
End
Begin VB.Menu mnuQCHeader
Caption = "- QuickChannels -"
Expand Down Expand Up @@ -3411,26 +3412,6 @@ ERROR_HANDLER:
End Sub

Private Sub lblCurrentChannel_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim i As Integer

' show home channel
mnuHomeChannel.Visible = (mnuHomeChannel.Caption <> vbNullString And StrComp(Config.HomeChannel, g_Channel.Name, vbTextCompare) <> 0)
mnuLastChannel.Visible = (mnuLastChannel.Caption <> vbNullString And StrComp(BotVars.LastChannel, g_Channel.Name, vbTextCompare) <> 0)
mnuQCDash.Visible = (mnuHomeChannel.Visible Or mnuLastChannel.Visible)

' show quick channels (section always visible)
'frmChat.mnuQCHeader.Visible = (mnuCustomChannels(0).Caption <> vbNullString)
'For i = 0 To mnuCustomChannels.Count - 1
' mnuCustomChannels(i).Visible = (mnuCustomChannels(i).Caption <> vbNullString)
'Next i

' show public channels
mnuPCDash.Visible = (mnuPublicChannels(0).Caption <> vbNullString)
mnuPCHeader.Visible = (mnuPublicChannels(0).Caption <> vbNullString)
For i = 0 To mnuPublicChannels.Count - 1
mnuPublicChannels(i).Visible = (mnuPublicChannels(i).Caption <> vbNullString)
Next i

PopupMenu mnuQCTop
End Sub

Expand Down Expand Up @@ -3878,28 +3859,6 @@ Private Sub lvClanList_MouseMove(Button As Integer, Shift As Integer, x As Singl
End If
End Sub

Private Sub mnuBot_Click()
Dim i As Integer

' show home channel
mnuHomeChannel.Visible = (mnuHomeChannel.Caption <> vbNullString And StrComp(Config.HomeChannel, g_Channel.Name, vbTextCompare) <> 0)
mnuLastChannel.Visible = (mnuLastChannel.Caption <> vbNullString And StrComp(BotVars.LastChannel, g_Channel.Name, vbTextCompare) <> 0)
mnuQCDash.Visible = (mnuHomeChannel.Visible Or mnuLastChannel.Visible)

' show quick channels (section always visible)
'frmChat.mnuQCHeader.Visible = (mnuCustomChannels(0).Caption <> vbNullString)
'For i = 0 To mnuCustomChannels.Count - 1
' mnuCustomChannels(i).Visible = (mnuCustomChannels(i).Caption <> vbNullString)
'Next i

' show public channels
mnuPCDash.Visible = (mnuPublicChannels(0).Caption <> vbNullString)
mnuPCHeader.Visible = (mnuPublicChannels(0).Caption <> vbNullString)
For i = 0 To mnuPublicChannels.Count - 1
mnuPublicChannels(i).Visible = (mnuPublicChannels(i).Caption <> vbNullString)
Next i
End Sub

Private Sub mnuCatchPhrases_Click()
frmCatch.Show
End Sub
Expand Down Expand Up @@ -4504,13 +4463,15 @@ Private Sub mnuPublicChannels_Click(Index As Integer)
' Exit Sub
'End If

If Not PublicChannels Is Nothing Then
Select Case Config.AutoCreateChannels
Case "ALERT", "NEVER"
Call FullJoin(PublicChannels.Item(Index + 1), 0)
Case Else ' "ALWAYS"
Call FullJoin(PublicChannels.Item(Index + 1), 2)
End Select
If Not BotVars.PublicChannels Is Nothing Then
If BotVars.PublicChannels.Count > Index Then
Select Case Config.AutoCreateChannels
Case "ALERT", "NEVER"
Call FullJoin(BotVars.PublicChannels.Item(Index + 1), 0)
Case Else ' "ALWAYS"
Call FullJoin(BotVars.PublicChannels.Item(Index + 1), 2)
End Select
End If
'AddQ "/join " & PublicChannels.Item(Index + 1), PRIORITY.CONSOLE_MESSAGE
End If
End Sub
Expand Down Expand Up @@ -5024,7 +4985,7 @@ Private Sub mnuCustomChannelAdd_Click()
For i = LBound(QC) To UBound(QC)
If LenB(Trim$(QC(i))) = 0 Then
QC(i) = g_Channel.Name
DoQuickChannelMenu
PrepareQuickChannelMenu

Exit Sub
End If
Expand Down Expand Up @@ -8149,8 +8110,6 @@ Sub DoDisconnect(Optional ByVal DoNotShow As Byte = 0, Optional ByVal LeaveUCCAl
UserCancelledConnect = True
End If

DoQuickChannelMenu

If (UserCancelledConnect) Then
'AddChat vbRed, "DISC!"

Expand Down Expand Up @@ -8207,19 +8166,12 @@ Sub DoDisconnect(Optional ByVal DoNotShow As Byte = 0, Optional ByVal LeaveUCCAl
mnuIgnoreInvites.Visible = False
mnuRealmSwitch.Visible = False

mnuHomeChannel.Caption = vbNullString
mnuLastChannel.Caption = vbNullString

Set PublicChannels = Nothing

With mnuPublicChannels(0)
.Caption = vbNullString
.Visible = False
End With
BotVars.LastChannel = vbNullString
PrepareHomeChannelMenu
PrepareQuickChannelMenu

For i = 1 To mnuPublicChannels.Count - 1
Call Unload(mnuPublicChannels(i))
Next i
Set BotVars.PublicChannels = Nothing
PreparePublicChannelMenu

If ((Me.WindowState = vbNormal) And _
(DoNotShow = 0)) Then
Expand Down Expand Up @@ -8251,8 +8203,6 @@ Sub DoDisconnect(Optional ByVal DoNotShow As Byte = 0, Optional ByVal LeaveUCCAl
BNLSFinderGotList = False
BNLSFinderIndex = 0

BotVars.LastChannel = vbNullString

PassedClanMotdCheck = False

On Error Resume Next
Expand Down
2 changes: 1 addition & 1 deletion trunk/frmQuickChannel.frm
Expand Up @@ -535,7 +535,7 @@ Private Sub cmdDone_Click()

SaveQuickChannels

DoQuickChannelMenu
PrepareQuickChannelMenu

Unload Me
End Sub

0 comments on commit 64a93de

Please sign in to comment.