|
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 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 |
KEYBIND_STRIP_ALIGN_LEFT = 1KEYBIND_STRIP_ALIGN_CENTER = 2KEYBIND_STRIP_ALIGN_RIGHT = 3KEYBIND_STRIP_DISABLED_ALERT = "alert"KEYBIND_STRIP_DISABLED_DIALOG = "dialog"local DOWN = falselocal UP = true end if keybindButtonDescriptor.handlesKeyUp or keybindButtonDescriptor.keybindButtonGroupDescriptor and keybindButtonDescriptor.keybindButtonGroupDescriptor.handlesKeyUp then end end end end -- NOTE: Whatever template is used here is expected to have the interface defined by -- ZO_KeybindButtonTemplate_OnInitialized. This should set up a few control references (for the name and key labels) -- as well as defining some state management functions...see that object for more details. end end end end end end endend-- Keybind State Stack Management local background background = ZO_KeybindStripMungeBackground else background = ZO_KeybindStripGamepadBackground end local state = { keybindGroups = {}, individualButtons = {}, } --copy all the keybind groups into the state and remove them from the strip end --now copy/overwrite any left over buttons to the state endend if(numStates > 0) then end end else end end endend if state then end end endend --remove all keybind buttons and loose buttons as well as any states endend if tier then end if layer then end endend if ZO_KeybindStripMungeBackground then if tier then end if layer then end end end if ZO_KeybindStripGamepadBackground then if tier then end if layer then end end endend--Returns nil if there are no keybind group states (push was not called).--Returns the bottom of the stack when there is no stateIndex if there are keybind group states (push was called at least once). stateIndex = stateIndex or 1 end return nilendend--- PRIVATE FUNCTIONS -----We store the descriptor for ethereals and the button control for keybinds that actually appear on the strip return buttonOrEtherealDescriptor.keybindButtonDescriptor end return buttonOrEtherealDescriptorend end endend if state.keybindGroups[keybindButtonGroupDescriptor] then state.keybindGroups[keybindButtonGroupDescriptor] = nil return true end return falseend state.individualButtons[keybindButtonDescriptor.keybind] = nilend if state.keybindGroups[keybindButtonDescriptor] then return true end return falseend -- do nothingend -- do nothingend end endend--- END OF PRIVATE FUNCTIONS -----[[An example keybind button descriptorlocal descriptor = { alignment = KEYBIND_STRIP_ALIGN_CENTER, -- defaults to KEYBIND_STRIP_ALIGN_RIGHT order = 100 -- or a function that returns the relative ordering within the alignment, where a lower number is anchored first (right to left for left alignment, left to right for center and right), default is 0 - buttons with the same order are ordered by insertion name = "Exit", -- or function that returns a name keybind = "UI_SHORTCUT_PRIMARY", gamepadPreferredKeybind = "UI_SHORTCUT_NEGATIVE", -- optional, only use in the case that you want to reuse a button between keyboard and gamepad, but want them to have different bindings. customKeybindControl = nil, -- control or a function that returns a control to display instead of the normal keybind label callback = function(up) DoSomething() end, -- First and only parameter is whether its a key up or down, ups will only be sent if handlesKeyUp flag is set visible = function(descriptor) return IsUsePossible(descriptor.something) end, -- An optional predicate, if present returning true indicates that this descriptor is visible, otherwise it is not icon = "IconPath/Icon.dds", -- or a function that returns an icon path, an optional icon to display to the right of the name handlesKeyUp = true, -- indicates that the callback would like to be informed of key ups in addition to downs, by default only downs are sent disabledDuringSceneHiding = false, -- indicates that the callback is disabled during Scene Hiding, by default it is false ethereal = false, -- if true, indicates that the button has no physical presence and will only be considered when a keybind is used, which means that name, alignment, etc properties are ignored. This cannot be a function that returns a value.}]]--do end function ZO_KeybindStrip:HandleDuplicateAddKeybind(existingButtonOrEtherealDescriptor, keybindButtonDescriptor, state, stateIndex, currentSceneName) if existingDescriptor then --We tried to re-add the same exact button, just return if existingDescriptor == keybindButtonDescriptor then return end local existingSceneName = existingDescriptor.addedForSceneName or "" local keybindIdentifier if keybindButtonDescriptor.gamepadPreferredKeybind then keybindIdentifier = string.format("%s or %s", keybindButtonDescriptor.keybind, keybindButtonDescriptor.gamepadPreferredKeybind) else keybindIdentifier = keybindButtonDescriptor.keybind end local assertMessage = string.format("Duplicate Keybind: %s. Before: %s (%s). After: %s (%s).", keybindIdentifier, existingSceneName, existingDescriptorIdentifier, currentSceneName, newDescriptorIdentifier) -- Asserting here usually means that a key is already bound (typically because someone forgot to remove a keybinding). end end function ZO_KeybindStrip:AddKeybindButtonStack(keybindButtonDescriptor, state, stateIndex, currentSceneName) local existingButtonOrEtherealDescriptor = state.individualButtons[keybindButtonDescriptor.keybind] if existingButtonOrEtherealDescriptor then self:HandleDuplicateAddKeybind(existingButtonOrEtherealDescriptor, keybindButtonDescriptor, state, stateIndex, currentSceneName) end state.individualButtons[keybindButtonDescriptor.keybind] = keybindButtonDescriptor keybindButtonDescriptor.addedForSceneName = currentSceneName end function ZO_KeybindStrip:RegisterKeybindButtonOrEtherealDescriptorInternal(buttonOrEtherealDescriptor) if descriptor.gamepadPreferredKeybind then self.keybindsByGamepadPreferredKeybind[descriptor.gamepadPreferredKeybind] = buttonOrEtherealDescriptor end end local currentSceneName = "" if SCENE_MANAGER then if currentScene then end end if state then end if existingButtonOrEtherealDescriptor then self:HandleDuplicateAddKeybind(existingButtonOrEtherealDescriptor, keybindButtonDescriptor, state, stateIndex, currentSceneName) end if keybindButtonDescriptor.gamepadPreferredKeybind then local existingButtonOrEtherealDescriptor = self.keybindsByGamepadPreferredKeybind[keybindButtonDescriptor.gamepadPreferredKeybind] if existingButtonOrEtherealDescriptor then self:HandleDuplicateAddKeybind(existingButtonOrEtherealDescriptor, keybindButtonDescriptor, state, stateIndex, currentSceneName) end -- edge case: if a keybind registers only using the normal pathway, but -- we shadow it here, there is no way to press that keybind. so let's -- prevent that using the normal duplicate keybind handling local existingButtonOrEtherealDescriptor = self.keybinds[keybindButtonDescriptor.gamepadPreferredKeybind] if existingButtonOrEtherealDescriptor and GetDescriptorFromButton(existingButtonOrEtherealDescriptor).gamepadPreferredKeybind == nil then self:HandleDuplicateAddKeybind(existingButtonOrEtherealDescriptor, keybindButtonDescriptor, state, stateIndex, currentSceneName) end end keybindButtonDescriptor.addedForSceneName = currentSceneName else -- clear this out in case it was previously in a group keybindButtonDescriptor.keybindButtonGroupDescriptor = nil end end end endend return (first == nil) or (second == nil) or ((first.keybind == second.keybind) andend if state then end if buttonOrEtherealDescriptor and CompareKeybindButtonDescriptor(buttonOrEtherealDescriptor.keybindButtonDescriptor, keybindButtonDescriptor) then if keybindButtonDescriptor.gamepadPreferredKeybind then end keybindButtonDescriptor.addedForSceneName = nil if cooldownKeybindDescriptor == keybindButtonDescriptor and not cooldownKeybindDescriptor.shouldCooldownPersist then cooldownKeybindDescriptor.cooldown = nil cooldownKeybindDescriptor.cooldownStart = nil break end end end end endend if state then end local existingButton = buttonOrEtherealDescriptor if existingButton.keybindButtonDescriptor == keybindButtonDescriptor and not GetValueFromRawOrFunction(keybindButtonDescriptor, "ethereal") then local UPDATE_ONLY = true end else end elseif buttonOrEtherealDescriptor then local existingButtonDescriptor = buttonOrEtherealDescriptor if keybindButtonDescriptor ~= existingButtonDescriptor or not GetValueFromRawOrFunction(keybindButtonDescriptor, "ethereal") then end endend return state.individualButtons[keybindButtonDescriptor.keybind] ~= nilend if state then endend return state.keybindGroups[keybindButtonGroupDescriptor] ~= nilend if state then endend--[[An example keybind button group descriptorlocal keybindButtonGroup = { -- Anything added here will be inherited by individual descriptors, for example adding an alignment of left here will cause individial descriptors to all be aligned left -- unless they specify their own alignment alignment = KEYBIND_STRIP_ALIGN_LEFT, { name = "Exit", -- or function that returns a name keybind = "UI_SHORTCUT_PRIMARY", callback = function(up) DoSomething() end, -- First and only parameter is whether its a key up or down, ups will only be sent if handlesKeyUp flag is set handlesKeyUp = true, -- indicates that the callback would like to be informed of key ups in addition to downs, by default only downs are sent }, { alignment = KEYBIND_STRIP_ALIGN_CENTER, -- override the alignment set un the group name = "Use", -- or function that returns a name keybind = "UI_SHORTCUT_SECONDARY", callback = function(up) UseSomething() end, -- First and only parameter is whether its a key up or down, ups will only be sent if handlesKeyUp flag is set visible = function(descriptor) return IsUsePossible(descriptor.something) end, sound = SOUNDS.POSITIVE_CLICK, -- An audio hook that plays when the button is pressed },}]]-- if not state.keybindGroups[keybindButtonGroupDescriptor] then state.keybindGroups[keybindButtonGroupDescriptor] = keybindButtonGroupDescriptor return true end return falseend if state then end keybindButtonDescriptor.keybindButtonGroupDescriptor = keybindButtonGroupDescriptor end end return true end return falseend if state then end keybindButtonDescriptor.keybindButtonGroupDescriptor = nil end return true end return falseend if state then end endend if state then end end return true end return falseend if keybindButtonDescriptor.disabledDuringSceneHiding then return false end end return trueend -- in the case of duplicates, prefer the gamepad key else -- in the case of duplicates, prefer the keyboard key endend if buttonOrEtherealDescriptor and (not buttonOrEtherealDescriptor.IsControlHidden or not buttonOrEtherealDescriptor:IsControlHidden()) then local enabled, disabledAlertText, disabledAlertType = GetValueFromRawOrFunction(keybindButtonDescriptor, "enabled") if cooldown then end local keybindHandled = nil keybindButtonDescriptor.handledDown = true -- ClearMenu must come after the keybind callback because it clears the -- MouseOverRow for SortFilterLists on which the callback may be relying end end end return keybindHandled or keybindHandled == nil --nil is considered true in this case to ensure backwards compatability end if disabledAlertType == KEYBIND_STRIP_DISABLED_DIALOG then ZO_Dialogs_ShowPlatformDialog("KEYBIND_STRIP_DISABLED_DIALOG", nil, { mainTextParams = { alertText }}) else if ZO_REMOTE_SCENE_CHANGE_ORIGIN == SCENE_MANAGER_MESSAGE_ORIGIN_INTERNAL then elseif ZO_REMOTE_SCENE_CHANGE_ORIGIN == SCENE_MANAGER_MESSAGE_ORIGIN_INGAME then end end end end end return falseend if buttonOrEtherealDescriptor and (not buttonOrEtherealDescriptor.IsControlHidden or not buttonOrEtherealDescriptor:IsControlHidden()) then if cooldown then end local handledPreviousDown = keybindButtonDescriptor.handledDown keybindButtonDescriptor.handledDown = nil if keybindButtonDescriptor.handlesKeyUp or keybindButtonDescriptor.keybindButtonGroupDescriptor and keybindButtonDescriptor.keybindButtonGroupDescriptor.handlesKeyUp then local keybindHandled = nil end end return keybindHandled or keybindHandled == nil --nil is considered true in this case to ensure backwards compatability end end end end return falseendfunction ZO_KeybindStrip:TriggerCooldown(keybindButtonDescriptor, duration, stateIndex, shouldCooldownPersist) else keybindButtonDescriptor.shouldCooldownPersist = shouldCooldownPersist end if self.keybinds[keybindButtonDescriptor.keybind] and self.keybinds[keybindButtonDescriptor.keybind].keybindButtonDescriptor == keybindButtonDescriptor then end --Check for duplicates if descriptor == keybindButtonDescriptor then return end endend local newCooldown else local cooldownStart = descriptor.cooldownStart newCooldown = descriptor.cooldown - difference end --Only update for changes in the seconds count if oldCeiling ~= newCeiling then descriptor.cooldown = newCooldown if descriptor.cooldown <= 0 then descriptor.cooldown = nil descriptor.cooldownStart = nil descriptor.shouldCooldownPersist = nil end if activeDescriptor then activeDescriptor = activeDescriptor.keybindButtonDescriptor end if descriptor == activeDescriptor then end end elseif descriptor.cooldown <= 0 then descriptor.cooldown = nil descriptor.cooldownStart = nil descriptor.shouldCooldownPersist = nil end endendend--[[ A style table provides font and other information to describe the look of the keybind buttons An example descriptor: { nameFont = "ZoFontKeybindStripDescription", nameFontColor = ZO_NORMAL_TEXT, keyFont = "ZoFontKeybindStripKey", modifyTextType = MODIFY_TEXT_TYPE_UPPERCASE, alwaysPreferGamepadMode = false, resizeToFitPadding = 40, yAnchorOffset = 0, leftAnchorRelativeToControl = GuiRoot, leftAnchorRelativePoint = LEFT, leftAnchorOffset = 0, centerAnchorOffset = 0, rightAnchorOffset = 0, rightAnchorRelativeToControl = GuiRoot, rightAnchorRelativePoint = RIGHT, drawTier = DT_HIGH, drawLevel = ZO_HIGH_TIER_GAMEPAD_KEYBIND_STRIP, backgroundDrawTier = DT_HIGH, backgroundDrawLevel = ZO_HIGH_TIER_GAMEPAD_KEYBIND_STRIP_BG, }]] end end end endend -- even though we are only refreshing the background style, we are still changing the style overall -- store the potential style change so that future calls to SetStyle can refresh everything appropriately end self:SetBackgroundDrawOrder(styleInfo.backgroundDrawTier, styleInfo.backgroundDrawLayer, styleInfo.backgroundDrawLevel)endend end-- implementation functions below if styleInfo then if styleInfo.nameFont then end if styleInfo.nameFontColor then end if styleInfo.keyFont then end if styleInfo.resizeToFitPadding then end if styleInfo.modifyTextType then end return styleInfo.alwaysPreferGamepadMode end return nilenddo local visibilityFunction = keybindButtonDescriptor.visible or keybindButtonDescriptor.keybindButtonGroupDescriptor and keybindButtonDescriptor.keybindButtonGroupDescriptor.visible return not visibilityFunction or visibilityFunction(keybindButtonDescriptor, keybindButtonDescriptor.keybindButtonGroupDescriptor) end local customKeybindControl = GetValueFromRawOrFunction(keybindButtonDescriptor, "customKeybindControl") if customKeybindControl then else end local keybind = keybindButtonDescriptor.keybind local gamepadPreferredKeybind = keybindButtonDescriptor.gamepadPreferredKeybind local keybindButtonGroupDescriptor = keybindButtonDescriptor.keybindButtonGroupDescriptor if keybindButtonGroupDescriptor then if not keybind then keybind = keybindButtonGroupDescriptor.keybind end if not gamepadPreferredKeybind then gamepadPreferredKeybind = keybindButtonGroupDescriptor.gamepadPreferredKeybind end end -- updateOnly is used only when we are trying to update keybinds from UpdateKeybindButton so we know that this setup is coming from an update if not suppressUpdate or buttonKeybindChanging then local DEFAULT_SHOW_UNBOUND = nil end end if cooldown and cooldown > 0 then end -- if we have a custom keybind control then attempt to disable it as well to match end if cooldown and cooldown > 0 then end if iconPath and iconPath ~= "" then end else end end else if customKeybindControl then end end end if leftOrder == rightOrder then return buttonLeft.insertionOrder < buttonRight.insertionOrder end return leftOrder < rightOrder end local GAMEPAD_BUTTON_ORDER = { UI_SHORTCUT_EXIT = 0, UI_SHORTCUT_PRIMARY = 1, UI_SHORTCUT_NEGATIVE = 2, UI_SHORTCUT_SECONDARY = 3, UI_SHORTCUT_TERTIARY = 4, UI_SHORTCUT_QUATERNARY = 5, UI_SHORTCUT_QUINARY = 6, UI_SHORTCUT_LEFT_STICK = 7, UI_SHORTCUT_RIGHT_STICK = 8, UI_SHORTCUT_LEFT_TRIGGER = 9, UI_SHORTCUT_RIGHT_TRIGGER = 10, DIALOG_PRIMARY = 1, DIALOG_NEGATIVE = 2, DIALOG_SECONDARY = 3, DIALOG_TERTIARY = 4, DIALOG_RESET = 5, } end order = GAMEPAD_BUTTON_ORDER[keybindDescriptor.gamepadPreferredKeybind or keybindDescriptor.keybind] end end return 0 end local leftKeybindDescriptor = buttonLeft.keybindButtonDescriptor local rightKeybindDescriptor = buttonRight.keybindButtonDescriptor if leftOrder == rightOrder then return buttonLeft.insertionOrder < buttonRight.insertionOrder end return leftOrder < rightOrder end local leftOrder = leftKeybindDescriptor.etherealNarrationOrder or 0 local rightOrder = rightKeybindDescriptor.etherealNarrationOrder or 0 if leftOrder == rightOrder then return leftKeybindDescriptor.keybind < rightKeybindDescriptor.keybind else return leftOrder < rightOrder end end end --Any additional info we end up needing for narration should go here { name = GetValueFromRawOrFunction(keybindButtonDescriptor, "narrationOverrideName") or GetValueFromRawOrFunction(keybindButtonDescriptor, "name"), keybindName = ZO_Keybindings_GetHighestPriorityNarrationStringFromAction(keybindButtonDescriptor.keybind) or GetString(SI_ACTION_IS_NOT_BOUND), } end local keybinds = {} --Do not include anything if the keybind strip is currently hidden local buttonsByAlignment = { [KEYBIND_STRIP_ALIGN_LEFT] = {}, [KEYBIND_STRIP_ALIGN_CENTER] = {}, [KEYBIND_STRIP_ALIGN_RIGHT] = {}, } local alignment = GetValueFromRawOrFunction(button.keybindButtonDescriptor, "alignment") or KEYBIND_STRIP_ALIGN_RIGHT end end else end end end end --Iterate backwards through the right aligned keybinds so they are ordered left to right visually for _, button in ZO_NumericallyIndexedTableReverseIterator(buttonsByAlignment[KEYBIND_STRIP_ALIGN_RIGHT]) do end local etherealDescriptors = {} --Iterate through ethereal keybinds to see if we need to narrate any --If any ethereal descriptor are marked as something we want to narrate, include them here end end end end end end end return keybinds end function ZO_KeybindStrip:UpdateAnchorsInternal(anchorTable, parent, initialConstrainXAnchor, initialConstrainYAnchor, subsequentAnchor) else end end local prevButton local UPDATE_ONLY = true end if prevButton then else end end end end -- collect button alignments local buttonsByAlignment = { [KEYBIND_STRIP_ALIGN_LEFT] = {}, [KEYBIND_STRIP_ALIGN_CENTER] = {}, [KEYBIND_STRIP_ALIGN_RIGHT] = {}, } local alignment = GetValueFromRawOrFunction(button.keybindButtonDescriptor, "alignment") or KEYBIND_STRIP_ALIGN_RIGHT end -- layout the KEYBIND_STRIP_ALIGN_LEFT buttons local leftAnchorRelativeToControl = hasCustomStyle and self.styleInfo.leftAnchorRelativeToControl or nil local leftInitialConstrainXAnchor = ZO_Anchor:New(LEFT, leftAnchorRelativeToControl, leftAnchorRelativePoint, leftAnchorOffsetX, 0, ANCHOR_CONSTRAINS_X) self:UpdateAnchorsInternal(buttonsByAlignment[KEYBIND_STRIP_ALIGN_LEFT], self.control, leftInitialConstrainXAnchor, leftInitialConstrainYAnchor, leftSubsequentAnchor) -- layout the KEYBIND_STRIP_ALIGN_RIGHT buttons local rightAnchorRelativeToControl = hasCustomStyle and self.styleInfo.rightAnchorRelativeToControl or nil local rightAnchorRelativePoint = hasCustomStyle and self.styleInfo.rightAnchorRelativePoint or RIGHT local rightInitialConstrainXAnchor = ZO_Anchor:New(RIGHT, rightAnchorRelativeToControl, rightAnchorRelativePoint, rightAnchorOffsetX, 0, ANCHOR_CONSTRAINS_X) self:UpdateAnchorsInternal(buttonsByAlignment[KEYBIND_STRIP_ALIGN_RIGHT], self.control, rightInitialConstrainXAnchor, rightInitialConstrainYAnchor, rightSubsequentAnchor) -- layout the KEYBIND_STRIP_ALIGN_CENTER buttons local centerInitialConstrainXAnchor = ZO_Anchor:New(LEFT, nil, LEFT, centerAnchorOffsetX, 0, ANCHOR_CONSTRAINS_X) self:UpdateAnchorsInternal(buttonsByAlignment[KEYBIND_STRIP_ALIGN_CENTER], self.centerParent, centerInitialConstrainXAnchor, centerInitialConstrainYAnchor, centerSubsequentAnchor) -- Clear alignment bumping, then determine if the center section needs to bump. local leftGroupLeftEdge, leftGroupRightEdge = self:GetButtonsLeftAndRight(buttonsByAlignment[KEYBIND_STRIP_ALIGN_LEFT]) local centerGroupLeftEdge, centerGroupRightEdge = self:GetButtonsLeftAndRight(buttonsByAlignment[KEYBIND_STRIP_ALIGN_CENTER]) local rightGroupLeftEdge, rightGroupRightEdge = self:GetButtonsLeftAndRight(buttonsByAlignment[KEYBIND_STRIP_ALIGN_RIGHT]) local centerOffsetFix = self:CalculateCenterButtonsOffset(leftGroupLeftEdge, leftGroupRightEdge, centerGroupLeftEdge, centerGroupRightEdge, rightGroupLeftEdge, rightGroupRightEdge) end -- Determine if the center buttons group is overlapping with either side and offset it to avoid overlap. function ZO_KeybindStrip:CalculateCenterButtonsOffset(leftGroupLeftEdge, leftGroupRightEdge, centerGroupLeftEdge, centerGroupRightEdge, rightGroupLeftEdge, rightGroupRightEdge) if centerGroupRightEdge ~= nil then -- As calculated, if either value is > 0, that pair of strips are overlapping. local rightSideOverlap = rightGroupLeftEdge ~= nil and centerGroupRightEdge - rightGroupLeftEdge or nil local leftSideOverlap = leftGroupRightEdge ~= nil and leftGroupRightEdge - centerGroupLeftEdge or nil if rightSideOverlap ~= nil and rightSideOverlap > 0 then -- If the right side is overlapping and there's space on the left to accomodate it if leftSideOverlap == nil or leftSideOverlap < -rightSideOverlap then return -rightSideOverlap end elseif leftSideOverlap ~= nil and leftSideOverlap > 0 then -- If the left side is overlapping and there's space on the right to accomodate it if rightSideOverlap == nil or rightSideOverlap < -leftSideOverlap then return leftSideOverlap end end end return 0 end -- Determine the bounding edges of a keybinding button list (left/right/center) by accumulating button edges. -- Initialize to ridiculous defaults. end end else -- Either there were no items in the list, no visible items, or button positions are messed up. return nil, nil end endend |