From 770434079d6c58f3232ee0d7b6c66fdcb2c4530e Mon Sep 17 00:00:00 2001 From: Alar of Runetotem Date: Sun, 28 Aug 2016 12:54:48 +0200 Subject: [PATCH] Order Hall support Quick mission completion and missions autofill now available for order hall, too --- GarrisonCommander.toc | 3 +- OrderHall.lua | 309 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 311 insertions(+), 1 deletion(-) create mode 100644 OrderHall.lua diff --git a/GarrisonCommander.toc b/GarrisonCommander.toc index 8a5ac6f..4ae36b5 100644 --- a/GarrisonCommander.toc +++ b/GarrisonCommander.toc @@ -29,7 +29,7 @@ ## X-License: GPL v3 ## X-eMail: alar@aspide.it ## X-Date: @project-date-iso@ -## X-Embeds: +## X-Embeds: LibInit embeds.xml wowhead.lua localization.lua @@ -46,6 +46,7 @@ MatchMaker.lua FollowerRecruiting.lua BuildingPage.lua ShipYard.lua +OrderHall.lua quick.lua RelNotes.lua #@do-not-package@ diff --git a/OrderHall.lua b/OrderHall.lua new file mode 100644 index 0000000..dc16ce2 --- /dev/null +++ b/OrderHall.lua @@ -0,0 +1,309 @@ +local pp=print +local me, ns = ... +ns.Configure() +local GetItemCount=GetItemCount +local addon=addon --#addon +local over=over --#over +local _G=_G +local G=C_Garrison +local pairs=pairs +local format=format +local strsplit=strsplit +local select=select +local GetCurrencyInfo=GetCurrencyInfo +local generated +local GARRISON_FOLLOWER_MAX_UPGRADE_QUALITY=GARRISON_FOLLOWER_MAX_UPGRADE_QUALITY +local GARRISON_CURRENCY=GARRISON_CURRENCY +local GARRISON_SHIP_OIL_CURRENCY=GARRISON_SHIP_OIL_CURRENCY +local GARRISON_FOLLOWER_MAX_LEVEL=GARRISON_FOLLOWER_MAX_LEVEL +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 +local LE_FOLLOWER_TYPE_GARRISON_7_0=LE_FOLLOWER_TYPE_GARRISON_7_0 +local module=addon:NewSubClass('OrderHall') --#Module +local GameTooltip=GameTooltip +local GCS +local GHF +local GHFMissions +function module:OnInitialize(...) +--@debug@ + print("OrderHall Init",GHF,ns.GHF) +--@end-debug@ + if not ns.GHF then return end -- Waiting to be late initialized by init routine + GHF=ns.GHF + GHFMissions=ns.GHFMissions + --GARRISON_SHIPYARD_NPC_OPEN + --GARRISON_SHIPYARD_NPC_CLOSE + self:SafeSecureHook("GarrisonFollowerButton_UpdateCounters") + local ref=GHFMissions.CompleteDialog.BorderFrame.ViewButton + local bt = CreateFrame('BUTTON','GCQuickHallMissionCompletionButton', ref, 'UIPanelButtonTemplate') + bt.missionType=LE_FOLLOWER_TYPE_GARRISON_7_0 + bt:SetWidth(300) + bt:SetText(L["Garrison Comander Quick Mission Completion"]) + bt:SetPoint("CENTER",0,-50) + addon:ActivateButton(bt,"MissionComplete",L["Complete all missions without confirmation"]) + self:SafeHookScript(GHF,"OnShow","Setup",true) + self:SafeHookScript(GHF.MissionTab.MissionList.CompleteDialog,"OnShow",true) + self:SafeHookScript(GHF.MissionTab,"OnShow",true) + self:SafeHookScript(GHF.FollowerTab,"OnShow",true) + self:SafeRegisterEvent("ADVENTURE_MAP_CLOSE") + self:SafeRegisterEvent("GARRISON_MISSION_STARTED") + --GarrisonShipyardFrameFollowersListScrollFrameButton1 + --GarrisonShipyardMapMission1 + addon:AddLabel(L["OrderHall Appearance"]) + addon:AddToggle("HALLMOVEPANEL",true,L["Unlock Panel"],L["Makes shipyard panel movable"]) + --addon:AddToggle("BIGSCREEN",true,L["Use big screen"],L["Disabling this will give you the interface from 1.1.8, given or taken. Need to reload interface"]) + addon:AddToggle("HALLPIN",true,L["Show Garrison Commander menu"],L["Disable if you dont want the full Garrison Commander Header."]) + for _,b in ipairs(GHF.MissionTab.MissionList.listScroll.buttons) do + local scale=0.8 + local f,h,s=b.Title:GetFont() + b.Title:SetFont(f,h*scale,s) + local f,h,s=b.Summary:GetFont() + b.Summary:SetFont(f,h*scale,s) + b:RegisterForClicks("LeftButtonUp","RightButtonUp") + b.hall=true + addon:SafeSecureHookScript(b,"OnEnter","ScriptGarrisonMissionButton_OnEnter") + self:SafeRawHookScript(b,"OnClick","ScriptGarrisonMissionButton_OnClick") + end + GHF.MissionTab.MissionList.Update=addon.HookedGarrisonMissionList_Update + GHF.MissionTab.MissionList.SetTab=addon.HookedGarrisonMissionList_SetTab +end +function module:AddLevel(source,button,mission,missionID,bigscreen) + print("Hall") + button.Level:SetPoint("CENTER", button, "TOPLEFT", 40, -36); + local quality=math.min(math.max(mission.level-UnitLevel("player")+3,0),6) + button.Level:SetText(mission.level) + button.Level:SetTextColor(self:GetQualityColor(quality)) + button.ItemLevel:Show(); +end + +function module:ScriptGarrisonMissionButton_OnClick(this,...) + if this.info then + addon:AddExtraData(this.info) + local perc=addon:MatchMaker(this.info) + end + return addon:ScriptGarrisonMissionButton_OnClick(this,...) +end +function module:GetMain() + return GHF +end +function module:GetMissions() + return GHFMissions +end +function module:GetBigScreen() + return false +end +--- + +function module:Setup(this,...) +--@debug@ +print("Doing one time initialization for",this:GetName(),...) +--@end-debug@ + addon:CheckMP() + self:SafeSecureHookScript("OrderHallMissionFrame","OnShow") + GCS=addon:CreateHeader(self,'HALLPIN') + GHF.FollowerStatusInfo=GHF:CreateFontString(nil, "BORDER", "GameFontNormal") + GHF.FollowerStatusInfo:SetPoint("TOPRIGHT",-30,0) + GHF.FollowerStatusInfo:SetHeight(25) + GHF.FollowerStatusInfo:Show() + self:ScriptOrderHallMissionFrame_OnShow() + self:RefreshParties() +end +function module:ScriptOrderHallMissionFrame_OnShow() +--@debug@ + print("Doing all time initialization") + print(GetTime()) +--@end-debug@ + GCS:Show() + GCS:SetWidth(GHF:GetWidth()) + GHF:ClearAllPoints() + GHF:SetPoint("TOPLEFT",GCS,"BOTTOMLEFT",0,23) + GHF:SetPoint("TOPRIGHT",GCS,"BOTTOMRIGHT",0,23) + self:RefreshMenu() + self:RefreshFollowerStatus() +--@debug@ + print("Done all time initialization") + print(GetTime()) +--@end-debug@ +end + +function addon:EventADVENTURE_MAP_CLOSE(event,...) +--@debug@ +print("NPC CLOSED") +--@end-debug@ + if (GCS) then + self:RemoveMenu() + GCS:Hide() + end +end + +function module:EventGARRISON_MISSION_STARTED(event,missionType,missionID,...) + --@debug@ + print(event,missionID) + --@end-debug@ + self:RefreshFollowerStatus() + self:ScheduleTimer("RefreshCurrency",0.2) +end +function module:RefreshParties() + if true then + addon:OnAllGarrisonMissions(function(missionID) addon:MatchMaker(missionID)end,false,LE_FOLLOWER_TYPE_GARRISON_7_0) + else + self:coroutineExecute(0.001,function() + addon:OnAllGarrisonMissions(function(missionID) addon:MatchMaker(missionID) coroutine.yield(true) end) + end + ) + end +end +function module:RefreshMenu() + if not GCS then return end -- This could be called before header is built + if not self.currentmenu or not self.currentmenu:IsVisible() then + self:RemoveMenu() + self:AddMenu() + end +end +function module:AddMenu() +--@debug@ +print("Adding Menu",GCS.Menu,GHF.MissionTab:IsVisible(),GHF.FollowerTab:IsVisible()) +--@end-debug@ + if GCS.Menu then + return + end + local menu,size + + if GHF.MissionTab:IsVisible() then + self.currentmenu=GHF.MissionTab + menu,size=self:CreateOptionsLayer('HALLMOVEPANEL') + elseif GHF.FollowerTab:IsVisible() then + self.currentmenu=GHF.FollowerTab + menu,size=self:CreateOptionsLayer('HALLMOVEPANEL') + --elseif GSF.MissionControlTab:IsVisible() then + -- self.currentmenu=GSF.MissionControlTab + -- menu,size=self:CreateOptionsLayer('BIGSCREEN','GCSKIPRARE','GCSKIPEPIC') + else + self.currentmenu=nil + menu,size=self:CreateOptionsLayer('HALLMOVEPANEL') + end +--@debug@ + self:AddOptionToOptionsLayer(menu,'DBG') + self:AddOptionToOptionsLayer(menu,'TRC') +--@end-debug@ + local frame=menu.frame + frame:Show() + frame:SetParent(GCS) + frame:SetFrameStrata(GCS:GetFrameStrata()) + frame:SetFrameLevel(GCS:GetFrameLevel()+2) + menu:ClearAllPoints() + menu:SetPoint("TOPLEFT",GCS,"TOPLEFT",25,-18) + menu:SetWidth(GCS:GetWidth()-50) + menu:SetHeight(GCS:GetHeight()-50) + menu:DoLayout() + GCS.Menu=menu +end +function module:RemoveMenu() +--@debug@ +print("Removing menu") +--@end-debug@ + if (GCS.Menu) then + local rc,message=pcall(GCS.Menu.Release,GCS.Menu) + --@debug@ + print("Removed menu",rc,message) + --@end-debug@ + GCS.Menu=nil + end +end + +function module:OpenLastTab() +--@debug@ +print("Should restore tab") +--@end-debug@ +end +do + local s=setmetatable({},{__index=function(t,k) return 0 end}) + local FOLLOWER_STATUS_FORMAT=(ns.bigscreen and L["Followers status "] or "" ).. + C(AVAILABLE..':%d ','green') .. + C(GARRISON_FOLLOWER_WORKING .. ":%d ",'cyan') .. + C(GARRISON_FOLLOWER_ON_MISSION .. ":%d ",'red') + function module:RefreshFollowerStatus() + + wipe(s) + for _,followerID in self:GetHeroesIterator() do + local status=self:GetFollowerStatus(followerID) + s[status]=s[status]+1 + end + if (GHF.FollowerStatusInfo) then + GHF.FollowerStatusInfo:SetWidth(0) + GHF.FollowerStatusInfo:SetFormattedText( + FOLLOWER_STATUS_FORMAT, + s[AVAILABLE], + s[GARRISON_FOLLOWER_WORKING], + s[GARRISON_FOLLOWER_ON_MISSION] + ) + end + end + function module:GetTotFollowers(status) + if not status then + return s[AVAILABLE]+ + s[GARRISON_FOLLOWER_WORKING]+ + s[GARRISON_FOLLOWER_ON_MISSION] + else + return s[status] or 0 + end + end +end + +--[[ Follower +displayHeight = 0.25 +followerTypeID = 2 +iLevel = 600 +isCollected = true +classAtlas = Ships_TroopTransport-List +garrFollowerID = 0x00000000000001E2 +displayScale = 95 +level = 100 +quality = 3 +portraitIconID = 0 +isFavorite = false +xp = 1500 +texPrefix = Ships_TroopTransport +className = Transport +classSpec = 53 +name = Chen's Favorite Brew +followerID = 0x00000000011E4D8F +height = 0.30000001192093 +displayID = 63894 +scale = 110 +levelXP = 40000 +--]] +--[[ Mission +followerTypeID = 2 +description = Hellscream has posted a sub near the Horde's main base on Ashran. Take that sub out. Alliance, that means you, too. Factional hatreds have no place here. +cost = 150 +adjustedPosX = 798 +duration = 8 hr +adjustedPosY = -246 +durationSeconds = 28800 +state = -2 +inProgress=false +typePrefix = ShipMissionIcon-Treasure +typeAtlas = ShipMissionIcon-Treasure-Mission +offerTimeRemaining = 19 days 1 hr +level = 100 +offeredGarrMissionTextureID = 0 +offerEndTime = 1681052.25 +mapPosY = -246 +type = Ship-Treasure +name = Warspear Fishing +iLevel = 0 +numRewards = 1 +rewards = [table: 000000004D079210] +hasBonusEffect = false +numFollowers = 2 +costCurrencyTypesID = 1101 +followers = [table: 000000004D0791C0] +missionID = 563 +canStart = false +location = [ph] +isRare = false +mapPosX = 798 +locPrefix = GarrMissionLocation-TannanSea +--]] +--view mission button GSF.MissionTab.MissionList.CompleteDialog.BorderFrame.ViewButton \ No newline at end of file -- 1.7.9.5