From 8aac2be136c5973b3c40969a5fc0eb1d45f0394d Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Fri, 25 Jan 2008 11:11:13 +0000 Subject: [PATCH] * Initial commit of a "Config" tab, that will be shown by default --- PerfectRaid.lua | 1 + PerfectRaid_Config.lua | 128 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 PerfectRaid_Config.lua diff --git a/PerfectRaid.lua b/PerfectRaid.lua index 0eeb728..74c835f 100644 --- a/PerfectRaid.lua +++ b/PerfectRaid.lua @@ -60,6 +60,7 @@ function PerfectRaid:Initialize() positions = {}, hideparty = true, showmanaonly = true, + clickcast = true, highlight = { mouseover = true, tooltip = false, diff --git a/PerfectRaid_Config.lua b/PerfectRaid_Config.lua new file mode 100644 index 0000000..d6bf6ab --- /dev/null +++ b/PerfectRaid_Config.lua @@ -0,0 +1,128 @@ +--[[------------------------------------------------------------------------- + Copyright (c) 2008, 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 Config = PerfectRaid:NewModule("PerfectRaid-Config") +local L = PerfectRaidLocals +local utils, frames + +function Config:Initialize() + self:RegisterMessage("DONGLE_PROFILE_CREATED") + self:RegisterMessage("PERFECTRAID_TAB_CHANGED") +end + +function Config:Enable() +end + +local options +function Config:CreateOptions(opt) + options = CreateFrame("Frame", "PROptions_Config", PROptions) + + opt:AddOptionsTab("Config", options) + + options.widgets = {} + + local check = CreateFrame("CheckButton", "PRConfig_HideParty", options, "PRCheckTemplate") + check.Label:SetText(L["Hide Blizzard Party Frames"]) + table.insert(options.widgets, check) + + local check = CreateFrame("CheckButton", "PRConfig_ShowManaOnly", options, "PRCheckTemplate") + check.Label:SetText(L["Only show mana bar for mana users"]) + table.insert(options.widgets, check) + + local check = CreateFrame("CheckButton", "PRConfig_ClickCast", options, "PRCheckTemplate") + check.Label:SetText(L["Enable click-casting on frames"]) + table.insert(options.widgets, check) + + local check = CreateFrame("CheckButton", "PRConfig_Lock", options, "PRCheckTemplate") + check.Label:SetText(L["Lock frames"]) + table.insert(options.widgets, check) + + local cancel = CreateFrame("Button", "PRConfig_Cancel", options, "PRButtonTemplate") + cancel:SetText(L["Cancel"]) + cancel:SetPoint("BOTTOMRIGHT", 0, 5) + cancel:SetScript("OnClick", function() options:CancelOptions() end) + cancel:Show() + + local save = CreateFrame("Button", "PRConfig_Save", options, "PRButtonTemplate") + save:SetText(L["Save"]) + save:SetPoint("BOTTOMRIGHT", cancel, "BOTTOMLEFT", -10, 0) + save:SetScript("OnClick", function() options:SaveOptions() end) + save:Show() + + function options:SaveOptions() + local mouseover = PRHighlight_Mouseover:GetChecked() and true or false + local tooltip = PRHighlight_Tooltip:GetChecked() and true or false + local disease = PRHighlight_Disease:GetChecked() and true or false + local curse = PRHighlight_Curse:GetChecked() and true or false + local magic = PRHighlight_Magic:GetChecked() and true or false + local poison = PRHighlight_Poison:GetChecked() and true or false + + PerfectRaid.db.profile.highlight.mouseover = mouseover + PerfectRaid.db.profile.highlight.tooltip = tooltip + PerfectRaid.db.profile.highlight.disease = disease + PerfectRaid.db.profile.highlight.curse = curse + PerfectRaid.db.profile.highlight.magic = magic + PerfectRaid.db.profile.highlight.poison = poison + + -- Trigger update here + for unit in pairs(frames) do + Highlight:UpdateUnit(unit) + end + end + + function options:CancelOptions() + local opt = PerfectRaid.db.profile.highlight + + PRHighlight_Mouseover:SetChecked(opt.mouseover) + PRHighlight_Tooltip:SetChecked(opt.tooltip) + PRHighlight_Disease:SetChecked(opt.disease) + PRHighlight_Curse:SetChecked(opt.curse) + PRHighlight_Magic:SetChecked(opt.magic) + PRHighlight_Poison:SetChecked(opt.poison) + + -- Trigger update here + for unit in pairs(frames) do + Highlight:UpdateUnit(unit) + end + end + + -- Force an update when tab is clicked + options:SetScript("OnShow", options.CancelOptions) + + for idx,widget in ipairs(options.widgets) do + widget:Show() + if idx == 1 then + widget:SetPoint("TOPLEFT", 0, 0) + else + widget:SetPoint("TOPLEFT", options.widgets[idx - 1], "BOTTOMLEFT", 0, -15) + end + end +end -- 1.7.9.5