0
+-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info
0
+-- LibStub is hereby placed in the Public Domain
0
+-- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
0
+local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
0
+local LibStub = _G[LIBSTUB_MAJOR]
0
+-- Check to see is this version of the stub is obsolete
0
+if not LibStub or LibStub.minor < LIBSTUB_MINOR then
0
+ LibStub = LibStub or {libs = {}, minors = {} }
0
+ _G[LIBSTUB_MAJOR] = LibStub
0
+ LibStub.minor = LIBSTUB_MINOR
0
+ -- LibStub:NewLibrary(major, minor)
0
+ -- major (string) - the major version of the library
0
+ -- minor (string or number ) - the minor version of the library
0
+ -- returns nil if a newer or same version of the lib is already present
0
+ -- returns empty library object or old library object if upgrade is needed
0
+ function LibStub:NewLibrary(major, minor)
0
+ assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
0
+ minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
0
+ local oldminor = self.minors[major]
0
+ if oldminor and oldminor >= minor then return nil end
0
+ self.minors[major], self.libs[major] = minor, self.libs[major] or {}
0
+ return self.libs[major], oldminor
0
+ -- LibStub:GetLibrary(major, [silent])
0
+ -- major (string) - the major version of the library
0
+ -- silent (boolean) - if true, library is optional, silently return nil if its not found
0
+ -- throws an error if the library can not be found (except silent is set)
0
+ -- returns the library object if found
0
+ function LibStub:GetLibrary(major, silent)
0
+ if not self.libs[major] and not silent then
0
+ error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
0
+ return self.libs[major], self.minors[major]
0
+ -- LibStub:IterateLibraries()
0
+ -- Returns an iterator for the currently registered libraries
0
+ function LibStub:IterateLibraries()
0
+ return pairs(self.libs)
0
+ setmetatable(LibStub, { __call = LibStub.GetLibrary })
0
--[[-------------------------------------------------------------------------
0
Copyright (c) 2006-2007, Dongle Development Team
0
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0
---------------------------------------------------------------------------]]
0
-local major = "DongleStub"
0
-local minor = tonumber(string.match("$Revision: 313 $", "(%d+)") or 1)
0
-if not g.DongleStub or g.DongleStub:IsNewerVersion(major, minor) then
0
- local lib = setmetatable({}, {
0
- __call = function(t,k)
0
- if type(t.versions) == "table" and t.versions[k] then
0
- return t.versions[k].instance
0
- error("Cannot find a library with name '"..tostring(k).."'", 2)
0
- function lib:IsNewerVersion(major, minor)
0
- local versionData = self.versions and self.versions[major]
0
- -- If DongleStub versions have differing major version names
0
- -- such as DongleStub-Beta0 and DongleStub-1.0-RC2 then a second
0
- -- instance will be loaded, with older logic. This code attempts
0
- -- to compensate for that by matching the major version against
0
- -- "^DongleStub", and handling the version check correctly.
0
- if major:match("^DongleStub") then
0
- local oldmajor,oldminor = self:GetVersion()
0
- if self.versions and self.versions[oldmajor] then
0
- return minor > oldminor
0
- if not versionData then return true end
0
- local oldmajor,oldminor = versionData.instance:GetVersion()
0
- return minor > oldminor
0
- local function NilCopyTable(src, dest)
0
- for k,v in pairs(dest) do dest[k] = nil end
0
- for k,v in pairs(src) do dest[k] = v end
0
- function lib:Register(newInstance, activate, deactivate)
0
- assert(type(newInstance.GetVersion) == "function",
0
- "Attempt to register a library with DongleStub that does not have a 'GetVersion' method.")
0
- local major,minor = newInstance:GetVersion()
0
- assert(type(major) == "string",
0
- "Attempt to register a library with DongleStub that does not have a proper major version.")
0
- assert(type(minor) == "number",
0
- "Attempt to register a library with DongleStub that does not have a proper minor version.")
0
- -- Generate a log of all library registrations
0
- if not self.log then self.log = {} end
0
- table.insert(self.log, string.format("Register: %s, %s", major, minor))
0
- if not self:IsNewerVersion(major, minor) then return false end
0
- if not self.versions then self.versions = {} end
0
- local versionData = self.versions[major]
0
- if not versionData then
0
- ["instance"] = newInstance,
0
- ["deactivate"] = deactivate,
0
- self.versions[major] = versionData
0
- if type(activate) == "function" then
0
- table.insert(self.log, string.format("Activate: %s, %s", major, minor))
0
- local oldDeactivate = versionData.deactivate
0
- local oldInstance = versionData.instance
0
- versionData.deactivate = deactivate
0
- if type(activate) == "function" then
0
- table.insert(self.log, string.format("Activate: %s, %s", major, minor))
0
- skipCopy = activate(newInstance, oldInstance)
0
- -- Deactivate the old libary if necessary
0
- if type(oldDeactivate) == "function" then
0
- local major, minor = oldInstance:GetVersion()
0
- table.insert(self.log, string.format("Deactivate: %s, %s", major, minor))
0
- oldDeactivate(oldInstance, newInstance)
0
- -- Re-use the old table, and discard the new one
0
- NilCopyTable(newInstance, oldInstance)
0
- function lib:GetVersion() return major,minor end
0
- local function Activate(new, old)
0
- -- This code ensures that we'll move the versions table even
0
- -- if the major version names are different, in the case of
0
- if not old then old = g.DongleStub end
0
- new.versions = old.versions
0
- -- Actually trigger libary activation here
0
- local stub = g.DongleStub or lib
0
- lib = stub:Register(lib, Activate)
0
--[[-------------------------------------------------------------------------
0
Begin Library Implementation
0
---------------------------------------------------------------------------]]
0
-local major = "OptionHouse-1.0"
0
-local minor = tonumber(string.match("$Revision: 581 $", "(%d+)") or 1)
0
+local major = "OptionHouse-1.1"
0
+local minor = tonumber(string.match("$Revision: 619 $", "(%d+)") or 1)
0
-assert(
DongleStub, string.format("%s requires DongleStub.", major))
0
+assert(
LibStub, string.format("%s requires LibStub.", major))
0
-if( not DongleStub:IsNewerVersion(major, minor) ) then return end
0
+local OHInstance, oldRevision = LibStub:NewLibrary(major, minor)
0
+if( not OHInstance ) then return end
0
["ERROR_NO_FRAME"] = "No frame returned for the addon \"%s\", category \"%s\", sub category \"%s\".",
0
["NO_FUNC_PASSED"] = "You must associate a function with a category.",
0
- ["IS_PRIVATEAPI"] = "You are trying to call a private api from a non-OptionHouse module.",
0
["BAD_ARGUMENT"] = "bad argument #%d to '%s' (%s expected, got %s)",
0
["MUST_CALL"] = "You must call '%s' from an OptionHouse addon object.",
0
["ADDON_ALREADYREG"] = "The addon '%s' is already registered with OptionHouse.",
0
@@ -173,6 +103,7 @@ local L = {
0
["NO_SUBCATEXISTS"] = "No sub-category '%s' exists in '%s' for the addon '%s'.",
0
["NO_PARENTCAT"] = "No parent category named '%s' exists in %s'",
0
["SUBCATEGORY_ALREADYREG"] = "The sub-category named '%s' already exists in the category '%s' for '%s'",
0
+ ["UNKNOWN_FRAMETYPE"] = "Unknown frame type given '%s', only 'main', 'perf', 'addon', 'config' are supported.",
0
["OPTION_HOUSE"] = "Option House",
0
["ENTERED_COMBAT"] = "|cFF33FF99Option House|r: Configuration window closed due to entering combat.",
0
["SEARCH"] = "Search...",
0
@@ -182,7 +113,6 @@ local L = {
0
["TOTAL_SUBCATEGORIES"] = "Sub Categories: %d",
0
["TAB_MANAGEMENT"] = "Management",
0
["TAB_PERFORMANCE"] = "Performance",
0
- ["UNKNOWN_FRAMETYPE"] = "Unknown frame type requested '%s', only 'main', 'perf', 'addon', 'config' are supported.",
0
local function assert(level,condition,message)
0
@@ -217,10 +147,10 @@ local frame
0
local function resizeTab(tab)
0
local textWidth = tab:GetFontString():GetWidth()
0
tab.middleActive:SetWidth(textWidth)
0
tab.middleInactive:SetWidth(textWidth)
0
tab:SetWidth((2 * tab.leftActive:GetWidth()) + textWidth)
0
tab.highlightTexture:SetWidth(textWidth + 20)
0
@@ -228,11 +158,11 @@ end
0
local function tabSelected(tab)
0
tab:SetTextColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b)
0
tab.highlightTexture:Hide()
0
tab.middleActive:Show()
0
tab.leftInactive:Hide()
0
tab.middleInactive:Hide()
0
tab.rightInactive:Hide()
0
local function tabDeselected(tab)
0
tab:SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b)
0
tab.highlightTexture:Show()
0
tab.leftInactive:Show()
0
tab.middleInactive:Show()
0
tab.rightInactive:Show()
0
@@ -255,7 +185,7 @@ local function setTab(id)
0
if( frame.selectedTab ) then
0
tabDeselected(frame.tabs[frame.selectedTab])
0
tabSelected(frame.tabs[id])
0
@@ -315,12 +245,12 @@ local function createTab(text, id)
0
tab:SetScript("OnClick", tabOnClick)
0
tab:GetFontString():SetPoint("CENTER", 0, 2)
0
tab.highlightTexture = tab:GetHighlightTexture()
0
tab.highlightTexture:ClearAllPoints()
0
tab.highlightTexture:SetPoint("CENTER", tab:GetFontString(), 0, 0)
0
tab.highlightTexture:SetBlendMode("ADD")
0
-- TAB SELECTED TEXTURES
0
tab.leftActive = tab:CreateTexture(nil, "ARTWORK")
0
tab.leftActive:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-ActiveTab")
0
@@ -342,7 +272,7 @@ local function createTab(text, id)
0
tab.rightActive:SetWidth(20)
0
tab.rightActive:SetPoint("LEFT", tab.middleActive, "RIGHT")
0
tab.rightActive:SetTexCoord(0.84375, 1.0, 0, 1.0)
0
-- TAB DESELECTED TEXTURES
0
tab.leftInactive = tab:CreateTexture(nil, "ARTWORK")
0
tab.leftInactive:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-InActiveTab")
0
@@ -371,10 +301,10 @@ local function createTab(text, id)
0
tab:SetPoint("TOPLEFT", frame, "BOTTOMLEFT", 15, 11)
0
@@ -387,8 +317,8 @@ local function onVerticalScroll(self, offset)
0
self.bar:SetValue(offset)
0
- self.offset = ceil((offset / self.displayNum))
0
+ self.offset = ceil(offset / self.displayNum)
0
if( self.offset < 0 ) then
0
@@ -404,13 +334,14 @@ local function onVerticalScroll(self, offset)
0
if( max == offset ) then
0
local function onMouseWheel(self, offset)
0
+ if( self.scroll ) then self = self.scroll end
0
self.bar:SetValue(self.bar:GetValue() - (self.bar:GetHeight() / 2))
0
local function updateScroll(scroll, totalRows)
0
local max = (totalRows - scroll.displayNum) * scroll.displayNum
0
-- Macs are unhappy if max is less then the min
0
@@ -447,10 +378,26 @@ local function updateScroll(scroll, totalRows)
0
+local function onValueChanged(self, offset)
0
+ self:GetParent():SetVerticalScroll(offset)
0
+local function scrollButtonUp(self)
0
+ local parent = self:GetParent()
0
+ parent:SetValue(parent:GetValue() - (parent:GetHeight() / 2))
0
+ PlaySound("UChatScrollButton")
0
+local function scrollButtonDown(self)
0
+ local parent = self:GetParent()
0
+ parent:SetValue(parent:GetValue() + (parent:GetHeight() / 2))
0
+ PlaySound("UChatScrollButton")
0
local function createScrollFrame(frame, displayNum, onScroll)
0
frame:EnableMouseWheel(true)
0
frame:SetScript("OnMouseWheel", onParentMouseWheel)
0
frame.scroll = CreateFrame("ScrollFrame", nil, frame)
0
frame.scroll:EnableMouseWheel(true)
0
frame.scroll:SetWidth(16)
0
@@ -461,16 +408,14 @@ local function createScrollFrame(frame, displayNum, onScroll)
0
frame.scroll.offset = 0
0
frame.scroll.displayNum = displayNum
0
frame.scroll.updateFunc = onScroll
0
-- Actual bar for scrolling
0
frame.scroll.bar = CreateFrame("Slider", nil, frame.scroll)
0
frame.scroll.bar:SetValueStep(frame.scroll.displayNum)
0
frame.scroll.bar:SetMinMaxValues(0, 0)
0
frame.scroll.bar:SetValue(0)
0
frame.scroll.bar:SetWidth(16)
0
- frame.scroll.bar:SetScript("OnValueChanged", function(self, offset)
0
- self:GetParent():SetVerticalScroll(offset)
0
+ frame.scroll.bar:SetScript("OnValueChanged", onValueChanged)
0
frame.scroll.bar:SetPoint("TOPLEFT", frame.scroll, "TOPRIGHT", 6, -16)
0
frame.scroll.bar:SetPoint("BOTTOMLEFT", frame.scroll, "BOTTOMRIGHT", 6, -16)
0
@@ -478,21 +423,13 @@ local function createScrollFrame(frame, displayNum, onScroll)
0
frame.scroll.up = CreateFrame("Button", nil, frame.scroll.bar, "UIPanelScrollUpButtonTemplate")
0
frame.scroll.up:ClearAllPoints()
0
frame.scroll.up:SetPoint( "BOTTOM", frame.scroll.bar, "TOP" )
0
- frame.scroll.up:SetScript("OnClick", function(self)