annotate Turok/Turok_Config.lua @ 6:a9b8b0866ece

clear out log jam
author Nenue
date Sun, 21 Feb 2016 08:32:53 -0500
parents
children
rev   line source
Nenue@6 1 -- User: Krakyn
Nenue@6 2 -- Created: 12/19/2015 12:18 AM
Nenue@6 3
Nenue@6 4 local _G = _G
Nenue@6 5 local T = LibStub("AceAddon-3.0"):GetAddon("Turok")
Nenue@6 6 local TL = 'Options'
Nenue@6 7 local mod = T:NewModule(TL)
Nenue@6 8 local LSM = LibStub("LibSharedMedia-3.0")
Nenue@6 9 local ConfigDialog = LibStub("AceConfigDialog-3.0")
Nenue@6 10 --@debug
Nenue@6 11 local print = function(...) _G.print(TL, ...) end
Nenue@6 12 local db
Nenue@6 13
Nenue@6 14 local TITLE_FONT_COLOR = '|cFF88FF44'
Nenue@6 15 local INPUT_FONT_COLOR = '|cFFFFFF00'
Nenue@6 16 local STACK_COLOR1 = '|cFFFF8800'
Nenue@6 17 local STACK_COLOR2 = '|cFFFFFF00'
Nenue@6 18 local FONTVAR_COLOR = '|cFFFFAA44'
Nenue@6 19 local FRAMEVAR_COLOR = '|cFFFFFF44'
Nenue@6 20 local PARAMETER_COLOR = '|cFF9999FF'
Nenue@6 21 local STATE_COLOR = '|cFFFF99FF'
Nenue@6 22
Nenue@6 23 function mod:OnInitialize()
Nenue@6 24 T:Print("config mod init")
Nenue@6 25 end
Nenue@6 26
Nenue@6 27 function mod:OnEnable()
Nenue@6 28 T:Print("config mod enable")
Nenue@6 29 db = T.db
Nenue@6 30 LibStub("AceConfig-3.0"):RegisterOptionsTable('Turok', T.MakeOptions(), {"turok"})
Nenue@6 31 T.configDialog = ConfigDialog:AddToBlizOptions("Turok")
Nenue@6 32 end
Nenue@6 33
Nenue@6 34 local optL = {
Nenue@6 35 background_color = 'Background color',
Nenue@6 36 foreground_color = 'Foreground color',
Nenue@6 37 width = FRAMEVAR_COLOR..'Width',
Nenue@6 38 height = FRAMEVAR_COLOR..'Height',
Nenue@6 39 alpha = FRAMEVAR_COLOR..'Alpha',
Nenue@6 40 alpha_ooc = STATE_COLOR..'Alpha (OOC)',
Nenue@6 41 label_strata = FONTVAR_COLOR..'Text Strata',
Nenue@6 42 label_font = FONTVAR_COLOR..'Font',
Nenue@6 43 label_size = FONTVAR_COLOR..'Font Size',
Nenue@6 44 label_inset = FONTVAR_COLOR..'Text Insets',
Nenue@6 45 foreground_blend = 'Foreground Blend Mode',
Nenue@6 46 background_blend = 'Background Blend Mode',
Nenue@6 47 isStatic = PARAMETER_COLOR..'Static Bar',
Nenue@6 48 duration = PARAMETER_COLOR..'Duration',
Nenue@6 49 isIcon = PARAMETER_COLOR..'Icon Only',
Nenue@6 50 }
Nenue@6 51
Nenue@6 52 local anchors = {
Nenue@6 53 ['CENTER'] = 'Center',
Nenue@6 54 ['TOPLEFT'] = 'Top Left',
Nenue@6 55 ['TOP'] = 'Top',
Nenue@6 56 ['TOPRIGHT'] = 'Top Right',
Nenue@6 57 ['RIGHT'] = 'Right',
Nenue@6 58 ['BOTTOMRIGHT'] = 'Bottom Right',
Nenue@6 59 ['BOTTOM'] = 'Bottom',
Nenue@6 60 ['BOTTOMLEFT'] = 'Bottom Left',
Nenue@6 61 ['LEFT'] = 'Left'
Nenue@6 62 }
Nenue@6 63
Nenue@6 64 local frames = {
Nenue@6 65 ['UIParent'] = 'UIParent',
Nenue@6 66 ['TkPowerBar'] = 'Power Bar',
Nenue@6 67 ['TekplayerCastBar'] = 'Player Castbar',
Nenue@6 68 ['TektargetCastBar'] = 'Target Castbar',
Nenue@6 69 ['TekfocusCastBar'] = 'Focus Castbar',
Nenue@6 70 ['TekpetCastBar'] = 'Pet Castbar'
Nenue@6 71 }
Nenue@6 72
Nenue@6 73 local range = {
Nenue@6 74 ['alpha'] = {0, 1, .01},
Nenue@6 75 ['alpha_ooc'] = {0, 1, .01},
Nenue@6 76 ['label_size'] = {1, 72, 1},
Nenue@6 77 ['label_inset'] = {-30, 30, 1},
Nenue@6 78 ['width'] = {0, 1200, 1},
Nenue@6 79 ['height'] = {0, 1200, 1},
Nenue@6 80 ['raidbuff_width'] = {0, 1200, 1},
Nenue@6 81 ['raidbuff_height'] = {0, 1200, 1},
Nenue@6 82 ['duration'] = {0, 6000, 0.1 },
Nenue@6 83 ['glow_size'] = {0, 30, 1},
Nenue@6 84 ['spark_size'] = {0, 30, 1},
Nenue@6 85 }
Nenue@6 86
Nenue@6 87 local opt_order = {
Nenue@6 88 ['width'] = 10,
Nenue@6 89 ['height'] = 15,
Nenue@6 90 ['anchor'] = 20,
Nenue@6 91 ['anchorTo'] = 25,
Nenue@6 92 ['parent'] = 30,
Nenue@6 93
Nenue@6 94 ['alpha'] = 110,
Nenue@6 95 ['alpha_ooc'] = 115,
Nenue@6 96 ['label_size'] = 200,
Nenue@6 97 ['label_inset'] = 210,
Nenue@6 98 ['label_font'] = 220,
Nenue@6 99
Nenue@6 100 ['background_texture'] = 300,
Nenue@6 101 ['background_color'] = 320,
Nenue@6 102 ['foreground_texture'] = 350,
Nenue@6 103 ['foreground_color'] = 370,
Nenue@6 104 }
Nenue@6 105 local opt_width = {
Nenue@6 106
Nenue@6 107 }
Nenue@6 108
Nenue@6 109 -- options dialog root
Nenue@6 110 T.myopts = {
Nenue@6 111 type = 'group',
Nenue@6 112 name = TITLE_FONT_COLOR..'Turok|r',
Nenue@6 113 desc = 'Dinosaur HUD',
Nenue@6 114 handler = T,
Nenue@6 115 set = function(info,value, ...)
Nenue@6 116 local db = T.db
Nenue@6 117 local index = db
Nenue@6 118 local traversal = 'db'
Nenue@6 119 for i = 1, #info-1 do
Nenue@6 120 if type(index[info[i]]) == 'table' then
Nenue@6 121 --print('|cFFFF0000SET|r:', i, info[i])
Nenue@6 122 traversal = traversal .. '.' .. info[i]
Nenue@6 123 index = index[info[i]]
Nenue@6 124 end
Nenue@6 125
Nenue@6 126 end
Nenue@6 127 --print('|cFFFF0000SET|r: hops=',#info,'index=', traversal, ' key=', info[#info])
Nenue@6 128
Nenue@6 129 if type(value) ~= 'boolean' and select('#',...) == 3 then
Nenue@6 130 --print('|cFFFF0000SET|r', 'multi-args', select('#',...))
Nenue@6 131 value = {value, ... }
Nenue@6 132 else
Nenue@6 133 --print('|cFFFF0000SET|r', 'single-arg', value)
Nenue@6 134 end
Nenue@6 135
Nenue@6 136 index[info[#info]] = value
Nenue@6 137 end,
Nenue@6 138 get = function(info)
Nenue@6 139 local db = T.db
Nenue@6 140 local value = db[info[1]]
Nenue@6 141 local traversal = info[1]
Nenue@6 142 if #info > 1 then
Nenue@6 143 for i=2, #info do
Nenue@6 144 traversal = traversal .. '.' .. info[i]
Nenue@6 145 if value[info[i]] ~= nil then
Nenue@6 146 value = value[info[i]]
Nenue@6 147 end
Nenue@6 148 end
Nenue@6 149 end
Nenue@6 150 --print('|cFFFF00FFGET|r: hops=', #info, 'index=', traversal, 'value=', value)
Nenue@6 151
Nenue@6 152 if type(value) == 'table' then
Nenue@6 153 return unpack(value)
Nenue@6 154 end
Nenue@6 155 return value
Nenue@6 156 end,
Nenue@6 157 }
Nenue@6 158
Nenue@6 159 function T:MakeOptions(dbtable, index, name, prefix)
Nenue@6 160 -- index = option insertion destination
Nenue@6 161 -- parent = nesting point
Nenue@6 162 local parent
Nenue@6 163 if not (index and dbtable) then
Nenue@6 164 dbtable = db
Nenue@6 165 name = 'root'
Nenue@6 166 prefix = ''
Nenue@6 167 parent = T.myopts
Nenue@6 168 parent.args = {
Nenue@6 169 main = {
Nenue@6 170 order = 1,
Nenue@6 171 type = 'group',
Nenue@6 172 name = 'Global',
Nenue@6 173 get = function(info) print('db.'..info[#info]..' get')
Nenue@6 174 if type(db[info[#info]]) == 'table' then
Nenue@6 175 print('getting color data', unpack(db[info[#info]]))
Nenue@6 176 return unpack(db[info[#info]])
Nenue@6 177 end
Nenue@6 178 return db[info[#info]]
Nenue@6 179 end,
Nenue@6 180 set = function(info, value, ...) print('db.'..info[#info]..' SET')
Nenue@6 181 if select('#',...) == 3 then
Nenue@6 182 print('receiving color data', value, ...)
Nenue@6 183 value = {value, ...}
Nenue@6 184 end
Nenue@6 185 db[info[#info]] = value
Nenue@6 186 end,
Nenue@6 187 args = {},
Nenue@6 188 }}
Nenue@6 189 index = parent.args.main
Nenue@6 190 print(STACK_COLOR1..'using TurokData as index')
Nenue@6 191 else
Nenue@6 192 index.type = 'group'
Nenue@6 193 index.name = name
Nenue@6 194 index.args = {}
Nenue@6 195 parent = index
Nenue@6 196 end
Nenue@6 197
Nenue@6 198 local order = 2
Nenue@6 199 for k, v in pairs(dbtable) do
Nenue@6 200 k = tostring(k)
Nenue@6 201 local kt = INPUT_FONT_COLOR .. (optL[k] or k)
Nenue@6 202 local nested = false
Nenue@6 203 --@debug@
Nenue@6 204 print(STACK_COLOR2..prefix..'.'..STACK_COLOR1..k..'|r =',v)--@debug@
Nenue@6 205 if type(v) == 'table' then
Nenue@6 206 if table.getn(v) == 4 then
Nenue@6 207 index.args[k] = {
Nenue@6 208 name = kt,
Nenue@6 209 type = 'color',
Nenue@6 210 hasAlpha = true,
Nenue@6 211 --@debug@
Nenue@6 212 print('color_pack=',unpack(v))--@debug@
Nenue@6 213 }
Nenue@6 214 else
Nenue@6 215 parent.args[k] = {}
Nenue@6 216 nested = true
Nenue@6 217 T:MakeOptions(v, parent.args[k], k, prefix .. '.' .. name)
Nenue@6 218 end
Nenue@6 219 elseif type(v) == 'string' then
Nenue@6 220 if string.match(k, "_font") then
Nenue@6 221 local font_list = {}
Nenue@6 222 for k, v in pairs(LSM:HashTable('font')) do
Nenue@6 223 font_list[v] = k
Nenue@6 224 end
Nenue@6 225 index.args[k] = {
Nenue@6 226 name = kt,
Nenue@6 227 type = 'select',
Nenue@6 228 values = font_list
Nenue@6 229 }
Nenue@6 230 elseif k:match('anchor$') or k:match('_point$') or k:match('anchorTo') then
Nenue@6 231
Nenue@6 232 index.args[k] = {
Nenue@6 233 name = kt,
Nenue@6 234 type = 'select',
Nenue@6 235 values = anchors
Nenue@6 236 }
Nenue@6 237
Nenue@6 238 elseif k:match('justifyH$') then
Nenue@6 239 index.args[k] = {
Nenue@6 240 name = kt,
Nenue@6 241 type = 'select',
Nenue@6 242 values = {
Nenue@6 243 ['LEFT'] = 'Left',
Nenue@6 244 ['CENTER'] = 'Center',
Nenue@6 245 ['RIGHT'] = 'Right'
Nenue@6 246 }
Nenue@6 247 }
Nenue@6 248
Nenue@6 249 elseif k:match('strata$') then
Nenue@6 250 index.args[k] = {
Nenue@6 251 name = kt,
Nenue@6 252 type = 'select',
Nenue@6 253 values = {
Nenue@6 254 BACKGROUND = 'BACKGROUND (clickthrough)',
Nenue@6 255 LOW = 'LOW',
Nenue@6 256 MEDIUM = 'MEDIUM',
Nenue@6 257 HIGH = 'HIGH',
Nenue@6 258 DIALOG = 'DIALOG',
Nenue@6 259 FULLSCREEN = 'FULLSCREEN',
Nenue@6 260 FULLSCREEN_DIALOG = 'FULLSCREEN_DIALOG',
Nenue@6 261 TOOLTIP = 'TOOLTIP (clickthrough)',
Nenue@6 262 }
Nenue@6 263 }
Nenue@6 264
Nenue@6 265 elseif k:match('outline$') then
Nenue@6 266 index.args[k] = {
Nenue@6 267 name = kt,
Nenue@6 268 type = 'select',
Nenue@6 269 values = {
Nenue@6 270 ['NONE'] = 'NONE',
Nenue@6 271 ['OUTLINE'] = 'OUTLINE',
Nenue@6 272 ['THICKOUTLINE'] = 'THICKOUTLINE'
Nenue@6 273 }
Nenue@6 274 }
Nenue@6 275 elseif k:match('parent') then
Nenue@6 276 index.args[k] = {
Nenue@6 277 name = kt,
Nenue@6 278 type = 'select',
Nenue@6 279 values = frames
Nenue@6 280 }
Nenue@6 281 else
Nenue@6 282
Nenue@6 283 index.args[k] = {
Nenue@6 284 name = kt,
Nenue@6 285 type = 'input',
Nenue@6 286 width = 'full',
Nenue@6 287 }
Nenue@6 288 end
Nenue@6 289 elseif type(v) == 'number' then
Nenue@6 290
Nenue@6 291 if not range[k] then
Nenue@6 292 range[k] = {0,150,1 }
Nenue@6 293 print('missing range values for', k)
Nenue@6 294 end
Nenue@6 295
Nenue@6 296 index.args[k] ={
Nenue@6 297 name = kt,
Nenue@6 298 type = 'range',
Nenue@6 299 min = range[k][1],
Nenue@6 300 max = range[k][2],
Nenue@6 301 softMax = range[k][2],
Nenue@6 302 step = range[k][3],
Nenue@6 303 bigStep = range[k][3],
Nenue@6 304 }
Nenue@6 305 elseif type(v) == 'boolean' then
Nenue@6 306
Nenue@6 307 index.args[k] = {
Nenue@6 308 name = kt,
Nenue@6 309 type = 'toggle',
Nenue@6 310 }
Nenue@6 311 end
Nenue@6 312 if nested then
Nenue@6 313 parent.args[k].order = order + (opt_order[k] and opt_order[k] or 0)
Nenue@6 314 elseif index.args[k] then
Nenue@6 315 index.args[k].order = order + (opt_order[k] and opt_order[k] or 0)
Nenue@6 316 print(' '..kt..' order = '..index.args[k].order)
Nenue@6 317 else
Nenue@6 318 print('|cFF99FFFFSkipped|r', kt)
Nenue@6 319 end
Nenue@6 320 end
Nenue@6 321
Nenue@6 322 return parent
Nenue@6 323 end