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

qol-improvements and beyond #52

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion RaidBrowser/RaidBrowser.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Interface: 30300
## Title: Raid Browser
## Version: v1.3.0
## Version: v1.4.0-DEV
## Notes: A raid finder that parses chat channel text and displays any found raids in the raid browser LFR frame.
## Author: Act/Horsebreed@Warmane
## SavedVariablesPerCharacter: RaidBrowserCharacterRaidsets, RaidBrowserCharacterCurrentRaidset
Expand Down
51 changes: 42 additions & 9 deletions RaidBrowser/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ RaidBrowser = LibStub('AceAddon-3.0'):NewAddon('RaidBrowser', 'AceConsole-3.0')

--[[ Parsing and pattern matching ]] --
-- Separator characters
local sep_chars = '%s-_,.<>%*)(/#+&x'
local sep_chars = '%s-_,.<>%*)(/#+&x\\['

-- Whitespace separator
local sep = '[' .. sep_chars .. ']';
Expand Down Expand Up @@ -130,6 +130,7 @@ local raid_list = {
patterns = {
'icc' .. csep .. '10' .. csep .. 'm?a?n?' .. csep .. 'repu?t?a?t?i?o?n?' .. csep,
'icc' .. csep .. 'repu?t?a?t?i?o?n?' .. csep .. '10',
'icc' .. csep .. '10' .. csep .. 'repu?t?a?t?i?o?n?',
'icc' .. csep .. '10' .. csep .. 'nm?' .. csep .. 'farm',
'icc' .. csep .. 'nm?' .. csep .. 'farm',
'icc' .. csep .. 'repu?t?a?t?i?o?n?',
Expand Down Expand Up @@ -726,6 +727,8 @@ local role_patterns = {
'm[dp][dp]s' .. meta_or_sep,
'r[dp][dp]s',
'dps',
'melee',
'ranged',
},

healer = {
Expand Down Expand Up @@ -753,6 +756,7 @@ local role_patterns = {
'ta*n+a?k+s?', -- NEED TANKS
'b[ea][ea]+rs?',
'prote?c?t?i?o?n?', -- NEED PROT PALA/WARRI
'fr?o?s?t? ?dk', -- frost DK
},
}

Expand All @@ -769,6 +773,7 @@ local gearscore_patterns = {

local guild_recruitment_patterns = {
'recrui?ti?n?g?',
'reclutan?d?o?',
'we' .. csep .. 'raid',
'we' .. csep .. 'are' .. csep .. 'raidi?n?g?',
'[<({-][%a%s]+[-})>]' .. csep .. 'is' .. csep .. 'a?', -- (<GuildName> is a) pve guild looking for
Expand All @@ -779,6 +784,8 @@ local guild_recruitment_patterns = {
'active' .. csep .. 'raiders?',
'is' .. csep .. 'a' .. csep .. '[%a]*' .. csep .. '[pvep][pvep][pvep]' .. csep .. 'guild',
'lf' .. sep .. 'members',
'new' .. sep .. 'members',
'Apply' .. sep .. 'here',
};

local trade_message_patterns = {
Expand Down Expand Up @@ -840,7 +847,7 @@ local lfm_patterns = {
lfm .. non_meta .. meta_raid,

meta_raid .. non_meta .. meta_role,
'new' .. csep .. 'run' .. meta_raid,
'new' .. csep .. 'run' .. csep .. meta_raid,
}

local guild_recruitment_metapatterns = {
Expand Down Expand Up @@ -1094,12 +1101,27 @@ function RaidBrowser.lex_and_extract(message, debug)

-- Get the raid_info from the message
local raid_info, raid_lexed_message, num_unique_raids = RaidBrowser.lex_raid_info(message, debug);
if not raid_info or not raid_lexed_message or not num_unique_raids then return end
if not raid_info or not raid_lexed_message or not num_unique_raids then
if debug then
RaidBrowser:Print("No valid raid found.");
end
return
end

if has_guild_recruitment_production(raid_lexed_message) then return end
if has_guild_recruitment_production(raid_lexed_message) then
if debug then
RaidBrowser:Print("Raid message was guild invite...");
end
return
end

-- If there are multiple distinct raids, then it is most likely a recruitment message.
if num_unique_raids > 1 then return end
if num_unique_raids > 1 then
if debug then
RaidBrowser:Print("found mulitple raids, could be recruiting...");
end
return
end

raid_lexed_message = lex_achievements(raid_lexed_message);

Expand Down Expand Up @@ -1133,10 +1155,20 @@ function RaidBrowser.raid_info(message, debug)
if not lexed_message then return end

-- Any message that is lexed out to be an lfg is excluded (unfortunately near the end).
if is_lfg_message(lexed_message, debug) then return end
if is_lfg_message(lexed_message, debug) then
if debug then
RaidBrowser:Print("message was lfg: " .. lexed_message);
end
return
end

-- Parse symbols to determine if the message is valid
if not is_lfm_message(lexed_message, debug) then return end
if not is_lfm_message(lexed_message, debug) then
if debug then
RaidBrowser:Print("message was not lfm: " .. lexed_message);
end
return
end

return raid_info, roles, gs or ' ';
end
Expand All @@ -1149,6 +1181,7 @@ end
RaidBrowserLfmChannelListeners = {
['CHAT_MSG_CHANNEL'] = {},
['CHAT_MSG_YELL'] = {},
['CHAT_MSG_SAY'] = {},
};

local channel_listeners = {};
Expand All @@ -1157,7 +1190,7 @@ local channel_listeners = {};
---@return boolean
---@nodiscard
local function is_lfm_channel(channel)
return channel == 'CHAT_MSG_CHANNEL' or channel == 'CHAT_MSG_YELL';
return channel == 'CHAT_MSG_CHANNEL' or channel == 'CHAT_MSG_YELL' or channel == 'CHAT_MSG_SAY';
end

---@diagnostic disable-next-line: unused-local
Expand Down Expand Up @@ -1223,7 +1256,7 @@ function RaidBrowser:OnEnable()
table.insert(channel_listeners, RaidBrowser.add_event_listener(channel, event_handler))
end

RaidBrowser.gui.raidset.initialize();
RaidBrowser.check_button()
end

function RaidBrowser:OnDisable()
Expand Down
14 changes: 9 additions & 5 deletions RaidBrowser/gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ local function set_sort(column)
end
end

---@return table
---@nodiscard
function RaidBrowser.set_sort(column)
set_sort(column)
end

local function get_sorted_messages()
local keys = {}
for _, info in pairs(RaidBrowser.lfm_messages) do
Expand Down Expand Up @@ -205,10 +207,12 @@ local function assign_lfr_button(button, host_name, lfm_info, index)
button.damageIcon:SetTexture("Interface\\LFGFrame\\LFGRole");
button.partyIcon:SetTexture("Interface\\LFGFrame\\LFGRole");

button:SetScript('OnEnter',
function(lfr_button)
GameTooltip:SetOwner(lfr_button, 'ANCHOR_RIGHT');
button:SetScript("OnDoubleClick", on_join)

button:SetScript('OnEnter',
function(lfr_button)
GameTooltip:SetOwner(lfr_button, 'ANCHOR_RIGHT');

local seconds = time() - lfr_button.lfm_info.time;
local last_sent = string.format('Last sent: %d seconds ago', seconds);
GameTooltip:AddLine(lfr_button.lfm_info.message, 1, 1, 1, true);
Expand Down
120 changes: 113 additions & 7 deletions RaidBrowser/raidset_frame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,45 @@ local function is_secondary_selected(_)
return 'Secondary' == current_selection;
end

local function is_both_selected(option)
return ('Both' == current_selection);
end

---@param selection 'Active'|'Primary'|'Secondary'
local function set_selection(selection)
local text = '';

if selection == 'Active' then
text = 'Active';
if selection == 'Both' then
local spec1, gs1 = RaidBrowser.stats.get_raidset('Primary')
local spec2, gs2 = RaidBrowser.stats.get_raidset('Secondary')


if spec1 and gs1 then
gs1 = math.floor(gs1 / 100) / 10
text = text .. gs1 .. ' ' .. spec1
else
text = text .. '-'
end
text = text .. ' / '
if spec2 and gs2 then
gs2 = math.floor(gs2 / 100) / 10
text = text .. gs2 .. ' ' .. spec2
else
text = text .. '-'
end
if not (spec1 or spec2) then
text = 'Set any spec first';
end

else
---@diagnostic disable-next-line: param-type-mismatch
local spec, gs = RaidBrowser.stats.get_raidset(selection)
if not spec then
text = 'Free slot';
elseif not gs then
text = spec;
else
text = gs..' '..spec
end
end

Expand All @@ -44,16 +70,25 @@ end
local function on_active()
set_selection('Active');
RaidBrowser.stats.select_current_raidset('Active');
RaidBrowser.check_button()
end

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

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

local function on_both()
set_selection('Both');
RaidBrowser.stats.select_current_raidset('Both');
RaidBrowser.check_button()
end

local menu = {
Expand All @@ -74,28 +109,61 @@ local menu = {
func = on_secondary,
checked = is_secondary_selected,
},

{
text = "Both",
func = on_both,
checked = is_both_selected,
}
}

-- Get the menu option text
---@param option 'Primary'|'Secondary'
---@return string
local function get_option_active(option)
local spec, gs = RaidBrowser.stats.get_active_raidset()
return (option .. ': ' .. gs .. ' ' .. spec)
end

-- Get the menu option text
local function get_option_text(option)
local spec, _ = RaidBrowser.stats.get_raidset(option);
local spec, gs = RaidBrowser.stats.get_raidset(option);
if not spec then
return option .. ': Free slot';
end

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

-- Get the menu option texts
local function get_option_texts(option)
local spec1, gs1 = RaidBrowser.stats.get_raidset('Primary');
local spec2, gs2 = RaidBrowser.stats.get_raidset('Secondary');
if not spec1 then
return (option .. ': Open');
end

return option .. ': ' .. spec;
if not (spec1 or spec2) then
return (option .. ': Set any spec first')
elseif (spec1 and spec2) then
return (option .. ': ' .. gs1 .. ' ' .. spec1 .. ' / ' .. gs2 .. ' ' .. spec2)
elseif spec1 then
return (option .. ': ' .. gs1 .. ' ' .. spec1 .. ' / ' .. '-')
elseif spec2 then
return (option .. ': ' .. '-' .. ' / ' .. gs2 .. ' ' .. spec2)
end

return (option .. ': ' .. gs1 .. ' ' .. spec1 .. ' / ' .. gs2 .. ' ' .. spec2);
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[1].text = get_option_text('Active');
menu[2].text = get_option_text('Primary');
menu[3].text = get_option_text('Secondary');
ToggleDropDownMenu(1, nil, frame, frame, 25, 10, menu);
menu[4].text = get_option_texts('Both');
ToggleDropDownMenu(1, nil, frame, frame, 25, 10, menu);
end

RaidBrowserRaidSetMenuButton:SetScript('OnClick', show_menu)
Expand All @@ -119,6 +187,43 @@ function RaidBrowser.gui.raidset.initialize()
set_selection(RaidBrowserCharacterCurrentRaidset);
end

local function check_button(button)
if is_active_selected() or is_both_selected() then
button:Disable()
else
button:Enable()
end
end

function RaidBrowser.check_button()
if is_active_selected() or is_both_selected() then
RaidBrowserRaidSetSaveButton:Disable()
RaidBrowserRaidSetSaveButton:SetText("Select spec first")
RaidBrowserRaidSetSaveButton:Hide()
else
RaidBrowserRaidSetSaveButton:Enable()
RaidBrowserRaidSetSaveButton:SetText("Save gear+spec")
RaidBrowserRaidSetSaveButton:Show()
end
end

local function onEvent(this, event, arg1)
if event == "PLAYER_EQUIPMENT_CHANGED" or "PLAYER_SPECIALIZATION_CHANGED" then
RaidBrowser.gui.raidset.initialize()
end
end

local function onShow(this)
-- update displayed Spec + GS in selection onShow
RaidBrowser.gui.raidset.initialize()
end

frame:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED")
frame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED")
frame:SetScript("OnEvent", onEvent)
frame:SetScript("onShow", onShow)


-- Create raidset save button
local button = CreateFrame("BUTTON", "RaidBrowserRaidSetSaveButton", LFRBrowseFrame, "OptionsButtonTemplate")
button:SetPoint("CENTER", LFRBrowseFrame, "CENTER", -53, 168)
Expand All @@ -129,3 +234,4 @@ button:SetText("Save Raid Gear");
button:SetWidth(110);
button:SetScript("OnClick", on_raidset_save);
button:Show();
check_button(button);
Loading