Wowpedia

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

READ MORE

Wowpedia
m (→‎MyModScrollBar.xml: NormalFont, OnVerticalScroll)
 
No edit summary
 
Line 1: Line 1:
  +
{{Stub/Cataclysm}}
''This HOWTO describes how to create a list view using the [{{wdnlink|FrameXML/UIPanelTemplates.xml}} FauxScrollFrameTemplate] [[FrameXML]] class. An alternative is to simply create a '''Slider''' object of your own, but there is no HOWTO on that at the moment. Using [[API CreateFrame|CreateFrame]]() to create the list items dynamically may also be a good idea.''
 
  +
[[File:Pvecurrency-justice.png|right]]
  +
'''Justice Points''' will be the new currency to buy items as a reward for participating in heroic mode [[dungeon]]s. Justice Points will replace {{item|icon=|Emblem of Frost|Emblems of Frost}} and {{item|icon=|Emblem of Triumph|Emblems of Triumph}}. Raids will reward [[Valor Point]]s instead.
   
== How to do it ==
+
== Sources ==
  +
Justice Points are rewarded in level-appropriate dungeons and raids at the following quantities<ref>http://forums.worldofwarcraft.com/thread.html?topicId=27026399005&sid=1&pageNo=1#0</ref>:
  +
{|class="darktable zebra"
  +
!Objective !! Points
  +
|-
  +
|Complete the Lich King (68-80) ''daily'' normal mode dungeon run || 12 Justice Points
  +
|-
  +
|Defeat a Lich King (80) Heroic mode dungeon boss encounter || 16 Justice Points
  +
|-
  +
|Complete the Lich King (80) ''daily'' Heroic mode dungeon run || 23 Justice Points
  +
|-
  +
|Defeat a Lich King (80) raid boss encounter || 23 Justice Points
  +
|-
  +
|Complete a Cataclysm (80-85) ''daily'' normal mode dungeon run || 75 Justice Points
  +
|-
  +
|Defeat a Cataclysm (85) Heroic mode dungeon boss encounter || 75 Justice Points
  +
|}
   
  +
Outgrowing content by out-leveling it will result in the listed objectives no longer rewarding Justice Points. Thus, for ''Wrath of the Lich King'' content, no Justice Points will be rewarded for players levels 81 and above. The same rule applies for Burning Crusade content, which will also reward Justice Points.
Before starting out, it helps to visualize that the Scrollbar is nothing more than a vertical slider. We set a min, max, steps to the slider and then react to changes in its offset. The slider doesn't keep tabs of any of our data beyond this. It's up to us to handle the actual movement of data as the user moves the thumb.
 
   
  +
== Purchasable Rewards ==
You can look at ItemTextFrame.xml/lua, QuestFrame.xml/lua for other examples of how to make ScrollFrames. This will focus on the FauxScrollFrameTemplate route, for a series of rows we define in detail.
 
  +
[[Image:Justice_points_triumph_vendor.jpg|thumb|Emblem of Triumph Vendor Justice Point Prices As of 4.0.1.13131]]
  +
[[Image:Justice_points_frost_vendor.jpg|thumb|Emblem of Frost Vendor Justice Point Prices As of 4.0.1.13131]]
  +
Precise details on what can be purchased with Justice Points are not finalized at this time.
   
  +
== Conversion of Emblems to Justice Points ==
FauxScrollFrameTemplate is inherited from UIPanelScrollFrameTemplate, both in UIPanelTemplates.xml. FriendsFrame.xml is a good reference for how to flesh out a FauxScrollFrame with things such as highlights and "gutter" textures. But for simplicity's sake ours will be very basic: An up+down arrow at the ends of the scrollbar and a thumb to move the data.
 
  +
When players first log in after [[Patch 4.0.1]], the number of Justice Points they have will be calculated as follows:
   
  +
:''JP = 11.58 * (EoT + EoF)''
First, we need data to scroll through:
 
   
  +
where:
function MyMod_OnLoad()
 
  +
* JP = the number of Justice Points;
MyModData = {};
 
  +
* EoT = the number of Emblems of Triumph;
for i=1,50 do
 
  +
* EoF = the number of Emblems of Frost.
MyModData[i] = "Test "..math.random(100);
 
end
 
end
 
   
  +
Players cannot stockpile more than 4,000 Justice Points at any time by normal means of running instances.
Now we have an array of 50 entries with "Test (some random number up to 100)"
 
   
  +
However, if the one-time emblem-to-point conversion grants the player more than 4,000 Justice Points, they will be unable to accumulate any additional Justice Points until they have spent the excess. Come [[Patch 4.0.3]], any Justice Points above 4,000 ''will be immediately converted to gold'' at a ratio of {{cost||47|50}} per Justice Point.
Next, we need a scrollbar on the window:
 
   
  +
=== Other emblems, badges and tokens ===
<ScrollFrame name="MyModScrollBar" inherits="FauxScrollFrameTemplate">
 
  +
{{loot|epic|Emblem of Valor|Emblems of Valor}}, {{loot|epic|Emblem of Heroism|Heroism}}, and {{loot|epic|Emblem of Conquest|Conquest}} will be ''immediately'' converted to gold (and not Justice Points) at a ratio of {{cost|5|50}} per emblem in [[Patch 4.0.1]]. {{loot|epic|Badge of Justice|Badges of Justice}} will also be immediately converted to gold at a rate of {{cost|1|83|30}} per badge.
<Anchors>
 
<Anchor point="TOPLEFT"/>
 
<Anchor point="BOTTOMRIGHT"/>
 
</Anchors>
 
<Scripts>
 
<OnVerticalScroll>
 
FauxScrollFrame_OnVerticalScroll(this, offset, 16, MyModScrollBar_Update); <!-- 16 is pixel height of each entry -->
 
</OnVerticalScroll>
 
<OnShow>
 
MyModScrollBar_Update()
 
</OnShow>
 
</Scripts>
 
</ScrollFrame>
 
   
  +
PvP-based currency will be converted to [[Honor Point]]s much the same way.
The components of the ScrollFrame that we care about now:
 
   
  +
=== Comparison of purchasing power ===
; Anchors : Note that the above example uses two anchors to stretch the ScrollFrame across the entire parent. You can use <Size> tags with one <Anchor> if you prefer. ''Note: The dimensions of the scrollframe itself are the area you intend to display information. The bar is not within this area but anchored to the right of this area.'' The OnMouseWheel event will only work over the area you define for the ScrollFrame. And of course it's important for properly positioning the scrollbar. If the ScrollFrame's parent has a UI-Tooltip-Border backdrop, you can use the following anchors to position the bar within the frame:
 
  +
<!-- this section should get modified; and when 4.0.1 rolls around, axed. -->
<Anchors>
 
  +
A comparison of costs of items currently (15 Sept 2010) available on PTR vs the expected translation of emblems to justice points favors spending emblems prior to the conversion. Note that these prices on PTR are not necessarily final.
<Anchor point="TOPLEFT">
 
<Offset>
 
<AbsDimension x="0" y="-8"/>
 
</Offset>
 
</Anchor>
 
<Anchor point="BOTTOMRIGHT">
 
<Offset>
 
<AbsDimension x="-30" y="8"/>
 
</Offset>
 
</Anchor>
 
</Anchors>
 
; OnVerticalScroll : This function is called whenever the scroll thumb is moved while shown. The 16 is the height of each entry in pixels. The second parameter is to a function you supply that updates the information. The function is required for the ScrollFrame to work.
 
; OnShow : With 1.9, it appears that FauxScrollFrame_OnVerticalScroll doesn't call the supplied function during initialization. So we need to do the first update ourselves. An OnShow is a convenient spot to do so.
 
''Note: The OnShow can happen BEFORE your mods' OnLoad. In 99% of cases this is not important but for testing purposes you may need to delay the OnShow to the mod's "primary" OnLoad.''
 
   
  +
== Patch history ==
The all-important MyModScrollBar_Update will look something like this in its most essential form:
 
  +
* {{Patch 4.0.3|note=Justice Points over the 4,000 hard cap will be immediately converted at a ratio of {{cost||47|50}} per Justice Point.}}
  +
* {{Patch 4.0.1|note=Added.|comment={{loot|epic|Emblem of Frost|Emblems of Frost}} and {{loot|epic|Emblem of Triumph|Emblems of Triumph}} will be converted to Justice Points at a ratio of 11.58 Justice Points per emblem. Items which were purchased using Emblems of Frost or Emblems of Triumph now require Justice Points instead. The softcap for Justice conversions is 4000 points. This means that if a character converts to above 4,000 points, it will not be possible for them to earn more until they fall below the 4,000 cap.}}
   
  +
== External links ==
function MyModScrollBar_Update()
 
  +
<!-- Read http://www.wowwiki.com/WoWWiki:External_links before posting your links here.
FauxScrollFrame_Update(MyModScrollBar,50,5,16);
 
  +
Links that do not conform to the rules will be DELETED.
-- 50 is max entries, 5 is number of lines, 16 is pixel height of each line
 
  +
Repeat violations may result in a BAN.
end
 
  +
Have a nice day. :) -->
  +
{{elink|link=http://forums.worldofwarcraft.com/thread.html?topicId=26850245012&sid=1&pageNo=10#184|type=wowus|site=Official Forums|desc=Cataclysm Currency Changes Explained}}
   
In UIPanelTemplates.lua, the function is documented as:
 
-- Function to handle the update of manually calculated
 
scrollframes. Used mostly for listings with an indeterminate
 
number of items
 
function FauxScrollFrame_Update(frame, numItems, numToDisplay,
 
valueStep, button, smallWidth, bigWidth, highlightFrame,
 
smallHighlightWidth, bigHighlightWidth )
 
   
  +
{{Points}}
If the function that's the second parameter of FauxScrollFrame_OnVerticalScroll doesn't contain a FauxScrollFrame_Update, we will get an error. Once we have an update function within <OnVerticalScroll>, and a FauxScrollFrame_Update call within that function, the scrollbar is functional. We can test it by getting the offset and printing it:
 
  +
[[Category:Cataclysm]]
 
  +
[[Category:Currency]]
function MyModScrollBar_Update()
 
FauxScrollFrame_Update(MyModScrollBar,50,5,16);
 
-- 50 is max entries, 5 is number of lines, 16 is pixel height of each line
 
DEFAULT_CHAT_FRAME:AddMessage("We're at "..FauxScrollFrame_GetOffset(MyModScrollBar));
 
end
 
 
Try that and scroll the bar around. You'll see that _GetOffset will return from 0 to 45, which happens to be 50-5.
 
 
We now have an indexed array of data and a scrollbar. Now we need to display the data based on the scrollbar's position. First we need to construct the xml elements of the display.
 
 
Start simple and make one button template to play around with:
 
 
<Button name = "MyModEntryTemplate" virtual="true">
 
<Size>
 
<AbsDimension x="150" y="16" />
 
</Size>
 
<NormalFont inherits="GameFontHighlight" justifyH="LEFT"/>
 
</Button>
 
 
This is a virtual button, 150 pixels wide and 16 pixels tall, that can be used to display text.
 
 
Now use this template to draw our series of buttons:
 
 
<Button name="MyModEntry1" inherits="MyModEntryTemplate">
 
<Anchors>
 
<Anchor point="TOPLEFT" relativeTo="MyModScrollBar" relativePoint="TOPLEFT">
 
<Offset>
 
<AbsDimension x="8" y="0"/>
 
</Offset>
 
</Anchor>
 
</Anchors>
 
</Button>
 
<Button name="MyModEntry2" inherits="MyModEntryTemplate">
 
<Anchors>
 
<Anchor point="TOPLEFT" relativeTo="MyModEntry1" relativePoint="BOTTOMLEFT"/>
 
</Anchors>
 
</Button>
 
<Button name="MyModEntry3" inherits="MyModEntryTemplate">
 
<Anchors>
 
<Anchor point="TOPLEFT" relativeTo="MyModEntry2" relativePoint="BOTTOMLEFT"/>
 
</Anchors>
 
</Button>
 
<Button name="MyModEntry4" inherits="MyModEntryTemplate">
 
<Anchors>
 
<Anchor point="TOPLEFT" relativeTo="MyModEntry3" relativePoint="BOTTOMLEFT"/>
 
</Anchors>
 
</Button>
 
<Button name="MyModEntry5" inherits="MyModEntryTemplate">
 
<Anchors>
 
<Anchor point="TOPLEFT" relativeTo="MyModEntry4" relativePoint="BOTTOMLEFT"/>
 
</Anchors>
 
</Button>
 
 
The above draws the first entry with top-left aligned to top-left of the scrollbar's scrollable area, 8 pixels to the right, then it draws each one below aligned with top-left of next one aligned to bottom-left of previous.
 
 
Now we go back to the update function and add the code to display our data depending on the position of the bar:
 
 
We have 5 lines on the screen at all times: MyModEntry1, MyModEntry2, etc. Each entry has a text inside named MyModEntry1_Text, MyModEntry2_Text, etc.
 
 
function MyModScrollBar_Update()
 
local line; -- 1 through 5 of our window to scroll
 
local lineplusoffset; -- an index into our data calculated from the scroll offset
 
FauxScrollFrame_Update(MyModScrollBar,50,5,16);
 
for line=1,5 do
 
lineplusoffset = line + FauxScrollFrame_GetOffset(MyModScrollBar);
 
if lineplusoffset < 50 then
 
getglobal("MyModEntry"..line):SetText(MyModData[lineplusoffset]);
 
getglobal("MyModEntry"..line):Show();
 
else
 
getglobal("MyModEntry"..line):Hide();
 
end
 
end
 
end
 
 
Now we have a scrollbar that scrolls through the data and redisplays it when we move. Now you can customize it to your mod's needs. First step would be to make the values fit your mod, especially the size and shape of the data.
 
 
Remember to check out FriendsFrame.xml/.lua to see how to select entries by locking/unlocking its highlight, how to draw a gutter, create multiple columns, etc.
 
 
== Completed example ==
 
 
=== MyModScrollBar.toc ===
 
 
## Interface: 20400
 
## Title: MyMod
 
## Notes: Example of using FauxScrollFrameTemplate
 
MyModScrollBar.xml
 
 
=== MyModScrollBar.lua ===
 
 
MyModData = {}
 
 
function MyMod_OnLoad()
 
for i=1,50 do
 
MyModData[i] = "Test "..math.random(100)
 
end
 
MyModScrollBar:Show()
 
end
 
 
function MyModScrollBar_Update()
 
local line; -- 1 through 5 of our window to scroll
 
local lineplusoffset; -- an index into our data calculated from the scroll offset
 
FauxScrollFrame_Update(MyModScrollBar,50,5,16);
 
for line=1,5 do
 
lineplusoffset = line + FauxScrollFrame_GetOffset(MyModScrollBar);
 
if lineplusoffset <= 50 then
 
getglobal("MyModEntry"..line):SetText(MyModData[lineplusoffset]);
 
getglobal("MyModEntry"..line):Show();
 
else
 
getglobal("MyModEntry"..line):Hide();
 
end
 
end
 
end
 
 
=== MyModScrollBar.xml ===
 
<Ui>
 
<Script file="MyModScrollBar.lua"/>
 
<Button name = "MyModEntryTemplate" virtual="true">
 
<Size>
 
<AbsDimension x="150" y="16" />
 
</Size>
 
<NormalFont style="GameFontHighlightLeft"/>
 
</Button>
 
 
<Frame name="MyMod" parent="UIParent" enableMouse="true" movable="true">
 
<Size>
 
<AbsDimension x="196" y="96"/>
 
</Size>
 
<Anchors>
 
<Anchor point="CENTER"/>
 
</Anchors>
 
<Scripts>
 
<OnLoad>
 
MyMod_OnLoad()
 
</OnLoad>
 
</Scripts>
 
<Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true">
 
<BackgroundInsets>
 
<AbsInset left="4" right="4" top="4" bottom="4" />
 
</BackgroundInsets>
 
<TileSize>
 
<AbsValue val="16" />
 
</TileSize>
 
<EdgeSize>
 
<AbsValue val="16" />
 
</EdgeSize>
 
</Backdrop>
 
<Frames>
 
<ScrollFrame name="MyModScrollBar" inherits="FauxScrollFrameTemplate" hidden="true">
 
<Anchors>
 
<Anchor point="TOPLEFT">
 
<Offset>
 
<AbsDimension x="0" y="-8"/>
 
</Offset>
 
</Anchor>
 
<Anchor point="BOTTOMRIGHT">
 
<Offset>
 
<AbsDimension x="-30" y="8"/>
 
</Offset>
 
</Anchor>
 
</Anchors>
 
<Scripts>
 
<OnVerticalScroll>
 
FauxScrollFrame_OnVerticalScroll(this, offset, 16, MyModScrollBar_Update);
 
</OnVerticalScroll>
 
<OnShow>
 
MyModScrollBar_Update()
 
</OnShow>
 
</Scripts>
 
</ScrollFrame>
 
 
<Button name="MyModEntry1" inherits="MyModEntryTemplate">
 
<Anchors>
 
<Anchor point="TOPLEFT" relativeTo="MyModScrollBar" relativePoint="TOPLEFT">
 
<Offset>
 
<AbsDimension x="8" y="0"/>
 
</Offset>
 
</Anchor>
 
</Anchors>
 
</Button>
 
<Button name="MyModEntry2" inherits="MyModEntryTemplate">
 
<Anchors>
 
<Anchor point="TOPLEFT" relativeTo="MyModEntry1" relativePoint="BOTTOMLEFT"/>
 
</Anchors>
 
</Button>
 
<Button name="MyModEntry3" inherits="MyModEntryTemplate">
 
<Anchors>
 
<Anchor point="TOPLEFT" relativeTo="MyModEntry2" relativePoint="BOTTOMLEFT"/>
 
</Anchors>
 
</Button>
 
<Button name="MyModEntry4" inherits="MyModEntryTemplate">
 
<Anchors>
 
<Anchor point="TOPLEFT" relativeTo="MyModEntry3" relativePoint="BOTTOMLEFT"/>
 
</Anchors>
 
</Button>
 
<Button name="MyModEntry5" inherits="MyModEntryTemplate">
 
<Anchors>
 
<Anchor point="TOPLEFT" relativeTo="MyModEntry4" relativePoint="BOTTOMLEFT"/>
 
</Anchors>
 
</Button>
 
 
</Frames>
 
</Frame>
 
</Ui>
 
[[Category: HOWTOs|Make a Scrollable List Using FauxScrollFrameTemplate]]
 

Revision as of 21:30, 6 October 2010

Template:Stub/Cataclysm

Pvecurrency-justice

Justice Points will be the new currency to buy items as a reward for participating in heroic mode dungeons. Justice Points will replace [Emblems of Frost] and [Emblems of Triumph]. Raids will reward Valor Points instead.

Sources

Justice Points are rewarded in level-appropriate dungeons and raids at the following quantities[1]:

Objective Points
Complete the Lich King (68-80) daily normal mode dungeon run 12 Justice Points
Defeat a Lich King (80) Heroic mode dungeon boss encounter 16 Justice Points
Complete the Lich King (80) daily Heroic mode dungeon run 23 Justice Points
Defeat a Lich King (80) raid boss encounter 23 Justice Points
Complete a Cataclysm (80-85) daily normal mode dungeon run 75 Justice Points
Defeat a Cataclysm (85) Heroic mode dungeon boss encounter 75 Justice Points

Outgrowing content by out-leveling it will result in the listed objectives no longer rewarding Justice Points. Thus, for Wrath of the Lich King content, no Justice Points will be rewarded for players levels 81 and above. The same rule applies for Burning Crusade content, which will also reward Justice Points.

Purchasable Rewards

File:Justice points triumph vendor.jpg

Emblem of Triumph Vendor Justice Point Prices As of 4.0.1.13131

File:Justice points frost vendor.jpg

Emblem of Frost Vendor Justice Point Prices As of 4.0.1.13131

Precise details on what can be purchased with Justice Points are not finalized at this time.

Conversion of Emblems to Justice Points

When players first log in after Patch 4.0.1, the number of Justice Points they have will be calculated as follows:

JP = 11.58 * (EoT + EoF)

where:

  • JP = the number of Justice Points;
  • EoT = the number of Emblems of Triumph;
  • EoF = the number of Emblems of Frost.

Players cannot stockpile more than 4,000 Justice Points at any time by normal means of running instances.

However, if the one-time emblem-to-point conversion grants the player more than 4,000 Justice Points, they will be unable to accumulate any additional Justice Points until they have spent the excess. Come Patch 4.0.3, any Justice Points above 4,000 will be immediately converted to gold at a ratio of 47s 50c per Justice Point.

Other emblems, badges and tokens

[Emblems of Valor], [Heroism], and [Conquest] will be immediately converted to gold (and not Justice Points) at a ratio of 5g 50s per emblem in Patch 4.0.1. [Badges of Justice] will also be immediately converted to gold at a rate of 1g 83s 30c per badge.

PvP-based currency will be converted to Honor Points much the same way.

Comparison of purchasing power

A comparison of costs of items currently (15 Sept 2010) available on PTR vs the expected translation of emblems to justice points favors spending emblems prior to the conversion. Note that these prices on PTR are not necessarily final.

Patch history

  • Cataclysm Patch 4.0.3 (2010-11-16): Justice Points over the 4,000 hard cap will be immediately converted at a ratio of 47s 50c per Justice Point.
  • Cataclysm Patch 4.0.1 (2010-10-12): Added.
    [Emblems of Frost] and [Emblems of Triumph] will be converted to Justice Points at a ratio of 11.58 Justice Points per emblem. Items which were purchased using Emblems of Frost or Emblems of Triumph now require Justice Points instead. The softcap for Justice conversions is 4000 points. This means that if a character converts to above 4,000 points, it will not be possible for them to earn more until they fall below the 4,000 cap.

External links