Go Back   WowAce Forums > General > Lua Code Discussion
Lua Code Discussion You scared? Terrified. Mortified. Petrified. Stupefied... by [coding].

Reply
 
Thread Tools
Old 04-15-2009   #1
DigitalSorceress
Junior Member
 
DigitalSorceress's Avatar
 
Join Date: Oct 2008
Location: Massachusetts
Posts: 87
Default AcceptGroup() and StaticPopup_Hide()

I've got a feature to auto accept group invites in my MultiTool addon if certain conditions are met...

Code:
self:RegisterEvent("PARTY_INVITE_REQUEST", "confirmPartyInvite")

function MultiTool:confirmPartyInvite(info, sender)

  if (self.db.profile.groupRejectFlag and not self:isInWhiteList(sender)) then
    DeclineGroup()
    StaticPopup_Hide("PARTY_INVITE")
    return
  elseif (self.db.profile.groupFlag and self:isInWhiteList(sender)) then
    AcceptGroup()
    StaticPopup_Hide("PARTY_INVITE")
    return
  end
end
My problem is that it looks as though the call to StaticPopup_Hide("PARTY_INVITE") is happening so soon after AcceptGroup() that AcceptGroup() ends up getting overridden by the popup hide.

I can put in some kind of delay, or otherwise change the way the code works and probably get it working, but I wanted to post here in case either someone else already figured it out, or else to let folks know that it appears there was some undocumented (as far as I can see) change in the way the StaticPopup_Hide("PARTY_INVITE") is being handled.
DigitalSorceress is offline   Reply With Quote
Old 04-15-2009   #2
Dridzt
Hero Member
 
Dridzt's Avatar
 
Join Date: Nov 2005
Posts: 872
Default Re: AcceptGroup() and StaticPopup_Hide()

I put an OnUpdate in my code and check at 0.2 intervals for GetNumPartyMembers()>0 before hiding the static popup.

I only SetScript the OnUpdate in the PARTY_INVITE_REQUEST event
and nil it after hiding the popup.
Dridzt is offline   Reply With Quote
Old 04-15-2009   #3
Borlox
Full Member
 
Borlox's Avatar
 
Join Date: Nov 2006
Location: Germany
Posts: 141
Default Re: AcceptGroup() and StaticPopup_Hide()

Putting the following code before the call to StaticPopup_Hide should prevent the Popup from declining the invite:

Code:
for i=1, STATICPOPUP_NUMDIALOGS do
    local dlg = _G["StaticPopup"..i]
    if dlg.which == "PARTY_INVITE" then
        dlg.inviteAccepted = 1
        break
    end
end
It loops through all StaticPopups and sets the inviteAccepted flag for the one that is showing the invite message.
__________________
http://xkcd.com/378/
Borlox is offline   Reply With Quote
Old 04-15-2009   #4
DigitalSorceress
Junior Member
 
DigitalSorceress's Avatar
 
Join Date: Oct 2008
Location: Massachusetts
Posts: 87
Default Re: AcceptGroup() and StaticPopup_Hide()

Thank you both for the suggestions.

I was thinking along slightly different lines, but I think either of these will work out better for me.

Still curious if 3.1 just plain changed something, or if I've had broken code all along, but was getting away with it until high server lag during patch day caused the "brokenness" to show through.
DigitalSorceress is offline   Reply With Quote
Old 04-15-2009   #5
Dridzt
Hero Member
 
Dridzt's Avatar
 
Join Date: Nov 2005
Posts: 872
Default Re: AcceptGroup() and StaticPopup_Hide()

Borlox workaround is more elegant.
Dridzt is offline   Reply With Quote
Old 04-15-2009   #6
Tekkub
Wiki Master
 
Tekkub's Avatar
 
Join Date: Feb 2005
Posts: 5,086
Default Re: AcceptGroup() and StaticPopup_Hide()

I'm going to dig into the default UI later tonight and see EXACTLY what it does now, so that we can duplicate that.
Tekkub is offline   Reply With Quote
Old 04-15-2009   #7
OrionShock
Legendary Member
 
OrionShock's Avatar
 
Join Date: May 2006
Location: Arizona
Posts: 3,787
Default Re: AcceptGroup() and StaticPopup_Hide()

while it might be a bit hacky, why not just use the static popu's own scripts?

You loop though it to find the dialoug, why not just call the accept buttons :Click() script?
__________________
Author of GuildCraft, SickOfClickingDailies, CursorCooldown, Broken_LFD
WoWAce Addon List WoWInterface Addon List

"I was there in the beginning... and things were very different back then" --An Echo from a time before.
OrionShock is offline   Reply With Quote
Old 04-16-2009   #8
Farmbuyer
Amazing Member
 
Farmbuyer's Avatar
 
Join Date: Feb 2005
Posts: 1,110
Default Re: AcceptGroup() and StaticPopup_Hide()

Quote:
Originally Posted by DigitalSorceress View Post
Still curious if 3.1 just plain changed something, or if I've had broken code all along, but was getting away with it until high server lag during patch day caused the "brokenness" to show through.
The 'Group' module in Automaton (not yet updated for 3.1) is suffering from a similar problem. Going to add the inviteAccepted workaround locally and see if it helps (it should).

edit: it does. left a comment on the automaton wowace page.

Last edited by Farmbuyer; 04-16-2009 at 01:44 AM.
Farmbuyer is offline   Reply With Quote
Old 04-16-2009   #9
weab
Newbie
 
Join Date: Oct 2008
Posts: 3
Default Re: AcceptGroup() and StaticPopup_Hide()

I registered the PARTY_MEMBERS_CHANGED event and close the static popup in Automaton that way. Works dandy.
weab is offline   Reply With Quote
Old 04-16-2009   #10
jerry
Amazing Member
 
Join Date: Jul 2006
Posts: 1,461
Default Re: AcceptGroup() and StaticPopup_Hide()

Why not simply:
Code:
UIParent:UnregisterEvent"PARTY_INVITE_REQUEST"
and choose yourself wether or not showing a Dialog in your code ?
jerry is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:06 PM.