diff --git a/HealBot_Action.lua b/HealBot_Action.lua index 6625968..6ea0d43 100644 --- a/HealBot_Action.lua +++ b/HealBot_Action.lua @@ -1,1304 +1,1304 @@ -function HealBot_Action_SetTexture(bar, btexture) - if not bar then return end - if btexture == 10 then - bar:SetStatusBarTexture("Interface\\Buttons\\WHITE8X8"); - else - HealBot_Action_SetTexture(bar, btexture); - end -end -local headerno=0; - -HealBot_Action_HealGroup = { - "player", - "pet", - "party1", - "party2", - "party3", - "party4", -}; - -HealBot_Action_HealTarget = { -}; - -HealBot_Action_HealButtons = { -}; - -HealBot_Action_UnitButtons = { -}; - -function HealBot_Action_AddDebug(msg) - HealBot_AddDebug("Action: " .. msg); -end - -function HealBot_HealthColor(unit,hlth,maxhlth) - if HealBot_UnitDebuff[unit] then - local debuff, tmp, debuff_type = UnitDebuff(unit,1, 1) - if not debuff then - HealBot_UnitDebuff[unit] = nil; - HealBot_UnitDebuff[unit.."_debuff_texture"]=nil - else - local dr = HealBot_Config.CDCBarColour[HealBot_UnitDebuff[unit]].R - local dg = HealBot_Config.CDCBarColour[HealBot_UnitDebuff[unit]].G - local db = HealBot_Config.CDCBarColour[HealBot_UnitDebuff[unit]].B - if HealBot_Config.btexture[HealBot_Config.Current_Skin] == 10 then - dr = dr * 4 - dg = dg * 4 - db = db * 4 - if dr > 1 then dr = 1 end - if dg > 1 then dg = 1 end - if db > 1 then db = 1 end - end - return dr, dg, db, HealBot_Config.Barcola[HealBot_Config.Current_Skin]; - end - end - local text = UnitName(unit); - if not HealBot_HealsIn[text] then - HealBot_HealsIn[text]=0; - end - - local pct = hlth+HealBot_HealsIn[text]; - if maxhlth and maxhlth > 0 then - if pctHealBot_Config.AlertLevel then - a=HealBot_Config.bardisa[HealBot_Config.Current_Skin]; - end - - local colorMode = HealBot_Config.bcolormode[HealBot_Config.Current_Skin] or 1 - if colorMode == 2 and HealBot_Model and HealBot_Model.units[unit] and HealBot_Model.units[unit].englishClass then - local engClass = HealBot_Model.units[unit].englishClass - if RAID_CLASS_COLORS and RAID_CLASS_COLORS[engClass] then - r = RAID_CLASS_COLORS[engClass].r - g = RAID_CLASS_COLORS[engClass].g - b = RAID_CLASS_COLORS[engClass].b - end - else - if pct>=0.98 then r = 0.0; end - if pct<0.98 and pct>=0.65 then r=2.94-(pct*3); end - if pct<=0.64 and pct>0.31 then g=(pct-0.31)*3; end - if pct<=0.31 then g = 0.0; end - end - return r,g,b,a; -end - -function HealBot_Action_HealthBar(button) - local name = button:GetName(); - return getglobal(name.."Bar"); -end - -function HealBot_Action_HealthBar2(button) - local name = button:GetName(); - return getglobal(name.."Bar2"); -end - -function HealBot_AlwaysHeal() - return HealBot_Config.EnableHealthy==1 -end - -function HealBot_MayHeal(unit) - if not UnitName(unit) or not HealBot_Heals[unit] then return false end - if unit ~= 'target' then return true end - if not HealBot_Config.TargetHeals or UnitCanAttack("player",unit) then return false end - return true; -end - -function HealBot_ShouldHeal(unit) - if HealBot_UnitDebuff[unit] and not UnitIsDeadOrGhost(unit) then - if HealBot_Range_Check(unit, 30)==1 then - return true; - end - end - return HealBot_MayHeal(unit) and UnitHealth(unit)>0 and not UnitIsDeadOrGhost(unit) - and (UnitHealth(unit) 0 and pt == 0 then - if HealBot_Config.ManaBarsHealersOnly == 1 then - if isHealer then showMana = true end - else - showMana = true - end - end - - if showMana then - local pr, pg, pb = 0, 0, 1 - - if bar3 then - bar3:SetMinMaxValues(0, state.maxMana) - bar3:SetValue(state.mana) - bar3:SetStatusBarColor(pr, pg, pb, HealBot_Config.Barcola[HealBot_Config.Current_Skin]) - bar3:Show() - bar3:SetHeight(bheight * 0.2) - end - - bar:SetHeight(bheight * 0.8) - bar2:SetHeight(bheight * 0.8) - else - if bar3 then - bar3:Hide() - end - bar:SetHeight(bheight) - bar2:SetHeight(bheight) - end - - if HealBot_HealsIn[name] then - bar2:SetMinMaxValues(0,maxhlth); - bar2:SetValue(hlth+HealBot_HealsIn[name]); - else - bar2:SetValue(0); - end - bar.txt = getglobal(bar:GetName().."_text"); - if (not HealBot_IsCasting and (HealBot_CanHeal(unit) or HealBot_MissingBuffs[unit])) then - button:Enable(); - if HealBot_UnitDebuff[unit] then - sr=HealBot_Config.btextcursecolr[HealBot_Config.Current_Skin]; - sg=HealBot_Config.btextcursecolg[HealBot_Config.Current_Skin]; - sb=HealBot_Config.btextcursecolb[HealBot_Config.Current_Skin]; - sa=HealBot_Config.btextcursecola[HealBot_Config.Current_Skin]; - elseif HealBot_MissingBuffs[unit] then - r=r*0.5; - g=g*0.5; - b=b*0.5; - sr=1.0; - sg=1.0; - sb=0.0; - end - bar:SetStatusBarColor(r,g,b,HealBot_Config.Barcola[HealBot_Config.Current_Skin]); - bar2:SetStatusBarColor(r,g,b,HealBot_Config.BarcolaInHeal[HealBot_Config.Current_Skin]); - else - button:Disable(); - sr=HealBot_Config.btextdisbledcolr[HealBot_Config.Current_Skin]; - sg=HealBot_Config.btextdisbledcolg[HealBot_Config.Current_Skin]; - sb=HealBot_Config.btextdisbledcolb[HealBot_Config.Current_Skin]; - sa=HealBot_Config.btextdisbledcola[HealBot_Config.Current_Skin]; - bar:SetStatusBarColor(r,g,b,HealBot_Config.bardisa[HealBot_Config.Current_Skin]); - bar2:SetStatusBarColor(r,g,b,HealBot_Config.bardisa[HealBot_Config.Current_Skin]); - end - if string.len(name)>textlen then - name = string.sub(name,1,textlen-3) .. '...'; - end - bar.txt:SetText(name); - bar.txt:SetTextColor(sr,sg,sb,sa); - local fontName, fontHeight, fontFlags = bar.txt:GetFont() - local fontOutline = HealBot_Config.bfontoutline[HealBot_Config.Current_Skin] or 0 - if fontOutline == 1 then - bar.txt:SetFont(fontName, fontHeight, "OUTLINE") - else - bar.txt:SetFont(fontName, fontHeight, "") - end - local fontName, fontHeight, fontFlags = bar.txt:GetFont() - local fontOutline = HealBot_Config.bfontoutline[HealBot_Config.Current_Skin] or 0 - if fontOutline == 1 then - bar.txt:SetFont(fontName, fontHeight, "OUTLINE") - else - bar.txt:SetFont(fontName, fontHeight, "") - end - - for i = 1, 5 do - local icon = getglobal(button:GetName().."BarIcon"..i) - if icon then - if HealBot_UnitIcons and HealBot_UnitIcons[unit] and HealBot_UnitIcons[unit][i] then - icon:SetTexture(HealBot_UnitIcons[unit][i]) - icon:Show() - else - icon:Hide() - end - end - end -end - -function HealBot_Action_EnableButtons() - table.foreach(HealBot_Action_HealButtons, function (index,button) - HealBot_Action_EnableButton(button); - end); -end - -function HealBot_Action_RefreshButton(button) - if not button then return end - if type(button)~="table" then DEFAULT_CHAT_FRAME:AddMessage("***** "..type(button)) end - local unit = button.unit; - if HealBot_MayHeal(unit) then - HealBot_Action_EnableButton(button) - end -end - -function HealBot_Action_ResetSkin() - HealBot_Action_PartyChanged() - if HealBot_Options:IsVisible() then - HealBot_Action_SetTexture(HealBot_DiseaseColorpick, HealBot_Config.btexture[HealBot_Config.Current_Skin]) - HealBot_Action_SetTexture(HealBot_MagicColorpick, HealBot_Config.btexture[HealBot_Config.Current_Skin]) - HealBot_Action_SetTexture(HealBot_PoisonColorpick, HealBot_Config.btexture[HealBot_Config.Current_Skin]) - HealBot_Action_SetTexture(HealBot_CurseColorpick, HealBot_Config.btexture[HealBot_Config.Current_Skin]) - HealBot_Action_SetTexture(HealBot_EnTextColorpick, HealBot_Config.btexture[HealBot_Config.Current_Skin]) - HealBot_Action_SetTexture(HealBot_EnTextColorpickin, HealBot_Config.btexture[HealBot_Config.Current_Skin]) - HealBot_Action_SetTexture(HealBot_DisTextColorpick, HealBot_Config.btexture[HealBot_Config.Current_Skin]) - HealBot_Action_SetTexture(HealBot_DebTextColorpick, HealBot_Config.btexture[HealBot_Config.Current_Skin]) - HealBot_SetSkinColours() - end -end - -function HealBot_Action_RefreshButtons() - table.foreach(HealBot_Action_HealButtons, function (index,button) - HealBot_Action_RefreshButton(button); - end); -end - -function HealBot_Action_RefreshButtons(unit) - if unit and HealBot_Action_UnitButtons[unit] then - table.foreach(HealBot_Action_UnitButtons[unit], function (index,button) - HealBot_Action_RefreshButton(button); - end); - else - table.foreach(HealBot_Action_HealButtons, function (index,button) - HealBot_Action_RefreshButton(button); - end); - end -end - -function HealBot_Action_PositionButton(button,OsetX,OsetY,bwidth,bheight,checked,header) - local brspace=HealBot_Config.brspace[HealBot_Config.Current_Skin] or 3; - if header then - headerno=headerno+1; - local headerobj=getglobal("HealBot_Action_Header"..headerno); - local tmpY=OsetY - headerobj:SetText(header) - headerobj:Show(); - headerobj:ClearAllPoints(); - headerobj:SetHeight(bheight); - headerobj:SetWidth(bwidth); - headerobj:SetPoint("TOPLEFT","HealBot_Action","TOPLEFT",OsetX,-OsetY); - headerobj:Disable(); - OsetY = OsetY+headerobj:GetHeight()+brspace; - else - local unit = button.unit; - button:SetText(" "); - if (HealBot_MayHeal(unit)) then - button:Show(); - button:ClearAllPoints(); - button:SetHeight(bheight); - if checked then - button:SetWidth(bwidth-14); - button:SetPoint("TOPLEFT","HealBot_Action","TOPLEFT",OsetX+14,-OsetY); - else - button:SetWidth(bwidth); - button:SetPoint("TOPLEFT","HealBot_Action","TOPLEFT",OsetX,-OsetY); - end - OsetY = OsetY+button:GetHeight()+brspace; - else - button:Hide(); - end - end - return OsetY; -end - -function HealBot_Action_SetHeightWidth(width,height,bwidth) - if HealBot_ActionHeight then - HealBot_Action:SetHeight(HealBot_ActionHeight); - end - if HealBot_Config.GrowUpwards==1 then - local left,bottom = HealBot_Action:GetLeft(),HealBot_Action:GetBottom(); - if left and bottom then - if HealBot_Config.PanelAnchorX==-1 then HealBot_Config.PanelAnchorX=left; end - if HealBot_Config.PanelAnchorY==-1 then HealBot_Config.PanelAnchorY=bottom; end - HealBot_Action:ClearAllPoints(); - HealBot_Action:SetPoint("BOTTOMLEFT","UIParent","BOTTOMLEFT",HealBot_Config.PanelAnchorX,HealBot_Config.PanelAnchorY); - end - else - local left,top = HealBot_Action:GetLeft(),HealBot_Action:GetTop(); - if left and top then - HealBot_Action:ClearAllPoints(); - HealBot_Action:SetPoint("TOPLEFT","UIParent","BOTTOMLEFT",left,top); - end - end - HealBot_Action:SetHeight(height); - HealBot_ActionHeight = height; - HealBot_Action:SetWidth(width+bwidth+10) -end - -function HealBot_Action_SetHealButton(index,unit) - if not index then - HealBot_Action_HealButtons = {}; - HealBot_Action_UnitButtons = {}; - return nil - end - local button = getglobal("HealBot_Action_HealUnit"..index); - button.unit = unit; - if unit then - table.insert(HealBot_Action_HealButtons,button); - if not HealBot_Action_UnitButtons[unit] then HealBot_Action_UnitButtons[unit] = {} end - table.insert(HealBot_Action_UnitButtons[unit],button); - else - button:Hide(); - end - return button; -end - -function HealBot_Action_PartyChanged() - -if not HealBot_IsFighting then - - local numBars = 0; - local numHeaders = 0; - local TempMaxH=0; - local HeaderPos = {}; - - for j=1,15 do - local headerobj=getglobal("HealBot_Action_Header"..j); - headerobj:SetText(" ") - headerobj:Hide(); - end - - local bwidth = HealBot_Config.bwidth[HealBot_Config.Current_Skin] or 85; - local sr=HealBot_Config.btextdisbledcolr[HealBot_Config.Current_Skin] or 0.4; - local sg=HealBot_Config.btextdisbledcolg[HealBot_Config.Current_Skin] or 0.4; - local sb=HealBot_Config.btextdisbledcolb[HealBot_Config.Current_Skin] or 0.4; - local sa=HealBot_Config.btextdisbledcola[HealBot_Config.Current_Skin] or 0.6; - local bheight=HealBot_Config.bheight[HealBot_Config.Current_Skin] or 18; - local btexture=HealBot_Config.btexture[HealBot_Config.Current_Skin] or 5; - local bcspace=HealBot_Config.bcspace[HealBot_Config.Current_Skin] or 4; - local cols=HealBot_Config.numcols[HealBot_Config.Current_Skin] or 2; - local btextheight=HealBot_Config.btextheight[HealBot_Config.Current_Skin] or 10; - local abortsize=HealBot_Config.abortsize[HealBot_Config.Current_Skin] or 10; - local checked_start=0; - local checked_end=0; - headerno=0; - - for j=1,41 do - HealBot_Action_SetHealButton(j,nil); - end - for j=51,60 do - HealBot_Action_SetHealButton(j,nil); - end - HealBot_Action_SetHealButton(); - local i = 0; - local last = 0; - local GroupValid=numBars; - last = last+6 - if HealBot_Config.GroupHeals==1 then - if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then - HeaderPos[i+1] = HEALBOT_OPTIONS_GROUPHEALS - end - for _,unit in ipairs(HealBot_Action_HealGroup) do - if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then - i = i+1; - HealBot_Action_SetHealButton(i,unit); - numBars=numBars+1; - end - if i==last then break end - end - end - if numBars>GroupValid and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then - numBars=numBars+1; - numHeaders=numHeaders+1; - end - - last = last+10 - local TankValid=numBars; - if HealBot_Config.TankHeals==1 then - if GetNumRaidMembers()>0 and CT_RA_MainTanks then - if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then - HeaderPos[i+1] = HEALBOT_OPTIONS_TANKHEALS - end - for j=1,10 do - if CT_RA_MainTanks[j] then - for k=1,GetNumRaidMembers() do - local unit = "raid"..k; - local PossibleMT=1; - if UnitInParty(unit) and HealBot_Config.GroupHeals==1 then - if not UnitIsUnit(unit, "player") then - PossibleMT=0; - end - end - if PossibleMT==1 then - if UnitName(unit)==CT_RA_MainTanks[j] then - if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then - i = i+1; - HealBot_Action_SetHealButton(i,unit); - numBars=numBars+1; - end - end - end - end - end - if i==last then break end - end - end - end - if numBars>TankValid and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then - numBars=numBars+1; - numHeaders=numHeaders+1; - end - - last = last+10; - local h=50; - local TargetValid=numBars; - if HealBot_Config.TargetHeals==1 then - if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then - HeaderPos[i+1] = HEALBOT_OPTIONS_TARGETHEALS - end - for _,unit in ipairs(HealBot_Action_HealTarget) do - if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then - i = i+1; - h = h+1; - if checked_start==0 then checked_start=i; end - checked_end=i; - HealBot_Action_SetHealButton(h,unit); - local check = getglobal("HealBot_Action_HealUnit"..h.."Check"); - check.unit = unit; - check:SetChecked(1); - check:Show(); - numBars=numBars+1; - end - if i==last then break end - end - - last = last+1 - unit = HealBot_TargetName() - if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal("target") then - i = i+1; - h = h+1; - if h<61 then - HealBot_Action_SetHealButton(h,"target"); - local check = getglobal("HealBot_Action_HealUnit"..h.."Check"); - - check:SetChecked(0); - check.unit = unit; - if check.unit then - if checked_start==0 then checked_start=i; end - checked_end=i; - check:Show(); - else - check:Hide(); - end - else - HealBot_Action_SetHealButton(i,"target"); - end - numBars=numBars+1; - end - end - if numBars>TargetValid and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then - numBars=numBars+1; - numHeaders=numHeaders+1; - end - - last = last+40 - local ExtraValid=numBars; - if HealBot_Config.EmergencyHeals==1 then - local order = {}; - local units = {}; - if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 and HealBot_Config.ExtraOrder==1 then - HeaderPos[i+1] = HEALBOT_OPTIONS_EMERGENCYHEALS - numBars=numBars+1; - numHeaders=numHeaders+1; - end - if HealBot_Config.EmergIncMonitor==1 then - if GetNumRaidMembers()>0 then - for j=1,40 do - local PossibleEmerg=1; - local unit = "raid"..j; - local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(j); - if not name then name="not known" end - if not class then class="not known" end - if not subgroup then subgroup="not known" end - - if UnitInParty(unit) and HealBot_Config.GroupHeals==1 then - PossibleEmerg=0; - end - if PossibleEmerg==1 then - if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then - if HealBot_Config.ExtraOrder==1 then - order[unit] = name; - elseif HealBot_Config.ExtraOrder==2 then - order[unit] = class; - elseif HealBot_Config.ExtraOrder==3 then - order[unit] = subgroup; - else - order[unit] = 0-UnitHealthMax(unit); - if UnitHealthMax(unit)>TempMaxH then TempMaxH=UnitHealthMax(unit); end - end - table.insert(units,unit); - numBars=numBars+1; - end - end - end - else - for _,unit in ipairs(HealBot_Action_HealGroup) do - if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then - if HealBot_Config.ExtraOrder==1 then - order[unit] = name; - elseif HealBot_Config.ExtraOrder==2 then - order[unit] = class; - elseif HealBot_Config.ExtraOrder==3 then - order[unit] = subgroup; - else - order[unit] = 0-UnitHealthMax(unit); - if UnitHealthMax(unit)>TempMaxH then TempMaxH=UnitHealthMax(unit); end - end - table.insert(units,unit); - numBars=numBars+1; - end - end - end - else - if GetNumRaidMembers()>0 then - for j=1,40 do - - local unit = "raid"..j; - local Class = UnitClass(unit); - local ProcessUnit = 0; - local PossibleEmerg=1; - local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(j); - if not name then name="not known" end - if not class then class="not known" end - if not subgroup then subgroup="not known" end - - if HealBot_EmergInc[Class]==1 then - ProcessUnit = 1; - end - if UnitInParty(unit) and HealBot_Config.GroupHeals==1 then - PossibleEmerg=0; - end - - if ProcessUnit==1 and PossibleEmerg==1 then - if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then - if HealBot_Config.ExtraOrder==1 then - order[unit] = name; - elseif HealBot_Config.ExtraOrder==2 then - order[unit] = class; - elseif HealBot_Config.ExtraOrder==3 then - order[unit] = subgroup; - else - order[unit] = 0-UnitHealthMax(unit); - if UnitHealthMax(unit)>TempMaxH then TempMaxH=UnitHealthMax(unit); end - end - table.insert(units,unit); - numBars=numBars+1; - end - end - end - else - for _,unit in ipairs(HealBot_Action_HealGroup) do - if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then - if HealBot_Config.ExtraOrder==1 then - order[unit] = name; - elseif HealBot_Config.ExtraOrder==2 then - order[unit] = class; - elseif HealBot_Config.ExtraOrder==3 then - order[unit] = subgroup; - else - order[unit] = 0-UnitHealthMax(unit); - if UnitHealthMax(unit)>TempMaxH then TempMaxH=UnitHealthMax(unit); end - end - table.insert(units,unit); - numBars=numBars+1; - end - end - end - end - table.sort(units,function (a,b) - if order[a]order[b] then return false end - return a0 then - for j=1,40 do - if not units[j] then break end - local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(strsub(units[j], 5)); - if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 and HealBot_Config.ExtraOrder==2 and TempSort~=class then - TempSort=class - HeaderPos[i+1] = class - numBars=numBars+1; - numHeaders=numHeaders+1; - end - if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 and HealBot_Config.ExtraOrder==3 and TempSort~=subgroup then - TempSort=subgroup - HeaderPos[i+1] = HEALBOT_OPTIONS_GROUPHEALS..subgroup - numBars=numBars+1; - numHeaders=numHeaders+1; - end - if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 and HealBot_Config.ExtraOrder==4 and TempMaxH>UnitHealthMax(units[j]) then - TempMaxH=TempMaxH-1000 - HeaderPos[i+1] = ">"..tostring(TempMaxH/1000).."k" - numBars=numBars+1; - numHeaders=numHeaders+1; - end - i = i+1; - HealBot_Action_SetHealButton(i,units[j]); - if i==last then break end - end - end - end - if numBars==ExtraValid+1 and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then - HeaderPos[i+1] = nil; - numBars=numBars-1; - end - - OffsetY = 10; - OffsetX = 10; - MaxOffsetY=0; - - if cols>(numBars-numHeaders) then - cols=numBars-numHeaders; - end - if cols <= 0 then cols = 1 end - - local h=1; - local i=0; - local z=1; - - table.foreach(HealBot_Action_HealButtons, function (index,button) - i=i+1; - local checked=false; - local header; - - if HeaderPos[i] then - header=HeaderPos[i]; - OffsetY = HealBot_Action_PositionButton(nil,OffsetX,OffsetY,bwidth,bheight,checked,header); - if h==ceil((numBars)/cols) and z=i then checked=true; end - OffsetY = HealBot_Action_PositionButton(button,OffsetX,OffsetY,bwidth,bheight,checked,nil); - if h==ceil((numBars)/cols) and z width) then - width = txtL:GetWidth() + txtR:GetWidth() + 25 - end - end - HealBot_Tooltip:SetWidth(width) - HealBot_Tooltip:SetHeight(height) - HealBot_Tooltip:ClearAllPoints(); - if HealBot_Config.TooltipPos>1 then - if HealBot_Config.TooltipPos==2 then - HealBot_Tooltip:SetPoint("TOPRIGHT","HealBot_Action","TOPLEFT",0,0); - elseif HealBot_Config.TooltipPos==3 then - HealBot_Tooltip:SetPoint("TOPLEFT","HealBot_Action","RIGHT",0,0); - elseif HealBot_Config.TooltipPos==4 then - HealBot_Tooltip:SetPoint("BOTTOM","HealBot_Action","TOP",0,0); - else - HealBot_Tooltip:SetPoint("TOP","HealBot_Action","BOTTOM",0,0); - end - else - HealBot_Tooltip:SetPoint("BOTTOMRIGHT","WorldFrame","BOTTOMRIGHT",-105,105); - end - HealBot_Tooltip:Show(); -end - -function HealBot_Action_Tooltip_SpellInfo(spell,linenum) - local text - if HealBot_Spells[spell] then - if HealBot_Spells[spell].HealsDur>0 then - linenum=linenum+1 - HealBot_Action_Tooltip_SetLineLeft(HEALBOT_WORDS_CAST..": "..HealBot_Spells[spell].CastTime.." "..HEALBOT_WORDS_SEC..".",0.8,0.8,0.8,linenum) - HealBot_Action_Tooltip_SetLineRight("Mana: "..HealBot_Spells[spell].Mana,0.5,0.5,1,linenum) - if HealBot_Spells[spell].HealsMax>0 then - local Heals = HEALBOT_HEAL.." " - if HealBot_Spells[spell].Shield then - Heals = HEALBOT_TOOLTIP_SHIELD.." " - end - if HealBot_Spells[spell].HealsMin0 then - text=HEALBOT_HEAL.." "..HealBot_Spells[spell].HealsDur.." "..HEALBOT_WORDS_OVER.." "..HealBot_Spells[spell].Duration-HealBot_Spells[spell].CastTime.." sec." - linenum=linenum+1 - HealBot_Action_Tooltip_SetLineLeft(text,1,1,1,linenum) - end - if not HealBot_Spells[spell].Shield then - text=HEALBOT_TOOLTIP_ITEMBONUS.." +"..HealBot_GetBonus().." | "..HEALBOT_TOOLTIP_ACTUALBONUS.." +"..HealBot_Spells[spell].RealHealing.." " - linenum=linenum+1 - HealBot_Action_Tooltip_SetLineLeft(text,0.8,0.8,0.8,linenum) - end - end - end - return linenum -end - -function HealBot_Action_Tooltip_SpellSummary(spell) - local ret_val = " "; - if HealBot_Spells[spell] then - if HealBot_Spells[spell].HealsDur and HealBot_Spells[spell].HealsDur>0 then - if HealBot_Spells[spell].HealsMax and HealBot_Spells[spell].HealsMax>0 then - local Heals = " "..HEALBOT_HEAL.." "; - if HealBot_Spells[spell].Shield then - Heals = " "..HEALBOT_TOOLTIP_SHIELD.." "; - end - if (HealBot_Spells[spell].HealsMin or 0)<(HealBot_Spells[spell].HealsMax or 0) then - ret_val=ret_val..Heals..format("%d", (((HealBot_Spells[spell].HealsMin or 0)+(HealBot_Spells[spell].HealsMax or 0))/2) + (HealBot_Spells[spell].RealHealing or 0)); - else - ret_val=ret_val..Heals..format("%d", (HealBot_Spells[spell].HealsMax or 0) + (HealBot_Spells[spell].RealHealing or 0)); - end - end - if HealBot_Spells[spell].HealsExt and HealBot_Spells[spell].HealsExt>0 then - ret_val=ret_val.." HoT "..HealBot_Spells[spell].HealsDur; - end - if HealBot_Spells[spell].Mana then - ret_val=ret_val.." "..HEALBOT_WORDS_FOR.." "..HealBot_Spells[spell].Mana.." Mana"; - end - end - end - if string.len(ret_val)<5 then ret_val = " - "..spell; end - return ret_val -end - -function HealBot_Action_Tooltip_CheckForInstant(unit,spell,upd,linenum,check) - if HealBot_Spells[spell] then - if HealBot_Spells[spell].CastTime == 0 then - if HealBot_UnitAffected(unit,HealBot_Spells[spell].Buff) then return check,linenum end; - if HealBot_UnitAffected(unit,HealBot_Spells[spell].Debuff) then return check,linenum end; - if upd=="upd" then - linenum=linenum+1 - HealBot_Action_Tooltip_SetLineLeft(" "..spell,1,1,1,linenum) - end - else - return check,linenum; - end - else - return check,linenum - end - return check+1,linenum; -end - -function HealBot_Action_Tooltip_SetLineLeft(Text,R,G,B,linenum) - local txtL = getglobal("HealBot_TooltipTextL" .. linenum) - txtL:SetTextColor(R,G,B) - txtL:SetText(Text) - txtL:Show() -end - -function HealBot_Action_Tooltip_SetLineRight(Text,R,G,B,linenum) - local txtR = getglobal("HealBot_TooltipTextR" .. linenum) - txtR:SetTextColor(R,G,B) - txtR:SetText(Text) - txtR:Show() -end - -function HealBot_Action_Tooltip_ClearLines() - for j=1,30 do - local txtL = getglobal("HealBot_TooltipTextL" .. j) - local txtR = getglobal("HealBot_TooltipTextR" .. j) - txtL:SetText(" ") - txtR:SetText(" ") - txtL:Hide() - txtR:Hide() - end -end - -function HealBot_Action_ShowTooltip(this) - if HealBot_Config.ShowTooltip==0 then return end - if not this.unit then return end; - if not this:IsEnabled() then return end; - -- GameTooltip_SetDefaultAnchor(HealBot_Tooltip,this); - - - HealBot_Action_TooltipUnit = this.unit; - HealBot_Action_RefreshTooltip(this.unit); -end - -function HealBot_Action_HideTooltip(this) - if HealBot_Config.ShowTooltip==0 then return end - HealBot_Tooltip:Hide(); - HealBot_Action_TooltipUnit = nil; -end - -function HealBot_Action_Refresh(unit) - if (UnitIsDeadOrGhost("player")) or (UnitOnTaxi("player")) then - if HealBot_Config.AutoClose==1 and HealBot_Config.ActionVisible~=0 then - HealBot_Action:Hide(); - else - HealBot_Action_RefreshButtons(unit); - end - return; - end - HealBot_Action_RefreshButtons(unit); - if not HealBot_IsFighting then - if (HealBot_Action_MustHealSome()) then - HealBot_Action:Show(); - elseif HealBot_AbortButton==0 then - HealBot_Action:Show(); - elseif (not HealBot_Action_ShouldHealSome()) then - if HealBot_AbortButton==1 and HealBot_Config.AutoClose==1 and HealBot_Config.ActionVisible~=0 then - HealBot_Action:Hide(); - end - end - end -end - -function HealBot_Action_SpellPattern(button) - local combos = HealBot_Config.KeyCombo[UnitClass("player")] - if not combos then return nil end - local press = button; - if IsAltKeyDown() then press = "Alt"..press end - if IsControlKeyDown() then press = "Ctrl"..press end - if IsShiftKeyDown() then press = "Shift"..press end - return combos[press] -end - -function HealBot_Decode_Button(button) - if button=="RightButton" then - button="Right"; - elseif button=="MiddleButton" then - button="Middle"; - elseif button=="Button4" then - button="Button4"; - elseif button=="Button5" then - button="Button5"; - else - button="Left"; - end - return button -end - --------------------------------------------------------------------------------------------------- --- Widget_OnFoo functions --------------------------------------------------------------------------------------------------- - -function HealBot_Action_HealUnit_OnLoad(this) - this:RegisterForClicks("LeftButtonUp", "RightButtonUp", "MiddleButtonUp", "Button4Up", "Button5Up"); -end - -function HealBot_Action_HealUnit_OnEnter(this) - HealBot_Action_ShowTooltip(this); -end - -function HealBot_Action_HealUnit_OnLeave(this) - HealBot_Action_HideTooltip(this); -end - -function HealBot_Action_HealUnit_OnClick(this,button) - local decode_button = HealBot_Decode_Button(button); - local pattern = HealBot_Action_SpellPattern(decode_button); - - -- Buff casting override - if HealBot_Config.BuffWatch == 1 then - local inCombat = UnitAffectingCombat("player") - if (not inCombat) or (HealBot_Config.BuffWatchInCombat == 1) then - local myClass = UnitClass("player") - if HealBot_MissingBuffs[this.unit] then - local missingBuff = HealBot_MissingBuffs[this.unit] - if decode_button == "Left" or decode_button == "Right" then - HealBot_CastSpellOnFriend(missingBuff, this.unit) - return - end - end - end - end - - HealBot_HealUnit(this.unit,pattern); - end - -function HealBot_Action_HealUnitCheck_OnClick(this) - if not this.unit then return end - if this:GetChecked() then - table.insert(HealBot_Action_HealTarget,this.unit) - else - for i=1,table.getn(HealBot_Action_HealTarget) do - if HealBot_Action_HealTarget[i]==this.unit then - table.remove(HealBot_Action_HealTarget,i); - break; - end - end - end - HealBot_Action_PartyChanged(); -end - -function HealBot_Action_OptionsButton_OnClick(this) - HealBot_TogglePanel(HealBot_Options); -end - -function HealBot_Action_AbortButton_OnClick(this) - SpellStopCasting(); -end - -local HealBot_CT_RA_UpdateMTs_Old; -function HealBot_CT_RA_UpdateMTs() - local value = HealBot_CT_RA_UpdateMTs_Old(); - return value; -end - -function HealBot_CT_RaidAssist_DEAD() --- if (type(CT_RA_MemberFrame_OnClick)=="function") then --- HealBot_CT_RA_CustomOnClickFunction_Old = CT_RA_CustomOnClickFunction; --- CT_RA_CustomOnClickFunction = HealBot_CT_RA_CustomOnClickFunction; --- end --- if (type(CT_RA_UpdateMTs)=="function") then --- HealBot_CT_RA_UpdateMTs_Old = CT_RA_UpdateMTs; --- CT_RA_UpdateMTs = HealBot_CT_RA_UpdateMTs; --- end -end - --------------------------------------------------------------------------------------------------- --- Frame_OnFoo functions --------------------------------------------------------------------------------------------------- - -function HealBot_Action_OnLoad(this) --- HealBot_CT_RaidAssist(); -end - -function HealBot_Action_OnShow(this) - if HealBot_Config.PanelSounds==1 then - PlaySound("igAbilityOpen"); - end - HealBot_Config.ActionVisible = 1 - HealBot_Action:SetBackdropColor( - HealBot_Config.backcolr[HealBot_Config.Current_Skin], - HealBot_Config.backcolg[HealBot_Config.Current_Skin], - HealBot_Config.backcolb[HealBot_Config.Current_Skin], - HealBot_Config.backcola[HealBot_Config.Current_Skin]); - local borderStyle = HealBot_Config.bborder[HealBot_Config.Current_Skin] or 2 - if borderStyle == 0 then - HealBot_Action:SetBackdropBorderColor(0,0,0,0); - elseif borderStyle == 1 then - HealBot_Action:SetBackdrop({ - bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", - edgeFile = "Interface\\Buttons\\WHITE8X8", - tile = true, tileSize = 8, edgeSize = 1, - insets = { left = 1, right = 1, top = 1, bottom = 1 } - }) - HealBot_Action:SetBackdropBorderColor( - HealBot_Config.borcolr[HealBot_Config.Current_Skin], - HealBot_Config.borcolg[HealBot_Config.Current_Skin], - HealBot_Config.borcolb[HealBot_Config.Current_Skin], - HealBot_Config.borcola[HealBot_Config.Current_Skin]); - else - HealBot_Action:SetBackdrop({ - bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", - edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, tileSize = 8, edgeSize = 16, - insets = { left = 4, right = 4, top = 4, bottom = 4 } - }) - HealBot_Action:SetBackdropBorderColor( - HealBot_Config.borcolr[HealBot_Config.Current_Skin], - HealBot_Config.borcolg[HealBot_Config.Current_Skin], - HealBot_Config.borcolb[HealBot_Config.Current_Skin], - HealBot_Config.borcola[HealBot_Config.Current_Skin]); - end -end - -function HealBot_Action_OnHide(this) - HealBot_StopMoving(this); - HealBot_Config.ActionVisible = 0 -end - -function HealBot_Action_OnMouseDown(this,button) - if button~="RightButton" then - if HealBot_Config.ActionLocked==0 then - HealBot_StartMoving(this); - end - end -end - -function HealBot_Action_OnMouseUp(this,button) - if button~="RightButton" then - HealBot_StopMoving(this); - elseif not HealBot_IsFighting then - HealBot_Action_OptionsButton_OnClick(); - end -end - -function HealBot_Action_OnClick(this,button) --- HealBot_Action_AddDebug("OnClick("..button..")"); -end - -function HealBot_Action_OnDragStart(this,button) - if HealBot_Config.ActionLocked==0 then - HealBot_StartMoving(this); - end -end - -function HealBot_Action_OnDragStop(this) - HealBot_StopMoving(this); -end - --- http://www.flexbarforums.com/viewtopic.php?t=66 -function HealBot_Action_OnKey(this,key,state) - local command = GetBindingAction(key); - if command then - DEFAULT_CHAT_FRAME:AddMessage(key.." "..state.." "..(command or "nil")); - keystate = state - RunBinding(command,keystate) - end - DEFAULT_CHAT_FRAME:AddMessage("HealBot_Action_OnKey - "..key); - if key=="SHIFT" or key=="CTRL" or key=="ALT" then - DEFAULT_CHAT_FRAME:AddMessage((IsShiftKeyDown() or 0).." "..(IsControlKeyDown() or 0).." "..(IsAltKeyDown() or 0)); - HealBot_Action_Refresh(); - end -end - - - - +function HealBot_Action_SetTexture(bar, btexture) + if not bar then return end + if btexture == 10 then + bar:SetStatusBarTexture("Interface\\Buttons\\WHITE8X8"); + else + bar:SetStatusBarTexture("Interface\\AddOns\\HealBotBlue\\Images\\bar" .. tostring(btexture) .. ".tga"); + end +end +local headerno=0; + +HealBot_Action_HealGroup = { + "player", + "pet", + "party1", + "party2", + "party3", + "party4", +}; + +HealBot_Action_HealTarget = { +}; + +HealBot_Action_HealButtons = { +}; + +HealBot_Action_UnitButtons = { +}; + +function HealBot_Action_AddDebug(msg) + HealBot_AddDebug("Action: " .. msg); +end + +function HealBot_HealthColor(unit,hlth,maxhlth) + if HealBot_UnitDebuff[unit] then + local debuff, tmp, debuff_type = UnitDebuff(unit,1, 1) + if not debuff then + HealBot_UnitDebuff[unit] = nil; + HealBot_UnitDebuff[unit.."_debuff_texture"]=nil + else + local dr = HealBot_Config.CDCBarColour[HealBot_UnitDebuff[unit]].R + local dg = HealBot_Config.CDCBarColour[HealBot_UnitDebuff[unit]].G + local db = HealBot_Config.CDCBarColour[HealBot_UnitDebuff[unit]].B + if HealBot_Config.btexture[HealBot_Config.Current_Skin] == 10 then + dr = dr * 4 + dg = dg * 4 + db = db * 4 + if dr > 1 then dr = 1 end + if dg > 1 then dg = 1 end + if db > 1 then db = 1 end + end + return dr, dg, db, HealBot_Config.Barcola[HealBot_Config.Current_Skin]; + end + end + local text = UnitName(unit); + if not HealBot_HealsIn[text] then + HealBot_HealsIn[text]=0; + end + + local pct = hlth+HealBot_HealsIn[text]; + if maxhlth and maxhlth > 0 then + if pctHealBot_Config.AlertLevel then + a=HealBot_Config.bardisa[HealBot_Config.Current_Skin]; + end + + local colorMode = HealBot_Config.bcolormode[HealBot_Config.Current_Skin] or 1 + if colorMode == 2 and HealBot_Model and HealBot_Model.units[unit] and HealBot_Model.units[unit].englishClass then + local engClass = HealBot_Model.units[unit].englishClass + if RAID_CLASS_COLORS and RAID_CLASS_COLORS[engClass] then + r = RAID_CLASS_COLORS[engClass].r + g = RAID_CLASS_COLORS[engClass].g + b = RAID_CLASS_COLORS[engClass].b + end + else + if pct>=0.98 then r = 0.0; end + if pct<0.98 and pct>=0.65 then r=2.94-(pct*3); end + if pct<=0.64 and pct>0.31 then g=(pct-0.31)*3; end + if pct<=0.31 then g = 0.0; end + end + return r,g,b,a; +end + +function HealBot_Action_HealthBar(button) + local name = button:GetName(); + return getglobal(name.."Bar"); +end + +function HealBot_Action_HealthBar2(button) + local name = button:GetName(); + return getglobal(name.."Bar2"); +end + +function HealBot_AlwaysHeal() + return HealBot_Config.EnableHealthy==1 +end + +function HealBot_MayHeal(unit) + if not UnitName(unit) or not HealBot_Heals[unit] then return false end + if unit ~= 'target' then return true end + if not HealBot_Config.TargetHeals or UnitCanAttack("player",unit) then return false end + return true; +end + +function HealBot_ShouldHeal(unit) + if HealBot_UnitDebuff[unit] and not UnitIsDeadOrGhost(unit) then + if HealBot_Range_Check(unit, 30)==1 then + return true; + end + end + return HealBot_MayHeal(unit) and UnitHealth(unit)>0 and not UnitIsDeadOrGhost(unit) + and (UnitHealth(unit) 0 and pt == 0 then + if HealBot_Config.ManaBarsHealersOnly == 1 then + if isHealer then showMana = true end + else + showMana = true + end + end + + if showMana then + local pr, pg, pb = 0, 0, 1 + + if bar3 then + bar3:SetMinMaxValues(0, state.maxMana) + bar3:SetValue(state.mana) + bar3:SetStatusBarColor(pr, pg, pb, HealBot_Config.Barcola[HealBot_Config.Current_Skin]) + bar3:Show() + bar3:SetHeight(bheight * 0.2) + end + + bar:SetHeight(bheight * 0.8) + bar2:SetHeight(bheight * 0.8) + else + if bar3 then + bar3:Hide() + end + bar:SetHeight(bheight) + bar2:SetHeight(bheight) + end + + if HealBot_HealsIn[name] then + bar2:SetMinMaxValues(0,maxhlth); + bar2:SetValue(hlth+HealBot_HealsIn[name]); + else + bar2:SetValue(0); + end + bar.txt = getglobal(bar:GetName().."_text"); + if (not HealBot_IsCasting and (HealBot_CanHeal(unit) or HealBot_MissingBuffs[unit])) then + button:Enable(); + if HealBot_UnitDebuff[unit] then + sr=HealBot_Config.btextcursecolr[HealBot_Config.Current_Skin]; + sg=HealBot_Config.btextcursecolg[HealBot_Config.Current_Skin]; + sb=HealBot_Config.btextcursecolb[HealBot_Config.Current_Skin]; + sa=HealBot_Config.btextcursecola[HealBot_Config.Current_Skin]; + elseif HealBot_MissingBuffs[unit] then + r=r*0.5; + g=g*0.5; + b=b*0.5; + sr=1.0; + sg=1.0; + sb=0.0; + end + bar:SetStatusBarColor(r,g,b,HealBot_Config.Barcola[HealBot_Config.Current_Skin]); + bar2:SetStatusBarColor(r,g,b,HealBot_Config.BarcolaInHeal[HealBot_Config.Current_Skin]); + else + button:Disable(); + sr=HealBot_Config.btextdisbledcolr[HealBot_Config.Current_Skin]; + sg=HealBot_Config.btextdisbledcolg[HealBot_Config.Current_Skin]; + sb=HealBot_Config.btextdisbledcolb[HealBot_Config.Current_Skin]; + sa=HealBot_Config.btextdisbledcola[HealBot_Config.Current_Skin]; + bar:SetStatusBarColor(r,g,b,HealBot_Config.bardisa[HealBot_Config.Current_Skin]); + bar2:SetStatusBarColor(r,g,b,HealBot_Config.bardisa[HealBot_Config.Current_Skin]); + end + if string.len(name)>textlen then + name = string.sub(name,1,textlen-3) .. '...'; + end + bar.txt:SetText(name); + bar.txt:SetTextColor(sr,sg,sb,sa); + local fontName, fontHeight, fontFlags = bar.txt:GetFont() + local fontOutline = HealBot_Config.bfontoutline[HealBot_Config.Current_Skin] or 0 + if fontOutline == 1 then + bar.txt:SetFont(fontName, fontHeight, "OUTLINE") + else + bar.txt:SetFont(fontName, fontHeight, "") + end + local fontName, fontHeight, fontFlags = bar.txt:GetFont() + local fontOutline = HealBot_Config.bfontoutline[HealBot_Config.Current_Skin] or 0 + if fontOutline == 1 then + bar.txt:SetFont(fontName, fontHeight, "OUTLINE") + else + bar.txt:SetFont(fontName, fontHeight, "") + end + + for i = 1, 5 do + local icon = getglobal(button:GetName().."BarIcon"..i) + if icon then + if HealBot_UnitIcons and HealBot_UnitIcons[unit] and HealBot_UnitIcons[unit][i] then + icon:SetTexture(HealBot_UnitIcons[unit][i]) + icon:Show() + else + icon:Hide() + end + end + end +end + +function HealBot_Action_EnableButtons() + table.foreach(HealBot_Action_HealButtons, function (index,button) + HealBot_Action_EnableButton(button); + end); +end + +function HealBot_Action_RefreshButton(button) + if not button then return end + if type(button)~="table" then DEFAULT_CHAT_FRAME:AddMessage("***** "..type(button)) end + local unit = button.unit; + if HealBot_MayHeal(unit) then + HealBot_Action_EnableButton(button) + end +end + +function HealBot_Action_ResetSkin() + HealBot_Action_PartyChanged() + if HealBot_Options:IsVisible() then + HealBot_Action_SetTexture(HealBot_DiseaseColorpick, HealBot_Config.btexture[HealBot_Config.Current_Skin]) + HealBot_Action_SetTexture(HealBot_MagicColorpick, HealBot_Config.btexture[HealBot_Config.Current_Skin]) + HealBot_Action_SetTexture(HealBot_PoisonColorpick, HealBot_Config.btexture[HealBot_Config.Current_Skin]) + HealBot_Action_SetTexture(HealBot_CurseColorpick, HealBot_Config.btexture[HealBot_Config.Current_Skin]) + HealBot_Action_SetTexture(HealBot_EnTextColorpick, HealBot_Config.btexture[HealBot_Config.Current_Skin]) + HealBot_Action_SetTexture(HealBot_EnTextColorpickin, HealBot_Config.btexture[HealBot_Config.Current_Skin]) + HealBot_Action_SetTexture(HealBot_DisTextColorpick, HealBot_Config.btexture[HealBot_Config.Current_Skin]) + HealBot_Action_SetTexture(HealBot_DebTextColorpick, HealBot_Config.btexture[HealBot_Config.Current_Skin]) + HealBot_SetSkinColours() + end +end + +function HealBot_Action_RefreshButtons() + table.foreach(HealBot_Action_HealButtons, function (index,button) + HealBot_Action_RefreshButton(button); + end); +end + +function HealBot_Action_RefreshButtons(unit) + if unit and HealBot_Action_UnitButtons[unit] then + table.foreach(HealBot_Action_UnitButtons[unit], function (index,button) + HealBot_Action_RefreshButton(button); + end); + else + table.foreach(HealBot_Action_HealButtons, function (index,button) + HealBot_Action_RefreshButton(button); + end); + end +end + +function HealBot_Action_PositionButton(button,OsetX,OsetY,bwidth,bheight,checked,header) + local brspace=HealBot_Config.brspace[HealBot_Config.Current_Skin] or 3; + if header then + headerno=headerno+1; + local headerobj=getglobal("HealBot_Action_Header"..headerno); + local tmpY=OsetY + headerobj:SetText(header) + headerobj:Show(); + headerobj:ClearAllPoints(); + headerobj:SetHeight(bheight); + headerobj:SetWidth(bwidth); + headerobj:SetPoint("TOPLEFT","HealBot_Action","TOPLEFT",OsetX,-OsetY); + headerobj:Disable(); + OsetY = OsetY+headerobj:GetHeight()+brspace; + else + local unit = button.unit; + button:SetText(" "); + if (HealBot_MayHeal(unit)) then + button:Show(); + button:ClearAllPoints(); + button:SetHeight(bheight); + if checked then + button:SetWidth(bwidth-14); + button:SetPoint("TOPLEFT","HealBot_Action","TOPLEFT",OsetX+14,-OsetY); + else + button:SetWidth(bwidth); + button:SetPoint("TOPLEFT","HealBot_Action","TOPLEFT",OsetX,-OsetY); + end + OsetY = OsetY+button:GetHeight()+brspace; + else + button:Hide(); + end + end + return OsetY; +end + +function HealBot_Action_SetHeightWidth(width,height,bwidth) + if HealBot_ActionHeight then + HealBot_Action:SetHeight(HealBot_ActionHeight); + end + if HealBot_Config.GrowUpwards==1 then + local left,bottom = HealBot_Action:GetLeft(),HealBot_Action:GetBottom(); + if left and bottom then + if HealBot_Config.PanelAnchorX==-1 then HealBot_Config.PanelAnchorX=left; end + if HealBot_Config.PanelAnchorY==-1 then HealBot_Config.PanelAnchorY=bottom; end + HealBot_Action:ClearAllPoints(); + HealBot_Action:SetPoint("BOTTOMLEFT","UIParent","BOTTOMLEFT",HealBot_Config.PanelAnchorX,HealBot_Config.PanelAnchorY); + end + else + local left,top = HealBot_Action:GetLeft(),HealBot_Action:GetTop(); + if left and top then + HealBot_Action:ClearAllPoints(); + HealBot_Action:SetPoint("TOPLEFT","UIParent","BOTTOMLEFT",left,top); + end + end + HealBot_Action:SetHeight(height); + HealBot_ActionHeight = height; + HealBot_Action:SetWidth(width+bwidth+10) +end + +function HealBot_Action_SetHealButton(index,unit) + if not index then + HealBot_Action_HealButtons = {}; + HealBot_Action_UnitButtons = {}; + return nil + end + local button = getglobal("HealBot_Action_HealUnit"..index); + button.unit = unit; + if unit then + table.insert(HealBot_Action_HealButtons,button); + if not HealBot_Action_UnitButtons[unit] then HealBot_Action_UnitButtons[unit] = {} end + table.insert(HealBot_Action_UnitButtons[unit],button); + else + button:Hide(); + end + return button; +end + +function HealBot_Action_PartyChanged() + +if not HealBot_IsFighting then + + local numBars = 0; + local numHeaders = 0; + local TempMaxH=0; + local HeaderPos = {}; + + for j=1,15 do + local headerobj=getglobal("HealBot_Action_Header"..j); + headerobj:SetText(" ") + headerobj:Hide(); + end + + local bwidth = HealBot_Config.bwidth[HealBot_Config.Current_Skin] or 85; + local sr=HealBot_Config.btextdisbledcolr[HealBot_Config.Current_Skin] or 0.4; + local sg=HealBot_Config.btextdisbledcolg[HealBot_Config.Current_Skin] or 0.4; + local sb=HealBot_Config.btextdisbledcolb[HealBot_Config.Current_Skin] or 0.4; + local sa=HealBot_Config.btextdisbledcola[HealBot_Config.Current_Skin] or 0.6; + local bheight=HealBot_Config.bheight[HealBot_Config.Current_Skin] or 18; + local btexture=HealBot_Config.btexture[HealBot_Config.Current_Skin] or 5; + local bcspace=HealBot_Config.bcspace[HealBot_Config.Current_Skin] or 4; + local cols=HealBot_Config.numcols[HealBot_Config.Current_Skin] or 2; + local btextheight=HealBot_Config.btextheight[HealBot_Config.Current_Skin] or 10; + local abortsize=HealBot_Config.abortsize[HealBot_Config.Current_Skin] or 10; + local checked_start=0; + local checked_end=0; + headerno=0; + + for j=1,41 do + HealBot_Action_SetHealButton(j,nil); + end + for j=51,60 do + HealBot_Action_SetHealButton(j,nil); + end + HealBot_Action_SetHealButton(); + local i = 0; + local last = 0; + local GroupValid=numBars; + last = last+6 + if HealBot_Config.GroupHeals==1 then + if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then + HeaderPos[i+1] = HEALBOT_OPTIONS_GROUPHEALS + end + for _,unit in ipairs(HealBot_Action_HealGroup) do + if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then + i = i+1; + HealBot_Action_SetHealButton(i,unit); + numBars=numBars+1; + end + if i==last then break end + end + end + if numBars>GroupValid and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then + numBars=numBars+1; + numHeaders=numHeaders+1; + end + + last = last+10 + local TankValid=numBars; + if HealBot_Config.TankHeals==1 then + if GetNumRaidMembers()>0 and CT_RA_MainTanks then + if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then + HeaderPos[i+1] = HEALBOT_OPTIONS_TANKHEALS + end + for j=1,10 do + if CT_RA_MainTanks[j] then + for k=1,GetNumRaidMembers() do + local unit = "raid"..k; + local PossibleMT=1; + if UnitInParty(unit) and HealBot_Config.GroupHeals==1 then + if not UnitIsUnit(unit, "player") then + PossibleMT=0; + end + end + if PossibleMT==1 then + if UnitName(unit)==CT_RA_MainTanks[j] then + if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then + i = i+1; + HealBot_Action_SetHealButton(i,unit); + numBars=numBars+1; + end + end + end + end + end + if i==last then break end + end + end + end + if numBars>TankValid and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then + numBars=numBars+1; + numHeaders=numHeaders+1; + end + + last = last+10; + local h=50; + local TargetValid=numBars; + if HealBot_Config.TargetHeals==1 then + if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then + HeaderPos[i+1] = HEALBOT_OPTIONS_TARGETHEALS + end + for _,unit in ipairs(HealBot_Action_HealTarget) do + if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then + i = i+1; + h = h+1; + if checked_start==0 then checked_start=i; end + checked_end=i; + HealBot_Action_SetHealButton(h,unit); + local check = getglobal("HealBot_Action_HealUnit"..h.."Check"); + check.unit = unit; + check:SetChecked(1); + check:Show(); + numBars=numBars+1; + end + if i==last then break end + end + + last = last+1 + unit = HealBot_TargetName() + if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal("target") then + i = i+1; + h = h+1; + if h<61 then + HealBot_Action_SetHealButton(h,"target"); + local check = getglobal("HealBot_Action_HealUnit"..h.."Check"); + + check:SetChecked(0); + check.unit = unit; + if check.unit then + if checked_start==0 then checked_start=i; end + checked_end=i; + check:Show(); + else + check:Hide(); + end + else + HealBot_Action_SetHealButton(i,"target"); + end + numBars=numBars+1; + end + end + if numBars>TargetValid and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then + numBars=numBars+1; + numHeaders=numHeaders+1; + end + + last = last+40 + local ExtraValid=numBars; + if HealBot_Config.EmergencyHeals==1 then + local order = {}; + local units = {}; + if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 and HealBot_Config.ExtraOrder==1 then + HeaderPos[i+1] = HEALBOT_OPTIONS_EMERGENCYHEALS + numBars=numBars+1; + numHeaders=numHeaders+1; + end + if HealBot_Config.EmergIncMonitor==1 then + if GetNumRaidMembers()>0 then + for j=1,40 do + local PossibleEmerg=1; + local unit = "raid"..j; + local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(j); + if not name then name="not known" end + if not class then class="not known" end + if not subgroup then subgroup="not known" end + + if UnitInParty(unit) and HealBot_Config.GroupHeals==1 then + PossibleEmerg=0; + end + if PossibleEmerg==1 then + if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then + if HealBot_Config.ExtraOrder==1 then + order[unit] = name; + elseif HealBot_Config.ExtraOrder==2 then + order[unit] = class; + elseif HealBot_Config.ExtraOrder==3 then + order[unit] = subgroup; + else + order[unit] = 0-UnitHealthMax(unit); + if UnitHealthMax(unit)>TempMaxH then TempMaxH=UnitHealthMax(unit); end + end + table.insert(units,unit); + numBars=numBars+1; + end + end + end + else + for _,unit in ipairs(HealBot_Action_HealGroup) do + if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then + if HealBot_Config.ExtraOrder==1 then + order[unit] = name; + elseif HealBot_Config.ExtraOrder==2 then + order[unit] = class; + elseif HealBot_Config.ExtraOrder==3 then + order[unit] = subgroup; + else + order[unit] = 0-UnitHealthMax(unit); + if UnitHealthMax(unit)>TempMaxH then TempMaxH=UnitHealthMax(unit); end + end + table.insert(units,unit); + numBars=numBars+1; + end + end + end + else + if GetNumRaidMembers()>0 then + for j=1,40 do + + local unit = "raid"..j; + local Class = UnitClass(unit); + local ProcessUnit = 0; + local PossibleEmerg=1; + local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(j); + if not name then name="not known" end + if not class then class="not known" end + if not subgroup then subgroup="not known" end + + if HealBot_EmergInc[Class]==1 then + ProcessUnit = 1; + end + if UnitInParty(unit) and HealBot_Config.GroupHeals==1 then + PossibleEmerg=0; + end + + if ProcessUnit==1 and PossibleEmerg==1 then + if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then + if HealBot_Config.ExtraOrder==1 then + order[unit] = name; + elseif HealBot_Config.ExtraOrder==2 then + order[unit] = class; + elseif HealBot_Config.ExtraOrder==3 then + order[unit] = subgroup; + else + order[unit] = 0-UnitHealthMax(unit); + if UnitHealthMax(unit)>TempMaxH then TempMaxH=UnitHealthMax(unit); end + end + table.insert(units,unit); + numBars=numBars+1; + end + end + end + else + for _,unit in ipairs(HealBot_Action_HealGroup) do + if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then + if HealBot_Config.ExtraOrder==1 then + order[unit] = name; + elseif HealBot_Config.ExtraOrder==2 then + order[unit] = class; + elseif HealBot_Config.ExtraOrder==3 then + order[unit] = subgroup; + else + order[unit] = 0-UnitHealthMax(unit); + if UnitHealthMax(unit)>TempMaxH then TempMaxH=UnitHealthMax(unit); end + end + table.insert(units,unit); + numBars=numBars+1; + end + end + end + end + table.sort(units,function (a,b) + if order[a]order[b] then return false end + return a0 then + for j=1,40 do + if not units[j] then break end + local name, rank, subgroup, level, class, fileName, zone, online, isDead = GetRaidRosterInfo(strsub(units[j], 5)); + if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 and HealBot_Config.ExtraOrder==2 and TempSort~=class then + TempSort=class + HeaderPos[i+1] = class + numBars=numBars+1; + numHeaders=numHeaders+1; + end + if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 and HealBot_Config.ExtraOrder==3 and TempSort~=subgroup then + TempSort=subgroup + HeaderPos[i+1] = HEALBOT_OPTIONS_GROUPHEALS..subgroup + numBars=numBars+1; + numHeaders=numHeaders+1; + end + if HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 and HealBot_Config.ExtraOrder==4 and TempMaxH>UnitHealthMax(units[j]) then + TempMaxH=TempMaxH-1000 + HeaderPos[i+1] = ">"..tostring(TempMaxH/1000).."k" + numBars=numBars+1; + numHeaders=numHeaders+1; + end + i = i+1; + HealBot_Action_SetHealButton(i,units[j]); + if i==last then break end + end + end + end + if numBars==ExtraValid+1 and HealBot_Config.ShowHeader[HealBot_Config.Current_Skin]==1 then + HeaderPos[i+1] = nil; + numBars=numBars-1; + end + + OffsetY = 10; + OffsetX = 10; + MaxOffsetY=0; + + if cols>(numBars-numHeaders) then + cols=numBars-numHeaders; + end + if cols <= 0 then cols = 1 end + + local h=1; + local i=0; + local z=1; + + table.foreach(HealBot_Action_HealButtons, function (index,button) + i=i+1; + local checked=false; + local header; + + if HeaderPos[i] then + header=HeaderPos[i]; + OffsetY = HealBot_Action_PositionButton(nil,OffsetX,OffsetY,bwidth,bheight,checked,header); + if h==ceil((numBars)/cols) and z=i then checked=true; end + OffsetY = HealBot_Action_PositionButton(button,OffsetX,OffsetY,bwidth,bheight,checked,nil); + if h==ceil((numBars)/cols) and z width) then + width = txtL:GetWidth() + txtR:GetWidth() + 25 + end + end + HealBot_Tooltip:SetWidth(width) + HealBot_Tooltip:SetHeight(height) + HealBot_Tooltip:ClearAllPoints(); + if HealBot_Config.TooltipPos>1 then + if HealBot_Config.TooltipPos==2 then + HealBot_Tooltip:SetPoint("TOPRIGHT","HealBot_Action","TOPLEFT",0,0); + elseif HealBot_Config.TooltipPos==3 then + HealBot_Tooltip:SetPoint("TOPLEFT","HealBot_Action","RIGHT",0,0); + elseif HealBot_Config.TooltipPos==4 then + HealBot_Tooltip:SetPoint("BOTTOM","HealBot_Action","TOP",0,0); + else + HealBot_Tooltip:SetPoint("TOP","HealBot_Action","BOTTOM",0,0); + end + else + HealBot_Tooltip:SetPoint("BOTTOMRIGHT","WorldFrame","BOTTOMRIGHT",-105,105); + end + HealBot_Tooltip:Show(); +end + +function HealBot_Action_Tooltip_SpellInfo(spell,linenum) + local text + if HealBot_Spells[spell] then + if HealBot_Spells[spell].HealsDur>0 then + linenum=linenum+1 + HealBot_Action_Tooltip_SetLineLeft(HEALBOT_WORDS_CAST..": "..HealBot_Spells[spell].CastTime.." "..HEALBOT_WORDS_SEC..".",0.8,0.8,0.8,linenum) + HealBot_Action_Tooltip_SetLineRight("Mana: "..HealBot_Spells[spell].Mana,0.5,0.5,1,linenum) + if HealBot_Spells[spell].HealsMax>0 then + local Heals = HEALBOT_HEAL.." " + if HealBot_Spells[spell].Shield then + Heals = HEALBOT_TOOLTIP_SHIELD.." " + end + if HealBot_Spells[spell].HealsMin0 then + text=HEALBOT_HEAL.." "..HealBot_Spells[spell].HealsDur.." "..HEALBOT_WORDS_OVER.." "..HealBot_Spells[spell].Duration-HealBot_Spells[spell].CastTime.." sec." + linenum=linenum+1 + HealBot_Action_Tooltip_SetLineLeft(text,1,1,1,linenum) + end + if not HealBot_Spells[spell].Shield then + text=HEALBOT_TOOLTIP_ITEMBONUS.." +"..HealBot_GetBonus().." | "..HEALBOT_TOOLTIP_ACTUALBONUS.." +"..HealBot_Spells[spell].RealHealing.." " + linenum=linenum+1 + HealBot_Action_Tooltip_SetLineLeft(text,0.8,0.8,0.8,linenum) + end + end + end + return linenum +end + +function HealBot_Action_Tooltip_SpellSummary(spell) + local ret_val = " "; + if HealBot_Spells[spell] then + if HealBot_Spells[spell].HealsDur and HealBot_Spells[spell].HealsDur>0 then + if HealBot_Spells[spell].HealsMax and HealBot_Spells[spell].HealsMax>0 then + local Heals = " "..HEALBOT_HEAL.." "; + if HealBot_Spells[spell].Shield then + Heals = " "..HEALBOT_TOOLTIP_SHIELD.." "; + end + if (HealBot_Spells[spell].HealsMin or 0)<(HealBot_Spells[spell].HealsMax or 0) then + ret_val=ret_val..Heals..format("%d", (((HealBot_Spells[spell].HealsMin or 0)+(HealBot_Spells[spell].HealsMax or 0))/2) + (HealBot_Spells[spell].RealHealing or 0)); + else + ret_val=ret_val..Heals..format("%d", (HealBot_Spells[spell].HealsMax or 0) + (HealBot_Spells[spell].RealHealing or 0)); + end + end + if HealBot_Spells[spell].HealsExt and HealBot_Spells[spell].HealsExt>0 then + ret_val=ret_val.." HoT "..HealBot_Spells[spell].HealsDur; + end + if HealBot_Spells[spell].Mana then + ret_val=ret_val.." "..HEALBOT_WORDS_FOR.." "..HealBot_Spells[spell].Mana.." Mana"; + end + end + end + if string.len(ret_val)<5 then ret_val = " - "..spell; end + return ret_val +end + +function HealBot_Action_Tooltip_CheckForInstant(unit,spell,upd,linenum,check) + if HealBot_Spells[spell] then + if HealBot_Spells[spell].CastTime == 0 then + if HealBot_UnitAffected(unit,HealBot_Spells[spell].Buff) then return check,linenum end; + if HealBot_UnitAffected(unit,HealBot_Spells[spell].Debuff) then return check,linenum end; + if upd=="upd" then + linenum=linenum+1 + HealBot_Action_Tooltip_SetLineLeft(" "..spell,1,1,1,linenum) + end + else + return check,linenum; + end + else + return check,linenum + end + return check+1,linenum; +end + +function HealBot_Action_Tooltip_SetLineLeft(Text,R,G,B,linenum) + local txtL = getglobal("HealBot_TooltipTextL" .. linenum) + txtL:SetTextColor(R,G,B) + txtL:SetText(Text) + txtL:Show() +end + +function HealBot_Action_Tooltip_SetLineRight(Text,R,G,B,linenum) + local txtR = getglobal("HealBot_TooltipTextR" .. linenum) + txtR:SetTextColor(R,G,B) + txtR:SetText(Text) + txtR:Show() +end + +function HealBot_Action_Tooltip_ClearLines() + for j=1,30 do + local txtL = getglobal("HealBot_TooltipTextL" .. j) + local txtR = getglobal("HealBot_TooltipTextR" .. j) + txtL:SetText(" ") + txtR:SetText(" ") + txtL:Hide() + txtR:Hide() + end +end + +function HealBot_Action_ShowTooltip(this) + if HealBot_Config.ShowTooltip==0 then return end + if not this.unit then return end; + if not this:IsEnabled() then return end; + -- GameTooltip_SetDefaultAnchor(HealBot_Tooltip,this); + + + HealBot_Action_TooltipUnit = this.unit; + HealBot_Action_RefreshTooltip(this.unit); +end + +function HealBot_Action_HideTooltip(this) + if HealBot_Config.ShowTooltip==0 then return end + HealBot_Tooltip:Hide(); + HealBot_Action_TooltipUnit = nil; +end + +function HealBot_Action_Refresh(unit) + if (UnitIsDeadOrGhost("player")) or (UnitOnTaxi("player")) then + if HealBot_Config.AutoClose==1 and HealBot_Config.ActionVisible~=0 then + HealBot_Action:Hide(); + else + HealBot_Action_RefreshButtons(unit); + end + return; + end + HealBot_Action_RefreshButtons(unit); + if not HealBot_IsFighting then + if (HealBot_Action_MustHealSome()) then + HealBot_Action:Show(); + elseif HealBot_AbortButton==0 then + HealBot_Action:Show(); + elseif (not HealBot_Action_ShouldHealSome()) then + if HealBot_AbortButton==1 and HealBot_Config.AutoClose==1 and HealBot_Config.ActionVisible~=0 then + HealBot_Action:Hide(); + end + end + end +end + +function HealBot_Action_SpellPattern(button) + local combos = HealBot_Config.KeyCombo[UnitClass("player")] + if not combos then return nil end + local press = button; + if IsAltKeyDown() then press = "Alt"..press end + if IsControlKeyDown() then press = "Ctrl"..press end + if IsShiftKeyDown() then press = "Shift"..press end + return combos[press] +end + +function HealBot_Decode_Button(button) + if button=="RightButton" then + button="Right"; + elseif button=="MiddleButton" then + button="Middle"; + elseif button=="Button4" then + button="Button4"; + elseif button=="Button5" then + button="Button5"; + else + button="Left"; + end + return button +end + +-------------------------------------------------------------------------------------------------- +-- Widget_OnFoo functions +-------------------------------------------------------------------------------------------------- + +function HealBot_Action_HealUnit_OnLoad(this) + this:RegisterForClicks("LeftButtonUp", "RightButtonUp", "MiddleButtonUp", "Button4Up", "Button5Up"); +end + +function HealBot_Action_HealUnit_OnEnter(this) + HealBot_Action_ShowTooltip(this); +end + +function HealBot_Action_HealUnit_OnLeave(this) + HealBot_Action_HideTooltip(this); +end + +function HealBot_Action_HealUnit_OnClick(this,button) + local decode_button = HealBot_Decode_Button(button); + local pattern = HealBot_Action_SpellPattern(decode_button); + + -- Buff casting override + if HealBot_Config.BuffWatch == 1 then + local inCombat = UnitAffectingCombat("player") + if (not inCombat) or (HealBot_Config.BuffWatchInCombat == 1) then + local myClass = UnitClass("player") + if HealBot_MissingBuffs[this.unit] then + local missingBuff = HealBot_MissingBuffs[this.unit] + if decode_button == "Left" or decode_button == "Right" then + HealBot_CastSpellOnFriend(missingBuff, this.unit) + return + end + end + end + end + + HealBot_HealUnit(this.unit,pattern); + end + +function HealBot_Action_HealUnitCheck_OnClick(this) + if not this.unit then return end + if this:GetChecked() then + table.insert(HealBot_Action_HealTarget,this.unit) + else + for i=1,table.getn(HealBot_Action_HealTarget) do + if HealBot_Action_HealTarget[i]==this.unit then + table.remove(HealBot_Action_HealTarget,i); + break; + end + end + end + HealBot_Action_PartyChanged(); +end + +function HealBot_Action_OptionsButton_OnClick(this) + HealBot_TogglePanel(HealBot_Options); +end + +function HealBot_Action_AbortButton_OnClick(this) + SpellStopCasting(); +end + +local HealBot_CT_RA_UpdateMTs_Old; +function HealBot_CT_RA_UpdateMTs() + local value = HealBot_CT_RA_UpdateMTs_Old(); + return value; +end + +function HealBot_CT_RaidAssist_DEAD() +-- if (type(CT_RA_MemberFrame_OnClick)=="function") then +-- HealBot_CT_RA_CustomOnClickFunction_Old = CT_RA_CustomOnClickFunction; +-- CT_RA_CustomOnClickFunction = HealBot_CT_RA_CustomOnClickFunction; +-- end +-- if (type(CT_RA_UpdateMTs)=="function") then +-- HealBot_CT_RA_UpdateMTs_Old = CT_RA_UpdateMTs; +-- CT_RA_UpdateMTs = HealBot_CT_RA_UpdateMTs; +-- end +end + +-------------------------------------------------------------------------------------------------- +-- Frame_OnFoo functions +-------------------------------------------------------------------------------------------------- + +function HealBot_Action_OnLoad(this) +-- HealBot_CT_RaidAssist(); +end + +function HealBot_Action_OnShow(this) + if HealBot_Config.PanelSounds==1 then + PlaySound("igAbilityOpen"); + end + HealBot_Config.ActionVisible = 1 + HealBot_Action:SetBackdropColor( + HealBot_Config.backcolr[HealBot_Config.Current_Skin], + HealBot_Config.backcolg[HealBot_Config.Current_Skin], + HealBot_Config.backcolb[HealBot_Config.Current_Skin], + HealBot_Config.backcola[HealBot_Config.Current_Skin]); + local borderStyle = HealBot_Config.bborder[HealBot_Config.Current_Skin] or 2 + if borderStyle == 0 then + HealBot_Action:SetBackdropBorderColor(0,0,0,0); + elseif borderStyle == 1 then + HealBot_Action:SetBackdrop({ + bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", + edgeFile = "Interface\\Buttons\\WHITE8X8", + tile = true, tileSize = 8, edgeSize = 1, + insets = { left = 1, right = 1, top = 1, bottom = 1 } + }) + HealBot_Action:SetBackdropBorderColor( + HealBot_Config.borcolr[HealBot_Config.Current_Skin], + HealBot_Config.borcolg[HealBot_Config.Current_Skin], + HealBot_Config.borcolb[HealBot_Config.Current_Skin], + HealBot_Config.borcola[HealBot_Config.Current_Skin]); + else + HealBot_Action:SetBackdrop({ + bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", + edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", + tile = true, tileSize = 8, edgeSize = 16, + insets = { left = 4, right = 4, top = 4, bottom = 4 } + }) + HealBot_Action:SetBackdropBorderColor( + HealBot_Config.borcolr[HealBot_Config.Current_Skin], + HealBot_Config.borcolg[HealBot_Config.Current_Skin], + HealBot_Config.borcolb[HealBot_Config.Current_Skin], + HealBot_Config.borcola[HealBot_Config.Current_Skin]); + end +end + +function HealBot_Action_OnHide(this) + HealBot_StopMoving(this); + HealBot_Config.ActionVisible = 0 +end + +function HealBot_Action_OnMouseDown(this,button) + if button~="RightButton" then + if HealBot_Config.ActionLocked==0 then + HealBot_StartMoving(this); + end + end +end + +function HealBot_Action_OnMouseUp(this,button) + if button~="RightButton" then + HealBot_StopMoving(this); + elseif not HealBot_IsFighting then + HealBot_Action_OptionsButton_OnClick(); + end +end + +function HealBot_Action_OnClick(this,button) +-- HealBot_Action_AddDebug("OnClick("..button..")"); +end + +function HealBot_Action_OnDragStart(this,button) + if HealBot_Config.ActionLocked==0 then + HealBot_StartMoving(this); + end +end + +function HealBot_Action_OnDragStop(this) + HealBot_StopMoving(this); +end + +-- http://www.flexbarforums.com/viewtopic.php?t=66 +function HealBot_Action_OnKey(this,key,state) + local command = GetBindingAction(key); + if command then + DEFAULT_CHAT_FRAME:AddMessage(key.." "..state.." "..(command or "nil")); + keystate = state + RunBinding(command,keystate) + end + DEFAULT_CHAT_FRAME:AddMessage("HealBot_Action_OnKey - "..key); + if key=="SHIFT" or key=="CTRL" or key=="ALT" then + DEFAULT_CHAT_FRAME:AddMessage((IsShiftKeyDown() or 0).." "..(IsControlKeyDown() or 0).." "..(IsAltKeyDown() or 0)); + HealBot_Action_Refresh(); + end +end + + + +