annotate Libs/AceDBOptions-3.0/AceDBOptions-3.0.lua @ 0:98c6f55e6619

First commit
author Xiiph
date Sat, 05 Feb 2011 16:45:02 +0100
parents
children
rev   line source
Xiiph@0 1 --- AceDBOptions-3.0 provides a universal AceConfig options screen for managing AceDB-3.0 profiles.
Xiiph@0 2 -- @class file
Xiiph@0 3 -- @name AceDBOptions-3.0
Xiiph@0 4 -- @release $Id: AceDBOptions-3.0.lua 938 2010-06-13 07:21:38Z nevcairiel $
Xiiph@0 5 local ACEDBO_MAJOR, ACEDBO_MINOR = "AceDBOptions-3.0", 12
Xiiph@0 6 local AceDBOptions, oldminor = LibStub:NewLibrary(ACEDBO_MAJOR, ACEDBO_MINOR)
Xiiph@0 7
Xiiph@0 8 if not AceDBOptions then return end -- No upgrade needed
Xiiph@0 9
Xiiph@0 10 -- Lua APIs
Xiiph@0 11 local pairs, next = pairs, next
Xiiph@0 12
Xiiph@0 13 -- WoW APIs
Xiiph@0 14 local UnitClass = UnitClass
Xiiph@0 15
Xiiph@0 16 -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
Xiiph@0 17 -- List them here for Mikk's FindGlobals script
Xiiph@0 18 -- GLOBALS: NORMAL_FONT_COLOR_CODE, FONT_COLOR_CODE_CLOSE
Xiiph@0 19
Xiiph@0 20 AceDBOptions.optionTables = AceDBOptions.optionTables or {}
Xiiph@0 21 AceDBOptions.handlers = AceDBOptions.handlers or {}
Xiiph@0 22
Xiiph@0 23 --[[
Xiiph@0 24 Localization of AceDBOptions-3.0
Xiiph@0 25 ]]
Xiiph@0 26
Xiiph@0 27 local L = {
Xiiph@0 28 default = "Default",
Xiiph@0 29 intro = "You can change the active database profile, so you can have different settings for every character.",
Xiiph@0 30 reset_desc = "Reset the current profile back to its default values, in case your configuration is broken, or you simply want to start over.",
Xiiph@0 31 reset = "Reset Profile",
Xiiph@0 32 reset_sub = "Reset the current profile to the default",
Xiiph@0 33 choose_desc = "You can either create a new profile by entering a name in the editbox, or choose one of the already existing profiles.",
Xiiph@0 34 new = "New",
Xiiph@0 35 new_sub = "Create a new empty profile.",
Xiiph@0 36 choose = "Existing Profiles",
Xiiph@0 37 choose_sub = "Select one of your currently available profiles.",
Xiiph@0 38 copy_desc = "Copy the settings from one existing profile into the currently active profile.",
Xiiph@0 39 copy = "Copy From",
Xiiph@0 40 delete_desc = "Delete existing and unused profiles from the database to save space, and cleanup the SavedVariables file.",
Xiiph@0 41 delete = "Delete a Profile",
Xiiph@0 42 delete_sub = "Deletes a profile from the database.",
Xiiph@0 43 delete_confirm = "Are you sure you want to delete the selected profile?",
Xiiph@0 44 profiles = "Profiles",
Xiiph@0 45 profiles_sub = "Manage Profiles",
Xiiph@0 46 current = "Current Profile:",
Xiiph@0 47 }
Xiiph@0 48
Xiiph@0 49 local LOCALE = GetLocale()
Xiiph@0 50 if LOCALE == "deDE" then
Xiiph@0 51 L["default"] = "Standard"
Xiiph@0 52 L["intro"] = "Hier kannst du das aktive Datenbankprofile \195\164ndern, damit du verschiedene Einstellungen f\195\188r jeden Charakter erstellen kannst, wodurch eine sehr flexible Konfiguration m\195\182glich wird."
Xiiph@0 53 L["reset_desc"] = "Setzt das momentane Profil auf Standardwerte zur\195\188ck, f\195\188r den Fall das mit der Konfiguration etwas schief lief oder weil du einfach neu starten willst."
Xiiph@0 54 L["reset"] = "Profil zur\195\188cksetzen"
Xiiph@0 55 L["reset_sub"] = "Das aktuelle Profil auf Standard zur\195\188cksetzen."
Xiiph@0 56 L["choose_desc"] = "Du kannst ein neues Profil erstellen, indem du einen neuen Namen in der Eingabebox 'Neu' eingibst, oder w\195\164hle eines der vorhandenen Profile aus."
Xiiph@0 57 L["new"] = "Neu"
Xiiph@0 58 L["new_sub"] = "Ein neues Profil erstellen."
Xiiph@0 59 L["choose"] = "Vorhandene Profile"
Xiiph@0 60 L["choose_sub"] = "W\195\164hlt ein bereits vorhandenes Profil aus."
Xiiph@0 61 L["copy_desc"] = "Kopiere die Einstellungen von einem vorhandenen Profil in das aktive Profil."
Xiiph@0 62 L["copy"] = "Kopieren von..."
Xiiph@0 63 L["delete_desc"] = "L\195\182sche vorhandene oder unbenutzte Profile aus der Datenbank um Platz zu sparen und um die SavedVariables Datei 'sauber' zu halten."
Xiiph@0 64 L["delete"] = "Profil l\195\182schen"
Xiiph@0 65 L["delete_sub"] = "L\195\182scht ein Profil aus der Datenbank."
Xiiph@0 66 L["delete_confirm"] = "Willst du das ausgew\195\164hlte Profil wirklich l\195\182schen?"
Xiiph@0 67 L["profiles"] = "Profile"
Xiiph@0 68 L["profiles_sub"] = "Profile verwalten"
Xiiph@0 69 --L["current"] = "Current Profile:"
Xiiph@0 70 elseif LOCALE == "frFR" then
Xiiph@0 71 L["default"] = "D\195\169faut"
Xiiph@0 72 L["intro"] = "Vous pouvez changer le profil actuel afin d'avoir des param\195\168tres diff\195\169rents pour chaque personnage, permettant ainsi d'avoir une configuration tr\195\168s flexible."
Xiiph@0 73 L["reset_desc"] = "R\195\169initialise le profil actuel au cas o\195\185 votre configuration est corrompue ou si vous voulez tout simplement faire table rase."
Xiiph@0 74 L["reset"] = "R\195\169initialiser le profil"
Xiiph@0 75 L["reset_sub"] = "R\195\169initialise le profil actuel avec les param\195\168tres par d\195\169faut."
Xiiph@0 76 L["choose_desc"] = "Vous pouvez cr\195\169er un nouveau profil en entrant un nouveau nom dans la bo\195\174te de saisie, ou en choississant un des profils d\195\169j\195\160 existants."
Xiiph@0 77 L["new"] = "Nouveau"
Xiiph@0 78 L["new_sub"] = "Cr\195\169\195\169e un nouveau profil vierge."
Xiiph@0 79 L["choose"] = "Profils existants"
Xiiph@0 80 L["choose_sub"] = "Permet de choisir un des profils d\195\169j\195\160 disponibles."
Xiiph@0 81 L["copy_desc"] = "Copie les param\195\168tres d'un profil d\195\169j\195\160 existant dans le profil actuellement actif."
Xiiph@0 82 L["copy"] = "Copier \195\160 partir de"
Xiiph@0 83 L["delete_desc"] = "Supprime les profils existants inutilis\195\169s de la base de donn\195\169es afin de gagner de la place et de nettoyer le fichier SavedVariables."
Xiiph@0 84 L["delete"] = "Supprimer un profil"
Xiiph@0 85 L["delete_sub"] = "Supprime un profil de la base de donn\195\169es."
Xiiph@0 86 L["delete_confirm"] = "Etes-vous s\195\187r de vouloir supprimer le profil s\195\169lectionn\195\169 ?"
Xiiph@0 87 L["profiles"] = "Profils"
Xiiph@0 88 L["profiles_sub"] = "Gestion des profils"
Xiiph@0 89 --L["current"] = "Current Profile:"
Xiiph@0 90 elseif LOCALE == "koKR" then
Xiiph@0 91 L["default"] = "기본값"
Xiiph@0 92 L["intro"] = "모든 캐릭터의 다양한 설정과 사용중인 데이터베이스 프로필, 어느것이던지 매우 다루기 쉽게 바꿀수 있습니다."
Xiiph@0 93 L["reset_desc"] = "단순히 다시 새롭게 구성을 원하는 경우, 현재 프로필을 기본값으로 초기화 합니다."
Xiiph@0 94 L["reset"] = "프로필 초기화"
Xiiph@0 95 L["reset_sub"] = "현재의 프로필을 기본값으로 초기화 합니다"
Xiiph@0 96 L["choose_desc"] = "새로운 이름을 입력하거나, 이미 있는 프로필중 하나를 선택하여 새로운 프로필을 만들 수 있습니다."
Xiiph@0 97 L["new"] = "새로운 프로필"
Xiiph@0 98 L["new_sub"] = "새로운 프로필을 만듭니다."
Xiiph@0 99 L["choose"] = "프로필 선택"
Xiiph@0 100 L["choose_sub"] = "당신이 현재 이용할수 있는 프로필을 선택합니다."
Xiiph@0 101 L["copy_desc"] = "현재 사용중인 프로필에, 선택한 프로필의 설정을 복사합니다."
Xiiph@0 102 L["copy"] = "복사"
Xiiph@0 103 L["delete_desc"] = "데이터베이스에 사용중이거나 저장된 프로파일 삭제로 SavedVariables 파일의 정리와 공간 절약이 됩니다."
Xiiph@0 104 L["delete"] = "프로필 삭제"
Xiiph@0 105 L["delete_sub"] = "데이터베이스의 프로필을 삭제합니다."
Xiiph@0 106 L["delete_confirm"] = "정말로 선택한 프로필의 삭제를 원하십니까?"
Xiiph@0 107 L["profiles"] = "프로필"
Xiiph@0 108 L["profiles_sub"] = "프로필 설정"
Xiiph@0 109 --L["current"] = "Current Profile:"
Xiiph@0 110 elseif LOCALE == "esES" or LOCALE == "esMX" then
Xiiph@0 111 L["default"] = "Por defecto"
Xiiph@0 112 L["intro"] = "Puedes cambiar el perfil activo de tal manera que cada personaje tenga diferentes configuraciones."
Xiiph@0 113 L["reset_desc"] = "Reinicia el perfil actual a los valores por defectos, en caso de que se haya estropeado la configuración o quieras volver a empezar de nuevo."
Xiiph@0 114 L["reset"] = "Reiniciar Perfil"
Xiiph@0 115 L["reset_sub"] = "Reinicar el perfil actual al de por defecto"
Xiiph@0 116 L["choose_desc"] = "Puedes crear un nuevo perfil introduciendo un nombre en el recuadro o puedes seleccionar un perfil de los ya existentes."
Xiiph@0 117 L["new"] = "Nuevo"
Xiiph@0 118 L["new_sub"] = "Crear un nuevo perfil vacio."
Xiiph@0 119 L["choose"] = "Perfiles existentes"
Xiiph@0 120 L["choose_sub"] = "Selecciona uno de los perfiles disponibles."
Xiiph@0 121 L["copy_desc"] = "Copia los ajustes de un perfil existente al perfil actual."
Xiiph@0 122 L["copy"] = "Copiar de"
Xiiph@0 123 L["delete_desc"] = "Borra los perfiles existentes y sin uso de la base de datos para ganar espacio y limpiar el archivo SavedVariables."
Xiiph@0 124 L["delete"] = "Borrar un Perfil"
Xiiph@0 125 L["delete_sub"] = "Borra un perfil de la base de datos."
Xiiph@0 126 L["delete_confirm"] = "¿Estas seguro que quieres borrar el perfil seleccionado?"
Xiiph@0 127 L["profiles"] = "Perfiles"
Xiiph@0 128 L["profiles_sub"] = "Manejar Perfiles"
Xiiph@0 129 --L["current"] = "Current Profile:"
Xiiph@0 130 elseif LOCALE == "zhTW" then
Xiiph@0 131 L["default"] = "預設"
Xiiph@0 132 L["intro"] = "你可以選擇一個活動的資料設定檔,這樣你的每個角色就可以擁有不同的設定值,可以給你的插件設定帶來極大的靈活性。"
Xiiph@0 133 L["reset_desc"] = "將當前的設定檔恢復到它的預設值,用於你的設定檔損壞,或者你只是想重來的情況。"
Xiiph@0 134 L["reset"] = "重置設定檔"
Xiiph@0 135 L["reset_sub"] = "將當前的設定檔恢復為預設值"
Xiiph@0 136 L["choose_desc"] = "你可以通過在文本框內輸入一個名字創立一個新的設定檔,也可以選擇一個已經存在的設定檔。"
Xiiph@0 137 L["new"] = "新建"
Xiiph@0 138 L["new_sub"] = "新建一個空的設定檔。"
Xiiph@0 139 L["choose"] = "現有的設定檔"
Xiiph@0 140 L["choose_sub"] = "從當前可用的設定檔裏面選擇一個。"
Xiiph@0 141 L["copy_desc"] = "從當前某個已保存的設定檔複製到當前正使用的設定檔。"
Xiiph@0 142 L["copy"] = "複製自"
Xiiph@0 143 L["delete_desc"] = "從資料庫裏刪除不再使用的設定檔,以節省空間,並且清理SavedVariables檔。"
Xiiph@0 144 L["delete"] = "刪除一個設定檔"
Xiiph@0 145 L["delete_sub"] = "從資料庫裏刪除一個設定檔。"
Xiiph@0 146 L["delete_confirm"] = "你確定要刪除所選擇的設定檔嗎?"
Xiiph@0 147 L["profiles"] = "設定檔"
Xiiph@0 148 L["profiles_sub"] = "管理設定檔"
Xiiph@0 149 --L["current"] = "Current Profile:"
Xiiph@0 150 elseif LOCALE == "zhCN" then
Xiiph@0 151 L["default"] = "默认"
Xiiph@0 152 L["intro"] = "你可以选择一个活动的数据配置文件,这样你的每个角色就可以拥有不同的设置值,可以给你的插件配置带来极大的灵活性。"
Xiiph@0 153 L["reset_desc"] = "将当前的配置文件恢复到它的默认值,用于你的配置文件损坏,或者你只是想重来的情况。"
Xiiph@0 154 L["reset"] = "重置配置文件"
Xiiph@0 155 L["reset_sub"] = "将当前的配置文件恢复为默认值"
Xiiph@0 156 L["choose_desc"] = "你可以通过在文本框内输入一个名字创立一个新的配置文件,也可以选择一个已经存在的配置文件。"
Xiiph@0 157 L["new"] = "新建"
Xiiph@0 158 L["new_sub"] = "新建一个空的配置文件。"
Xiiph@0 159 L["choose"] = "现有的配置文件"
Xiiph@0 160 L["choose_sub"] = "从当前可用的配置文件里面选择一个。"
Xiiph@0 161 L["copy_desc"] = "从当前某个已保存的配置文件复制到当前正使用的配置文件。"
Xiiph@0 162 L["copy"] = "复制自"
Xiiph@0 163 L["delete_desc"] = "从数据库里删除不再使用的配置文件,以节省空间,并且清理SavedVariables文件。"
Xiiph@0 164 L["delete"] = "删除一个配置文件"
Xiiph@0 165 L["delete_sub"] = "从数据库里删除一个配置文件。"
Xiiph@0 166 L["delete_confirm"] = "你确定要删除所选择的配置文件么?"
Xiiph@0 167 L["profiles"] = "配置文件"
Xiiph@0 168 L["profiles_sub"] = "管理配置文件"
Xiiph@0 169 --L["current"] = "Current Profile:"
Xiiph@0 170 elseif LOCALE == "ruRU" then
Xiiph@0 171 L["default"] = "По умолчанию"
Xiiph@0 172 L["intro"] = "Изменяя активный профиль, вы можете задать различные настройки модификаций для каждого персонажа."
Xiiph@0 173 L["reset_desc"] = "Если ваша конфигурации испорчена или если вы хотите настроить всё заново - сбросьте текущий профиль на стандартные значения."
Xiiph@0 174 L["reset"] = "Сброс профиля"
Xiiph@0 175 L["reset_sub"] = "Сброс текущего профиля на стандартный"
Xiiph@0 176 L["choose_desc"] = "Вы можете создать новый профиль, введя название в поле ввода, или выбрать один из уже существующих профилей."
Xiiph@0 177 L["new"] = "Новый"
Xiiph@0 178 L["new_sub"] = "Создать новый чистый профиль"
Xiiph@0 179 L["choose"] = "Существующие профили"
Xiiph@0 180 L["choose_sub"] = "Выбор одиного из уже доступных профилей"
Xiiph@0 181 L["copy_desc"] = "Скопировать настройки из выбранного профиля в активный."
Xiiph@0 182 L["copy"] = "Скопировать из"
Xiiph@0 183 L["delete_desc"] = "Удалить существующий и неиспользуемый профиль из БД для сохранения места, и очистить SavedVariables файл."
Xiiph@0 184 L["delete"] = "Удалить профиль"
Xiiph@0 185 L["delete_sub"] = "Удаление профиля из БД"
Xiiph@0 186 L["delete_confirm"] = "Вы уверены, что вы хотите удалить выбранный профиль?"
Xiiph@0 187 L["profiles"] = "Профили"
Xiiph@0 188 L["profiles_sub"] = "Управление профилями"
Xiiph@0 189 --L["current"] = "Current Profile:"
Xiiph@0 190 end
Xiiph@0 191
Xiiph@0 192 local defaultProfiles
Xiiph@0 193 local tmpprofiles = {}
Xiiph@0 194
Xiiph@0 195 -- Get a list of available profiles for the specified database.
Xiiph@0 196 -- You can specify which profiles to include/exclude in the list using the two boolean parameters listed below.
Xiiph@0 197 -- @param db The db object to retrieve the profiles from
Xiiph@0 198 -- @param common If true, getProfileList will add the default profiles to the return list, even if they have not been created yet
Xiiph@0 199 -- @param nocurrent If true, then getProfileList will not display the current profile in the list
Xiiph@0 200 -- @return Hashtable of all profiles with the internal name as keys and the display name as value.
Xiiph@0 201 local function getProfileList(db, common, nocurrent)
Xiiph@0 202 local profiles = {}
Xiiph@0 203
Xiiph@0 204 -- copy existing profiles into the table
Xiiph@0 205 local currentProfile = db:GetCurrentProfile()
Xiiph@0 206 for i,v in pairs(db:GetProfiles(tmpprofiles)) do
Xiiph@0 207 if not (nocurrent and v == currentProfile) then
Xiiph@0 208 profiles[v] = v
Xiiph@0 209 end
Xiiph@0 210 end
Xiiph@0 211
Xiiph@0 212 -- add our default profiles to choose from ( or rename existing profiles)
Xiiph@0 213 for k,v in pairs(defaultProfiles) do
Xiiph@0 214 if (common or profiles[k]) and not (nocurrent and k == currentProfile) then
Xiiph@0 215 profiles[k] = v
Xiiph@0 216 end
Xiiph@0 217 end
Xiiph@0 218
Xiiph@0 219 return profiles
Xiiph@0 220 end
Xiiph@0 221
Xiiph@0 222 --[[
Xiiph@0 223 OptionsHandlerPrototype
Xiiph@0 224 prototype class for handling the options in a sane way
Xiiph@0 225 ]]
Xiiph@0 226 local OptionsHandlerPrototype = {}
Xiiph@0 227
Xiiph@0 228 --[[ Reset the profile ]]
Xiiph@0 229 function OptionsHandlerPrototype:Reset()
Xiiph@0 230 self.db:ResetProfile()
Xiiph@0 231 end
Xiiph@0 232
Xiiph@0 233 --[[ Set the profile to value ]]
Xiiph@0 234 function OptionsHandlerPrototype:SetProfile(info, value)
Xiiph@0 235 self.db:SetProfile(value)
Xiiph@0 236 end
Xiiph@0 237
Xiiph@0 238 --[[ returns the currently active profile ]]
Xiiph@0 239 function OptionsHandlerPrototype:GetCurrentProfile()
Xiiph@0 240 return self.db:GetCurrentProfile()
Xiiph@0 241 end
Xiiph@0 242
Xiiph@0 243 --[[
Xiiph@0 244 List all active profiles
Xiiph@0 245 you can control the output with the .arg variable
Xiiph@0 246 currently four modes are supported
Xiiph@0 247
Xiiph@0 248 (empty) - return all available profiles
Xiiph@0 249 "nocurrent" - returns all available profiles except the currently active profile
Xiiph@0 250 "common" - returns all avaialble profiles + some commonly used profiles ("char - realm", "realm", "class", "Default")
Xiiph@0 251 "both" - common except the active profile
Xiiph@0 252 ]]
Xiiph@0 253 function OptionsHandlerPrototype:ListProfiles(info)
Xiiph@0 254 local arg = info.arg
Xiiph@0 255 local profiles
Xiiph@0 256 if arg == "common" and not self.noDefaultProfiles then
Xiiph@0 257 profiles = getProfileList(self.db, true, nil)
Xiiph@0 258 elseif arg == "nocurrent" then
Xiiph@0 259 profiles = getProfileList(self.db, nil, true)
Xiiph@0 260 elseif arg == "both" then -- currently not used
Xiiph@0 261 profiles = getProfileList(self.db, (not self.noDefaultProfiles) and true, true)
Xiiph@0 262 else
Xiiph@0 263 profiles = getProfileList(self.db)
Xiiph@0 264 end
Xiiph@0 265
Xiiph@0 266 return profiles
Xiiph@0 267 end
Xiiph@0 268
Xiiph@0 269 function OptionsHandlerPrototype:HasNoProfiles(info)
Xiiph@0 270 local profiles = self:ListProfiles(info)
Xiiph@0 271 return ((not next(profiles)) and true or false)
Xiiph@0 272 end
Xiiph@0 273
Xiiph@0 274 --[[ Copy a profile ]]
Xiiph@0 275 function OptionsHandlerPrototype:CopyProfile(info, value)
Xiiph@0 276 self.db:CopyProfile(value)
Xiiph@0 277 end
Xiiph@0 278
Xiiph@0 279 --[[ Delete a profile from the db ]]
Xiiph@0 280 function OptionsHandlerPrototype:DeleteProfile(info, value)
Xiiph@0 281 self.db:DeleteProfile(value)
Xiiph@0 282 end
Xiiph@0 283
Xiiph@0 284 --[[ fill defaultProfiles with some generic values ]]
Xiiph@0 285 local function generateDefaultProfiles(db)
Xiiph@0 286 defaultProfiles = {
Xiiph@0 287 ["Default"] = L["default"],
Xiiph@0 288 [db.keys.char] = db.keys.char,
Xiiph@0 289 [db.keys.realm] = db.keys.realm,
Xiiph@0 290 [db.keys.class] = UnitClass("player")
Xiiph@0 291 }
Xiiph@0 292 end
Xiiph@0 293
Xiiph@0 294 --[[ create and return a handler object for the db, or upgrade it if it already existed ]]
Xiiph@0 295 local function getOptionsHandler(db, noDefaultProfiles)
Xiiph@0 296 if not defaultProfiles then
Xiiph@0 297 generateDefaultProfiles(db)
Xiiph@0 298 end
Xiiph@0 299
Xiiph@0 300 local handler = AceDBOptions.handlers[db] or { db = db, noDefaultProfiles = noDefaultProfiles }
Xiiph@0 301
Xiiph@0 302 for k,v in pairs(OptionsHandlerPrototype) do
Xiiph@0 303 handler[k] = v
Xiiph@0 304 end
Xiiph@0 305
Xiiph@0 306 AceDBOptions.handlers[db] = handler
Xiiph@0 307 return handler
Xiiph@0 308 end
Xiiph@0 309
Xiiph@0 310 --[[
Xiiph@0 311 the real options table
Xiiph@0 312 ]]
Xiiph@0 313 local optionsTable = {
Xiiph@0 314 desc = {
Xiiph@0 315 order = 1,
Xiiph@0 316 type = "description",
Xiiph@0 317 name = L["intro"] .. "\n",
Xiiph@0 318 },
Xiiph@0 319 descreset = {
Xiiph@0 320 order = 9,
Xiiph@0 321 type = "description",
Xiiph@0 322 name = L["reset_desc"],
Xiiph@0 323 },
Xiiph@0 324 reset = {
Xiiph@0 325 order = 10,
Xiiph@0 326 type = "execute",
Xiiph@0 327 name = L["reset"],
Xiiph@0 328 desc = L["reset_sub"],
Xiiph@0 329 func = "Reset",
Xiiph@0 330 },
Xiiph@0 331 current = {
Xiiph@0 332 order = 11,
Xiiph@0 333 type = "description",
Xiiph@0 334 name = function(info) return L["current"] .. " " .. NORMAL_FONT_COLOR_CODE .. info.handler:GetCurrentProfile() .. FONT_COLOR_CODE_CLOSE end,
Xiiph@0 335 width = "default",
Xiiph@0 336 },
Xiiph@0 337 choosedesc = {
Xiiph@0 338 order = 20,
Xiiph@0 339 type = "description",
Xiiph@0 340 name = "\n" .. L["choose_desc"],
Xiiph@0 341 },
Xiiph@0 342 new = {
Xiiph@0 343 name = L["new"],
Xiiph@0 344 desc = L["new_sub"],
Xiiph@0 345 type = "input",
Xiiph@0 346 order = 30,
Xiiph@0 347 get = false,
Xiiph@0 348 set = "SetProfile",
Xiiph@0 349 },
Xiiph@0 350 choose = {
Xiiph@0 351 name = L["choose"],
Xiiph@0 352 desc = L["choose_sub"],
Xiiph@0 353 type = "select",
Xiiph@0 354 order = 40,
Xiiph@0 355 get = "GetCurrentProfile",
Xiiph@0 356 set = "SetProfile",
Xiiph@0 357 values = "ListProfiles",
Xiiph@0 358 arg = "common",
Xiiph@0 359 },
Xiiph@0 360 copydesc = {
Xiiph@0 361 order = 50,
Xiiph@0 362 type = "description",
Xiiph@0 363 name = "\n" .. L["copy_desc"],
Xiiph@0 364 },
Xiiph@0 365 copyfrom = {
Xiiph@0 366 order = 60,
Xiiph@0 367 type = "select",
Xiiph@0 368 name = L["copy"],
Xiiph@0 369 desc = L["copy_desc"],
Xiiph@0 370 get = false,
Xiiph@0 371 set = "CopyProfile",
Xiiph@0 372 values = "ListProfiles",
Xiiph@0 373 disabled = "HasNoProfiles",
Xiiph@0 374 arg = "nocurrent",
Xiiph@0 375 },
Xiiph@0 376 deldesc = {
Xiiph@0 377 order = 70,
Xiiph@0 378 type = "description",
Xiiph@0 379 name = "\n" .. L["delete_desc"],
Xiiph@0 380 },
Xiiph@0 381 delete = {
Xiiph@0 382 order = 80,
Xiiph@0 383 type = "select",
Xiiph@0 384 name = L["delete"],
Xiiph@0 385 desc = L["delete_sub"],
Xiiph@0 386 get = false,
Xiiph@0 387 set = "DeleteProfile",
Xiiph@0 388 values = "ListProfiles",
Xiiph@0 389 disabled = "HasNoProfiles",
Xiiph@0 390 arg = "nocurrent",
Xiiph@0 391 confirm = true,
Xiiph@0 392 confirmText = L["delete_confirm"],
Xiiph@0 393 },
Xiiph@0 394 }
Xiiph@0 395
Xiiph@0 396 --- Get/Create a option table that you can use in your addon to control the profiles of AceDB-3.0.
Xiiph@0 397 -- @param db The database object to create the options table for.
Xiiph@0 398 -- @return The options table to be used in AceConfig-3.0
Xiiph@0 399 -- @usage
Xiiph@0 400 -- -- Assuming `options` is your top-level options table and `self.db` is your database:
Xiiph@0 401 -- options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
Xiiph@0 402 function AceDBOptions:GetOptionsTable(db, noDefaultProfiles)
Xiiph@0 403 local tbl = AceDBOptions.optionTables[db] or {
Xiiph@0 404 type = "group",
Xiiph@0 405 name = L["profiles"],
Xiiph@0 406 desc = L["profiles_sub"],
Xiiph@0 407 }
Xiiph@0 408
Xiiph@0 409 tbl.handler = getOptionsHandler(db, noDefaultProfiles)
Xiiph@0 410 tbl.args = optionsTable
Xiiph@0 411
Xiiph@0 412 AceDBOptions.optionTables[db] = tbl
Xiiph@0 413 return tbl
Xiiph@0 414 end
Xiiph@0 415
Xiiph@0 416 -- upgrade existing tables
Xiiph@0 417 for db,tbl in pairs(AceDBOptions.optionTables) do
Xiiph@0 418 tbl.handler = getOptionsHandler(db)
Xiiph@0 419 tbl.args = optionsTable
Xiiph@0 420 end