Mercurial > wow > devian
comparison Devian.lua @ 4:247118593c66
Console interface properly resides in XML, and has been fitted with a sizing widget.
Console frame can be moved by clicking and dragging anywhere, and can be minimized by right click.
Font paths point to the actual addon tree.
| author | Nenue |
|---|---|
| date | Fri, 18 Dec 2015 19:48:10 -0500 |
| parents | 77adceb8ebe4 |
| children | ac644fc860cc |
comparison
equal
deleted
inserted
replaced
| 3:957f42cb49d0 | 4:247118593c66 |
|---|---|
| 3 if not LibStub then | 3 if not LibStub then |
| 4 print('Something has happened...') | 4 print('Something has happened...') |
| 5 end | 5 end |
| 6 Devian = LibStub("AceAddon-3.0"):NewAddon("Devian", "AceConsole-3.0", "AceEvent-3.0") | 6 Devian = LibStub("AceAddon-3.0"):NewAddon("Devian", "AceConsole-3.0", "AceEvent-3.0") |
| 7 local D = _G.Devian | 7 local D = _G.Devian |
| 8 local db | |
| 9 local STATE_LOW, STATE_HIGH = 1, 2 | 8 local STATE_LOW, STATE_HIGH = 1, 2 |
| 10 local PLAYER_REALM = UnitName("player") .. '-' .. GetRealmName() | 9 local PLAYER_REALM = UnitName("player") .. '-' .. GetRealmName() |
| 11 local DEVIAN_FRAME = DevianDebugInfo | 10 local DEVIAN_FRAME = DevianConsole |
| 11 local cherry = false | |
| 12 if not DevianDB then | |
| 13 DevianDB = { | |
| 14 ['global'] = {[STATE_LOW] = {}, [STATE_HIGH] = {}}, | |
| 15 console = true, | |
| 16 dnd_status = true, | |
| 17 dnd_message = "Debugging. Your messages may get eaten.", | |
| 18 x = 100, | |
| 19 y = -150, | |
| 20 height = 500, | |
| 21 width = 600, | |
| 22 } | |
| 23 cherry = "This is probably the first time, so:\n /dvn 2 to save your regular addon list\n /dvn 1 to save your development addon list\n /dvn to switch between the two\n /dvc to toggle print() frame" | |
| 24 end | |
| 25 local db = DevianDB | |
| 26 | |
| 27 function D:SavePos(x,y) | |
| 28 db.y = DEVIAN_FRAME:GetTop() | |
| 29 db.x = DEVIAN_FRAME:GetLeft() | |
| 30 db.width = DEVIAN_FRAME:GetWidth() | |
| 31 db.height = DEVIAN_FRAME:GetHeight() | |
| 32 end | |
| 12 | 33 |
| 13 local ScanAddOnList = function(args) | 34 local ScanAddOnList = function(args) |
| 14 local list_state | 35 local list_state |
| 15 | 36 |
| 16 local mode = tonumber(args:match('^%d$')) | 37 local mode = tonumber(args:match('^%d$')) |
| 84 end | 105 end |
| 85 end | 106 end |
| 86 | 107 |
| 87 -- Debug info | 108 -- Debug info |
| 88 local function CreateMessenger() | 109 local function CreateMessenger() |
| 89 -- TODO: throw this into an XML file | 110 if db.console == true then |
| 90 if not DEVIAN_FRAME then | 111 DEVIAN_FRAME:Show() |
| 91 DEVIAN_FRAME = CreateFrame('ScrollingMessageFrame', DEVIAN_FRAME, UIParent) | 112 end |
| 92 if not db.console then | 113 |
| 93 DEVIAN_FRAME:Hide() | |
| 94 end | |
| 95 end | |
| 96 | 114 |
| 97 local f = DEVIAN_FRAME | 115 local f = DEVIAN_FRAME |
| 116 --[[ | |
| 98 f.backdrop = f:CreateTexture('backdrop', 'BACKGROUND') | 117 f.backdrop = f:CreateTexture('backdrop', 'BACKGROUND') |
| 99 f.backdrop:SetTexture(1,1,1,1) | 118 f.backdrop:SetTexture(1,1,1,1) |
| 100 f.backdrop:SetGradient('HORIZONTAL', 0.2, 0.2, 0.2, 1, 1, 1) | 119 f.backdrop:SetGradient('HORIZONTAL', 0.2, 0.2, 0.2, 1, 1, 1) |
| 101 f.backdrop:SetBlendMode('MOD') | 120 f.backdrop:SetBlendMode('MOD') |
| 102 f.backdrop:SetAllPoints(f) | 121 f.backdrop:SetAllPoints(f) |
| 103 f:AddMessage('init a thing') | 122 f:AddMessage('init a thing') |
| 104 | 123 |
| 105 f:EnableMouseWheel(true) | 124 f:EnableMouseWheel(true) |
| 106 f:EnableKeyboard(true) | 125 f:EnableKeyboard(true) |
| 107 f:SetScript('OnMouseWheel', function (self, delta) | 126 f:SetScript('OnMouseWheel', function (self, delta) |
| 108 local up = delta > 0 | |
| 109 if IsControlKeyDown() then | |
| 110 if up then self:ScrollToTop() | |
| 111 else self:ScrollToBottom() end | |
| 112 elseif IsShiftKeyDown() then | |
| 113 if up then self:PageUp() | |
| 114 else self:PageDown() end | |
| 115 else | |
| 116 if up then self:ScrollUp() | |
| 117 else self:ScrollDown() end | |
| 118 end | |
| 119 end) | 127 end) |
| 120 | 128 |
| 121 f:ScrollToBottom() | 129 f:ScrollToBottom() |
| 122 f:SetMaxLines(500) | 130 f:SetMaxLines(500) |
| 123 f:SetInsertMode('BOTTOM') | 131 --]] |
| 124 f:SetPoint('BOTTOMLEFT', GENERAL_CHAT_DOCK, 'TOPLEFT', 0, 25) | 132 f.console:SetInsertMode('BOTTOM') |
| 125 f:SetPoint('TOPRIGHT', UIParent, 'TOP', 0, 0- PlayerFrame:GetHeight()) | 133 f:SetPoint('CENTER', UIParent, 'CENTER', db.x, db.y) |
| 126 f:SetFrameStrata('BACKGROUND') | 134 f:SetSize(db.width, db.height) |
| 127 f:SetFont([[Interface\Addons\Turok\Media\font\SourceCodePro-Regular.ttf]], 14, 'NONE') | 135 f:Lower() |
| 128 | 136 f.console:SetFont([[Interface\Addons\Turok\Media\font\SourceCodePro-Regular.ttf]], 13, 'NONE') |
| 129 f:SetFading(false) | 137 |
| 130 f:SetTimeVisible(2147483647) | 138 f.console:SetFading(false) |
| 131 f:SetJustifyH('LEFT') | 139 f.console:SetTimeVisible(2147483647) |
| 140 --f:SetJustifyH('LEFT') | |
| 132 | 141 |
| 133 | 142 |
| 134 D.debug_init = true | 143 D.debug_init = true |
| 135 end | 144 end |
| 136 | 145 |
| 175 var = 'nil' | 184 var = 'nil' |
| 176 end | 185 end |
| 177 | 186 |
| 178 table.insert(buffer, var) | 187 table.insert(buffer, var) |
| 179 end | 188 end |
| 180 DEVIAN_FRAME:AddMessage(table.concat(buffer, ' ')) | 189 DEVIAN_FRAME.console:AddMessage(table.concat(buffer, ' ')) |
| 181 table.wipe(buffer) | 190 table.wipe(buffer) |
| 182 end | 191 end |
| 183 | 192 |
| 184 function D:OnEnable() | 193 function D:OnEnable() |
| 185 if db.enabled then | 194 if db.enabled then |
| 189 D:Print('Development AddOn list active. Type /dvn to revert to regular operation.') | 198 D:Print('Development AddOn list active. Type /dvn to revert to regular operation.') |
| 190 end | 199 end |
| 191 end | 200 end |
| 192 | 201 |
| 193 function D:OnInitialize() | 202 function D:OnInitialize() |
| 194 | |
| 195 local cherry = false | |
| 196 if not DevianDB then | |
| 197 DevianDB = { | |
| 198 ['global'] = {[STATE_LOW] = {}, [STATE_HIGH] = {}}, | |
| 199 console = true, | |
| 200 dnd_status = true, | |
| 201 dnd_message = "Debugging. Your messages may get eaten.", | |
| 202 } | |
| 203 cherry = "This is probably the first time, so:\n /dvn 2 to save your regular addon list\n /dvn 1 to save your development addon list\n /dvn to switch between the two\n /dvc to toggle print() frame" | |
| 204 end | |
| 205 db = DevianDB | |
| 206 | 203 |
| 207 if not db[PLAYER_REALM] then | 204 if not db[PLAYER_REALM] then |
| 208 db[PLAYER_REALM] = {[STATE_LOW] = {}, [STATE_HIGH] = {} } | 205 db[PLAYER_REALM] = {[STATE_LOW] = {}, [STATE_HIGH] = {} } |
| 209 if not cherry then | 206 if not cherry then |
| 210 cherry = "This character didn't have an AddOn table." | 207 cherry = "This character didn't have an AddOn table." |
