/
## X-Email: sekrin.ad@googlemail.com |
## X-Category: Miscellaneous |
libs\tekKonfig\tekKonfig.xml |
Thanks4Buff.lua |
local lib, oldminor = LibStub:NewLibrary("tekKonfig-TopTab", 1) |
if not lib then return end |
oldminor = oldminor or 0 |
function lib:activatetab() |
self.left:ClearAllPoints() |
self.left:SetPoint("TOPLEFT") |
self.left:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab") |
self.middle:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab") |
self.right:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab") |
self:Disable() |
end |
function lib:deactivatetab() |
self.left:ClearAllPoints() |
self.left:SetPoint("BOTTOMLEFT", 0, 2) |
self.left:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab") |
self.middle:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab") |
self.right:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab") |
self:Enable() |
end |
function lib:SetTextHelper(...) self:SetWidth(40 + self:GetFontString():GetStringWidth()); return ... end |
function lib:NewSetText(...) return lib.SetTextHelper(self, self.OrigSetText(self, ...)) end |
function lib.new(parent, text, ...) |
local tab = CreateFrame("Button", nil, parent) |
tab:SetHeight(24) |
tab:SetPoint(...) |
tab:SetFrameLevel(tab:GetFrameLevel() + 4) |
tab.left = tab:CreateTexture(nil, "BORDER") |
tab.left:SetWidth(20) tab.left:SetHeight(24) |
tab.left:SetTexCoord(0, 0.15625, 0, 1) |
tab.right = tab:CreateTexture(nil, "BORDER") |
tab.right:SetWidth(20) tab.right:SetHeight(24) |
tab.right:SetPoint("TOP", tab.left) |
tab.right:SetPoint("RIGHT", tab) |
tab.right:SetTexCoord(0.84375, 1, 0, 1) |
tab.middle = tab:CreateTexture(nil, "BORDER") |
tab.middle:SetHeight(24) |
tab.middle:SetPoint("LEFT", tab.left, "RIGHT") |
tab.middle:SetPoint("RIGHT", tab.right, "Left") |
tab.middle:SetTexCoord(0.15625, 0.84375, 0, 1) |
tab:SetHighlightTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight", "ADD") |
local hilite = tab:GetHighlightTexture() |
hilite:ClearAllPoints() |
hilite:SetPoint("LEFT", 10, -4) |
hilite:SetPoint("RIGHT", -10, -4) |
tab:SetDisabledFontObject(GameFontHighlightSmall) |
tab:SetHighlightFontObject(GameFontHighlightSmall) |
tab:SetNormalFontObject(GameFontNormalSmall) |
tab.OrigSetText = tab.SetText |
tab.SetText = lib.NewSetText |
tab:SetText(text) |
tab.Activate, tab.Deactivate = lib.activatetab, lib.deactivatetab |
tab:Activate() |
return tab |
end |
local lib, oldminor = LibStub:NewLibrary("tekKonfig-AboutPanel", 5) |
if not lib then return end |
function lib.new(parent, addonname) |
local frame = CreateFrame("Frame", nil, InterfaceOptionsFramePanelContainer) |
frame.name, frame.parent, frame.addonname = parent and "About" or addonname, parent, addonname |
frame:Hide() |
frame:SetScript("OnShow", lib.OnShow) |
InterfaceOptions_AddCategory(frame) |
return frame |
end |
local editbox = CreateFrame('EditBox', nil, UIParent) |
editbox:Hide() |
editbox:SetAutoFocus(true) |
editbox:SetHeight(32) |
editbox:SetFontObject('GameFontHighlightSmall') |
lib.editbox = editbox |
local left = editbox:CreateTexture(nil, "BACKGROUND") |
left:SetWidth(8) left:SetHeight(20) |
left:SetPoint("LEFT", -5, 0) |
left:SetTexture("Interface\\Common\\Common-Input-Border") |
left:SetTexCoord(0, 0.0625, 0, 0.625) |
local right = editbox:CreateTexture(nil, "BACKGROUND") |
right:SetWidth(8) right:SetHeight(20) |
right:SetPoint("RIGHT", 0, 0) |
right:SetTexture("Interface\\Common\\Common-Input-Border") |
right:SetTexCoord(0.9375, 1, 0, 0.625) |
local center = editbox:CreateTexture(nil, "BACKGROUND") |
center:SetHeight(20) |
center:SetPoint("RIGHT", right, "LEFT", 0, 0) |
center:SetPoint("LEFT", left, "RIGHT", 0, 0) |
center:SetTexture("Interface\\Common\\Common-Input-Border") |
center:SetTexCoord(0.0625, 0.9375, 0, 0.625) |
editbox:SetScript("OnEscapePressed", editbox.ClearFocus) |
editbox:SetScript("OnEnterPressed", editbox.ClearFocus) |
editbox:SetScript("OnEditFocusLost", editbox.Hide) |
editbox:SetScript("OnEditFocusGained", editbox.HighlightText) |
editbox:SetScript("OnTextChanged", function(self) |
self:SetText(self:GetParent().val) |
self:HighlightText() |
end) |
function lib.OpenEditbox(self) |
editbox:SetText(self.val) |
editbox:SetParent(self) |
editbox:SetPoint("LEFT", self) |
editbox:SetPoint("RIGHT", self) |
editbox:Show() |
end |
local fields = {"Version", "Author", "X-Category", "X-License", "X-Email", "X-Website", "X-Credits"} |
local haseditbox = {["Version"] = true, ["X-Website"] = true, ["X-Email"] = true} |
local function HideTooltip() GameTooltip:Hide() end |
local function ShowTooltip(self) |
GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT") |
GameTooltip:SetText("Click and press Ctrl-C to copy") |
end |
function lib.OnShow(frame) |
local notes = GetAddOnMetadata(frame.addonname, "Notes") |
local title = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge") |
title:SetPoint("TOPLEFT", 16, -16) |
title:SetText((frame.parent or frame.addonname).." - About") |
local subtitle = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall") |
subtitle:SetHeight(32) |
subtitle:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8) |
subtitle:SetPoint("RIGHT", parent, -32, 0) |
subtitle:SetNonSpaceWrap(true) |
subtitle:SetJustifyH("LEFT") |
subtitle:SetJustifyV("TOP") |
subtitle:SetText(notes) |
local anchor |
for _,field in pairs(fields) do |
local val = GetAddOnMetadata(frame.addonname, field) |
if val then |
local title = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall") |
title:SetWidth(75) |
if not anchor then title:SetPoint("TOPLEFT", subtitle, "BOTTOMLEFT", -2, -8) |
else title:SetPoint("TOPLEFT", anchor, "BOTTOMLEFT", 0, -6) end |
title:SetJustifyH("RIGHT") |
title:SetText(field:gsub("X%-", "")) |
local detail = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall") |
detail:SetPoint("LEFT", title, "RIGHT", 4, 0) |
detail:SetPoint("RIGHT", -16, 0) |
detail:SetJustifyH("LEFT") |
detail:SetText((haseditbox[field] and "|cff9999ff" or "").. val) |
if haseditbox[field] then |
local button = CreateFrame("Button", nil, frame) |
button:SetAllPoints(detail) |
button.val = val |
button:SetScript("OnClick", lib.OpenEditbox) |
button:SetScript("OnEnter", ShowTooltip) |
button:SetScript("OnLeave", HideTooltip) |
end |
anchor = title |
end |
end |
frame:SetScript("OnShow", nil) |
end |
local lib, oldminor = LibStub:NewLibrary("tekKonfig-Button", 5) |
if not lib then return end |
oldminor = oldminor or 0 |
if oldminor < 5 then |
local GameTooltip = GameTooltip |
local function HideTooltip() GameTooltip:Hide() end |
local function ShowTooltip(self) |
if self.tiptext then |
GameTooltip:SetOwner(self, "ANCHOR_RIGHT") |
GameTooltip:SetText(self.tiptext, nil, nil, nil, nil, true) |
end |
end |
-- Create a button. |
-- All args optional, parent recommended |
function lib.new(parent, ...) |
local butt = CreateFrame("Button", nil, parent) |
if select("#", ...) > 0 then butt:SetPoint(...) end |
butt:SetWidth(80) butt:SetHeight(22) |
-- Fonts -- |
butt:SetDisabledFontObject(GameFontDisable) |
butt:SetHighlightFontObject(GameFontHighlight) |
butt:SetNormalFontObject(GameFontNormal) |
-- Textures -- |
butt:SetNormalTexture("Interface\\Buttons\\UI-Panel-Button-Up") |
butt:SetPushedTexture("Interface\\Buttons\\UI-Panel-Button-Down") |
butt:SetHighlightTexture("Interface\\Buttons\\UI-Panel-Button-Highlight") |
butt:SetDisabledTexture("Interface\\Buttons\\UI-Panel-Button-Disabled") |
butt:GetNormalTexture():SetTexCoord(0, 0.625, 0, 0.6875) |
butt:GetPushedTexture():SetTexCoord(0, 0.625, 0, 0.6875) |
butt:GetHighlightTexture():SetTexCoord(0, 0.625, 0, 0.6875) |
butt:GetDisabledTexture():SetTexCoord(0, 0.625, 0, 0.6875) |
butt:GetHighlightTexture():SetBlendMode("ADD") |
-- Tooltip bits |
butt:SetScript("OnEnter", ShowTooltip) |
butt:SetScript("OnLeave", HideTooltip) |
return butt |
end |
function lib.new_small(parent, ...) |
local butt = lib.new(parent, ...) |
butt:SetHighlightFontObject(GameFontHighlightSmall) |
butt:SetNormalFontObject(GameFontNormalSmall) |
return butt |
end |
end |
local lib, oldminor = LibStub:NewLibrary("tekKonfig-Dropdown", 3) |
if not lib then return end |
oldminor = oldminor or 0 |
local GameTooltip = GameTooltip |
local function HideTooltip() GameTooltip:Hide() end |
local function ShowTooltip(self) |
if self.frame.tiptext then |
GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT") |
GameTooltip:SetText(self.frame.tiptext, nil, nil, nil, nil, true) |
end |
end |
local function ShowTooltip2(self) ShowTooltip(self.container) end |
local function OnClick(self) |
ToggleDropDownMenu(nil, nil, self:GetParent()) |
PlaySound("igMainMenuOptionCheckBoxOn") |
end |
local function OnHide() CloseDropDownMenus() end |
-- Create a dropdown. |
-- All args optional, parent recommended |
function lib.new(parent, label, ...) |
local container = CreateFrame("Button", nil, parent) |
container:SetWidth(149+13) container:SetHeight(32+24) |
container:SetScript("OnEnter", ShowTooltip) |
container:SetScript("OnLeave", HideTooltip) |
if select("#", ...) > 0 then container:SetPoint(...) end |
local name = "tekKonfigDropdown"..GetTime() -- Sadly, some of these frames must be named |
local f = CreateFrame("Frame", name, parent) |
f:SetWidth(149) f:SetHeight(32) |
f:SetPoint("TOPLEFT", container, -13, -24) |
f:EnableMouse(true) |
f:SetScript("OnHide", OnHide) |
container.frame = f |
local ltex = f:CreateTexture(name.."Left", "ARTWORK") |
ltex:SetWidth(25) ltex:SetHeight(64) |
ltex:SetPoint("TOPLEFT", 0, 17) |
ltex:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame") |
ltex:SetTexCoord(0, 0.1953125, 0, 1) |
local rtex = f:CreateTexture(nil, "ARTWORK") |
rtex:SetWidth(25) rtex:SetHeight(64) |
rtex:SetPoint("RIGHT") |
rtex:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame") |
rtex:SetTexCoord(0.8046875, 1, 0, 1) |
local mtex = f:CreateTexture(nil, "ARTWORK") |
mtex:SetWidth(115) mtex:SetHeight(64) |
mtex:SetPoint("LEFT", ltex, "RIGHT") |
mtex:SetPoint("RIGHT", rtex, "LEFT") |
mtex:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame") |
mtex:SetTexCoord(0.1953125, 0.8046875, 0, 1) |
local text = f:CreateFontString(name.."Text", "ARTWORK", "GameFontHighlightSmall") |
text:SetWidth(0) text:SetHeight(10) |
text:SetPoint("RIGHT", rtex, -43, 2) |
text:SetJustifyH("RIGHT") |
local button = CreateFrame("Button", nil, f) |
button:SetWidth(24) button:SetHeight(24) |
button:SetPoint("TOPRIGHT", rtex, -16, -18) |
button:SetScript("OnClick", OnClick) |
button:SetScript("OnEnter", ShowTooltip2) |
button.container = container |
button:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Up") |
button:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Down") |
button:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight") |
button:SetDisabledTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Disabled") |
button:GetHighlightTexture():SetBlendMode("ADD") |
local labeltext = f:CreateFontString(nil, "BACKGROUND", "GameFontNormal")--GameFontHighlight |
labeltext:SetPoint("BOTTOMLEFT", container, "TOPLEFT", 16-13, 3-24) |
labeltext:SetText(label) |
return f, text, container, labeltext |
end |
local lib, oldminor = LibStub:NewLibrary("tekKonfig-Group", 2) |
if not lib then return end |
lib.bg = { |
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", |
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", |
tile = true, |
tileSize = 16, |
edgeSize = 16, |
insets = { left = 5, right = 5, top = 5, bottom = 5 } |
} |
-- Creates a background box to place behind widgets for visual grouping. |
-- All args optional, parent highly recommended |
function lib.new(parent, label, ...) |
local box = CreateFrame('Frame', nil, parent) |
box:SetBackdrop(lib.bg) |
box:SetBackdropBorderColor(0.4, 0.4, 0.4) |
box:SetBackdropColor(0.1, 0.1, 0.1) |
if select('#',...) > 0 then box:SetPoint(...) end |
if label then |
local fs = box:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall") |
fs:SetPoint("BOTTOMLEFT", box, "TOPLEFT", 16, 0) |
fs:SetText(label) |
end |
return box |
end |
<Ui xmlns="http://www.blizzard.com/wow/ui/"> |
<Script file="LibStub.lua"/> |
<Script file="tekKonfigButton.lua"/> |
<Script file="tekKonfigCheckbox.lua"/> |
<Script file="tekKonfigFadeIn.lua"/> |
<Script file="tekKonfigHeading.lua"/> |
<Script file="tekKonfigScroll.lua"/> |
<Script file="tekKonfigSlider.lua"/> |
<Script file="tekKonfigDropdown.lua"/> |
<Script file="tekKonfigAboutPanel.lua"/> |
<Script file="tekKonfigGroup.lua"/> |
<Script file="tekKonfigTopTab.lua"/> |
</Ui> |
local lib, oldminor = LibStub:NewLibrary("tekKonfig-Scroll", 2) |
if not lib then return end |
lib.bg = { |
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", |
tile = true, |
tileSize = 16, |
edgeSize = 12, |
insets = { left = 0, right = 0, top = 5, bottom = 5 } |
} |
-- Creates a scrollbar |
-- Parent is required, offset and step are optional |
function lib.new(parent, offset, step) |
local f = CreateFrame("Slider", nil, parent) |
f:SetWidth(16) |
f:SetPoint("TOPRIGHT", 0 - (offset or 0), -16 - (offset or 0)) |
f:SetPoint("BOTTOMRIGHT", 0 - (offset or 0), 16 + (offset or 0)) |
local up = CreateFrame("Button", nil, f) |
up:SetPoint("BOTTOM", f, "TOP") |
up:SetWidth(16) up:SetHeight(16) |
up:SetNormalTexture("Interface\\Buttons\\UI-ScrollBar-ScrollUpButton-Up") |
up:SetPushedTexture("Interface\\Buttons\\UI-ScrollBar-ScrollUpButton-Down") |
up:SetDisabledTexture("Interface\\Buttons\\UI-ScrollBar-ScrollUpButton-Disabled") |
up:SetHighlightTexture("Interface\\Buttons\\UI-ScrollBar-ScrollUpButton-Highlight") |
up:GetNormalTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4) |
up:GetPushedTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4) |
up:GetDisabledTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4) |
up:GetHighlightTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4) |
up:GetHighlightTexture():SetBlendMode("ADD") |
up:SetScript("OnClick", function(self) |
local parent = self:GetParent() |
parent:SetValue(parent:GetValue() - (step or parent:GetHeight()/2)) |
PlaySound("UChatScrollButton") |
end) |
local down = CreateFrame("Button", nil, f) |
down:SetPoint("TOP", f, "BOTTOM") |
down:SetWidth(16) down:SetHeight(16) |
down:SetNormalTexture("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Up") |
down:SetPushedTexture("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Down") |
down:SetDisabledTexture("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Disabled") |
down:SetHighlightTexture("Interface\\Buttons\\UI-ScrollBar-ScrollDownButton-Highlight") |
down:GetNormalTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4) |
down:GetPushedTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4) |
down:GetDisabledTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4) |
down:GetHighlightTexture():SetTexCoord(1/4, 3/4, 1/4, 3/4) |
down:GetHighlightTexture():SetBlendMode("ADD") |
down:SetScript("OnClick", function(self) |
local parent = self:GetParent() |
parent:SetValue(parent:GetValue() + (step or parent:GetHeight()/2)) |
PlaySound("UChatScrollButton") |
end) |
f:SetThumbTexture("Interface\\Buttons\\UI-ScrollBar-Knob") |
local thumb = f:GetThumbTexture() |
thumb:SetWidth(16) thumb:SetHeight(24) |
thumb:SetTexCoord(1/4, 3/4, 1/8, 7/8) |
f:SetScript("OnValueChanged", function(self, value) |
local min, max = self:GetMinMaxValues() |
if value == min then up:Disable() else up:Enable() end |
if value == max then down:Disable() else down:Enable() end |
end) |
local border = CreateFrame("Frame", nil, f) |
border:SetPoint("TOPLEFT", up, -5, 5) |
border:SetPoint("BOTTOMRIGHT", down, 5, -3) |
border:SetBackdrop(lib.bg) |
border:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b, 0.5) |
return f, up, down, border |
end |
local lib, oldminor = LibStub:NewLibrary("tekKonfig-Heading", 1) |
if not lib then return end |
-- Creates a heading and subheading |
-- parent is required, texts are optional |
function lib.new(parent, text, subtext) |
local title = parent:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge") |
title:SetPoint("TOPLEFT", 16, -16) |
title:SetText(text) |
local subtitle = parent:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall") |
subtitle:SetHeight(32) |
subtitle:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8) |
subtitle:SetPoint("RIGHT", parent, -32, 0) |
--~ nonSpaceWrap="true" maxLines="3" |
subtitle:SetNonSpaceWrap(true) |
subtitle:SetJustifyH("LEFT") |
subtitle:SetJustifyV("TOP") |
subtitle:SetText(subtext) |
return title, subtitle |
end |
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info |
-- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke |
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! |
local LibStub = _G[LIBSTUB_MAJOR] |
if not LibStub or LibStub.minor < LIBSTUB_MINOR then |
LibStub = LibStub or {libs = {}, minors = {} } |
_G[LIBSTUB_MAJOR] = LibStub |
LibStub.minor = LIBSTUB_MINOR |
function LibStub:NewLibrary(major, minor) |
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") |
minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") |
local oldminor = self.minors[major] |
if oldminor and oldminor >= minor then return nil end |
self.minors[major], self.libs[major] = minor, self.libs[major] or {} |
return self.libs[major], oldminor |
end |
function LibStub:GetLibrary(major, silent) |
if not self.libs[major] and not silent then |
error(("Cannot find a library instance of %q."):format(tostring(major)), 2) |
end |
return self.libs[major], self.minors[major] |
end |
function LibStub:IterateLibraries() return pairs(self.libs) end |
setmetatable(LibStub, { __call = LibStub.GetLibrary }) |
end |
local lib, oldminor = LibStub:NewLibrary("tekKonfig-Slider", 3) |
if not lib then return end |
oldminor = oldminor or 0 |
local GameTooltip = GameTooltip |
local function HideTooltip() GameTooltip:Hide() end |
local function ShowTooltip(self) |
if self.tiptext then |
GameTooltip:SetOwner(self, "ANCHOR_RIGHT") |
GameTooltip:SetText(self.tiptext, nil, nil, nil, nil, true) |
end |
end |
local HorizontalSliderBG = { |
bgFile = "Interface\\Buttons\\UI-SliderBar-Background", |
edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", |
edgeSize = 8, tile = true, tileSize = 8, |
insets = {left = 3, right = 3, top = 6, bottom = 6} |
} |
if oldminor < 2 then |
-- Create a slider. |
-- All args optional, parent recommended |
-- If lowvalue and highvalue are strings it is assumed they are % values |
-- and the % is parsed and set as decimal values for min/max |
function lib.new(parent, label, lowvalue, highvalue, ...) |
local container = CreateFrame("Frame", nil, parent) |
container:SetWidth(144) |
container:SetHeight(17+12+10) |
if select(1, ...) then container:SetPoint(...) end |
local slider = CreateFrame("Slider", nil, container) |
slider:SetPoint("LEFT") |
slider:SetPoint("RIGHT") |
slider:SetHeight(17) |
slider:SetHitRectInsets(0, 0, -10, -10) |
slider:SetOrientation("HORIZONTAL") |
slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal") -- Dim: 32x32... can't find API to set this? |
slider:SetBackdrop(HorizontalSliderBG) |
local text = slider:CreateFontString(nil, "ARTWORK", "GameFontNormal") |
text:SetPoint("BOTTOM", slider, "TOP") |
text:SetText(label) |
local low = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall") |
low:SetPoint("TOPLEFT", slider, "BOTTOMLEFT", -4, 3) |
low:SetText(lowvalue) |
local high = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall") |
high:SetPoint("TOPRIGHT", slider, "BOTTOMRIGHT", 4, 3) |
high:SetText(highvalue) |
if type(lowvalue) == "string" then slider:SetMinMaxValues(tonumber((lowvalue:gsub("%%", "")))/100, tonumber((highvalue:gsub("%%", "")))/100) |
else slider:SetMinMaxValues(lowvalue, highvalue) end |
-- Tooltip bits |
slider:SetScript("OnEnter", ShowTooltip) |
slider:SetScript("OnLeave", HideTooltip) |
return slider, text, container, low, high |
end |
end |
-- Create a slider without labels. |
-- All args optional, parent recommended |
function lib.newbare(parent, ...) |
local slider = CreateFrame("Slider", nil, parent) |
slider:SetHeight(17) |
slider:SetWidth(144) |
if select(1, ...) then slider:SetPoint(...) end |
slider:SetOrientation("HORIZONTAL") |
slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal") -- Dim: 32x32... can't find API to set this? |
slider:SetBackdrop(HorizontalSliderBG) |
-- Tooltip bits |
slider:SetScript("OnEnter", ShowTooltip) |
slider:SetScript("OnLeave", HideTooltip) |
return slider |
end |
local lib, oldminor = LibStub:NewLibrary("tekKonfig-Checkbox", 1) |
if not lib then return end |
local GameTooltip = GameTooltip |
local function HideTooltip() GameTooltip:Hide() end |
local function ShowTooltip(self) |
if self.tiptext then |
GameTooltip:SetOwner(self, "ANCHOR_RIGHT") |
GameTooltip:SetText(self.tiptext, nil, nil, nil, nil, true) |
end |
end |
local function OnClick(self) PlaySound(self:GetChecked() and "igMainMenuOptionCheckBoxOn" or "igMainMenuOptionCheckBoxOff") end |
-- Creates a checkbox. |
-- All args optional but parent is highly recommended |
function lib.new(parent, size, label, ...) |
local check = CreateFrame("CheckButton", nil, parent) |
check:SetWidth(size or 26) |
check:SetHeight(size or 26) |
if select(1, ...) then check:SetPoint(...) end |
check:SetHitRectInsets(0, -100, 0, 0) |
check:SetNormalTexture("Interface\\Buttons\\UI-CheckBox-Up") |
check:SetPushedTexture("Interface\\Buttons\\UI-CheckBox-Down") |
check:SetHighlightTexture("Interface\\Buttons\\UI-CheckBox-Highlight") |
check:SetDisabledCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check-Disabled") |
check:SetCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check") |
-- Tooltip bits |
check:SetScript("OnEnter", ShowTooltip) |
check:SetScript("OnLeave", HideTooltip) |
-- Sound |
check:SetScript("OnClick", OnClick) |
-- Label |
local fs = check:CreateFontString(nil, "ARTWORK", "GameFontHighlight") |
fs:SetPoint("LEFT", check, "RIGHT", 0, 1) |
fs:SetText(label) |
return check, fs |
end |
local lib, oldminor = LibStub:NewLibrary("tekKonfig-FadeIn", 1) |
if not lib then return end |
local starttimes, endtimes, OnUpdates = {}, {}, {} |
local function OnUpdate(frame) |
local time = GetTime() |
if time >= (starttimes[frame] + endtimes[frame]) then |
frame:SetScript("OnUpdate", OnUpdates[frame]) |
frame:SetAlpha(1) |
else frame:SetAlpha((time - starttimes[frame])/endtimes[frame]) end |
end |
-- Fades in a frame, if time is not passed 0.5sec is used |
function lib.FadeIn(frame, time) |
time = time or 0.5 |
assert(frame, "No frame passed") |
assert(time > 0, "Time must be positive") |
starttimes[frame], endtimes[frame], OnUpdates[frame] = GetTime(), time, frame:GetScript("OnUpdate") |
frame:SetAlpha(0) |
frame:SetScript("OnUpdate", OnUpdate) |
end |