@@ -877,13 +877,72 @@ function STATUSBTN:CastBar_OnEvent(event, ...)
877877 self .sb .cbtimer .castInfo [unit ][1 ] = text
878878 self .sb .cbtimer .castInfo [unit ][2 ] = " %0.1f"
879879
880+ elseif (event == " UNIT_SPELLCAST_CHANNEL_START" ) then
881+
882+ local name , text , texture , startTime , endTime , isTradeSkill , notInterruptible = UnitChannelInfo (unit )
883+
884+ if (not name ) then
885+ self :CastBar_Reset ()
886+ return
887+ end
888+
889+ self .sb :SetStatusBarColor (self .sb .channelColor [1 ], self .sb .channelColor [2 ], self .sb .channelColor [3 ], self .sb .channelColor [4 ])
890+
891+ self .sb .value = ((endTime / 1000 )- GetTime ())
892+ self .sb .maxValue = (endTime - startTime ) / 1000 ;
893+ self .sb :SetMinMaxValues (0 , self .sb .maxValue );
894+ self .sb :SetValue (self .sb .value )
895+
896+ CastWatch [unit ].spell = text
897+
898+ if (self .sb .showIcon ) then
899+
900+ self .sb .icon :SetTexture (texture )
901+ self .sb .icon :Show ()
902+
903+ if (notInterruptible ) then
904+ self .sb .shield :Show ()
905+ else
906+ self .sb .shield :Hide ()
907+ end
908+
909+ else
910+ self .sb .icon :Hide ()
911+ self .sb .shield :Hide ()
912+ end
913+
914+ if (self .sb .spark ) then
915+ self .sb .spark :Hide ()
916+ end
917+
918+ self .sb :SetAlpha (1.0 )
919+ self .sb .holdTime = 0
920+ self .sb .casting = false
921+ self .sb .channeling = true
922+ self .sb .fadeOut = nil
923+
924+ self .sb :Show ()
925+
926+ -- update text on castbar
927+ if (not self .sb .cbtimer .castInfo [unit ]) then
928+ self .sb .cbtimer .castInfo [unit ] = {}
929+ end
930+
931+ self .sb .cbtimer .castInfo [unit ][1 ] = text
932+ self .sb .cbtimer .castInfo [unit ][2 ] = " %0.1f"
933+
934+
880935 elseif (event == " UNIT_SPELLCAST_SUCCEEDED" and not self .sb .channeling ) then -- don't do anything with this event when channeling as it fires at each pulse of a spell channel
881936
882937 self .sb :SetStatusBarColor (self .sb .successColor [1 ], self .sb .successColor [2 ], self .sb .successColor [3 ], self .sb .successColor [4 ])
883938
884- elseif (event == " UNIT_SPELLCAST_FAILED" or event == " UNIT_SPELLCAST_INTERRUPTED" or event == " UNIT_SPELLCAST_STOP" or event == " UNIT_SPELLCAST_CHANNEL_STOP" ) and self .sb .castID == eventCastID then
939+ elseif (event == " UNIT_SPELLCAST_SUCCEEDED" and self .sb .channeling ) then
940+
941+ -- do nothing (when Tranquility is channeling if reports UNIT_SPELLCAST_SUCCEEDED many times during the duration)
885942
886- if (self .sb :IsShown () and ((self .sb .casting ) or self .sb .channeling ) and not self .sb .fadeOut ) then
943+ elseif ((event == " UNIT_SPELLCAST_FAILED" or event == " UNIT_SPELLCAST_INTERRUPTED" or event == " UNIT_SPELLCAST_STOP" ) and self .sb .castID == eventCastID ) or event == " UNIT_SPELLCAST_CHANNEL_STOP" then
944+
945+ if (self .sb :IsShown () and (self .sb .casting or self .sb .channeling ) and not self .sb .fadeOut ) then
887946
888947 self .sb :SetValue (self .sb .maxValue )
889948
@@ -941,60 +1000,6 @@ function STATUSBTN:CastBar_OnEvent(event, ...)
9411000 end
9421001 end
9431002
944- elseif (event == " UNIT_SPELLCAST_CHANNEL_START" ) then
945-
946- local name , text , texture , startTime , endTime , isTradeSkill , notInterruptible = UnitChannelInfo (unit )
947-
948- if (not name ) then
949- self :CastBar_Reset ()
950- return
951- end
952-
953- self .sb :SetStatusBarColor (self .sb .channelColor [1 ], self .sb .channelColor [2 ], self .sb .channelColor [3 ], self .sb .channelColor [4 ])
954-
955- self .sb .value = ((endTime / 1000 )- GetTime ())
956- self .sb .maxValue = (endTime - startTime ) / 1000 ;
957- self .sb :SetMinMaxValues (0 , self .sb .maxValue );
958- self .sb :SetValue (self .sb .value )
959-
960- CastWatch [unit ].spell = text
961-
962- if (self .sb .showIcon ) then
963-
964- self .sb .icon :SetTexture (texture )
965- self .sb .icon :Show ()
966-
967- if (notInterruptible ) then
968- self .sb .shield :Show ()
969- else
970- self .sb .shield :Hide ()
971- end
972-
973- else
974- self .sb .icon :Hide ()
975- self .sb .shield :Hide ()
976- end
977-
978- if (self .sb .spark ) then
979- self .sb .spark :Hide ()
980- end
981-
982- self .sb :SetAlpha (1.0 )
983- self .sb .holdTime = 0
984- self .sb .casting = false
985- self .sb .channeling = true
986- self .sb .fadeOut = nil
987-
988- self .sb :Show ()
989-
990- -- update text on castbar
991- if (not self .sb .cbtimer .castInfo [unit ]) then
992- self .sb .cbtimer .castInfo [unit ] = {}
993- end
994-
995- self .sb .cbtimer .castInfo [unit ][1 ] = text
996- self .sb .cbtimer .castInfo [unit ][2 ] = " %0.1f"
997-
9981003 elseif (event == " UNIT_SPELLCAST_CHANNEL_UPDATE" ) then
9991004
10001005 if (self .sb :IsShown ()) then
0 commit comments