From b3a6547ce14c93fb4ce643f364c1ecd94fe1fb43 Mon Sep 17 00:00:00 2001 From: Alar of Daggerspine Date: Tue, 24 Mar 2015 18:59:45 +0100 Subject: [PATCH] Signed-off-by: Alar of Daggerspine --- GarrisonCommander-Broker/ldb.lua | 23 +++- MissionCompletion.lua | 28 +++-- MissionControl.lua | 12 +- Widgets.lua | 248 +++++++++++++++++++------------------- 4 files changed, 166 insertions(+), 145 deletions(-) diff --git a/GarrisonCommander-Broker/ldb.lua b/GarrisonCommander-Broker/ldb.lua index edaac55..0d4c0ee 100644 --- a/GarrisonCommander-Broker/ldb.lua +++ b/GarrisonCommander-Broker/ldb.lua @@ -107,7 +107,7 @@ function addon:UNIT_SPELLCAST_START(event,unit,name,rank,lineID,spellID) end function addon:ITEM_PUSH(event,bag,icon) --@debug@ - print(event,bag,icon) + self:print(event,bag,icon) --@end-debug@ end function addon:CheckDateReset() @@ -132,7 +132,7 @@ function addon:CheckDateReset() if (reset<3600*3) then today=yesterday end - if self.db.realm.lastday 0) then + GMFMissions.CompleteDialog.BorderFrame.ViewButton:SetEnabled(false) -- Disabling standard Blizzard Completion report=self:GenerateMissionCompleteList("Missions' results") - --report:SetPoint("TOPLEFT",GMFMissions.CompleteDialog.BorderFrame) - --report:SetPoint("BOTTOMRIGHT",GMFMissions.CompleteDialog.BorderFrame) - report:SetParent(GMF) - report:SetPoint("TOP",GMF) - report:SetPoint("BOTTOM",GMF) - report:SetWidth(500) wipe(rewards.followerBase) wipe(rewards.followerXP) wipe(rewards.currencies) @@ -182,7 +192,7 @@ function module:MissionAutoComplete(event,ID,arg1,arg2,arg3,arg4) currentMission.state=0 currentMission.goldMultiplier=currentMission.goldMultiplier or 1 currentMission.xp=select(2,G.GetMissionInfo(currentMission.missionID)) - report:AddMissionButton(currentMission,currentMission.successChance) + report:AddMissionButton(currentMission,addon:GetParty(currentMission.missionID),currentMission.successChance) end if (step==0) then --@alpha@ diff --git a/MissionControl.lua b/MissionControl.lua index e4cd6df..fcc5279 100644 --- a/MissionControl.lua +++ b/MissionControl.lua @@ -537,12 +537,12 @@ local addPriorityRule,prioRefresh,removePriorityRule,prioMenu,prioTitles,prioChe do -- 1 = item, 2 = folitem, 3 = exp, 4 = money, 5 = resource prioTitles={ - itemLevel="Equipment", - followerUpgrade="Followr Upgrade", - xp="Xp gain", - gold="Gold Reward", - resources="Resource Rewards", - generic="Other Rewards" + itemLevel=L["Equipment"], + followerUpgrade=L["Follower Upgrade"], + xp=L["Xp gain"], + gold=L["Gold Reward"], + resources=L["Resource Rewards"], + generic=L["Other Rewards"] } prioVoices=0 for _ in pairs(prioTitles) do prioVoices=prioVoices+1 end diff --git a/Widgets.lua b/Widgets.lua index 77151c8..dbe4aa1 100644 --- a/Widgets.lua +++ b/Widgets.lua @@ -24,7 +24,7 @@ end local function GMCList() local Type="GCMCList" local Version=1 - local m={} --#GCMList + local m={} --#GMCList function m:ScrollDown() local obj=self.scroll if (#self.missions >1 and obj.scrollbar and obj.scrollbar:IsShown()) then @@ -50,11 +50,11 @@ local function GMCList() b:SetCallback("OnClick",action) obj:AddChild(b) end - function m:AddMissionButton(mission,perc) + function m:AddMissionButton(mission,party,perc) if not self.missions[mission.missionID] then local obj=self.scroll local b=AceGUI:Create("GMCSlimMissionButton") - b:SetMission(mission,perc) + b:SetMission(mission,party,perc) b:SetScale(0.7) b:SetFullWidth(true) self.missions[mission.missionID]=b @@ -140,6 +140,7 @@ local function GMCList() self:AddIconText(itemtexture,itemlink,qt) end end + ---@function [parent=#GMCList] local function Constructor() local widget=AceGUI:Create("GMCGUIContainer") widget:SetLayout("Fill") @@ -174,7 +175,7 @@ local function GMCGUIContainer() end ---@function [parent=#GMCGUIContainer] local function Constructor() - local frame=CreateFrame("Frame",nil,nil,"GarrisonUITemplate") + local frame=CreateFrame("Frame",Type..(GetTime()*1000),nil,"GarrisonUITemplate") for _,f in pairs({frame:GetRegions()}) do if (f:GetObjectType()=="Texture" and f:GetAtlas()=="Garr_WoodFrameCorner") then f:Hide() end end @@ -292,134 +293,133 @@ local function GMCLayer() end local function GMCMissionButton() - do - local Type1="GMCMissionButton" - local Type2="GMCSlimMissionButton" - local Version=1 - local unique=0 - local m={} --#GMCMissionButton - function m:OnAcquire() - local frame=self.frame - frame.info=nil - frame:SetHeight(self.type==Type1 and 80 or 80) - frame:SetAlpha(1) - frame:Enable() - for i=1,#self.scripts do - frame:SetScript(self.scripts[i],nil) - end - for i=1,#frame.Rewards do - frame.Rewards[i].Icon:SetDesaturated(false) - end - wipe(self.scripts) - return self.frame:SetScale(1.0) - end - function m:Show() - return self.frame:Show() - end - function m:SetHeight(h) - return self.frame:SetHeight(h) - end - function m:Hide() - self.frame:SetHeight(1) - self.frame:SetAlpha(0) - return self.frame:Disable() - end - function m:SetScript(name,method) - tinsert(self.scripts,name) - return self.frame:SetScript(name,method) - end - function m:SetScale(s) - return self.frame:SetScale(s) + local Type1="GMCMissionButton" + local Type2="GMCSlimMissionButton" + local Version=1 + local unique=0 + local m={} --#GMCMissionButton + function m:OnAcquire() + local frame=self.frame + print("Acquired button ",frame:GetName()) + frame.info=nil + frame:SetHeight(self.type==Type1 and 80 or 80) + frame:SetAlpha(1) + frame:SetScale(1.0) + frame:Enable() + for i=1,#self.scripts do + frame:SetScript(self.scripts[i],nil) end - function m:SetMission(mission,perc) - self.frame.info=mission - self.frame.fromFollowerPage=true - self.frame:EnableMouse(true) - self.frame.party=addon:GetParty(mission.missionID) - if self.type==Type1 then - addon:DrawSingleButton(false,self.frame,false,false) - self.frame:SetScript("OnEnter",GarrisonMissionButton_OnEnter) - self.frame:SetScript("OnLeave",ns.OnLeave) - else - addon:DrawSingleSlimButton(false,self.frame,false,false) - self.frame:SetScript("OnEnter",nil) - self.frame:SetScript("OnLeave",nil) - end - if self.type==Type2 then - self.frame.Percent:SetFormattedText("%d%%",perc) - self.frame.Percent:SetTextColor(addon:GetDifficultyColors(perc)) - _G.AX=self.frame - end + for i=1,#frame.Rewards do + frame.Rewards[i].Icon:SetDesaturated(false) end - - local function Constructor() - unique=unique+1 - local frame=CreateFrame("Button",nil,nil,"GarrisonMissionListButtonTemplate") --"GarrisonCommanderMissionListButtonTemplate") - frame.Title:SetFontObject("QuestFont_Shadow_Small") - frame.Summary:SetFontObject("QuestFont_Shadow_Small") - frame:SetScript("OnEnter",nil) - frame:SetScript("OnLeave",nil) - frame:SetScript("OnClick",function(self,button) return self.obj:Fire("OnClick",self,button) end) - frame.LocBG:SetPoint("LEFT") - frame.MissionType:SetPoint("TOPLEFT",5,-2) - --[[ - frame.members={} - for i=1,3 do - local f=CreateFrame("Button",nil,frame,"GarrisonCommanderMissionPageFollowerTemplateSmall" ) - frame.members[i]=f - f:SetPoint("BOTTOMRIGHT",-65 -65 *i,5) - f:SetScale(0.8) - end - --]] - local widget={} - setmetatable(widget,{__index=frame}) - widget.frame=frame - widget.scripts={} - frame.obj=widget - for k,v in pairs(m) do widget[k]=v end - return widget + wipe(self.scripts) + return + end + function m:Show() + return self.frame:Show() + end + function m:SetHeight(h) + return self.frame:SetHeight(h) + end + function m:Hide() + self.frame:SetHeight(1) + self.frame:SetAlpha(0) + return self.frame:Disable() + end + function m:SetScript(name,method) + tinsert(self.scripts,name) + return self.frame:SetScript(name,method) + end + function m:SetScale(s) + return self.frame:SetScale(s) + end + function m:SetMission(mission,party,perc) + self.frame.info=mission + self.frame.fromFollowerPage=true + self.frame:EnableMouse(true) + self.frame.party=party + if self.type==Type1 then + addon:DrawSingleButton(false,self.frame,false,false) + self.frame:SetScript("OnEnter",GarrisonMissionButton_OnEnter) + self.frame:SetScript("OnLeave",ns.OnLeave) + else + addon:DrawSingleSlimButton(false,self.frame,false,false) + self.frame:SetScript("OnEnter",nil) + self.frame:SetScript("OnLeave",nil) end - ---@function [parent=#GMCMissionButton] - local function Constructor1() - local widget=Constructor() - widget.type=Type1 - return AceGUI:RegisterAsWidget(widget) + if self.type==Type2 then + self.frame.Percent:SetFormattedText("%d%%",perc or party.perc) + self.frame.Percent:SetTextColor(addon:GetDifficultyColors(perc or party.perc)) end - ---@function [parent=#GMCMissionButton] - local function Constructor2() - local widget=Constructor() - local frame=widget.frame - widget.type=Type2 - local indicators=CreateFrame("Frame",nil,frame,"GarrisonCommanderIndicators") - indicators.Percent:SetJustifyH("LEFT") - indicators.Percent:SetJustifyV("CENTER") - indicators:SetPoint("LEFT",70,0) - indicators.Age:Hide() - local spinner=CreateFrame("Frame",nil,frame,"LoadingSpinnerTemplate") - frame.Spinner=spinner - frame.Indicators=indicators - frame.Percent=indicators.Percent - frame.Failure=frame:CreateFontString() - frame.Success=frame:CreateFontString() - frame.Failure:SetFontObject("GameFontRedLarge") - frame.Success:SetFontObject("GameFontGreenLarge") - frame.Failure:SetText(FAILED) - frame.Success:SetText(SUCCESS) - frame.Failure:Hide() - frame.Success:Hide() - frame.Title:SetPoint("TOPLEFT",frame.Indicators,"TOPRIGHT",0,0) - frame.Success:SetPoint("BOTTOMLEFT",frame.Indicators,"BOTTOMRIGHT",0,10) - frame.Failure:SetPoint("BOTTOMLEFT",frame.Indicators,"BOTTOMRIGHT",0,10) - frame.Spinner:SetPoint("BOTTOMLEFT",frame.Indicators,"BOTTOMRIGHT",0,-2) + end - --widget.frame.MissionType:Hide() - --widget.frame.IconBG:Hide() - return AceGUI:RegisterAsWidget(widget) + local function Constructor(type) + unique=unique+1 + local frame=CreateFrame("Button",type..unique,nil,"GarrisonMissionListButtonTemplate") --"GarrisonCommanderMissionListButtonTemplate") + print("Building button ",frame:GetName()) + frame.Title:SetFontObject("QuestFont_Shadow_Small") + frame.Summary:SetFontObject("QuestFont_Shadow_Small") + frame:SetScript("OnEnter",nil) + frame:SetScript("OnLeave",nil) + frame:SetScript("OnClick",function(self,button) return self.obj:Fire("OnClick",self,button) end) + frame.LocBG:SetPoint("LEFT") + frame.MissionType:SetPoint("TOPLEFT",5,-2) + --[[ + frame.members={} + for i=1,3 do + local f=CreateFrame("Button",nil,frame,"GarrisonCommanderMissionPageFollowerTemplateSmall" ) + frame.members[i]=f + f:SetPoint("BOTTOMRIGHT",-65 -65 *i,5) + f:SetScale(0.8) end - AceGUI:RegisterWidgetType(Type1,Constructor1,Version) - AceGUI:RegisterWidgetType(Type2,Constructor2,Version) + --]] + local widget={} + setmetatable(widget,{__index=frame}) + widget.frame=frame + widget.scripts={} + frame.obj=widget + for k,v in pairs(m) do widget[k]=v end + return widget + end + ---@function [parent=#GMCMissionButton] + local function Constructor1() + local widget=Constructor(Type1) + widget.type=Type1 + return AceGUI:RegisterAsWidget(widget) + end + ---@function [parent=#GMCMissionButton] + local function Constructor2() + local widget=Constructor(Type2) + local frame=widget.frame + widget.type=Type2 + local indicators=CreateFrame("Frame",nil,frame,"GarrisonCommanderIndicators") + indicators.Percent:SetJustifyH("LEFT") + indicators.Percent:SetJustifyV("CENTER") + indicators:SetPoint("LEFT",70,0) + indicators.Age:Hide() + local spinner=CreateFrame("Frame",nil,frame,"LoadingSpinnerTemplate") + frame.Spinner=spinner + frame.Indicators=indicators + frame.Percent=indicators.Percent + frame.Failure=frame:CreateFontString() + frame.Success=frame:CreateFontString() + frame.Failure:SetFontObject("GameFontRedLarge") + frame.Success:SetFontObject("GameFontGreenLarge") + frame.Failure:SetText(FAILED) + frame.Success:SetText(SUCCESS) + frame.Failure:Hide() + frame.Success:Hide() + frame.Title:SetPoint("TOPLEFT",frame.Indicators,"TOPRIGHT",0,0) + frame.Success:SetPoint("BOTTOMLEFT",frame.Indicators,"BOTTOMRIGHT",0,10) + frame.Failure:SetPoint("BOTTOMLEFT",frame.Indicators,"BOTTOMRIGHT",0,10) + frame.Spinner:SetPoint("BOTTOMLEFT",frame.Indicators,"BOTTOMRIGHT",0,-2) + --widget.frame.MissionType:Hide() + --widget.frame.IconBG:Hide() + return AceGUI:RegisterAsWidget(widget) end + AceGUI:RegisterWidgetType(Type1,Constructor1,Version) + AceGUI:RegisterWidgetType(Type2,Constructor2,Version) end function module:OnInitialized() print("Module widget called") -- 1.7.9.5