comparison CrossRealmAssist.lua @ 25:e0a1917e571f v0.65

Simple filters, minor bug fixes, and reuploading
author ShadowTheAge
date Sat, 26 Sep 2015 13:21:55 +0300
parents 1edc9cc7f43a
children 42a70f4b2ff5
comparison
equal deleted inserted replaced
24:ecff6ee4b36e 25:e0a1917e571f
7 local db 7 local db
8 8
9 local homeRealm, realmSep, gui, btRefresh, btSettings, btQuick, btManual, lbRealm, lbStatus, playerName, lfgui, lfgTabSelected, lfgTable, lbThrottle, curLfgGroup, sheduledScan, wasInGroup, inInstance 9 local homeRealm, realmSep, gui, btRefresh, btSettings, btQuick, btManual, lbRealm, lbStatus, playerName, lfgui, lfgTabSelected, lfgTable, lbThrottle, curLfgGroup, sheduledScan, wasInGroup, inInstance
10 local settingsMenu 10 local settingsMenu
11 local hintShown 11 local hintShown
12 local cbHideGroups, cbHideRaids, cbHideNoAutoinv
12 13
13 local tabs = {} 14 local tabs = {}
14 local curRealmStat, curPartyStat 15 local curRealmStat, curPartyStat
15 local scanstate=0 16 local scanstate=0
16 local recentRealms={} 17 local recentRealms={}
184 leaderRealm = 1 + 2*math.min(1,ago/600); 185 leaderRealm = 1 + 2*math.min(1,ago/600);
185 end 186 end
186 187
187 local countWeight = 4 -- count weight 188 local countWeight = 4 -- count weight
188 if pcount >= 39 or pcount <= 1 then countWeight = 1 189 if pcount >= 39 or pcount <= 1 then countWeight = 1
189 elseif pcount >= 35 or pcount <= 4 then countWeight = 2 190 elseif pcount >= 35 or pcount <= 5 then countWeight = 2
190 elseif pcount >= 30 or pcount <= 10 then countWeight = 3 191 elseif pcount >= 30 or pcount <= 10 then countWeight = 3
191 else countWeight = 4 end 192 else countWeight = 4 end
192 193
193 local ageWeight = 2 194 local ageWeight = 2
194 if time > 1200 then ageWeight = 4 195 if time > 1200 then ageWeight = 4
275 local pname, realm = PlayerName(name); 276 local pname, realm = PlayerName(name);
276 return recentRealms[realm] and COLOR_YELLOW or COLOR_GREEN; 277 return recentRealms[realm] and COLOR_YELLOW or COLOR_GREEN;
277 end 278 end
278 279
279 local function filterTable(self, row) 280 local function filterTable(self, row)
280 local delisted = select(11, C_LFGList.GetSearchResultInfo(row.id)) 281 local _, _, _, _, _, _, _, _, _, _, delisted, _, pcount, autoinv = C_LFGList.GetSearchResultInfo(row.id)
281 return not delisted; 282 if delisted then return false end;
283 if pcount > 5 and cbHideRaids:GetChecked() then return false end;
284 if pcount <= 5 and cbHideGroups:GetChecked() then return false end;
285 if not autoinv and cbHideNoAutoinv:GetChecked() then return false end;
286 return true;
282 end 287 end
283 288
284 function addon:UpdateResponseData(event, result) 289 function addon:UpdateResponseData(event, result)
285 if not lfgTable then return end 290 if not lfgTable then return end
286 if select(11, C_LFGList.GetSearchResultInfo(result)) then 291 if select(11, C_LFGList.GetSearchResultInfo(result)) then
312 end 317 end
313 end 318 end
314 319
315 local function JoinGroup(rid) 320 local function JoinGroup(rid)
316 local tank, heal, dd = C_LFGList.GetAvailableRoles() 321 local tank, heal, dd = C_LFGList.GetAvailableRoles()
322 local noHealTank = not db.global.applyAsDD;
317 addon:SetGroupJoinStatus(rid, "_init") 323 addon:SetGroupJoinStatus(rid, "_init")
318 C_LFGList.ApplyToGroup(rid, "", tank, heal, dd) 324 C_LFGList.ApplyToGroup(rid, "", tank and noHealTank, heal and noHealTank, dd)
319 end 325 end
320 326
321 local function TableCellClick(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) 327 local function TableCellClick(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
322 if not realrow or not canJoinGroup() then return end 328 if not realrow or not canJoinGroup() then return end
323 local rowdata = scrollingTable:GetRow(realrow); 329 local rowdata = scrollingTable:GetRow(realrow);
416 local point,_,_,x,y = gui:GetPoint(1); 422 local point,_,_,x,y = gui:GetPoint(1);
417 db.global.widgetPos = {x=x,y=y,to=point} 423 db.global.widgetPos = {x=x,y=y,to=point}
418 end 424 end
419 425
420 function addon:CreateUI() 426 function addon:CreateUI()
421 gui = setupWidget(CreateFrame("Frame","CrossRealmAssistMainUI",nil,"InsetFrameTemplate3"), {SetFrameStrata="LOW",SetWidth=208,SetHeight=60,EnableMouse=true,SetMovable=true}) 427 gui = setupWidget(CreateFrame("Frame","CrossRealmAssistMainUI",nil,"InsetFrameTemplate3"), {SetFrameStrata="LOW",SetWidth=208,SetHeight=60,EnableMouse=true,SetMovable=true,SetClampedToScreen=true})
422 local title = setupWidget(CreateFrame("Frame",nil,gui), {SetWidth=190,SetHeight=18,EnableMouse=true,RegisterForDrag="LeftButton"}, 0, 6); 428 local title = setupWidget(CreateFrame("Frame",nil,gui), {SetWidth=190,SetHeight=18,EnableMouse=true,RegisterForDrag="LeftButton"}, 0, 6);
423 title:SetScript("OnDragStart", function() gui:StartMoving() end) 429 title:SetScript("OnDragStart", function() gui:StartMoving() end)
424 title:SetScript("OnDragStop", stopMovingWidget) 430 title:SetScript("OnDragStop", stopMovingWidget)
425 gui:SetScript("OnHide", addon.Deactivate) 431 gui:SetScript("OnHide", addon.Deactivate)
426 setupTooltip(title, "ANCHOR_TOP", realmToolip) 432 setupTooltip(title, "ANCHOR_TOP", realmToolip)
466 lfgTable:Refresh() 472 lfgTable:Refresh()
467 hasLfgListChanges = false 473 hasLfgListChanges = false
468 end 474 end
469 end 475 end
470 476
477 function addon.refreshList()
478 lfgTable:SetFilter(filterTable)
479 end
480
471 function addon:CreateLFGUI() 481 function addon:CreateLFGUI()
472 lfgui = setupWidget(CreateFrame("Frame","CrossRealmAssistJoinUI",nil,"UIPanelDialogTemplate"), {SetFrameStrata="DIALOG",SetWidth=405,SetHeight=300,EnableMouse=true,SetMovable=true}) 482 lfgui = setupWidget(CreateFrame("Frame","CrossRealmAssistJoinUI",nil,"UIPanelDialogTemplate"), {SetFrameStrata="DIALOG",SetWidth=405,SetHeight=323,EnableMouse=true,SetMovable=true})
473 lfgui.title:SetText("Click to join group") 483 lfgui.title:SetText("Click to join group")
474 lfgui:SetScript("OnUpdate",addon.lfgUpdate) 484 lfgui:SetScript("OnUpdate",addon.lfgUpdate)
475 local titlereg = lfgui:CreateTitleRegion() 485 local titlereg = lfgui:CreateTitleRegion()
476 titlereg:SetAllPoints(lfgui.title) 486 titlereg:SetAllPoints(lfgui.title)
477 addon:CreateTabs() 487 addon:CreateTabs()
495 505
496 local btRefresh = setupWidget(CreateFrame("Button",nil,lfgui,"UIPanelSquareButton"),{SetWidth=22,SetHeight=22},379,27) 506 local btRefresh = setupWidget(CreateFrame("Button",nil,lfgui,"UIPanelSquareButton"),{SetWidth=22,SetHeight=22},379,27)
497 btRefresh.icon:SetTexture("Interface/BUTTONS/UI-RefreshButton") 507 btRefresh.icon:SetTexture("Interface/BUTTONS/UI-RefreshButton")
498 btRefresh.icon:SetTexCoord(0,1,0,1); 508 btRefresh.icon:SetTexCoord(0,1,0,1);
499 btRefresh:SetScript("OnClick",addon.refreshLfgCurrent) 509 btRefresh:SetScript("OnClick",addon.refreshLfgCurrent)
510
511 setupWidget(CreateFrame("Frame",nil,lfgui,"HorizontalBarTemplate"),{SetWidth=392,SetHeight=2}, 8, 294)
512 local text = setupWidget(lfgui:CreateFontString(nil,"BACKGROUND", "GameFontHighlightSmall"), {SetText="Hide:"}, 20, 302)
513
514 cbHideGroups = setupWidget(CreateFrame("CheckButton",nil,lfgui,"UICheckButtonTemplate"),{SetWidth=22,SetHeight=22})
515 cbHideGroups:SetPoint("TOPLEFT",text,"TOPRIGHT",5,7)
516 cbHideGroups:SetScript("OnClick",addon.refreshList)
517 text = setupWidget(lfgui:CreateFontString(nil,"BACKGROUND", "GameFontHighlightSmall"), {SetText="5p Groups"})
518 text:SetPoint("TOPLEFT",cbHideGroups,"TOPRIGHT",0,-7)
519
520 cbHideRaids = setupWidget(CreateFrame("CheckButton",nil,lfgui,"UICheckButtonTemplate"),{SetWidth=22,SetHeight=22})
521 cbHideRaids:SetPoint("TOPLEFT",text,"TOPRIGHT",5,7)
522 cbHideRaids:SetScript("OnClick",addon.refreshList)
523 text = setupWidget(lfgui:CreateFontString(nil,"BACKGROUND", "GameFontHighlightSmall"), {SetText="Raids"})
524 text:SetPoint("TOPLEFT",cbHideRaids,"TOPRIGHT",0,-7)
525
526 cbHideNoAutoinv = setupWidget(CreateFrame("CheckButton",nil,lfgui,"UICheckButtonTemplate"),{SetWidth=22,SetHeight=22})
527 cbHideNoAutoinv:SetPoint("TOPLEFT",text,"TOPRIGHT",5,7)
528 cbHideNoAutoinv:SetScript("OnClick",addon.refreshList)
529 text = setupWidget(lfgui:CreateFontString(nil,"BACKGROUND", "GameFontHighlightSmall"), {SetText="Groups w/o Autoinvite"})
530 text:SetPoint("TOPLEFT",cbHideNoAutoinv,"TOPRIGHT",0,-7)
500 end 531 end
501 532
502 function addon:CreateTabs() 533 function addon:CreateTabs()
503 local prevTab 534 local prevTab
504 for i=1,#lfgGroups do 535 for i=1,#lfgGroups do
930 961
931 local function toggleAllLanguages(btn, arg1, arg2, checked) 962 local function toggleAllLanguages(btn, arg1, arg2, checked)
932 db.global.allLanguages = checked 963 db.global.allLanguages = checked
933 end 964 end
934 965
966 local function toggleApplyAsDD(btn, arg1, arg2, checked)
967 db.global.applyAsDD = checked
968 end
969
935 local function ClearJoinHistory() 970 local function ClearJoinHistory()
936 recentgroups = {} 971 recentgroups = {}
937 addon:UpdateAutoButtonStatus() 972 addon:UpdateAutoButtonStatus()
938 if lfgTable then lfgTable:Refresh() end 973 if lfgTable then lfgTable:Refresh() end
939 end 974 end
953 UIDropDownMenu_AddButton({text="Clear join history",notCheckable=1,func=ClearJoinHistory}, level) 988 UIDropDownMenu_AddButton({text="Clear join history",notCheckable=1,func=ClearJoinHistory}, level)
954 UIDropDownMenu_AddButton({disabled=1,notCheckable=1}, level) 989 UIDropDownMenu_AddButton({disabled=1,notCheckable=1}, level)
955 UIDropDownMenu_AddButton({isTitle=1,text="Settings",notCheckable=1}, level) 990 UIDropDownMenu_AddButton({isTitle=1,text="Settings",notCheckable=1}, level)
956 UIDropDownMenu_AddButton({text="Show Minimap Button",checked=not db.global.minimap.hide, func=toggleMinimapIcon,keepShownOnClick=true,isNotRadio=true}, level) 991 UIDropDownMenu_AddButton({text="Show Minimap Button",checked=not db.global.minimap.hide, func=toggleMinimapIcon,keepShownOnClick=true,isNotRadio=true}, level)
957 UIDropDownMenu_AddButton({text="All language groups",checked=db.global.allLanguages, func=toggleAllLanguages,keepShownOnClick=true,isNotRadio=true}, level) 992 UIDropDownMenu_AddButton({text="All language groups",checked=db.global.allLanguages, func=toggleAllLanguages,keepShownOnClick=true,isNotRadio=true}, level)
993 UIDropDownMenu_AddButton({text="Apply to groups as DD only",checked=db.global.applyAsDD, func=toggleApplyAsDD,keepShownOnClick=true,isNotRadio=true}, level)
958 UIDropDownMenu_AddButton({text="Show Quick Join Hint",checked=db.global.quickJoinHint, func=toggleQuickJoinHint,keepShownOnClick=true,isNotRadio=true}, level) 994 UIDropDownMenu_AddButton({text="Show Quick Join Hint",checked=db.global.quickJoinHint, func=toggleQuickJoinHint,keepShownOnClick=true,isNotRadio=true}, level)
959 UIDropDownMenu_AddButton({text="Quick join categories",notCheckable=1,hasArrow=1,value="qjc",keepShownOnClick=true}, level) 995 UIDropDownMenu_AddButton({text="Quick join categories",notCheckable=1,hasArrow=1,value="qjc",keepShownOnClick=true}, level)
960 elseif level == 2 then 996 elseif level == 2 then
961 if UIDROPDOWNMENU_MENU_VALUE == "qjc" then 997 if UIDROPDOWNMENU_MENU_VALUE == "qjc" then
962 for i=1,#lfgGroups do 998 for i=1,#lfgGroups do