Skip to content

Commit

Permalink
Header menu is now context sensitive
Browse files Browse the repository at this point in the history
Signed-off-by: Alar of Daggerspine <[email protected]>
  • Loading branch information
Alar of Daggerspine committed Aug 22, 2015
1 parent f631aef commit 9fd54ba
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 38 deletions.
66 changes: 51 additions & 15 deletions GarrisonCommander.lua
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,12 @@ print("Initialize")
self:AddSlider("MAXRESCHANCE",80,50,100,L["Minum needed chance"],L["Applied when maximise result is enabled. Default is 80%"])
ns.bigscreen=self:GetBoolean("BIGSCREEN")
self:AddLabel("Followers Panel")
self:AddSlider("MAXMISSIONS",5,1,8,L["Mission shown for follower"],nil,1)
self:AddSlider("MINPERC",50,0,100,L["Minimun chance success under which ignore missions"],nil,5)
self:AddToggle("ILV",true,L["Show weapon/armor level"],L["When checked, show on each follower button weapon and armor level for maxed followers"])
self:AddToggle("IXP",true,L["Show xp to next level"],L["When checked, show on each follower button missing xp to next level"])
self:AddToggle("UPG",true,L["Show upgrade options"],L["Only meaningful upgrades are shown"])
self:AddToggle("NOCONFIRM",true,L["Don't ask for confirmation"],L["If checked, clicking an upgrade icon will consume the item and upgrade the follower\n|cFFFF0000NO QUESTION ASKED|r"])
self:AddSlider("MAXMISSIONS",5,1,8,L["Mission shown"],L["Mission shown for follower"],1)
self:AddSlider("MINPERC",50,0,100,L["Minimun chance"],L["Minimun chance success under which ignore missions"],5)
self:AddToggle("ILV",true,L["Show itemlevel"],L["When checked, show on each follower button weapon and armor level for maxed followers"])
self:AddToggle("IXP",true,L["Show xp"],L["When checked, show on each follower button missing xp to next level"])
self:AddToggle("UPG",true,L["Show upgrades"],L["Only meaningful upgrades are shown"])
self:AddToggle("NOCONFIRM",true,L["Don't ask confirmation"],L["If checked, clicking an upgrade icon will consume the item and upgrade the follower\n|cFFFF0000NO QUESTION ASKED|r"])
self:AddToggle("SWAPBUTTONS",false,L["Swap upgrades position"],L["IF checked, shows armors on the left and weapons on the right "])
self:AddLabel("Buildings Panel")
self:AddToggle("HF",false,L["Hide followers"],L["Do not show follower icon on plots"])
Expand Down Expand Up @@ -532,6 +532,8 @@ end
function addon:ApplyMAXMISSIONS(value)
MAXMISSIONS=value
BUSY_MESSAGE=format(BUSY_MESSAGE_FORMAT,MAXMISSIONS,MINPERC)
if ns.bigscreen and GMF.FollowerTab:IsVisible() then
end
end
function addon:ApplyMINPERC(value)
MINPERC=value
Expand Down Expand Up @@ -603,7 +605,7 @@ function addon:SetThreatColor(obj,threat)
end

function addon:HookedGarrisonMissionButton_AddThreatsToTooltip(missionID)
if (ns.ns.GMC:IsVisible()) then return end
if (ns.GMF.MissionControlTab:IsVisible()) then return end
return self:RenderTooltip(missionID)
end
function addon:AddIconsToFollower(missionID,useful,followers,members,followerTypeID)
Expand Down Expand Up @@ -1080,6 +1082,9 @@ function addon:AddOptionToOptionsLayer(o,flag,maxsize)
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=self:GetBoolean(flag)
Expand All @@ -1101,6 +1106,16 @@ function addon:AddOptionToOptionsLayer(o,flag,maxsize)
widget:SetCallback("OnClick",function(widget,event,value)
self[info.func](self,data,value)
end)
elseif (info.type=="range") then
local value=self:GetNumber(flag)
widget=AceGUI:Create("Slider")
widget:SetLabel(info.name)
widget:SetValue(value)
widget:SetSliderValues(info.min,info.max,info.step)
widget:SetWidth(maxsize)
widget:SetCallback("OnClick",function(widget,event,value)
self[info.func](self,data,value)
end)
else
widget=AceGUI:Create("Label")
widget:SetText(info.name)
Expand Down Expand Up @@ -1477,15 +1492,30 @@ print("Setup")
--collectgarbage("step",10)
--/Interface/FriendsFrame/UI-Toast-FriendOnlineIcon
end

function addon:RefreshMenu()
if not self.currentmenu or not self.currentmenu:IsVisible() then
self:RemoveMenu()
self:AddMenu()
end
end
function addon:AddMenu()
--@debug@
print("Adding Menu")
--@end-debug@
if GCF.Menu then
return
end
local menu,size=self:CreateOptionsLayer(MP and 'CKMP' or nil,'BIGSCREEN','IGM','IGP','NOFILL','MSORT','MAXRES','USEFUL')
local menu,size
if GMF.MissionTab:IsVisible() then
self.currentmenu=GMF.MissionTab
menu,size=self:CreateOptionsLayer(MP and 'CKMP' or nil,'BIGSCREEN','IGM','IGP','NOFILL','MSORT','MAXRES','USEFUL')
elseif GMF.FollowerTab:IsVisible() then
self.currentmenu=GMF.FollowerTab
menu,size=self:CreateOptionsLayer('BIGSCREEN',ns.bigscreen and 'MAXMISSIONS' or nil,ns.bigscreen and 'MINPERC' or nil,'ILV','IXP','UPG','NOCONFIRM','SWAPBUTTONS')
elseif GMF.MissionControlTab:IsVisible() then
self.currentmenu=GMF.MissionControlTab
menu,size=self:CreateOptionsLayer('BIGSCREEN')
end
--@debug@
self:AddOptionToOptionsLayer(menu,'DBG')
self:AddOptionToOptionsLayer(menu,'TRC')
Expand Down Expand Up @@ -2115,8 +2145,8 @@ end
function addon:OpenLastTab()
lastTab=lastTab or PanelTemplates_GetSelectedTab(GMF)
if lastTab then
if ns.GMC:IsVisible() then
ns.GMC:Hide()
if GMF.MissionControlTab:IsVisible() then
GMF.MissionControlTab:Hide()
GMF.tabMC:SetChecked(false)
if lastTab==2 then
GMF.FollowerTab:Show()
Expand All @@ -2140,19 +2170,20 @@ function addon:OpenMissionsTab()
return self:OpenLastTab()
end
function addon:OpenMissionControlTab()
if (not ns.GMC:IsVisible()) then
if (not GMF.MissionControlTab:IsVisible()) then
lastTab=PanelTemplates_GetSelectedTab(GMF)
GMF.FollowerTab:Hide()
GMF.FollowerList:Hide()
GMF.MissionTab:Hide()
GMF.TitleText:SetText(L["Garrison Commander Mission Control"])
ns.GMC:Show()
ns.GMC.startButton:Click()
GMF.MissionControlTab:Show()
GMF.MissionControlTab.startButton:Click()
GMF.tabMC:SetChecked(true)
else
GMF.tabMC:SetChecked(false)
self:OpenLastTab()
end
self:RefreshMenu()
end
function addon:OnClick_GarrisonMissionFrame_MissionComplete_NextMissionButton(this,button)
local frame = GMF.MissionComplete
Expand Down Expand Up @@ -2790,13 +2821,17 @@ function addon:HookedGarrisonMissionList_SetTab(tab)
for i=1,#GMFMissionListButtons do
GMFMissionListButtons.lastMissionID=nil
end
self:RefreshMenu()
if (HD) then addon:ResetSinks() end
end
function addon:HookedClickOnTabs(tab)
--@debug@
print(tab)
--@end-debug@
lastTab=tab
if GCF then
self:RefreshMenu()
end
end
function addon:GarrisonMissionFrame_SelectTab(frame,tab)
--@debug@
Expand All @@ -2810,8 +2845,9 @@ function addon:GarrisonMissionFrame_SelectTab(frame,tab)
if (HD) then addon:ResetSinks() end
if GMF.tabMC then
GMF.tabMC:SetChecked(false)
ns.GMC:Hide()
GMF.MissionControlTab:Hide()
end
self:RefreshMenu()
end
function addon:HookedGarrisonMissionButton_SetRewards(frame,rewards,numRewards)
collectgarbage("step",300)
Expand Down
35 changes: 12 additions & 23 deletions MissionControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ local factory=addon:GetFactory()
local aMissions={}
local chardb
local db
local GMC
local GMF=GarrisonMissionFrame
local GMCUsedFollowers={}
local wipe=wipe
Expand Down Expand Up @@ -100,6 +99,7 @@ function module:GMCRunMission(missionID,start)
--@debug@
print("Asked to start mission",missionID)
--@end-debug@
local GMC=GMF.MissionControlTab
if (start) then
G.StartMission(missionID)
PlaySound("UI_Garrison_CommandTable_MissionStart")
Expand Down Expand Up @@ -137,6 +137,7 @@ do
local currentMission=0
local x=0
function module:GMCCalculateMissions(this,elapsed)
local GMC=GMF.MissionControlTab
db.news.MissionControl=true
timeElapsed = timeElapsed + elapsed
if (#aMissions == 0 ) then
Expand Down Expand Up @@ -204,6 +205,7 @@ do
end

function module:GMC_OnClick_Run(this,button)
local GMC=GMF.MissionControlTab
this:Disable()
GMC.logoutButton:Disable()
do
Expand All @@ -224,7 +226,7 @@ function module:GMC_OnClick_Run(this,button)
end
end
function module:GMC_OnClick_Start(this,button)

local GMC=GMF.MissionControlTab
--@debug@
print(C("-------------------------------------------------","Yellow"))
--@end-debug@
Expand Down Expand Up @@ -256,6 +258,7 @@ print(C("-------------------------------------------------","Yellow"))
end
local chestTexture
local function drawItemButtons()
local GMC=GMF.MissionControlTab
local scale=1.1
local h=37 -- itemButtonTemplate standard size
local gap=5
Expand Down Expand Up @@ -404,8 +407,8 @@ function module:OnInitialized()
db=addon.db.global
chardb=addon.privatedb.profile
chestTexture='GarrMission-'..UnitFactionGroup('player').. 'Chest'
GMC = CreateFrame('FRAME', 'GMCOptions', GMF)
ns.GMC=GMC
local GMC = CreateFrame('FRAME', nil, GMF)
GMF.MissionControlTab=GMC
settings=chardb.missionControl
tOrder=settings.rewardOrder
if settings.version < 2 then
Expand Down Expand Up @@ -494,7 +497,7 @@ function module:OnInitialized()
return GMC
end
function module:GMCBuildChance()
_G['GMC']=GMC
local GMC=GMF.MissionControlTab
--Chance
GMC.cf = CreateFrame('FRAME', nil, GMC)
GMC.cf:SetSize(256, 150)
Expand Down Expand Up @@ -546,6 +549,7 @@ function module:GMCBuildChance()
return GMC.cf
end
local function timeslidechange(this,value)
local GMC=GMF.MissionControlTab
local value = math.floor(value)
if (this.max) then
settings.maxDuration = max(value,settings.minDuration)
Expand All @@ -561,6 +565,7 @@ local function timeslidechange(this,value)
end
function module:GMCBuildDuration()
-- Duration
local GMC=GMF.MissionControlTab
GMC.tf = CreateFrame('FRAME', nil, GMC)
GMC.tf:SetSize(256, 180)
GMC.tf:SetPoint('LEFT', 80, 120)
Expand Down Expand Up @@ -604,6 +609,7 @@ function module:GMCBuildDuration()
end
function module:GMCBuildRewards()
--Allowed rewards
local GMC=GMF.MissionControlTab
GMC.aif = CreateFrame('FRAME', nil, GMC)
GMC.itf = GMC.aif:CreateFontString()
GMC.itf:SetFontObject('GameFontNormalHuge')
Expand All @@ -616,25 +622,8 @@ function module:GMCBuildRewards()
end

function module:GMCBuildMissionList()
-- Mission list on follower panels
-- local ml=CreateFrame("Frame",nil,GMC)
-- addBackdrop(ml)
-- ml:Show()
-- ml.Missions={}
-- ml.Parties={}
-- GMC.ml=ml
-- local fs=ml:CreateFontString(nil, "BACKGROUND", "GameFontNormalHugeBlack")
-- fs:SetPoint("TOPLEFT",0,-5)
-- fs:SetPoint("TOPRIGHT",0,-5)
-- fs:SetText(READY)
-- fs:SetTextColor(C.Green())
-- fs:SetHeight(30)
-- fs:SetJustifyV("CENTER")
-- fs:Show()
-- GMC.progressText=fs
-- GMC.ml.Header=fs
-- return GMC.ml
local ml={widget=AceGUI:Create("GMCLayer"),Parties={}}
local GMC=GMF.MissionControlTab
ml.widget:SetTitle(READY)
ml.widget:SetTitleColor(C.Green())
ml.widget:SetTitleHeight(40)
Expand Down

0 comments on commit 9fd54ba

Please sign in to comment.