Revision 32

This commit is contained in:
Robin 2021-01-13 15:27:24 +01:00
commit cf54258448
7 changed files with 330 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "Common"]
path = Common
url = https://git.grml.de/rilgamon/Common.git

1
Common Submodule

@ -0,0 +1 @@
Subproject commit 762c59c6c6abc6ecaa71f3e36bb2c6dd16b8e0ed

306
core.lua Normal file
View File

@ -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
GameTooltip:AddDoubleLine(k, addon:colorize("Mission done","00ff00"))
break
end
end
end
end
if(IsShiftKeyDown()) then
for k, v in pairs(db['missions']) do
if(v[GBM]) then
local found = 0
for a,b in pairs(v[GBM]) do
if(b>=ti) then
local r = b - ti
if(r<found or found==0) then
found = r
end
end
end
if(found>0) 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)

BIN
icon2.tga Normal file

Binary file not shown.

6
license.txt Normal file
View File

@ -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.

3
pack.xml Normal file
View File

@ -0,0 +1,3 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<Script file="core.lua"/>
</Ui>

11
zz_GarrisonToggle.toc Normal file
View File

@ -0,0 +1,11 @@
## Interface: 90002
## X-Curse-Project-ID: 84059
## X-Repository: https://svn.grml.de/zz_GarrisonToggle
## X-WoWI-ID: 23044
## Title: zz_GarrisonToggle
## Notes: Toggle GarrisonUI
## Author: Rilgamon
## SavedVariables: zz_GarrisonToggleDB
## OptionalDeps: Ace3, BrokerPack, zzLibCommon
Common\common.xml
pack.xml