Quantcast

v7.3.0 - Update and options

Pawel [10-15-17 - 11:51]
v7.3.0 - Update and options
Filename
MaxDps.toc
buttons.lua
core.lua
diff --git a/MaxDps.toc b/MaxDps.toc
index 52eb09b..a0481b6 100644
--- a/MaxDps.toc
+++ b/MaxDps.toc
@@ -1,8 +1,8 @@
 ## Title: MaxDps
 ## Notes: Rotation helper framework.
-## Version: 7.2.6
+## Version: 7.3.0
 ## Author: Kaminaris
-## Interface: 70200
+## Interface: 70300
 ## SavedVariables: MaxDpsOptions
 ## OptionalDependencies: Bartender4, ElvUI, ButtonForge, SVUI_ActionBars

diff --git a/buttons.lua b/buttons.lua
index e144c39..38cb8d8 100644
--- a/buttons.lua
+++ b/buttons.lua
@@ -4,7 +4,13 @@ MaxDps.SpellsGlowing = {};
 MaxDps.FramePool = {};
 MaxDps.Frames = {};

-function MaxDps:CreateOverlay(parent, id, texture, r, g, b)
+--- Creates frame overlay over a specific frame, it doesn't need to be a button.
+-- @param parent - frame that is suppose to be attached to
+-- @param id - string id of overlay because frame can have multiple overlays
+-- @param texture - optional custom texture
+-- @param type - optional type of overlay, standard types are 'normal' and 'cooldown' - used to select overlay color
+-- @param color - optional custom color in standard structure {r = 1, g = 1, b = 1, a = 1}
+function MaxDps:CreateOverlay(parent, id, texture, type, color)
 	local frame = tremove(self.FramePool);
 	if not frame then
 		frame = CreateFrame('Frame', 'MaxDps_Overlay_' .. id, parent);
@@ -26,12 +32,21 @@ function MaxDps:CreateOverlay(parent, id, texture, r, g, b)
 	end

 	t:SetAllPoints(frame);
-	t:SetVertexColor(
-		r or self.db.global.highlightColor.r,
-		g or self.db.global.highlightColor.g,
-		b or self.db.global.highlightColor.b,
-		self.db.global.highlightColor.a
-	);
+
+	if type then
+		frame.ovType = type;
+		if type == 'normal' then
+			local c = self.db.global.highlightColor;
+			t:SetVertexColor(c.r, c.g, c.b, c.a);
+		elseif type == 'cooldown' then
+			local c = self.db.global.cooldownColor;
+			t:SetVertexColor(c.r, c.g, c.b, c.a);
+		else
+			t:SetVertexColor(color.r, color.r, color.r, color.r);
+		end
+	else
+		t:SetVertexColor(color.r, color.g, color.b, color.a);
+	end

 	tinsert(self.Frames, frame);
 	return frame;
@@ -53,6 +68,24 @@ function MaxDps:DestroyAllOverlays()
 	end
 end

+function MaxDps:ApplyOverlayChanges()
+	for key, frame in pairs(self.Frames) do
+		local sizeMult = self.db.global.sizeMult or 1.4;
+		frame:SetWidth(frame:GetParent():GetWidth() * sizeMult);
+		frame:SetHeight(frame:GetParent():GetHeight() * sizeMult);
+		frame.texture:SetTexture(MaxDps:GetTexture());
+		frame.texture:SetAllPoints(frame);
+
+		if frame.ovType == 'normal' then
+			local c = self.db.global.highlightColor;
+			frame.texture:SetVertexColor(c.r, c.g, c.b, c.a);
+		elseif frame.ovType == 'cooldown' then
+			local c = self.db.global.cooldownColor;
+			frame.texture:SetVertexColor(c.r, c.g, c.b, c.a);
+		end
+	end
+end
+
 function MaxDps:UpdateButtonGlow()
 	local LAB;
 	local LBG;
@@ -88,7 +121,7 @@ function MaxDps:UpdateButtonGlow()
 	end
 end

-function MaxDps:Glow(button, id, r, g, b, texture)
+function MaxDps:Glow(button, id, texture, type, color)
 	if button.MaxDpsOverlays and button.MaxDpsOverlays[id] then
 		button.MaxDpsOverlays[id]:Show();
 	else
@@ -96,7 +129,7 @@ function MaxDps:Glow(button, id, r, g, b, texture)
 			button.MaxDpsOverlays = {};
 		end

-		button.MaxDpsOverlays[id] = self:CreateOverlay(button, id, texture, r, g, b);
+		button.MaxDpsOverlays[id] = self:CreateOverlay(button, id, texture, type, color);
 		button.MaxDpsOverlays[id]:Show();
 	end
 end
@@ -239,9 +272,8 @@ end
 function MaxDps:Dump()
 	local s = '';
 	for k, v in pairs(self.Spells) do
-		s = s .. ', ' .. k;
+		print(k);
 	end
-	print(s);
 end

 function MaxDps:FindSpell(spellName)
@@ -249,11 +281,11 @@ function MaxDps:FindSpell(spellName)
 	return self.Spells[name];
 end

-function MaxDps:GlowIndependent(spellName, id, r, g, b, texture)
+function MaxDps:GlowIndependent(spellName, id, texture, color)
 	local name = GetSpellInfo(spellName) or spellName;
 	if self.Spells[name] ~= nil then
 		for k, button in pairs(self.Spells[name]) do
-			self:Glow(button, id, r, g, b, texture);
+			self:Glow(button, id, texture, 'cooldown', color);
 		end
 	end
 end
@@ -273,7 +305,7 @@ function MaxDps:GlowCooldown(spell, condition)
 	end
 	if condition and not self.Flags[spell] then
 		self.Flags[spell] = true;
-		self:GlowIndependent(spell, spell, 0, 1, 0);
+		self:GlowIndependent(spell, spell);
 	end
 	if not condition and self.Flags[spell] then
 		self.Flags[spell] = false;
@@ -284,7 +316,7 @@ end
 function MaxDps:GlowSpell(spellName)
 	if self.Spells[spellName] ~= nil then
 		for k, button in pairs(self.Spells[spellName]) do
-			self:Glow(button, 'next');
+			self:Glow(button, 'next', nil, 'normal');
 		end
 		self.SpellsGlowing[spellName] = 1;
 	else
diff --git a/core.lua b/core.lua
index 943be0c..131b9f8 100644
--- a/core.lua
+++ b/core.lua
@@ -39,12 +39,22 @@ local defaultOptions = {
 		debugMode = false,
 		disableButtonGlow = false,
 		onCombatEnter = true,
-		texture = '',
+		texture = 'Interface\\Cooldown\\ping4',
 		customTexture = '',
 		highlightColor = {
-			r = 1, g = 1, b = 1, a = 1
+			r = 1,
+			g = 1,
+			b = 1,
+			a = 1
 		},
-		interval = 0.15
+		cooldownColor = {
+			r = 0,
+			g = 1,
+			b = 0,
+			a = 1
+		},
+		interval = 0.15,
+		sizeMult = 1.4
 	}
 }

@@ -53,115 +63,187 @@ local options = {
 	name = 'MaxDps Options',
 	inline = false,
 	args = {
-		enable = {
-			name = 'Enable',
-			desc = 'Enables / disables the addon',
-			type = 'toggle',
-			width = 'full',
-			set = function(info, val)
-				MaxDps.db.global.enabled = val;
-			end,
-			get = function(info) return MaxDps.db.global.enabled end
-		},
-		disabledInfo = {
-			name = 'Disable info messages',
-			desc = 'Enables / disables info messages, if you have issues with addon, make sure to deselect this.',
-			type = 'toggle',
-			width = 'full',
-			set = function(info, val)
-				MaxDps.db.global.disabledInfo = val;
-			end,
-			get = function(info) return MaxDps.db.global.disabledInfo end
-		},
-		debugMode = {
-			name = 'Enable debug mode',
-			desc = 'Enables spammy chat messages (use this when addon does not work for you)',
-			type = 'toggle',
-			width = 'full',
-			set = function(info, val)
-				MaxDps.db.global.debugMode = val;
-			end,
-			get = function(info) return MaxDps.db.global.debugMode end
+		general = {
+			order = 10,
+			name = 'General',
+			type = 'group',
+			args = {
+				enable = {
+					order = 10,
+					name = 'Enable',
+					desc = 'Enables / disables the addon',
+					type = 'toggle',
+					width = 'full',
+					set = function(info, val)
+						MaxDps.db.global.enabled = val;
+					end,
+					get = function(info) return MaxDps.db.global.enabled end
+				},
+				onCombatEnter = {
+					order = 20,
+					name = 'Enable upon entering combat',
+					desc = 'Automatically enables helper upon entering combat',
+					type = 'toggle',
+					width = 'full',
+					set = function(info, val)
+						MaxDps.db.global.onCombatEnter = val;
+					end,
+					get = function(info) return MaxDps.db.global.onCombatEnter end
+				},
+				disableButtonGlow = {
+					order = 30,
+					name = 'Dissable blizzard button glow (experimental)',
+					desc = 'Disables original blizzard button glow',
+					type = 'toggle',
+					width = 'full',
+					set = function(info, val)
+						MaxDps.db.global.disableButtonGlow = val;
+						MaxDps:UpdateButtonGlow();
+					end,
+					get = function(info) return MaxDps.db.global.disableButtonGlow end
+				},
+				interval = {
+					order = 40,
+					name = 'Interval in seconds',
+					desc = 'Sets how frequent rotation updates will be. Low value will result in fps drops.',
+					type = 'range',
+					min = 0.01,
+					max = 2,
+					set = function(info, val) MaxDps.db.global.interval = val end,
+					get = function(info) return MaxDps.db.global.interval end
+				},
+			}
 		},
-		disableButtonGlow = {
-			name = 'Dissable blizzard button glow (experimental)',
-			desc = 'Disables original blizzard button glow',
-			type = 'toggle',
-			width = 'full',
-			set = function(info, val)
-				MaxDps.db.global.disableButtonGlow = val;
-				MaxDps:UpdateButtonGlow();
-			end,
-			get = function(info) return MaxDps.db.global.disableButtonGlow end
+		debug = {
+			order = 30,
+			name = 'Debug options',
+			type = 'group',
+			args = {
+				debugMode = {
+					order = 10,
+					name = 'Enable debug mode',
+					desc = 'Enables spammy chat messages (use this when addon does not work for you)',
+					type = 'toggle',
+					width = 'full',
+					set = function(info, val)
+						MaxDps.db.global.debugMode = val;
+					end,
+					get = function(info) return MaxDps.db.global.debugMode end
+				},
+				disabledInfo = {
+					order = 20,
+					name = 'Disable info messages',
+					desc = 'Enables / disables info messages, if you have issues with addon, make sure to deselect this.',
+					type = 'toggle',
+					width = 'full',
+					set = function(info, val)
+						MaxDps.db.global.disabledInfo = val;
+					end,
+					get = function(info) return MaxDps.db.global.disabledInfo end
+				},
+			}
 		},
-		onCombatEnter = {
-			name = 'Enable upon entering combat',
-			desc = 'Automatically enables helper upon entering combat',
-			type = 'toggle',
-			width = 'full',
-			set = function(info, val)
-				MaxDps.db.global.onCombatEnter = val;
-			end,
-			get = function(info) return MaxDps.db.global.onCombatEnter end
-		},
-		customTexture = {
-			name = 'Custom Texture',
-			desc = 'Sets Highlight texture, has priority over selected one (changing this requires UI Reload)',
-			type = 'input',
-			set = function(info, val) MaxDps.db.global.customTexture = strtrim(val or ''); end,
-			get = function(info) return strtrim(MaxDps.db.global.customTexture or '') end
-		},
-		texture = {
-			type = 'select',
-			dialogControl = 'LSM30_Background',
-			name = 'Texture',
-			desc = 'Sets Highlight texture (changing this requires UI Reload)',
-			values = function()
-				return MaxDps.Textures;
-			end,
-			get = function()
-				return MaxDps.db.global.texture;
-			end,
-			set = function(self, val)
-				MaxDps.db.global.texture = val;
-			end,
-		},
-		highlightColor = {
-			name = 'Highlight color',
-			desc = 'Sets Highlight color',
-			type = 'color',
-			set = function(info, r, g, b, a)
-				MaxDps.db.global.highlightColor.r = r;
-				MaxDps.db.global.highlightColor.g = g;
-				MaxDps.db.global.highlightColor.b = b;
-				MaxDps.db.global.highlightColor.a = a;
-			end,
-			get = function(info)
-				return MaxDps.db.global.highlightColor.r, MaxDps.db.global.highlightColor.g, MaxDps.db.global.highlightColor.b, MaxDps.db.global.highlightColor.a;
-			end,
-			hasAlpha = true
-		},
-		interval = {
-			name = 'Interval in seconds',
-			desc = 'Sets how frequent rotation updates will be. Low value will result in fps drops.',
-			type = 'range',
-			min = 0.01,
-			max = 2,
-			set = function(info,val) MaxDps.db.global.interval = val end,
-			get = function(info) return MaxDps.db.global.interval end
-		},
-		sizeMult = {
-			name = 'Overlay size multiplier',
-			desc = 'Sets how big will be overlay on the button. 1 = exactly the same as button',
-			type = 'range',
-			min = 0.5,
-			max = 2,
-			set = function(info,val) MaxDps.db.global.sizeMult = val end,
-			get = function(info) return MaxDps.db.global.sizeMult or 1.4 end
+		overlay = {
+			order = 20,
+			name = 'Overlay settings',
+			type = 'group',
+			args = {
+				texture = {
+					order = 10,
+					type = 'select',
+					dialogControl = 'LSM30_Background',
+					name = 'Texture',
+					width = 'normal',
+					desc = 'Sets Highlight texture (changing this requires UI Reload)',
+					values = function()
+						return MaxDps.Textures;
+					end,
+					get = function()
+						return MaxDps.db.global.texture;
+					end,
+					set = function(self, val)
+						MaxDps.db.global.texture = val;
+						MaxDps:ApplyOverlayChanges();
+					end,
+				},
+				customTexture = {
+					order = 20,
+					name = 'Custom Texture',
+					desc = 'Sets Highlight texture, has priority over selected one (changing this requires UI Reload)',
+					type = 'input',
+					width = 'normal',
+					set = function(info, val)
+						MaxDps.db.global.customTexture = strtrim(val or '');
+						MaxDps:ApplyOverlayChanges();
+					end,
+					get = function(info) return strtrim(MaxDps.db.global.customTexture or '') end
+				},
+				highlightColor = {
+					order = 30,
+					name = 'Highlight color',
+					desc = 'Sets Highlight color',
+					type = 'color',
+					width = 'normal',
+					set = function(info, r, g, b, a)
+						local c = MaxDps.db.global.highlightColor;
+						c.r, c.g, c.b, c.a = r, g, b, a;
+						MaxDps:ApplyOverlayChanges();
+					end,
+					get = function(info)
+						local c = MaxDps.db.global.highlightColor;
+						return c.r, c.g, c.b, c.a;
+					end,
+					hasAlpha = true
+				},
+				cooldownColor = {
+					order = 40,
+					name = 'Cooldown color',
+					desc = 'Sets Cooldown color',
+					type = 'color',
+					width = 'normal',
+					set = function(info, r, g, b, a)
+						local c = MaxDps.db.global.cooldownColor;
+						c.r, c.g, c.b, c.a = r, g, b, a;
+						MaxDps:ApplyOverlayChanges();
+					end,
+					get = function(info)
+						local c = MaxDps.db.global.cooldownColor;
+						return c.r, c.g, c.b, c.a;
+					end,
+					hasAlpha = true
+				},
+				sizeMult = {
+					order = 50,
+					name = 'Overlay size multiplier',
+					desc = 'Sets how big will be overlay on the button. 1 = exactly the same as button',
+					type = 'range',
+					width = 'full',
+					min = 0.5,
+					max = 2,
+					set = function(info, val)
+						MaxDps.db.global.sizeMult = val;
+						MaxDps:ApplyOverlayChanges();
+					end,
+					get = function(info) return MaxDps.db.global.sizeMult or 1.4 end
+				},
+			}
 		},
+		reset = {
+			name = 'Reset settings',
+			desc = 'Resets settings to default values',
+			type = 'execute',
+			func = function()
+				MaxDps:ResetSettings();
+				MaxDps:ApplyOverlayChanges();
+			end
+		}
 	},
 }

+function MaxDps:ResetSettings()
+	self.db:ResetDB();
+end
+
 function MaxDps:GetTexture()
 	if self.db.global.customTexture ~= '' and self.db.global.customTexture ~= nil then
 		self.FinalTexture = self.db.global.customTexture;
@@ -177,7 +259,7 @@ function MaxDps:GetTexture()
 end

 function MaxDps:OnInitialize()
-	LibStub('AceConfig-3.0'):RegisterOptionsTable('MaxDps', options, {'/maxdps'});
+	LibStub('AceConfig-3.0'):RegisterOptionsTable('MaxDps', options, { '/maxdpsopts' });
 	self.db = LibStub('AceDB-3.0'):New('MaxDpsOptions', defaultOptions);
 	self.optionsFrame = LibStub('AceConfigDialog-3.0'):AddToBlizOptions('MaxDps', 'MaxDps');
 	self:RegisterChatCommand('maxdps', 'ShowCustomWindow');