diff --git a/.gitignore b/.gitignore index 0d72554..59d92a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /format.lua +/.settings/ diff --git a/.project b/.project index a3c0e0c..1cd1993 100644 --- a/.project +++ b/.project @@ -10,6 +10,11 @@ <arguments> </arguments> </buildCommand> + <buildCommand> + <name>de.loskutov.FileSync.FSBuilder</name> + <arguments> + </arguments> + </buildCommand> </buildSpec> <natures> <nature>org.eclipse.koneki.ldt.nature</nature> diff --git a/GarrisonCommander-Broker/ldb.lua b/GarrisonCommander-Broker/ldb.lua index 8932e17..7d89688 100644 --- a/GarrisonCommander-Broker/ldb.lua +++ b/GarrisonCommander-Broker/ldb.lua @@ -17,6 +17,7 @@ local C=addon:GetColorTable() local dataobj --#Missions local farmobj --#Farms local workobj --#Works +local cacheobj --#Cache local SecondsToTime=SecondsToTime local type=type local strsplit=strsplit @@ -56,6 +57,8 @@ local GARRISON_NUM_COMPLETED_MISSIONS=format(GARRISON_NUM_COMPLETED_MISSIONS,'9 local KEY_BUTTON1="Shift " .. KEY_BUTTON1 local KEY_BUTTON2="Shift " .. KEY_BUTTON2 local EMPTY=EMPTY -- "Empty" +local GARRISON_CACHE=GARRISON_CACHE + local dbversion=1 local frequency=5 local ldbtimer=nil @@ -93,6 +96,7 @@ function addon:ldbCleanup() end function addon:ldbUpdate() dataobj:Update() + cacheobj:Update() end function addon:GARRISON_MISSION_STARTED(event,missionID) local duration=select(2,G.GetPartyMissionInfo(missionID)) or 0 @@ -175,6 +179,21 @@ function addon:CountMissing() end return missing,tot end +function addon:CountCaches() + local tot=0 + local missing=0 + local now=time() + local expired=400*600 -- 1 risorsa ogni 10 minuti, per fullare servono 500 * 600 secondi + for p,j in pairs(self.db.realm.caches) do + if j>0 then + tot=tot+1 + if j+expired < now then + missing=missing+1 + end + end + end + return missing,tot +end function addon:CountEmpty() local tot=0 local missing=0 @@ -247,6 +266,7 @@ function addon:SetDbDefaults(default) orders={["*"]={ ["*"]=false }}, + caches={["*"]=0}, dbversion=1 } end @@ -276,6 +296,7 @@ function addon:OnInitialized() self:RegisterEvent("GARRISON_MISSION_NPC_OPENED","ldbCleanup") self:RegisterEvent("ZONE_CHANGED_NEW_AREA") self:RegisterEvent("SHIPMENT_CRAFTER_INFO") + self:RegisterEvent("SHOW_LOOT_TOAST") --self:RegisterEvent("SHIPMENT_CRAFTER_REAGENT_UPDATE",print) self:AddLabel(GARRISON_NUM_COMPLETED_MISSIONS) self:AddToggle("OLDINT",false,L["Use old interface"],L["Uses the old, more intrusive interface"]) @@ -294,6 +315,12 @@ function addon:SHIPMENT_CRAFTER_INFO(...) self:WorkUpdate(...) end +function addon:SHOW_LOOT_TOAST(event,typeIdentifier, itemLink, quantity, specID, sex, isPersonal, lootSource) + if (isPersonal and lootSource==10) then -- GARRISON_CACHE + self.db.realm.caches[ns.me]=time() + cacheobj:Update() + end +end function addon:DelayedInit() self:CheckDateReset() self:WorkUpdate() @@ -349,6 +376,13 @@ workobj=LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("GC-WorkOrders", { category = "Interface", icon = "Interface\\Icons\\Trade_Engineering" }) +cacheobj=LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("GC-Cache", { + type = "data source", + label = "GC " .. GARRISON_CACHE, + text=QUEUED_STATUS_WAITING, + category = "Interface", + icon = "Interface\\Icons\\Trade_Engineering" +}) function farmobj:Update() local n,t=addon:CountMissing() if (t>0) then @@ -358,6 +392,15 @@ function farmobj:Update() farmobj.text=NONE end end +function cacheobj:Update() + local n,t=addon:CountCaches() + if (t>0) then + local c=addon:ColorToString(addon:Gradient((t-n)/t)) + cacheobj.text=format("|cff%s%d|r/|cff%s%d|r",c,t-n,C.Green.c,t) + else + cacheobj.text=NONE + end +end function farmobj:OnTooltipShow() self:AddDoubleLine(L["Time to next reset"],SecondsToTime(GetQuestResetTime())) for k,v in kpairs(addon.db.realm.farms) do @@ -375,6 +418,14 @@ function farmobj:OnTooltipShow() self:AddDoubleLine(KEY_BUTTON2,NEED) self:AddLine(me,C.Silver()) end +function cacheobj:OnTooltipShow() + self:AddLine(GARRISON_CACHE) + for k,v in kpairs(addon.db.realm.caches) do + local resources=math.floor((time()-v)*(1/600)) + self:AddDoubleLine(k==ns.me and C(k,"green") or C(k,"Orange"),resources,nil,nil,nil,addon:Gradient(resources/500)) + end + self:AddLine(me,C.Silver()) +end function dataobj:OnTooltipShow() self:AddLine(L["Mission awaiting"]) @@ -457,6 +508,7 @@ end farmobj.OnLeave=dataobj.OnLeave workobj.OnLeave=dataobj.OnLeave +cacheobj.OnLeave=dataobj.OnLeave function farmobj:OnClick(button) if (IsShiftKeyDown()) then for k,v in pairs(addon.db.realm.farms) do @@ -486,6 +538,7 @@ function dataobj:OnClick(button) end end workobj.OnClick=dataobj.OnClick +cacheobj.OnClick=dataobj.OnClick function dataobj:Update() if addon:GetBoolean("OLDINT") then return self:OldUpdate() end local now=time() @@ -538,7 +591,7 @@ function dataobj:OldUpdate() completed=completed+1 end self.text=format("%s: %s (Tot: |cff00ff00%d|r) %s: %s",READY,ready,completed,NEXT,prox) -end +end-- Resources rate: 144 a day --@debug@ local function highdebug(tb) diff --git a/GarrisonCommander.lua b/GarrisonCommander.lua index ad97e09..df4bf6a 100644 --- a/GarrisonCommander.lua +++ b/GarrisonCommander.lua @@ -2082,6 +2082,7 @@ do { text=L["Ignore for this mission"],checked=false, func=func, arg1=0, arg2="none"}, -- { text=L["Ignore for all missions"],checked=false, func=func, arg1=0, arg2="none"}, { text=L["Consider again"], notClickable=true,notCheckable=true,isTitle=true }, + { text=CLOSE, notClickable=true,notCheckable=true,isTitle=true }, } function addon:OnClick_PartyMember(frame,button,down,...) local followerID=frame.info and frame.info.followerID or nil @@ -2108,6 +2109,10 @@ do v.func=func2 v.arg1=missionID v.arg2=k + v.notCheckable=nil + v.notClickable=nil + v.checked=false + v.isTitle=nil menu[i]=v else dbcache.ignored[missionID][k]=nil @@ -2117,6 +2122,15 @@ do i=i+1 menu[i]={text=ALL,func=func2,arg1=missionID,arg2='all'} end + i=i+1 + if not menu[i] then + menu[i]={ text=CLOSE,func=function() end, notCheckable=true } + else + menu[i].text=CLOSE + menu[i].notCheckable=true + menu[i].notClickable=nil + menu[i].func=function() end + end for x=#menu,i+1,-1 do tremove(menu) end EasyMenu(menu,menuFrame,"cursor",0,0,"MENU",5) end diff --git a/PartyCache.lua b/PartyCache.lua index 66cdfdd..3d8293b 100644 --- a/PartyCache.lua +++ b/PartyCache.lua @@ -60,9 +60,12 @@ local ID,maxFollowers,members,ignored,threats=0,1,{},{},{} function party:Open(missionID,followers) maxFollowers=followers ID=missionID - for enemy,menaces in pairs(G.GetMissionUncounteredMechanics(ID)) do - for i=1,#menaces do - tinsert(threats,format("%d:%d",enemy,menaces[i])) + local mechanics=G.GetMissionUncounteredMechanics(ID) + if (type(mechanics)=="table") then + for enemy,menaces in pairs(mechanics) do + for i=1,#menaces do + tinsert(threats,format("%d:%d",enemy,menaces[i])) + end end end holdEvents()