annotate CrossRealmAssistSettings.lua @ 38:616d67ff7543 beta-0.8

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