From cf54258448a42fd06d281bc1346e469098ca1099 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 13 Jan 2021 15:27:24 +0100 Subject: [PATCH] Revision 32 --- .gitmodules | 3 + Common | 1 + core.lua | 306 ++++++++++++++++++++++++++++++++++++++++++ icon2.tga | Bin 0 -> 2848 bytes license.txt | 6 + pack.xml | 3 + zz_GarrisonToggle.toc | 11 ++ 7 files changed, 330 insertions(+) create mode 100644 .gitmodules create mode 160000 Common create mode 100644 core.lua create mode 100644 icon2.tga create mode 100644 license.txt create mode 100644 pack.xml create mode 100644 zz_GarrisonToggle.toc diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..34950ac --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "Common"] + path = Common + url = https://git.grml.de/rilgamon/Common.git diff --git a/Common b/Common new file mode 160000 index 0000000..762c59c --- /dev/null +++ b/Common @@ -0,0 +1 @@ +Subproject commit 762c59c6c6abc6ecaa71f3e36bb2c6dd16b8e0ed diff --git a/core.lua b/core.lua new file mode 100644 index 0000000..6d80ffe --- /dev/null +++ b/core.lua @@ -0,0 +1,306 @@ +local name, addon = ... +local parentName = addon['parentName'] or "BrokerPack" +local childName = "zz_GarrisonToggle" +local realm = GetRealmName() +local player = UnitName('player').."-"..realm +local defaults = { + ['garrisonText'] = 'GS', + ['garrisonHideCombat'] = false, + ['hideStandard'] = true, +} + +local options = { +} + +local db +local GBM = Enum.GarrisonFollowerType.FollowerType_8_0 +local function OnText(message) + addon:OnText(childName, message) +end +local function switchDisplay(value) + if(value) then + AlertFrame:UnregisterEvent("GARRISON_MISSION_FINISHED") + AlertFrame:UnregisterEvent("GARRISON_BUILDING_ACTIVATABLE") + else + AlertFrame:RegisterEvent("GARRISON_MISSION_FINISHED") + AlertFrame:RegisterEvent("GARRISON_BUILDING_ACTIVATABLE") + end +end +local function getPref(pref) + return db[pref[#pref]] +end + +local function setPref(pref,value) + if(pref[#pref] == "garrisonText" and value=="") then + value = nil + elseif(pref[#pref] == "garrisonHideCombat") then + switchDisplay(value) + end + db[pref[#pref]] = value + OnText(db['garrisonText'] or GARRISON_LOCATION_TOOLTIP) +end + +local gtypes = {} +local function ResetGBM() + for k,v in pairs(gtypes) do + local l = C_Garrison.GetGarrisonInfo(v) + if(l and l>0) then + GBM = k + db['GBM'] = GBM + GarrisonLandingPage.garrTypeID = gtypes[GBM] + break + end + end +end +local function findTypes() + for k, v in pairs(Enum.GarrisonType) do + local l = C_Garrison.GetGarrisonInfo(v) + if(l and tonumber(l)>0) then + local _, ver, subver = strsplit('_', k) + local followerType = Enum.GarrisonFollowerType[format('FollowerType_%i_%i',ver, subver)] + if(followerType) then + db['missions'][player][followerType] = db['missions'][player][followerType] or {} + gtypes[followerType] = v + end + end + end + if(not gtypes[GBM]) then + ResetGBM() + end +end +local function bclick(swap) + if(GarrisonLandingPage) then + if(GarrisonLandingPage:IsShown()) then + GarrisonLandingPage_Toggle() + if(not swap) then + return + end + end + GarrisonLandingPage.garrTypeID = gtypes[GBM] + if(not GarrisonLandingPage.garrTypeID) then + ResetGBM() + findTypes() + if(not GarrisonLandingPage.garrTypeID) then +-- print("still no garrType") + GarrisonLandingPage_Toggle() + return + end + end + if (C_Garrison.GetGarrisonInfo(GarrisonLandingPage.garrTypeID)) then + ShowGarrisonLandingPage(gtypes[GBM]) + GarrisonLandingPageReportList_OnShow(GarrisonLandingPage) + C_Garrison.RequestLandingPageShipmentInfo() + if ( not GarrisonLandingPageReport.selectedTab ) then + GarrisonLandingPageReport.unselectedTab = GarrisonLandingPageReport.InProgress + GarrisonLandingPageReport.selectedTab = GarrisonLandingPageReport.Available + GarrisonLandingPageReport_SetTab(GarrisonLandingPageReport.unselectedTab) + else + GarrisonLandingPageReportList_UpdateItems() + end + else + ResetGBM() + end + end +end +local function OnButton(self,button) + local level = C_Garrison.GetGarrisonInfo(C_Garrison.GetLandingPageGarrisonType()) + if(tonumber(level) and tonumber(level)<1) then + ResetGBM() + end + if(button=="LeftButton") then + if(IsShiftKeyDown()) then + findTypes() + local k = 0 + local picknext = nil + for a,b in pairs(gtypes) do + local level = C_Garrison.GetGarrisonInfo(b) + if(level and level > 0) then + if(picknext) then + k = a + break + end + if(GBM == a) then + picknext = true + end + + end + end + if(k==0) then + ResetGBM() + else + GBM = k + db['GBM'] = GBM + end + bclick(true) + else + bclick() + end + elseif(button=="RightButton") then + if(InterfaceOptionsFrame:IsVisible() and not InCombatLockdown()) then + InterfaceOptionsFrame:Hide() + else + InterfaceOptionsFrame_OpenToCategory(childName) + InterfaceOptionsFrame_OpenToCategory(childName) -- Call it twice because auf WoW-Bug + end + end +end + +local function IsInProgress(mid) + for k,v in pairs(C_Garrison.GetInProgressMissions(GBM) or {}) do + if(tonumber(v['missionID'])==tonumber(mid)) then + return true + end + end + return false +end + +local function GetMission(missionID) + for k,v in pairs(C_Garrison.GetInProgressMissions(GBM) or {}) do + if(missionID==v['missionID']) then + return v + end + end +end +local function AddDB(missionID) + local missionInfo = GetMission(missionID) + if(missionInfo) then + local mt = {C_Garrison.GetMissionTimes(missionID)} + db['missions'][player][GBM][missionID] = time() + mt[5] + end +end +local function CheckDB(missionID) + local missionInfo = GetMission(missionID) + if(missionInfo and db['missions'][player][GBM]) then + local old = db['missions'][player][GBM][missionID] + local mt = {C_Garrison.GetMissionTimes(missionID)} + db['missions'][player][GBM][missionID] = db['missions'][player][GBM][missionID] or (time() + mt[5]) + if(db['missions'][player][GBM][missionID] ~= old) then +-- print("RESET",missionInfo['name']) + end + end +end +local function prune() + if(C_Garrison.GetInProgressMissions and GBM) then + local temp = C_Garrison.GetInProgressMissions(GBM) + if(temp) then + db['missions'][player][GBM] = {} + local ti = time() + for k, v in pairs(temp) do + if(v['missionEndTime']) then + db['missions'][player][GBM][v['missionID']] = v['missionEndTime'] + else + local mt = {C_Garrison.GetMissionTimes(v['missionID'])} + db['missions'][player][GBM][v['missionID']] = ti + mt[5] + end + end + end + end +end +local function tooltipsort(a, b) + return (db['missions'][player][GBM][a['missionID']] or 0) < (db['missions'][player][GBM][b['missionID']] or 0) +end +local function OnTooltipShow(GameTooltip) + GameTooltip:AddLine(childName) + local num = C_Garrison.GetNumFollowers(GBM) + if(GBM and db['missions'][player][GBM]) then + local temp = C_Garrison.GetInProgressMissions(GBM) + local ti = time() + if(temp) then + db['missions'][player][GBM] = {} + for k, v in pairs(temp) do + db['missions'][player][GBM][v['missionID']] = v['missionEndTime'] + end + sort(temp,tooltipsort) + for k,v in pairs(temp) do + -- CheckDB(tonumber(v['missionID'])) + GameTooltip:AddDoubleLine(v['name'],db['missions'][player][GBM][tonumber(v['missionID'])]>ti and v['timeLeft'] or addon:colorize("Done","00ff00")) + num = num - v['numFollowers'] + end + end + for k, v in pairs(db['missions']) do + if(k ~= player and v[GBM]) then + for a,b in pairs(v[GBM]) do + if(b=ti) then + local r = b - ti + if(r0) then + GameTooltip:AddDoubleLine(k, addon:colorize(format("Next %.1f Min",found / 60 ),"ffff00")) + end + end + end + end + local nr = C_Garrison.GetInProgressMissions(GBM) + local nr2 = C_Garrison.GetAvailableMissions(GBM) + if(num>0) then + GameTooltip:AddDoubleLine(addon:colorize("Follower:","ffffff"),num.."/"..C_Garrison.GetNumFollowers(GBM)) + end + if(nr and nr2) then + GameTooltip:AddDoubleLine(addon:colorize("Missions:","ffffff"),#nr.."/"..#nr2) + end + else + GameTooltip:AddLine("No garrison found!") + end + GameTooltip:AddLine(addon:colorize("SHIFT LEFTCLICK toggles Garrison","00ff00")) + GameTooltip:AddLine(addon:colorize("Press SHIFT for other characters info","00ff00")) +end +local function event(self,event,missionID,...) + if(event == "GARRISON_MISSION_COMPLETE_RESPONSE") then + local canComplete, succeeded = ... + if(canComplete) then +-- db['missions'][player][GBM][missionID] = nil + end + elseif(event == "GARRISON_MISSION_STARTED") then + AddDB(missionID) + elseif(event == "ADDON_LOADED") then + if(missionID == 'Blizzard_GarrisonUI') then + findTypes() + self:UnregisterEvent(event) + end + return + end + prune() +end +local function init() + db = addon['db']['profile'][childName] + db['missions'] = db['missions'] or {} + db['missions'][player] = db['missions'][player] or {} + options = addon:InitConfig(childName, true, { + ['type'] = "launcher", + ['OnClick'] = OnButton, + ['text'] = db['garrisonText'] or GARRISON_LOCATION_TOOLTIP, + ['OnTooltipShow'] = OnTooltipShow, + ['icon'] = "Interface\\Icons\\Achievement_Arena_2v2_6", + }, getPref, setPref) + addon:AddConfigEntry(childName,'toggle','garrisonHideCombat',"Hide Alert","Hide mission complete alert",1,nil,nil,nil,nil) + addon:AddConfigEntry(childName,'toggle','hideStandard',"Hide Blizzard","Hide Blizzards default garrison button",1,nil,nil,nil,nil) + addon:AddConfigEntry(childName,'input','garrisonText',"Display Text","",1,nil,nil,nil,nil) + addon:RegisterFunc({"ADDON_LOADED","GARRISON_MISSION_STARTED","GARRISON_MISSION_FINISHED","GARRISON_MISSION_COMPLETE_RESPONSE","PLAYER_LOGOUT"},"OnEvent", event) + db['GBM'] = db['GBM'] or Enum.GarrisonFollowerType.FollowerType_8_0 + GBM = db['GBM'] + if(not IsAddOnLoaded("Blizzard_GarrisonUI")) then + UIParentLoadAddOn("Blizzard_GarrisonUI") + end + if(db['hideStandard']) then + GarrisonLandingPageMinimapButton:UnregisterAllEvents() + GarrisonLandingPageMinimapButton:Hide() + end + + switchDisplay(db['garrisonHideCombat']) +end +addon:startup(name, childName, init, true, defaults) \ No newline at end of file diff --git a/icon2.tga b/icon2.tga new file mode 100644 index 0000000000000000000000000000000000000000..f675e12e0d0804417cc12c597a266809fb754edf GIT binary patch literal 2848 zcmY*b2Ut{R7X1e_f>=PnRTRQv%Nq2Mn;E|UKj;4Eo_pV8Y%=@brOD_|?q2}d zB*tV^n4HQAHe-PiQ(0ufloy(?X`0)ZjQmnsKaF4YPj0C^)6zH5{qIQ!GZ`>9IHeEw!t4DH6ejiZy33x-F2|Yk$HxSwd z_;vy|RU?@7lS>5?$Z7MtoVcx18JjRk^O#rC+g6~IwxqYy)(^CmeuuOGeocUTBj7^+ zH_vFp1iizNl&}K7dkjKn*ID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UJc17+=n(qcN&R{Hnk{}l@DCW7?1foS3@*@+ zvq-L{%=7SlU>Xz*FJv$#JB3H(ADl`|T~}}CgS=MmnaN#!Bo3Jbwe&li!nUa&4m4Ek zBa?8exD9sAWXt@IG$zH^A5{RgR0F^_|B}{4FIv&G`7Sl`K#Hmx6j`7ij=k6yR4ifd) zzZS!{s0Uu<1GrH_FD#-Sn7*jPx5BjkS>~>pg0HrmXR?!(`Q2l0rLvP`nCfD6ws7mKADH~ig;d6g{AwyFf0^vwW3boo2g98^mhAt|aJ#`$ F_Fw4mm%so3 literal 0 HcmV?d00001 diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..6d2e364 --- /dev/null +++ b/license.txt @@ -0,0 +1,6 @@ +The following license excludes the libraries (Libs) included. See the libraries directory or website. + +This AddOn is public domain. That means you can change it, rename it or paint it yellow. +My name (Rilgamon) is valid only for WoWInterface.com and curse.com. +If you use/offer this addon on another website please remove my name. +If you want to give me credit you can replace it with a link to my profile on WoWInterface.com. \ No newline at end of file diff --git a/pack.xml b/pack.xml new file mode 100644 index 0000000..0f7eacc --- /dev/null +++ b/pack.xml @@ -0,0 +1,3 @@ + +