Thread Tools Display Modes
03-10-14, 11:01 AM   #1
ghozt
A Deviate Faerie Dragon
Join Date: Apr 2011
Posts: 10
Question BG Queue Event and Inserting Images

I'm really new to LUA/Wow-addons, but I have a programming background. I have a few simple questions & I can't seem to find an answer.

So I've found that "LFG_PROPOSAL_SHOW" is the event that takes place when a LFG/LFR queue is found. Is there an equivalent for Battlegrounds?

How do I just a small image into one of my frames? Say for example: test.tga in the same folder as my addon.

Thanks in advance.
  Reply With Quote
03-10-14, 03:00 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
(1) According to a quick grep through the default UI, the event you're looking for is "BATTLEFIELD_MGR_ENTRY_INVITE". See Blizzard's usage in FrameXML/PVPHelper.lua for arguments, related functions/events, etc.

(2) Assuming you have a 32x32px image that you want to display immediately to the right of the frame:

Lua Code:
  1. -- Create the texture object:
  2. local texture = MyFrame:CreateTexture(nil, "ARTWORK")
  3. -- Place it:
  4. texture:SetPoint("LEFT", MyFrame, "RIGHT", 10, 0)
  5. -- Give it a size:
  6. texture:SetSize(32, 32)
  7. -- And tell it what file to display:
  8. texture:SetTexture("Interface\\AddOns\\MyAddon\\test")
  9. -- Attach it as a frame member for easier programmatic access later:
  10. MyFrame.texture = texture

Replace "MyFrame" with the actual name of your frame, etc.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
03-10-14, 05:13 PM   #3
ghozt
A Deviate Faerie Dragon
Join Date: Apr 2011
Posts: 10
Wow thanks Phanx! It's not always you post a topic and your hero replies. I tested the script you posted, but it's just showing a green square. I've blurred out the text as I am not ready to reveal my addon yet.. I tried reloading the client. I am using a .tga 32/32. I've attached the tga and the results..
Attached Thumbnails
Click image for larger version

Name:	results.png
Views:	349
Size:	568.6 KB
ID:	8034  
Attached Files
File Type: tga qm.tga (995 Bytes, 158 views)
  Reply With Quote
03-10-14, 05:22 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Green square means one of two things:

(a) You used the wrong path. It should be the full path to the texture, starting with Interface, and omitting the file extension. If writing in Lua, you must either escape the backslashes by doubling them, or use literal string notation:
  • textureObject:SetTexture("Interface\\Addons\\MyAddon\\fileName")
  • textureObject:SetTexture([[Interface\Addons\MyAddon\fileName]])

(b) The file was not present when WoW launched. If you add files, you must restart the game client before they will be recognized.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
03-10-14, 09:07 PM   #5
ghozt
A Deviate Faerie Dragon
Join Date: Apr 2011
Posts: 10
Awesome, Thanks Phanx! It was a typo on my end. One last question, though. Is there anyway to keep the same exact size of the image despite what resolution the user is using? I really want to keep the image exactly the same across all resolutions and windows/full-screen mode. Oh, and also BATTLEFIELD_MGR_ENTRY_INVITE doesn't seem to work.

Code:
MyAddon:RegisterEvent("LFG_PROPOSAL_SHOW")
MyAddon:RegisterEvent("BATTLEFIELD_MGR_ENTRY_INVITE")
local function eventHandler(self, event, ...)
 MyAddon:Show()
end

Last edited by ghozt : 03-10-14 at 09:18 PM.
  Reply With Quote
03-11-14, 12:19 PM   #6
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Originally Posted by ghozt View Post
Awesome, Thanks Phanx! It was a typo on my end. One last question, though. Is there anyway to keep the same exact size of the image despite what resolution the user is using? I really want to keep the image exactly the same across all resolutions and windows/full-screen mode. Oh, and also BATTLEFIELD_MGR_ENTRY_INVITE doesn't seem to work.

Code:
MyAddon:RegisterEvent("LFG_PROPOSAL_SHOW")
MyAddon:RegisterEvent("BATTLEFIELD_MGR_ENTRY_INVITE")
local function eventHandler(self, event, ...)
 MyAddon:Show()
end
Show your entire code please, in this snippet it is unclear if you defined the eventhandler to the OnEvent script.

lua Code:
  1. local MyAddon = CreateFrame("Frame")
  2. MyAddon:RegisterEvent("LFG_PROPOSAL_SHOW")
  3. MyAddon:RegisterEvent("BATTLEFIELD_MGR_ENTRY_INVITE")
  4. MyAddon:SetScript("OnEvent", function(self, event, ...)
  5.     -- right here, self and MyAddon are the same. [i]self[/i] however is faster as it is defined in a deeper scope(function)
  6.     self:Show()
  7. end)
  Reply With Quote
03-11-14, 04:17 PM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by ghozt View Post
Is there anyway to keep the same exact size of the image despite what resolution the user is using? I really want to keep the image exactly the same across all resolutions and windows/full-screen mode.
That doesn't really make any sense... first of all, what does "exactly the same" even mean? 100 pixels on a 14" laptop screen is not "exactly the same" as 100 pixels on a 27" desktop monitor or a 64" wall-mounted TV panel.

Secondly, if you're talking about physical sizes, eg. "one inch", that still doesn't make sense, as one inch is nearly twice as big, subjectively speaking, to someone on a 14" laptop vs. someone on a 27" desktop, and practically invisible to someone playing on their TV from halfway across the room. Also, there's no API for getting the physical size of the user's monitor, or even the resolution of the user's monitor -- you can only determine the resolution of the WoW window.

Finally, "exactly the same" fails to take into account that people use different UI scales, even at the same monitor/window size and screen resolution. My eyesight sucks, for example, so I need things to be much bigger than someone with 20/20 vision. Even if your "exactly the same" size looks good to you on both a 14" laptop and a 27" desktop, it may be completely useless for me or someone with worse visual acuity.

So, without being more specific about what you actually mean by "exactly the same" and why you think this matters (eg. what role this texture plays in your Top Secret National Security Clearance Level 9000 Mystery Addon) I can't really help you.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
03-12-14, 08:20 AM   #8
ghozt
A Deviate Faerie Dragon
Join Date: Apr 2011
Posts: 10
Sorry ravegernl,

It does have an event handler for OnEvent. My LFG one does fire and show MyAddon's frame, but the LFG for PVP does not. I want all events to do the same thing (show my frame).

Code:
MyAddon:SetScript("OnEvent", eventHandler)
MyAddon:RegisterEvent("LFG_PROPOSAL_SHOW")
MyAddon:RegisterEvent("BATTLEFIELD_MGR_ENTRY_INVITE")
MyAddon:RegisterEvent("BATTLEFIELD_MGR_QUEUE_REQUEST_RESPONSE")
MyAddon:SetScript("OnMouseDown", function(self) self:Hide() end)

local function eventHandler(self, event, ...)
 MyAddon:Show()
end
Phanx, to give you more information. I am scanning the screen for that image with an outside program, if it is different sizes it's a lot harder to detect... if it gets it at all. I want the image in WoW to be the same size as the .tga in the Addon folder. Sorry I did not make sense the first time around. Maybe there is a way to get the scale and set it for just the image so that it remains the same size?

Last edited by ghozt : 03-12-14 at 08:23 AM.
  Reply With Quote
03-12-14, 08:31 AM   #9
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by ghozt View Post
Phanx, to give you more information. I am scanning the screen for that image with an outside program, if it is different sizes it's a lot harder to detect... if it gets it at all. I want the image in WoW to be the same size as the .tga in the Addon folder. Sorry I did not make sense the first time around. Maybe there is a way to get the scale and set it for just the image so that it remains the same size?
Sounds like a bot to me.
  Reply With Quote
03-12-14, 09:54 AM   #10
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
That code you posted doesn't work because you call SetScript before you have defined the local variable it references. Since all your scripts are doing is calling Hide/Show and the first argument passed is self then all you need to do is set Hide/Show directly to the script handler:
Code:
MyAddon:SetScript("OnEvent", MyAddon.Show)
MyAddon:RegisterEvent("LFG_PROPOSAL_SHOW")
MyAddon:RegisterEvent("BATTLEFIELD_MGR_ENTRY_INVITE")
MyAddon:RegisterEvent("BATTLEFIELD_MGR_QUEUE_REQUEST_RESPONSE")
MyAddon:SetScript("OnMouseDown", MyAddon.Hide)
However, what you intend to do sounds shady as Duugu stated. I can think of a valid reason to do what you are describing but that doesn't mean you shouldn't explain yourself more before getting further help.
  Reply With Quote
03-12-14, 10:08 AM   #11
ghozt
A Deviate Faerie Dragon
Join Date: Apr 2011
Posts: 10
Okay, apologies again. Let me just go ahead and describe what I am doing. I wanted to have it completed before I let anyone know anything about it, but it seems like it's just making people angry when I ask for help with bits of it.

Whenever you get a PVP or LFR/LFG queue to pop up, my image will display.

I have a desktop app made that scans your screen for this image. When the image is found my local client sends either a text or a notification (pushover, or homemade app) to your phone.

I have a (in a few weeks) 1 year old daughter. When she sleeps I queue up for something. However, I also need to do chores around the house. This lets me do chores while I wait for the sometimes 30-40 minute queue. For other people, maybe they just want to watch a movie or TV while they wait for the queue?

Vrul, thanks for that snippet, definitely alot more efficient than mine, and my Addon does work already I just posted that snippet from memory.. I got the function/setscript backwards it looks like. I'll post my code whenever I get home today.

Duugu, my client doesnt send ANYTHING to the WoW.exe, not even a keypress. It just scans your display for it the image.
  Reply With Quote
03-12-14, 10:30 AM   #12
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Well, to be exact ... what you're planning to do is not allowed. Even if your intention is not malicous. I know that is not what you would like to hear. But that's the way it is.
You agree that you will not, under any circumstances:
[...]
2.6 use any unauthorized third-party software that intercepts, "mines", or otherwise collects information from or through any Game or the Service, including without limitation any software that reads areas of RAM used by any Game or the Service to store information about a character or a Game environment; provided, however, that Blizzard may, at its sole and absolute discretion, allow the use of certain third party user interfaces;

Last edited by Duugu : 03-12-14 at 10:38 AM.
  Reply With Quote
03-12-14, 10:37 AM   #13
ghozt
A Deviate Faerie Dragon
Join Date: Apr 2011
Posts: 10
Hmm.. well.. I may need to reach out to blizzard on this one as it's not malicious at all..

Last edited by ghozt : 03-12-14 at 10:39 AM.
  Reply With Quote
03-12-14, 10:39 AM   #14
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Originally Posted by ghozt View Post
Duugu, that is a great idea. Didn't even consider that. I will look into this as well. Thank you!!
I've sayed nothing. Don't know what you're talking about. ;D
  Reply With Quote
03-14-14, 06:22 AM   #15
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
I don't know what secret messages I've missed here, but couldn't you instead mute sounds in WoW, make queue pop sounds play on master channel (which ignores mute) and have the app forward any sounds made from the WoW process to your phone? I don't know whether the screen reader would be classed as illegal, but I can't imagine this one would.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
03-14-14, 04:36 PM   #16
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
If you disable sound entirely, sounds on the Master channel will not play either. I think you're thinking of disabling/muting the Sound Effects channel -- while this will indeed mute most game sounds (especially if you also disable Music and Ambient Sounds) you will still get some non-queue-related sounds.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » BG Queue Event and Inserting Images


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

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