Gaming
 

PopNUI/RegisterUI

From WoWWiki

Image:Addonicon.gif
WoWWiki Hosted AddOn Sub-Page
PopNUI » ChangeLog

Contents

Registering a component to use PopNUI functionality

You do this by issuing this call :

PopNUI_RegisterUI(whichUI, chatComm, callback, confName, confDesc)
whichUI 
Which UI element, be sure to pass the exact name.
chatComm 
the chat command to use to control the options, don't pass a / or pui.. just the nickname for your UI element. This can be a single command or a list of commands.
callback 
optional (pass nil if not needed). If your UI element requires more specialized code to control "popupability", then provide a callback to that function here. Look below for the format. You can provide a requirements list instead, see below for that as well.
confName 
the name to show in Cosmos' UI config
confDesc 
the description to show in Cosmos' UI config

PopNUI_Callback specification

PopNUI_Callback(whichUI, isEnabled, xPos, yPos)
whichUI 
will be the UI name you passed to the command
isEnabled 
will let you know if it is enabled or not (so you know to show it normal or popped)
xPos 
the x position of the cursor
yPos 
the y position of the cursor

Generic Callback

Unless you do some strange stuff with your AddOn, this is the callback to use :

function Generic_PopNUICallback(whichUI, isEnabled, xPos, yPos)
	if ( ( not ModName_Enabled ) or ( ModName_Enabled ~= 1 ) ) then
		local ui = getglobal(whichUI);
		if ( ( ui ) and ( ui:IsVisible() ) ) then
			ui:Hide();
		end
	else
		PopNUI_CheckUI(whichUI, isEnabled, xPos, yPos);
	end
end

Note that this assumes there's a variable called ModName_Enabled which is set to 1 if the AddOn is enabled (and thus should be shown).


-- Sarf

Requirements List

As mentioned, you can pass a list of requirements instead of a callback.
If all requirements are met then PopNUI will show/hide the UI element appropriately. If any are not met, it either will not do anything, or if you have set hide to true, on one of the requirements that was not met, it will hide the UI element.

{ {"GlobalVarName",  checkValue, hide},
  {"GlobalVarName2", checkValue, hide},
  {"GlobalVarName3", checkValue, hide} }

Or you can pass just a single requirement set:

{"GlobalVarName",  checkValue, hide}
"GlobalVarName" 
the name of the variable you want checked, this can also be a function.
checkVale 
what "GlobalVarName" has to be equal to, for the requirement to be considered true.
hide 
pass true if you want the UI to be hidden if this requirement is not met.