A Murloc Raider
Join Date: Sep 2011
Posts: 5
|
The error aboult "ADDON_ACTION_BLOCKED"
While I falling down for Vehicle in combat ,it will call sevel errors like that.
Code:
"[ADDON_ACTION_BLOCKED] 插件 'AspectPosionBar' 尝试调用保护功能 'PossessButton1:Show()'。:\n<in C code>: in function `Show'\nInterface\\FrameXML\\BonusActionBarFrame.lua:501: in function `PossessBar_UpdateState':\nInterface\\FrameXML\\BonusActionBarFrame.lua:476: in function `PossessBar_Update':\nInterface\\FrameXML\\MainMenuBar.lua:127: in function `MainMenuBar_ToPlayerArt':\nInterface\\FrameXML\\MainMenuBar.lua:63: in function `MainMenuBar_UpdateArt':\nInterface\\FrameXML\\MainMenuBar.lua:50: in function `animPostFunc':\nInterface\\FrameXML\\AnimationSystem.lua:22: in function <Interface\\FrameXML\\AnimationSystem.lua:10>:\nInterface\\FrameXML\\AnimationSystem.lua:35: in function <Interface\\FrameXML\\AnimationSystem.lua:29>:\n\n ---"
But I dont know how to solve them.
This is the Addon.
Code:
------------------------------------------------------------------------------------------
AspectPosionBarFrame = LibStub("AceAddon-3.0"):NewAddon("AspectPosionBarFrame", "AceEvent-3.0", "AceHook-3.0");
local L = {};
local A = AspectPosionBarFrame;
A._DEBUG = false;
A.name = "AspectPosionBar";
A.class = select(2, UnitClass("player"));
A.enable = true;
local GetSpellName = GetSpellName or GetSpellBookItemName
if (GetLocale() == "zhCN") then
L["左键 - 上毒主手"] = "左键 - 主手上毒";
L["右键 - 上毒副手"] = "右键 - 副手上毒";
L["中键 - 上毒投掷"] = "中键 - 投掷上毒";
L["麻醉药膏"] = "麻醉药膏";
L["速效药膏"] = "速效药膏";
L["致伤药膏"] = "致伤药膏";
L["致命药膏"] = "致命药膏";
L["麻痹药膏"] = "麻痹药膏";
L["减速药膏"] = "减速药膏";
L["埃索达"] = "埃索达";
L["塞拉摩"] = "塞拉摩";
L["奥格瑞玛"] = "奥格瑞玛";
L["幽暗城"] = "幽暗城";
L["斯通纳德"] = "斯通纳德";
L["暴风城"] = "暴风城";
L["沙塔斯"] = "沙塔斯";
L["达拉然"] = "达拉然";
L["达纳苏斯"] = "达纳苏斯";
L["铁炉堡"] = "铁炉堡";
L["银月城"] = "银月城";
L["雷霆崖"] = "雷霆崖";
L["托尔巴拉德"] = "托尔巴拉德"
L["传送门: "] = "传送门:";
L["传送: "] = "传送:";
L["左键 - 传送: "] = "左键 - 传送: ";
L["右键 - 传送门: "] = "右键 - 传送门: ";
BINDING_HEADER_AspectPosionBar_TITLE = "守护/毒药/传送门条";
_G["BINDING_NAME_CLICK AspectPosionBarButton1:LeftButton"] = "快捷键1";
_G["BINDING_NAME_CLICK AspectPosionBarButton2:LeftButton"] = "快捷键2";
_G["BINDING_NAME_CLICK AspectPosionBarButton3:LeftButton"] = "快捷键3";
_G["BINDING_NAME_CLICK AspectPosionBarButton4:LeftButton"] = "快捷键4";
_G["BINDING_NAME_CLICK AspectPosionBarButton5:LeftButton"] = "快捷键5";
_G["BINDING_NAME_CLICK AspectPosionBarButton6:LeftButton"] = "快捷键6";
_G["BINDING_NAME_CLICK AspectPosionBarButton7:LeftButton"] = "快捷键7";
_G["BINDING_NAME_CLICK AspectPosionBarButton8:LeftButton"] = "快捷键8";
_G["BINDING_NAME_CLICK AspectPosionBarButton9:LeftButton"] = "快捷键9";
_G["BINDING_NAME_CLICK AspectPosionBarButton10:LeftButton"] = "快捷键10";
elseif (GetLocale() == "zhTW") then
L["左键 - 上毒主手"] = "左鍵 - 主手上毒";
L["右键 - 上毒副手"] = "右鍵 - 副手上毒";
L["中鍵 - 上毒投掷"] = "中键 - 投擲上毒";
L["麻醉药膏"] = "麻醉毒藥";
L["速效药膏"] = "速效毒藥";
L["致伤药膏"] = "致傷毒藥";
L["致命药膏"] = "致命毒藥";
L["麻痹药膏"] = "麻痹毒藥";
L["减速药膏"] = "致殘毒藥";
L["埃索达"] = "艾克索達";
L["塞拉摩"] = "塞拉摩";
L["奥格瑞玛"] = "奧格瑪";
L["幽暗城"] = "幽暗城";
L["斯通纳德"] = "斯通納德";
L["暴风城"] = "暴風城";
L["沙塔斯"] = "撒塔斯";
L["达拉然"] = "達拉然";
L["达纳苏斯"] = "達納蘇斯";
L["铁炉堡"] = "鐵爐堡";
L["银月城"] = "銀月城";
L["雷霆崖"] = "雷霆崖";
L["托尔巴拉德"] = "托巴拉德"
L["传送门: "] = "傳送門:";
L["传送: "] = "傳送:";
L["左键 - 传送: "] = "左鍵 - 傳送:";
L["右键 - 传送门: "] = "右鍵 - 傳送門:";
else
L["左键 - 上毒主手"] = "左键 - 主手上毒";
L["右键 - 上毒副手"] = "右键 - 副手上毒";
L["中键 - 上毒投掷"] = "中键 - 投掷上毒";
L["麻醉药膏"] = "Anesthetic Poison";
L["速效药膏"] = "Instant Poison";
L["致伤药膏"] = "Wound Poison";
L["致命药膏"] = "Deadly Poison";
L["麻痹药膏"] = "Mind-numbing Poison";
L["减速药膏"] = "Crippling Poison";
L["埃索达"] = "埃索达";
L["塞拉摩"] = "塞拉摩";
L["奥格瑞玛"] = "奥格瑞玛";
L["幽暗城"] = "幽暗城";
L["斯通纳德"] = "斯通纳德";
L["暴风城"] = "暴风城";
L["沙塔斯"] = "撒塔斯";
L["达拉然"] = "達拉然";
L["达纳苏斯"] = "达纳苏斯";
L["铁炉堡"] = "铁炉堡";
L["银月城"] = "银月城";
L["雷霆崖"] = "雷霆崖";
L["托尔巴拉德"] = "托尔巴拉德"
L["传送门: "] = "传送门:";
L["传送: "] = "传送:";
L["左键 - 传送: "] = "左键 - 传送: ";
L["右键 - 传送门: "] = "右键 - 传送门: ";
end
A.spellsDB = {
["HUNTER"] = {
[1] = 13165, -- 雄鹰守
[2] = 82661, --獵狐守護
[3] = 5118, -- 猎豹守护
[4] = 13159, -- 豹群守护
[5] = 20043, -- 野性守护
},
["ROGUE"] = {
[1] = 1784, -- 潜行
[2] = 51713, -- 暗影之舞
-- 毒药(itemID可能获取不到信息...)
[3] = {t = "p", name = L["麻醉药膏"]},
[4] = {t = "p", name = L["速效药膏"]},
[5] = {t = "p", name = L["致伤药膏"]},
[6] = {t = "p", name = L["致命药膏"]},
[7] = {t = "p", name = L["麻痹药膏"]},
[8] = {t = "p", name = L["减速药膏"]},
},
["MAGE"] = {
[1] = {t = "d", name = L["埃索达"]},
[2] = {t = "d", name = L["塞拉摩"]},
[3] = {t = "d", name = L["奥格瑞玛"]},
[4] = {t = "d", name = L["幽暗城"]},
[5] = {t = "d", name = L["斯通纳德"]},
[6] = {t = "d", name = L["暴风城"]},
[7] = {t = "d", name = L["沙塔斯"]},
[8] = {t = "d", name = L["达拉然"]},
[9] = {t = "d", name = L["达纳苏斯"]},
[10] = {t = "d", name = L["铁炉堡"]},
[11] = {t = "d", name = L["银月城"]},
[12] = {t = "d", name = L["雷霆崖"]},
[13] = {t = "d", name = L["托尔巴拉德"]},
},
["WARLOCK"] = {
[1] = 47241, -- 恶魔变形61610
[2] = 688, -- 召唤小鬼
[3] = 697, -- 召唤虚空行者
[4] = 712, -- 召唤魅魔
[5] = 691, -- 召唤地狱猎犬
[6] = 30146, -- 召唤恶魔卫士
[7] = 1122, -- 地狱火
[8] = 18540, -- 末日仪式
},
};
A.ROMAN = {" IX", " VIII", " VII", " V", " IV", " III", " II"," VI", ""};
A.order = {"spells", "teleport", "items"};
A.actions = {
spells = {};
teleport = {};
items = {};
};
A.tmp = {
spells = {};
teleport = {};
items = {};
};
A.buttons = {};
A.hooks = {};
A.hooked = false;
A.loaded = false;
function A:debug(fmt, ...)
if (self._DEBUG) then
print(format(fmt, ...));
end
end
local function SecureCall( ...)
local func = select(1, ...);
if (type(func) == "function") then
if (InCombatLockdown()) then
--dwPush(func, ...);
return;
end
pcall(...);
end
end
function AspectPosionButton_OnLoad(self)
self:SetNormalTexture("");
self:RegisterForClicks("AnyUp");
self.cooldown = _G[self:GetName() .. "Cooldown"];
self.icon = _G[self:GetName() .. "Icon"];
self.spellID = -1;
self.buttonType = "AspectPosionButtonTemplate"; --11
ActionButton_UpdateHotkeys(self, self.buttonType);--11
self:RegisterEvent("UPDATE_BINDINGS")--11
end
function AspectPosionButton_OnEvent(self,event,...)
if event=="UPDATE_BINDINGS" then
ActionButton_UpdateHotkeys(self, self.buttonType)
end
end
function AspectPosionButton_OnEnter(self)
if ( GetCVar("UberTooltips") == "1" ) then
GameTooltip_SetDefaultAnchor(GameTooltip, self);
else
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
end
local link, isItem;
if (self:GetAttribute("type") == "spell") then
if (self.teleportID) then
isteleport = true;
elseif (self.spellID) then
link = GetSpellLink(self.spellID);
end
elseif (self:GetAttribute("type") == "item" and self.itemID) then
-- _, link = GetItemInfo(self.itemID);
isItem = true;
end
if (link) then
GameTooltip:SetHyperlink(link);
else
GameTooltip:SetText(self.spellName);
if (isItem) then
GameTooltip:AddLine(L["左键 - 上毒主手"], 0.7, 0.7, 0.7);
GameTooltip:AddLine(L["右键 - 上毒副手"], 0.7, 0.7, 0.7);
GameTooltip:AddLine(L["中键 - 上毒投掷"], 0.7, 0.7, 0.7);
elseif (isteleport) then
GameTooltip:AddLine(L["左键 - 传送: "] .. self.spellName, 0.7, 0.7, 0.7);
GameTooltip:AddLine(L["右键 - 传送门: "] .. self.spellName, 0.7, 0.7, 0.7);
end
end
GameTooltip:Show();
end
function AspectPosionButton_PostClick(self)
if (self.isActive) then
self:SetChecked(1);
else
self:SetChecked(0);
end
end
function A:CreateButton(index)
if (index <= NUM_SHAPESHIFT_SLOTS) then
local button = _G["AspectPosionBarButton" .. index];
return button;
end
return false;
end
function A:CheckSpell(spellID)
if sepllID=="传送 :托尔巴拉德" then
sepllID = 88344
end
--[[ local i = 1;
local spell = GetSpellInfo(spellID);
local spellName = GetSpellName(i, BOOKTYPE_SPELL);
while (spellName) do
if (spellName == spell) then
--print(spellName)
return true;
end
i = i + 1;
spellName = GetSpellName(i, BOOKTYPE_SPELL);
end ]]
local spelllink=GetSpellLink(spellID)
spellID=spelllink and string.match(spelllink,"spell:(%d*)")
return spellID and IsSpellKnown(spellID);
end
function A:CheckItem(itemName)
local id, name;
if (itemName) then
for _, i in ipairs(self.ROMAN) do
name = format("%s%s", itemName, i);
local count = GetItemCount(name);
if (count and count > 0) then
return true, name;
end
end
end
return false;
end
function A:hasNewSpell()
if (#(self.actions) ~= #(self.tmp) or #(self.actions.spells) ~= #(self.tmp.spells) or #(self.actions.teleport) ~= #(self.tmp.teleport) or #(self.actions.items) ~= #(self.tmp.items)) then
return true;
end
return false;
end
function A:CloneTable(t)
assert(t and type(t) == "table", "CloneTable #! param must be a table value");
local tmp = {};
for k, v in pairs(t) do
if (type(v) == "table") then
tmp[k] = self:CloneTable(v);
else
tmp[k] = v;
end
end
return tmp;
end
function A:UpdateAspect()
self.tmp.spells = {};
self.tmp.teleport = {};
self.tmp.items = {};
if (self.spellsDB[ self.class]) then
for i, spellID in ipairs(self.spellsDB[self.class]) do
if (type(spellID) == "table") then
if (spellID.t and spellID.t == "p") then -- 毒药
local hasItem, name = self:CheckItem(spellID.name)
if (hasItem) then
tinsert(self.tmp.items, name);
end
elseif (spellID.t and spellID.t == "d") then -- 传送门
local check1, check2 = self:CheckSpell(L["传送门: "] .. spellID.name), self:CheckSpell(L["传送: "] .. spellID.name);
if (check1 or check2) then
tinsert(self.tmp.teleport, spellID.name);
end
end
else
if (self:CheckSpell(spellID)) then
tinsert(self.tmp.spells, spellID);
end
end
end
end
if (self:hasNewSpell()) then
self.actions = self:CloneTable(self.tmp);
return true;
end
return false;
end
function A:CreateBar()
for i = 1, NUM_SHAPESHIFT_SLOTS do
A.buttons[i] = self:CreateButton(i);
end
end
function A:GetNumShapeshiftForms()
local num = #(self.actions.spells) + #(self.actions.items) + #(self.actions.teleport);
num = (num > 0 and num) or GetNumShapeshiftForms() or 0;
if (num > NUM_SHAPESHIFT_SLOTS) then
num = NUM_SHAPESHIFT_SLOTS; -- 猜测有错误
end
return tonumber(num);
end
function A:IsBuffActive(name)
local i = 1;
local buffName = UnitBuff("player", i);
while (buffName) do
if (buffName == name) then
return i;
end
i = i +1;
buffName = UnitBuff("player", i);
end
return false;
end
function A:GetShapeshiftFormInfo(buttonId)
local isActive, isCastable, name, _, texture, type;
local sn = #(self.actions.spells)
local tn = #(self.actions.teleport);
if (self.actions["spells"][buttonId]) then
name, _, texture = GetSpellInfo(self.actions.spells[buttonId]);
isActive = self:IsBuffActive(name);
isCastable = true;
type = "spell";
elseif (self.actions["teleport"][buttonId - sn]) then
_, _, texture = GetSpellInfo(L["传送: "] .. self.actions.teleport[buttonId - sn])
texture = texture or select(3,GetSpellInfo(L["传送门: "] .. self.actions.teleport[buttonId - sn])) --11
name = self.actions.teleport[buttonId - sn];
isActive = false;
isCastable = true;
type = "teleport";
elseif (self.actions["items"][buttonId - sn - tn]) then
name, _, _, _, _, _, _, _, _, texture = GetItemInfo(self.actions.items[buttonId - sn - tn]);
isActive = false;
isCastable = true;
type = "item";
end
if (not texture) then
texture, name, isActive, isCastable = GetShapeshiftFormInfo(buttonId);
end
--self:debug("texture: %s name: %s", texture, name);
return texture, name or "", isActive, isCastable, type;
end
function A:GetShapeshiftForm(var)
local texture, name, isActive, isCastable;
for i=1, NUM_SHAPESHIFT_SLOTS, 1 do
texture, name, isActive, isCastable = self:GetShapeshiftFormInfo(i);
if (isActive) then
return i;
end
end
end
function A:GetShapeshiftFormCooldown(buttonId)
local sn = #(self.actions.spells);
local tn = #(self.actions.teleport);
if (self.actions.spells and self.actions.spells[buttonId]) then
local name = GetSpellInfo(self.actions.spells[buttonId]);
return GetSpellCooldown(name);
--[[ elseif (self.actions.teleport and self.actions.teleport[buttonId - sn]) then
local name = GetSpellInfo(self.actions.teleport[buttonId - sn]);
return GetItemCooldown(name);
elseif (self.actions.items and self.actions.items[buttonId - sn - tn]) then
return GetItemCooldown(self.actions.items[buttonId - sn - tn]); ]]
end
return GetShapeshiftFormCooldown(buttonId);
end
function A:UpdateAspectCooldown()
local numForms = self:GetNumShapeshiftForms();
local start, duration, enable, cooldown, button;
for i=1, numForms do
button = self.buttons[i];
cooldown = _G[button:GetName() .. "Cooldown"];
start, duration, enable = self:GetShapeshiftFormCooldown(i);
if (cooldown and start and duration) then
CooldownFrame_SetTimer(cooldown, start, duration, enable);
end
end
end
function A:AspectBarUpdate()
if not InCombatLockdown() then--for blocked
local numForms = self:GetNumShapeshiftForms();
if (numForms > 0) then
if ( numForms == 1 ) then
AspectPosionBarMiddle:Hide();
AspectPosionBarRight:SetPoint("LEFT", "AspectPosionBarLeft", "LEFT", 12, 0);
SecureCall(AspectPosionBarButton1.ClearAllPoints, AspectPosionBarButton1);
SecureCall(AspectPosionBarButton1.SetPoint, AspectPosionBarButton1, "BOTTOMLEFT", "AspectPosionBar", "BOTTOMLEFT", 12, 3);
elseif ( numForms == 2 ) then
AspectPosionBarMiddle:Hide();
AspectPosionBarRight:SetPoint("LEFT", "AspectPosionBarLeft", "RIGHT", 0, 0);
else
AspectPosionBarMiddle:Show();
AspectPosionBarMiddle:SetPoint("LEFT", "AspectPosionBarLeft", "RIGHT", 0, 0);
AspectPosionBarMiddle:SetWidth(37 * (numForms-2));
AspectPosionBarMiddle:SetTexCoord(0, numForms-2, 0, 1);
AspectPosionBarRight:SetPoint("LEFT", "AspectPosionBarMiddle", "RIGHT", 0, 0);
end
SecureCall(AspectPosionBar.Show, AspectPosionBar);
else
SecureCall(AspectPosionBar.Hide, AspectPosionBar);
end
end
self:AspectBarUpdateState();
end
function A:AspectBarUpdateState()
local numForms = self:GetNumShapeshiftForms();
self:debug("number forms %d", numForms);
local texture, name, isActive, isCastable, type;
local button, icon, cooldown, ssb;
local start, duration, enable;
local sn = #(self.actions.spells);
local tn = #(self.actions.teleport);
for i=1, NUM_SHAPESHIFT_SLOTS do
button =self.buttons[i];
if ( i <= numForms ) then
texture, name, isActive, isCastable, type = self:GetShapeshiftFormInfo(i);
button.icon:SetTexture(texture);
if ( texture ) then
button.cooldown:Show();
else
button.cooldown:Hide();
end
self:UpdateAspectCooldown();
if ( isActive ) then
button:SetChecked(1);
button.isActive = true;
else
button:SetChecked(0);
button.isActive = false;
end
if ( isCastable ) then
button.icon:SetVertexColor(1.0, 1.0, 1.0);
else
button.icon:SetVertexColor(0.4, 0.4, 0.4);
end
if (type == "spell") then
SecureCall(button.SetAttribute, button, "type", "spell");
SecureCall(button.SetAttribute, button, "spell", name);
button.spellID = self.actions.spells[i];
elseif (type == "teleport") then
SecureCall(button.SetAttribute, button, "type", "spell");
SecureCall(button.SetAttribute, button, "spell1", name~=L["托尔巴拉德"] and L["传送: "] .. name or 88344);--11
SecureCall(button.SetAttribute, button, "spell2", L["传送门: "] .. name);
button.teleportID = true;
elseif (type == "item") then
SecureCall(button.SetAttribute, button, "type", "item");
SecureCall(button.SetAttribute, button, "item", name);
SecureCall(button.SetAttribute, button, "target-slot1", "16");
SecureCall(button.SetAttribute, button, "target-slot2", "17");
SecureCall(button.SetAttribute, button, "target-slot3", "18");--11
button.itemID = self.actions.items[i - sn - tn];
end
button.spellName = name;
SecureCall(button.Show, button);
else
SecureCall(button.Hide, button);
end
end
self:UpdateItemCount();
SecureCall(UIParent_ManageFramePositions);
end
function A:UpdateItemCount()
local button, count, label;
for i=1, NUM_SHAPESHIFT_SLOTS do
button =self.buttons[i];
if (button:IsShown() and button:GetAttribute("type") == "item") then
count = GetItemCount(button:GetAttribute("item"));
label = _G[button:GetName() .. "Count"];
label:SetText(count);
if (count > 9) then
label:SetTextColor(0.0, 1.0, 0.0)
elseif (count > 4) then
label:SetTextColor(1.0, 1.0, 0.0)
elseif (count > 0) then
label:SetTextColor(1.0, 0.0, 0.0)
end
elseif _G[button:GetName() .. "Count"] then--11
_G[button:GetName() .. "Count"]:SetText("")
end
end
end
function A:UNIT_AURA(event, unit)
if (unit == "player") then
self:AspectBarUpdate();
end
end
function A:LEARNED_SPELL_IN_TAB()
if (self:UpdateAspect()) then
self:AspectBarUpdate();
--RePositionPetActionBar();
end
end
function A:ACTIONBAR_UPDATE_USABLE()
self:AspectBarUpdate();
end
function A:ACTIONBAR_UPDATE_COOLDOWN()
self:UpdateAspectCooldown();
end
function A:UPDATE_BINDINGS(self,actionButtonType)
local numForms = A:GetNumShapeshiftForms();
--ClearOverrideBindings(ShapeshiftBarFrame);
for i = 1, numForms do
local buttonName = "AspectPosionBarButton" .. i;
local key1, key2 = GetBindingKey("SHAPESHIFTBUTTON"..i);
if (key1) then
--SetOverrideBindingClick(AspectPosionBar, true, key1, buttonName);
end
if (key2) then
--SetOverrideBindingClick(AspectPosionBar, true, key2, buttonName);
end
end
end
function A:SPELLS_CHANGED()
if (self:UpdateAspect()) then
self:AspectBarUpdate();
--RePositionPetActionBar();
end
self:UnregisterEvent("SPELLS_CHANGED");
end
function A:BAG_UPDATE()
if (self:UpdateAspect()) then
self:AspectBarUpdate();
--RePositionPetActionBar();
else
self:UpdateItemCount();
end
end
function A:PLAYER_ENTERING_WORLD()
self:AspectBarUpdate();
if not ChatFrame1:IsUserPlaced() then--11
ChatFrame1:SetPoint("BOTTOMLEFT",UIParent, "BOTTOMLEFT" ,32 ,155)
ChatFrame1:SetUserPlaced(true)
end
end
function A:UIParent_ManageFramePositions()
if (not self.enable) then return end
local hasBottomLeft;
if ( MultiBarBottomLeft:IsShown() ) then
hasBottomLeft = 1;
end
local YOffset = hasBottomLeft and 45 or 0;
if ( ReputationWatchBar:IsShown() and MainMenuExpBar:IsShown() ) then
YOffset = YOffset + 8;
end
if ( MainMenuBarMaxLevelBar:IsShown() ) then
YOffset = YOffset -5;
end
if ( hasBottomLeft ) then
if ( AspectPosionBar ) then
AspectPosionBarLeft:SetAlpha(0);
AspectPosionBarRight:SetAlpha(0);
AspectPosionBarMiddle:SetAlpha(0);
end
else
if ( AspectPosionBar ) then
if ( self:GetNumShapeshiftForms() > 2 ) then
AspectPosionBarMiddle:SetAlpha(1);
end
AspectPosionBarLeft:SetAlpha(1);
AspectPosionBarRight:SetAlpha(1);
end
end
self:debug("UIParent_ManageFramePositions YOffset %d", YOffset);
--SecureCall(AspectPosionBar.ClearAllPoints, AspectPosionBar);--11
--SecureCall(AspectPosionBar.SetPoint, AspectPosionBar, "BOTTOMLEFT", "MainMenuBar", "TOPLEFT", 80, YOffset);
end
-----------------------------------------
-- OnX
-----------------------------------------
function A:OnModuleEnable()
self:RegisterEvent("UNIT_AURA");
self:RegisterEvent("SPELLS_CHANGED");
self:RegisterEvent("LEARNED_SPELL_IN_TAB");
self:RegisterEvent("ACTIONBAR_UPDATE_USABLE");
self:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN");
self:RegisterEvent("UPDATE_BINDINGS");
self:RegisterEvent("BAG_UPDATE");
self:RegisterEvent("PLAYER_ENTERING_WORLD");
SecureCall(ShapeshiftBarFrame.Hide, ShapeshiftBarFrame);
ShapeshiftBarFrame.orgShow = ShapeshiftBarFrame.Show;
ShapeshiftBarFrame.Show = DUMMY_FUNC;
ShapeshiftBarFrame.orgHide = ShapeshiftBarFrame.Hide;
ShapeshiftBarFrame.Hide = DUMMY_FUNC;
self:SecureHook("UIParent_ManageFramePositions");
SecureCall(AspectPosionBar.ClearAllPoints, AspectPosionBar);
AspectPosionBarDB = AspectPosionBarDB or {}--11
if AspectPosionBarDB.a then
SecureCall(AspectPosionBar.SetPoint, AspectPosionBar, AspectPosionBarDB.a, "UIParent", AspectPosionBarDB.a, AspectPosionBarDB.x, AspectPosionBarDB.y);
elseif IsAddOnLoaded("LUI") then--11
SecureCall(AspectPosionBar.SetPoint, AspectPosionBar, "BOTTOMLEFT", "ChatFrame1Tab", "TOPLEFT", 50, 5);
else
SecureCall(AspectPosionBar.SetPoint, AspectPosionBar, "BOTTOMLEFT", "MainMenuBar", "TOPLEFT", 80, 45);
end
self:AspectBarUpdate();
end
function DUMMY_FUNC() end
function A:OnModuleDisable()
self:UnregisterAllEvents();
self:AspectBarUpdate();
self:Unhook("UIParent_ManageFramePositions");
ShapeshiftBarFrame.Show = ShapeshiftBarFrame.orgShow;
ShapeshiftBarFrame.orgShow = nil;
ShapeshiftBarFrame.Hide = ShapeshiftBarFrame.orgHide;
ShapeshiftBarFrame.orgHide = nil;
SecureCall(AspectPosionBar.Hide, AspectPosionBar);
ShapeshiftBar_Update();
end
function A:ToggleManageFrame(switch)
if (switch) then
self.enable = true;
else
self.enable = false;
end
end
function A:OnInitialize()
if (not self.loaded) then
self.loaded = true;
self:UpdateAspect();
self:CreateBar();
end
end
function AspectPosionBar_OnLoad(self)
self:SetClampedToScreen()
end
function AspectPosionBar_OnEvent(self, event, arg1)
end
function AspectPosionBar_OnShow(self)
SecureCall(UIParent_ManageFramePositions);
end
function AspectPosionBar_OnHide(self)
SecureCall(UIParent_ManageFramePositions);
end
--[[function PetActionBarFrameRePosition_Toggle(switch)
PetActionBarFrame:ClearAllPoints()
if (switch) then
PetActionBarFrame:SetPoint(poa,pob,poc,pod+350,poe)
else
PetActionBarFrame:SetPoint(poa,pob,poc,pod,poe)
end
end]]
local petpo=PetActionBarFrame.SetPoint
function PetActionBarFrame.SetPoint(...)
if InCombatLockdown() then--for blocked
return
end
local poa,pob,poc,pod,poe,pof=...
if AspectPosionBar:IsShown() and not GetSpellLink("恶魔变形") and not A.class=="HUNTER" then--11
poe=poe+350
end
petpo(poa,pob,poc,pod,poe,pof)
end
function AspectPosionBar_Toggle(switch)
if (switch) then
A:OnModuleEnable();
else
A:OnModuleDisable();
end
--PetActionBarFrameRePosition_Toggle(switch);
end
function AspectPosionBar_Jieguan(switch)
local apb, ssb, la;
for i=1, NUM_SHAPESHIFT_SLOTS do
apb = _G["AspectPosionBarButton" .. i];
ssb = _G["ShapeshiftButton" .. i];
SecureCall(apb.ClearAllPoints, apb);
if (switch) then
SecureCall(apb.SetPoint, apb, "CENTER", ssb, "CENTER", 0, 0);
else
if (i == 1) then
SecureCall(apb.SetPoint, apb, "BOTTOMLEFT", AspectPosionBar, "BOTTOMLEFT", 10, 3);
else
SecureCall(apb.SetPoint, apb, "LEFT", la, "RIGHT", 8, 0);
end
la = apb;
end
end
if (switch) then
AspectPosionBarFrame:ToggleManageFrame(false);
else
AspectPosionBarFrame:ToggleManageFrame(true);
end
SecureCall(UIParent_ManageFramePositions);
end
function AspectPosionBar_ShowKeyBindingFrame(key) --11
if ( key == nil ) then
KeyBindingFrame_LoadUI();
ShowUIPanel(KeyBindingFrame);
return;
end
local bindings = GetNumBindings();
for i = 1, bindings, 1 do
local value = GetBinding(i);
if ( value == key ) then
KeyBindingFrame_LoadUI();
ShowUIPanel(KeyBindingFrame);
KeyBindingFrameScrollFrameScrollBar:SetValue((i-1)*KEY_BINDING_HEIGHT);
end
end
end
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="svn://113.106.98.20/repos/Duowan-Work/UI.xsd">
<Script file="AspectPosionBar.lua"/>
<CheckButton name="AspectPosionButtonTemplate" enableMouse="true" inherits="SecureActionButtonTemplate, ActionButtonTemplate" virtual="true">
<Size>
<AbsDimension x="30" y="30"/>
</Size>
<Scripts>
<OnLoad>
AspectPosionButton_OnLoad(self);
</OnLoad>
<OnEnter>
AspectPosionButton_OnEnter(self);
</OnEnter>
<OnEvent>
AspectPosionButton_OnEvent(self,event,...);
</OnEvent>
<PostClick>
AspectPosionButton_PostClick(self);
</PostClick>
<OnLeave function="GameTooltip_Hide"/>
</Scripts>
</CheckButton>
<Frame name="AspectPosionBar" movable="true" parent="UIParent" enableMouse="true" hidden="false">
<Size>
<AbsDimension x="29" y="32"/>
</Size>
<Anchors>
<Anchor point="BOTTOMLEFT" relativeTo="MainMenuBar" relativePoint="TOPLEFT">
<Offset>
<AbsDimension x="30" y="0"/>
</Offset>
</Anchor>
</Anchors>
<Layers>
<Layer level="BACKGROUND">
<Texture name="$parentLeft" file="Interface\ShapeshiftBar\ShapeshiftBar">
<Size x="47" y="38"/>
<Anchors>
<Anchor point="BOTTOMLEFT"/>
</Anchors>
<TexCoords left="0" right="0.734375" top="0" bottom="0.296875"/>
</Texture>
<Texture name="$parentMiddle" file="Interface\ShapeshiftBar\ShapeshiftBarMiddle">
<Size x="37" y="38"/>
<Anchors>
<Anchor point="LEFT" relativeTo="ShapeshiftBarLeft" relativePoint="RIGHT"/>
</Anchors>
<TexCoords left="0" right="2" top="0" bottom="1"/>
</Texture>
</Layer>
<Layer level="BORDER">
<Texture name="$parentRight" file="Interface\ShapeshiftBar\ShapeshiftBar">
<Size x="43" y="38"/>
<Anchors>
<Anchor point="LEFT" relativeTo="ShapeshiftBarMiddle" relativePoint="RIGHT"/>
</Anchors>
<TexCoords left="0.328125" right="1" top="0.3125" bottom="0.6015625"/>
</Texture>
</Layer>
</Layers>
<Frames>
<Button name="$parentTab" frameStrata="HIGH" hidden="false" alpha="0.4">
<Size>
<AbsDimension x="16" y="50"/>
</Size>
<Layers>
<Layer level="BACKGROUND">
<Texture name="$parentTexture" file="Interface\Addons\AspectPosionBar\MOGUBarTab">
<Size>
<AbsDimension x="16" y="50"/>
</Size>
</Texture>
</Layer>
</Layers>
<Anchors>
<Anchor point="LEFT">
<Offset>
<AbsDimension x="-5" y="2"/>
</Offset>
</Anchor>
</Anchors>
<Scripts>
<!-- <OnMouseDown>
if (not self.isMoving) then
self:GetParent():StartMoving();
self.isMoving = true;
end
</OnMouseDown>
<OnMouseUp>
if (self.ismoving) then
self.ismoving = false;
self:GetParent():StopMovingOrSizing();
AspectPosionBar_Jieguan(true);
end
</OnMouseUp> -->
<OnEnter>
GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT")
GameTooltip:ClearLines()
GameTooltip:AddLine("点击拖动位置")
GameTooltip:Show()
</OnEnter>
<OnLeave>
GameTooltip:Hide()
</OnLeave>
<OnMouseDown>
self:GetParent():StartMoving()
</OnMouseDown>
<OnMouseUp>
self:GetParent():StopMovingOrSizing()
AspectPosionBarDB.a, _, AspectPosionBarDB.a, AspectPosionBarDB.x, AspectPosionBarDB.y=self:GetParent():GetPoint()
</OnMouseUp>
</Scripts>
<HighlightTexture file="Interface\Addons\MoguBar\MOGUBarTabHighlight" alphaMode="ADD"/>
</Button>
<CheckButton name="$parentButton1" inherits="AspectPosionButtonTemplate" id="1">
<Anchors>
<Anchor point="BOTTOMLEFT">
<Offset>
<AbsDimension x="10" y="3"/>
</Offset>
</Anchor>
</Anchors>
</CheckButton>
<CheckButton name="$parentButton2" inherits="AspectPosionButtonTemplate" id="2">
<Anchors>
<Anchor point="LEFT" relativeTo="$parentButton1" relativePoint="RIGHT">
<Offset>
<AbsDimension x="8" y="0"/>
</Offset>
</Anchor>
</Anchors>
</CheckButton>
<CheckButton name="$parentButton3" inherits="AspectPosionButtonTemplate" id="3">
<Anchors>
<Anchor point="LEFT" relativeTo="$parentButton2" relativePoint="RIGHT">
<Offset>
<AbsDimension x="7" y="0"/>
</Offset>
</Anchor>
</Anchors>
</CheckButton>
<CheckButton name="$parentButton4" inherits="AspectPosionButtonTemplate" id="4">
<Anchors>
<Anchor point="LEFT" relativeTo="$parentButton3" relativePoint="RIGHT">
<Offset>
<AbsDimension x="7" y="0"/>
</Offset>
</Anchor>
</Anchors>
</CheckButton>
<CheckButton name="$parentButton5" inherits="AspectPosionButtonTemplate" id="5">
<Anchors>
<Anchor point="LEFT" relativeTo="$parentButton4" relativePoint="RIGHT">
<Offset>
<AbsDimension x="7" y="0"/>
</Offset>
</Anchor>
</Anchors>
</CheckButton>
<CheckButton name="$parentButton6" inherits="AspectPosionButtonTemplate" id="6">
<Anchors>
<Anchor point="LEFT" relativeTo="$parentButton5" relativePoint="RIGHT">
<Offset>
<AbsDimension x="7" y="0"/>
</Offset>
</Anchor>
</Anchors>
</CheckButton>
<CheckButton name="$parentButton7" inherits="AspectPosionButtonTemplate" id="7">
<Anchors>
<Anchor point="LEFT" relativeTo="$parentButton6" relativePoint="RIGHT">
<Offset>
<AbsDimension x="7" y="0"/>
</Offset>
</Anchor>
</Anchors>
</CheckButton>
<CheckButton name="$parentButton8" inherits="AspectPosionButtonTemplate" id="8">
<Anchors>
<Anchor point="LEFT" relativeTo="$parentButton7" relativePoint="RIGHT">
<Offset>
<AbsDimension x="7" y="0"/>
</Offset>
</Anchor>
</Anchors>
</CheckButton>
<CheckButton name="$parentButton9" inherits="AspectPosionButtonTemplate" id="9">
<Anchors>
<Anchor point="LEFT" relativeTo="$parentButton8" relativePoint="RIGHT">
<Offset>
<AbsDimension x="7" y="0"/>
</Offset>
</Anchor>
</Anchors>
</CheckButton>
<CheckButton name="$parentButton10" inherits="AspectPosionButtonTemplate" id="10">
<Anchors>
<Anchor point="LEFT" relativeTo="$parentButton9" relativePoint="RIGHT">
<Offset>
<AbsDimension x="7" y="0"/>
</Offset>
</Anchor>
</Anchors>
</CheckButton>
</Frames>
<Scripts>
<OnLoad>
AspectPosionBar_OnLoad(self);
</OnLoad>
<OnEvent>
AspectPosionBar_OnEvent(self, event, arg1);
</OnEvent>
<OnShow>
AspectPosionBar_OnShow(self);
</OnShow>
<OnHide>
AspectPosionBar_OnHide(self);
</OnHide>
</Scripts>
</Frame>
</Ui>
It's sorry that the addon olny can be use in zhCN or zhTW local ,and my English is very poor.
Last edited by cakhuang2 : 09-06-11 at 07:57 PM.
|