Mercurial > wow > devian
comparison Config.lua @ 45:5341e4d84622
Removed dock manager from the TOC for now
Parts of the config dialog in, needs finishing
| author | Nenue |
|---|---|
| date | Wed, 30 Dec 2015 07:05:38 -0500 |
| parents | |
| children | c3166f700438 |
comparison
equal
deleted
inserted
replaced
| 44:8a3f42ccf920 | 45:5341e4d84622 |
|---|---|
| 1 --- | |
| 2 -- @file-author@ | |
| 3 -- @project-revision@ @project-hash@ | |
| 4 -- @file-revision@ @file-hash@ | |
| 5 -- Created: 12/30/2015 1:35 AM | |
| 6 | |
| 7 if not LibStub then | |
| 8 print('Something has happened...') | |
| 9 end | |
| 10 local D = LibStub("AceAddon-3.0"):GetAddon("Devian") | |
| 11 DevCon = D:NewModule("Config") | |
| 12 local Cf, tinsert, ipairs, tostring = DevCon, table.insert, ipairs, tostring | |
| 13 local PLAYER_REALM = UnitName("player") .. '-' .. GetRealmName() | |
| 14 local db | |
| 15 | |
| 16 | |
| 17 local SetOpt = function(info, value) | |
| 18 db[info[#info]] = value | |
| 19 end | |
| 20 local GetOpt = function(info) | |
| 21 return db[info[#info]] | |
| 22 end | |
| 23 local GetProfileList = function(info) | |
| 24 local select = {} | |
| 25 for i, profile in ipairs(db.profiles) do | |
| 26 if i == db.workspace then | |
| 27 profile[1] = '|cFFFFFF00'..profile[1]..'|r' | |
| 28 elseif i == db.last_workspace then | |
| 29 profile[1] = '|cFF00FF00'..profile[1]..'|r' | |
| 30 end | |
| 31 tinsert(select,tostring(i)..':'..profile[1]) | |
| 32 end | |
| 33 return select | |
| 34 end | |
| 35 local GetAddOnList = function(id) | |
| 36 local t = Cf.opts.args.addon.args | |
| 37 for k, v in pairs(t) do | |
| 38 k:match("addon_") | |
| 39 t[k] = nil | |
| 40 end | |
| 41 | |
| 42 | |
| 43 end | |
| 44 local SetSelectedToProfile = function(info, value) | |
| 45 GetAddOnList(value) | |
| 46 end | |
| 47 local SetLoadedToProfile = function(info, value) end | |
| 48 local SetProfile = function(info, value) end | |
| 49 local LoadSelectedProfile = function() print('Load #', Cf.selected_profile) end | |
| 50 function Cf:OnInitialize() | |
| 51 db = DevianDB | |
| 52 self.selected_profile = db.primary_channel | |
| 53 end | |
| 54 | |
| 55 function Cf:OnEnable() | |
| 56 | |
| 57 D:Print('Options UI loaded') | |
| 58 self.opts = { | |
| 59 type = 'group', | |
| 60 name = 'Devian', | |
| 61 desc = 'Devkit in a nutshell', | |
| 62 handler = Cf, | |
| 63 set = SetOpt, | |
| 64 get = GetOpt, | |
| 65 args = { | |
| 66 enabled = { | |
| 67 type = 'toggle', | |
| 68 name = 'Enable Print Handler', | |
| 69 desc = 'Allows Devian to handle print() calls.', | |
| 70 order = 10, | |
| 71 }, | |
| 72 addon = { | |
| 73 type = 'group', | |
| 74 name = 'AddOns', | |
| 75 order = 20, | |
| 76 args= { | |
| 77 selected_profile = { | |
| 78 type = 'select', | |
| 79 name = 'Profile', | |
| 80 values = GetProfileList, | |
| 81 set = function(info, value, ...) self.selected_profile = value print('select', value, ...) end, | |
| 82 get = function(info) return self.selected_profile or 1 end, | |
| 83 order = 10 | |
| 84 }, | |
| 85 load_selected = { | |
| 86 func = LoadSelectedProfile, | |
| 87 type = 'execute', | |
| 88 name = 'Load Selected', | |
| 89 desc = 'Save currently loaded AddOns as a profile.', | |
| 90 order = 13, | |
| 91 }, | |
| 92 t_header = { | |
| 93 type = 'header', | |
| 94 name = 'Addons', | |
| 95 width = 'full', | |
| 96 order = 15, | |
| 97 }, | |
| 98 save_loaded = { | |
| 99 func = SetLoadedToProfile, | |
| 100 type = 'execute', | |
| 101 name = 'Save Loaded', | |
| 102 desc = 'Save currently loaded AddOns as a profile.', | |
| 103 order = 400, | |
| 104 }, | |
| 105 save_selected = { | |
| 106 func = SetSelectedToProfile, | |
| 107 type = 'execute', | |
| 108 name = 'Save', | |
| 109 desc = 'Save the selected AddOns as a profile.', | |
| 110 order = 450, | |
| 111 } | |
| 112 } | |
| 113 }, | |
| 114 channels = { | |
| 115 type = 'group', | |
| 116 name = 'Console', | |
| 117 order = 30, | |
| 118 args = { | |
| 119 primary_channel = { | |
| 120 type = 'select', | |
| 121 name = 'Primary Channel', | |
| 122 desc = 'Set the default output channel for untagged messages.', | |
| 123 values = {}, | |
| 124 } | |
| 125 } | |
| 126 }, | |
| 127 tags = { | |
| 128 type = 'group', | |
| 129 name = 'Tags', | |
| 130 order = 40, | |
| 131 args = { | |
| 132 enable_tag = { | |
| 133 type = 'toggle', | |
| 134 name ='Message prefix handling', | |
| 135 desc = 'Enables direction of print() results to different channels based on the first whole word in the output.', | |
| 136 } | |
| 137 } | |
| 138 }, | |
| 139 } | |
| 140 } | |
| 141 | |
| 142 | |
| 143 for i = 1, GetNumAddOns() do | |
| 144 local name = GetAddOnInfo(i) | |
| 145 local enableState, globalState = GetAddOnEnableState(playername, i), GetAddOnEnableState(nil, i) | |
| 146 self.opts.args.addon.args['addon_'..i..'_desc'] = { | |
| 147 type = 'description', | |
| 148 name = name, | |
| 149 width = 'single', | |
| 150 order= (500+i*3) | |
| 151 } | |
| 152 self.opts.args.addon.args['addon_'..i..'_global'] = { | |
| 153 type = 'toggle', | |
| 154 name = '', | |
| 155 get = function() return (GetAddOnEnableState(nil, i) == 2) and true or false end, | |
| 156 set = function(info, value) EnableAddOn(i, value) end, | |
| 157 width= 'half', | |
| 158 order= (500+i*3+1) | |
| 159 } | |
| 160 | |
| 161 self.opts.args.addon.args['addon_'..i..'_char'] = { | |
| 162 type = 'toggle', | |
| 163 name = '', | |
| 164 get = function() return (GetAddOnEnableState(GetUnitName('player'), i) == 1) and true or false end, | |
| 165 set = function(info, value) EnableAddOn(PLAYER_REALM, value) end, | |
| 166 width= 'half', | |
| 167 order= (500+i*3+2) | |
| 168 } | |
| 169 end | |
| 170 | |
| 171 LibStub("AceConfig-3.0"):RegisterOptionsTable("Devian", self.opts) | |
| 172 self.diag = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Devian", "Devian") | |
| 173 end | |
| 174 | |
| 175 function Cf:ChatCommand(input) | |
| 176 InterfaceOptionsFrame_OpenToCategory(self.diag) | |
| 177 InterfaceOptionsFrame_OpenToCategory(self.diag) | |
| 178 end |
