|
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 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 |
-- layers for the various elements on the market product tiles-- controls are layered to ensure correct display order-- Background layerZO_MARKET_TILE_BACKGROUND_LEVEL = 1ZO_MARKET_TILE_OVERLAY_LEVEL = 9-- Text/Content layerZO_MARKET_TILE_BORDER_LEVEL = 10ZO_MARKET_TILE_TEXT_LEVEL = 11ZO_MARKET_TILE_ABOVE_TEXT_LEVEL = 12-- Top layerZO_MARKET_TILE_HIGHLIGHT_LEVEL = 20-- icons should be on top of the highlightZO_MARKET_TILE_ICON_FRAME_LEVEL = 21ZO_MARKET_TILE_ICON_IMAGE_LEVEL = 22--account for the fade that we add to the sides of the calloutZO_MARKET_PRODUCT_CALLOUT_X_OFFSET = 5ZO_MARKET_PRODUCT_HIGHLIGHT_ANIMATION_DURATION_MS = 255do local MARKET_PRODUCT_COLOR_MAP_UNFOCUSED = { [MARKET_PRODUCT_DISPLAY_STATE_NOT_PURCHASED] = ZO_MARKET_DIMMED_COLOR, [MARKET_PRODUCT_DISPLAY_STATE_PURCHASED] = ZO_MARKET_PRODUCT_PURCHASED_DIMMED_COLOR, [MARKET_PRODUCT_DISPLAY_STATE_INELIGIBLE] = ZO_MARKET_PRODUCT_INELIGIBLE_DIMMED_COLOR, } local MARKET_PRODUCT_COLOR_MAP_FOCUSED = { [MARKET_PRODUCT_DISPLAY_STATE_NOT_PURCHASED] = ZO_MARKET_SELECTED_COLOR, [MARKET_PRODUCT_DISPLAY_STATE_PURCHASED] = ZO_MARKET_PRODUCT_PURCHASED_COLOR, [MARKET_PRODUCT_DISPLAY_STATE_INELIGIBLE] = ZO_MARKET_PRODUCT_INELIGIBLE_COLOR, } local colorLookup = isFocused and MARKET_PRODUCT_COLOR_MAP_FOCUSED or MARKET_PRODUCT_COLOR_MAP_UNFOCUSED endenddo local UNFOCUSED_COLOR_MAP = { [MARKET_PRODUCT_DISPLAY_STATE_NOT_PURCHASED] = ZO_MARKET_PRODUCT_ESO_PLUS_DIMMED_COLOR, [MARKET_PRODUCT_DISPLAY_STATE_PURCHASED] = ZO_MARKET_PRODUCT_ESO_PLUS_PURCHASED_DIMMED_COLOR, [MARKET_PRODUCT_DISPLAY_STATE_INELIGIBLE] = ZO_MARKET_PRODUCT_ESO_PLUS_PURCHASED_DIMMED_COLOR, } local FOCUSED_COLOR_MAP = { [MARKET_PRODUCT_DISPLAY_STATE_NOT_PURCHASED] = ZO_MARKET_PRODUCT_ESO_PLUS_COLOR, [MARKET_PRODUCT_DISPLAY_STATE_PURCHASED] = ZO_MARKET_PRODUCT_ESO_PLUS_PURCHASED_COLOR, [MARKET_PRODUCT_DISPLAY_STATE_INELIGIBLE] = ZO_MARKET_PRODUCT_ESO_PLUS_PURCHASED_COLOR, } local colorLookup = isFocused and FOCUSED_COLOR_MAP or UNFOCUSED_COLOR_MAP endend----[[ MarketProductBase ]]---- return marketProductendend -- To be overriddenendendendendendendendendendendendendendendendendendendendend local isGiftable = false local isHouseMarketProduct, houseTemplateDataList, defaultHouseTemplateIndex = ZO_MarketProduct_GetMarketProductHouseTemplateDataList(self.productData.marketProductId, function(...) return { GetActiveMarketProductListingsForHouseTemplate(...) } end) if marketData then local houseTemplateMarketProductData = ZO_MarketProductData:New(marketData.marketProductId, marketData.presentationIndex) end end return isGiftable endend -- may be overridden by child classes that require additional logicendendendendendendendendendend return isPurchased and ZO_MARKET_PRODUCT_PURCHASED_DESATURATION or ZO_MARKET_PRODUCT_NOT_PURCHASED_DESATURATIONend -- Setup default anchoring without any font resizing if hasNormalCost then control.textCallout:SetAnchor(BOTTOMLEFT, control.previousCost, TOPLEFT, ZO_MARKET_PRODUCT_CALLOUT_X_OFFSET - 2, self.textCalloutYOffset) -- x offset to account for strikethrough else control.textCallout:SetAnchor(BOTTOMLEFT, control.cost, TOPLEFT, ZO_MARKET_PRODUCT_CALLOUT_X_OFFSET, self.textCalloutYOffset) end else -- if we don't have a normal cost, then we need to anchor the callout to the ESO Plus cost -- there should never be a case where a market product has neither a normal cost nor an ESO Plus cost (because then it would be unpurchasable) control.textCallout:SetAnchor(BOTTOMLEFT, control.esoPlusCost, TOPLEFT, ZO_MARKET_PRODUCT_CALLOUT_X_OFFSET, self.textCalloutYOffset) end if hasEsoPlusCost then if hasNormalCost then else end end -- Setup default anchors before setting any text so that we will know if fonts need to be resized to fit the text -- Setup the callouts for new, on sale, and LTO -- layout the price labels ZO_MarketClasses_Shared_ApplyTextColorToLabelByState(control.title, self:IsFocused(), self.displayState)end local purchasedAndNew = self.productData:IsNew() and not (purchaseable or self:IsLimitedTimeProduct() or self:IsOnSale())endfunction ZO_MarketProductBase:GetMarketProductListingsForHouseTemplate(houseTemplateId, displayGroup)end return ZO_MarketProduct_GetDefaultHousingTemplatePricingInfo(self:GetId(), function(...) return self:GetMarketProductListingsForHouseTemplate(...) end)end local hideCallouts = true -- setup the callouts for new, on sale, and LTO hideCallouts = false hideCallouts = false calloutUpdateHandler = function() self:UpdateSaleRemainingTimeCalloutText(self.discountPercent, onSaleMarketProductId) end end hideCallouts = false end endenddo local TEXT_CALLOUT_BACKGROUND_ALPHA = 0.9 if textCalloutBackgroundColor then end endend -- layout the previous cost else end -- layout the current cost local priceFormat = "%s %s" priceFormat = "%s+ %s" end local INHERIT_ICON_COLOR = true local CURRENCY_ICON_SIZE = "100%" local currencyIcon = ZO_Currency_GetPlatformFormattedCurrencyIcon(GetCurrencyTypeFromMarketCurrencyType(self.currencyType), CURRENCY_ICON_SIZE, INHERIT_ICON_COLOR) local currencyString = string.format(priceFormat, zo_strformat(SI_NUMBER_FORMAT, self.costAfterDiscount), currencyIcon) else end ZO_MarketClasses_Shared_ApplyTextColorToLabelByState(control.cost, self:IsFocused(), self.displayState) else end local INHERIT_ICON_COLOR = true local CURRENCY_ICON_SIZE = "100%" local currencyIcon = ZO_Currency_GetPlatformFormattedCurrencyIcon(GetCurrencyTypeFromMarketCurrencyType(self.currencyType), CURRENCY_ICON_SIZE, INHERIT_ICON_COLOR) -- the keyboard Crown Gem icon is purple, so we shouldn't try to recolor it with gold colors local iconColor = self:CanBePurchased() and ZO_MARKET_SELECTED_COLOR or ZO_MARKET_PRODUCT_PURCHASED_COLOR end local currencyString = string.format("%s %s", zo_strformat(SI_NUMBER_FORMAT, self.esoPlusCost), currencyIcon) else end ZO_MarketClasses_Shared_ApplyEsoPlusColorToLabelByState(control.esoPlusCost, self:IsFocused(), self.displayState) else endend if not canBePurchased then local purchasedString purchasedString = "" elseif self.displayState == MARKET_PRODUCT_DISPLAY_STATE_NOT_PURCHASED and self:IsHouseCollectible() then purchasedString = "" else -- MARKET_PRODUCT_DISPLAY_STATE_PURCHASED else end end ZO_MarketClasses_Shared_ApplyTextColorToLabelByState(purchaseLabelControl, self:IsFocused(), self.displayState) endendend -- anchor the purchase control to the bottom right of the tile -- if this is a bundle, account for the bundle indicators in the bottom right else end else end -- anchor the left side to the right-most cost label else -- we shouldn't hit this case endend -- Text callout anchors are only going to need to be readjusted in the case where we have and eso plus cost and the item is a bundle local isBundleLabelAnchorValid, _, _, _, bundleLabelOffsetX = self.control.bundledProductsItemsLabel:GetAnchor(0) local isBundleNumLabelAnchorValid, _, _, _, bundleNumLabelOffsetX = self.control.numBundledProductsLabel:GetAnchor(0) local isEsoPlusDealLabelAnchorValid, _, _, _, esoPlusDealLabelOffsetX = self.control.esoPlusDealLabelControl:GetAnchor(0) -- Subtract x offsets for bundle elements because they right justified local bundleLabelWidthWithOffset = bundleLabelWidth - (isBundleLabelAnchorValid and bundleLabelOffsetX or 0) local bundleNumLabelWidthWithOffset = bundleNumLabelWidth - (isBundleNumLabelAnchorValid and bundleNumLabelOffsetX or 0) -- Bundle will be right anchored to the eso plus deal label so it's offset needs to be considered as well local totalBundleWidthWithOffsets = bundleLabelWidthWithOffset + bundleNumLabelWidthWithOffset - (isEsoPlusDealLabelAnchorValid and esoPlusDealLabelOffsetX or 0) local totalTextCalloutLineWidthWithOffset = textCalloutWidth + (isTextCalloutAnchorValid and textCalloutOffsetX or 0) local totalLineContentWidth = totalTextCalloutLineWidthWithOffset + totalBundleWidthWithOffsets if totalLineContentWidth > tileWidth then end endend -- Bundle text is only in line with callout when there's an eso plus deal else end else endend if shouldShowDealLabel then else end ZO_MarketClasses_Shared_ApplyEsoPlusColorToLabelByState(esoPlusDealLabelControl, self:IsFocused(), self.displayState) endendend if isBundle then -- hide the label if the result is 0 or 1 (which means either an empty bundle or what should be a single product...) local hideBundledProductsLabel = numBundledProducts <= 1 else endend -- optional overrideend -- if there is no time left remaining then the MarketProduct is not limited time -- because when a limited time product reaches 0 it is removed from the store if remainingTime > 0 then if remainingTime >= ZO_ONE_DAY_IN_SECONDS then self.textCalloutText = zo_strformat(SI_TIME_DURATION_LEFT, ZO_FormatTime(remainingTime, TIME_FORMAT_STYLE_SHOW_LARGEST_UNIT_DESCRIPTIVE, TIME_FORMAT_PRECISION_SECONDS)) else self.textCalloutText = zo_strformat(SI_TIME_DURATION_LEFT, ZO_FormatTimeLargestTwo(remainingTime, TIME_FORMAT_STYLE_DESCRIPTIVE_MINIMAL)) end endend -- if there is no time left remaining then the MarketProduct is not limited time -- because when a limited time product reaches 0 it is removed from the store if remainingTime > 0 and remainingTime <= ZO_ONE_MONTH_IN_SECONDS then local remainingTimeText if remainingTime >= ZO_ONE_DAY_IN_SECONDS then remainingTimeText = ZO_FormatTime(remainingTime, TIME_FORMAT_STYLE_SHOW_LARGEST_UNIT_DESCRIPTIVE, TIME_FORMAT_PRECISION_SECONDS) else end else endend -- this is currently a safeguard for the announcement tiles which set their -- product data up ahead of time and don't pass in data on show if marketProductData then endendend local currencyType, cost, costAfterDiscount, discountPercent, esoPlusCost = self:GetMarketProductPricingByPresentation() local houseCurrencyType, houseCost, houseCostAfterDiscount, houseDiscountPercent, houseEsoPlusCost, defaultHouseTemplateMarketProductId, hasMultipleTemplates = self:GetDefaultHouseTemplatePricingInfo() if houseCurrencyType ~= MKCT_NONE then currencyType = houseCurrencyType cost = houseCost costAfterDiscount = houseCostAfterDiscount discountPercent = houseDiscountPercent or 0 esoPlusCost = houseEsoPlusCost else end else endendendendendendendend -- Clear the background's texture so that it can be cleared at zero referencesendendend--Get the narration for the title of this market productend--Get the narration for the callouts section of this market productend--Get the narration for the pricing of this market product local narrations = {} --Do the narration for the regular cost --If the product has a discounted price, narrate the original price first ZO_AppendNarration(narrations, SCREEN_NARRATION_MANAGER:CreateNarratableObject(GetString(SI_MARKET_ORIGINAL_PRICE_NARRATION))) local currencyString = ZO_Currency_FormatGamepad(GetCurrencyTypeFromMarketCurrencyType(self.currencyType), self.cost, ZO_CURRENCY_FORMAT_AMOUNT_NAME) ZO_AppendNarration(narrations, SCREEN_NARRATION_MANAGER:CreateNarratableObject(GetString(SI_MARKET_CURRENT_PRICE_NARRATION))) end --Narrate the current price local currencyString --If the product has more than 1 pricing option, we need to format the currency narration a bit differently local IS_UPPER = false local currencyName = GetCurrencyName(GetCurrencyTypeFromMarketCurrencyType(self.currencyType), IsCountSingularForm(self.costAfterDiscount), IS_UPPER) currencyString = string.format("%s + %s", zo_strformat(SI_NUMBER_FORMAT, self.costAfterDiscount), currencyName) else currencyString = ZO_Currency_FormatGamepad(GetCurrencyTypeFromMarketCurrencyType(self.currencyType), self.costAfterDiscount, ZO_CURRENCY_FORMAT_AMOUNT_NAME) end else ZO_AppendNarration(narrations, SCREEN_NARRATION_MANAGER:CreateNarratableObject(GetString(SI_MARKET_FREE_LABEL))) end end --Do the narration for the eso plus specific cost --Narrate the cost local currencyString = ZO_Currency_FormatGamepad(GetCurrencyTypeFromMarketCurrencyType(self.currencyType), self.esoPlusCost, ZO_CURRENCY_FORMAT_AMOUNT_NAME) else ZO_AppendNarration(narrations, SCREEN_NARRATION_MANAGER:CreateNarratableObject(GetString(SI_MARKET_FREE_LABEL))) end --Narrate what type of deal this is local dealText = self:HasCost() and GetString(SI_MARKET_ESO_PLUS_DEAL_NARRATION) or GetString(SI_MARKET_ESO_PLUS_EXCLUSIVE_NARRATION) end end return narrationsend--Get the narration for the bundle information of this market product local narrations = {} if numBundledProducts > 1 then ZO_AppendNarration(narrations, SCREEN_NARRATION_MANAGER:CreateNarratableObject(GetString(SI_MARKET_PRODUCT_TOTAL_LABEL))) end end return narrationsend--Get the narration for the purchased state of this market productend-- MarketProduct Preview functionsend --Houses are special because as far as C is concerned they aren't previewable, but Lua allows for a roundabout preview with jumping to the house return CanPreviewMarketProduct(self:GetId()) or self:GetMarketProductPreviewType() == ZO_MARKET_PREVIEW_TYPE_HOUSEendend-- functions to be overridden -- optional overridde, default behavior return trueend -- to be overriddenend -- to be overridden, default behavior return nilend -- to be overridden, default behavior return nilend -- to be overriddenend-- global functions if collectibleType == COLLECTIBLE_CATEGORY_TYPE_HOUSE then return true end end return falseendfunction ZO_MarketProduct_GetMarketProductHouseTemplateDataList(marketProductId, getMarketProductListingsCallback) local isHouseMarketProduct = false --[[ If the defined default is valid, defaultHouseTemplateIndex should be that index; if the defined default is not valid, but another is, it will be the first valid one; if none are valid, it's the defined default again. ]] local defaultHouseTemplateIndex local isDefaultTemplateValid = false local isAnyTemplateValid = false local houseTemplateDataList = {} isHouseMarketProduct = true local marketProductListings = getMarketProductListingsCallback(houseTemplateId, MARKET_DISPLAY_GROUP_CROWN_STORE) local houseTemplateData = { houseTemplateId = houseTemplateId, marketPurchaseOptions = {} } if #marketProductListings > 0 then --There could be multiple listings per template, one for each currency type. local PRODUCT_LISTINGS_STRIDE = 2 for i = 1, #marketProductListings, PRODUCT_LISTINGS_STRIDE do local houseTemplateMarketProductId = marketProductListings[i] local presentationIndex = marketProductListings[i + 1] local currencyType, cost, costAfterDiscount, discountPercent, esoPlusCost = GetMarketProductPricingByPresentation(houseTemplateMarketProductId, presentationIndex) --Don't allow the same currency twice. This is a nonsense scenario but technically possible. if not houseTemplateData.marketPurchaseOptions[currencyType] then local marketPurchaseData = { currencyType = currencyType, marketProductId = houseTemplateMarketProductId, presentationIndex = presentationIndex, houseId = houseId, houseTemplateId = houseTemplateId, isHouseOwned = isHouseOwned, cost = cost, costAfterDiscount = costAfterDiscount, discountPercent = discountPercent, esoPlusCost = esoPlusCost, } houseTemplateData.marketPurchaseOptions[currencyType] = marketPurchaseData houseTemplateData.name = houseTemplateData.name or GetMarketProductDisplayName(houseTemplateMarketProductId) end end end --[[ The following should guarantee that we set the default index to the defined default if it's valid, the first valid entry if it's not, and the defined default if there are no valid entries. ]] if houseTemplateId == defaultHouseTemplateId then if #houseTemplateData.marketPurchaseOptions > 0 then isDefaultTemplateValid = true isAnyTemplateValid = true defaultHouseTemplateIndex = index -- The following fires if we have the defined default but we haven't found any valid entries (including this one). elseif not isAnyTemplateValid then defaultHouseTemplateIndex = index end -- The following fires if this is the first valid template we've found. elseif not isAnyTemplateValid and #houseTemplateData.marketPurchaseOptions > 0 then defaultHouseTemplateIndex = index isAnyTemplateValid = true end end end return isHouseMarketProduct, houseTemplateDataList, defaultHouseTemplateIndexendfunction ZO_MarketProduct_GetDefaultHousingTemplatePricingInfo(marketProductId, getMarketProductListingsCallback) local isHouseMarketProduct, houseTemplateDataList, defaultHouseTemplateIndex = ZO_MarketProduct_GetMarketProductHouseTemplateDataList(marketProductId, getMarketProductListingsCallback) local defaultHouseTemplateData = houseTemplateDataList[defaultHouseTemplateIndex] -- Count how many templates actually have purchase data. local numValidTemplates = 0 if #houseTemplateData.marketPurchaseOptions > 0 then numValidTemplates = numValidTemplates + 1 end end if marketData then return currencyType, marketData.cost, marketData.costAfterDiscount, marketData.discountPercent, marketData.esoPlusCost, marketData.marketProductId, numValidTemplates > 1 else return currencyType end endend----[[ XML Handlers ]]---- endend |