From 7524a4eecd0775efe72f9c0dc25a9eb691a834d4 Mon Sep 17 00:00:00 2001 From: Alar of Daggerspine Date: Tue, 1 Sep 2015 00:29:28 +0200 Subject: [PATCH] 2.7.0 Signed-off-by: Alar of Daggerspine --- .pkgmeta | 4 + FollowerPage.lua | 1 + GarrisonCommander.lua | 88 +++---- Init.lua | 31 +-- MissionCache.lua | 36 +-- MissionCompletion.lua | 59 ++++- MissionControl.lua | 627 ++++++++++++++++++++++++++++--------------------- ShipYard.lua | 32 ++- embeds.xml | 1 + 9 files changed, 511 insertions(+), 368 deletions(-) diff --git a/.pkgmeta b/.pkgmeta index dd063b7..1be6825 100755 --- a/.pkgmeta +++ b/.pkgmeta @@ -9,6 +9,10 @@ externals: url: svn://svn.wowace.com/wow/ace3/mainline/trunk tag: latest + libs/LibItemUpgradeInfo-1.0: + url: git://git.wowace.com/wow/libitemupgradeinfo-1-0/mainline.git + tag: latest + move-folders: GarrisonCommander/GarrisonCommander-Broker: GarrisonCommander-Broker diff --git a/FollowerPage.lua b/FollowerPage.lua index 9d8f9d6..cde88db 100644 --- a/FollowerPage.lua +++ b/FollowerPage.lua @@ -20,6 +20,7 @@ local StaticPopupDialogs=StaticPopupDialogs local YES=YES local NO=NO local GARRISON_FOLLOWER_MAX_ITEM_LEVEL=GARRISON_FOLLOWER_MAX_ITEM_LEVEL +local module=addon:NewSubClass("FollowerPage") --#module function addon:ShowImprovements() local scroller=self:GetScroller("Items") scroller:AddRow("Follower Upgrades",C.Orange()) diff --git a/GarrisonCommander.lua b/GarrisonCommander.lua index c4dd396..32d05b7 100644 --- a/GarrisonCommander.lua +++ b/GarrisonCommander.lua @@ -24,7 +24,7 @@ local trc=false local pin=false local baseHeight local minHeight -local addon=addon --#self +local addon=addon --#addon local LE_FOLLOWER_TYPE_GARRISON_6_0=LE_FOLLOWER_TYPE_GARRISON_6_0 local LE_FOLLOWER_TYPE_SHIPYARD_6_2=LE_FOLLOWER_TYPE_SHIPYARD_6_2 ns.bigscreen=true @@ -398,6 +398,10 @@ print("Initialize") db.lifespan=nil -- Removed in 2.6.9 db.traits=nil -- Removed in 2.6.9 db.types=nil -- Removed in 2.6.9 + chardb.missions=nil -- Removed + chardb.followers=nil + chardb.running=nil + chardb.runningIndex=nil if type(dbGAC)== "table " and type(dbGAC.namespaces)=="table" then dbGAC.namespaces.missionscache=nil -- Removed in 2.6.9 dbGAC.namespaces=nil @@ -423,7 +427,7 @@ print("Initialize") L["Sort missions by:"],L["Original sort restores original sorting method, whatever it was (If you have another addon sorting mission, it should kick in again)"]) self:AddToggle("USEFUL",true,L["Enhance tooltip"],L["Adds a list of other useful followers to tooltip"]) self:AddToggle("MAXRES",true,L["Maximize result"],L["Allows a lower success percentage for resource missions. Use /gac gui to change percentage. Default is 80%"]) - self:AddSlider("MAXRESCHANCE",80,50,100,L["Minum needed chance"],L["Applied when maximise result is enabled. Default is 80%"],1) + self:AddSlider("MAXRESCHANCE",80,50,100,L["Minum needed chance"],L["Applied when 'maximize result' is enabled. Default is 80%"],1) ns.bigscreen=self:GetBoolean("BIGSCREEN") self:AddLabel("Followers Panel") self:AddSlider("MAXMISSIONS",5,1,8,L["Mission shown"],L["Mission shown for follower"],1) @@ -794,31 +798,14 @@ function addon:CreatePrivateDb() } }, missionControl={ - version=1, + version=3, allowedRewards = { - followerUpgrade=true, - gold=true, - itemLevel=true, - resources=true, - xp=true, - scroll=true, - apexis=true, - oil=true, - other=true + ['*']=true, }, rewardChance={ - followerUpgrade=100, - gold=100, - itemLevel=100, - resources=100, - xp=100, - scroll=100, - apexis=100, - oil=100, - seal=100, - other=100 + ['*']=100, }, - rewardOrder={1,2,3,4,5,6,7,8,9,10}, + rewardList={}, useOneChance=true, minimumChance = 100, minDuration = 0, @@ -1087,18 +1074,12 @@ function addon:CreateOptionsLayer(...) return o,totsize end function addon:AddOptionToOptionsLayer(o,flag,maxsize) ---@debug@ - print("Adding option",flag) ---@end-debug@ maxsize=tonumber(maxsize) or 160 if (not flag) then return 0 end local info=addon:GetVarInfo(flag) if (info) then local data={option=info} local widget ---@debug@ - print("Adding option",flag,info.type,info) ---@end-debug@ if (info.type=="toggle") then widget=AceGUI:Create("CheckBox") local value=addon:GetBoolean(flag) @@ -1377,6 +1358,14 @@ function addon.ClonedGarrisonMissionMechanic_OnEnter(this) end tip:Show() end +local function removeAllFollowers(missionID) + local x=G.GetBasicMissionInfo(missionID) + if x then + for i=1,#x.followers do + G.RemoveFollowerFromMission(missionID,x.followers[i]) + end + end +end function addon:HookedGarrisonFollowerPage_ShowFollower(frame,followerID,force) return self:RenderFollowerPageMissionList(frame,followerID,force) end @@ -1387,7 +1376,17 @@ do local mh=nil local tContains=tContains local function MissionOnClick(this,...) - + local m=GMF.MissionTab.MissionPage.missionInfo + if m and m.missionID then + holdEvents() + local rc,message=pcall(removeAllFollowers,m.missionID) + if not rec then + print(message) + end + releaseEvents() + + + end --@debug@ print(this.frame,this.frame:GetName()) --@end-debug@ @@ -1559,9 +1558,6 @@ function addon:RefreshMenu() end end function addon:AddMenu() ---@debug@ -print("Adding Menu") ---@end-debug@ if GCF.Menu then return end @@ -1576,7 +1572,7 @@ print("Adding Menu") self:RenderFollowerPageMissionList(nil,GMF.FollowerTab.followerID) elseif GMF.MissionControlTab:IsVisible() then self.currentmenu=GMF.MissionControlTab - menu,size=self:CreateOptionsLayer('BIGSCREEN','USEFUL','MOVEPANEL') + menu,size=self:CreateOptionsLayer('BIGSCREEN','GCMINLEVEL','GCMINUPGRADE','GCSKIPRARE','GCSKIPEPIC','USEFUL') end --@debug@ self:AddOptionToOptionsLayer(menu,'DBG') @@ -1595,14 +1591,8 @@ print("Adding Menu") GCF.Menu=menu end function addon:RemoveMenu() ---@debug@ -print("Removing menu") ---@end-debug@ if (GCF.Menu) then local rc,message=pcall(GCF.Menu.Release,GCF.Menu) - --@debug@ - print("Removed menu",rc,message) - --@end-debug@ GCF.Menu=nil end end @@ -1840,6 +1830,7 @@ local fakeinfo={followerID=false} local fakeframe={} function addon:FillMissionPage(missionInfo) + --@debug@ print("FillMissionPage",missionInfo) --@end-debug@ @@ -1887,17 +1878,12 @@ function addon:FillMissionPage(missionInfo) local followerID=members[i] if (followerID) then main:AssignFollowerToMission(followerframe,self:GetAnyData(missionInfo.followerTypeID,followerID)) - -- local rc,error=pcall(GarrisonMissionPage_AddFollower,followerID) - -- if (not rc) then - -- print("fillmissinopage",error) - -- end end end else - ---@debug@ -print("No martini no party") ---@end-debug@ + --@debug@ + print("No martini no party") + --@end-debug@ end main:UpdateMissionParty(main.MissionTab.MissionPage.Followers) main:UpdateMissionData(main.MissionTab.MissionPage) @@ -2261,9 +2247,6 @@ function addon:ScriptGarrisonMissionButton_OnClick(tab,button) return end if (type(tab.info)~="table") then return end - if (tab.fromFollowerPage) then - self:OpenMissionsTab() - end self:FillMissionPage(tab.info) end function addon:OnClick_GCMissionButton(frame,button) @@ -2354,7 +2337,7 @@ function deleteGarrisonMissionFrame_SetFollowerPortrait(portraitFrame, followerI end end -function addon:GarrisonMissionPageOnClose(self) +function addon:GarrisonMissionPageOnClose() GMF:ClearParty() GarrisonMissionFrame.MissionTab.MissionPage:Hide(); GarrisonMissionFrame.followerCounters = nil; @@ -2518,6 +2501,7 @@ function addon:ScriptGarrisonMissionButton_OnEnter(this, button) --@debug@ GameTooltip:AddDoubleLine("MissionID",this.info.missionID) GameTooltip:AddDoubleLine("Class",this.info.class) + GameTooltip:AddDoubleLine(this.info.class,this.info[this.info.class]) GameTooltip:AddDoubleLine("TitleLen",this.Title:GetStringWidth()) GameTooltip:AddDoubleLine("SummaryLen",this.Summary:GetStringWidth()) GameTooltip:AddDoubleLine("Reward",this.Rewards[1]:GetWidth()) diff --git a/Init.lua b/Init.lua index cfa8db9..acef281 100644 --- a/Init.lua +++ b/Init.lua @@ -13,7 +13,6 @@ local tostringall=tostringall local tostring=tostring local tonumber=tonumber local type=type -print("init loaded") --@debug@ LoadAddOn("Blizzard_DebugTools") LoadAddOn("LibDebug") @@ -383,7 +382,9 @@ ns.traitTable={ [232]="Dancer" } } - +-- Caching iteminfo +ns.I=LibStub("LibItemUpgradeInfo-1.0") +ns.GetItemInfo=ns.I:GetCachingGetItemInfo() -- Pseudo Global Support. -- Calling ns.Configure() will give to the calling function a preloaded env @@ -409,29 +410,5 @@ function ns.Configure() end setfenv(2, ENV) end --------------------- to be estracted to CountersCache --- ---local G=C_Garrison ---ns.Abilities=setmetatable({},{ --- __index=function(t,k) rawset(t,k,G.GetFollowerAbilityName(k)) return rawget(t,k) end ---}) --- --- --- ---[[ TtraitTable generator -local TT=C_Garrison.GetRecruiterAbilityList(true) -local map={} -local keys={} -for i,v in pairs(C_Garrison.GetRecruiterAbilityCategories()) do - keys[v]=i -end -for _,trait in pairs(TT) do - local key=keys[trait.category] - if type(map[key])~="table" then - map[key]={} - end - map[key][trait.id]=trait.name -end -ATEINFO['abilities']=map ---]] + diff --git a/MissionCache.lua b/MissionCache.lua index 8bd317f..07fafd7 100644 --- a/MissionCache.lua +++ b/MissionCache.lua @@ -317,13 +317,12 @@ function addon:GetMissionIterator(followerType,func) end local function inList(self,id,reward) if self.key=='xp' then - if reward.followerXP then return reward.followerXp end + if reward.followerXP then return reward.followerXP end elseif self.key=='followerUpgrade' then if not reward.itemID then return false end - local info=addon:IsFollowerUpgrade(reward.itemID) - if info then - local _,_,level=strsplit(':',info) - return tonumber(level) or 0 + local level=addon:IsFollowerUpgrade(reward.itemID) + if level then + return tonumber(level) or 0 end elseif self.key=='itemLevel' then if not reward.itemID then return false end @@ -338,9 +337,9 @@ local function inList(self,id,reward) end elseif self.key=='other' then return reward.quantity or 0 - elseif reward.itemID and tcontains(self.list,reward.itemID) then + elseif reward.currencyID and tContains(self.list,-reward.currencyID) then return reward.quantity or 1 - elseif reward.currency and tcontains(self.list,reward.currency) then + elseif reward.itemID and tContains(self.list,reward.itemID) then return reward.quantity or 1 end return false @@ -373,23 +372,30 @@ local function newMissionType(key,name,icon,maxable,mat,func,...) end classes={ newMissionType('xp',L['Follower experience'],'XPBonus_icon',false,false,nil,0), - newMissionType('resources',GetCurrencyInfo(GARRISON_CURRENCY),'inv_garrison_resource',true,true,nil,GARRISON_CURRENCY), - newMissionType('oil',GetCurrencyInfo(GARRISON_SHIP_OIL_CURRENCY),'garrison_oil',true,true,nil,GARRISON_SHIP_OIL_CURRENCY), + newMissionType('resources',GetCurrencyInfo(GARRISON_CURRENCY),'inv_garrison_resource',true,true,nil,-GARRISON_CURRENCY), + newMissionType('oil',GetCurrencyInfo(GARRISON_SHIP_OIL_CURRENCY),'garrison_oil',true,true,nil,-GARRISON_SHIP_OIL_CURRENCY), newMissionType('rush',L['Rush orders'],'INV_Scroll_12',false,false,nil,122595,122594,122596,122592,122590,122593,122591,122576), - newMissionType('apexis',GetCurrencyInfo(823),'inv_apexis_draenor',false,false,nil,823), - newMissionType('seal',GetCurrencyInfo(994),'ability_animusorbs',false,false,nil,824), + newMissionType('apexis',GetCurrencyInfo(823),'inv_apexis_draenor',false,false,nil,-823), + newMissionType('seal',GetCurrencyInfo(994),'ability_animusorbs',false,false,nil,-994), newMissionType('gold',BONUS_ROLL_REWARD_MONEY,'inv_misc_coin_01',false,false,nil,0), newMissionType('followerUpgrade',L['Follower equipment set or upgrade'],'Garrison_ArmorUpgrade',false,false,nil,0), newMissionType('itemLevel',L['Item Tokens'],'INV_Bracer_Cloth_Reputation_C_01',false,false,nil,0), - newMissionType('other',L['Other rewards'],'INV_Box_02',false,false,nil,0), newMissionType('primalspirit',L['Reagents'],'6BF_Explosive_shard',false,false,nil,118472,120945,113261,113262,113263,113264), - newMissionType('ark',L['Archaelogy'],'achievement_character_orc_male',false,false,nil,829,828,821,108439,109585,109584), -- Fragments and completer - newMissionType('training',L['Follower Training'],'Spell_Holy_WeaponMastery',false,false,nil,123858,118354,118475,122582,122580,122584,118474), + newMissionType('ark',L['Archaelogy'],'achievement_character_orc_male',false,false,nil,-829,-828,-821,108439,109585,109584), -- Fragments and completer + newMissionType('training',L['Follower Training'],'Spell_Holy_WeaponMastery',false,false,nil,123858,118354,118475,122582,122583,122580,122584,118474), newMissionType('legendary',L['Legendary Items'],'INV_Relics_Runestone',false,false,nil,115510,115280,128693), newMissionType('toys',L['Toys and Mounts'],'INV_LesserGronnMount_Red',false,false,nil,128310,127748,128311), newMissionType('reputation',L['Reputation Items'],'Spell_Shadow_DemonicCircleTeleport',false,false,nil,117492,128315), + newMissionType('other',L['Other rewards'],'INV_Box_02',false,false,nil,0), } function addon:GetRewardClasses() return classes end - +function addon:TestMission(id) + local rewards=G.GetMissionRewardInfo(id) + for id,reward in pairs(rewards) do + for _,v in pairs(classes) do + print(v.key,v.func(v,id,reward)) + end + end +end diff --git a/MissionCompletion.lua b/MissionCompletion.lua index de5b0f0..830d56e 100644 --- a/MissionCompletion.lua +++ b/MissionCompletion.lua @@ -8,6 +8,7 @@ local GMFMissions=GarrisonMissionFrameMissions local GSFMissions=GarrisonMissionFrameMissions local GARRISON_CURRENCY=GARRISON_CURRENCY local GARRISON_SHIP_OIL_CURRENCY=_G.GARRISON_SHIP_OIL_CURRENCY or 0 +local SEAL_CURRENCY=994 local LE_FOLLOWER_TYPE_GARRISON_6_0=_G.LE_FOLLOWER_TYPE_GARRISON_6_0 local LE_FOLLOWER_TYPE_SHIPYARD_6_2=_G.LE_FOLLOWER_TYPE_SHIPYARD_6_2 local pairs=pairs @@ -36,9 +37,15 @@ function module:GenerateMissionCompleteList(title,anchor) end --@debug@ function addon.ShowRewards() - module:GenerateMissionCompleteList("Test") + module:GenerateMissionCompleteList("Test",UIParent) end --@end-debug@ +local cappedCurrencies={ + GARRISON_CURRENCY, + GARRISON_SHIP_OIL_CURRENCY, + SEAL_CURRENCY +} + local missions={} local followerType=LE_FOLLOWER_TYPE_GARRISON_6_0 local states={} @@ -99,27 +106,30 @@ function module:CloseReport() addon:RefreshParties() addon:RefreshMissions() end -function module:MissionComplete(this,button) - ---@debug@ -print(this,button,this.missionType) ---@end-debug@ +function module:MissionComplete(this,button,skiprescheck) followerType=this.missionType missions=G.GetCompleteMissions(followerType) + if (missions and #missions > 0) then + this:SetEnabled(false) GMFMissions.CompleteDialog.BorderFrame.ViewButton:SetEnabled(false) -- Disabling standard Blizzard Completion GSFMissions.CompleteDialog.BorderFrame.ViewButton:SetEnabled(false) -- Disabling standard Blizzard Completion - report=self:GenerateMissionCompleteList("Missions' results",followerType==LE_FOLLOWER_TYPE_GARRISON_6_0 and GMF or GSF) wipe(rewards.followerBase) wipe(rewards.followerXP) wipe(rewards.currencies) wipe(rewards.items) + local message=C("WARNING",'red') + local wasted={} for i=1,#missions do for k,v in pairs(missions[i].followers) do rewards.followerBase[v]=self:GetAnyData(followerType,v,'qLevel',0) end for k,v in pairs(missions[i].rewards) do if v.itemID then GetItemInfo(v.itemID) end -- tickling server + if v.currencyID and tContains(cappedCurrencies,v.currencyID) then + local currentQT=select(2,GetCurrencyInfo(v.currencyID)) + wasted[v.currencyID]=(wasted[v.currencyID] or 0) + v.quantity + end end local m=missions[i] --totalTimeString, totalTimeSeconds, isMissionTimeImproved, successChance, partyBuffs, isEnvMechanicCountered, xpBonus, materialMultiplier, goldMultiplier = C_Garrison.GetPartyMissionInfo(MISSION_PAGE_FRAME.missionInfo.missionID); @@ -128,10 +138,43 @@ print(this,button,this.missionType) _,_,m.isMissionTimeImproved,m.successChance,_,_,m.xpBonus,m.resourceMultiplier,m.goldMultiplier=G.GetPartyMissionInfo(m.missionID) end + local stop + for id,qt in pairs(wasted) do + local name,current,_,_,_,cap=GetCurrencyInfo(id) + --@debug@ + print(name,current,qt,cap) + --@debug-end@ + current=current+qt + if current+qt > cap then + message=message.."\n"..format(L["Capped %1$s. Spend at least %2$d of them"],name,current-cap) + stop =true + end + end + if stop and not skiprescheck then + self:Popup(message.."\n" ..L["If you continue, you will loose them"],0, + function() + module:MissionComplete(this,button,true) + end, + function() + this:SetEnabled(true) + if GMF then + GMF:Hide() + GMFMissions.CompleteDialog.BorderFrame.ViewButton:SetEnabled(true) + end + if GSF then + GSF:Hide() + GSFMissions.CompleteDialog.BorderFrame.ViewButton:SetEnabled(true) + end + end + ) + return + end + report=self:GenerateMissionCompleteList("Missions' results",followerType==LE_FOLLOWER_TYPE_GARRISON_6_0 and GMF or GSF) report:SetUserData('missions',missions) report:SetUserData('current',1) self:Events(true) self:MissionAutoComplete("INIT") + this:SetEnabled(true) end end function module:GetMission(missionID) @@ -199,7 +242,7 @@ function module:MissionAutoComplete(event,ID,arg1,arg2,arg3,arg4) end startTimer(0.1) return - else -- event == LOOP + else -- event == LOOP or INIT if (currentMission) then local step=currentMission.state or -1 if (step<1) then diff --git a/MissionControl.lua b/MissionControl.lua index 1044566..82301c0 100644 --- a/MissionControl.lua +++ b/MissionControl.lua @@ -18,7 +18,8 @@ local pairs=pairs local tinsert=tinsert local tremove=tremove local dbg -local tItems = { +local tItems ={ + --[[ {t = 'Enable/Disable money rewards.', i = 'Interface\\Icons\\inv_misc_coin_01', key = 'gold'}, {t = 'Enable/Disable resource awards. (Resources/Seals)', i= 'Interface\\Icons\\inv_garrison_resource', key = 'resources'}, {t = 'Enable/Disable oil awards.', i= 'Interface\\Icons\\garrison_oil', key = 'oil'}, @@ -30,17 +31,23 @@ local tItems = { {t = 'Enable/Disable generc rewards.', i = "Interface\\ICONS\\INV_Box_02", key = 'other'}, {t = 'Enable/Disable Seal of Tempered Fate.', i = "Interface\\Icons\\ability_animusorbs", key = 'seal'}, {t = 'Enable/Disable Primal Spirit.', i = "Interface\\Icons\\6BF_Explosive_shard", key = 'primalspirit'}, - {t = 'Enable/Disable Follower Equip Set.', i = "Interface\\Icons\\Garrison_GreenArmor", key = 'followerSet'}, -} -tItems=addon:GetRewardClasses() -local tOrder -local tSort={} + --]] + } +for _,data in ipairs(addon:GetRewardClasses()) do + tItems[data.key]=data +end +local classlist={} ---#table local reference to settings.rewardList +local class2order={} ---#table maps a classname to its priority local settings local module=addon:NewSubClass("MissionControl") --#module function module:GMCBusy(followerID) return GMCUsedFollowers[followerID] end addon.GMCBusy=module.GMCBusy +--- +-- Builds a mission list based on user preferences +-- @param #module self self +-- @param #table workList table to be filled with mission list function module:GMCCreateMissionList(workList) --First get rid of unwanted rewards and missions that are too long local settings=self.privatedb.profile.missionControl @@ -50,38 +57,43 @@ function module:GMCCreateMissionList(workList) local discarded=false local class=self:GetMissionData(missionID,"class") repeat - ---@debug@ -print("|cffff0000",'Examing',missionID,self:GetMissionData(missionID,"name"),class,"|r") ---@end-debug@ + --@debug@ + print("|cffff0000",'Examining',missionID,self:GetMissionData(missionID,"name"),class,"|r") + --@end-debug@ local durationSeconds=self:GetMissionData(missionID,'durationSeconds') if (durationSeconds > settings.maxDuration * 3600 or durationSeconds < settings.minDuration * 3600) then - ---@debug@ -print(missionID,"discarded due to len",durationSeconds /3600) ---@end-debug@ + --@debug@ + print(" ",missionID,"discarded due to duration",durationSeconds /3600) + --@end-debug@ break end -- Mission too long, out of here if self:GetMissionData(missionID,'isRare') and addon:GetBoolean('GCSKIPRARE') then - ---@debug@ -print(missionID,"discarded due to rarity") ---@end-debug@ + --@debug@ + print(" ",missionID,"discarded due to rarity") + --@end-debug@ break end if (not ar[class]) then - ---@debug@ -print(missionID,"discarded due to class == ", class) ---@end-debug@ + --@debug@ + print(" ",missionID,"discarded due to class == ", class) + --@end-debug@ discarded=true break end if class=="itemLevel" then if self:GetMissionData(missionID,'itemLevel') < settings.minLevel then ---@debug@ -print(missionID,"discarded due to ilevel == ", self:GetMissionData(missionID,'itemLevel')) ---@end-debug@ + --@debug@ + print(" ",missionID,"discarded due to ilevel == ", self:GetMissionData(missionID,'itemLevel')) + --@end-debug@ + discarded=true + break + end + elseif class=="followerUpgrade" then + if self:GetMissionData(missionID,'followerUpgrade') < settings.minUpgrade and + self:GetMissionData(missionID,'followerUpgrade') > 600 then + --@debug@ + print(" ",missionID,"discarded due to followerUpgrade == ", self:GetMissionData(missionID,'followerUpgrade')) + --@end-debug@ discarded=true break end @@ -98,25 +110,27 @@ print(missionID,"discarded due to ilevel == ", self:GetMissionData(missionID,'it if (c1==c2) then return addon:GetMissionData(i1,c1,0) > addon:GetMissionData(i2,c2,0) else - return (tSort[c1] or i1)<(tSort[c2] or i2) + return (class2order[c1] or i1)<(class2order[c2] or i2) end end table.sort(workList,msort) ---@debug@ + --@debug@ for i=1,#workList do local id=workList[i] print(self:GetMissionData(id,'name'),self:GetMissionData(id,'class'),self:GetMissionData(id,self:GetMissionData(id,'class'))) end ---@end-debug@ + --@end-debug@ end ---- This routine can be called both as coroutin and as a standard one +--- +-- This routine can be called both as coroutin and as a standard one -- In standard version, delay between group building and submitting is done via a self schedule ---@param #integer missionID Optional, to run a single mission ---@param #bool start Optional, tells that follower already are on mission and that we need just to start it +-- @param #module self +-- @param #number missionID Optional, to run a single mission +-- @param #boolean start Optional, tells that follower already are on mission and that we need just to start it function module:GMCRunMission(missionID,start) ---@debug@ + --@debug@ print("Asked to start mission",missionID) ---@end-debug@ + --@end-debug@ local GMC=GMF.MissionControlTab if (start) then G.StartMission(missionID) @@ -126,9 +140,9 @@ function module:GMCRunMission(missionID,start) end for i=1,#GMC.list.Parties do local party=GMC.list.Parties[i] ---@debug@ + --@debug@ print("Checking",party.missionID) ---@end-debug@ + --@end-debug@ if (missionID and party.missionID==missionID or not missionID) then GMC.list.widget:RemoveChild(party.missionID) GMC.list.widget:DoLayout() @@ -194,13 +208,13 @@ do end local party={members={},perc=0} self:MCMatchMaker(missionID,party,settings.skipEpic,minimumChance) ---@debug@ + --@debug@ print(missionID," Requested",class,";",minimumChance,"Mission",party.perc,party.full,settings) ---@end-debug@ + --@end-debug@ if ( party.full and party.perc >= minimumChance) then ---@debug@ + --@debug@ print(missionID," Acccepted",party) ---@end-debug@ + --@end-debug@ local mb=AceGUI:Create("GMCMissionButton") for i=1,#party.members do GMCUsedFollowers[party.members[i]]=true @@ -227,27 +241,27 @@ function module:GMC_OnClick_Run(this,button) this:Disable() GMC.logoutButton:Disable() do - local elapsed=0 - local co=coroutine.wrap(self.GMCRunMission) - self:RawHookScript(GMC.runButton,'OnUpdate',function(this,ts) - elapsed=elapsed+ts - if (elapsed>0.25) then - elapsed=0 - local rc=co(self) - if (not rc) then - self:Unhook(GMC.runButton,'OnUpdate') - GMC.logoutButton:Enable() + local elapsed=0 + local co=coroutine.wrap(self.GMCRunMission) + self:RawHookScript(GMC.runButton,'OnUpdate',function(this,ts) + elapsed=elapsed+ts + if (elapsed>0.25) then + elapsed=0 + local rc=co(self) + if (not rc) then + self:Unhook(GMC.runButton,'OnUpdate') + GMC.logoutButton:Enable() + end end end - end - ) + ) end end function module:GMC_OnClick_Start(this,button) local GMC=GMF.MissionControlTab ---@debug@ -print(C("-------------------------------------------------","Yellow")) ---@end-debug@ + --@debug@ + print(C("-------------------------------------------------","Yellow")) + --@end-debug@ GMC.list.widget:ClearChildren() if (self:GetTotFollowers(AVAILABLE) == 0) then GMC.list.widget:SetTitle("All followers are busy") @@ -275,149 +289,177 @@ print(C("-------------------------------------------------","Yellow")) end local chestTexture +local function buildDragging(frame,drawItemButtons) + local GMC=GMF.MissionControlTab + frame:SetScript('OnClick', function(this) + settings.allowedRewards[this.key] = not settings.allowedRewards[this.key] + drawItemButtons() + GMC.startButton:Click() + end) + frame:SetScript('OnEnter', function(this) + GameTooltip:SetOwner(this, 'ANCHOR_BOTTOMRIGHT') + GameTooltip:AddLine(this.tooltip); + for _,line in ipairs(this.list) do + local info=GetItemInfo(line,2) + if info then GameTooltip:AddLine(info) end + end + GameTooltip:Show() + end) + frame:RegisterForDrag("LeftButton") + frame:SetMovable(true) + frame:SetScript("OnDragStart",function(this,button) + --@debug@ + print("Start",this:GetName(),GetMouseFocus():GetName(),this:GetID(),this.key) + --@end-debug@ + local f=GMC.ignoreFrames[this:GetID()+1] + if f then f:ClearAllPoints() end + this:StartMoving() + this.oldframestrata=this:GetFrameStrata() + this:SetFrameStrata("FULLSCREEN_DIALOG") + end) + frame:SetScript("OnDragStop",function(this,button) + this:StopMovingOrSizing() + --@debug@ + print("Stopped",this:GetName(),GetMouseFocus():GetName(),this:GetID(),this.key) + --@end-debug@ + this:SetFrameStrata(this.oldframestrata) + end) + frame:SetScript("OnReceiveDrag",function(this,...) + --@debug@ + print("Receive",this:GetName(),GetMouseFocus():GetName(),this:GetID(),this.key,...) + --@end-debug@ + local from=this:GetID() + local to + local x,y=this:GetCenter() + local id=this:GetID() + for i=1,#GMC.ignoreFrames do + local f=GMC.ignoreFrames[i] + if f:GetID() ~= id then + if f:IsMouseOver() then + to=f:GetID() + break + end + if y>=f:GetBottom() and y<=f:GetTop() and x>=f:GetLeft() and x<=f:GetRight() then + to=f:GetID() + break + end + end + end + if (to) then + local appo=tremove(classlist,from) + tinsert(classlist,to,appo) + --@debug@ + print(appo,"from:",from,"to:",to) + DevTools_Dump(classlist) + --@end-debug@ + end + drawItemButtons() + --module:Refresh() + end) + frame:SetScript('OnLeave', function() GameTooltip:Hide() end) + +end local function drawItemButtons(frame) local GMC=GMF.MissionControlTab frame=frame or GMC.rewards - local scale=0.8 + local scale=1.0 local h=37 -- itemButtonTemplate standard size local gap=5 local single=settings.useOneChance --for j = 1, #tItems do - --local i=tOrder[j] - for j,i in ipairs(tOrder) do - local frame = GMC.ignoreFrames[j] or CreateFrame('BUTTON', "Priority" .. j, frame, 'ItemButtonTemplate') - GMC.ignoreFrames[j] = frame - frame:SetID(j) - frame:ClearAllPoints() - frame:SetScale(scale) - --frame:SetPoint('TOPLEFT', 10,(j) * ((-h * scale) -gap)) - if j==1 then - frame:SetPoint('TOPLEFT', 35,-35) + --local i=tOrder[j] + local wrap=#classlist/2 +1 + for frameIndex,i in ipairs(classlist) do + local row = GMC.ignoreFrames[frameIndex] + if not row then + row= CreateFrame('BUTTON', "Priority" .. frameIndex, frame, 'ItemButtonTemplate') + row.chance=settings.rewardChance[row.key] or 100 + GMC.ignoreFrames[frameIndex] = row + row.slider=row.slider or factory:Slider(row,0,100,row.chance,row.chance) + row.slider:SetWidth(128) + row.slider:SetPoint('BOTTOMLEFT',row,'BOTTOMRIGHT',15,0) + row.slider.Text:SetFontObject('NumberFont_Outline_Med') + row.slider.isPercent=true + row.slider:SetScript("OnValueChanged",function(this,value) + settings.rewardChance[this:GetParent().key]=this:OnValueChanged(value) + module:Refresh() + end + ) + row.chest = row.chest or row:CreateTexture(nil, 'BACKGROUND') + row.chest:SetTexture('Interface\\Garrison\\GarrisonMissionUI2.blp') + row.chest:SetAtlas(chestTexture) + row.chest:SetSize((209-(209*0.25))*0.30, (155-(155*0.25)) * 0.30) + row.chest:SetPoint('CENTER',row.slider, 0, 15) + buildDragging(row,drawItemButtons) + end + row:SetID(frameIndex) + row:ClearAllPoints() + row:SetScale(scale) + --frame:SetPoint('TOPLEFT', 10,(j) * ((-h * scale) -gap)) + if frameIndex==1 then + row:SetPoint('TOPLEFT', 10,-35) + elseif frameIndex==wrap then + row:SetPoint('TOPRIGHT', -(10 + 145),-35) else - frame:SetPoint('TOPLEFT', GMC.ignoreFrames[j-1],'BOTTOMLEFT',0,-6) + row:SetPoint('TOPLEFT', GMC.ignoreFrames[frameIndex-1],'BOTTOMLEFT',0,-5) end - frame.icon:SetTexture(tItems[i].i) - frame.key=tItems[i].key - tSort[frame.key]=j - frame.tooltip=tItems[i].t - frame.allowed=settings.allowedRewards[frame.key] - frame.chance=settings.rewardChance[frame.key] - frame.icon:SetDesaturated(not frame.allowed) - if frame.key=="itemLevel" then - frame.Count:SetText(settings.minLevel) - frame.Count:SetPoint('BOTTOMRIGHT',0,5) - frame.Count:Show() - elseif frame.key=="followerUpgrade" then - frame.Count:SetText(settings.minUpgrade) - frame.Count:Show() + row.icon:SetTexture(tItems[i].i) + row.key=tItems[i].key + class2order[row.key]=frameIndex + row.tooltip=tItems[i].t + row.list=tItems[i].list + row.allowed=settings.allowedRewards[row.key] + row.chance=settings.rewardChance[row.key] or 100 + row.icon:SetDesaturated(not row.allowed) + if row.key=="itemLevel" then + row.Count:SetText(settings.minLevel) + row.Count:SetJustifyH("RIGHT") + row.Count:SetPoint('BOTTOMRIGHT',0,5) + row.Count:Show() + elseif row.key=="followerUpgrade" then + row.Count:SetText(settings.minUpgrade) + row.Count:SetJustifyH("RIGHT") + row.Count:SetPoint('BOTTOMRIGHT',0,5) + row.Count:Show() else - frame.Count:Hide() + row.Count:Hide() end -- Need to resave them asap in order to populate the array for future scans - settings.allowedRewards[frame.key]=frame.allowed - settings.rewardChance[frame.key]=frame.chance - frame.slider=frame.slider or factory:Slider(frame,0,100,frame.chance or 100,frame.chance or 100) - frame.slider:SetWidth(128) - frame.slider:SetPoint('BOTTOMLEFT',60,0) - frame.slider.Text:SetFontObject('NumberFont_Outline_Med') + settings.allowedRewards[row.key]=row.allowed + settings.rewardChance[row.key]=row.chance + --row.slider:OnValueChanged(row.chance) + row.slider:SetValue(row.chance) if (single) then - frame.slider.Text:SetTextColor(C.Silver()) + row.slider:SetTextColor(C.Silver()) else - frame.slider.Text:SetTextColor(C.Green()) + row.slider:SetTextColor(C.Green()) end - frame.slider.isPercent=true - frame.slider:SetScript("OnValueChanged",function(this,value) - settings.rewardChance[this:GetParent().key]=this:OnValueChanged(value) - end - ) - frame.slider:OnValueChanged(settings.rewardChance[frame.key] or 100) + row.slider:OnValueChanged(settings.rewardChance[row.key] or 100) --frame.slider:SetText(settings.rewardChance[frame.key]) - frame.chest = frame.chest or frame:CreateTexture(nil, 'BACKGROUND') - frame.chest:SetTexture('Interface\\Garrison\\GarrisonMissionUI2.blp') - frame.chest:SetAtlas(chestTexture) - frame.chest:SetSize((209-(209*0.25))*0.30, (155-(155*0.25)) * 0.30) - frame.chest:SetPoint('CENTER',frame.slider, 0, 15) if (single) then - frame.chest:SetDesaturated(true) + row.chest:SetDesaturated(true) else - frame.chest:SetDesaturated(false) + row.chest:SetDesaturated(false) end - frame.chest:Show() - frame:SetScript('OnClick', function(this) - settings.allowedRewards[this.key] = not settings.allowedRewards[this.key] - drawItemButtons() - GMC.startButton:Click() - end) - frame:SetScript('OnEnter', function(this) - GameTooltip:SetOwner(this, 'ANCHOR_BOTTOMRIGHT') - GameTooltip:AddLine(this.tooltip); - GameTooltip:Show() - end) - frame:RegisterForDrag("LeftButton") - frame:SetMovable(true) - frame:SetScript("OnDragStart",function(this,button) - ---@debug@ -print("Start",this:GetID(),this.key) ---@end-debug@ - this:StartMoving() - this.oldframestrata=this:GetFrameStrata() - this:SetFrameStrata("FULLSCREEN_DIALOG") - end) - frame:SetScript("OnDragStop",function(this,button) - this:StopMovingOrSizing() - ---@debug@ -print("Stopped",this:GetID(),this.key) ---@end-debug@ - this:SetFrameStrata(this.oldframestrata) - - end) - frame:SetScript("OnReceiveDrag",function(this) - ---@debug@ -print("Receive",this:GetID(),this.key) ---@end-debug@ - local from=this:GetID() - local to - local x,y=this:GetCenter() - local id=this:GetID() - for i=1,#GMC.ignoreFrames do - local f=GMC.ignoreFrames[i] - if f:GetID() ~= id then - if y>=f:GetBottom() and y<=f:GetTop() then - to=f:GetID() - end - end - end - if (to) then - ---@debug@ -print("from:",from,"to:",to) ---@end-debug@ - local appo=tremove(tOrder,from) - tinsert(tOrder,to,appo) - end - drawItemButtons() - GMC.startButton:Click() - end) - frame:SetScript('OnLeave', function() GameTooltip:Hide() end) - frame:Show() - frame.top=frame:GetTop() - frame.bottom=frame:GetBottom() + row.chest:Show() + row:Show() + row.top=row:GetTop() + row.bottom=row:GetBottom() end if not GMC.rewardinfo then GMC.rewardinfo = frame:CreateFontString() local info=GMC.rewardinfo info:SetFontObject('GameFontHighlight') - info:SetText("Click to enable/disable a reward.\nDrag to reorder") + info:SetText("Click to enable/disable a reward. Drag to reorder") info:SetTextColor(1, 1, 1) info:SetPoint("BOTTOM",0,-5) end - frame:SetWidth(200) return GMC.ignoreFrames[#tItems] end local function dbfixV1() +--@debug@ + print('dbfixV1') +--@debug-end@ if type(settings.allowedRewards['equip'])~='nil' then settings.allowedRewards['itemLevel']=settings.allowedRewards['equip'] settings.rewardChance['itemLevel']=settings.rewardChance['equip'] @@ -430,15 +472,62 @@ local function dbfixV1() settings.allowedRewards['followerEquip']=nil settings.rewardChance['followerEquip']=nil end + settings.version=2 +end +local function dbfixV2() +--@debug@ + print('dbfixV2') +--@debug-end@ + local old= + { + 'gold', + 'resources', + 'oil', + 'rush', + 'xp', + 'followerUpgrade', + 'itemLevel', + 'apexis', + 'seal', + 'other' + } + settings.rewardList={} + settings.itemIgnoreList=nil + local a=settings.rewardList + if type(settings.rewardOrder)=="table" then + for _,i in ipairs(settings.rewardOrder) do + if old[i] ~='-' then + tinsert(a,old[i]) + old[i]='-' + end + end + end + for _,v in ipairs(old) do + if v~='-' then + tinsert(a,v) + end + end + for index,key in ipairs(a) do + class2order[key]=index + end + for _,v in ipairs(addon:GetRewardClasses()) do + if not class2order[v.key] then + tinsert(a,v.key) + end + end + settings.rewardOrder=nil + settings.version=3 end -local function toggleEpicWarning(warning) +local function toggleEpicWarning() local GMC=GMF.MissionControlTab + local warning=GMC.warning + if not warning then return end if (settings.skipEpic) then warning:Show() - GMC.duration:SetPoint("TOPLEFT",GMC.rewards,"TOPRIGHT",0,-30) + GMC.list.widget:SetPoint("TOPLEFT",GMC.chance,"TOPRIGHT",0,ns.bigscreen and -60 or -50) else warning:Hide() - GMC.duration:SetPoint("TOPLEFT",GMC.rewards,"TOPRIGHT",0,0) + GMC.list.widget:SetPoint("TOPLEFT",GMC.chance,"TOPRIGHT",0,-30) end end function module:OnInitialized() @@ -449,29 +538,17 @@ function module:OnInitialized() local GMC = CreateFrame('FRAME', nil, GMF) GMF.MissionControlTab=GMC settings=chardb.missionControl - tOrder=settings.rewardOrder if settings.version < 2 then dbfixV1() end - if false then - local aa={} - for k,v in pairs(tOrder) do aa[k]=v end - for k,v in pairs(aa) do tOrder[k]=nil end - wipe(tOrder) - for i=1,#tItems do - tinsert(tOrder,i) - end - _G.tOrder=tOrder - end - if #tOrder<#tItems then - for i=#tOrder+1,#tItems do - tOrder[i]=i - end + if settings.version < 3 or type(settings.rewardOrder)=='table' then + dbfixV2() end - for i=1,#tOrder do - tSort[tItems[tOrder[i]].key]=i - end - + wipe(class2order) + classlist=settings.rewardList + for index,key in ipairs(classlist) do + class2order[key]=index + end if settings.itemPrio then settings.itemPrio=nil end @@ -489,19 +566,22 @@ function module:OnInitialized() local rewards=GMC.rewards local list=GMC.list local flags=GMC.flags - rewards:SetPoint("TOPLEFT",20,-25) - rewards:SetPoint("BOTTOMLEFT",20,25) - list.widget:SetPoint("TOPLEFT",duration,"TOPRIGHT",0,-30) + list.widget:SetPoint("TOPLEFT",chance,"TOPRIGHT",0,-30) list.widget:SetPoint("BOTTOMRIGHT",GMF,"BOTTOMRIGHT",-25,25) - --duration:SetPoint("TOPLEFT",rewards,"TOPRIGHT",0,-50) Now, its position is decided in toggleEpicWarning - chance:SetPoint("TOPLEFT",duration,"BOTTOMLEFT",0,0) - flags:SetPoint("TOPLEFT",chance,"BOTTOMLEFT",0,0) ---@debug@ --- AddBackdrop(rewards) --- AddBackdrop(duration,0,1,0) --- AddBackdrop(chance,0,0,1) --- AddBackdrop(flags,0,1,1) ---@end-debug@ + duration:SetPoint("TOPLEFT",20,-25) + chance:SetPoint("TOPLEFT",duration,"TOPRIGHT",0,0) + rewards:SetPoint("TOPLEFT",duration,"BOTTOMLEFT",0,0) + rewards:SetPoint("BOTTOMLEFT",20,25) + toggleEpicWarning() + if flags then + flags:SetPoint("TOPLEFT",chance,"BOTTOMLEFT",0,0) + end + --@debug@ + --AddBackdrop(rewards) + --AddBackdrop(duration,0,1,0) + --AddBackdrop(chance,0,0,1) + -- AddBackdrop(flags,0,1,1) + --@end-debug@ GMC.Credits=GMC:CreateFontString(nil,"ARTWORK","QuestFont_Shadow_Small") GMC.Credits:SetWidth(0) GMC.Credits:SetFormattedText(C(L["Original concept and interface by %s"],'Yellow'),C("Motig","Red") ) @@ -511,6 +591,7 @@ function module:OnInitialized() end local refreshTimer function module:Refresh() + if not GMF.MissionControlTab.startButton then return end if GMF.MissionControlTab.startButton:IsEnabled() and not IsMouseButtonDown("LeftButton") then self:GMC_OnClick_Start(GMF.MissionControlTab.startButton,"LeftUp") else @@ -525,25 +606,18 @@ function module:GMCBuildChance() local GMC=GMF.MissionControlTab --Chance local frame= CreateFrame('FRAME', nil, GMC) - frame:SetSize(210, 170) - - GMC.cc = frame:CreateFontString() --title - GMC.cc:SetFontObject('GameFontNormalHuge') - GMC.cc:SetText(L['Success Chance']) - GMC.cc:SetPoint('TOP', 0, -5) - GMC.cc:SetTextColor(C:White()) - + frame:SetSize(210, 165) GMC.cp = frame:CreateTexture(nil, 'BACKGROUND') --Chest GMC.cp:SetTexture('Interface\\Garrison\\GarrisonMissionUI2.blp') GMC.cp:SetAtlas(chestTexture) GMC.cp:SetDesaturated(not settings.useOneChance) GMC.cp:SetSize((209-(209*0.25))*0.60, (155-(155*0.25))*0.60) - GMC.cp:SetPoint('CENTER', 0, 20) + GMC.cp:SetPoint('CENTER', 0, 40) GMC.ct = frame:CreateFontString() --Chance number GMC.ct:SetFontObject('ZoneTextFont') GMC.ct:SetFormattedText('%d%%',settings.minimumChance) - GMC.ct:SetPoint('CENTER', 0,20) + GMC.ct:SetPoint('CENTER', 0,25) if settings.useOneChance then GMC.ct:SetTextColor(C:Green()) else @@ -552,9 +626,10 @@ function module:GMCBuildChance() GMC.cs = factory:Slider(frame,0,100,settings.minimumChance,L['Minumum needed chance'],L["Mission with lower success chance will be ignored"]) -- Slider GMC.cs:SetPoint('CENTER', 0, -25) GMC.cs:SetScript('OnValueChanged', function(self, value) - local value = math.floor(value) - GMC.ct:SetText(value..'%') - settings.minimumChance = value + local value = math.floor(value) + GMC.ct:SetText(value..'%') + settings.minimumChance = value + module:Refresh() end) GMC.cs:SetValue(settings.minimumChance) GMC.ck=factory:Checkbox(frame,settings.useOneChance,L["Global success chance"],L["Unchecking this will allow you to set specific success chance for each reward type"]) @@ -569,6 +644,7 @@ function module:GMCBuildChance() GMC.ct:SetTextColor(C.Silver()) end drawItemButtons() + module:Refresh() end) return frame end @@ -587,78 +663,98 @@ local function timeslidechange(this,value) GMC.mt:SetTextColor(1, c, c) GMC.mt:SetFormattedText("%d-%dh",settings.minDuration,settings.maxDuration) end +function addon:ApplyGCMINLEVEL(value) + settings.minLevel=value + drawItemButtons() + module:Refresh() +end +function addon:ApplyGCMINUPGRADE(value) + settings.minUpgrade=value + drawItemButtons() + module:Refresh() +end +function addon:ApplyGCSKIPEPIC(value) + settings.skipEpic=value + toggleEpicWarning() + module:Refresh() +end +function addon:ApplyGCSKIPRARE(value) + settings.skipRare=value + module:Refresh() +end function module:GMCBuildFlags() - -- Duration local GMC=GMF.MissionControlTab - local frame= CreateFrame('FRAME', nil, GMC) -- Flags frame - frame:SetSize(210, 30+40*5) - local title = frame:CreateFontString() -- Title - title:SetFontObject('GameFontNormalHuge') - title:SetText(L['Other settings']) - title:SetPoint('TOPLEFT', 0, -5) - title:SetPoint('TOPRIGHT', 0, -5) - title:SetTextColor(1, 1, 1) - title:SetJustifyH("CENTER") - GMC.skipRare=factory:Checkbox(frame,settings.skipRare,L["Ignore rare missions"],L["Rare missions will not be considered"]) - GMC.skipRare:SetPoint("TOPLEFT",title,"BOTTOMLEFT",0,-5) - GMC.skipRare:SetScript("OnClick",function(this) - settings.skipRare=this:GetChecked() - module:GMC_OnClick_Start(GMC.startButton,"LeftUp") - end) - local warning=GMC:CreateFontString(nil,"ARTWORK","CombatTextFont") + local warning=GMC:CreateFontString(nil,"ARTWORK",ns.bigscreen and "GameFontNormalHuge" or "GameFontNormal") warning:SetText(L["Epic followers are NOT sent alone on xp only missions"]) - warning:SetPoint("TOPLEFT",GMC.rewards,"TOPRIGHT",0,0) + warning:SetPoint("TOPLEFT",GMC.chance,"TOPRIGHT",0,0) warning:SetPoint("TOPRIGHT",GMC,"TOPRIGHT",0,-25) warning:SetJustifyH("CENTER") warning:SetTextColor(C.Orange()) - toggleEpicWarning(warning) - GMC.skipEpic=factory:Checkbox(frame,settings.skipEpic,L["Ignore epic for xp missions."],L["IF you have a Salvage Yard you probably dont want to have this one checked"]) - GMC.skipEpic:SetPoint("TOPLEFT",GMC.skipRare,"BOTTOMLEFT",0,-5) - GMC.skipEpic:SetScript("OnClick",function(this) - settings.skipEpic=this:GetChecked() - toggleEpicWarning(warning) - module:Refresh() - end) - GMC.minLevel=factory:Slider(frame,540,715,settings.minLevel,L["Item minimum level"],L['Minimum requested level for equipment rewards']) - GMC.minLevel:SetPoint('TOP', GMC.skipEpic,"BOTTOM",0, -25) - GMC.minLevel:SetScript('OnValueChanged', function(self, value) + GMC.warning=warning + if true then + addon:AddLabel(L["Mission Control"]) + addon:AddSlider("GCMINLEVEL",settings.minLevel,535,715,L["Item minimum level"],L['Minimum requested level for equipment rewards'],15) + addon:AddSlider("GCMINUPGRADE",settings.minUpgrade,600,675,L["Follower set minimum upgrade"],L['Minimum requested upgrade for followers set (Enhancements are always included)'],15) + addon:AddToggle("GCSKIPEPIC",settings.skipEpic,L["Ignore epic for xp missions."],L["IF you have a Salvage Yard you probably dont want to have this one checked"]) + addon:AddToggle("GCSKIPRARE",settings.skipRare,L["Ignore rare missions"],L["Rare missions will not be considered"]) + else + -- Duration + local frame= CreateFrame('FRAME', nil, GMC) -- Flags frame + frame:SetSize(210, 30+40*5) + local title = frame:CreateFontString() -- Title + title:SetFontObject('GameFontNormalHuge') + title:SetText(L['Other settings']) + title:SetPoint('TOPLEFT', 0, -5) + title:SetPoint('TOPRIGHT', 0, -5) + title:SetTextColor(1, 1, 1) + title:SetJustifyH("CENTER") + GMC.skipRare=factory:Checkbox(frame,settings.skipRare,L["Ignore rare missions"],L["Rare missions will not be considered"]) + GMC.skipRare:SetPoint("TOPLEFT",title,"BOTTOMLEFT",0,-5) + GMC.skipRare:SetScript("OnClick",function(this) + settings.skipRare=this:GetChecked() + module:GMC_OnClick_Start(GMC.startButton,"LeftUp") + end) + GMC.skipEpic=factory:Checkbox(frame,settings.skipEpic,L["Ignore epic for xp missions."],L["IF you have a Salvage Yard you probably dont want to have this one checked"]) + GMC.skipEpic:SetPoint("TOPLEFT",GMC.skipRare,"BOTTOMLEFT",0,-5) + GMC.skipEpic:SetScript("OnClick",function(this) + settings.skipEpic=this:GetChecked() + toggleEpicWarning(warning) + module:Refresh() + end) + GMC.minLevel=factory:Slider(frame,540,715,settings.minLevel,L["Item minimum level"],L['Minimum requested level for equipment rewards']) + GMC.minLevel:SetPoint('TOP', GMC.skipEpic,"BOTTOM",0, -25) + GMC.minLevel:SetScript('OnValueChanged', function(self, value) local value = math.floor(value) settings.minLevel = value drawItemButtons() module:Refresh() - end) - --GMC.minLevel:SetValue(settings.minLevel) - GMC.minLevel:SetStep(15) - GMC.minUpgrade=factory:Slider(frame,600,675,settings.minUpgrade,L["Follower set minimum upgrade"],L['Minimum requested upgrade for followers set (Enhancements are always included)']) - GMC.minUpgrade:SetPoint('TOP', GMC.minLevel,"BOTTOM",0, -25) - GMC.minUpgrade:SetScript('OnValueChanged', function(self, value) + end) + --GMC.minLevel:SetValue(settings.minLevel) + GMC.minLevel:SetStep(15) + GMC.minUpgrade=factory:Slider(frame,600,675,settings.minUpgrade,L["Follower set minimum upgrade"],L['Minimum requested upgrade for followers set (Enhancements are always included)']) + GMC.minUpgrade:SetPoint('TOP', GMC.minLevel,"BOTTOM",0, -25) + GMC.minUpgrade:SetScript('OnValueChanged', function(self, value) local value = math.floor(value) settings.minUpgrade = value drawItemButtons() module:Refresh() - end) - --GMC.minUpgrade:SetValue(settings.minUpgrade) - GMC.minUpgrade:SetStep(15) - return frame + end) + --GMC.minUpgrade:SetValue(settings.minUpgrade) + GMC.minUpgrade:SetStep(15) + return frame + end end function module:GMCBuildDuration() -- Duration local GMC=GMF.MissionControlTab - local frame= CreateFrame('FRAME', nil, GMC) -- Dutation frame - frame:SetSize(210, 220) + local frame= CreateFrame('FRAME', 'PIPPO', GMC) -- Dutation frame + frame:SetSize(210, 165) frame:SetPoint('TOP',0, -20) - GMC.mdt = frame:CreateFontString() -- Title - GMC.mdt:SetFontObject('GameFontNormalHuge') - GMC.mdt:SetText(L['Mission Duration']) - GMC.mdt:SetPoint('TOP', 0, -5) - GMC.mdt:SetTextColor(1, 1, 1) - - GMC.hg = frame:CreateTexture(nil, 'BACKGROUND') -- Hourglass GMC.hg:SetTexture('Interface\\Timer\\Challenges-Logo.blp') GMC.hg:SetSize(7, 70) - GMC.hg:SetPoint('CENTER', 0, 0) + GMC.hg:SetPoint('CENTER', 0, 10) GMC.hg:SetBlendMode('ADD') GMC.rune = frame:CreateTexture(nil, 'BACKGROUND') --Rune @@ -666,7 +762,7 @@ function module:GMCBuildDuration() --bb:SetTexture('dungeons\\textures\\devices\\mm_clockface_01.blp') GMC.rune:SetTexture('World\\Dungeon\\Challenge\\clockRunes.blp') GMC.rune:SetSize(80, 80) - GMC.rune:SetPoint('CENTER', 0, 0) + GMC.rune:SetPoint('CENTER', 0, 10) GMC.rune:SetBlendMode('ADD') GMC.mt = frame:CreateFontString() -- Duration string over hourglass @@ -677,7 +773,7 @@ function module:GMCBuildDuration() GMC.ms1 = factory:Slider(frame,0,24,settings.minDuration,L['Minimum mission duration.']) GMC.ms2 = factory:Slider(frame,0,24,settings.maxDuration,L['Maximum mission duration.']) - GMC.ms1:SetPoint('TOP', frame,'TOP',0, -45) + GMC.ms1:SetPoint('TOP', frame,'TOP',0, -10) GMC.ms2:SetPoint('BOTTOM', frame,'BOTTOM',0, 15) GMC.ms2.max=true GMC.ms1:SetScript('OnValueChanged', timeslidechange) @@ -690,6 +786,7 @@ function module:GMCBuildRewards() --Allowed rewards local GMC=GMF.MissionControlTab local frame = CreateFrame('FRAME', nil, GMC) + frame:SetWidth(420) GMC.itf = frame:CreateFontString() GMC.itf:SetFontObject('GameFontNormalHuge') GMC.itf:SetText(L['Allowed Rewards']) diff --git a/ShipYard.lua b/ShipYard.lua index d817abc..4507706 100644 --- a/ShipYard.lua +++ b/ShipYard.lua @@ -47,6 +47,7 @@ function module:OnInitialize() self:SafeSecureHook("GarrisonShipyardMapMission_OnLeave") local ref=GSFMissions.CompleteDialog.BorderFrame.ViewButton + --@debug@ print(ref) --@end-debug@ @@ -138,6 +139,7 @@ function module:ScriptMapButtonOnClick(this) end function module:HookedGSF_OnClickMission(this,missionInfo) self:FillMissionPage(missionInfo) + self:RefreshFollowerStatus() end function module:HookedGarrisonFollowerButton_UpdateCounters(gsf,frame,follower,showcounter,lastupdate) if follower.followerTypeID~=LE_FOLLOWER_TYPE_SHIPYARD_6_2 then return end @@ -172,6 +174,9 @@ print("Doing one time initialization for",this:GetName(),...) GCS=addon:CreateHeader(self) self:ScriptGarrisonShipyardFrame_OnShow() self:SafeHookScript(GSF,"OnShow") + GSF.FollowerStatusInfo=GSF:CreateFontString(nil, "BORDER", "GameFontNormal") + GSF.FollowerStatusInfo:SetPoint("TOPRIGHT",-30,-5) + GSF.FollowerStatusInfo:Show() end function module:ScriptGarrisonShipyardFrame_OnShow() GCS:Show() @@ -180,7 +185,7 @@ function module:ScriptGarrisonShipyardFrame_OnShow() GSF:SetPoint("TOPLEFT",GCS,"BOTTOMLEFT",0,23) GSF:SetPoint("TOPRIGHT",GCS,"BOTTOMRIGHT",0,23) self:RefreshMenu() - + self:RefreshFollowerStatus() --@debug@ print("Doing all time initialization") --@end-debug@ @@ -319,6 +324,31 @@ function module:ShowEnhancements() end u:Show() end +do + local s=setmetatable({},{__index=function(t,k) return 0 end}) + local FOLLOWER_STATUS_FORMAT="Ship status: " .. + C(AVAILABLE..':%d ','green') .. + C(GARRISON_FOLLOWER_ON_MISSION .. ":%d ",'red') + function module:RefreshFollowerStatus() + + wipe(s) + for _,followerID in self:GetShipsIterator() do + local status=self:GetFollowerStatus(followerID) + s[status]=s[status]+1 + end + if (GSF.FollowerStatusInfo) then + GSF.FollowerStatusInfo:SetWidth(0) + GSF.FollowerStatusInfo:SetFormattedText( + FOLLOWER_STATUS_FORMAT, + s[AVAILABLE], + s[GARRISON_FOLLOWER_ON_MISSION] + ) + end + end + function module:GetTotFollowers(status) + return s[status] or 0 + end +end --[[ Follower displayHeight = 0.25 followerTypeID = 2 diff --git a/embeds.xml b/embeds.xml index 0474c94..a9575d2 100644 --- a/embeds.xml +++ b/embeds.xml @@ -11,5 +11,6 @@ + -- 1.7.9.5