Currency Formatting

From ESOUI Wiki

Revision as of 06:50, 21 January 2019 by Scootworks (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Currency ESO source code

See currency.lua for the corresponding control type


Currency master table

local currenciesData = ZO_CURRENCIES_DATA


currencyType

There are many currencyTypes. Mostly you will use these:

local currencyTypes =
{
	CURT_MONEY,
	CURT_TELVAR_STONES,
	CURT_ALLIANCE_POINTS,
}


Most use case functions

ZO_Currency_FormatKeyboard(currencyType, currencyAmount, formatType, extraOptions)
-- or
ZO_Currency_FormatGamepad(currencyType, currencyAmount, formatType, extraOptions)
-- or
ZO_Currency_FormatPlatform(currencyType, currencyAmount, formatType, extraOptions)
 
-- ─ currencyType
 
-- ─ currencyAmount - value (number)
 
-- ┬ formatType
-- ├ ZO_CURRENCY_FORMAT_AMOUNT_NAME
-- ├ ZO_CURRENCY_FORMAT_WHITE_AMOUNT_WHITE_NAME
-- ├ ZO_CURRENCY_FORMAT_PARENTHETICAL_AMOUNT
-- ├ ZO_CURRENCY_FORMAT_AMOUNT_ICON
-- ├ ZO_CURRENCY_FORMAT_WHITE_AMOUNT_ICON
-- ├ ZO_CURRENCY_FORMAT_ERROR_AMOUNT_ICON
-- ├ ZO_CURRENCY_FORMAT_PLURAL_NAME_ICON
-- └ ZO_CURRENCY_FORMAT_STRIKETHROUGH_AMOUNT_ICON
 
-- ┬ extraOptions is a table of additional options to modify how the currency is formatted
-- ├ showCap - if set to true, the formatted currency amount will also show the currency cap in the format amount/cap if there is a cap
-- ├ currencyLocation - used with showCap to specify the currency location to pull the cap from
-- ├ color - specify a color to be used for the currency amount instead of the default currency color
-- └ iconInheritColor - will allow the currency icon to inherit the color of the label it's displayed in

Example with extraOptions:

local currencyType = CURT_MONEY
local currencyAmount = 123456
local formatType = ZO_CURRENCY_FORMAT_STRIKETHROUGH_AMOUNT_ICON
local extraOptions =
{
	color = ZO_DEFAULT_TEXT,
	iconInheritColor = true,
}
local currencyString = zo_strformat(SI_NUMBER_FORMAT, ZO_Currency_FormatKeyboard(currencyType, currencyAmount, formatType, extraOptions))
d(currencyString)

Same example without extraOptions:

local currencyType = CURT_MONEY
local currencyAmount = 123456
local formatType = ZO_CURRENCY_FORMAT_STRIKETHROUGH_AMOUNT_ICON
local currencyString = zo_strformat(SI_NUMBER_FORMAT, ZO_Currency_FormatKeyboard(currencyType, currencyAmount, formatType))
d(currencyString)


Label (currency name)

ZO_Currency_GetAmountLabel(currencyType)

Example:

local goldLabel = ZO_Currency_GetAmountLabel(CURT_MONEY)
d(goldLabel)


Simply format a control

ZO_CurrencyControl_SetSimpleCurrency(labelControl, currencyType, amount, options, showAll, notEnough, displayOptions)
-- ─ labelControl - label control
 
-- ─ currencyType
 
-- ─ amount - value (number)
 
-- ┬ options -
-- ├ showTooltips = false,
-- ├ useShortFormat = false,
-- ├ font = "ZoFontGame",
-- ├ iconSide = RIGHT,
-- └ iconSize = 36, -- value or a percent string
 
-- ─ showAll - boolean (true or false)
 
-- ─ notEnough - Certain currency types always determine the notEnough value automatically. This could be calculated externally. Might need updates if that value can change after a currency control has been formatted.
 
-- ┬ displayOptions is a table of additional display options to modify how the given currencyType appears in the control
-- ├ obfuscateAmount - will not show the passed in currency amount, but will instead show SI_CURRENCY_OBFUSCATE_VALUE
-- ├ currencyCapAmount - if specified, the formatted currency amount will also show the currency cap in the format amount/cap
-- ├ iconInheritColor - will make the currency icon inherit the color of the currency amount
-- ├ color - is the color of the currency amount shown, will override the default color, but not any color specified in options.color
-- └ strikethroughCurrencyAmount - will add a strikethrough to the currency amount (as long as it's not obfuscated)
Personal tools
Namespaces
Variants
Actions
Menu
Wiki
Toolbox