Mercurial > wow > turok
view Turok/Modules/Timer/Editor.lua @ 9:9400a0ff8540
Ugh
Timer:
- container update directionality
- talent update iterates over a non-volatile table to carry out updates
- index management steps organized
- talentRow status implemented, returns the spell associated with the talent chosen from that row
CombatLog:
- sort out font controls and unbork arguments
author | Nenue |
---|---|
date | Sun, 21 Feb 2016 13:08:30 -0500 |
parents | a9b8b0866ece |
children |
line wrap: on
line source
--- Modules -- @file-author@ -- @project-revision@ @project-hash@ -- @file-revision@ @file-hash@ -- Created: 1/18/2016 3:33 PM local _G = _G local T, type, pairs = _G.Turok, type, pairs local mod = T.modules.TimerControl local cType, cText, cNum, cWord, cKey, cPink, cBool = cType, cText, cNum, cWord, cKey, cPink, cBool local print = function(...) if Devian and DevianDB.workspace ~= 1 then print('Dialog', ...) end end local TimerConfig = { conf = { padding = 4, spacing = 1, width = 450, }, info = { { key = 'timerName', desc = 'Unique Name:', type='EditBox', name = 'timerName', fill=true, line = true, }, { key = 'spellEnable', inherits = 'TurokCheckButtonOverlay', type='CheckButton', name = 'spellEnable', fixed=25, point='LEFT', get = Dialog_Boolean, getarg = 'spellID', collapse = true, desc = 'Spell Name', }, { key = 'spellID', type='EditBox', name = 'spellName', line = true, float = true }, { key = 'fill_inverse', desc = 'Reverse Fill', type='CheckButton', name='fillInverse', fixed=25, point='LEFT', get = Dialog_Boolean, getarg = 'fill_inverse', text='Inverted Fill', line = true, }, { key = 'display', desc = 'Display Type', type='EditBox', name='displayType', line = true, }, }, } local Dialog_SetField = {} local dget = function(name, key) if mod.db.timers[name] then return mod.db.timers[name][key] end return nil end local inherits = { EditBox = 'TkEditBox', CheckButton = 'TurokCheckButtonInline', Slider = 'TkSlider', } Dialog_SetField['CheckButton'] = function(self, checked) self:SetChecked(checked) end Dialog_SetField['EditBox'] = function(self, text) print(' ', cKey(self:GetName()), text) self:SetText(text or '') end Dialog_SetField['Button'] = function(self, text) self:SetText(text) end local function Dialog_Boolean(name, key) print(' Dialog_Boolean', name, key) return (mod.db.timers[name][key] and true or false) end function mod.Dialog_Select(self, key) local timer if self.parent_values[key] then print('matched timer name', key) timer = self.parent_values[key] elseif rawget(mod.frames.spellID, key) then print('matched spellID', key) timer = mod.frames.spellID[key][1] for k,v in pairs(timer) do print(' -', k, '=', v) end end if timer then self.values = timer self.timerName = timer.timerName else self.values = { timerName = 'New Timer' } self.timerName = 'New Timer' end mod.Dialog_Init(self, TimerConfig.conf, TimerConfig.info) end function mod.Dialog_Init(self, dconf, dinfo) print('init,', self.values.timerName) if not self.fields then self.fields = {} self.rows = {} self.Click = mod.Dialog_Click self.Check = mod.Dialog_Check self.EditBox = mod.Dialog_EditBox end print(self.name, self.timerName) self.name:SetText(self.timerName) local inset = dconf.padding + dconf.spacing -- frame X max local fX = 0 -- row number, row Y offset local rn, ry = 1, -34 -- row x offset left-align, row x offset right-aligned, largest collapsed element local rxL, rxR, rC, rh = dconf.spacing, dconf.spacing, 0, 0 for i, opt in ipairs(dinfo) do if not self.rows[rn] then self.rows[rn] = CreateFrame('Frame', self:GetName()..'Row'..rn, self, 'TurokDialogRow') end local k = opt.key if self.fields[i] == nil then self.fields[i] = CreateFrame(opt.type, self:GetName()..opt.name, self.rows[rn], opt.inherits or inherits[opt.type]) self.fields[i].index = i self.fields[i].key = k -- row point (from), row point (to), row x offset local rp, rpt, rx -- row delta local rd if opt.fill then rpt = opt.float and 'BOTTOMLEFT' or 'BOTTOMRIGHT' -- row point X offset local rpx = opt.float and dconf.spacing or -dconf.spacing self.fields[i]:SetPoint(rpt, self.rows[rn], rpt, rpx, 0) print(' fill:', rpt, '-', rpt,' :: ', rpx, 0) rd = 0 else rd = self.fields[i]:GetWidth() + dconf.spacing end if opt.float then rp = 'BOTTOMRIGHT' rx = -rxR rxR = rxR + rd elseif opt.collapse then rp = 'BOTTOMLEFT' rx = dconf.spacing rC = math.max(rC, rd + dconf.spacing) -- spacing L + rd{width + spacing R} else rp = 'BOTTOMLEFT' rx = rxL rxL = rxL + rd end rh = math.max(rh, self.fields[i]:GetHeight()) self.fields[i]:SetPoint(rp, self.rows[rn], rp, rx, dconf.spacing) print(' align:', rp, '-', rp, ' :: ', rx, 0) print(' dR:', cNum(rd), 'nR:',cWord(rn), 'rX:', cNum(rx), 'i:', cText(i)) if opt.line or (not dinfo[i+1]) then print(cText'nR:', cNum(rn), 'rY:', cNum(ry)) self.rows[rn]:ClearAllPoints() self.rows[rn]:SetPoint('TOPLEFT', self, 'TOPLEFT', dconf.padding, ry) self.rows[rn]:SetPoint('TOPRIGHT', self, 'TOPRIGHT', -dconf.padding, ry) self.rows[rn]:SetHeight(rh + dconf.spacing*2) self.rows[rn]:Show() rn = rn + 1 ry = ry - (rh + dconf.spacing*3) -->| {spacing T + rh + spacing B} + spacing dR |<-- print('fX:',cNum(fX), 'rX:', cNum(rxL+rxR+dconf.spacing), 'rC:', cNum(rC)) fX = math.max(fX, rxL+rxR+dconf.spacing) fX = math.max(fX, rC) rxL, rxR = dconf.spacing, dconf.spacing rh = 0 end end self.fields[i]:Show() if opt.desc and self.fields[i].description then self.fields[i].description:SetText(opt.desc) end Dialog_SetField[opt.type](self.fields[i], opt.get and opt.get(self.values.timerName, opt.getarg) or self.values[k]) end if not self.initialized then self.initialized = true self:SetSize(fX + dconf.padding + dconf.spacing*2, dconf.padding + math.abs(ry)) end end function mod.Dialog_Click(self,...) local command = self:GetName():match("_(a%+)$") print(command) end function mod.Dialog_Check(self, ...) print('field #', self.index, self.key, 'checked') --self:SetChecked(self:GetChecked() and false or true) end function mod.Dialog_EditBox(self, ...) print('field #', self.index, self.key, 'changed', self:GetText()) if self.key == 'timerName' then self.values.timerName = self:GetText() self.name:SetText(self.values.timerName) self.timerName = self.values.timerName elseif self.key == 'spellID' then print('handling spellID') end end function mod.Dialog_Command(str, editbox) --local spellID = T:GetArgs(str, 1,0) local f = mod.EditDialog f.values = {} local db = mod.db local func, t, z = pairs(db.timers) -- iterator, table local name, values, y = func(t) -- index, values f.parent_values = {[name] = values} f.timerName = name f.values = values f.values.timerName = name for k,v in pairs(f.values) do print(cText(k), cType(v)) end print('pairs1', func, t) print('pairs2', z, y) name, values = func(t, name) while name do print(' entry:', name, values) f.parent_values[name] = values name, values = func(t, name) end if f:IsVisible() then f:Hide() else mod.Dialog_Init(f, TimerConfig.conf, TimerConfig.info) f:Show() end end