From a126f73beae6d089a59fd47dffe7682cefd115b5 Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Mon, 1 Jan 2007 23:15:45 +0000 Subject: [PATCH] * Helps if you add the file, artard! --- PerfectRaid_Hacks.lua | 133 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 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 + 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 + -- 1.7.9.5