Permalink
Browse files

Merge pull request #3 from yanivkalfa/feature_queue_and_unqueue_to_ev…

…ents

Feature queue and unqueue to events
  • Loading branch information...
yanivkalfa committed Mar 6, 2017
2 parents 776c33a + 3c0e27e commit 99888bb9068851ad4d7e179600e49f6794ae0026
@@ -27,39 +27,65 @@ function LFG.Actions.Event.clearSearch()
end

function LFG.Actions.Event.fetch()
LFG.Outgoing:send(LFG.Constants.EVENTS.ERQ, nil, {});
end

function LFG.Actions.Event.show(request)
LFG.Outgoing:send(LFG.Constants.EVENTS.E_REQUEST, nil, {});
end

function LFG.Actions.Event.create()
local event = LFG.Utils.Event.createEvent();
LFG.Outgoing:send(LFG.Constants.EVENTS.ECRS, nil, event);
LFG.Outgoing:send(LFG.Constants.EVENTS.E_CREATE, nil, event);
LFG.QueueScrollFrames.queueList = {};
LFG.QueueScrollFrames.updateLFGQueue();
LFG_Settings.event = event;
LFG.EventScrollFrames.newEvent = true;
LFG.Tabs.select("events.viewQueues");
DEFAULT_CHAT_FRAME:AddMessage("Create");
end

function LFG.Actions.Event.remind()
if ( LFG_Settings.event ) then
LFG.Outgoing:send(LFG.Constants.EVENTS.E_CREATE, nil, LFG_Settings.event);
end
end

function LFG.Actions.Event.update(request)
local event = LFG.Utils.Event.createEvent();
DEFAULT_CHAT_FRAME:AddMessage("event.I: ".. tostring(event.I));
LFG.Outgoing:send(LFG.Constants.EVENTS.EURS, nil, event);
LFG.Outgoing:send(LFG.Constants.EVENTS.E_UPDATE, nil, event);
LFG_Settings.event = event;
LFG.Tabs.select("events.viewQueues");
end

function LFG.Actions.Event.delete(request)
LFG.Outgoing:send(LFG.Constants.EVENTS.EDRQ, nil, {});
LFG.Outgoing:send(LFG.Constants.EVENTS.E_DELETE, nil, {});
LFG.QueueScrollFrames.queueList = {};
LFG.QueueScrollFrames.updateLFGQueue();
LFG_Settings.event = nil;
LFG.Tabs.select("events.view");
end

function LFG.Actions.Event.eventQueueIndex(request)
function LFG.Actions.Event.cancelQueue(name, event, hideEvent)

if( type(event) ~= "table") then
return false;
end

if (type(event.QTE) == "table" and event.QTE.timer) then
Timer.clearTimer(event.QTE.timer);
end

event.QTE = nil;

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

if (name and not hideEvent) then
LFG.EventScrollFrames.LFGEventItemUpdateButton(name, event);
else
LFG.EventScrollFrames.updateLFGEvent();
end
end

function LFG.Actions.Event.eventQueueCreate(request)
@@ -1,27 +1,40 @@
LFG.Actions.Queue = {};
LFG.Actions.Queue = {
count = 0,
};
local tableUtils = LFG.Utils.Table;
local eventUtils = LFG.Utils.Events;

-- add to local queue list
--

function LFG.Actions.Queue.get(request)
function LFG.Actions.Queue.fetch()
LFG.Outgoing:send(LFG.Constants.EVENTS.Q_REQUEST, nil, {});
end

function LFG.Actions.Queue.create(request)
function LFG.Actions.Queue.create()
local name = LFG.RolePicker.name;
local event = LFG.RolePicker.event;
local roles = LFG.RolePicker.getRoles();
local noteToLeader = LFG.RolePicker.getNoteToLeader();
local queue = {
OR = event.OR,
C = LFG.Constants.CLASS_LIST_MAP[LFG_Settings.character.class],
LVL = LFG_Settings.character.level,
R = roles,
NTL = noteToLeader
};
event.QTE = {
expireAt = time() + LFG.Constants.QUEUE_TIMEOUT,
timer = Timer.setTimeout(LFG.Constants.QUEUE_TIMEOUT, LFG.Actions.Queue.cancel, { name, event, true } ),
queue = queue;
};
LFG.Actions.Queue.count = LFG.Actions.Queue.count + 1;
LFG.Outgoing:send(LFG.Constants.EVENTS.Q_CREATE, event.OR, queue);
LFG.EventScrollFrames.LFGEventItemUpdateButton(name, event);
end

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)
LFG.Actions.Event.cancelQueue(name, event, hideEvent);
LFG.Actions.Queue.count = LFG.Actions.Queue.count - 1;
LFG.Outgoing:send(LFG.Constants.EVENTS.Q_DELETE, event.OR, {});
end

function LFG.Actions.Queue.acceptQueue(name, index)
@@ -31,9 +44,7 @@ function LFG.Actions.Queue.acceptQueue(name, index)
LFG.QueueScrollFrames.LFGQueueItemUpdateButton(name, index)
end

function LFG.Actions.Queue.declineQueue(name, index)
--local queue = LFG.QueueScrollFrames.queueList[index];
--queue.INV = nil;
-- send server cancel request
--LFG.QueueScrollFrames.LFGQueueItemUpdateButton(name, index)
function LFG.Actions.Queue.delete(index)
table.remove(LFG.QueueScrollFrames.queueList, index);
LFG.QueueScrollFrames.updateLFGQueue()
end
@@ -1,7 +1,6 @@
LFG.EventDropDownMenu = {};

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

@@ -13,13 +12,12 @@ function LFG.EventDropDownMenu.OnClick()
return false
end

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

elseif(this.arg1 == "cancel") then
LFG.Actions.Queue.cancel(name, event);
end
if(this.arg1 == "signup") then
LFG.RolePicker.Show(name, event);
elseif(this.arg1 == "whisperOwner") then
LFG.Whisper.show(event.OR);
elseif(this.arg1 == "cancel") then
LFG.Actions.Queue.cancel(name, event);
end
end

@@ -32,6 +30,9 @@ function LFG.EventDropDownMenu.Initialize()
info.text = "Sign Up";
info.arg1 = "signup";
UIDropDownMenu_AddButton(info);
info.text = "Whisper Owner";
info.arg1 = "whisperOwner";
UIDropDownMenu_AddButton(info);
end

if(event and event.QTE) then
@@ -4,7 +4,8 @@ LFG.EventScrollFrames = {
eventList = {},
filter = nill,
searchBouncer = nil,
fatchedInitially = nil
fetchedInitially = nil,
newEvent = nil
};

function LFG.EventScrollFrames.resetSelection(event)
@@ -162,7 +163,7 @@ 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, eventList;
local line, index, LFGEventItemButton, LFGEventItemName, totalResults, eventList, LFGEventItemButton_EventMembersCount;
eventList = table.filter(LFG.EventScrollFrames.eventList, filter);
totalResults = table.getn(eventList);

@@ -174,6 +175,15 @@ function LFG.EventScrollFrames.updateLFGEvent()
index = line + FauxScrollFrame_GetOffset(LFGEventScrollFrame);
LFGEventItemName = "LFGEventItem"..line;
LFGEventItemButton = getglobal(LFGEventItemName);
LFGEventItemButton_EventMembersCount = getglobal(LFGEventItemName.."EventMembersCount");

if ( totalResults > LFG.Constants.MAX_PAGE_SIZE ) then
LFGEventItemButton:SetWidth(297);
LFGEventItemButton_EventMembersCount:SetPoint("LEFT", 275, 0);
else
LFGEventItemButton:SetWidth(316);
LFGEventItemButton_EventMembersCount:SetPoint("LEFT", 295, 0);
end

if (index <= totalResults) then
LFGEventItemButton:Show();
@@ -0,0 +1,46 @@
LFG.Utils.Friend = {
temp = nill,
added = nill
};

function LFG.Utils.Friend.getFriendInfoFromList(playerName)
local maxFriends, name, level, class ;
maxFriends = LFG.Constants.MAX_FRIENDS;

for i = 1, maxFriends do
name, level, class = GetFriendInfo(i);
if (name == playerName) then
return i, name, level, class;
end
end
end

function LFG.Utils.Friend.reset()
LFG.Utils.Friend.temp = nill;
LFG.Utils.Friend.added = nill;
end

function LFG.Utils.Friend.addFriendCheck(playerName)
local maxFriends, numFriends, index, name, level, class;

maxFriends = LFG.Constants.MAX_FRIENDS;
numFriends = GetNumFriends();
if(numFriends >= maxFriends) then
LFG.Utils.Friend.temp = GetFriendInfo(maxFriends);
RemoveFriend(maxFriends);
end
AddFriend(playerName);
LFG.Utils.Friend.added = playerName;
end

function LFG.Utils.Friend.resetFriendCheck(index)
RemoveFriend(index);
if (LFG.Utils.Friend.temp) then
AddFriend(LFG.Utils.Friend.temp);
end
LFG.Utils.Friend.reset();
end




@@ -2,32 +2,35 @@ LFG.QueueDropDownMenu = {};

function LFG.QueueDropDownMenu.OnClick()
--DEFAULT_CHAT_FRAME:AddMessage("UIDROPDOWNMENU_MENU_VALUE".. UIDROPDOWNMENU_MENU_VALUE);
local id = this:GetID();
local id = this:GetID();
local name = LFG.QueueScrollFrames.queueDropDownFocus.name;
local index = LFG.QueueScrollFrames.queueDropDownFocus.index;

if ( id == 1 ) then
if(this.arg1 == "signup") then
LFG.RolePicker.Show(name, index);
elseif(this.arg1 == "cancel") then
LFG.Actions.Queue.cancel(name, index);
end
local queue = LFG.QueueScrollFrames.queueList[index];

if(this.arg1 == "signup") then
LFG.RolePicker.Show(name, index);
elseif(this.arg1 == "whisperOwner") then
LFG.Whisper.show(queue.OR);
elseif(this.arg1 == "cancel") then
LFG.Actions.Queue.cancel(name, index);
end
end

function LFG.QueueDropDownMenu.Initialize()
local index = LFG.QueueScrollFrames.queueDropDownFocus.index;
local index = LFG.QueueScrollFrames.queueDropDownFocus.index;
local queue = LFG.QueueScrollFrames.queueList[index];
local info = {};

local info = {};
info.func = LFG.QueueDropDownMenu.OnClick;
if(not queue or not queue.QTE) then
info.text = "Sign Up";
info.arg1 = "signup";
UIDropDownMenu_AddButton(info);
info.text = "Whisper Player";
info.arg1 = "whisperOwner";
UIDropDownMenu_AddButton(info);
end

if(queue and queue.QTE) then
info.text = "Cancel";
info.arg1 = "cancel";
@@ -36,5 +39,5 @@ function LFG.QueueDropDownMenu.Initialize()
end

function LFG.QueueDropDownMenu.OnLoad()
UIDropDownMenu_Initialize(this, LFG.QueueDropDownMenu.Initialize, "MENU");
UIDropDownMenu_Initialize(this, LFG.QueueDropDownMenu.Initialize, "MENU");
end
Oops, something went wrong.

0 comments on commit 99888bb

Please sign in to comment.