Quantcast

* Helps if you add the file, artard!

James Whitehead II [01-01-07 - 23:15]
* Helps if you add the file, artard!
Filename
PerfectRaid_Hacks.lua
diff --git a/PerfectRaid_Hacks.lua b/PerfectRaid_Hacks.lua
new file mode 100644
index 0000000..93f0675
--- /dev/null
+++ b/PerfectRaid_Hacks.lua
@@ -0,0 +1,133 @@
+--[[-------------------------------------------------------------------------
+  Copyright (c) 2006, Jim Whitehead II <cladhaire@gmail.com>
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are
+  met:
+
+      * Redistributions of source code must retain the above copyright
+        notice, this list of conditions and the following disclaimer.
+      * Redistributions in binary form must reproduce the above
+        copyright notice, this list of conditions and the following
+        disclaimer in the documentation and/or other materials provided
+        with the distribution.
+      * Neither the name of PerfectRaid nor the names of its contributors
+        may be used to endorse or promote products derived from this software
+        without specific prior written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+---------------------------------------------------------------------------]]
+
+local Hacks = PerfectRaid:NewModule("PerfectRaid-Hacks")
+local frames
+
+function Hacks:Initialize()
+	PerfectRaid.defaults.profile.HacksScale = 1.0
+
+	frames = PerfectRaid.frames
+end
+
+function Hacks:Enable()
+end
+
+function Hacks:Disable()
+end
+
+function Hacks:DONGLE_PROFILE_CHANGED(event, addon, svname, name)
+end
+
+function Hacks:ShowButton(button)
+	self:UpdateScale()
+end
+
+local options
+function Hacks:CreateOptions(opt)
+	options = CreateFrame("Frame", "PROptions_Hacks", PROptions)
+	options:SetScript("OnShow", function() self:OnShow() end)
+
+	opt:AddOptionsTab("Hacks", options)
+
+	options.widgets = {}
+
+	local slider = CreateFrame("Slider", "PRHacks_Scale", options, "PRSliderTemplate")
+	slider.Text:SetText("Frame Scale")
+	slider.High:SetText("2.0")
+	slider.Low:SetText("0.1")
+	slider:SetMinMaxValues(0.1,2.0)
+	slider:SetValueStep(0.05)
+	table.insert(options.widgets, slider)
+
+	slider:SetScript("OnValueChanged", function(frame)
+		frame.Current:SetText(string.format("%0.2f", frame:GetValue()))
+		self:UpdateScale(frame:GetValue())
+	end)
+
+	local cancel = CreateFrame("Button", "PRHacks_Cancel", options, "PRButtonTemplate")
+	cancel.Label:SetText("Cancel")
+	cancel:SetPoint("BOTTOMRIGHT", 0, 5)
+	cancel:SetScript("OnClick", function() self:OnShow() end)
+	cancel:Show()
+
+	local save = CreateFrame("Button", "PRHacks_Save", options, "PRButtonTemplate")
+	save.Label:SetText("Save")
+	save:SetPoint("BOTTOMRIGHT", cancel, "BOTTOMLEFT", -10, 0)
+	save:SetScript("OnClick", function() self:SaveOptions() end)
+	save:Show()
+
+	for idx,widget in ipairs(options.widgets) do
+		widget:Show()
+		if idx == 1 then
+			widget:SetPoint("TOPLEFT", 0, -5)
+		else
+			widget:SetPoint("TOPLEFT", options.widgets[idx - 1], "BOTTOMLEFT", 0, -15)
+		end
+	end
+end
+
+function Hacks:OnShow()
+	local profile = PerfectRaid.db.profile
+
+	PRHacks_Scale:SetValue(profile.HacksScale)
+	self:UpdateScale()
+end
+
+function Hacks:SaveOptions()
+	local profile = PerfectRaid.db.profile
+
+	profile.HacksScale = PRHacks_Scale:GetValue()
+	self:UpdateScale()
+	self:SavePositions()
+end
+
+function Hacks:UpdateScale(val)
+	local scale = val or PerfectRaid.db.profile.HacksScale
+	for i=1,8 do
+		local name = "PRHeader"..i
+		local button = getglobal(name)
+		if button then
+			button:SetScale(scale)
+		end
+	end
+end
+
+function Hacks:SavePositions()
+	for i=1,8 do
+		local name = "PRHeader"..i
+		local button = getglobal(name)
+		if button then
+			PerfectRaid:SavePosition(name)
+		end
+	end
+end
+