comparison CrossRealmAssistSettings.lua @ 32:7b7b3ca996fd

CrossRealmAssist beta 0.75 release-candidate
author ShadowTheAge
date Mon, 26 Oct 2015 00:47:27 +0300
parents
children d12ccf325b4b
comparison
equal deleted inserted replaced
31:efecddd638fc 32:7b7b3ca996fd
1 local version = "v0.75 beta";
2 local about = [[About:
3 I have started to make this addon as a tool for myself. Few people started to use it when I pushed it to Curse. Then updated it once with 6.2 release.
4 After some time I have catched a dialog on my own realm discussing it. I went to check curse page and I was shocked - it was in top-60 monthly downloaded addons with lots of suggestions and few bug reports.
5 I wasn't going to support it - because it was working - but now it looks like I have to spend at least some time to make it better.
6
7 Realm hopping has become a thing. The idea was rather obvious, but less people were using it at the start of WOD. Now every raid group with autoaccept are going to have some quiet people joining and leaving it. But since we became a huge community, it is up to us to control this.
8 The idea is to create groups from realmhoppers to realmhoppers. Taking small steps to not flood LFG too much. There are some ideas how to make realmhopping more comfortably while reducing annoyance to others.
9
10 FAQ:
11 Q: I cannot loot timeless coins / some other loot
12 A: Some items cannot be looted while in a raid group. However, rare timeless items can be.".
13
14 Q: I'm on the oceanic region and I can't hop to another realm
15 A: Unfortunately, oceanic realms are separated by Blizzard. There is little I can do :(
16
17 Changelog:
18
19 v0.7 - 0.75
20 - New options panel (Groundwork for future customization)
21 - Some UI customizations are now possible
22 - "Join to a friend" feature
23 - "Keywords" feature - blacklist, whitelist and highlight list
24 - You can add more info to "Manual Join" list
25 - Clicking to join group when you are already in a group causes you to leave it.
26 - You can now create a group for other people to use for realm hopping purpose
27 - You can now automatically create such group when AFK at garrison
28 - Added advanced filters
29 - Last column ("Misc") is now a sortable column - it uses base sort (by weight)
30
31 http://www.curse.com/addons/wow/crossrealmassist
32 https://www.reddit.com/r/crossrealmassist
33 ]]
34
35 local AceConfig = LibStub("AceConfig-3.0")
36 local addon = CrossRealmAssist;
37
38 local db
39 local orderId = 0
40 local registered = false;
41 local needReloadUI = false;
42
43 local function haveToReloadUI()
44 return not needReloadUI;
45 end
46
47 local function order()
48 orderId = orderId + 1
49 return orderId;
50 end
51
52 local function traverse(info, value)
53 local node = db.global
54 local last
55 if info.arg then
56 for k,v in ipairs(info.arg) do
57 if last then node = node[last] end
58 last = v;
59 end
60 if value ~= nil then
61 local callback = info.arg.callback
62 if callback then
63 if (type(callback) == "string") then
64 addon[callback](value);
65 elseif type(callback) == "function" then
66 callback(value)
67 end
68 end
69 if info.arg.needReloadUI then
70 needReloadUI = true
71 end
72 end
73 else last = info[#info] end
74 return node, last
75 end
76
77 local function getter(info)
78 local node, last = traverse(info);
79 return node[last]
80 end
81
82 local function setter(info, value)
83 local node, last = traverse(info, value);
84 node[last] = value;
85 end
86
87 local function multiGetter(info, key)
88 local node, last = traverse(info);
89 return node[last][key];
90 end
91
92 local function multiSetter(info, key, value)
93 local node, last = traverse(info, value);
94 node[last][key] = value;
95 end
96
97 local function setMinimapIcon(hidden)
98 if hidden then
99 DEFAULT_CHAT_FRAME:AddMessage("|cffff0000Type |cffffffff/cra |cffff0000in chat to open Cross Realm Assist without minimap button");
100 minimapIcon:Hide("CrossRealmAssistMinimapIcon")
101 else
102 minimapIcon:Show("CrossRealmAssistMinimapIcon")
103 end
104 end
105
106 local function createKeywordTable(name, desc, listValue)
107 local list = db.global[listValue];
108 if not list then
109 list = {}
110 db.global[listValue] = list;
111 end
112 local selected = 0;
113
114 local function setSelection(info, value)
115 selected = value
116 end
117
118 local function getSelection()
119 return selected
120 end
121
122 local function deleteSelected()
123 if selected == 0 then return end;
124 table.remove(list, selected);
125 selected = 0;
126 end
127
128 local function addItem(info, value)
129 if string.len(value) >= 3 then
130 value = string.lower(value);
131 for k,v in pairs(list) do
132 if v == value then return end
133 end
134 table.insert(list, value);
135 end
136 end
137
138 return {
139 name = name,
140 type = "group",
141 order=order(),
142 args = {
143 desc = {
144 type = "description",
145 order=order(),
146 name = desc
147 },
148 input = {
149 type = "input",
150 name = "Add new",
151 order=order(),
152 set = addItem
153 },
154 list = {
155 name = "Current list",
156 type = "select",
157 values=list,
158 style="radio",
159 order=order(),
160 set = setSelection,
161 get = getSelection,
162 },
163 delete = {
164 type = "execute",
165 name = "Delete selected",
166 order=order(),
167 func = deleteSelected
168 },
169 },
170 }
171 end
172
173 local function getLFGGroups()
174 local table = {}
175 for i=1,#addon.lfgGroups do
176 local groupId = addon.lfgGroups[i]
177 table[groupId] = (C_LFGList.GetCategoryInfo(groupId))
178 end
179 return table;
180 end
181
182 local function register()
183 local CRAOptions = {
184 type = "group",
185 get = getter,
186 set = setter,
187 args = {
188 reload = {
189 type = "execute",
190 name = "Reload UI",
191 order=order(),
192 func = ReloadUI,
193 hidden = haveToReloadUI
194 },
195 reloadDesc = {
196 name = "UI reload is required for some settings to take effect",
197 type = "description",
198 order=order(),
199 width="double",
200 hidden = haveToReloadUI
201 },
202 general={
203 name = "General options",
204 type = "group",
205 order=order(),
206 args = {
207 quickJoinHint = {
208 name = "Show Quick Join Hint",
209 type = "toggle",
210 order=order(),
211 },
212 minimap = {
213 name = "Hide minimap button",
214 type = "toggle",
215 arg = {"minimap","hide",callback="toggleMinimapIcon"},
216 order=order(),
217 },
218 allLanguages = {
219 name = "All language groups",
220 type = "toggle",
221 order=order(),
222 },
223 applyAsDD = {
224 name = "Apply to groups as DD only",
225 type = "toggle",
226 width = "double",
227 order=order(),
228 },
229 quickJoin = {
230 name = "Quick Join Categories",
231 type = "multiselect",
232 values = getLFGGroups(),
233 get = multiGetter,
234 set = multiSetter,
235 order=order()
236 },
237 hopGroupHeader = {
238 name = "Realm Hoppers Union",
239 type = "header",
240 order=order(),
241 },
242 hopGroupDesc = {
243 name = "Help other CrossRealmAssist users (and other people) and they will help you someday! Open a group for others when you are away. CRA can automatically open such group when following conditions are met:",
244 type = "description",
245 order=order(),
246 },
247 autoCreateHopGroup = {
248 name = "You are AFK at garrison",
249 type = "toggle",
250 order=order(),
251 }
252 }
253 },
254 keywords={
255 name = "Keywords",
256 type = "group",
257 order=order(),
258 args={
259 blacklist = createKeywordTable("Blacklisted keywords","Groups with these keywords will be ignored when quick joining. Don't be evil","stoplist"),
260 whitelist = createKeywordTable("Priority keywords","Groups with these keywords are high-priority groups and are first to join regardless of group size","priorityList"),
261 highlight = createKeywordTable("Highlight keywords","Groups with these keywords will be highlighted in green in the Manual Join panel","highlightList")
262 }
263 },
264 appearance={
265 name = "Appearance",
266 type = "group",
267 order=order(),
268 args={
269 uiScale = {
270 name = "Mini panel size",
271 type = "range",
272 min=0.5, max=1.5,isPercent=true,bigStep=0.05,
273 order=order(),
274 arg={"uiScale",callback="updateUIScale"}
275 },
276 lfgPanelScale = {
277 name = "Manual Join panel size",
278 type = "range",
279 min=0.5, max=1.5,isPercent=true,bigStep=0.05,
280 order=order(),
281 arg={"lfgPanelScale",callback="updateLfgScale"}
282 },
283 listItemCount = {
284 name = "Manual Join list size",
285 type = "range",
286 min=5, max=30,step=1,
287 order=order(),
288 arg={"listItemCount",needReloadUI=1}
289 },
290 extraColumns = {
291 name = "Show extra info in group table",
292 type = "multiselect",
293 values = {rtype="Realm type (PVE/PVP/etc)",groupAge="Group age",joinTime="Time since joining"},
294 arg={"extraColumns",needReloadUI=1},
295 get = multiGetter,
296 set = multiSetter,
297 order=order()
298 },
299 }
300 },
301 about={
302 name = "About",
303 type = "group",
304 order=order(),
305 args={
306 aboutHeader = {
307 name = "CrossRealmAssist "..version.." by ShadowTheAge",
308 type = "header",
309 order=order(),
310 },
311 aboutDesc = {
312 name = about,
313 type = "description",
314 width = "full",
315 order=order(),
316 }
317 }
318 }
319 }
320 }
321 AceConfig:RegisterOptionsTable("CrossRealmAssist", CRAOptions)
322 registered = true;
323 end
324
325 addon.showSettings = function()
326 db = addon.db;
327 if not registered then register() end
328 LibStub("AceConfigDialog-3.0"):Open("CrossRealmAssist")
329 end