Mercurial > wow > askmrrobot
diff Gear.lua @ 81:0515882856f1 v38
updated for 7.0
author | yellowfive |
---|---|
date | Tue, 19 Jul 2016 10:05:32 -0700 |
parents | 304d7ebb8e30 |
children | af2474d28bb4 |
line wrap: on
line diff
--- a/Gear.lua Tue Apr 05 16:19:31 2016 -0700 +++ b/Gear.lua Tue Jul 19 10:05:32 2016 -0700 @@ -14,7 +14,7 @@ return 1000 end - -- different upgrade levels of the same item (only for older gear, player has control over upgrade level) + -- different upgrade levels of the same item if item1.upgradeId ~= item2.upgradeId then return 100 end @@ -138,7 +138,7 @@ icon:SetHeight(48) local iconSpec - if player.SubSpecs[spec] then + if player.SubSpecs and player.SubSpecs[spec] then iconSpec = player.SubSpecs[spec] else iconSpec = player.Specs[spec] @@ -149,7 +149,7 @@ panelGear:AddChild(icon) local btnEquip = AceGUI:Create("AmrUiButton") - btnEquip:SetText(L.GearButtonEquip(spec)) + btnEquip:SetText(L.GearButtonEquip(L.SpecsShort[player.Specs[spec]])) btnEquip:SetBackgroundColor(Amr.Colors.Green) btnEquip:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.White)) btnEquip:SetWidth(300) @@ -161,17 +161,6 @@ end) panelGear:AddChild(btnEquip) - --[[local btnShop = AceGUI:Create("AmrUiButton") - btnShop:SetText(L.GearButtonShop) - btnShop:SetBackgroundColor(Amr.Colors.Blue) - btnShop:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.White)) - btnShop:SetWidth(300) - btnShop:SetHeight(26) - btnShop:SetPoint("LEFT", btnEquip.frame, "RIGHT", 75, 0) - btnShop:SetPoint("RIGHT", panelMods.content, "RIGHT", -20, 0) - btnShop:SetCallback("OnClick", function(widget) Amr:ShowShopWindow() end) - panelMods:AddChild(btnShop)]] - -- each physical item can only be used once, this tracks ones we have already used local usedItems = {} @@ -371,30 +360,25 @@ lbl2:SetPoint("TOP", lbl.frame, "BOTTOM", 10, -5) container:AddChild(lbl2) - --[[ - local btnClean = AceGUI:Create("AmrUiButton") - btnClean:SetText(L.GearButtonCleanText) - btnClean:SetBackgroundColor(Amr.Colors.Orange) - btnClean:SetFont(Amr.CreateFont("Bold", 16, Amr.Colors.White)) - btnClean:SetWidth(120) - btnClean:SetHeight(26) - btnClean:SetPoint("BOTTOMLEFT", container.content, "BOTTOMLEFT", 0, 5) - btnClean:SetCallback("OnClick", function(widget) Amr:CleanBags() end) - container:AddChild(btnClean) - ]] - local t = AceGUI:Create("AmrUiTabGroup") t:SetLayout("None") - t:SetTabs({ - {text=L.GearTabPrimary, value="1", style="bold"}, - {text=L.GearTabSecondary, value="2", style="bold"} - }) + + local tabz = {} + for pos = 1, 4 do + local specId = GetSpecializationInfo(pos) + if specId then + table.insert(tabz, { text = L.SpecsShort[Amr.SpecIds[specId]], value = pos .. "", style = "bold" }) + end + end + + t:SetTabs(tabz) t:SetCallback("OnGroupSelected", onGearTabSelected) t:SetPoint("TOPLEFT", container.content, "TOPLEFT", 144, -30) t:SetPoint("BOTTOMRIGHT", container.content, "BOTTOMRIGHT") container:AddChild(t) _gearTabs = t; + --[[ local btnShop = AceGUI:Create("AmrUiButton") btnShop:SetText(L.GearButtonShop) btnShop:SetBackgroundColor(Amr.Colors.Blue) @@ -404,10 +388,10 @@ btnShop:SetPoint("TOPRIGHT", container.content, "TOPRIGHT", -20, -25) btnShop:SetCallback("OnClick", function(widget) Amr:ShowShopWindow() end) container:AddChild(btnShop) - + ]] if not _activeTab then - _activeTab = tostring(GetActiveSpecGroup()) + _activeTab = tostring(GetSpecialization()) end t:SelectTab(_activeTab) @@ -707,8 +691,9 @@ end local function onActiveTalentGroupChanged() + local auto = Amr.db.profile.options.autoGear - local currentSpec = GetActiveSpecGroup() + local currentSpec = GetSpecialization() if currentSpec == _waitingForSpec or auto then -- spec is what we want, now equip the gear @@ -718,21 +703,19 @@ _waitingForSpec = 0 end --- activate the specified spec and then equip the saved gear set for either primary (1) or secondary (2) spec +-- activate the specified spec and then equip the saved gear set function Amr:EquipGearSet(spec) - -- if no argument, then toggle spec + -- if no argument, then cycle spec if not spec then - spec = GetActiveSpecGroup() == 1 and 2 or 1 + spec = GetSpecialization() + 1 end - + -- allow some flexibility in the arguments - if spec == "primary" or spec == "Primary" then spec = 1 end - if spec == "secondary" or spec == "Secondary" then spec = 2 end - if spec == "1" or spec == "2" then spec = tonumber(spec) end - - -- only spec 1 or 2 are valid - if spec ~= 1 and spec ~= 2 then return end + if spec == "1" or spec == "2" or spec == "3" or spec == "4" then spec = tonumber(spec) end + + local specId = GetSpecializationInfo(spec) + if not specId then spec = 1 end if UnitAffectingCombat("player") then Amr:Print(L.GearEquipErrorCombat) @@ -741,9 +724,9 @@ _waitingForSpec = spec - local currentSpec = GetActiveSpecGroup() + local currentSpec = GetSpecialization() if currentSpec ~= spec then - SetActiveSpecGroup(spec) + SetSpecialization(spec) else onActiveTalentGroupChanged() end @@ -754,9 +737,17 @@ -- TODO: implement end +--[[ +local function testfunc(message) + print(strsub(message, 13)) +end +]] + function Amr:InitializeGear() - Amr:AddEventHandler("ACTIVE_TALENT_GROUP_CHANGED", onActiveTalentGroupChanged) + Amr:AddEventHandler("PLAYER_SPECIALIZATION_CHANGED", onActiveTalentGroupChanged) + --Amr:AddEventHandler("CHAT_MSG_CHANNEL", testfunc) + Amr:AddEventHandler("UNIT_INVENTORY_CHANGED", function(unitID) if unitID and unitID ~= "player" then return end Amr:RefreshGearTab()