Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
 
 
Line 1: Line 1:
  +
[[Image:Eastern Crystal Pylon.jpg|thumb|The east side of the pylon.]]
−
{{UIHowTo}}
 
−
'''Static popups'' are simple one- or two-button dialog boxes you see when confirming a warlock summon, sending money
 
−
through the mail, renaming a pet, and so forth. This tutorial describes how you can use the StaticPopup code to display simple dialogs in your own addon.
 
   
  +
The '''Eastern Crystal Pylon''' is located in [[Un'Goro Crater]]. {{coords|77.2|50|Un'Goro Crater}}
−
As you might expect, all of the basic UI elements (positioning, sound effects, layout) are handled for you.
 
   
  +
==Objective of==
  +
Needs to be examined the quest [[Quest:The Eastern Pylon]].
   
−
== Basic Setup ==
+
==Quests==
  +
You must complete {{quest|Making Sense of It}}, before these quests become available.
  +
*[[Quest:Crystal Force]] {{queststartfinish}}
  +
*[[Quest:Crystal Spire]] {{queststartfinish}}
   
  +
==Examined==
−
In the "Hello, World" programming tradition, the example on this page will assume that you have a function, called <tt>GreetTheWorld</tt>, and that you are creating a simple dialog to ask the player whether or not to be socially outgoing.
 
  +
A closer inspection of the pylon leads you to find a small table containing blue, yellow, and green [[Power crystals|crystals]] arranged in what seems like a specific formation.
   
  +
A large blue circle of crystals is flanked on either side by a smaller circle of yellow crystals and another of green crystals.
−
New dialogs are created by adding an entry to the global <tt>StaticPopupDialogs</tt> table, and populating the entry with required and optional information. Here is a simple two-button entry:
 
   
  +
You carefully take note of the colours of the crystals, knowing that [[J.D. Collie|J. D.]] would be very interested in hearing about what you have found.
−
StaticPopupDialogs["EXAMPLE_HELLOWORLD"] = {
 
−
text = "Do you want to greet the world today?",
 
−
button1 = "Yes",
 
−
button2 = "No",
 
−
OnAccept = function()
 
−
GreetTheWorld();
 
−
end,
 
−
timeout = 0,
 
−
whileDead = 1,
 
−
hideOnEscape = 1
 
−
};
 
   
  +
==J.D. explains==
−
The index into the array is an arbitrary string. It must be unique in the context of the array. (If you are
 
  +
The Eastern Pylon accepts blue, yellow, and green crystals.
−
familiar with the [[HOWTO:_Create_a_Slash_Command|SlashCmdList]] array, this works exactly the same.)
 
   
  +
It focuses on the energy that can be created using blue crystals as the main source of power. There are two possible effects: one provides bonus to spirit, and one that creates a damaging shield.
−
Here you see the basic required information, along with some settings that are strictly optional but should be given by all well-behaved entries:
 
   
  +
[[Crystal Force]] requires blue and green crystals. This will provide you with an increase in spirit.
−
* ''text'' - This is the text inside the dialog box. For example, "Looting this item will bind it to you."
 
−
* ''button1'' - This is the text on the left "yes" button. Clicking this button will call the <tt>OnAccept</tt> function in the entry. In a popup with only one button, it is this one. Some dialogs (like the "you are not part of this instance's group and are going to get teleported" warning) do not even have a single button.
 
−
* ''button2'' - This is the text on the right "no" button. If the entry has an <tt>OnCancel</tt> function, clicking this button will call it with "clicked" as the reason (see below).
 
−
* ''OnAccept'' - This is a local function; it can be as complicated as you like. You do not need to explicitly hide the popup frame, it will be done for you.
 
−
* ''timeout'' - After this many seconds, the dialog will go away. If the entry has an <tt>OnCancel</tt> function, it will be called with "timeout" as the reason. Dialogs which do not expire should set this to zero.
 
−
* ''whileDead'' - Set to 1 if this dialog can be shown while the player is a ghost. You probably want to do this.
 
−
* ''hideOnEscape'' - Set to 1 if hitting the Escape key should be treated like clicking button2. You probably want to do this.
 
   
  +
[[Crystal Spire]] requires blue and yellow crystals. This will creaste a shield that does damage to attackers.
−
If your addon has a general OnLoad event handler, that is an excellent place to perform this array insertion.
 
   
  +
==External links==
  +
<!-- Read http://www.wowpedia.org/Wowpedia:External_links before posting your links here.
  +
Links that do not conform to the rules will be DELETED.
  +
Repeat violations may result in a BAN.
  +
Have a nice day. :) -->
  +
{{elinks-object|164957}}
   
  +
[[Category:Fixed devices]]
−
== Displaying the Popup ==
 
  +
[[Category:Object quest enders]]
−  
  +
[[Category:Object quest givers]]
−
To display the dialog, call <tt>StaticPopup_Show</tt> with the name of the entry:
 
  +
[[Category:Un'Goro Crater objects]]
−  
−
StaticPopup_Show ("EXAMPLE_HELLOWORLD");
 
−  
−
The dialog will be put together and displayed, and the function returns as soon as the dialog is shown.
 
−
If all goes well, the XML frame object for that dialog will be returned from the function. If there
 
−
are any problems, it returns nil.
 
−  
−
This function has two more optional arguments, see [[#Dialog_Text_Parameters|Dialog Text Parameters]] below.
 
−  
−
Up to 4 static popups may be displayed at once. The UI will handle finding an open slot for you.
 
−  
−  
−
== Hiding the Popup ==
 
−  
−
To make the dialog disappear without having a user click it, call <tt>StaticPopup_Hide</tt> with the name of the entry:
 
−  
−
StaticPopup_Hide ("EXAMPLE_HELLOWORLD");
 
−  
−
Calling the <tt>StaticPopup_Hide</tt> function after the dialog has already been hidden does not appear to have any ill effect. Return values of this function, if any, are not documented.
 
−  
−
== Advanced Setup ==
 
−  
−
* ''OnAccept'' - This function can take up to two arguments, both optional. They are for passing arbitrary data around the callbacks. There are very few examples of the use of the arguments. In general this is used with dialogs that have an editable text field, to pass the entered text back to the function. Also for chaining dialog boxes together.
 
−  
−
* ''OnCancel'' - This function can take up to two arguments, both optional. The first is used the same way as the first parameter in OnAccept (whatever that may actually be). The second is a string describing the reason the popup was cancelled; the game will pass this as required:
 
−
** "override" - Another popup cancelled this one, or is set to 'exclusive' (see below), or the player is dead or logging out.
 
−
** "timeout" - The popup's entry specified a nonzero timeout field, and the time expired.
 
−
** "clicked" - The player clicked button2, or hit the escape key and hideOnEscape is set.
 
−  
−  
−
=== Dialog Text Parameters ===
 
−  
−
The ''text'' field of an entry can contain formatting placeholders. When the popup is actually displayed,
 
−
the calling function can pass two additional arguments to <tt>StaticPopup_Show</tt>. The ''text'' field and
 
−
these two arguments will be passed through the [[API_format|format]] function before being added to the dialog.
 
−  
−
For example, the default guild invitation popup sets <tt>text = "%s invites you to join %s"</tt>, and the display call is to <tt>StaticPopup_Show ("GUILD_INVITE", name_of_officer, name_of_guild)</tt>.
 
−  
−  
−
=== Editable Text Fields ===
 
−  
−
To add a editbox in the popup set the ''hasEditBox'' option to 1. The EditBox get the name "$parentEditBox", relative to the Popup. To get and set the value of the EditBox use the following code:
 
−  
−
OnShow = function()
 
−
getglobal(this:GetName().."EditBox"):SetText("Some data")
 
−
-- notice: "this" is the StaticPopup, normally its "StaticPopup1"
 
−
end,
 
−
OnAccept = function()
 
−
getglobal(this:GetParent():GetName().."EditBox"):GetText()
 
−
-- do whatever you want with it
 
−
-- notice: "this" is the left button, normally its "StaticPopup1Button1",
 
−
-- so you need the GetParent() call.
 
−
end,
 
−
hasEditBox = 1,
 
−  
−
== Optional Features ==
 
−  
−
There are some more settings available for use in static popup entries. This list is almost certainly incomplete, I'm just describing the ones which catch my eye. For more information, extract the StaticPopup.xml and .lua files from the default UI and browse.
 
−  
−
* ''sound'' - Play this sound when the dialog is displayed. For example, "igPlayerInvite".
 
−
* ''hasMoneyFrame'' - This is for things like the money-in-mail confirmation. See the Lua file for more.
 
−
* ''showAlert'' - Set this to 1 if you also want the OH NO SOMETHING BAD icon to be displayed in the popup. For example, deleting a mail message with an item still attached to it.
 
−
* ''notClosableByLogout'' - Normally if a player quits the game, your popup will go away and its OnCancel function will be called. Set this field to 1 to avoid that behavior.
 
−
* ''cancels'' - If your popup should make another popup go away, set this field to that popup's name. For example, <tt>cancels = "EXAMPLE_HELLOWORLD"</tt>. If that popup is displayed at the time yours is shown, that popup's OnCancel function will be called and its frame hidden.
 
−
* ''StartDelay'' and ''delayText'' - These fields are responsible for things like the delay before you can resurrect, before you get kicked out of an ungrouped instance, etc. The first is a function (a pointer to the function itself, not its name) to be called which returns the number of seconds which must pass before button1 can be used. The second is text to be displayed during the delay; it is formatted like the normal ''text'' field, with the time as the parameters.
 
−
* ''exclusive'' - Set this to 1 to make your popup go away if any other popup is displayed.
 
−
* ''OnShow'' and ''OnHide'' - These functions will be called when the popup frame is initially shown and finally hidden, respectively. Most popups can ignore these. A very few need to do something special.
 
−  
−
As an example, consider the Ready Check from [http://ctmod.net/ CT_RaidAssist], which pops up a two-button dialog box with a 30-second timeout. Currently the CT authors implement everything from scratch: 107 lines of XML specifying window, field, and button sizes, plus a couple lines of Lua here and there. It could be replaced with something like the following:
 
−  
−
StaticPopupDialogs["EXAMPLE_CTRA_READY"] = {
 
−
text = "%s has performed a ready check. Are you ready?",
 
−
button1 = "Yes",
 
−
button2 = "No",
 
−
OnAccept = function()
 
−
CT_RA_SendReady();
 
−
end,
 
−
OnCancel = function (_,reason)
 
−
if reason == "timeout" or reason == "clicked" then
 
−
CT_RA_SendNotReady();
 
−
else
 
−
-- "override" ...?
 
−
end;
 
−
end,
 
−
sound = "levelup2",
 
−
timeout = 30,
 
−
whileDead = 1,
 
−
hideOnEscape = 1
 
−
};
 
−  
−
and called via
 
−  
−
StaticPopup_Show ("EXAMPLE_CTRA_READY", CT_RA_CheckReady_Person);
 
−  
−
(Note: the above was written before the 1.11 game patch added a builtin ready check. While ready checks no longer need
 
−
to be implemented by addon authors, the example is simple enough to remain here.)
 
−  
−
== Passing Arguments to Local Functions ==
 
−  
−
It is possible, though not immediately obvious how, to pass arbitrary user data to the local functions (e.g. OnAccept, OnCancel). Write your local function like this:
 
−  
−
OnAccept = function(self)
 
−
DoSomethingWith(self.data)
 
−
end
 
−  
−
And make the call like this:
 
−  
−
varName = "Some value" -- This is the data you want to use in OnAccept
 
−
local dialog = StaticPopup_Show("YOUR_POPUP") -- dialog contains the frame object
 
−
if (dialog) then
 
−
dialog.data = varName -- set the frame's data field to the value you want
 
−
end
 
−  
−
If you'll notice, you are actually setting the frame's data (which is passed as the first argument to the local function) ''after'' the user has clicked the button. This works because popping up a dialog box does not halt script execution. The dialog box isn't even visible to the player until after the current script execution cycle completes. By the time the player clicks a button to run OnAccept/OnCancel/etc, all of this code will have long since finished.
 
−  
−
== Notes and Observations ==
 
−
* The 'text' fields and button1/2 fields are usually localized. Blizzard tends to use generic texts like ACCEPT, CANCEL, and OKAY; you can probably do the same. These global variables contain a localized string and can be used as-is, like <tt>button1 = ACCEPT</tt>
 
−
* Creating a static popup with an editbox and only one button will cause the button and the editbox to overlap. Having more than one button will get the desired behavior. (Tested on 2.4.1)
 
−
* While creating your popup entries, you will probably be doing a lot of UI reloading. Extract the <tt>[[FrameXML/DebugUI.xml]]</tt> file from the default UI, copy it into your addon folder, and add it to your .toc file. This has two effects: it starts verbose logging into FrameXML.log, and it adds a "Reload UI" button to your screen. Very handy timesaver. :-)
 
−
* Added by [[user:Layrajha|Layrajha]]: The OnHide function will always be called after OnAccept or OnCancel have finished their execution. Therefore, it is safe to assume that your changes done in OnAccept or OnCancel will be done when OnHide is called. Also note that you can prevent the popup from hiding after clicking the "Accept" button: just make the OnAccept function return "true" (or anything different from "nil" and "false", it will work just as well).
 
−  
−
[[Category:HOWTOs|Popup Simple Dialog Boxes]]
 

Revision as of 11:09, 20 January 2012

Eastern Crystal Pylon

The east side of the pylon.

The Eastern Crystal Pylon is located in Un'Goro Crater. [77.2, 50]VZ-Un'Goro CraterBlip

Objective of

Needs to be examined the quest Quest:The Eastern Pylon.

Quests

You must complete Making Sense of It, before these quests become available.

Examined

A closer inspection of the pylon leads you to find a small table containing blue, yellow, and green crystals arranged in what seems like a specific formation.

A large blue circle of crystals is flanked on either side by a smaller circle of yellow crystals and another of green crystals.

You carefully take note of the colours of the crystals, knowing that J. D. would be very interested in hearing about what you have found.

J.D. explains

The Eastern Pylon accepts blue, yellow, and green crystals.

It focuses on the energy that can be created using blue crystals as the main source of power. There are two possible effects: one provides bonus to spirit, and one that creates a damaging shield.

Inv misc gem crystal 02 [Crystal Force] requires blue and green crystals. This will provide you with an increase in spirit.

Inv misc gem stone 01 [Crystal Spire] requires blue and yellow crystals. This will creaste a shield that does damage to attackers.

External links