diff --git a/.pkgmeta b/.pkgmeta index cbb84aa..5dd6b2b 100755 --- a/.pkgmeta +++ b/.pkgmeta @@ -10,6 +10,31 @@ externals: url: svn://svn.wowace.com/wow/ace3/mainline/trunk tag: latest + GarrisonCommander-Broker/libs/Ace3/AceAddon-3.0: + url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceAddon-3.0 + tag: latest + GarrisonCommander-Broker/libs/Ace3/AceDB-3.0: + url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceDB-3.0 + tag: latest + GarrisonCommander-Broker/libs/Ace3/AceEvent-3.0: + url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceEvent-3.0 + tag: latest + GarrisonCommander-Broker/libs/Ace3/AceHook-3.0: + url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceHook-3.0 + tag: latest + GarrisonCommander-Broker/libs/Ace3/AceLocale-3.0: + url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceLocale-3.0 + tag: latest + GarrisonCommander-Broker/libs/Ace3/CallbackHandler-1.0: + url: svn://svn.wowace.com/wow/ace3/mainline/trunk/CallbackHandler-1.0 + tag: latest + GarrisonCommander-Broker/libs/Ace3/LibStub: + url: svn://svn.wowace.com/wow/ace3/mainline/trunk/LibStub + tag: latest + +move-folders: + GarrisonCommander/GarrisonCommander-Broker: GarrisonCommander-Broker + manual-changelog: filename: CHANGELOG.txt markup-type: textile diff --git a/GarrisonCommander-Broker/GarrisonCommander-Broker.toc b/GarrisonCommander-Broker/GarrisonCommander-Broker.toc new file mode 100644 index 0000000..17069f4 --- /dev/null +++ b/GarrisonCommander-Broker/GarrisonCommander-Broker.toc @@ -0,0 +1,27 @@ +## Interface: 60000 +## Title: Alar:GarrisonCommander-Broker +## Notes: Data-Broker for GarrisonCommander +## Notes-itIT: Data-Broker per GarrisonCommander +## Notes-frFR: Data-Broker pour GarrisonCommander +## Author: Alar of Daggerspine +## Version: @project-version@ @project-abbreviated-hash@ +## X-Version: 2.3.0-Beta2 +## X-Revision: @project-abbreviated-hash@ +## eMail: alar@aspide.it +## URL: http://wow.aspide.it +## OptionalDeps: Titan, Bazooka, ChocolateBar , FuBar +## DefaultState: Enabled +## LoadOnDemand: 1 +## LoadWith: Titan,Bazooka,ChocolateBar,FuBar +## SavedVariables: dbGACB +## X-ID: GACB +## X-Database:dbGACB +## X-Category: Garrison +## X-License: GPL v3 +## X-eMail: alar@aspide.it +## X-Date: @project-date-iso@ +## X-Embeds: +embeds.xml +localization.lua +ldb.lua + diff --git a/GarrisonCommander-Broker/embeds.xml b/GarrisonCommander-Broker/embeds.xml new file mode 100644 index 0000000..84f891c --- /dev/null +++ b/GarrisonCommander-Broker/embeds.xml @@ -0,0 +1,10 @@ +<Ui xmlns="http://www.blizzard.com/wow/ui/"> + <Script file="libs\Ace3\LibStub\LibStub.lua"/> + <Include file="libs\Ace3\CallbackHandler-1.0\CallbackHandler-1.0.xml"/> + <Include file="libs\Ace3\AceAddon-3.0\AceAddon-3.0.xml"/> + <Include file="libs\Ace3\AceHook-3.0\AceHook-3.0.xml"/> + <Include file="libs\Ace3\AceEvent-3.0\AceEvent-3.0.xml"/> + <Include file="libs\Ace3\AceTimer-3.0\AceTimer-3.0.xml"/> + <Include file="libs\Ace3\AceLocale-3.0\AceLocale-3.0.xml"/> + <Include file="libs\Ace3\AceDB-3.0\AceDB-3.0.xml"/> +</Ui> diff --git a/GarrisonCommander-Broker/ldb.lua b/GarrisonCommander-Broker/ldb.lua new file mode 100644 index 0000000..964440d --- /dev/null +++ b/GarrisonCommander-Broker/ldb.lua @@ -0,0 +1,97 @@ +local me, ns = ... +if (not LibStub:GetLibrary("LibDataBroker-1.1",true)) then + --@debug@ + print("Missing libdatabroker") + --@end-debug@ + return +end +if (LibDebug) then LibDebug() end +local L=LibStub("AceLocale-3.0"):GetLocale(me,true) +local addon=LibStub("AceAddon-3.0"):NewAddon(me,"AceTimer-3.0","AceEvent-3.0") +local dataobj +local G=C_Garrison +function addon:ldbCleanup() + local now=time() + for i=1,#self.db.realm.missions do + local s=self.db.realm.missions[i] + if (type(s)=='string') then + local t,ID,pc=strsplit('.',s) + t=tonumber(t) or 0 + if pc==ns.me and t < now then + tremove(self.db.realm.missions,i) + i=i-1 + end + end + end +end +function addon:ldbUpdate() + local now=time() + for i=1,#self.db.realm.missions do + local t,missionID,pc=strsplit('.',self.db.realm.missions[i]) + t=tonumber(t) or 0 + if t>now then + local duration=t-now + local duration=duration < 60 and duration or math.floor(duration/60)*60 + dataobj.text=format("Next mission on |cff20ff20%s|r in %s",pc,SecondsToTime(duration)) + return + end + end + dataobj.text=NONE +end +function addon:GARRISON_MISSION_STARTED(event,missionID) + local duration=select(2,G.GetPartyMissionInfo(missionID)) or 0 + local k=format("%015d.%4d.%s",time() + duration,missionID,ns.me) + tinsert(self.db.realm.missions,k) + table.sort(self.db.realm.missions) + self:ldbUpdate() +end +function addon:OnInitialize() + ns.me=GetUnitName("player",false) + self:RegisterEvent("GARRISON_MISSION_STARTED") + self:RegisterEvent("GARRISON_MISSION_NPC_OPENED","ldbCleanup") + self:ScheduleRepeatingTimer("ldbUpdate",1) + self.db=LibStub("AceDB-3.0"):New("dbGACB",{realm={missions={}}}) +end +dataobj=LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject(me, { + type = "data source", + label = "GarrisonCommander", + text=NONE, + icon = "Interface\\ICONS\\ACHIEVEMENT_GUILDPERK_WORKINGOVERTIME" +}) +function dataobj:OnTooltipShow() + self:AddLine("Mission awaiting") + local db=addon.db.realm.missions + local now=time() + for i=1,#db do + if db[i] then + local t,missionID,pc=strsplit('.',db[i]) + t=tonumber(t) or 0 + local name=C_Garrison.GetMissionName(missionID) + if (name) then + if t > now then + self:AddDoubleLine(format("|cffff9900%s|r: %s",pc,name),SecondsToTime(t-now),nil,nil,nil,0,1,0) + else + self:AddDoubleLine(format("|cffff9900%s|r: %s",pc,name),DONE,nil,nil,nil,1,0,0) + end + end + end + end +end + +function dataobj:OnEnter() + GameTooltip:SetOwner(self, "ANCHOR_NONE") + GameTooltip:SetPoint("TOPLEFT", self, "BOTTOMLEFT") + GameTooltip:ClearLines() + dataobj.OnTooltipShow(GameTooltip) + + GameTooltip:Show() +end + +function dataobj:OnLeave() + GameTooltip:Hide() +end +--@debug@ +_G.GACDB=addon +--@end-debug@ +--function dataobj:OnClick(button) +--end diff --git a/GarrisonCommander-Broker/localization.lua b/GarrisonCommander-Broker/localization.lua new file mode 100644 index 0000000..ee2a2bf --- /dev/null +++ b/GarrisonCommander-Broker/localization.lua @@ -0,0 +1,55 @@ +local me,ns=... +local lang=GetLocale() +local l=LibStub("AceLocale-3.0") +local L=l:NewLocale(me,"enUS",true,true) +--@localization(locale="enUS", format="lua_additive_table" , escape-non-ascii=true, same-key-is-true=true, handle-unlocalized="blank" )@ +L=l:NewLocale(me,"ptBR") +if (L) then +--@localization(locale="ptBR", format="lua_additive_table" , escape-non-ascii=true, same-key-is-true=true, handle-unlocalized="blank" )@ +return +end +L=l:NewLocale(me,"frFR") +if (L) then +--@localization(locale="frFR", format="lua_additive_table" , escape-non-ascii=true, same-key-is-true=true, handle-unlocalized="blank" )@ +return +end +L=l:NewLocale(me,"deDE") +if (L) then +--@localization(locale="deDE", format="lua_additive_table" , escape-non-ascii=true, same-key-is-true=true, handle-unlocalized="blank" )@ +return +end +L=l:NewLocale(me,"itIT") +if (L) then +--@localization(locale="itIT", format="lua_additive_table" , escape-non-ascii=true, same-key-is-true=true, handle-unlocalized="blank" )@ +return +end +L=l:NewLocale(me,"koKR") +if (L) then +--@localization(locale="koKR", format="lua_additive_table" , escape-non-ascii=true, same-key-is-true=true, handle-unlocalized="blank" )@ +return +end +L=l:NewLocale(me,"esMX") +if (L) then +--@localization(locale="esMX", format="lua_additive_table" , escape-non-ascii=true, same-key-is-true=true, handle-unlocalized="blank" )@ +return +end +L=l:NewLocale(me,"ruRU") +if (L) then +--@localization(locale="ruRU", format="lua_additive_table" , escape-non-ascii=true, same-key-is-true=true, handle-unlocalized="blank" )@ +return +end +L=l:NewLocale(me,"zhCN") +if (L) then +--@localization(locale="zhCN", format="lua_additive_table" , escape-non-ascii=true, same-key-is-true=true, handle-unlocalized="blank" )@ +return +end +L=l:NewLocale(me,"esES") +if (L) then +--@localization(locale="esES", format="lua_additive_table" , escape-non-ascii=true, same-key-is-true=true, handle-unlocalized="blank" )@ +return +end +L=l:NewLocale(me,"zhTW") +if (L) then +--@localization(locale="zhTW", format="lua_additive_table" , escape-non-ascii=true, same-key-is-true=true, handle-unlocalized="blank" )@ +return +end diff --git a/GarrisonCommander.lua b/GarrisonCommander.lua index 340add7..8c59f4d 100644 --- a/GarrisonCommander.lua +++ b/GarrisonCommander.lua @@ -625,10 +625,6 @@ function addon:OnInitialized() self:AddToggle("DBG",false, "Enable Debug") self:AddToggle("TRC",false, "Enable Trace") --@end-debug@ - if self.ldbUpdate then - self:ldbUpdate() - self:ScheduleRepeatingTimer("ldbUpdate",5) - end self:Trigger("MSORT") return true end @@ -1355,6 +1351,7 @@ function addon:BuildMissionsCache(fc,mm,OnEvent) xprint("Start Full Cache Rebuild") --@end-debug@ local t=new() + holdEvents() G.GetAvailableMissions(t) for index=1,#t do local missionID=t[index].missionID @@ -1374,6 +1371,7 @@ function addon:BuildMissionsCache(fc,mm,OnEvent) dbcache.seen[k]=nil end end + releaseEvents() del(t) collectgarbage("step",10) --@debug@ @@ -1549,10 +1547,8 @@ function addon:BuildMissionCache(id,data) end function addon:SetDbDefaults(default) default.global=default.global or {} - default.global["*"]={ - } + default.global["*"]={} default.global.lifespan={["*"]=0} - default.realm={missions={}} end function addon:CreatePrivateDb() self.privatedb=self:RegisterDatabase( @@ -1672,10 +1668,6 @@ function addon:EventGARRISON_MISSION_STARTED(event,missionID,...) -- }, dbcache.running[missionID].started=time() dbcache.running[missionID].duration=select(2,G.GetPartyMissionInfo(missionID)) - local k=format("%015d.%4d.%s",dbcache.running[missionID].started + dbcache.running[missionID].duration,missionID,ns.me) - tinsert(self.db.realm.missions,k) - table.sort(self.db.realm.missions) - if self.ldbUpdate then self:ldbUpdate() end wipe(dbcache.running[missionID].followers) wipe(dbcache.ignored[missionID]) for i=1,3 do @@ -1708,7 +1700,6 @@ end -- function addon:EventGARRISON_MISSION_FINISHED(event,missionID,...) - self:ldbCleanup() --@debug@ xprint(event,missionID,...) xdump(G.GetPartyMissionInfo(missionID)) @@ -2100,7 +2091,7 @@ function addon:GenerateMissionCompleteList(title) l:SetText(text) end l:SetImage(icon) - l:SetImageSize(16,16) + l:SetImageSize(24,24) l:SetFullWidth(true) obj:AddChild(l) return l @@ -3166,7 +3157,6 @@ function addon:StartUp(...) self:RefreshFollowerStatus() self:Trigger("MSORT") self:Trigger("CKMP") - self:ldbCleanup() end function addon:MarkAsNew(obj,key,message) if (not db.news[key]) then @@ -3433,7 +3423,7 @@ function addon:FillMissionPage(missionInfo) local followerID=members[i] if (followerID) then local status=G.GetFollowerStatus(followerID) - if (status) then + if (false and status) then if status == GARRISON_FOLLOWER_IN_PARTY then -- Left from a previous assignment? --@debug@ xprint(followerID,self:GetFollowerData(followerID,"name"),"was already on mission") @@ -4245,15 +4235,15 @@ function addon:GMC_OnClick_Start(this,button) xprint(C("-------------------------------------------------","Yellow")) this:Disable() GMC.ml.widget:ClearChildren() - addon:GMCCreateMissionList(aMissions) - wipe(GMCUsedFollowers) - wipe(GMC.ml.Parties) - self:RefreshFollowerStatus() if (self:GetTotFollowers(AVAILABLE) == 0) then self:Popup("All followers are busy",10) this:Enable() return end + addon:GMCCreateMissionList(aMissions) + wipe(GMCUsedFollowers) + wipe(GMC.ml.Parties) + self:RefreshFollowerStatus() if (#aMissions>0) then GMC.ml.widget:SetFormattedTitle(L["Processing mission %d of %d"],1,#aMissions) else @@ -4706,15 +4696,18 @@ do end function addon:MissionEvents(start) self:UnregisterEvent("GARRISON_MISSION_BONUS_ROLL_COMPLETE") + self:UnregisterEvent("GARRISON_MISSION_BONUS_ROLL_LOOT") self:UnregisterEvent("GARRISON_MISSION_COMPLETE_RESPONSE") self:UnregisterEvent("GARRISON_FOLLOWER_XP_CHANGED") self:UnregisterEvent("GET_ITEM_INFO_RECEIVED") if start then + self:RegisterEvent("GARRISON_MISSION_BONUS_ROLL_LOOT","MissionAutoComplete") self:RegisterEvent("GARRISON_MISSION_BONUS_ROLL_COMPLETE","MissionAutoComplete") self:RegisterEvent("GARRISON_MISSION_COMPLETE_RESPONSE","MissionAutoComplete") self:RegisterEvent("GARRISON_FOLLOWER_XP_CHANGED","MissionAutoComplete") self:RegisterEvent("GET_ITEM_INFO_RECEIVED","MissionAutoComplete") else + self:SafeRegisterEvent("GARRISON_MISSION_BONUS_ROLL_LOOT") self:SafeRegisterEvent("GARRISON_MISSION_BONUS_ROLL_COMPLETE") self:SafeRegisterEvent("GARRISON_MISSION_COMPLETE_RESPONSE") self:SafeRegisterEvent("GARRISON_FOLLOWER_XP_CHANGED") @@ -4770,6 +4763,10 @@ do elseif (event=="GET_ITEM_INFO_RECEIVED") then currentMission.items[ID]=1 return + -- GET_ITEM_INFO_RECEIVED: itemID + elseif (event=="GARRISON_MISSION_BONUS_ROLL_LOOT") then + currentMission.items[ID]=1 + return -- GARRISON_MISSION_COMPLETE_RESPONSE: missionID, requestCompleted, succeeded elseif (event=="GARRISON_MISSION_COMPLETE_RESPONSE") then if (not arg1) then @@ -4864,7 +4861,7 @@ do currentMission.items[v.itemID]=nil else -- Follower XP reward - report:AddIconText(v.icon,v.name) + --report:AddIconText(v.icon,v.name) end end end diff --git a/GarrisonCommander.toc b/GarrisonCommander.toc index abfc0b2..896ea08 100644 --- a/GarrisonCommander.toc +++ b/GarrisonCommander.toc @@ -26,5 +26,4 @@ embeds.xml localization.lua wowhead.lua GarrisonCommander.xml -ldb.lua RelNotes.lua diff --git a/ldb.lua b/ldb.lua deleted file mode 100644 index f3246d0..0000000 --- a/ldb.lua +++ /dev/null @@ -1,81 +0,0 @@ -local me, ns = ... -if (LibDebug) then LibDebug() end -local L=LibStub("AceLocale-3.0"):GetLocale(me,true) -local addon=LibStub("AceAddon-3.0"):GetAddon(me) ---[[ ----------------------------------------- -LibDataBroker Stuff ---]] -local appo={} -function addon:ldbCleanup() - local now=time() - for i=1,#self.db.realm.missions do - local s=self.db.realm.missions[i] - if (type(s)=='string') then - local t,ID,pc=strsplit('.',s) - t=tonumber(t) or 0 - if pc==ns.me and t < now then - tremove(self.db.realm.missions,i) - i=i-1 - end - end - end -end -if (not LibStub:GetLibrary("LibDataBroker-1.1",true)) then - --@debug@ - print("Missing libdatabroker") - --@end-debug@ - return -end -local dataobj=LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject(me, { - type = "data source", - label = "GarrisonCommander", - text=NONE, - icon = "Interface\\ICONS\\ACHIEVEMENT_GUILDPERK_WORKINGOVERTIME" -}) -function addon:ldbUpdate() - local now=time() - local old=time()-3600 - for i=1,#self.db.realm.missions do - local t,missionID,pc=strsplit('.',self.db.realm.missions[i]) - t=tonumber(t) or 0 - if t>now then - dataobj.text=format("Next mission on |cff20ff20%s|r in %s",pc,SecondsToTime(t-now)) - return - end - end - dataobj.text=NONE -end -function dataobj:OnTooltipShow() - self:AddLine("Mission awaiting") - local db=addon.db.realm.missions - local now=time() - for i=1,#db do - if db[i] then - local t,missionID,pc=strsplit('.',db[i]) - t=tonumber(t) or 0 - local name=C_Garrison.GetMissionName(missionID) - if (name) then - if t > now then - self:AddDoubleLine(format("|cffff9900%s|r: %s",pc,name),SecondsToTime(t-now),nil,nil,nil,0,1,0) - else - self:AddDoubleLine(format("|cffff9900%s|r: %s",pc,name),DONE,nil,nil,nil,1,0,0) - end - end - end - end -end - -function dataobj:OnEnter() - GameTooltip:SetOwner(self, "ANCHOR_NONE") - GameTooltip:SetPoint("TOPLEFT", self, "BOTTOMLEFT") - GameTooltip:ClearLines() - dataobj.OnTooltipShow(GameTooltip) - - GameTooltip:Show() -end - -function dataobj:OnLeave() - GameTooltip:Hide() -end ---function dataobj:OnClick(button) ---end