Permalink
Browse files

Merge pull request #2 from yanivkalfa/changing_search_to_work_directl…

…y_on_eventList

Changing search to work directly on event list
  • Loading branch information...
yanivkalfa committed Mar 2, 2017
2 parents 8186093 + adf15e8 commit 776c33aa1e3a9b96dc55235e24b1d870afb6f306
@@ -13,43 +13,17 @@ function LFG.Actions.Event.search()
return false;
end

DEFAULT_CHAT_FRAME:AddMessage("text: "..text);

LFG.EventScrollFrames.searchBouncer = Timer.setTimeout(1, function()
DEFAULT_CHAT_FRAME:AddMessage("executing searchBouncer: ");
if ( type(LFG.EventScrollFrames.eventListBackup) == "table" ) then
LFG.EventScrollFrames.eventList = LFG.EventScrollFrames.eventListBackup;
end
LFG.EventScrollFrames.eventListBackup = LFG.EventScrollFrames.eventList;
LFG.EventScrollFrames.eventList = table.filter(LFG.EventScrollFrames.eventList, function(index, value)
DEFAULT_CHAT_FRAME:AddMessage("in filter: "..index);
local title = strlower(value.TT);
local description = strlower(value.DC);
local queueTo = strlower(LFG.Constants.EVENT_LIST[value.QT].name);

local inTitle = string.find(title, text) or title == text;
local inDescription = string.find(description, text) or description == text;
local inQueueTo = string.find(queueTo, text) or queueTo == text;
local InLevel = string.find(value.ML, text) or value.ML == text;

DEFAULT_CHAT_FRAME:AddMessage("inTitle, inDescription, inQueueTo, InLevel: "..tostring(inTitle)..", "..tostring(inDescription)..", "..tostring(inQueueTo)..", "..tostring(InLevel));
if(not inTitle and not inDescription and not inQueueTo and not InLevel ) then
return true;
end
return false;
end)
LFG.EventScrollFrames.filter = text;
LFG.EventScrollFrames.updateLFGEvent();
Timer.clearTimer(LFG.EventScrollFrames.searchBouncer);
end)
DEFAULT_CHAT_FRAME:AddMessage("LFG.EventScrollFrames.searchBouncer: "..LFG.EventScrollFrames.searchBouncer);
end

function LFG.Actions.Event.clearSearch()
if ( type(LFG.EventScrollFrames.eventListBackup) == "table" ) then
LFG.EventScrollFrames.eventList = LFG.EventScrollFrames.eventListBackup;
LFG.EventScrollFrames.eventListBackup = nil;
LFG.EventScrollFrames.updateLFGEvent();
LFGEventsViewSearch:SetText("");
end
LFG.EventScrollFrames.filter = nil;
LFG.EventScrollFrames.updateLFGEvent();
LFGEventsViewSearch:SetText("");
end

function LFG.Actions.Event.fetch()
@@ -11,8 +11,15 @@ end
function LFG.Actions.Queue.create(request)
end

function LFG.Actions.Queue.cancel(name, event)
function LFG.Actions.Queue.cancel(name, event, hideEvent)
event.QTE = nil;

if (hideEvent) then
event.hide = true;
LFG.EventScrollFrames.resetSelection(event);
LFG.RolePicker.reset(event);
end

-- send server cancel request
LFG.EventScrollFrames.LFGEventItemUpdateButton(name, event)
end
@@ -1,15 +1,23 @@
LFG.EventDropDownMenu = {};

function LFG.EventDropDownMenu.OnClick()
local id = this:GetID();
local id = this:GetID();
local name = LFG.EventScrollFrames.eventDropDownFocus.name;
local event = LFG.EventScrollFrames.eventDropDownFocus.event;

if ( id == 1 ) then

if ( not event ) then
return false
end

if ( event.hide ) then
return false
end

if ( id == 1 ) then
if(this.arg1 == "signup") then
LFG.RolePicker.Show(name, event);
elseif(this.arg1 == "cancel") then

elseif(this.arg1 == "cancel") then
LFG.Actions.Queue.cancel(name, event);
end
end
@@ -2,20 +2,31 @@ LFG.EventScrollFrames = {
eventSelected = { event = {}, name = '' },
eventDropDownFocus = { event = {}, name = '' },
eventList = {},
eventListBackup = nil,
filter = nill,
searchBouncer = nil,
fatchedInitially = nil
};

function LFG.EventScrollFrames.LFGEventQueueToEvent(name, index)

end
function LFG.EventScrollFrames.resetSelection(event)

if( not event ) then
return false
end

if( LFG.EventScrollFrames.eventSelected.event.OR == event.OR) then
LFG.EventScrollFrames.eventSelected = { event = {}, name = '' }
end

if(LFG.EventScrollFrames.eventDropDownFocus.event.OR == event.OR) then
LFG.EventScrollFrames.eventDropDownFocus = { event = {}, name = '' };
end

LFG.EventScrollFrames.updateLFGEvent();

function LFG.EventScrollFrames.LFGEventUnQueueToEvent(name, index)

end



function LFG.EventScrollFrames.LFGEventResetSelected()
for line=1,LFG.Constants.MAX_PAGE_SIZE do
getglobal("LFGEventItem"..line):SetButtonState("NORMAL");
@@ -122,10 +133,38 @@ function LFG.EventScrollFrames.LFGEventItemUpdateButton(LFGEventItemName, event)
LFGEventItemButton_EventMembersCount:SetText(event.PIE);
end

local function filter(index, value)
if (value.hide) then
return true;
end

local text = LFG.EventScrollFrames.filter;

if (not text) then
return false;
end

local title = strlower(value.TT);
local description = strlower(value.DC);
local queueTo = strlower(LFG.Constants.EVENT_LIST[value.QT].name);

local inTitle = string.find(title, text) or title == text;
local inDescription = string.find(description, text) or description == text;
local inQueueTo = string.find(queueTo, text) or queueTo == text;
local InLevel = string.find(value.ML, text) or value.ML == text;

--DEFAULT_CHAT_FRAME:AddMessage("inTitle, inDescription, inQueueTo, InLevel: "..tostring(inTitle)..", "..tostring(inDescription)..", "..tostring(inQueueTo)..", "..tostring(InLevel));
if(not inTitle and not inDescription and not inQueueTo and not InLevel ) then
return true;
end
return false;
end

function LFG.EventScrollFrames.updateLFGEvent()
-- 1 through 5 of our window to scroll , an index into our data calculated from the scroll offset
local line, index, LFGEventItemButton, LFGEventItemName, totalResults;
totalResults = table.getn(LFG.EventScrollFrames.eventList);
local line, index, LFGEventItemButton, LFGEventItemName, totalResults, eventList;
eventList = table.filter(LFG.EventScrollFrames.eventList, filter);
totalResults = table.getn(eventList);

-- hiding tooltips to avoid incorrect data
GameTooltip:Hide();
@@ -138,10 +177,10 @@ function LFG.EventScrollFrames.updateLFGEvent()

if (index <= totalResults) then
LFGEventItemButton:Show();
LFGEventItemButton.event = LFG.EventScrollFrames.eventList[index];
LFGEventItemButton.event = eventList[index];
LFG.EventScrollFrames.LFGEventItemUpdateButton(LFGEventItemName, LFGEventItemButton.event);
else
LFGEventItemButton.event = nil;
LFGEventItemButton.event = {};
LFGEventItemButton:Hide();
end
end
@@ -3,26 +3,6 @@ LFG.RolePicker = {
event = nil
};

function LFG.RolePicker.reset()
LFGRolePickerNoteToLeader:SetText("");
LFGRoleTankCheckButton:SetChecked(false);
LFGRoleHealCheckButton:SetChecked(false);
LFGRoleDPSCheckButton:SetChecked(false);

if(LFG_Settings.lastRoleSelected.T) then
DEFAULT_CHAT_FRAME:AddMessage("T");
LFGRoleTankCheckButton:SetChecked(true);
end
if(LFG_Settings.lastRoleSelected.H) then
DEFAULT_CHAT_FRAME:AddMessage("H");
LFGRoleHealCheckButton:SetChecked(true);
end
if(LFG_Settings.lastRoleSelected.D) then
DEFAULT_CHAT_FRAME:AddMessage("D");
LFGRoleDPSCheckButton:SetChecked(true);
end
end

function LFG.RolePicker.fixPresets(fames)
local famesCount = table.getn(fames);

@@ -39,11 +19,13 @@ function LFG.RolePicker.fixPresets(fames)
end

function LFG.RolePicker.prepare()

local roles = {
{ name = "T", frame=LFGRoleTankCheckButtonFrame },
{ name = "H", frame=LFGRoleHealCheckButtonFrame },
{ name = "D", frame=LFGRoleDPSCheckButtonFrame }
};

local frames, class, role;
frames = {};
class = LFG.Constants.ROLE_FOR_CLASS_LIST[LFG_Settings.character.class];
@@ -82,21 +64,46 @@ function LFG.RolePicker.signUp()
return false;
end
local noteToLeader = LFG.RolePicker.getNoteToLeader();
event.QTE = { expireAt = time() + 300, timer = Timer.setTimeout(299, LFG.Actions.Queue.cancel, { name, event } )};
event.QTE = { expireAt = time() + 10, timer = Timer.setTimeout(10, LFG.Actions.Queue.cancel, { name, event, true } )};
-- send server cancel request
LFG.EventScrollFrames.LFGEventItemUpdateButton(name, event);

LFGRolePicker:Hide();
end

function LFG.RolePicker.reset(event)
if ( event and LFG.RolePicker.event and LFG.RolePicker.event.OR == event.OR) then
LFG.RolePicker.cancel()
end
end

function LFG.RolePicker.cancel()
LFGRolePicker:Hide();
LFG.RolePicker.name = "";
LFG.RolePicker.name = nil;
LFGRolePickerNoteToLeader:SetText("");
LFGRoleTankCheckButton:SetChecked(false);
LFGRoleHealCheckButton:SetChecked(false);
LFGRoleDPSCheckButton:SetChecked(false);

if(LFG_Settings.lastRoleSelected.T) then
DEFAULT_CHAT_FRAME:AddMessage("T");
LFGRoleTankCheckButton:SetChecked(true);
end
if(LFG_Settings.lastRoleSelected.H) then
DEFAULT_CHAT_FRAME:AddMessage("H");
LFGRoleHealCheckButton:SetChecked(true);
end
if(LFG_Settings.lastRoleSelected.D) then
DEFAULT_CHAT_FRAME:AddMessage("D");
LFGRoleDPSCheckButton:SetChecked(true);
end
end

function LFG.RolePicker.Show(name, event)
LFG.RolePicker.cancel()
LFG.RolePicker.name = name;
LFG.RolePicker.event = event;
LFG.RolePicker.reset()
LFG.RolePicker.prepare()
LFGRolePicker:Show();
end
@@ -260,7 +260,7 @@
</Anchors>
</FontString>

<FontString name="$parentPendingText" inherits="GameFontHighlight" justifyH="LEFT" text="Pending - 4:38" hidden="true">
<FontString name="$parentPendingText" inherits="GameFontHighlight" justifyH="LEFT" hidden="true">
<Color r="0.12" g="1" b="0.12"/>
<Size>
<AbsDimension x="90" y="15"/>
@@ -16,6 +16,9 @@ function LFG.Incoming.EDRQ(payload, sender, language, channelString, target, fla
end);

if (foundIndex >= 1) then
local event = LFG.EventScrollFrames.eventList[foundIndex];
LFG.EventScrollFrames.resetSelection(event);
LFG.RolePicker.reset(event);
table.remove(LFG.EventScrollFrames.eventList, foundIndex);
LFG.EventScrollFrames.updateLFGEvent();
-- update queue status for the "searching eye"

0 comments on commit 776c33a

Please sign in to comment.