Permalink
Browse files

Merge pull request #1 from yanivkalfa/change_index_to_entry

scroll buttons now have entire event not just index
  • Loading branch information...
yanivkalfa committed Mar 2, 2017
2 parents 37d157e + 79f3e1f commit 81860935887b80529c216f6c5084f09105a76b1d
@@ -11,11 +11,10 @@ end
function LFG.Actions.Queue.create(request)
end

function LFG.Actions.Queue.cancel(name, index)
local event = LFG.EventScrollFrames.eventList[index];
function LFG.Actions.Queue.cancel(name, event)
event.QTE = nil;
-- send server cancel request
LFG.EventScrollFrames.LFGEventItemUpdateButton(name, index)
LFG.EventScrollFrames.LFGEventItemUpdateButton(name, event)
end

function LFG.Actions.Queue.acceptQueue(name, index)
@@ -1,26 +1,24 @@
LFG.EventDropDownMenu = {};

function LFG.EventDropDownMenu.OnClick()
--DEFAULT_CHAT_FRAME:AddMessage("UIDROPDOWNMENU_MENU_VALUE".. UIDROPDOWNMENU_MENU_VALUE);
local id = this:GetID();
local name = LFG.EventScrollFrames.eventDropDownFocus.name;
local index = LFG.EventScrollFrames.eventDropDownFocus.index;
local event = LFG.EventScrollFrames.eventDropDownFocus.event;

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

elseif(this.arg1 == "cancel") then
LFG.Actions.Queue.cancel(name, index);
LFG.Actions.Queue.cancel(name, event);
end
end
end

function LFG.EventDropDownMenu.Initialize()
local index = LFG.EventScrollFrames.eventDropDownFocus.index;
local event = LFG.EventScrollFrames.eventList[index];

local info = {};
local event = LFG.EventScrollFrames.eventDropDownFocus.event;

local info = {};
info.func = LFG.EventDropDownMenu.OnClick;
if(not event or not event.QTE) then
info.text = "Sign Up";
@@ -1,6 +1,6 @@
LFG.EventScrollFrames = {
eventSelected = { index=0, name='' },
eventDropDownFocus = { index=0, name='' },
eventSelected = { event = {}, name = '' },
eventDropDownFocus = { event = {}, name = '' },
eventList = {},
eventListBackup = nil,
searchBouncer = nil,
@@ -23,44 +23,43 @@ function LFG.EventScrollFrames.LFGEventResetSelected()
end

function LFG.EventScrollFrames.LFGEventOnClick(button)
--DEFAULT_CHAT_FRAME:AddMessage("aaaaaaa".. self.GetName());
-- if left we select the row
if ( button == "LeftButton") then
LFG.EventScrollFrames.LFGEventResetSelected()
LFG.EventScrollFrames.eventSelected = { index=this.eventIndex, name=this:GetName() };
if(not LFG.EventScrollFrames.eventList[this.eventIndex].QTE) then
LFG.EventScrollFrames.eventSelected = { event = this.event, name = this:GetName() };
if(not this.event.QTE) then
this:SetButtonState("PUSHED", true);
end
else
CloseDropDownMenus()
LFG.EventScrollFrames.eventDropDownFocus = { index=this.eventIndex, name=this:GetName() };
LFG.EventScrollFrames.eventDropDownFocus = { event = this.event, name = this:GetName() };
ToggleDropDownMenu(1, nil, LFGEventDropDownMenu, "cursor")
end
end

function LFG.EventScrollFrames.LFGEventCreateToolTip(index)
local Owner = LFG.EventScrollFrames.eventList[index].OR;
local title = LFG.EventScrollFrames.eventList[index].TT or "";
local description = LFG.EventScrollFrames.eventList[index].DC or "";
local minLevel = LFG.EventScrollFrames.eventList[index].ML;
local timeStamp = LFG.EventScrollFrames.eventList[index].TS;
local queueTo = LFG.Constants.EVENT_LIST[LFG.EventScrollFrames.eventList[index].QT].name or "";
local PIE = LFG.EventScrollFrames.eventList[index].PIE or 0;
function LFG.EventScrollFrames.LFGEventCreateToolTip(event)
local Owner = event.OR;
local title = event.TT or "";
local description = event.DC or "";
local minLevel = event.ML;
local timeStamp = event.TS;
local queueTo = LFG.Constants.EVENT_LIST[event.QT].name or "";
local PIE = event.PIE or 0;
local toolTop = HIGHLIGHT_FONT_COLOR_CODE..title..FONT_COLOR_CODE_CLOSE.."\n";
toolTop = toolTop..NORMAL_FONT_COLOR_CODE..queueTo..FONT_COLOR_CODE_CLOSE.."\n";
toolTop = toolTop..GRAY_FONT_COLOR_CODE.."\""..description.."\""..FONT_COLOR_CODE_CLOSE.."\n\n";
toolTop = toolTop..NORMAL_FONT_COLOR_CODE.."Minimum Level Required: "..FONT_COLOR_CODE_CLOSE..HIGHLIGHT_FONT_COLOR_CODE..minLevel..FONT_COLOR_CODE_CLOSE.."\n\n";

toolTop = toolTop..NORMAL_FONT_COLOR_CODE.."Creator: "..FONT_COLOR_CODE_CLOSE..HIGHLIGHT_FONT_COLOR_CODE..Owner..FONT_COLOR_CODE_CLOSE.."\n";
toolTop = toolTop..NORMAL_FONT_COLOR_CODE.."Created: "..FONT_COLOR_CODE_CLOSE..HIGHLIGHT_FONT_COLOR_CODE..LFG.Utils.String.getTimeString(timeStamp)..FONT_COLOR_CODE_CLOSE.."\n\n";

toolTop = toolTop..NORMAL_FONT_COLOR_CODE.."Members: "..FONT_COLOR_CODE_CLOSE..HIGHLIGHT_FONT_COLOR_CODE..PIE..FONT_COLOR_CODE_CLOSE.."\n\n";

return toolTop
end

function LFG.EventScrollFrames.LFGEventOnEnter()
local toolTip = LFG.EventScrollFrames.LFGEventCreateToolTip(this.eventIndex);
local toolTip = LFG.EventScrollFrames.LFGEventCreateToolTip(this.event);
GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
GameTooltip:SetText(toolTip);
end
@@ -87,20 +86,20 @@ function LFG.EventScrollFrames.LFGEventOnLoad()
end
]]--

function LFG.EventScrollFrames.LFGEventItemUpdateButton(LFGEventItemName, index)
local LFGEventItemButton, LFGEventItemButton_Title, LFGEventItemButton_QueueTo,
LFGEventItemButton_EventMembersCount, LFGEventItemButton_PendingText,
function LFG.EventScrollFrames.LFGEventItemUpdateButton(LFGEventItemName, event)
local LFGEventItemButton, LFGEventItemButton_Title, LFGEventItemButton_QueueTo,
LFGEventItemButton_EventMembersCount, LFGEventItemButton_PendingText,
LFGEventItemButton_PendingTexture, LFGEventItemButton_PendingCancel;

LFGEventItemButton = getglobal(LFGEventItemName);
LFGEventItemButton_Title = getglobal(LFGEventItemName.."Title");
LFGEventItemButton_QueueTo = getglobal(LFGEventItemName.."QueueTo");
LFGEventItemButton_EventMembersCount = getglobal(LFGEventItemName.."EventMembersCount");
LFGEventItemButton_PendingText = getglobal(LFGEventItemName.."PendingText");
LFGEventItemButton_PendingTexture = getglobal(LFGEventItemName.."PendingTexture");
LFGEventItemButton_PendingCancel = getglobal(LFGEventItemName.."PendingCancel");
if(LFG.EventScrollFrames.eventList[index].QTE) then

if(event.QTE) then
LFGEventItemButton_EventMembersCount:Hide();
LFGEventItemButton_PendingText:Show();
LFGEventItemButton_PendingTexture:Show();
@@ -111,38 +110,38 @@ function LFG.EventScrollFrames.LFGEventItemUpdateButton(LFGEventItemName, index)
LFGEventItemButton_PendingText:Hide();
LFGEventItemButton_PendingTexture:Hide();
LFGEventItemButton_PendingCancel:Hide();
if (LFGEventItemButton.eventIndex == LFG.EventScrollFrames.eventSelected.index) then
if (LFGEventItemButton.event.OR == LFG.EventScrollFrames.eventSelected.event.OR) then
LFGEventItemButton:SetButtonState("PUSHED", true);
else
LFGEventItemButton:SetButtonState("NORMAL");
end
end
LFGEventItemButton_Title:SetText(LFG.EventScrollFrames.eventList[index].TT);
LFGEventItemButton_QueueTo:SetText(LFG.Constants.EVENT_LIST[LFG.EventScrollFrames.eventList[index].QT].name);
LFGEventItemButton_EventMembersCount:SetText(LFG.EventScrollFrames.eventList[index].PIE);

LFGEventItemButton_Title:SetText(event.TT);
LFGEventItemButton_QueueTo:SetText(LFG.Constants.EVENT_LIST[event.QT].name);
LFGEventItemButton_EventMembersCount:SetText(event.PIE);
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);

-- hiding tooltips to avoid incorrect data
GameTooltip:Hide();

FauxScrollFrame_Update(LFGEventScrollFrame, totalResults, LFG.Constants.MAX_PAGE_SIZE, LFG.Constants.EVENT_ITEM_HEIGHT);
for line=1,LFG.Constants.MAX_PAGE_SIZE do
index = line + FauxScrollFrame_GetOffset(LFGEventScrollFrame);
LFGEventItemName = "LFGEventItem"..line;
LFGEventItemButton = getglobal(LFGEventItemName);

if (index <= totalResults) then
LFGEventItemButton:Show();
LFGEventItemButton.eventIndex = index;
LFG.EventScrollFrames.LFGEventItemUpdateButton(LFGEventItemName, index);
LFGEventItemButton.event = LFG.EventScrollFrames.eventList[index];
LFG.EventScrollFrames.LFGEventItemUpdateButton(LFGEventItemName, LFGEventItemButton.event);
else
LFGEventItemButton.eventIndex = nil;
LFGEventItemButton.event = nil;
LFGEventItemButton:Hide();
end
end
@@ -11,7 +11,7 @@ LFG.EventSelectMenu = {
function LFG.EventSelectMenu:setCurrentPage(level)

--LFG.EventSelectMenu.minEventLevel = LFG_Settings.character.faction == "Alliance" and 17 or 13;
self.currentPage = level or 6;--level or LFG_Settings.character.level;
self.currentPage = level or LFG_Settings.character.level;--level or LFG_Settings.character.level;
self.first = self.currentPage <= 6 ;
self.last = self.currentPage >= self.totalEvents - 6;
end
@@ -48,7 +48,8 @@ function LFG.EventSelectMenu.setText(text)
end

function LFG.EventSelectMenu.OnClick()
local id = this:GetID(), Self, prevLevel, nextLevel, checkImage, text;
local id, Self, prevLevel, nextLevel, checkImage, text;
id = this:GetID();
Self = LFG.EventSelectMenu;

checkImage = getglobal("DropDownList1Button"..id.."Check");
@@ -78,7 +79,7 @@ function LFG.EventSelectMenu.OnClick()
end

function LFG.EventSelectMenu:renderMenuPage()
local info, startMenuPos, endMenuPos, event, eventName, faction, listFrameName;
local info, startMenuPos, endMenuPos, event, eventName, faction, listFrameName, button, normalText, width;
faction = LFG_Settings.character.faction == "Alliance" and "A" or "H";
startMenuPos = self.currentPage - 5;
endMenuPos = self.currentPage + 5;
@@ -116,8 +117,8 @@ function LFG.EventSelectMenu:renderMenuPage()
UIDropDownMenu_AddButton(info);


local button = getglobal(listFrameName.."Button"..i+2);
local normalText = getglobal(button:GetName().."NormalText");
button = getglobal(listFrameName.."Button"..i+2);
normalText = getglobal(button:GetName().."NormalText");
width = normalText:GetWidth() + 60;
if ( width > self.maxWidth ) then
self.maxWidth = width;
@@ -211,7 +212,7 @@ end


function LFG.EventSelectMenu.OnLoad()
UIDropDownMenu_Initialize(LFGEventSelectMenu, LFG.EventSelectMenu.Initialize);
UIDropDownMenu_Initialize(LFGEventSelectMenu, LFG.EventSelectMenu.Initialize);
UIDropDownMenu_SetWidth(270);
local text = getglobal(LFGEventSelectMenu:GetName().."Text");
text:SetJustifyH("LEFT");
@@ -39,15 +39,6 @@ function LFG.MinimapIcon:resetIcon()
end

function LFG.MinimapIcon:toggle()
--[[
self.Opened = not self.Opened;
if(self.Opened) then
LFGFrame:Show();
else
LFGFrame:Hide();
end
]]--

if( LFGFrame:IsVisible() ) then
HideUIPanel(LFGFrame);
else
@@ -1,10 +1,6 @@
--[[
fix bug where role selection is not saved
add a check that at least 1 role is selected
]]--
LFG.RolePicker = {
name = "",
index = ""
event = nil
};

function LFG.RolePicker.reset()
@@ -48,9 +44,9 @@ function LFG.RolePicker.prepare()
{ name = "H", frame=LFGRoleHealCheckButtonFrame },
{ name = "D", frame=LFGRoleDPSCheckButtonFrame }
};
local frames = {};

local class = LFG.Constants.ROLE_FOR_CLASS_LIST[LFG_Settings.character.class], role;
local frames, class, role;
frames = {};
class = LFG.Constants.ROLE_FOR_CLASS_LIST[LFG_Settings.character.class];
for i = 1, 3 do
role = roles[i];
role.frame:Hide();
@@ -80,16 +76,15 @@ end

function LFG.RolePicker.signUp()
local name = LFG.RolePicker.name;
local index = LFG.RolePicker.index;
local event = LFG.EventScrollFrames.eventList[index];
local event = LFG.RolePicker.event;
local roles = LFG.RolePicker.getRoles();
if( not event or not LFG.RolePicker.roleSelected(roles) ) then
return false;
end
local noteToLeader = LFG.RolePicker.getNoteToLeader();
event.QTE = { expireAt = time() + 300, timer = Timer.setTimeout(299, LFG.Actions.Queue.cancel, { name, index } )};
event.QTE = { expireAt = time() + 300, timer = Timer.setTimeout(299, LFG.Actions.Queue.cancel, { name, event } )};
-- send server cancel request
LFG.EventScrollFrames.LFGEventItemUpdateButton(name, index);
LFG.EventScrollFrames.LFGEventItemUpdateButton(name, event);

LFGRolePicker:Hide();
end
@@ -98,10 +93,9 @@ function LFG.RolePicker.cancel()
LFGRolePicker:Hide();
end

function LFG.RolePicker.Show(name, index)
function LFG.RolePicker.Show(name, event)
LFG.RolePicker.name = name;
LFG.RolePicker.index = index;
local event = LFG.EventScrollFrames.eventList[index];
LFG.RolePicker.event = event;
LFG.RolePicker.reset()
LFG.RolePicker.prepare()
LFGRolePicker:Show();
@@ -51,7 +51,7 @@ function LFG.Tabs.update()
end

LFG.EventSelectMenu.selected = LFG_Settings.event.QT;
text = LFG.Constants.EVENT_LIST[LFG_Settings.event.QT].name;
local text = LFG.Constants.EVENT_LIST[LFG_Settings.event.QT].name;
LFG.EventSelectMenu.setText(text);
LFGEventTitle:SetText(LFG_Settings.event.TT);
LFGEventDescription:SetText(LFG_Settings.event.DC);
11 LFG.xml
@@ -294,7 +294,7 @@
<OnClick>
local parent = this:GetParent();
local parentName = parent:GetName();
LFG.Actions.Queue.cancel(parentName, parent.eventIndex);
LFG.Actions.Queue.cancel(parentName, parent.event);
</OnClick>
</Scripts>
<NormalTexture file="Interface\Buttons\CancelButton-Up"/>
@@ -313,12 +313,11 @@
this.time = 0;
this:RegisterForClicks("LeftButtonUp","RightButtonUp");
</OnLoad>
<OnUpdate>
<OnUpdate>
this.time = this.time + arg1;
if( this.time >= 1) then
local name = this:GetName();
local index = this.eventIndex;
local event = LFG.EventScrollFrames.eventList[index];
local event = this.event;
if(event.QTE) then
local remining = event.QTE.expireAt - time();
if(remining > 0) then
@@ -714,8 +713,8 @@
</Anchors>
<Scripts>
<OnClick>
if(LFG.EventScrollFrames.eventSelected.index >= 1) then
LFG.RolePicker.Show(LFG.EventScrollFrames.eventSelected.name, LFG.EventScrollFrames.eventSelected.index);
if(LFG.EventScrollFrames.eventSelected.event.OR) then
LFG.RolePicker.Show(LFG.EventScrollFrames.eventSelected.name, LFG.EventScrollFrames.eventSelected.event);
end
</OnClick>
</Scripts>
@@ -1,3 +1,2 @@
# LFG

<b>Looking for a group wow vanilla addon</b>

0 comments on commit 8186093

Please sign in to comment.