80 lines
4.0 KiB
Lua
80 lines
4.0 KiB
Lua
-- OctoTextSize: addon-local factory; Blizzard CreateFrame is unchanged.
|
|
local CreateFrame = OctoTextSize and OctoTextSize.WrapFactory(CreateFrame) or CreateFrame
|
|
-- Guild roster search (#24, 2026-11-25): a Blizzard SearchBoxTemplate box in the native Communities roster (expanded
|
|
-- display, beside "Show offline members"). Filters the rows RefreshListDisplay just built by name, rank, zone, public
|
|
-- and officer note. Data only from the roster the Source server already sends; no Blizzard globals are written.
|
|
WoWHybridUI = WoWHybridUI or {};
|
|
local state = WoWHybridUI;
|
|
|
|
local function lower(s) return type(s) == "string" and s:lower() or ""; end
|
|
|
|
local function Matches(info, query)
|
|
if not info then return false; end
|
|
for _, field in ipairs({ info.name, info.guildRank, info.zone, info.memberNote, info.officerNote }) do
|
|
if lower(field):find(query, 1, true) then return true; end
|
|
end
|
|
return false;
|
|
end
|
|
|
|
local function ApplyFilter(list)
|
|
local box = state.guildSearchBox;
|
|
local query = box and lower(strtrim(box:GetText() or "")) or "";
|
|
if query == "" or not list.ScrollBox then return; end
|
|
-- Search the whole roster like the 1.12 guild frame search (owner 2026-11-26: an offline member was found on
|
|
-- Octo but not here): the shown rows leave offline members out unless "Show offline members" is ticked.
|
|
if not (list.IsDisplayingProfessions and list:IsDisplayingProfessions()) and type(list.allMemberList) == "table" then
|
|
local provider = CreateDataProvider();
|
|
for _, memberInfo in ipairs(list.allMemberList) do
|
|
if Matches(memberInfo, query) then provider:Insert({ memberInfo = memberInfo }); end
|
|
end
|
|
list.ScrollBox:SetDataProvider(provider, ScrollBoxConstants.RetainScrollPosition);
|
|
list.ScrollBox:ForEachFrame(function(button) button:SetExpanded(list.expandedDisplay); end);
|
|
return;
|
|
end
|
|
local provider = list.ScrollBox:GetDataProvider();
|
|
if not provider then return; end
|
|
provider:RemoveByPredicate(function(elementData)
|
|
return elementData.memberInfo ~= nil and not Matches(elementData.memberInfo, query);
|
|
end);
|
|
end
|
|
|
|
-- Gamepad UI: install no hooks on the Communities frame (see the SetPreferredGamepadInteractTarget() popup).
|
|
local function Install(style)
|
|
style = style or C_InputInterfaceStyle.GetCurrentStyle()
|
|
if style == Enum.InputDeviceInterfaceType.Gamepad then return end
|
|
local list = CommunitiesFrame and CommunitiesFrame.MemberList;
|
|
if state.guildSearchInstalled or not list or not list.RefreshListDisplay then return; end
|
|
state.guildSearchInstalled = true;
|
|
local box = CreateFrame("EditBox", "WoWHybridGuildSearchBox", list, "SearchBoxTemplate");
|
|
box:SetSize(150, 20);
|
|
box:SetPoint("BOTTOMRIGHT", list, "TOPRIGHT", -4, 28);
|
|
box:SetAutoFocus(false);
|
|
box:HookScript("OnTextChanged", function() list:RefreshListDisplay(); end);
|
|
state.guildSearchBox = box;
|
|
-- No hooks on the member list or its methods (with them, calls to RefreshListDisplay failed with "attempt to call a nil
|
|
-- value"): our own child frame watches for the new data provider that each refresh creates.
|
|
local seen;
|
|
local function Watch()
|
|
box:SetShown(list.ShowOfflineButton and list.ShowOfflineButton:IsShown());
|
|
local provider = list.ScrollBox and list.ScrollBox:GetDataProvider();
|
|
if provider ~= seen then
|
|
ApplyFilter(list);
|
|
seen = list.ScrollBox and list.ScrollBox:GetDataProvider();
|
|
end
|
|
end
|
|
CreateFrame("Frame", nil, list):SetScript("OnUpdate", Watch);
|
|
Watch();
|
|
end
|
|
|
|
local f = CreateFrame("Frame");
|
|
f:RegisterEvent("ADDON_LOADED");
|
|
pcall(f.RegisterEvent, f, "INPUT_DEVICE_INTERFACE_TRANSITION"); -- install after a switch to mouse and keyboard
|
|
f:SetScript("OnEvent", function(_, event, arg1)
|
|
if event == "INPUT_DEVICE_INTERFACE_TRANSITION" then
|
|
Install(arg1); -- arg1 is the new style
|
|
elseif arg1 == "Blizzard_Communities" then
|
|
Install();
|
|
end
|
|
end);
|
|
if C_AddOns and C_AddOns.IsAddOnLoaded("Blizzard_Communities") then Install(); end
|