diff --git a/DruidBar.lua b/DruidBar.lua index 931bf6a..18a2571 100644 --- a/DruidBar.lua +++ b/DruidBar.lua @@ -2,31 +2,22 @@ local aquaformid, travelformid; function DruidBar_OnLoad() - DruidBarUpdateFrame:RegisterEvent("PLAYER_ENTERING_WORLD"); - DruidBarUpdateFrame:RegisterEvent("PLAYER_LEAVING_WORLD"); - DruidBarUpdateFrame:RegisterEvent("UNIT_POWER_UPDATE"); + DruidBarUpdateFrame:RegisterEvent("UNIT_AURA"); DruidBarUpdateFrame:RegisterEvent("UNIT_MAXPOWER"); - DruidBarUpdateFrame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START"); - DruidBarUpdateFrame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP"); - DruidBarUpdateFrame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE"); - DruidBarUpdateFrame:RegisterEvent("UNIT_SPELLCAST_DELAYED"); - DruidBarUpdateFrame:RegisterEvent("UNIT_SPELLCAST_FAILED"); - DruidBarUpdateFrame:RegisterEvent("UNIT_SPELLCAST_FAILED_QUIET"); - DruidBarUpdateFrame:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED"); - DruidBarUpdateFrame:RegisterEvent("UNIT_SPELLCAST_START"); - DruidBarUpdateFrame:RegisterEvent("UNIT_SPELLCAST_STOP"); - DruidBarUpdateFrame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED"); + DruidBarUpdateFrame:RegisterEvent("COMBAT_LOG_EVENT"); DruidBarUpdateFrame:RegisterEvent("VARIABLES_LOADED"); + DruidBarUpdateFrame:RegisterEvent("UNIT_POWER_UPDATE"); + DruidBarUpdateFrame:RegisterEvent("INSTANCE_BOOT_STOP"); + DruidBarUpdateFrame:RegisterEvent("INSTANCE_BOOT_START"); + DruidBarUpdateFrame:RegisterEvent("UNIT_SPELLCAST_STOP"); + DruidBarUpdateFrame:RegisterEvent("PLAYER_LEAVING_WORLD"); + DruidBarUpdateFrame:RegisterEvent("PLAYER_ENTERING_WORLD"); DruidBarUpdateFrame:RegisterEvent("UNIT_INVENTORY_CHANGED"); - DruidBarUpdateFrame:RegisterEvent("UNIT_AURA"); DruidBarUpdateFrame:RegisterEvent("UPDATE_SHAPESHIFT_FORMS"); - DruidBarUpdateFrame:RegisterEvent("COMBAT_LOG_EVENT"); - DruidBarUpdateFrame:RegisterEvent("INSTANCE_BOOT_START"); - DruidBarUpdateFrame:RegisterEvent("INSTANCE_BOOT_STOP"); SlashCmdList["DRUIDBARSLASH"] = DruidBar_Enable_ChatCommandHandler; SLASH_DRUIDBARSLASH1 = "/dbar"; SLASH_DRUIDBARSLASH2 = "/druidbar"; - -- DBarSpellCatch:SetOwner(DruidBarFrame, "ANCHOR_NONE"); + DBarSpellCatch:SetOwner(DruidBarUpdateFrame, "ANCHOR_NONE"); end local className, inform, lowregentimer, fullmanatimer, lastshift, inCombat, firstEZ, pre_UseAction, shiftload, isMoving, waitonce, firstshift; @@ -83,7 +74,7 @@ function DruidBar_OnEvent(self, event,...) -- Player's power changed elseif event == "UNIT_POWER_UPDATE" and arg1 == "player" then if arg2 == "MANA" then - DruidBarKey.keepthemana = UnitPower("player"); + DruidBarKey.keepthemana = UnitPower("player", 0); elseif DruidBarKey.keepthemana < DruidBarKey.maxmana then -- Not sure whats going on in here yet local add = DruidBar_ReflectionCheck(); @@ -95,6 +86,7 @@ function DruidBar_OnEvent(self, event,...) -- Player gained or lost a form, buff, debuff, status, or item bonus elseif event == "UNIT_AURA" or event == "UPDATE_SHAPESHIFT_FORMS" then + if UnitPowerType("player") == 1 and not inform then --Bear inform = true; @@ -114,10 +106,10 @@ function DruidBar_OnEvent(self, event,...) end DruidBar_Message(); - elseif (event == "UNIT_SPELLCAST_CHANNEL_UPDATE" or - event == "UNIT_SPELLCAST_FAILED_QUIET" or - event == "UNIT_SPELLCAST_INTERRUPTED" or - event == "UNIT_SPELLCAST_SUCCEEDED") then + + -- Player stopped casting, for any reason. + elseif (event == "UNIT_SPELLCAST_STOP") then + -- Something for EZCast... I think it is supposed to auto drop form? if (not firstEZ) then if (DruidBarKey.EZShift) then pre_UseAction = UseAction; @@ -125,7 +117,9 @@ function DruidBar_OnEvent(self, event,...) end firstEZ = true; end + if UnitPowerType("player") == 0 then lowregentimer = 5; + waitonce = nil; end end elseif className and className == "DRUID" and not DruidBarKey.Enabled then @@ -295,7 +289,10 @@ end --Gets the mana cost of your shapeshifting spells. function DruidBar_GetShapeshiftCost() - if not DBarSpellCatch:IsOwned(DruidBarUpdateFrame) then DBarSpellCatch:SetOwner(DruidBarUpdateFrame, "ANCHOR_NONE"); end + if not DBarSpellCatch:IsOwned(DruidBarUpdateFrame) then + DBarSpellCatch:SetOwner(DruidBarUpdateFrame, "ANCHOR_NONE"); + end + DruidBarKey.subtractmana = 0; local a, b, c, d = GetSpellTabInfo(4); for i = 1, c+d, 1 do @@ -483,7 +480,7 @@ function DruidBar_MainGraphics() end dbarlen(); dbarhei(); - if DruidBarKey.XPBar then + if DruidBarKey.Player then DruidBarFrame:ClearAllPoints(); DruidBarFrame:SetPoint("TOPLEFT","PlayerFrame","TOPLEFT", 80, -63); PlayerFrame:SetFrameLevel("1"); @@ -825,8 +822,8 @@ function DruidBar_Enable_ChatCommandHandler(text) DruidBarKey.DontShiftBack = DruidBar_Toggle(DruidBarKey.DontShiftBack, "Prevent shifting to human using different forms is"); DRUIDBAR_FrameSet(); elseif msg[1] == "player" then - DruidBarKey.XPBar = DruidBar_Toggle(DruidBarKey.XPBar, "Showing the bar below the Player Frame is"); - if DruidBarKey.XPBar then DruidBarKey.xvar = 150; DruidBarKey.yvar = 18; else DruidBarKey.xvar = 160; DruidBarKey.yvar = 18; end + DruidBarKey.Player = DruidBar_Toggle(DruidBarKey.Player, "Showing the bar below the Player Frame is"); + if DruidBarKey.Player then DruidBarKey.xvar = 150; DruidBarKey.yvar = 18; else DruidBarKey.xvar = 160; DruidBarKey.yvar = 18; end DRUIDBAR_FrameSet(); elseif msg[1] == "text" then if not DruidBarKey.Text then DruidBarKey.Text = 0; DruidBar_Print("Original-Style text on!"); elseif DruidBarKey.Text == 0 then DruidBarKey.Text = 1; DruidBar_Print("New-Style text on!"); elseif DruidBarKey.Text == 1 then DruidBarKey.Text = nil; DruidBar_Print("Text removed."); end @@ -901,7 +898,7 @@ function DruidBar_Status() DruidBar_Print("Hiding when in caster is "..DruidBar_On(DruidBarKey.Hide)); DruidBar_Print("Hiding when mana is full is "..DruidBar_On(DruidBarKey.Full)); DruidBar_Print("Replacing the Player Frame's mana bar is "..DruidBar_On(DruidBarKey.Replace)); - DruidBar_Print("Showing under the Player Frame is "..DruidBar_On(DruidBarKey.XPBar)); + DruidBar_Print("Showing under the Player Frame is "..DruidBar_On(DruidBarKey.Player)); local str; if not DruidBarKey.Text then str = "|CFF888888Off|r"; elseif DruidBarKey.Text == 1 then str = "|CFFFFFFFFModern|r"; else str = "|CFF00FF00Classic|r"; end DruidBar_Print("The current style of text is "..str); @@ -919,10 +916,8 @@ function DruidBar_On(tog) end function DruidBar_MaxManaScript() - print("In DruidBar_MaxManaScript") - + -- TODO: not sure what int is in this case, RENAME local _, int = UnitStat("player", 4); - print("int = ", int) DruidBar_GetShapeshiftCost(); if UnitPowerType("player") == 0 then diff --git a/DruidBar.toc b/DruidBar.toc index ccd1804..9e0c4a5 100644 --- a/DruidBar.toc +++ b/DruidBar.toc @@ -1,6 +1,7 @@ ## Interface: 11200 -## Title: Druid Bar v3.4 +## Title: Druid Bar Classic v0.1 ## Notes: Shows mana in bear/cat form. -## Author: SkaDemon (GUI: DiabloHu) +## Current Author: Tek (port to WoW Classic Beta) +## Original Author: SkaDemon (GUI: DiabloHu) ## SavedVariables: DruidBarKey -DruidBar.xml \ No newline at end of file +DruidBar.xml diff --git a/DruidBar.xml b/DruidBar.xml index 8e98040..cbc36f9 100644 --- a/DruidBar.xml +++ b/DruidBar.xml @@ -90,7 +90,7 @@ <Frame name="DruidBarUpdateFrame"> <Scripts> <OnLoad>DruidBar_OnLoad();</OnLoad> - <OnEvent>DruidBar_OnEvent(self, event,...);</OnEvent> + <OnEvent>DruidBar_OnEvent(self, event, ...);</OnEvent> <OnUpdate function="DruidBar_OnUpdate" /> </Scripts> </Frame> diff --git a/GUI.lua b/GUI.lua index f5a4748..5b96eeb 100644 --- a/GUI.lua +++ b/GUI.lua @@ -70,13 +70,13 @@ end function DRUIDBAROptions_Replace() DruidBarKey.Replace = true; - DruidBarKey.XPBar = false; + DruidBarKey.Player = false; DruidBarKey.Lock = true; DRUIDBAR_FrameSet(); end function DRUIDBAROptions_Player() - DruidBarKey.XPBar = true; + DruidBarKey.Player = true; DruidBarKey.xvar = 150; DruidBarKey.yvar = 18; DruidBarKey.Replace = false; @@ -86,7 +86,8 @@ end function DRUIDBAROptions_Custom() DruidBarKey.Replace = false; - DruidBarKey.XPBar = false; + DruidBarKey.Player = false; + DruidBarKey.Lock = false; DruidBarKey.xvar = DruidBarKey.tempW; DruidBarKey.yvar = DruidBarKey.tempH; DRUIDBAR_FrameSet(); @@ -130,7 +131,10 @@ function DRUIDBAROptions_Text_Initialize() end function DRUIDBAROptions_Text_OnShow() + -- Construct dropdown UIDropDownMenu_Initialize(DRUIDBAROptionsTextDropDown, DRUIDBAROptions_Text_Initialize); + + -- Sets initial value if( DruidBarKey.Text == 0 ) then UIDropDownMenu_SetSelectedID(DRUIDBAROptionsTextDropDown, 1); elseif( DruidBarKey.Text == 1 ) then @@ -141,9 +145,10 @@ function DRUIDBAROptions_Text_OnShow() UIDropDownMenu_SetWidth(DRUIDBAROptionsTextDropDown, 100); end -function DRUIDBAROptions_Text_OnClick() +function DRUIDBAROptions_Text_OnClick(self) i = self:GetID(); UIDropDownMenu_SetSelectedID(DRUIDBAROptionsTextDropDown, i); + if(i == 1) then DruidBarKey.Text = 0; elseif(i == 2) then @@ -175,9 +180,10 @@ function DRUIDBAROptions_Percent_OnShow() UIDropDownMenu_SetWidth(DRUIDBAROptionsPercentDropDown, 112); end -function DRUIDBAROptions_Percent_OnClick() +function DRUIDBAROptions_Percent_OnClick(self) i = self:GetID(); UIDropDownMenu_SetSelectedID(DRUIDBAROptionsPercentDropDown, i); + if(i == 1) then DruidBarKey.Percent = 0; elseif(i == 2) then @@ -408,13 +414,16 @@ function DRUIDBAROptions_MessageOOM_OnClick() end function DRUIDBAR_FrameSet() + -- DruidBarKey is not set, get out if not DruidBarKey then return end + -- Check temp width and temp height if not DruidBarKey.tempW then DruidBarKey.tempW = 0; end if not DruidBarKey.tempH then DruidBarKey.tempH = 0; end + DRUIDBAROptionsToggle:SetChecked(DruidBarKey.Enabled); DRUIDBAROptionsVis:SetChecked(DruidBarKey.Graphics); DRUIDBAROptionsReplace:SetChecked(DruidBarKey.Replace); - DRUIDBAROptionsPlayer:SetChecked(DruidBarKey.XPBar); + DRUIDBAROptionsPlayer:SetChecked(DruidBarKey.Player); DRUIDBAROptionsLock:SetChecked(DruidBarKey.Lock); DRUIDBAROptionsHide:SetChecked(DruidBarKey.Hide); DRUIDBAROptionsFull:SetChecked(DruidBarKey.Full); @@ -438,7 +447,7 @@ function DRUIDBAR_FrameSet() DRUIDBAROptionsKMGText:SetText("|cff9d9d9d"..DRUIDBAR_OPTIONS_KMG.."|r"); end - if(DruidBarKey.XPBar == false and DruidBarKey.Replace == false) then + if(DruidBarKey.Player == false and DruidBarKey.Replace == false) then DRUIDBAROptionsCustom:SetChecked("true"); DRUIDBAROptionsWeightText:SetText(DRUIDBAR_OPTIONS_Weight); DRUIDBAROptionsHeightText:SetText(DRUIDBAR_OPTIONS_Height); @@ -538,7 +547,6 @@ function DRUIDBAROptions_GetBGColor(self) getglobal(self:GetName().."_SwatchBg"):SetVertexColor(DruidBarKey.bgcolor[1], DruidBarKey.bgcolor[2], DruidBarKey.bgcolor[3]); end - function DRUIDBAROptions_GetBorderColor(self) if not DruidBarKey then return end local info; @@ -560,8 +568,6 @@ function DRUIDBAROptions_GetBorderColor(self) getglobal(self:GetName().."_SwatchBg"):SetVertexColor(DruidBarKey.bordercolor[1], DruidBarKey.bordercolor[2], DruidBarKey.bordercolor[3]); end - - function DRUIDBAROptions_ManaBarFrameLevel_Initialize() local info; for i = 0, 3, 1 do diff --git a/GUI.xml b/GUI.xml index 9aea0b0..553587f 100644 --- a/GUI.xml +++ b/GUI.xml @@ -420,7 +420,7 @@ </Scripts> </CheckButton> - <Frame name="DRUIDBAROptionsTextDropDown" inherits="UIDropDownMenuTemplate" enableMouse="true"> + <Frame name="DRUIDBAROptionsTextDropDown" inherits="UIDropDownMenuTemplate"> <Anchors> <Anchor point="TOPLEFT"> <Offset> @@ -445,7 +445,7 @@ <Scripts> <OnShow> - DRUIDBAROptions_Text_OnShow(); + DRUIDBAROptions_Text_OnShow(self); </OnShow> </Scripts> </Frame> @@ -1158,17 +1158,10 @@ <Scripts> <OnLoad> DRUIDBAROptions_OnLoad(); + self:RegisterForDrag("LeftButton"); </OnLoad> - <OnMouseDown> - if (arg1 == 'LeftButton') then - self:StartMoving(); - end - </OnMouseDown> - <OnMouseUp> - if (arg1 == 'LeftButton') then - self:StopMovingOrSizing(); - end - </OnMouseUp> + <OnDragStart>self:StartMoving();</OnDragStart> + <OnDragStop>self:StopMovingOrSizing();</OnDragStop> </Scripts> </Frame> </Ui> diff --git a/localization.lua b/localization.lua index 911736e..eced2ab 100644 --- a/localization.lua +++ b/localization.lua @@ -57,12 +57,12 @@ DRUIDBAR_OPTIONS_DROP = { ["Text"] = { [0] = "Original"; [1] = "New"; - [2] = "No Text"; + [2] = "No Text"; }; ["Percent"] = { [0] = "Raw numbers"; [1] = "Percentages"; - [2] = "Both above"; + [2] = "Both above"; }; ["Message"] = { [0] = "SAY"; @@ -134,7 +134,7 @@ elseif GetLocale() == "zhTW" then DRUIDBAR_CAT_FORM = "獵豹形態"; DRUIDBAR_BEAR_FORM = "熊形態"; DRUIDBAR_MANA_DELIM = "法力"; - + DRUIDBAR_META = "變形符文"; DRUIDBAR_AQ1 = "安其拉"; DRUIDBAR_AQ2 = "安其拉之門"; @@ -144,7 +144,7 @@ elseif GetLocale() == "zhTW" then DRUIDBAR_FEL = "召喚地獄戰馬"; DRUIDBAR_GHOST = "幽魂之狼"; DRUIDBAR_WAR = "召喚戰馬"; - + DRUIDBAR_OPTIONS_TITLE = "Druid Bar設定"; DRUIDBAR_OPTIONS_Bar = "狀態條設定"; DRUIDBAR_OPTIONS_MessageO = "變形訊息設定"; @@ -173,12 +173,12 @@ elseif GetLocale() == "zhTW" then ["Text"] = { [0] = "原始樣式"; [1] = "新樣式"; - [2] = "不顯示文字"; + [2] = "不顯示文字"; }; ["Percent"] = { [0] = "數值"; [1] = "百分比"; - [2] = "數值/百分比"; + [2] = "數值/百分比"; }; ["Message"] = { [0] = "SAY"; @@ -194,7 +194,6 @@ elseif GetLocale() == "zhTW" then DRUIDBAR_OPTIONS_Shift = "由任何形態變回人型"; DRUIDBAR_OPTIONS_EZShift = "簡易變形"; DRUIDBAR_OPTIONS_Debug = "除錯模式"; - elseif GetLocale() == "zhCN" then DRUIDBAR_DRUIDCLASS = "德鲁伊"; DRUIDBAR_INNERVATE = "激活"; @@ -206,9 +205,9 @@ elseif GetLocale() == "zhCN" then DRUIDBAR_REGEN3 = "装备: 每5秒恢复(%d+)点法力值。" DRUIDBAR_REGEN4 = "每5秒恢复(%d+)点法力值。"; DRUIDBAR_CAT_FORM = "猎豹形态"; - + DRUIDBAR_BEAR_FORM = "熊形态"; - + DRUIDBAR_MANA_DELIM = "法力值"; DRUIDBAR_META = "变形符文"; DRUIDBAR_OPTIONS_TITLE = "Druid Bar 设置"; @@ -239,12 +238,12 @@ elseif GetLocale() == "zhCN" then ["Text"] = { [0] = "原样式"; [1] = "新样式"; - [2] = "无文本"; + [2] = "无文本"; }; ["Percent"] = { [0] = "具体数字"; [1] = "百分比"; - [2] = "显示两者"; + [2] = "显示两者"; }; ["Message"] = { [0] = "说";