diff Hansgar_And_Franzok_Assist.lua @ 11:2f09fe4be15c

Added an Options Panel.
author Tercio
date Mon, 20 Apr 2015 16:34:18 -0300
parents f1e32be6773e
children 6dd01dcec75e
line wrap: on
line diff
--- a/Hansgar_And_Franzok_Assist.lua	Mon Apr 06 19:41:32 2015 -0300
+++ b/Hansgar_And_Franzok_Assist.lua	Mon Apr 20 16:34:18 2015 -0300
@@ -1,3 +1,10 @@
+
+local DF = _G ["DetailsFramework"]
+if (not DF) then
+	print ("|cFFFFAA00Please restart your client to finish update some AddOns.|c")
+	return
+end
+
 local floor = floor
 local min = min
 local UnitExists = UnitExists
@@ -6,14 +13,41 @@
 local GetNumGroupMembers = GetNumGroupMembers
 local abs = abs
 local GetPlayerFacing = GetPlayerFacing
+local db
+local _
 
-local f = CreateFrame ("frame", "Hansgar_And_Franzok_Assist", UIParent)
+--local f = CreateFrame ("frame", "Hansgar_And_Franzok_Assist", UIParent)
+local f = DF:Create1PxPanel (_, 155, 166, "Hans & Franz", "Hansgar_And_Franzok_Assist", nil, "top") --
 f:SetFrameStrata ("DIALOG")
-f.version = "v0.11"
+f.version = "v0.12"
+
+f.Close:SetScript ("OnClick", function (self)
+	if (f.StampersPhase) then
+		return f:StopTracking()
+	end
+	f:EndTrackPlayerPosition()
+end)
+
+f.Lock:SetScript ("OnClick", function (self)
+	if (db.FRAME_LOCK) then
+		f:SetLockState()
+		print ("|cFFFFAA00Hansgar and Franzok Assist|r frame unlocked.")
+		
+		f.unlocked_frame = true
+		f.player_pos_frame:Show()
+		f.player_bar:Show()
+		f.stop_casting_frame:Show()
+	else
+		f:SetLockState()
+		print ("|cFFFFAA00Hansgar and Franzok Assist|r frame locked.")
+		f.unlocked_frame = false
+		f.stop_casting_frame:Hide()
+	end
+end)
 
 local tframe = CreateFrame ("frame", "Hansgar_And_Franzok_Assist_PTrack", UIParent)
 
-f:SetSize (155, 156)
+f:SetSize (155, 159)
 f:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, insets = {left = -1, right = -1, top = -1, bottom = -1},
 edgeFile = "Interface\\AddOns\\Hansgar_And_Franzok_Assist\\border_2", edgeSize = 8})
 f:SetPoint ("center", UIParent, "center", 300, 200)
@@ -24,10 +58,10 @@
 f.all_blocks = {}
 f:Hide()
 
-local title = f:CreateFontString (nil, "overlay", "GameFontNormal")
-title:SetText ("Hansgar & Franzok Assist")
-title:SetPoint ("center", f, "center")
-title:SetPoint ("bottom", f, "top", 0, 2)
+--local title = f:CreateFontString (nil, "overlay", "GameFontNormal")
+--title:SetText ("Hansgar & Franzok Assist")
+--title:SetPoint ("center", f, "center")
+--title:SetPoint ("bottom", f, "top", 0, 2)
 
 --
 local frame_event = CreateFrame ("frame", "Hansgar_And_Franzok_AssistEvents", f)
@@ -137,6 +171,7 @@
 	end
 end)
 player_pos_frame:Hide()
+f.player_pos_frame = player_pos_frame
 
 --red
 local t1 = player_pos_frame:CreateTexture (nil, "artwork")
@@ -240,8 +275,6 @@
 end
 f:RegisterComm ("HAFR", "CommReceived")
 
-local db
-
 f.block_tracker = {}
 
 frame_event:SetFrameStrata ("FULLSCREEN")
@@ -489,6 +522,15 @@
 		f:RefreshCooldownSettings()
 		
 	else
+	
+		if (f.StampersPhase) then
+			f:EndTrackPlayerPosition()
+			return f:StopTracking()
+		end
+		
+		f:StartTracking()
+		f:StartTrackPlayerPosition()
+	
 		print ("|cFFFFAA00Hansgar and Franzok Assist|r |cFF00FF00" .. f.version .. "|r Commands:")
 		print ("|cFFFFFF00/hansgar resetpos|r: reset the position of all frames.")
 		print ("|cFFFFFF00/hansgar lock|r: toggle lock and unlock on the frame.")
@@ -505,6 +547,185 @@
 
 --
 
+local options_panel = {
+	{
+		type = "range",
+		get = function() return db.STAMPERS_DELAY end,
+		set = function (self, fixedparam, value) db.STAMPERS_DELAY = value end,
+		min = 4,
+		max = 8,
+		step = 1,
+		desc = "Time in seconds to move out from a heating up stamper.",
+		name = "Stampers Delay",
+	},
+	{
+		type = "toggle",
+		get = function() return db.FRAME_LOCK end,
+		set = function (self, fixedparam, value) 
+			db.FRAME_LOCK = not value;
+			if (db.FRAME_LOCK) then
+				f:SetLockState()
+				print ("|cFFFFAA00Hansgar and Franzok Assist|r frame unlocked.")
+				
+				f.unlocked_frame = true
+				f.player_pos_frame:Show()
+				f.player_bar:Show()
+				f.stop_casting_frame:Show()
+			else
+				f:SetLockState()
+				print ("|cFFFFAA00Hansgar and Franzok Assist|r frame locked.")
+				f.unlocked_frame = false
+				f.stop_casting_frame:Hide()
+			end			
+		end,
+		desc = "Lock or unlock the frames.",
+		name = "Frame Locked"
+	},
+	{
+		type = "toggle",
+		get = function() return db.SHOW_DANCE end,
+		set = function (self, fixedparam, value) 
+			db.SHOW_DANCE = not db.SHOW_DANCE
+			if (db.SHOW_DANCE) then
+				if (f.on_encounter) then
+					f:StartTrackPlayerPosition()
+				end
+			else
+				f:EndTrackPlayerPosition()
+			end		
+		end,
+		desc = "Enable or disable the dance bar.",
+		name = "Dance Bar"
+	},
+	{
+		type = "toggle",
+		get = function() return db.CD_NUMBER end,
+		set = function (self, fixedparam, value) 
+			db.CD_NUMBER = not db.CD_NUMBER
+			f:RefreshCooldownSettings()
+		end,
+		desc = "When enabled, shows the number countdown on each block.",
+		name = "Show Cooldown Number"
+	},
+	{
+		type = "toggle",
+		get = function() return db.STOP_CAST end,
+		set = function (self, fixedparam, value) 
+			db.STOP_CAST = not db.STOP_CAST
+		end,
+		desc = "When enabled, shows an alert for Disrupting Roar.",
+		name = "Stop Cast Alert"
+	},
+	{
+		type = "execute",
+		func = function() 
+			if (f.StampersPhase) then
+				f:EndTrackPlayerPosition()
+				return f:StopTracking()
+			end
+			f:StartTracking()
+			f:StartTrackPlayerPosition()
+		end,
+		desc = "Test the addon, run over the tracks in the room.",
+		name = "Start Test Mode"
+	},
+	{
+		type = "execute",
+		func = function() 
+			f:ClearAllPoints()
+			f:SetPoint ("center", UIParent, "center")
+			
+			player_bar:ClearAllPoints()
+			player_bar:SetPoint ("center", UIParent, "center")
+			
+			player_pos_frame:ClearAllPoints()
+			player_pos_frame:SetPoint ("center", UIParent, "center")
+			
+			if (f.StampersPhase) then
+				f:EndTrackPlayerPosition()
+				f:StopTracking()
+			end
+			
+			db.FRAME_LOCK = true
+			f:SetLockState()
+			
+			f.unlocked_frame = true
+			
+			f:StartTracking()
+			f:StartTrackPlayerPosition()
+			
+			print ("|cFFFFAA00Hansgar and Franzok Assist|r: position reseted and frames are unlocked.")
+			print ("|cFFFFAA00Hansgar and Franzok Assist|r: move between the tracks to show the other frames.")
+		end,
+		desc = "Reset the position of all frames and start the test mode.",
+		name = "Reset Position"
+	},
+	{
+		type = "execute",
+		func = function() 
+			if (f.users_schedule) then
+				print ("|cFFFFAA00Hansgar and Franzok Assist|r please wait 5 seconds...")
+			elseif (IsInRaid()) then
+				f.users = {}
+				f:SendCommMessage ("HAFR", "US", "RAID")
+				f.users_schedule = f:ScheduleTimer ("ShowUsers", 5)
+				print ("|cFFFFAA00Hansgar and Franzok Assist|r please wait 5 seconds...")
+			else
+				print ("|cFFFFAA00Hansgar and Franzok Assist|r you aren't in a raid group.")
+			end
+		end,
+		desc = "Show raid members which are also using this addon.",
+		name = "Version Check"
+	},
+	{
+		type = "execute",
+		func = function() 
+			f.feedback_func()
+		end,
+		desc = "Send a feedback for us on our Curse page or MMO-Champion forum Thread.",
+		name = "Send Feedback"
+	},
+}
+
+local build_options_panel = function()
+	local options_frame = DF:CreateOptionsFrame ("HansgarFranzokAssistOptions", "Hans & Franz Assist", 1)
+	options_frame:SetHeight (180)
+	DF:BuildMenu (options_frame, options_panel, 15, -60, 180)
+	options_frame:SetBackdropColor (0, 0, 0, .9)
+end
+
+f.OpenOptionsPanel = function()
+	if (not HansgarFranzokAssistOptions) then
+		build_options_panel()
+	end
+	HansgarFranzokAssistOptions:Show()
+end
+
+-- /run Hansgar_And_Franzok_Assist.OpenOptionsPanel()
+local options = DF:CreateOptionsButton (f, f.OpenOptionsPanel, "Hansgar_And_Franzok_Assist_OPButton")
+options:SetPoint ("right", f.Lock, "left", 1, 0)
+f.Options = options
+
+--
+local feedback_func = function()
+	local feedback1 = {icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\feedback_sites]], coords = DF.www_icons.mmoc, desc = "Post on our thread on MMO-Champion Forum.", link = [[http://www.mmo-champion.com/threads/1725970-Hans-gar-and-Franzok-Assist-(addon)]]}
+	local feedback2 = {icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\feedback_sites]], coords = DF.www_icons.curse, desc = "Leave a comment on our page at Curse.com.", link = [[http://www.curse.com/addons/wow/hansgar_and_franzok_assist]]}
+	
+	local same1 = {name = "Details! Damage Meter", desc = "A Damage Meter with a lot of tools for raiders and leaders.", link = [[http://www.curse.com/addons/wow/details]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {0, 128/512, 0, 64/512}}
+	local same2 = {name = "Gold Token Price", desc = "Adds the slash command '/gold'. This command tells you the current price of WoW Token.", link = [[http://www.curse.com/addons/wow/gold-token-price]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {128/512, 256/512, 0, 64/512}}
+	local same3 = {name = "Salvage Yard Seller", desc = "Sells stuff gathered from salvage crates respecting item level limit.", link = [[http://www.curse.com/addons/wow/salvage-yard-seller]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {384/512, 512/512, 64/512, 128/512}}
+	local same4 = {name = "AddOns CPU Usage", desc = "Measure the CPU usage by addons. Important to get rid of FPS drops during boss encounters.", link = [[http://www.curse.com/addons/wow/addons-cpu-usage]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {384/512, 512/512, 0, 64/512}}
+	local same5 = {name = "Keep World Map Zoom", desc = "Because it's a pain having to re-zoom the world map after close and reopening in a short period of time.", link = [[http://www.curse.com/addons/wow/world-map-zoom]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {0/512, 128/512, 64/512, 128/512}}
+	local same6 = {name = "PvPScan", desc = "Show a unit frame with enemy players near you.", link = [[http://www.wowace.com/addons/pvpscan/]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {128/512, 256/512, 64/512, 128/512}}
+	local same7 = {name = "HotCorners", desc = "Show a hotcorner when poiting the mouse on the absolute top left of your screen (similar of those on Windows 8).", link = [[http://www.curse.com/addons/wow/hotcorners]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {256/512, 384/512, 64/512, 128/512}}
+	
+	DF:ShowFeedbackPanel ("Hans & Franz Assist", f.version, {feedback2, feedback1}, {same1, same2, same3, same4, same5, same6, same7})
+end
+f.feedback_func = feedback_func
+local feedback_button = DF:CreateFeedbackButton (f, feedback_func, "Hansgar_And_Franzok_AssistFBButton")
+feedback_button:SetPoint ("right", f.Options, "left", 0, -1)
+--
+
 local stop_casting_frame = CreateFrame ("frame", "Hansgar_And_Franzok_AssistStopCasting", UIParent)
 stop_casting_frame:SetSize (200, 30)
 stop_casting_frame:SetPoint ("center", UIParent, "center", 0, 75)