annotate CrossRealmAssistSettings.lua @ 40:d12ccf325b4b v0.8

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