Quantcast

Add an 'exactcolor' option for the waypoint arrow

James Whitehead II [07-08-12 - 10:40]
Add an 'exactcolor' option for the waypoint arrow

This will be used when you are moving within 98% accuracy of the
intended direction and can be useful for distinguishing between the
shades of 'good' and some value of 'exact'.
Filename
TomTom.lua
TomTom_Config.lua
TomTom_CrazyArrow.lua
diff --git a/TomTom.lua b/TomTom.lua
index 47553cf..ace2383 100755
--- a/TomTom.lua
+++ b/TomTom.lua
@@ -53,6 +53,7 @@ function TomTom:Initialize(event, addon)
                 goodcolor = {0, 1, 0},
                 badcolor = {1, 0, 0},
                 middlecolor = {1, 1, 0},
+				exactcolor = {0, 1, 0},
                 arrival = 15,
                 lock = false,
                 noclick = false,
diff --git a/TomTom_Config.lua b/TomTom_Config.lua
index ec5f03d..2cbde3f 100644
--- a/TomTom_Config.lua
+++ b/TomTom_Config.lua
@@ -63,7 +63,7 @@ local function createconfig()
 				order = 1,
 				type = "description",
 				name = L["TomTom provides you with a floating coordinate display that can be used to determine your current position.  These options can be used to enable or disable this display, or customize the block's display."],
-			},
+			},
 			enable = {
 				order = 2,
 				type = "toggle",
@@ -156,7 +156,7 @@ local function createconfig()

 	options.args.crazytaxi = {
 		type = "group",
-		order = 3,
+		order = 3,
 		name = L["Waypoint Arrow"],
 		get = get,
 		set = set,
@@ -165,7 +165,7 @@ local function createconfig()
 				order = 1,
 				type = "description",
 				name = L["TomTom provides an arrow that can be placed anywhere on the screen.  Similar to the arrow in \"Crazy Taxi\" it will point you towards your next waypoint"],
-			},
+			},
 			enable = {
 				order = 2,
 				type = "toggle",
@@ -358,9 +358,17 @@ local function createconfig()
 						arg = "arrow.badcolor",
 						hasAlpha = false,
 					},
+					exactcolor = {
+						order = 5,
+						type = "color",
+						name = L["Exact color"],
+						desc = L["The color to be displayed when you are moving in the exact direction of the active waypoint"],
+						arg = "arrow.exactcolor",
+						hasAlpha = false,
+					},
 				},
 			},
-		},
+		},
 	} -- End crazy taxi options

 	options.args.minimap = {
@@ -385,7 +393,7 @@ local function createconfig()
 			otherzone = {
 				type = "toggle",
 				name = L["Display waypoints from other zones"],
-				desc = L["TomTom can hide waypoints in other zones, this setting toggles that functionality"],
+				desc = L["TomTom can hide waypoints in other zones, this setting toggles that functionality"],
 				width = "double",
 				arg = "minimap.otherzone",
 				disabled = true,
@@ -430,7 +438,7 @@ local function createconfig()
 				order = 3,
 				type = "toggle",
 				name = L["Display waypoints from other zones"],
-				desc = L["TomTom can hide waypoints in other zones, this setting toggles that functionality"],
+				desc = L["TomTom can hide waypoints in other zones, this setting toggles that functionality"],
 				width = "double",
 				arg = "worldmap.otherzone",
 				disabled = true,
@@ -631,7 +639,7 @@ local function createconfig()
 				type = "range",
 				order = 4,
 				name = L["Clear waypoint distance"],
-				desc = L["Waypoints can be automatically cleared when you reach them.  This slider allows you to customize the distance in yards that signals your \"arrival\" at the waypoint.  A setting of 0 turns off the auto-clearing feature\n\nChanging this setting only takes effect after reloading your interface."],
+				desc = L["Waypoints can be automatically cleared when you reach them.  This slider allows you to customize the distance in yards that signals your \"arrival\" at the waypoint.  A setting of 0 turns off the auto-clearing feature\n\nChanging this setting only takes effect after reloading your interface."],
 				min = 0, max = 150, step = 1,
 				arg = "persistence.cleardistance",
 			},
@@ -658,7 +666,7 @@ local function createconfig()
 				order = 1,
 				type = "description",
 				name = L["TomTom can be configured to set waypoints for the quest objectives that are shown in the watch frame and on the world map.  These options can be used to configure these options."],
-			},
+			},
 			enable = {
 				order = 2,
 				type = "toggle",
diff --git a/TomTom_CrazyArrow.lua b/TomTom_CrazyArrow.lua
index 766e866..0bfe4c6 100644
--- a/TomTom_CrazyArrow.lua
+++ b/TomTom_CrazyArrow.lua
@@ -177,6 +177,13 @@ local function OnUpdate(self, elapsed)
 		local mr,mg,mb = unpack(TomTom.db.profile.arrow.middlecolor)
 		local br,bg,bb = unpack(TomTom.db.profile.arrow.badcolor)
 		local r,g,b = ColorGradient(perc, br, bg, bb, mr, mg, mb, gr, gg, gb)
+
+		-- If we're 98% heading in the right direction, then use the exact
+		-- color instead of the gradient. This allows us to distinguish 'good'
+		-- from 'on target'. Thanks to Gregor_Curse for the suggestion.
+		if perc > 0.98 then
+			r,g,b = unpack(TomTom.db.profile.arrow.exactcolor)
+		end
 		arrow:SetVertexColor(r,g,b)

 		local cell = floor(angle / twopi * 108 + 0.5) % 108