-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleNotes.lua
More file actions
executable file
·91 lines (73 loc) · 2.58 KB
/
SimpleNotes.lua
File metadata and controls
executable file
·91 lines (73 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
-- Helper Functions
local function saveNotes(notes)
CharacterNotes = notes
end
local function getNotes()
return CharacterNotes or ""
end
local function printNotes()
print(getNotes())
end
-- UI
local simpleNotesFrame = CreateFrame("Frame", "SimpleNotesFrame", UIParent, "BasicFrameTemplate")
simpleNotesFrame:SetSize(300, 200)
simpleNotesFrame:SetPoint("CENTER")
simpleNotesFrame:SetMovable(true)
simpleNotesFrame:EnableMouse(true)
simpleNotesFrame:RegisterForDrag("LeftButton")
simpleNotesFrame:Hide()
local function toggleFrame()
if simpleNotesFrame:IsVisible() then
simpleNotesFrame:Hide()
else
simpleNotesFrame:Show()
end
end
-- Title
simpleNotesFrame.title = simpleNotesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
simpleNotesFrame.title:SetPoint("LEFT", simpleNotesFrame.TitleBg, "LEFT", 5, 0)
simpleNotesFrame.title:SetText("Simple Notes")
-- Scroll Frame
local editBoxWidth = 282
simpleNotesFrame.scrollFrame = CreateFrame("ScrollFrame", "SimpleNotesScrollFrame", simpleNotesFrame,
"InputScrollFrameTemplate")
simpleNotesFrame.scrollFrame:SetSize(editBoxWidth, 165)
simpleNotesFrame.scrollFrame:SetPoint("TOP", simpleNotesFrame, "TOP", -2, -28)
simpleNotesFrame.scrollFrame.CharCount:Hide()
-- Hide the scrollbar while allowing to scroll
simpleNotesFrame.scrollFrame.ScrollBar:SetAlpha(0)
-- Edit Box
simpleNotesFrame.notes = simpleNotesFrame.scrollFrame.EditBox
simpleNotesFrame.notes:SetMultiLine(true)
simpleNotesFrame.notes:SetAutoFocus(true)
simpleNotesFrame.notes:SetFontObject(ChatFontNormal)
simpleNotesFrame.notes:SetWidth(editBoxWidth)
simpleNotesFrame.notes:SetText(getNotes())
-- Slash Commands
SLASH_SIMPLENOTESSAVE1 = "/snsave"
SLASH_SIMPLENOTESPRINT1 = "/snprint"
SLASH_SIMPLENOTESTOGGLE1 = "/sn"
SlashCmdList["SIMPLENOTESSAVE"] = saveNotes
SlashCmdList["SIMPLENOTESPRINT"] = printNotes
SlashCmdList["SIMPLENOTESTOGGLE"] = toggleFrame
-- Event Handlers
local function handleAddonLoaded(addonName)
if addonName ~= "SimpleNotes" then
return
end
if CharacterNotes == nil then
CharacterNotes = ""
end
simpleNotesFrame.notes:SetText(getNotes())
end
simpleNotesFrame:RegisterEvent("ADDON_LOADED")
simpleNotesFrame:SetScript("OnEvent", function(self, event, arg1)
if event == "ADDON_LOADED" then
return handleAddonLoaded(arg1)
end
end)
simpleNotesFrame:SetScript("OnDragStart", simpleNotesFrame.StartMoving)
simpleNotesFrame:SetScript("OnDragStop", simpleNotesFrame.StopMovingOrSizing)
simpleNotesFrame.notes:SetScript("OnUpdate", function()
saveNotes(simpleNotesFrame.notes:GetText())
end)