Skip to content

Instantly share code, notes, and snippets.

@ngerakines
Created December 20, 2009 08:54
Show Gist options
  • Select an option

  • Save ngerakines/260407 to your computer and use it in GitHub Desktop.

Select an option

Save ngerakines/260407 to your computer and use it in GitHub Desktop.
local EDGEGAP, ROWHEIGHT, ROWGAP, GAP = 16, 19, 2, 4
-- Core reminders anchor.
-- ----------------------
local anchor = CreateFrame("Button", nil, UIParent)
local rows = {}
local text = anchor:CreateFontString(nil, nil, "GameFontNormalSmall")
text:SetPoint("CENTER")
text:SetText("Remind Me")
anchor:SetWidth(text:GetStringWidth() + 16)
anchor:SetHeight(24)
anchor:SetBackdrop({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 16, insets = {left = 5, right = 5, top = 5, bottom = 5}, tile = true, tileSize = 16})
anchor:SetBackdropColor(0.09, 0.09, 0.19, 0.5)
anchor:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
anchor:SetMovable(true)
anchor:RegisterForDrag("LeftButton")
anchor:SetScript("OnDragStart", anchor.StartMoving)
anchor:SetScript("OnDragStop", function(self, button)
self:StopMovingOrSizing()
RemindMeDB.point, RemindMeDB.x, RemindMeDB.y = "BOTTOMLEFT", self:GetLeft(), self:GetBottom()
end)
anchor:SetScript("OnEvent", function(self, event, ...)
if self[event] then
return self[event](self, event, ...)
end
end)
anchor:RegisterEvent("ADDON_LOADED")
function anchor:ADDON_LOADED(event, addon)
if addon:lower() ~= "remindme" then return end
if not RemindMeDB then
RemindMeDB = {point = "CENTER", x = 0, y = 300, showanchor = true, font = "GameFontNormalLarge", tasks = {}}
end
anchor:SetPoint(RemindMeDB.point, RemindMeDB.x, RemindMeDB.y)
-- if not RemindMeDB.showanchor then
-- anchor:Hide()
-- end
self:UnregisterEvent("ADDON_LOADED")
self.ADDON_LOADED = nil
self:RegisterEvent("PLAYER_LOGOUT")
reload_reminders()
end
function reload_reminders()
local sortedtitles = {}
for title, data in pairs(RemindMeDB["tasks"]) do
table.insert(sortedtitles, title)
end
table.sort(sortedtitles, function(a,b) return string.lower(a) < string.lower(b) end)
local function OnClick(self)
print("check! " .. self.value)
end
local i, tmpanchor = 1
for i = 1,#sortedtitles do
print("Reminder: " .. sortedtitles[i]);
rows[i] = CreateFrame("Button", nil, anchor)
if not lastrow then
rows[i]:SetPoint("TOP", text, "BOTTOM", 0, -16)
else
rows[i]:SetPoint("TOP", lastrow, "BOTTOM", 0, -ROWGAP)
end
rows[i]:SetPoint("LEFT", EDGEGAP, 0)
rows[i]:SetPoint("RIGHT", -EDGEGAP*2-8, 0)
rows[i]:SetHeight(ROWHEIGHT)
lastrow = rows[i]
local check = CreateFrame("CheckButton", nil, row)
check:SetWidth(ROWHEIGHT+4)
check:SetHeight(ROWHEIGHT+4)
check:SetPoint("LEFT")
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")
check:SetScript("OnClick", OnClick)
rows[i].check = check
local tmpTitle = row:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
tmpTitle:SetPoint("LEFT", check, "RIGHT", 4, 0)
tmpTitle:SetText(sortedtitles[i])
rows[i].title = tmpTitle
i = i + 1
if i > 10 then return end
end
end
-- Config frame (Currently unused)
-- -------------------------------
local frame = CreateFrame("Frame", nil, InterfaceOptionsFramePanelContainer)
-- anchor:SetScript("OnClick", function(self) InterfaceOptionsFrame_OpenToCategory(frame) end)
frame.name = "Remind Me"
frame:Hide()
frame:SetScript("OnShow", function(self)
local sortedtitles = {}
for title, data in pairs(db) do
table.insert(sortedtitles, title)
end
table.sort(sortedtitles, function(a,b) return string.lower(a) < string.lower(b) end)
local title = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 16, -16)
title:SetText("Remind Me")
local subtitle = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
subtitle:SetHeight(35)
subtitle:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
subtitle:SetPoint("RIGHT", frame, -32, 0)
subtitle:SetNonSpaceWrap(true)
subtitle:SetJustifyH("LEFT")
subtitle:SetJustifyV("TOP")
subtitle:SetText("This panel can be used to remove and modify reminders.")
local rows, tmpanchor = {}
for i=1,#sortedtitles do
local row = CreateFrame("Button", nil, frame)
if not tmpanchor then row:SetPoint("TOP", subtitle, "BOTTOM", 0, -16)
else row:SetPoint("TOP", tmpanchor, "BOTTOM", 0, -ROWGAP) end
row:SetPoint("LEFT", EDGEGAP, 0)
row:SetPoint("RIGHT", -EDGEGAP*2-8, 0)
row:SetHeight(ROWHEIGHT)
tmpanchor = row
rows[i] = row
local check = CreateFrame("CheckButton", nil, row)
check:SetWidth(ROWHEIGHT+4)
check:SetHeight(ROWHEIGHT+4)
check:SetPoint("LEFT")
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")
row.check = check
local title = row:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
title:SetPoint("LEFT", check, "RIGHT", 4, 0)
title:SetText(sortedtitles[i])
row.title = title
end
end)
InterfaceOptions_AddCategory(frame)
SLASH_REMINDME1 = "/remindme"
SlashCmdList.REMINDME = function(msg)
local task = msg:match("^add (.*)$")
if task then
RemindMeDB["tasks"][task] = date()
reload_reminders()
else
print("Usage:");
print("/remindme add [Note]");
for title, data in pairs(RemindMeDB["tasks"]) do
print("Reminder title: " .. title)
end
end
end
## Interface: 30300
## Title: Remind Me
## Notes: None
## SavedVariables: RemindMeDB
## Dependencies:
remindme.lua
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment