Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.2.0 #5

Merged
merged 6 commits into from
Jun 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion RaidBrowser/RaidBrowser.toc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## Interface: 30300
## Title: Raid Browser
## Version: v1.1.1
## Version: v1.2.0
## Notes: A raid finder that parses chat channel text and displays any found raids in the raid browser LFR frame.
## Author: Horsebreed
## SavedVariablesPerCharacter: raid_browser_character_raidsets, raid_browser_character_current_raidset
## OptionalDeps: GearScoreLite
## X-Embeds: Ace3

Expand All @@ -13,3 +14,4 @@ event.lua
timer.lua
stats.lua
gui.lua
raidset_frame.lua
120 changes: 72 additions & 48 deletions RaidBrowser/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,10 @@ local raid_list = {
{
name = 'molten core',
instance_name = 'Molten Core',
size = 25,
size = 40,
patterns = {
'molte?n[%s]*core?',
'[%s-_,.%^]+mc'..sep..'*2?5?[%s-_,.$]+',
'[%s-_,.%^]+mc'..sep..'*4?0?[%s-_,.$]+',
},
},

Expand All @@ -290,7 +290,7 @@ local raid_list = {
},

{
name = 'aq10',
name = 'aq20',
instance_name = 'Ruins of Ahn\'Qiraj',
size = 20,
patterns = {
Expand All @@ -300,36 +300,34 @@ local raid_list = {
},
}

local role_patterns = {
ranged_dps = {
local role_patterns = {
dps = {
'[0-9]*[%s-_,.]*dps',

-- melee dps
'[0-9]*[%s-_,.]*m[dp][dp]s',
'[0-9]*[%s-_,.]*rogue',
'[0-9]*[%s-_,.]*kitt?y?',
'[0-9]*[%s-_,.]*feral',
'[0-9]*[%s-_,.]*ret[%s-_,.]*pal[al]?[dy]?i?n?',

-- ranged dps
"[0-9]*[%s-_,.]*r[dp][dp]s",
'[0-9]*[%s-_,.]*w?a?r?lock',
'[0-9]*[%s-_,.]*spri?e?st',
'[0-9]*[%s-_,.]*elem?e?n?t?a?l?',
'[0-9]*[%s-_,.]*mage',
'[0-9]*[%s-_,.]*boomy?k?i?n?',
'[0-9]*[%s-_,.]*boo?mm?y?k?i?n?',
'[0-9]*[%s-_,.]*hunte?r?s?',
},

melee_dps = {
'[0-9]*[%s-_,.]*m[dp][dp]s',
'[0-9]*[%s-_,.]*rogue',
'[0-9]*[%s-_,.]*kitt?y?',
'[0-9]*[%s-_,.]*feral',
'[0-9]*[%s-_,.]*ret[%s-_,.]*pal[al]?[dy]?i?n?',
},

dps = {
'[0-9]*[%s-_,.]*dps',
},

healer = {
'[0-9]*[%s-_,.]*he[a]?l[er|ers]*', -- LF healer
'[0-9]*[%s-_,.]*rd[ru][ud][iu]d?', -- LF rdruid/rdudu
'[0-9]*[%s-_,.]*re?s?t?o?'..sep..'*d[ru][ud][iu]d?', -- LF rdruid/rdudu
'[0-9]*[%s-_,.]*tree', -- LF tree
'[0-9]*[%s-_,.]*re?s?t?o?[%s-_,.]*shamm?y?', -- LF rsham
'[0-9]*'..sep..'*di?s?c?'..sep..'*pri?e?st', -- disc priest
'[0-9]*[%s-_,.]*hpala', -- LF hpala
'[0-9]*'..sep..'*di?s?c?o?'..sep..'*pri?e?st', -- disc priest
'[0-9]*[%s-_,.]*ho?l?l?y?'..sep..'*pala', -- LF hpala
},

tank = {
Expand All @@ -352,20 +350,21 @@ local gearscore_patterns = {

local lfm_patterns = {
'lf[0-9]*m',
'looking[%s]*for[%s]*all',
'looking'..sep..'*for'..sep..'*an?',
'looking[%s]*for[%s]*[0-9]*[%s]*more', -- looking for 9 more
'lf[%s]*.*for', -- LF <any characters> for
'lf[%s]*[0-9]*[%s]*he[a]?l[er|ers]*', -- LF healer
'lf[%s]*[0-9]*[%s]*t[a]?nk[s]?', -- LF 5 tanks
'lf[%s]*[0-9]*[%s]*[mr]?dps', -- LF 9 DPS
'seek[%s]*[0-9]*[%s]*he[a]?l[er|ers]*', -- seek healer
'seek[%s]*[0-9]*[%s]*t[a]?nk[s]?', -- seek 5 tanks
'seek[%s]*[0-9]*[%s]*[mr]?dps', -- seek 9 DPS
'lf[%s]*all',
'lf'..sep..'*all',
'need',
'need[%s]*all',
'whispe?r?[%s]*me',
'need'..sep..'*all',
'seek'..sep..'*[0-9]*'..sep..'*he[a]?l[er|ers]*', -- seek healer
'seek'..sep..'*[0-9]*'..sep..'*t[a]?nk[s]?', -- seek 5 tanks
'seek'..sep..'*[0-9]*'..sep..'*[mr]?dps', -- seek 9 DPS
'looking'..sep..'*for[%s]*all',
'looking'..sep..'*for'..sep..'*an?'..sep,
'looking'..sep..'*for'..sep..'*[0-9]*'..sep..'*more', -- looking for 9 more
'lf'..sep..'*.*for', -- LF <any characters> for
'looking'..sep..'*for'..sep..'*.*'..sep..'for', -- LF <any characters> for
'lf'..sep..'*[0-9]*'..sep..'*he[a]?l[er|ers]*', -- LF healer
'lf'..sep..'*[0-9]*'..sep..'*t[a]?nk[s]?', -- LF 5 tanks
'lf'..sep..'*[0-9]*'..sep..'*[mr]?dps', -- LF 9 DPS
'whispe?r?'..sep..'*me',
--'[%s]/w[%s]*[%a]+', -- Too greedy
}

Expand Down Expand Up @@ -434,6 +433,28 @@ local function remove_http_links(message)
local http_pattern = 'https?://*[%a]*.[%a]*.[%a]*/?[%a%-%%0-9_]*/?';
return string.gsub(message, http_pattern, '');
end

local function find_roles(roles, message, pattern_table, role)
local found = false;
for _, pattern in ipairs(pattern_table[role]) do
local result = string.find(message, pattern)

-- If a raid was found then save it to our list of roles and continue.
if result then
found = true;

-- Remove the substring from the message
message = string.gsub(message, pattern, '')
end
end

if not found then
return roles, message;
end

table.insert(roles, role);
return roles, message;
end

function raid_browser.raid_info(message)
message = string.lower(message)
Expand Down Expand Up @@ -481,19 +502,10 @@ function raid_browser.raid_info(message)

-- Get any roles that are needed
local roles = {};
for r, patterns in pairs(role_patterns) do
for _, pattern in ipairs(patterns) do
local result = string.find(message, pattern)

-- If a raid was found then save it to our list of roles and continue.
if result then
table.insert(roles, r)

-- Remove the substring from the message
message = string.gsub(message, pattern, '')
end
end
end

roles, message = find_roles(roles, message, role_patterns, 'dps');
roles, message = find_roles(roles, message, role_patterns, 'tank');
roles, message = find_roles(roles, message, role_patterns, 'healer');

-- If there is only an LFM message, then it is assumed that all roles are needed
if #roles == 0 then
Expand Down Expand Up @@ -537,13 +549,25 @@ end

function raid_browser:OnEnable()
raid_browser:Print("loaded. Type /rb to toggle the raid browser.")

if not raid_browser_character_current_raidset then
raid_browser_character_current_raidset = 'Active';
end

if not raid_browser_character_raidsets then
raid_browser_character_raidsets = {
primary = {},
secondary = {},
};
end

-- LFM messages expire after 60 seconds
raid_browser.expiry_time = 60;

raid_browser.lfm_messages = {}
raid_browser.timer = raid_browser.set_timer(10, refresh_lfm_messages, true)
raid_browser.listener = raid_browser.add_event_listener("CHAT_MSG_CHANNEL", event_handler )
raid_browser.listener = raid_browser.add_event_listener("CHAT_MSG_CHANNEL", event_handler)
raid_browser.gui.raidset.initialize();
end

function raid_browser:OnDisable()
Expand Down
4 changes: 2 additions & 2 deletions RaidBrowser/gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ for i = 1, NUM_LFR_LIST_BUTTONS do

if button.raid_locked then
GameTooltip:AddLine('\nYou are |cffff0000saved|cffffd100 for ' .. button.raid_info.name);
local _, reset_time = raid_browser.stats.raid_lock_info(button.raid_info)
local _, reset_time = raid_browser.stats.raid_lock_info(button.raid_info.instance_name, button.raid_info.size)
GameTooltip:AddLine('Lockout expires in ' .. format_seconds(reset_time));
else
GameTooltip:AddLine('\nYou are |cff00ff00not saved|cffffd100 for ' .. button.raid_info.name);
Expand Down Expand Up @@ -139,7 +139,7 @@ local function assign_lfr_button(button, host_name, lfm_info, index)
-- Raid name
button.class:SetText(button.raid_info.name);

button.raid_locked = raid_browser.stats.raid_lock_info(button.raid_info);
button.raid_locked = raid_browser.stats.raid_lock_info(button.raid_info.instance_name, button.raid_info.size);
button.type = "party";

button.partyIcon:Show();
Expand Down
121 changes: 121 additions & 0 deletions RaidBrowser/raidset_frame.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
raid_browser.gui.raidset = {};

local frame = CreateFrame("Frame", "RaidBrowserRaidSetMenu", LFRBrowseFrame, "UIDropDownMenuTemplate")

local current_selection = nil;

local function is_active_selected(option)
return ('Active' == current_selection);
end

local function is_primary_selected(option)
return ('Primary' == current_selection);
end

local function is_secondary_selected(option)
return ('Secondary' == current_selection);
end

local function set_selection(selection)
local text = '';

if selection == 'Active' then
text = 'Active';
else
local spec, gs = raid_browser.stats.get_raidset(selection);
if not spec then
text = 'Open';
else
text = spec .. ' ' .. gs .. 'gs';
end
end

UIDropDownMenu_SetText(RaidBrowserRaidSetMenu, text)
current_selection = selection;
end

local function on_active()
set_selection('Active');
raid_browser.stats.select_current_raidset('Active');
end

local function on_primary()
set_selection('Primary');
raid_browser.stats.select_current_raidset('Primary');
end

local function on_secondary()
set_selection('Secondary');
raid_browser.stats.select_current_raidset('Secondary');
end

local menu = {
{
text = 'Active',
func = on_active,
checked = is_active_selected,
},

{
text = "Primary",
func = on_primary,
checked = is_primary_selected,
},

{
text = "Secondary",
func = on_secondary,
checked = is_secondary_selected,
},
}

-- Get the menu option text
local function get_option_text(option)
local spec = raid_browser.stats.get_raidset(option);
if not spec then
return (option .. ': Open');
end

return (option .. ': ' .. spec);
end

-- Setup dropdown menu for the raidset selection
frame:SetPoint("CENTER", LFRBrowseFrame, "CENTER", 30, 165)
UIDropDownMenu_Initialize(frame, EasyMenu_Initialize, nil, nil, menu);

local function show_menu()
menu[2].text = get_option_text('Primary');
menu[3].text = get_option_text('Secondary');
ToggleDropDownMenu(1, nil, frame, frame, 25, 10, menu);
end

RaidBrowserRaidSetMenuButton:SetScript('OnClick', show_menu)

local function on_raidset_save()
if current_selection == 'Primary' then
raid_browser.stats.save_primary_raidset();

elseif current_selection == 'Secondary' then
raid_browser.stats.save_secondary_raidset();
end

local spec, gs = raid_browser.stats.current_raidset();
raid_browser:Print('Raidset saved: ' .. spec .. ' ' .. gs .. 'gs');
set_selection(current_selection);
end

function raid_browser.gui.raidset.initialize()
set_selection(raid_browser_character_current_raidset);
end

-- Create raidset save button
local button = CreateFrame("BUTTON","RaidBrowserRaidSetSaveButton", LFRBrowseFrame, "OptionsButtonTemplate")
button:SetPoint("CENTER", LFRBrowseFrame, "CENTER", -40, 168)
button:EnableMouse(true)
button:RegisterForClicks("AnyUp")

button:SetText("Save Raid Set");
button:SetWidth(120);
button:SetScript("OnClick", on_raidset_save);
button:Show();

Loading