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.]]
−
== Introduction ==
 
   
  +
The '''Eastern Crystal Pylon''' is located in [[Un'Goro Crater]]. {{coords|77.2|50|Un'Goro Crater}}
−
This HOWTO covers the creation of what Blizzard calls ''static popups''. These are the simple
 
−
one-button and two-button dialog boxes you see when confirming a warlock summon, sending money
 
−
through the mail, renaming a pet, and so forth.
 
   
  +
==Objective of==
−
As you might expect, all of the basic UI elements (positioning, sound effects, layout) are handled for you.
 
  +
Needs to be examined the quest [[Quest:The Eastern Pylon]].
   
  +
==Quests==
  +
You must complete {{quest|Making Sense of It}}, before these quests become available.
  +
*[[Quest:Crystal Force]] {{queststartfinish}}
  +
*[[Quest:Crystal Spire]] {{queststartfinish}}
   
−
== Basic Setup ==
+
==Examined==
  +
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.
−
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.
 
   
  +
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.
−
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:
 
   
  +
==J.D. explains==
−
StaticPopupDialogs["EXAMPLE_HELLOWORLD"] = {
 
  +
The Eastern Pylon accepts blue, yellow, and green crystals.
−
text = "Do you want to greet the world today?",
 
−
button1 = "Yes",
 
−
button2 = "No",
 
−
OnAccept = function()
 
−
GreetTheWorld();
 
−
end,
 
−
timeout = 0,
 
−
whileDead = 1,
 
−
hideOnEscape = 1
 
−
};
 
   
  +
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.
−
The index into the array is an arbitrary string. It must be unique in the context of the array. (If you are
 
−
familiar with the [[HOWTO:_Create_a_Slash_Command|SlashCmdList]] array, this works exactly the same.)
 
   
  +
[[Crystal Force]] requires blue and green crystals. This will provide you with an increase in spirit.
−
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 Spire]] requires blue and yellow crystals. This will creaste a shield that does damage to attackers.
−
* ''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.
 
   
  +
==External links==
−
If your addon has a general OnLoad event handler, that is an excellent place to perform this array insertion.
 
  +
<!-- 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]]
−  
  +
[[Category:Object quest enders]]
−
== Displaying the Popup ==
 
  +
[[Category:Object quest givers]]
−  
  +
[[Category:Un'Goro Crater objects]]
−
To display the dialog, call <tt>StaticPopup_Show</tt> with the name of the entry:
 
−  
−
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.
 
−  
−  
−
== 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, normaly its "StaticPopup1"
 
−
end,
 
−
OnAccept = function()
 
−
getglobal(this:GetParent():GetName().."EditBox"):GetText()
 
−
-- do whatever you want with it
 
−
-- notice: "this" is the left button, normaly its "StaticPopup1Button1",
 
−
-- so you need the GetParent() call.
 
−
end,
 
−  
−
== 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(argName)
 
−
DoSomethingWith(argName)
 
−
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 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. I'm not exactly sure how this mechanism works, my initial guess is that the popup functions are run in a separate thread to allow for this kind of manipulation.
 
−
:[[User:Wickedsick|Wickedsick]] 02:49, 8 May 2006 (EDT)
 
−  
−
== 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. They wrap all those in a call to TEXT() for translation, like <tt>button1 = TEXT(ACCEPT)</tt>
 
−
* 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. :-)
 
−  
−  
−  
−
-Documentation by [[user:Farmbuyer|Farmbuyer]]
 
−
[[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