1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 |
CURRENCY_SHOW_ALL = true
CURRENCY_DONT_SHOW_ALL = false
CURRENCY_IGNORE_HAS_ENOUGH = false
CURRENCY_HAS_ENOUGH = false
CURRENCY_NOT_ENOUGH = true
local NOT_ENOUGH_COLOR = ZO_ERROR_COLOR
local DEFAULT_COLOR = ZO_ColorDef : New ( GetInterfaceColor ( INTERFACE_COLOR_TYPE_GENERAL , INTERFACE_GENERAL_COLOR_ENABLED ) )
local DEFAULT_GAMEPAD_COLOR = ZO_ColorDef : New ( GetInterfaceColor ( INTERFACE_COLOR_TYPE_GENERAL , INTERFACE_TEXT_COLOR_SELECTED ) )
ZO_CURRENCIES_DATA = { }
local g_currenciesData = ZO_CURRENCIES_DATA -- These APIs are called a lot, so let's not spam global lookup
do
for currencyType = CURT_ITERATION_BEGIN , CURT_ITERATION_END do
local IS_PLURAL = false
local IS_UPPER = false
local currencyInfo =
{
}
currencyInfo . keyboardTexture = keyboardTexture
currencyInfo . keyboardPercentOfLineSize = keyboardPercentOfLineSize .. "%"
currencyInfo . gamepadTexture = gamepadTexture
currencyInfo . gamepadPercentOfLineSize = gamepadPercentOfLineSize .. "%"
g_currenciesData [ currencyType ] = currencyInfo
end
end
end
ZO_MARKET_CURRENCY_TO_UI_CURRENCY =
{
[ MKCT_CROWNS ] = CURT_CROWNS ,
[ MKCT_CROWN_GEMS ] = CURT_CROWN_GEMS ,
}
return ZO_MARKET_CURRENCY_TO_UI_CURRENCY [ marketCurrencyType ]
end
local ICON_PADDING = 4
local ITEM_ICON_TEXTURE_SIZE = 32
local MULTI_CURRENCY_PADDING = 8 -- the amount of space between each currency type in a control
local DEFAULT_CURRENCY_OPTIONS =
{
showTooltips = false ,
useShortFormat = false ,
font = "ZoFontGame" ,
iconSide = RIGHT ,
}
--[[
Used to set up an args table on a control that will show currencies.
This is done to prevent many reallocations of consistently used data.
Pass in the currency types that the control will be known to use.
(The control doesn't need to ALWAYS use them, but if you know all possible
types ahead of time, pass then in and a display subtable will be created for
each type.)
When you want to show the appropriate currency call ZO_CurrencyControl_SetCurrencyData
and set up the display parameters.
--]]
local currencyArgs = { }
end
else
-- Mark all types as unused because we may not have the same data between calls
-- (Example: go to a store, not everything that's on sale will use the same currency types,
-- so we can only disable what we know about)
end
end
end
-- Use this function if you have a currency control that constantly needs to show arbitrary currency types, but only ever one (non-item) currency at a time
local function DynamicSetCurrencyData ( control , currencyType , amount , showAll , notEnough , displayOptions )
end
if showAll == nil then showAll = CURRENCY_SHOW_ALL end
if notEnough == nil then notEnough = CURRENCY_IGNORE_HAS_ENOUGH end
if showAll or ( amount > 0 ) then
displayData . amount = amount
displayData . isUsed = true
displayData . notEnough = notEnough
if displayOptions then
displayData . obfuscateAmount = displayOptions . obfuscateAmount
displayData . currencyCapAmount = displayOptions . currencyCapAmount
end
else
displayData . isUsed = false
end
end
local currentOffset = 1 -- used for finding the right item currency type
if offset ~= nil then
if offset == currentOffset then
else
currentOffset = currentOffset + 1
end
else
end
end
end
end
function ZO_CurrencyControl_SetCurrencyData ( control , currencyType , amount , showAll , notEnough , entryIndex , offset )
if displayData then
if showAll == nil then showAll = CURRENCY_SHOW_ALL end
if notEnough == nil then notEnough = CURRENCY_IGNORE_HAS_ENOUGH end
if showAll or ( amount > 0 ) then
displayData . amount = amount
displayData . isUsed = true
displayData . notEnough = notEnough
-- NOTE: 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.
if currencyType == CURT_ALLIANCE_POINTS then
displayData . notEnough = amount > GetCurrencyAmount ( CURT_ALLIANCE_POINTS , CURRENCY_LOCATION_CHARACTER )
end
else
displayData . isUsed = false
end
end
end
local USE_UPPERCASE_NUMBER_SUFFIXES = true
if obfuscateAmount then
elseif useShortFormat and amount >= CURRENCY_NO_ABBREVIATION_THRESHOLD then
return ZO_AbbreviateNumber ( amount , NUMBER_ABBREVIATION_PRECISION_HUNDREDTHS , USE_UPPERCASE_NUMBER_SUFFIXES )
else
end
end
function ZO_CurrencyControl_FormatCurrencyAndAppendIcon ( amount , useShortFormat , currencyType , isGamepad , obfuscateAmount )
local formattedCurrency = ZO_CurrencyControl_FormatCurrency ( amount , useShortFormat , obfuscateAmount )
local iconMarkup
local iconSize
local currencyInfo = g_currenciesData [ currencyType ]
if isGamepad then
iconSize = currencyInfo . gamepadPercentOfLineSize
iconMarkup = currencyInfo . gamepadTexture
else
iconSize = currencyInfo . keyboardPercentOfLineSize
iconMarkup = currencyInfo . keyboardTexture
end
end
local useDefaultText = true
if options then
useDefaultText = false
elseif options . customTooltip then
SetTooltipText ( InformationTooltip , zo_strformat ( SI_CURRENCY_CUSTOM_TOOLTIP_FORMAT , GetString ( options . customTooltip ) ) )
useDefaultText = false
end
end
if useDefaultText then
SetTooltipText ( InformationTooltip , zo_strformat ( SI_CURRENCY_CUSTOM_TOOLTIP_FORMAT , g_currenciesData [ control . type ] . amountLabel ) )
end
end
end
end
-- displayOptions is a table of additional display options to modify how the currency 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
function ZO_CurrencyControl_SetSimpleCurrency ( labelControl , currencyType , amount , options , showAll , notEnough , displayOptions )
end
local g_currencyStringFormatTable = { }
options = options or DEFAULT_CURRENCY_OPTIONS
local isGamepad = options . isGamepad
-- Show tooltips by default, only if showTooltips was explicitly set to false in options should
-- tooltips be turned off.
local showTooltips = true
if options . showTooltips == false then
showTooltips = false
end
if options . font then
end
local iconSide = RIGHT
if options . iconSide then
iconSide = options . iconSide
end
local iconSize = nil
if options . iconSize then
iconSize = options . iconSize
end
local overrideColor = nil
else
end
end
local multiCurrencyPad = 0
local currencyStaticInfo = g_currenciesData [ currencyType ]
if currencyData . isUsed and currencyStaticInfo then
if currencyData . notEnough then
else
if overrideColor then
else
end
end
-- If there are not multiple currencies then we can just set the color on the label. Otherwise, text must be colorized per currency fragment
else
end
if not iconSize then
iconSize = isGamepad and currencyStaticInfo . gamepadPercentOfLineSize or currencyStaticInfo . keyboardPercentOfLineSize
end
local iconMarkup = zo_iconFormat ( isGamepad and currencyStaticInfo . gamepadTexture or currencyStaticInfo . keyboardTexture , iconSize , iconSize )
local formattedAmount = ZO_CurrencyControl_FormatCurrency ( currencyData . amount , options . useShortFormat , currencyData . obfuscateAmount )
if not currencyData . obfuscateAmount and currencyData . currencyCapAmount then
local formattedCap = ZO_CurrencyControl_FormatCurrency ( currencyData . currencyCapAmount , options . useShortFormat )
formattedAmount = formattedAmount .. "/" .. formattedCap
end
if iconSide == LEFT then
local currencyMarkup = string . format ( "|u%d:%d:currency:%s|u" , ICON_PADDING , multiCurrencyPad , formattedAmount )
else -- Treat everything else as the default of going on the right
local currencyMarkup = string . format ( "|u%d:%d:currency:%s|u" , multiCurrencyPad , ICON_PADDING , formattedAmount )
end
end
-- Assume that there are more currencies, this is the whitespace to insert between them
multiCurrencyPad = MULTI_CURRENCY_PADDING
-- Needs to be handled with a table...this is for tooltips, so we need to figure out which region the mouse is over.
-- For now, it's last come, first serve...so if there is only a single currency type on the control this works fine.
end
end
end
end
end
else
end
end
--[[
Augmented Currency API
]] --
return g_currenciesData [ currencyType ] . keyboardTexture
end
return g_currenciesData [ currencyType ] . gamepadTexture
end
return g_currenciesData [ currencyType ] . gamepadTexture
else
return g_currenciesData [ currencyType ] . keyboardTexture
end
end
if inheritColor then
end
local currencyInfo = g_currenciesData [ currencyType ]
local iconSize = overrideIconSize or currencyInfo . keyboardPercentOfLineSize
end
if inheritColor then
end
local currencyInfo = g_currenciesData [ currencyType ]
local iconSize = overrideIconSize or currencyInfo . gamepadPercentOfLineSize
end
if inheritColor then
end
local currencyInfo = g_currenciesData [ currencyType ]
local iconSize = overrideIconSize or currencyInfo . gamepadPercentOfLineSize
else
local iconSize = overrideIconSize or currencyInfo . keyboardPercentOfLineSize
end
end
ZO_CURRENCY_FORMAT_AMOUNT_NAME = 1
ZO_CURRENCY_FORMAT_WHITE_AMOUNT_WHITE_NAME = 2
ZO_CURRENCY_FORMAT_PARENTHETICAL_AMOUNT = 3
ZO_CURRENCY_FORMAT_AMOUNT_ICON = 4
ZO_CURRENCY_FORMAT_WHITE_AMOUNT_ICON = 5
ZO_CURRENCY_FORMAT_ERROR_AMOUNT_ICON = 6
ZO_CURRENCY_FORMAT_PLURAL_NAME_ICON = 7
if isGamepad then
return g_currenciesData [ currencyType ] . gamepadColor
else
end
end
if isGamepad then
else
end
end
--The return of this function is intended to be formatted into another string
local formattedAmount
if currencyAmount then
if extraOptions and extraOptions . showCap then
local currencyLocation = extraOptions . currencyLocation
formattedAmount = formattedAmount .. "/" .. formattedCap
end
end
end
--We use string format to preserve the gender markup on currencyName.
if formatType == ZO_CURRENCY_FORMAT_AMOUNT_NAME then
local currencyInfo = g_currenciesData [ currencyType ]
local currencyName = GetCurrencyName ( currencyType , IsCountSingularForm ( currencyAmount ) , currencyInfo . isDefaultLowercase )
elseif formatType == ZO_CURRENCY_FORMAT_WHITE_AMOUNT_WHITE_NAME then
local currencyInfo = g_currenciesData [ currencyType ]
local currencyName = GetCurrencyName ( currencyType , IsCountSingularForm ( currencyAmount ) , currencyInfo . isDefaultLowercase )
elseif formatType == ZO_CURRENCY_FORMAT_PARENTHETICAL_AMOUNT then
elseif formatType == ZO_CURRENCY_FORMAT_AMOUNT_ICON then
elseif formatType == ZO_CURRENCY_FORMAT_WHITE_AMOUNT_ICON then
elseif formatType == ZO_CURRENCY_FORMAT_ERROR_AMOUNT_ICON then
return string . format ( "%s|u0:6%%:currency:|u%s" , ZO_ERROR_COLOR : Colorize ( formattedAmount ) , iconMarkup )
elseif formatType == ZO_CURRENCY_FORMAT_PLURAL_NAME_ICON then
local IS_PLURAL = false
local currencyInfo = g_currenciesData [ currencyType ]
end
end
local IS_KEYBOARD = false
end
local IS_GAMEPAD = true
end
return ZO_Currency_Format ( currencyAmount , currencyType , formatType , IsInGamepadPreferredMode ( ) , extraOptions )
end
return g_currenciesData [ currencyType ] . amountLabel
end
local playerCurrency1 = GetCurrencyAmount ( itemData . currencyType1 , GetCurrencyPlayerStoredLocation ( itemData . currencyType1 ) )
local playerCurrency2 = GetCurrencyAmount ( itemData . currencyType2 , GetCurrencyPlayerStoredLocation ( itemData . currencyType2 ) )
local costGold = quantity * itemData . price
local costCurrency1 = quantity * itemData . currencyQuantity1
local costCurrency2 = quantity * itemData . currencyQuantity2
local confirmCurrency1 = DoesCurrencyAmountMeetConfirmationThreshold ( itemData . currencyType1 , costCurrency1 )
local confirmCurrency2 = DoesCurrencyAmountMeetConfirmationThreshold ( itemData . currencyType2 , costCurrency2 )
if itemData . meetsRequirementsToBuy and ( ( confirmGold and playerGold >= costGold ) or ( confirmCurrency1 and playerCurrency1 >= costCurrency1 ) or ( confirmCurrency2 and playerCurrency2 >= costCurrency2 ) ) then
local params = {
quantity ,
itemLink ,
costGold > 0 and ZO_Currency_FormatKeyboard ( CURT_MONEY , costGold , ZO_CURRENCY_FORMAT_AMOUNT_ICON ) or "" ,
costCurrency1 > 0 and ZO_Currency_FormatKeyboard ( itemData . currencyType1 , costCurrency1 , ZO_CURRENCY_FORMAT_AMOUNT_ICON ) or "" ,
costCurrency2 > 0 and ZO_Currency_FormatKeyboard ( itemData . currencyType2 , costCurrency2 , ZO_CURRENCY_FORMAT_AMOUNT_ICON ) or ""
}
ZO_Dialogs_ShowPlatformDialog ( "CONFIRM_PURCHASE" , { buyIndex = storeItemIndex , quantity = quantity } , { mainTextParams = params } )
return true
end
return false
end |