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:	358
Size:	568.6 KB
ID:	8034  
Attached Files
File Type: tga qm.tga (995 Bytes, 171 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

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