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 |
KEYBIND_STRIP_ALIGN_LEFT = 1
KEYBIND_STRIP_ALIGN_CENTER = 2
KEYBIND_STRIP_ALIGN_RIGHT = 3
return keybindStrip
end
local DOWN = false
local UP = true
end
if keybindButtonDescriptor . handlesKeyUp or keybindButtonDescriptor . keybindButtonGroupDescriptor and keybindButtonDescriptor . keybindButtonGroupDescriptor . handlesKeyUp then
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
end
-- Keybind State Stack Management
end
end
end
local state =
{
keybindGroups = { } ,
}
end
end
if ( numStates > 0 ) then
self : SetDrawOrder ( state . drawTier , state . drawLayer , state . drawLevel , state . mungeBackgroundTier , state . gamepadBackgroundTier )
end
end
end
end
function ZO_KeybindStrip : SetDrawOrder ( tier , layer , level , mungeBackgroundTier , gamepadBackgroundTier )
if tier then
end
if layer then
end
if level then
end
if mungeBackgroundTier then
end
if gamepadBackgroundTier then
end
end
--[[
An example keybind button descriptor
local 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",
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
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.
}
]] --
-- Asserting here usually means that a key is already bound (typically because someone forgot to remove a keybinding).
if keybindButtonDescriptor . ethereal then
else
-- clear this out in case it was previously in a group
keybindButtonDescriptor . keybindButtonGroupDescriptor = nil
end
end
end
end
return ( first == nil ) or ( second == nil ) or
( ( first . keybind == second . keybind ) and
end
if buttonOrEtherealDescriptor and CompareKeybindButtonDescriptor ( buttonOrEtherealDescriptor . keybindButtonDescriptor , keybindButtonDescriptor ) then
end
end
end
end
if buttonOrEtherealDescriptor then
if buttonOrEtherealDescriptor . keybindButtonDescriptor == keybindButtonDescriptor then
end
else
end
else
if keybindButtonDescriptor ~= buttonOrEtherealDescriptor then
end
end
end
end
end
--[[
An example keybind button group descriptor
local 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
},
}
]] --
keybindButtonDescriptor . keybindButtonGroupDescriptor = keybindButtonGroupDescriptor
end
end
return true
end
return false
end
keybindButtonDescriptor . keybindButtonGroupDescriptor = nil
end
return true
end
return false
end
end
end
end
return true
end
return false
end
end
return buttonOrEtherealDescriptor . keybindButtonDescriptor
end
return buttonOrEtherealDescriptor
end
if keybindButtonDescriptor [ key ] == nil then
value = keybindButtonDescriptor . keybindButtonGroupDescriptor and keybindButtonDescriptor . keybindButtonGroupDescriptor [ key ]
else
end
end
end
if buttonOrEtherealDescriptor and ( not buttonOrEtherealDescriptor . IsControlHidden or not buttonOrEtherealDescriptor : IsControlHidden ( ) ) then
keybindButtonDescriptor . handledDown = true
end
if keybindButtonDescriptor . sound then
end
return true
end
end
end
return false
end
if buttonOrEtherealDescriptor and ( not buttonOrEtherealDescriptor . IsControlHidden or not buttonOrEtherealDescriptor : IsControlHidden ( ) ) then
local handledPreviousDown = keybindButtonDescriptor . handledDown
keybindButtonDescriptor . handledDown = nil
if keybindButtonDescriptor . handlesKeyUp or keybindButtonDescriptor . keybindButtonGroupDescriptor and keybindButtonDescriptor . keybindButtonGroupDescriptor . handlesKeyUp then
end
return true
end
end
end
end
return false
end
end
--[[
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",
resizeToFitPadding = 40,
leftAnchorOffset = 0,
centerAnchorOffset = 0,
rightAnchorOffset = 0,
}
]]
end
end
end
end
end
end
end
-- implementation functions below
local anchorTable = self : GetAnchorTableFromAlignment ( keybindButtonDescriptor . alignment or keybindButtonDescriptor . keybindButtonGroupDescriptor and keybindButtonDescriptor . keybindButtonGroupDescriptor . alignment )
for i = 1 , # anchorTable do
break
end
end
end
local anchorTable = self : GetAnchorTableFromAlignment ( keybindButtonDescriptor . alignment or keybindButtonDescriptor . keybindButtonGroupDescriptor and keybindButtonDescriptor . keybindButtonGroupDescriptor . alignment )
end
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 nil
end
if alignment == KEYBIND_STRIP_ALIGN_LEFT then
end
if alignment == KEYBIND_STRIP_ALIGN_CENTER then
end
end
do
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 isVisible then
if customKeybindControl then
else
end
local keybind = keybindButtonDescriptor . keybind or keybindButtonDescriptor . keybindButtonGroupDescriptor and keybindButtonGroupDescriptor . keybindButtonGroupDescriptor . keybind
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_LEFT_STICK = 5 ,
UI_SHORTCUT_RIGHT_STICK = 6 ,
UI_SHORTCUT_LEFT_TRIGGER = 7 ,
UI_SHORTCUT_RIGHT_TRIGGER = 8 ,
DIALOG_PRIMARY = 1 ,
DIALOG_NEGATIVE = 2 ,
DIALOG_SECONDARY = 3 ,
DIALOG_TERTIARY = 4 ,
}
local leftKeybindDescriptor = buttonLeft . keybindButtonDescriptor
local rightKeybindDescriptor = buttonRight . keybindButtonDescriptor
local leftOrder = GetValueFromRawOrFunction ( leftKeybindDescriptor , "gamepadOrder" ) or GAMEPAD_BUTTON_ORDER [ GetValueFromRawOrFunction ( leftKeybindDescriptor , "keybind" ) ] or GetValueFromRawOrFunction ( leftKeybindDescriptor , "order" ) or 0
local rightOrder = GetValueFromRawOrFunction ( rightKeybindDescriptor , "gamepadOrder" ) or GAMEPAD_BUTTON_ORDER [ GetValueFromRawOrFunction ( rightKeybindDescriptor , "keybind" ) ] or GetValueFromRawOrFunction ( rightKeybindDescriptor , "order" ) or 0
if leftOrder == rightOrder then
return buttonLeft . insertionOrder < buttonRight . insertionOrder
end
return leftOrder < rightOrder
end
if anchorTable and # anchorTable > 0 then
else
end
end
local prevButton
if isVisible then
if prevButton then
else
end
end
end
return anchorTable
end
return nil
end
self . leftButtons = UpdateAnchors ( self . leftButtons , LEFT , RIGHT , self . control , self . styleInfo and self . styleInfo . leftAnchorOffset or 0 , yOffset )
self . rightButtons = UpdateAnchors ( self . rightButtons , RIGHT , LEFT , self . control , self . styleInfo and self . styleInfo . rightAnchorOffset or 0 , yOffset )
self . centerButtons = UpdateAnchors ( self . centerButtons , LEFT , RIGHT , self . centerParent , self . styleInfo and self . styleInfo . centerAnchorOffset or 0 , yOffset )
end
end |