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