From 1631339eabfd166253f34325904262e33e8727b4 Mon Sep 17 00:00:00 2001 From: Thrumbar Date: Sun, 3 May 2026 19:18:09 -0500 Subject: [PATCH 1/2] GSE Compatibility Update for button override from GSE so it would work with Dominoes. Sorta unasked but neverless here it is... --- Dominos/CHANGELOG.md | 210 ++ Dominos/Dominos.toc | 1 + Dominos/LICENSE | 26 + Dominos/README.md | 54 + Dominos/bars/actionBar/bindings.lua | 259 ++- Dominos/bars/actionBar/button.lua | 195 +- Dominos/bars/actionBar/buttons.lua | 296 ++- Dominos/core/bindableButton.lua | 56 +- Dominos/core/bindingCompat.lua | 288 +++ Dominos/libs/AceAddon-3.0/AceAddon-3.0.lua | 649 ++++++ Dominos/libs/AceAddon-3.0/AceAddon-3.0.xml | 4 + .../libs/AceConsole-3.0/AceConsole-3.0.lua | 246 ++ .../libs/AceConsole-3.0/AceConsole-3.0.xml | 4 + Dominos/libs/AceDB-3.0/AceDB-3.0.lua | 797 +++++++ Dominos/libs/AceDB-3.0/AceDB-3.0.xml | 4 + Dominos/libs/AceEvent-3.0/AceEvent-3.0.lua | 126 + Dominos/libs/AceEvent-3.0/AceEvent-3.0.xml | 4 + Dominos/libs/AceLocale-3.0/AceLocale-3.0.lua | 133 ++ Dominos/libs/AceLocale-3.0/AceLocale-3.0.xml | 4 + .../CallbackHandler-1.0.lua | 202 ++ .../CallbackHandler-1.0.xml | 4 + Dominos/libs/LibDBIcon-1.0/LibDBIcon-1.0.lua | 713 ++++++ Dominos/libs/LibDBIcon-1.0/lib.xml | 7 + .../LibDataBroker-1.1/LibDataBroker-1.1.lua | 90 + Dominos/libs/LibDataBroker-1.1/README.textile | 13 + .../libs/LibDualSpec-1.0/LibDualSpec-1.0.lua | 517 +++++ .../libs/LibDualSpec-1.0/LibDualSpec-1.0.toc | 11 + Dominos/libs/LibDualSpec-1.0/LibStub.lua | 30 + .../libs/LibFlyPaper-2.0/LibFlyPaper-2.0.lua | 717 ++++++ Dominos/libs/LibFlyPaper-2.0/README.md | 100 + .../libs/LibKeyBound-1.0/LibKeyBound-1.0.lua | 682 ++++++ Dominos/libs/LibKeyBound-1.0/Locale-deDE.lua | 92 + Dominos/libs/LibKeyBound-1.0/Locale-enUS.lua | 158 ++ Dominos/libs/LibKeyBound-1.0/Locale-esES.lua | 87 + Dominos/libs/LibKeyBound-1.0/Locale-esMX.lua | 87 + Dominos/libs/LibKeyBound-1.0/Locale-frFR.lua | 87 + Dominos/libs/LibKeyBound-1.0/Locale-koKR.lua | 87 + Dominos/libs/LibKeyBound-1.0/Locale-ruRU.lua | 87 + Dominos/libs/LibKeyBound-1.0/Locale-zhCN.lua | 88 + Dominos/libs/LibKeyBound-1.0/Locale-zhTW.lua | 88 + Dominos/libs/LibKeyBound-1.0/lib.xml | 13 + .../LibSharedMedia-3.0/LibSharedMedia-3.0.lua | 324 +++ Dominos/libs/LibSharedMedia-3.0/lib.xml | 4 + Dominos/libs/LibStub/LibStub.lua | 30 + Dominos/libs/LibStub/LibStub.toc | 9 + .../libs/AceConfig-3.0/AceConfig-3.0.lua | 58 + .../libs/AceConfig-3.0/AceConfig-3.0.xml | 8 + .../AceConfigCmd-3.0/AceConfigCmd-3.0.lua | 787 +++++++ .../AceConfigCmd-3.0/AceConfigCmd-3.0.xml | 4 + .../AceConfigDialog-3.0.lua | 2045 +++++++++++++++++ .../AceConfigDialog-3.0.xml | 4 + .../AceConfigRegistry-3.0.lua | 373 +++ .../AceConfigRegistry-3.0.xml | 4 + .../AceDBOptions-3.0/AceDBOptions-3.0.lua | 456 ++++ .../AceDBOptions-3.0/AceDBOptions-3.0.xml | 4 + Dominos_Config/libs/AceGUI-3.0/AceGUI-3.0.lua | 1020 ++++++++ Dominos_Config/libs/AceGUI-3.0/AceGUI-3.0.xml | 28 + .../AceGUIContainer-BlizOptionsGroup.lua | 143 ++ .../widgets/AceGUIContainer-DropDownGroup.lua | 157 ++ .../widgets/AceGUIContainer-Frame.lua | 318 +++ .../widgets/AceGUIContainer-InlineGroup.lua | 103 + .../widgets/AceGUIContainer-ScrollFrame.lua | 215 ++ .../widgets/AceGUIContainer-SimpleGroup.lua | 69 + .../widgets/AceGUIContainer-TabGroup.lua | 535 +++++ .../widgets/AceGUIContainer-TreeGroup.lua | 719 ++++++ .../widgets/AceGUIContainer-Window.lua | 336 +++ .../widgets/AceGUIWidget-Button.lua | 103 + .../widgets/AceGUIWidget-CheckBox.lua | 292 +++ .../widgets/AceGUIWidget-ColorPicker.lua | 230 ++ .../widgets/AceGUIWidget-DropDown-Items.lua | 471 ++++ .../widgets/AceGUIWidget-DropDown.lua | 732 ++++++ .../widgets/AceGUIWidget-EditBox.lua | 267 +++ .../widgets/AceGUIWidget-Heading.lua | 78 + .../AceGUI-3.0/widgets/AceGUIWidget-Icon.lua | 140 ++ .../widgets/AceGUIWidget-InteractiveLabel.lua | 94 + .../widgets/AceGUIWidget-Keybinding.lua | 251 ++ .../AceGUI-3.0/widgets/AceGUIWidget-Label.lua | 179 ++ .../widgets/AceGUIWidget-MultiLineEditBox.lua | 377 +++ .../widgets/AceGUIWidget-Slider.lua | 281 +++ 79 files changed, 18457 insertions(+), 107 deletions(-) create mode 100644 Dominos/CHANGELOG.md create mode 100644 Dominos/LICENSE create mode 100644 Dominos/README.md create mode 100644 Dominos/core/bindingCompat.lua create mode 100644 Dominos/libs/AceAddon-3.0/AceAddon-3.0.lua create mode 100644 Dominos/libs/AceAddon-3.0/AceAddon-3.0.xml create mode 100644 Dominos/libs/AceConsole-3.0/AceConsole-3.0.lua create mode 100644 Dominos/libs/AceConsole-3.0/AceConsole-3.0.xml create mode 100644 Dominos/libs/AceDB-3.0/AceDB-3.0.lua create mode 100644 Dominos/libs/AceDB-3.0/AceDB-3.0.xml create mode 100644 Dominos/libs/AceEvent-3.0/AceEvent-3.0.lua create mode 100644 Dominos/libs/AceEvent-3.0/AceEvent-3.0.xml create mode 100644 Dominos/libs/AceLocale-3.0/AceLocale-3.0.lua create mode 100644 Dominos/libs/AceLocale-3.0/AceLocale-3.0.xml create mode 100644 Dominos/libs/CallbackHandler-1.0/CallbackHandler-1.0.lua create mode 100644 Dominos/libs/CallbackHandler-1.0/CallbackHandler-1.0.xml create mode 100644 Dominos/libs/LibDBIcon-1.0/LibDBIcon-1.0.lua create mode 100644 Dominos/libs/LibDBIcon-1.0/lib.xml create mode 100644 Dominos/libs/LibDataBroker-1.1/LibDataBroker-1.1.lua create mode 100644 Dominos/libs/LibDataBroker-1.1/README.textile create mode 100644 Dominos/libs/LibDualSpec-1.0/LibDualSpec-1.0.lua create mode 100644 Dominos/libs/LibDualSpec-1.0/LibDualSpec-1.0.toc create mode 100644 Dominos/libs/LibDualSpec-1.0/LibStub.lua create mode 100644 Dominos/libs/LibFlyPaper-2.0/LibFlyPaper-2.0.lua create mode 100644 Dominos/libs/LibFlyPaper-2.0/README.md create mode 100644 Dominos/libs/LibKeyBound-1.0/LibKeyBound-1.0.lua create mode 100644 Dominos/libs/LibKeyBound-1.0/Locale-deDE.lua create mode 100644 Dominos/libs/LibKeyBound-1.0/Locale-enUS.lua create mode 100644 Dominos/libs/LibKeyBound-1.0/Locale-esES.lua create mode 100644 Dominos/libs/LibKeyBound-1.0/Locale-esMX.lua create mode 100644 Dominos/libs/LibKeyBound-1.0/Locale-frFR.lua create mode 100644 Dominos/libs/LibKeyBound-1.0/Locale-koKR.lua create mode 100644 Dominos/libs/LibKeyBound-1.0/Locale-ruRU.lua create mode 100644 Dominos/libs/LibKeyBound-1.0/Locale-zhCN.lua create mode 100644 Dominos/libs/LibKeyBound-1.0/Locale-zhTW.lua create mode 100644 Dominos/libs/LibKeyBound-1.0/lib.xml create mode 100644 Dominos/libs/LibSharedMedia-3.0/LibSharedMedia-3.0.lua create mode 100644 Dominos/libs/LibSharedMedia-3.0/lib.xml create mode 100644 Dominos/libs/LibStub/LibStub.lua create mode 100644 Dominos/libs/LibStub/LibStub.toc create mode 100644 Dominos_Config/libs/AceConfig-3.0/AceConfig-3.0.lua create mode 100644 Dominos_Config/libs/AceConfig-3.0/AceConfig-3.0.xml create mode 100644 Dominos_Config/libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.lua create mode 100644 Dominos_Config/libs/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.xml create mode 100644 Dominos_Config/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua create mode 100644 Dominos_Config/libs/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.xml create mode 100644 Dominos_Config/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.lua create mode 100644 Dominos_Config/libs/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.xml create mode 100644 Dominos_Config/libs/AceDBOptions-3.0/AceDBOptions-3.0.lua create mode 100644 Dominos_Config/libs/AceDBOptions-3.0/AceDBOptions-3.0.xml create mode 100644 Dominos_Config/libs/AceGUI-3.0/AceGUI-3.0.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/AceGUI-3.0.xml create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIContainer-DropDownGroup.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIContainer-Frame.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIContainer-InlineGroup.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIContainer-ScrollFrame.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIContainer-SimpleGroup.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIContainer-TabGroup.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIContainer-TreeGroup.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIContainer-Window.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIWidget-Button.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown-Items.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIWidget-DropDown.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIWidget-Label.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIWidget-MultiLineEditBox.lua create mode 100644 Dominos_Config/libs/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua diff --git a/Dominos/CHANGELOG.md b/Dominos/CHANGELOG.md new file mode 100644 index 00000000..38772dd6 --- /dev/null +++ b/Dominos/CHANGELOG.md @@ -0,0 +1,210 @@ +# Dominos Changelog + +## Unreleased - Phase 2: Blizzard-compatible action button frame contract rebase + +* Rebased the Phase 2 action-button frame contract work onto the updated `Dominos-master` base without downgrading the newer 11.3.0-beta1 TOC metadata or Mists loading directives. +* Added `core/bindingCompat.lua` as the centralized binding identity layer for native Blizzard binding commands, Dominos fallback CLICK bindings, and stable action-button binding IDs. +* Updated action-button setup to expose stable binding fields and attributes such as `commandName`, `bindingAction`, `bindingID`, `dominosButtonID`, `nativeCommandName`, and `fallbackCommandName` without deriving stable identity from paged action slots. +* Updated hotkey and quick-binding lookup paths to consume the shared BindingCompat contract while preserving existing Dominos fallback bindings for saved user configurations. +* Hardened action button override-binding refresh paths to tolerate missing or nil binding keys and avoid unsafe binding mutation. +* Refactored override binding handling for Blizzard default override states, vehicle/possess-style action states, pet battle states, native `ACTIONBUTTON1`-`ACTIONBUTTON6` keys, and Dominos fallback CLICK bindings. +* Improved support for external secure action-button overrides by detecting `type`, `clickbutton`, and `gse-button` style override attributes on action buttons. +* Preserved the safe restricted-environment correction: Dominos does not alias `ActionButton1`-`ActionButton12` to Dominos-created frames and does not write Dominos buttons into Blizzard restricted `MainActionBar.actionButtons` tables. +* Added a safe bridge for external addons that attach overrides to Blizzard `ActionButton1`-`ActionButton12`, mirroring supported external override attributes onto the matching visible Dominos action buttons without corrupting Blizzard restricted action-bar controller state. +* Preserved slot-driven secure action behavior; Dominos remains a Blizzard-compatible action-slot orchestrator and does not implement custom spell, item, macro, or GSE casting logic. +* Kept Phase 2 changes Lua 5.1 compatible and guarded against combat-taint-prone protected attribute updates where possible. + +## 11.3.0-beta1 + +* Note: This version won't work on 5.5.3 (hence the beta designation) +* Update TOCs for the 12.0.7 and 5.5.4 PTRs + +## 11.2.21 + +* Update TOCs for 12.0.5 + +## 11.2.20 + +* (Retail) Fixed an issue causing the cast bar to not disappear when canceling a channeled spell. + +## 11.2.19 + +* (Retail) Fixed the reputation bar for major factions (Thanks [fediazgon](https://github.com/fediazgon)) + +## 11.2.18 + +* (Retail) Fix more secret errors with the cast bar by using castBarID when available. + +## 11.2.17 + +* Keyboard nudging now checks your Strafe Left/Right keybindings in addition to Turn Left/Right. (Handles the Modern/Legacy control options in 12.x) +* (TBC) Added latency information to the minimap icon, like in Vanilla (Thanks [PortalPi ](https://github.com/PortalPi)) + +## 11.2.16 + +* (Retail) Better handle secret icons on the cast bar. + +## 11.2.15 + +* (TBC) Fixed the talent button not appearing on the menu bar + +## 11.2.14 + +* (Retail) Fixed an menu bar error when entering/exiting pet battles + +## 11.2.13 + +* Fixed an issue with unregistering the Blizzard stance bar that was causing errors + +## 11.2.12 + +* Added support for Burning Crusade Classic Anniversary Edition +* Added in missing menu bar button names + +## 11.2.11 + +* Refactored the progress bar to use a data provider interface instead of metatable manipulation (which broke with the last Midnight fix) + +## 11.2.10 + +* Added a workaround Dominos frame class inheritance to fix the Invalid 'self' frame handle errors in the latest Midnight build (Thanks, [Tyler Fleckenstein](https://github.com/tpfleck)) + +## 11.2.9 + +* (Midnight) Added a workaround for GetUnitEmpowerHoldAtMaxTime returning + secret values to prevent error messages when casting empowered spells. + Hopefully Blizzard will drop this restriction. + +## 11.2.8 + +* (Classic) Fixed the missing Monk class bar + +## 11.2.7 + +* (Retail, Midnight) Reuse the existing pet bar action buttons and logic. This should make the bar usable in Midnight +* (Classic) Use a custom impelemntation for the class bar. This shold resolve issues with positioning of the bar when playing certain classes +* (Midnight) Partially reimplemented the logic for hiding action button cooldowns on transparent bars. + +## 11.2.6 + +* (Midnight) Enabled the cast bar after resolving some secret value comparison errors + +## 11.2.5 + +* Fixed an issue that would prevent bindings from working when in Edit House mode + +## 11.2.4 + +* Updated TOC files for game versions 5.5.3 and 1.15.8 +* Dropped the specific TOC file for Vanilla as 1.15.8 supports conditional directives +* The artifactBar and azeriteBar lua files should now not load at all on Classic + +## 11.2.3 + +* Updated TOC files for 12.0.0 (Midnight) and 11.2.7 +* Fixed an error caused byt the progress bar trying to call a missing API when attempting to show azerite information. +* (Midnight) Disabled the cast bar and pet bar +* (Midnight) Disabled the ability to open flyouts via keypress + +## 11.2.2 + +* Changed the default paging settings for Warriors in Mists to use Action Bar 1 for battle stance, instead of Action Bar 7 +* Fixed an issue with the progress bars that could cause an Addon Action Blocked message to occur when leveling up in combat +* Reintroduced a workaround for a Blizzard error that could occur when hiding the achievement button in classic version +* Updated TOCs for 11.2.5 and 5.5.1 + +## 11.2.1 + +* Fixed the addon compartment menu icon not showing the options menu when clicked + +## 11.2.0 + +* Excluded the new combat assistant highlights from spell animation filtering + +## 11.1.9 + +* Fixed menu bar errors +* Corrected pkgmeta file so that you'll actually see the right changelog and not just my commit messages + +## 11.1.8 + +* Added support for 11.2.0 +* Updated TOCs to use conditional file loading directives +* Rewrote the bar states configuration formats to handle multiple game versions a bit better +* Updated the menu bar button ordering to hopefully prevent issues when switching to vehicle/pet battle UIs + +## 11.1.7 + +* Added support for Monk stances in MoP Classic + +## 11.1.6 + +* Fixed multiple paging issues with Mists of Pandaria Classic + +## 11.1.5 + +* Updated TOCs for 11.1.7 and 5.5.0 (Mists of Pandaria Classic) +* Refreshed libraries to fix a lua error in MoP Classic + +## 11.1.4 + +* Updated TOCs for 11.1.5 + +## 11.1.3 + +* Updated TOCs for 1.15.7 + +## 11.1.2 + +* Context menu dropdowns now use the standard dropdown menu templates + +## 11.1.1 + +* Fixed renown level text showing %d + +## 11.1.0 + +* Adjusted KeyRingButton test to hopefully avoid some errors + +## 11.0.9 + +* Updated TOCs for 11.1.0, 4.4.2 and 1.15.6 +* (Classic) Added experimental support for the extra ability bar + +## 11.0.8 + +* Updated TOCs for 1.15.5 + +## 11.0.7 + +* (Classic) Fixed tooltip issues when enabling all Blizzard action bars + +## 11.0.6 + +* Updated TOCs for 11.0.7 and 11.0.5 + +## 11.0.5 + +* (Vanilla) Fixed tooltip issues when enabling all Blizzard action bars + +## 11.0.4 + +* Added a new slider for row spacing (contributed by [Xiaoyang-Huang](https://github.com/Xiaoyang-Huang)) +* Added a Hide at Max Level option to the display menu of progress bars + +## 11.0.3 + +* Added support for classic versions 4.4.1 and 1.15.4 + +## 11.0.2 + +* Updated Override UI detection + +## 11.0.1 + +* Fixed an issue that would let spell overlay glows still display, even if disabled + +## 11.0.0 + +* (Classic) Ensured the Encounter Bar always is given a size to prevent issues with repositioning frames +* Dropped WoW 10.x from TOC files diff --git a/Dominos/Dominos.toc b/Dominos/Dominos.toc index 0ac44c02..19319b7f 100644 --- a/Dominos/Dominos.toc +++ b/Dominos/Dominos.toc @@ -19,6 +19,7 @@ core\barStates\[Game].lua core\shadowUIParent.lua core\frame.lua core\buttonBar.lua +core\bindingCompat.lua core\bindableButton.lua core\fadeManager.lua core\overrideController.lua [AllowLoadGameType mainline, mists, cata, wrath, tbc] diff --git a/Dominos/LICENSE b/Dominos/LICENSE new file mode 100644 index 00000000..396bd500 --- /dev/null +++ b/Dominos/LICENSE @@ -0,0 +1,26 @@ +Copyright (c) 2008-2021 Jason Greer +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of its contributors may + be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FORANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/Dominos/README.md b/Dominos/README.md new file mode 100644 index 00000000..609c559c --- /dev/null +++ b/Dominos/README.md @@ -0,0 +1,54 @@ +# Dominos + +Dominos is an addon that replaces your main bar with movable parts that offer +additional customization. Dominos is used primarily for its action bars, +which feature: + +* Customizable layout settings (spacing, vertical bars, opacity, scale, etc) +* Customizable action bar paging (so that you can change what your bars do when shapeshifted, etc) +* Customizable visiblity (so that you can make bars transparent, or show up only when in combat, etc) +* [Masque](https://www.curseforge.com/wow/addons/masque) support for button styling, +with individual settings per bar +* [LibKeyBound](https://www.wowace.com/projects/libkeybound-1-0) is implemented for quickly binding keys +* Any other addon that works on Blizzard UI for action buttons should also work with Dominos, too. +This includes things like [tullaRange](https://www.curseforge.com/wow/addons/tullarange), [AdiButtonAuras](https://www.curseforge.com/wow/addons/adibuttonauras), and [OmniCC](https://www.curseforge.com/wow/addons/omni-cc) + +## Usage + +### General Settings + +The main options menu in Dominos can be found by either right clicking the +minimap icon or via the `/dominos` slashcommand. On the main options menu, +you will find sections for configuring shared bar settings and profiles. + +### Moving Stuff Around + +To move around or hide bars, you will want to enter **configuration mode**. You +can do this by either one of the following ways + +* Left clicking the minimap button +* Clicking **Configure Bars...** from the main options menu (accessible from /dominos) +* Using the slash command /dominos config +* Once in configuration mode, you can drag around bars using your mouse + +### Customizing Individual Bars + +Most per bar settings can be found in context menus. To access these settings, +*right click* or alt left click the bar in configuration mode. + +### Binding Keys + +Dominos implements support for [LibKeyBound](https://www.wowace.com/projects/libkeybound-1-0) +for quickly binding keys. Quick Binding mode can be entered by either the standard keybound shortcut (/kb) +or by clicking the Bind Keys... button in the main options menu. + +### Slash Commands + +Dominos provides a large set of slash commands for usage in macros and bulk +adjustments. [The complete set of slash commands can be found on the wiki](https://github.com/tullamods/Dominos/wiki/Slash-Commands) + +## Contributing + +[Source code for the addon can be found on GitHub](https://github.com/tullamods/Dominos). +Contributions are welcome (though I can be picky 😊). + diff --git a/Dominos/bars/actionBar/bindings.lua b/Dominos/bars/actionBar/bindings.lua index 8c6f4725..1cea8aef 100644 --- a/Dominos/bars/actionBar/bindings.lua +++ b/Dominos/bars/actionBar/bindings.lua @@ -1,11 +1,11 @@ -------------------------------------------------------------------------------- --- Sets priority bindings to the Pet Battle and Override UI when either frame --- is visible +-- Secure binding bridge for Blizzard override/pet-battle action routing. -- --- TODO: --- Load the override bindings from whatever bar we've configured as the Dominos --- override bar. Ensure that the bindings displayed for those frames are sourced --- from those +-- Default action bars route ACTIONBUTTON1-6 through Blizzard's secure action +-- button functions when the Override UI or Pet Battle UI is active. Dominos +-- also has a configurable override bar, so the bridge must preserve both: +-- 1. Blizzard's priority ACTIONBUTTON routing when the default UI owns it. +-- 2. Dominos' configured override-bar buttons when Dominos owns it. -------------------------------------------------------------------------------- local _, Addon = ... @@ -13,6 +13,116 @@ if not OverrideActionBar then return end local Binder = CreateFrame("Frame", nil, nil, "SecureHandlerAttributeTemplate") +local MAX_OVERRIDE_BINDINGS = NUM_OVERRIDE_BUTTONS or 6 +local MAX_BINDING_SOURCES = 6 +local SOURCE_ATTRIBUTE_TEMPLATE = "ACTIONBUTTON%d_SOURCE%d" +local ENABLED_ATTRIBUTE_TEMPLATE = "ACTIONBUTTON%d_ENABLED" +local BUTTON_REF_TEMPLATE = "overrideButton%d" + +Binder:SetAttribute("maxOverrideBindings", MAX_OVERRIDE_BINDINGS) + +local function GetBindingCompat() + return Addon.BindingCompat +end + +local function GetOverrideButton(index) + if not Addon.GetOverrideBar then + return nil + end + + local bar = Addon:GetOverrideBar() + if bar and bar.buttons then + return bar.buttons[index] + end +end + +local function SetSourceAttribute(self, buttonIndex, sourceIndex, value) + self:SetAttribute(SOURCE_ATTRIBUTE_TEMPLATE:format(buttonIndex, sourceIndex), value) +end + +local function ClearOverrideButtonSources(self, buttonIndex) + for sourceIndex = 1, MAX_BINDING_SOURCES do + SetSourceAttribute(self, buttonIndex, sourceIndex, nil) + end +end + +local function SetOverrideButtonSources(self, buttonIndex, button) + ClearOverrideButtonSources(self, buttonIndex) + + if not button then + self:SetAttribute(ENABLED_ATTRIBUTE_TEMPLATE:format(buttonIndex), nil) + return + end + + local bindingCompat = GetBindingCompat() + if bindingCompat and bindingCompat.GetActionButtonCommands then + local commands = bindingCompat.GetActionButtonCommands(button:GetAttribute("bindingID"), button) + for sourceIndex = 1, math.min(#commands, MAX_BINDING_SOURCES) do + SetSourceAttribute(self, buttonIndex, sourceIndex, commands[sourceIndex]) + end + else + SetSourceAttribute(self, buttonIndex, 1, button:GetAttribute("commandName")) + end + + self:SetFrameRef(BUTTON_REF_TEMPLATE:format(buttonIndex), button) + self:SetAttribute(ENABLED_ATTRIBUTE_TEMPLATE:format(buttonIndex), 1) +end + +local function MarkBindingsDirty(self) + if InCombatLockdown() then + self.needsBindingRefresh = true + self:RegisterEvent("PLAYER_REGEN_ENABLED") + return + end + + self:SetAttribute("bindingUpdate", (self:GetAttribute("bindingUpdate") or 0) + 1) +end + +local function SetUseOverrideUI(self, enabled) + if InCombatLockdown() then + self.pendingUseOverrideUI = enabled and true or false + self:RegisterEvent("PLAYER_REGEN_ENABLED") + return + end + + self:SetAttribute("useoverrideui", enabled and 1 or 0) +end + +function Binder:UpdateOverrideBindingSources() + if InCombatLockdown() then + self.needsOverrideBindingSourceUpdate = true + self:RegisterEvent("PLAYER_REGEN_ENABLED") + return + end + + for buttonIndex = 1, MAX_OVERRIDE_BINDINGS do + SetOverrideButtonSources(self, buttonIndex, GetOverrideButton(buttonIndex)) + end + + MarkBindingsDirty(self) +end + +function Binder:PLAYER_REGEN_ENABLED() + self:UnregisterEvent("PLAYER_REGEN_ENABLED") + + if self.pendingUseOverrideUI ~= nil then + self:SetAttribute("useoverrideui", self.pendingUseOverrideUI and 1 or 0) + self.pendingUseOverrideUI = nil + end + + if self.needsOverrideBindingSourceUpdate then + self.needsOverrideBindingSourceUpdate = nil + self:UpdateOverrideBindingSources() + elseif self.needsBindingRefresh then + self.needsBindingRefresh = nil + MarkBindingsDirty(self) + end +end + +function Binder:UPDATE_BINDINGS() + MarkBindingsDirty(self) +end + Binder:WrapScript(OverrideActionBarButton1, "OnShow", [[ control:SetAttribute("overrideui", 1) ]]) @@ -21,54 +131,133 @@ Binder:WrapScript(OverrideActionBarButton1, "OnHide", [[ control:SetAttribute("overrideui", 0) ]]) -Binder:SetAttributeNoHandler("_onattributechanged", [[ - if name == "bind" then return end - - local bind = ( - (self:GetAttribute("overrideui") == 1 and self:GetAttribute("useoverrideui") == 1) - or self:GetAttribute("petbattleui") == 1 - ) - - if self:GetAttribute("bind") ~= bind then - self:SetAttribute("bind", bind) - self:ClearBindings() - - if bind then - for i = 1, 6 do - local command = "ACTIONBUTTON" .. i - local keyCommand = self:GetAttribute(command) or command - self:RunAttribute("SetBindings", command, GetBindingKey(keyCommand)) +Binder:SetAttributeNoHandler("SetCommandBindings", [[ + local targetCommand = ... + + for sourceIndex = 2, select("#", ...) do + local sourceCommand = select(sourceIndex, ...) + if sourceCommand then + for keyIndex = 1, select("#", GetBindingKey(sourceCommand)) do + local key = select(keyIndex, GetBindingKey(sourceCommand)) + if key then + self:SetBinding(true, key, targetCommand) + end end end end ]]) -Binder:SetAttributeNoHandler("SetBindings", [[ - local command = ... - for i = 2, select("#", ...) do - self:SetBinding(true, select(i, ...), command) +Binder:SetAttributeNoHandler("SetClickBindings", [[ + local targetButton = ... + + for sourceIndex = 2, select("#", ...) do + local sourceCommand = select(sourceIndex, ...) + if sourceCommand then + for keyIndex = 1, select("#", GetBindingKey(sourceCommand)) do + local key = select(keyIndex, GetBindingKey(sourceCommand)) + if key then + self:SetBindingClick(true, key, targetButton, "LeftButton") + end + end + end end ]]) --- initialize state +Binder:SetAttributeNoHandler("UpdateBindings", [[ + local overrideUIValue = self:GetAttribute("overrideui") + local useOverrideUIValue = self:GetAttribute("useoverrideui") + local petBattleValue = self:GetAttribute("petbattleui") + local statePetBattleValue = self:GetAttribute("state-petbattleui") + local overridePage = tonumber(self:GetAttribute("state-overridepage")) or 0 + local maxOverrideBindings = tonumber(self:GetAttribute("maxOverrideBindings")) or 6 + + local overrideUIActive = overrideUIValue == 1 or overrideUIValue == "1" or overrideUIValue == true + local useOverrideUI = useOverrideUIValue == 1 or useOverrideUIValue == "1" or useOverrideUIValue == true + local petBattleActive = petBattleValue == 1 or petBattleValue == "1" or petBattleValue == true + or statePetBattleValue == 1 or statePetBattleValue == "1" or statePetBattleValue == true + local dominosOverrideActive = overridePage > 0 and not useOverrideUI and not petBattleActive + + self:ClearBindings() + + if (overrideUIActive and useOverrideUI) or petBattleActive then + for buttonIndex = 1, maxOverrideBindings do + local targetCommand = "ACTIONBUTTON" .. buttonIndex + self:RunAttribute( + "SetCommandBindings", + targetCommand, + targetCommand, + self:GetAttribute(targetCommand .. "_SOURCE1"), + self:GetAttribute(targetCommand .. "_SOURCE2"), + self:GetAttribute(targetCommand .. "_SOURCE3"), + self:GetAttribute(targetCommand .. "_SOURCE4"), + self:GetAttribute(targetCommand .. "_SOURCE5"), + self:GetAttribute(targetCommand .. "_SOURCE6") + ) + end + elseif dominosOverrideActive then + for buttonIndex = 1, maxOverrideBindings do + if self:GetAttribute("ACTIONBUTTON" .. buttonIndex .. "_ENABLED") == 1 then + local targetCommand = "ACTIONBUTTON" .. buttonIndex + local targetButton = self:GetFrameRef("overrideButton" .. buttonIndex) + if targetButton then + self:RunAttribute( + "SetClickBindings", + targetButton, + targetCommand, + self:GetAttribute(targetCommand .. "_SOURCE1"), + self:GetAttribute(targetCommand .. "_SOURCE2"), + self:GetAttribute(targetCommand .. "_SOURCE3"), + self:GetAttribute(targetCommand .. "_SOURCE4"), + self:GetAttribute(targetCommand .. "_SOURCE5"), + self:GetAttribute(targetCommand .. "_SOURCE6") + ) + end + end + end + end +]]) + +Binder:SetAttributeNoHandler("_onattributechanged", [[ + self:RunAttribute("UpdateBindings") +]]) + Binder:SetScript("OnEvent", function(self, event) - self:SetScript("OnEvent", nil) - self:UnregisterEvent(event) + if event == "PLAYER_LOGIN" then + self:UnregisterEvent(event) + + self:SetAttribute("overrideui", OverrideActionBarButton1:IsVisible() and 1 or 0) + SetUseOverrideUI(self, Addon:UsingOverrideUI()) + RegisterAttributeDriver(self, "petbattleui", "[petbattle]1;0") - self:SetAttribute("overrideui", OverrideActionBarButton1:IsVisible() and 1 or 0) - self:SetAttribute("useoverrideui", Addon:UsingOverrideUI() and 1 or 0) - RegisterAttributeDriver(self, "petbattleui", "[petbattle]1;0") + if Addon.OverrideController then + Addon.OverrideController:Add(self) + end + + self:RegisterEvent("UPDATE_BINDINGS") + self:UpdateOverrideBindingSources() + return + end + + if self[event] then + self[event](self) + end end) Binder:RegisterEvent("PLAYER_LOGIN") function Binder:USE_OVERRRIDE_UI_CHANGED(_, enabled) - self:SetAttribute("useoverrideui", enabled and 1 or 0) + SetUseOverrideUI(self, enabled) end function Binder:LAYOUT_LOADED() - self:SetAttribute("useoverrideui", Addon:UsingOverrideUI() and 1 or 0) + SetUseOverrideUI(self, Addon:UsingOverrideUI()) + self:UpdateOverrideBindingSources() +end + +function Binder:OVERRIDE_BAR_UPDATED() + self:UpdateOverrideBindingSources() end Addon.RegisterCallback(Binder, "USE_OVERRRIDE_UI_CHANGED") Addon.RegisterCallback(Binder, "LAYOUT_LOADED") +Addon.RegisterCallback(Binder, "OVERRIDE_BAR_UPDATED") diff --git a/Dominos/bars/actionBar/button.lua b/Dominos/bars/actionBar/button.lua index cedd6ce4..10509620 100644 --- a/Dominos/bars/actionBar/button.lua +++ b/Dominos/bars/actionBar/button.lua @@ -1,55 +1,121 @@ local _, Addon = ... local ActionButton = {} -local function GetActionButtonCommand(id) - -- 0 - if id <= 0 then - return - -- 1 - elseif id <= 12 then - return "ACTIONBUTTON" .. id - -- 2 - elseif id <= 24 then - return - -- 3 - elseif id <= 36 then - return "MULTIACTIONBAR3BUTTON" .. (id - 24) - -- 4 - elseif id <= 48 then - return "MULTIACTIONBAR4BUTTON" .. (id - 36) - -- 5 - elseif id <= 60 then - return "MULTIACTIONBAR2BUTTON" .. (id - 48) - -- 6 - elseif id <= 72 then - return "MULTIACTIONBAR1BUTTON" .. (id - 60) - -- 7-11 - elseif id <= 132 then +local function GetBindingCompat() + return Addon.BindingCompat +end + +local function GetActionTextureSafe(action) + if C_ActionBar and C_ActionBar.GetActionTexture then + return C_ActionBar.GetActionTexture(action) + end + + return GetActionTexture(action) +end + +local function GetActionButtonCommand(button) + local bindingCompat = GetBindingCompat() + if bindingCompat then + local command = bindingCompat.NormalizeCommandName(button:GetAttribute("commandName")) + if command then + return command + end + + return bindingCompat.GetActionButtonCommand(button:GetAttribute("bindingID"), button) + end + + local name = button:GetName() + if name then + return ("CLICK %s:HOTKEY"):format(name) + end +end + +local function ApplyActionButtonContract(button, id) + local bindingCompat = GetBindingCompat() + if bindingCompat and bindingCompat.ApplyActionButtonContract then + bindingCompat.ApplyActionButtonContract(button, id) return - -- 12 - elseif id <= 144 then - return "MULTIACTIONBAR5BUTTON" .. (id - 132) - -- 13 - elseif id <= 156 then - return "MULTIACTIONBAR6BUTTON" .. (id - 144) - -- 14 - elseif id <= 168 then - return "MULTIACTIONBAR7BUTTON" .. (id - 156) + end + + local name = button:GetName() + local command = name and ("CLICK %s:HOTKEY"):format(name) or nil + button.commandName = command + button.bindingAction = command + button.bindingID = id + button.dominosButtonID = id + + button:SetAttributeNoHandler("commandName", command) + button:SetAttributeNoHandler("bindingID", id) + button:SetAttributeNoHandler("dominosButtonID", id) +end + +local function SetRegionParent(region, parent) + if region and region:GetParent() ~= parent then + region:SetParent(parent) + end +end + +local function IsExternalActionOverrideType(actionType) + return actionType ~= nil and actionType ~= "action" and actionType ~= "actionrelease" +end + +local function HasExternalActionOverride(button) + if not button then + return nil + end + + if button:GetAttribute("gse-button") then + return true + end + + if button:GetAttribute("clickbutton") then + return true + end + + if IsExternalActionOverrideType(button:GetAttribute("type")) then + return true + end + + if IsExternalActionOverrideType(button:GetAttribute("type1")) then + return true + end + + if IsExternalActionOverrideType(button:GetAttribute("*type1")) then + return true + end + + if type(SecureButton_GetModifiedAttribute) == "function" then + return IsExternalActionOverrideType(SecureButton_GetModifiedAttribute(button, "type", "LeftButton")) end end function ActionButton:OnCreate(id) - -- initialize secure state + -- Preserve a Blizzard-compatible public identity before the button is used + -- by binding, tooltip, hotkey, or external hook code. This identity is the + -- stable Dominos/native button id, not the current paged action slot. + ApplyActionButtonContract(self, id) + + -- initialize secure state. Match Blizzard's ActionBarActionButtonMixin + -- public secure-action contract while keeping Dominos execution slot-driven + -- through the explicit secure "action" attribute. + self:SetAttributeNoHandler("type", "action") + self:SetAttributeNoHandler("typerelease", "actionrelease") self:SetAttributeNoHandler("action", 0) - self:SetAttributeNoHandler("commandName", GetActionButtonCommand(id) or ("CLICK %s:HOTKEY"):format(self:GetName())) self:SetAttributeNoHandler("showgrid", 0) + self:SetAttributeNoHandler("statehidden", nil) + self:SetAttributeNoHandler("checkfocuscast", true) + self:SetAttributeNoHandler("checkmouseovercast", true) + self:SetAttributeNoHandler("checkselfcast", true) self:SetAttributeNoHandler("useparent-checkfocuscast", true) self:SetAttributeNoHandler("useparent-checkmouseovercast", true) self:SetAttributeNoHandler("useparent-checkselfcast", true) + self:SetAttributeNoHandler("useparent-unit", true) - -- register for clicks on all buttons, and enable mousewheel bindings + -- register for clicks exactly like Blizzard action buttons: mouse-up for + -- normal actions, plus down-click support for ActionButtonUseKeyDown paths. self:EnableMouseWheel() - self:RegisterForClicks("AnyUp", "AnyDown") + self:RegisterForDrag("LeftButton", "RightButton") + self:RegisterForClicks("AnyUp", "LeftButtonDown", "RightButtonDown") -- secure handlers self:SetAttributeNoHandler('_childupdate-offset', [[ @@ -77,7 +143,16 @@ function ActionButton:OnCreate(id) if (prevValue ~= value) or force then self:SetAttribute("showgrid", value) - local show = (value > 0 or HasAction(self:GetAttribute("action"))) + local buttonType = self:GetAttribute("type") + local type1 = self:GetAttribute("type1") or self:GetAttribute("*type1") + local hasExternalActionOverride = self:GetAttribute("gse-button") + or self:GetAttribute("clickbutton") + or (buttonType and buttonType ~= "action" and buttonType ~= "actionrelease") + or (type1 and type1 ~= "action" and type1 ~= "actionrelease") + + local show = (value > 0 + or HasAction(self:GetAttribute("action")) + or hasExternalActionOverride) and not self:GetAttribute("statehidden") if show then @@ -89,7 +164,16 @@ function ActionButton:OnCreate(id) ]]) self:SetAttributeNoHandler("UpdateShown", [[ - local show = (self:GetAttribute("showgrid") > 0 or HasAction(self:GetAttribute("action"))) + local buttonType = self:GetAttribute("type") + local type1 = self:GetAttribute("type1") or self:GetAttribute("*type1") + local hasExternalActionOverride = self:GetAttribute("gse-button") + or self:GetAttribute("clickbutton") + or (buttonType and buttonType ~= "action" and buttonType ~= "actionrelease") + or (type1 and type1 ~= "action" and type1 ~= "actionrelease") + + local show = (self:GetAttribute("showgrid") > 0 + or HasAction(self:GetAttribute("action")) + or hasExternalActionOverride) and not self:GetAttribute("statehidden") if show then @@ -108,30 +192,43 @@ function ActionButton:OnCreate(id) end function ActionButton:UpdateIcon() - local icon = GetActionTexture(self.action) + local icon = GetActionTextureSafe(self.action) if icon then self.icon:SetTexture(icon) self.icon:Show() - else + elseif not HasExternalActionOverride(self) then self.icon:Hide() end end function ActionButton:UpdateOverrideBindings() if InCombatLockdown() then return end + if not self.bind then return end if C_HouseEditor and C_HouseEditor.IsHouseEditorActive() then ClearOverrideBindings(self.bind) - else - self.bind:SetOverrideBindings(GetBindingKey(self:GetAttribute("commandName"))) + return + end + + local bindingCompat = GetBindingCompat() + if bindingCompat and bindingCompat.GetActionButtonBindingKeys then + local keys = bindingCompat.GetActionButtonBindingKeys(self:GetAttribute("bindingID"), self) + self.bind:SetOverrideBindings(HasExternalActionOverride(self), unpack(keys)) + return end + + local command = GetActionButtonCommand(self) + local keys = command and { GetBindingKey(command) } or {} + self.bind:SetOverrideBindings(HasExternalActionOverride(self), unpack(keys)) end function ActionButton:UpdateShown() if InCombatLockdown() then return end self:SetShown( - (self:GetAttribute("showgrid") > 0 or HasAction(self:GetAttribute("action"))) + (self:GetAttribute("showgrid") > 0 + or HasAction(self:GetAttribute("action")) + or HasExternalActionOverride(self)) and not self:GetAttribute("statehidden") ) end @@ -151,10 +248,7 @@ end -- so we simply make our hotkeys transparent when we don't want them shown function ActionButton:SetShowBindingText(show) local parent = (show and self) or Addon.ShadowUIParent - - if self.HotKey:GetParent() ~= parent then - self.HotKey:SetParent(parent) - end + SetRegionParent(self.HotKey, parent) end -- we hide cooldowns when action buttons are transparent @@ -179,10 +273,7 @@ end function ActionButton:SetShowEquippedItemBorders(show) local parent = (show and self) or Addon.ShadowUIParent - - if self.Border:GetParent() ~= parent then - self.Border:SetParent(parent) - end + SetRegionParent(self.Border, parent) end function ActionButton:SetShowEmptyButtons(show, force) diff --git a/Dominos/bars/actionBar/buttons.lua b/Dominos/bars/actionBar/buttons.lua index 603c32a7..88ae0122 100644 --- a/Dominos/bars/actionBar/buttons.lua +++ b/Dominos/bars/actionBar/buttons.lua @@ -21,6 +21,9 @@ ActionButtons.ShowGridReasons = { -- states -- [button] = action ActionButtons.buttons = {} +ActionButtons.blizzardActionButtonBridge = {} +ActionButtons.blizzardActionButtonBridgeHooked = {} +ActionButtons.pendingExternalOverrideUpdates = {} ActionButtons:Execute([[ ActionButtons = table.new() @@ -181,6 +184,44 @@ function ActionButtons:PLAYER_LOGIN() self:LAYOUT_LOADED() end +function ActionButtons:PLAYER_REGEN_ENABLED() + self:UnregisterEvent("PLAYER_REGEN_ENABLED") + + for sourceButton, targetButton in pairs(self.blizzardActionButtonBridge) do + self:MirrorBlizzardActionButtonOverride(sourceButton, targetButton) + end + + for button in pairs(self.pendingExternalOverrideUpdates) do + if button.UpdateShown then + button:UpdateShown() + end + + if button.UpdateOverrideBindings then + button:UpdateOverrideBindings() + end + + self.pendingExternalOverrideUpdates[button] = nil + end + + self:ForAll("UpdateShown") + self:ForAll("UpdateOverrideBindings") +end + +function ActionButtons:OnExternalOverrideChanged(buttonName) + local button = _G[buttonName] + if not button or not self.buttons[button] then + return + end + + if InCombatLockdown() then + self:QueueExternalOverrideUpdate(button) + return + end + + button:UpdateShown() + button:UpdateOverrideBindings() +end + -- force a visibility updates when spells changed (typically called when -- switching talents) function ActionButtons:SPELLS_CHANGED() @@ -234,6 +275,19 @@ local ActionButton_AttributeChanged = [[ control:CallMethod("OnActionChanged", self:GetName(), value, prevValue) end + elseif name == "type" + or name == "type1" + or name == "*type1" + or name == "typerelease" + or name == "clickbutton" + or name == "clickbutton1" + or name == "*clickbutton1" + or name == "gse-button" + or name == "gse-eff-action" + then + DirtyButtons[self] = true + control:SetAttribute("commit", 0) + control:CallMethod("OnExternalOverrideChanged", self:GetName(), name) end ]] @@ -261,6 +315,202 @@ local ActionButton_OnShowHide = [[ self:RunAttribute("UpdateShown") ]] + +local MIRRORED_EXTERNAL_OVERRIDE_ATTRIBUTES = { + "gse-button", + "gse-eff-action", + "type", + "type1", + "type2", + "*type1", + "*type2", + "typerelease", + "clickbutton", + "clickbutton1", + "clickbutton2", + "*clickbutton1", + "*clickbutton2", + "macro", + "macro1", + "macro2", + "*macro1", + "*macro2", + "macrotext", + "macrotext1", + "macrotext2", + "*macrotext1", + "*macrotext2", + "spell", + "spell1", + "spell2", + "*spell1", + "*spell2", + "item", + "item1", + "item2", + "*item1", + "*item2", + "unit", + "unit1", + "unit2", + "*unit1", + "*unit2", +} + +local MIRRORED_EXTERNAL_OVERRIDE_ATTRIBUTE_SET = {} +for _, attributeName in ipairs(MIRRORED_EXTERNAL_OVERRIDE_ATTRIBUTES) do + MIRRORED_EXTERNAL_OVERRIDE_ATTRIBUTE_SET[attributeName] = true +end + +local function IsMirroredExternalOverrideAttribute(attributeName) + return MIRRORED_EXTERNAL_OVERRIDE_ATTRIBUTE_SET[attributeName] == true +end + +local function IsExternalActionOverrideType(actionType) + return actionType ~= nil and actionType ~= "action" and actionType ~= "actionrelease" +end + +local function HasExternalActionOverrideAttributes(button) + if not button or not button.GetAttribute then + return nil + end + + return button:GetAttribute("gse-button") + or button:GetAttribute("clickbutton") + or IsExternalActionOverrideType(button:GetAttribute("type")) + or IsExternalActionOverrideType(button:GetAttribute("type1")) + or IsExternalActionOverrideType(button:GetAttribute("*type1")) +end + +local function SetAttributeIfChanged(button, attributeName, value) + if button:GetAttribute(attributeName) ~= value then + button:SetAttribute(attributeName, value) + end +end + +local function GetButtonIcon(button) + if not button then + return nil + end + + return button.icon or button.Icon or (button.GetName and _G[button:GetName() .. "Icon"]) +end + +local function CopyButtonIcon(sourceButton, targetButton) + local sourceIcon = GetButtonIcon(sourceButton) + local targetIcon = GetButtonIcon(targetButton) + if not sourceIcon or not targetIcon or not sourceIcon.GetTexture then + return + end + + local texture = sourceIcon:GetTexture() + if texture then + targetIcon:SetTexture(texture) + targetIcon:Show() + end +end + +local function ScheduleButtonIconCopy(sourceButton, targetButton) + CopyButtonIcon(sourceButton, targetButton) + + if C_Timer and C_Timer.After then + C_Timer.After(0, function() + if targetButton and targetButton.GetAttribute and targetButton:GetAttribute("gse-button") then + CopyButtonIcon(sourceButton, targetButton) + end + end) + end +end + +local function RestoreNativeActionAttributes(button) + SetAttributeIfChanged(button, "type", "action") + SetAttributeIfChanged(button, "typerelease", "actionrelease") + + for _, attributeName in ipairs(MIRRORED_EXTERNAL_OVERRIDE_ATTRIBUTES) do + if attributeName ~= "type" and attributeName ~= "typerelease" then + SetAttributeIfChanged(button, attributeName, nil) + end + end +end + +function ActionButtons:QueueExternalOverrideUpdate(button) + if not button then + return + end + + self.pendingExternalOverrideUpdates[button] = true + self:RegisterEvent("PLAYER_REGEN_ENABLED") +end + +function ActionButtons:MirrorBlizzardActionButtonOverride(sourceButton, targetButton) + if not sourceButton or not targetButton or sourceButton == targetButton then + return + end + + if InCombatLockdown() then + self:QueueExternalOverrideUpdate(targetButton) + return + end + + if HasExternalActionOverrideAttributes(sourceButton) then + targetButton.dominosExternalOverrideBridgeSource = sourceButton + + for _, attributeName in ipairs(MIRRORED_EXTERNAL_OVERRIDE_ATTRIBUTES) do + SetAttributeIfChanged(targetButton, attributeName, sourceButton:GetAttribute(attributeName)) + end + + if sourceButton:GetAttribute("clickbutton") and not targetButton:GetAttribute("type") then + SetAttributeIfChanged(targetButton, "type", "click") + end + + ScheduleButtonIconCopy(sourceButton, targetButton) + elseif targetButton.dominosExternalOverrideBridgeSource == sourceButton then + targetButton.dominosExternalOverrideBridgeSource = nil + RestoreNativeActionAttributes(targetButton) + end + + if targetButton.UpdateShown then + targetButton:UpdateShown() + end + + if targetButton.UpdateOverrideBindings then + targetButton:UpdateOverrideBindings() + end +end + +local function BlizzardActionButton_OnAttributeChanged(sourceButton, attributeName) + if not IsMirroredExternalOverrideAttribute(attributeName) then + return + end + + local targetButton = ActionButtons.blizzardActionButtonBridge[sourceButton] + if targetButton then + ActionButtons:MirrorBlizzardActionButtonOverride(sourceButton, targetButton) + end +end + +function ActionButtons:RegisterBlizzardActionButtonBridge(button, id) + if type(id) ~= "number" or id < 1 or id > 12 then + return + end + + local sourceButton = _G[("ActionButton%d"):format(id)] + if not sourceButton or sourceButton == button then + return + end + + self.blizzardActionButtonBridge[sourceButton] = button + button.dominosBlizzardActionButtonBridgeSource = sourceButton + button.blizzardActionButtonName = sourceButton:GetName() + + if not self.blizzardActionButtonBridgeHooked[sourceButton] then + sourceButton:HookScript("OnAttributeChanged", BlizzardActionButton_OnAttributeChanged) + self.blizzardActionButtonBridgeHooked[sourceButton] = true + end + + self:MirrorBlizzardActionButtonOverride(sourceButton, button) +end + local function GetActionButtonName(id) if id <= 0 then return @@ -363,39 +613,54 @@ function ActionButtons:GetOrCreateActionButton(id, parent) self.buttons[button] = 0 end + self:RegisterBlizzardActionButtonBridge(button, id) + return button end -- update the pushed state of our parent button when pressing and releasing --- the button's hotkey +-- the button's hotkey. The hidden secure proxy owns override bindings for normal +-- slot execution. When an external addon replaces the visible button contract +-- with a clickbutton/macro/spell override, bindings are retargeted to the visible +-- button so the external secure override receives the same click as the mouse. local function bindButton_PreClick(self, _, down) local owner = self:GetParent() + if not owner then + return + end if down then if owner:GetButtonState() == "NORMAL" then owner:SetButtonState("PUSHED") end - else - if owner:GetButtonState() == "PUSHED" then - owner:SetButtonState("NORMAL") - end + elseif owner:GetButtonState() == "PUSHED" then + owner:SetButtonState("NORMAL") end end -local function bindButton_SetOverrideBindings(self, ...) +local function bindButton_SetOverrideBindings(self, useVisibleButton, ...) ClearOverrideBindings(self) - local name = self:GetName() + local owner = self:GetParent() + local targetName = useVisibleButton and owner and owner:GetName() or self:GetName() + local targetButton = useVisibleButton and "LeftButton" or "HOTKEY" + if not targetName then + return + end + for i = 1, select("#", ...) do - SetOverrideBindingClick(self, false, select(i, ...), name, "HOTKEY") + local key = select(i, ...) + if key then + SetOverrideBindingClick(self, false, key, targetName, targetButton) + end end end --- cast on keypress support is implemented by using a second hidden button --- that mirrors all ofthe attributes of its parent button. This is to work --- around inconsistent handling of drag and drop if we just use the --- SecureActionButtonTemplate for buttons, as well as the OnClick handler --- for action buttons only triggering actions on key release. +-- Cast-on-keypress support is implemented by using a second hidden button that +-- mirrors the secure action attributes of its parent. Native Blizzard binding +-- keys are captured with override bindings and redirected here for normal action +-- slots so addon-created Dominos buttons are not executed through Blizzard's +-- restricted ACTIONBUTTON binding snippets. function ActionButtons:AddCastOnKeyPressSupport(button) local bind = CreateFrame("Button", "$parentHotkey", button, "SecureActionButtonTemplate") @@ -412,16 +677,15 @@ function ActionButtons:AddCastOnKeyPressSupport(button) bind:EnableMouseWheel() bind:RegisterForClicks("AnyUp", "AnyDown") - bind:SetScript("PreClick", bindButton_PreClick) - bind.SetOverrideBindings = bindButton_SetOverrideBindings if Addon.SpellFlyout then Addon.SpellFlyout:Register(bind) end - -- translate HOTKEY button "clicks" into LeftButton + -- Translate HOTKEY button clicks into LeftButton. This matches the old + -- Dominos fallback path while preserving flyout safety on Midnight builds. if Addon:IsAfterMidnight() then self:WrapScript(bind, "OnClick", [[ if button == "HOTKEY" then diff --git a/Dominos/core/bindableButton.lua b/Dominos/core/bindableButton.lua index dc27483b..eab291b3 100644 --- a/Dominos/core/bindableButton.lua +++ b/Dominos/core/bindableButton.lua @@ -3,12 +3,23 @@ local AddonName, Addon = ... local KeyBound = LibStub('LibKeyBound-1.0') local COMMAND_TEMPLATE = 'CLICK %s:HOTKEY' +local function getBindingCompat() + return Addon.BindingCompat +end + -- binding method definitions -- returns the binding action associated with the button -- we use a virtual button (arbitrarily named HOTKEY) -- to enable cast on key press support local function getButtonBindingAction(button) + local bindingCompat = getBindingCompat() + if bindingCompat then + return bindingCompat.NormalizeCommandName(button:GetAttribute("commandName")) + or bindingCompat.GetActionButtonCommand(button:GetAttribute("bindingID"), button) + or bindingCompat.GetFallbackClickBinding(button, button:GetAttribute("bindingID")) + end + return button:GetAttribute("commandName") or COMMAND_TEMPLATE:format(button:GetName()) end @@ -20,6 +31,13 @@ local function getButtonBindingActionName(button) end local function getButtonBindings(button) + local bindingID = button:GetAttribute("bindingID") + local bindingCompat = getBindingCompat() + + if bindingID and bindingCompat and bindingCompat.GetActionButtonBindingKeys then + return unpack(bindingCompat.GetActionButtonBindingKeys(bindingID, button)) + end + return GetBindingKey(getButtonBindingAction(button)) end @@ -36,7 +54,12 @@ end -- returns a space separated list of all bindings for the given button local function getButtonBindingsList(button) - return strjoin(' ', getButtonBindings(button)) + local key = getButtonBindings(button) + if key then + return strjoin(' ', getButtonBindings(button)) + end + + return '' end -- set bindings @@ -45,13 +68,28 @@ local function setButtonBinding(button, key) end -- clears all bindings from the button -local function clearButtonBindings(button) - local key = (getButtonBindings(button)) +local function clearButtonBindingCommand(command) + local key = GetBindingKey(command) while key do SetBinding(key, nil) - key = (getButtonBindings(button)) + key = GetBindingKey(command) + end +end + +local function clearButtonBindings(button) + local bindingID = button:GetAttribute("bindingID") + local bindingCompat = getBindingCompat() + + if bindingID and bindingCompat and bindingCompat.GetActionButtonCommands then + local commands = bindingCompat.GetActionButtonCommands(bindingID, button) + for _, command in ipairs(commands) do + clearButtonBindingCommand(command) + end + return end + + clearButtonBindingCommand(getButtonBindingAction(button)) end -- used to implement keybinding support without applying all of the LibKeyBound @@ -108,6 +146,16 @@ function BindableButton:AddQuickBindingSupport(button) end function BindableButton:UpdateHotkeys() + local bindingAction = getButtonBindingAction(self) + + -- Blizzard's ActionBarActionButtonMixin may rebuild bindingAction from + -- GetID(), which Dominos intentionally keeps decoupled from secure paging. + -- Restore the stable binding contract after the native hotkey update path + -- runs so external binding-highlighting hooks see the same command Dominos + -- displays and binds. + self.commandName = bindingAction + self.bindingAction = bindingAction + local key = (self.GetHotkey or getButtonHotkey)(self) or '' local hotkey = self.HotKey diff --git a/Dominos/core/bindingCompat.lua b/Dominos/core/bindingCompat.lua new file mode 100644 index 00000000..f49b1895 --- /dev/null +++ b/Dominos/core/bindingCompat.lua @@ -0,0 +1,288 @@ +-- Centralized binding identity helpers for Dominos action buttons. +-- +-- Dominos buttons should expose Blizzard-native binding commands whenever a +-- stable Dominos button maps to a native Blizzard action button. Dominos CLICK +-- bindings remain available as fallback compatibility bindings for buttons that +-- do not have a Blizzard-native binding command. +local AddonName, Addon = ... + +local BindingCompat = {} +local CLICK_BINDING_TEMPLATE = "CLICK %s:HOTKEY" +local LEGACY_BUTTON_NAME_TEMPLATE = AddonName .. "ActionButton%d" + +local NATIVE_BINDING_RANGES = { + -- Main action bar. + {first = 1, last = 12, prefix = "ACTIONBUTTON", offset = 0}, + + -- Blizzard multi action bars. The Dominos stable button ids intentionally + -- match action slot layout, not paged runtime action attributes. + {first = 25, last = 36, prefix = "MULTIACTIONBAR3BUTTON", offset = 24}, + {first = 37, last = 48, prefix = "MULTIACTIONBAR4BUTTON", offset = 36}, + {first = 49, last = 60, prefix = "MULTIACTIONBAR2BUTTON", offset = 48}, + {first = 61, last = 72, prefix = "MULTIACTIONBAR1BUTTON", offset = 60}, + + -- Retail extra multi action bars. These are capability-checked before use + -- so TBC safely falls back to Dominos CLICK bindings. + {first = 133, last = 144, prefix = "MULTIACTIONBAR5BUTTON", offset = 132, retailOnly = true}, + {first = 145, last = 156, prefix = "MULTIACTIONBAR6BUTTON", offset = 144, retailOnly = true}, + {first = 157, last = 168, prefix = "MULTIACTIONBAR7BUTTON", offset = 156, retailOnly = true}, +} + +local function IsNonEmptyString(value) + return type(value) == "string" and value ~= "" +end + +local function GetBindingNameGlobal(command) + if IsNonEmptyString(command) then + return _G["BINDING_NAME_" .. command] + end +end + +local function IsNativeBindingCommandAvailable(command) + -- Binding name globals are the safest capability probe here: they indicate + -- that the client actually exposes the command through Blizzard's binding + -- system. GetBindingKey() alone cannot distinguish unbound commands from + -- commands that do not exist on a flavor. + return GetBindingNameGlobal(command) ~= nil +end + +local function GetRangeInfo(buttonID) + if type(buttonID) ~= "number" then + return nil + end + + for _, range in ipairs(NATIVE_BINDING_RANGES) do + if buttonID >= range.first and buttonID <= range.last then + return range + end + end +end + + +local function AddUniqueValue(values, seen, value) + if IsNonEmptyString(value) and not seen[value] then + values[#values + 1] = value + seen[value] = true + end +end + +local function AddBindingKeysForCommand(keys, seen, command) + if not IsNonEmptyString(command) then + return + end + + local firstKey, secondKey = GetBindingKey(command) + AddUniqueValue(keys, seen, firstKey) + AddUniqueValue(keys, seen, secondKey) +end + +local function GetButtonName(button) + if type(button) == "string" then + return button + end + + if type(button) == "table" and button.GetName then + return button:GetName() + end +end + +function BindingCompat.NormalizeCommandName(command) + if IsNonEmptyString(command) then + return command + end +end + +function BindingCompat.GetLegacyActionButtonName(buttonID) + if type(buttonID) == "number" and buttonID > 0 then + return LEGACY_BUTTON_NAME_TEMPLATE:format(buttonID) + end +end + +function BindingCompat.GetBlizzardActionButtonAliasName(buttonID) + if type(buttonID) == "number" and buttonID >= 1 and buttonID <= 12 then + return ("ActionButton%d"):format(buttonID) + end +end + +function BindingCompat.CreateLegacyActionButtonAlias(button, buttonID) + local legacyName = BindingCompat.GetLegacyActionButtonName(buttonID) + if not legacyName or not button then + return + end + + -- Keep the historical DominosActionButtonN global as an alias only when it + -- already resolves to this frame or has not been created yet. Do not alias + -- Blizzard-owned ActionButtonN globals to Dominos-created frames; those are + -- used by restricted Blizzard binding scripts and controller tables. + if _G[legacyName] == nil or _G[legacyName] == button then + _G[legacyName] = button + end +end + +function BindingCompat.GetClickBindingForButtonName(buttonName) + if IsNonEmptyString(buttonName) then + return CLICK_BINDING_TEMPLATE:format(buttonName) + end +end + +function BindingCompat.GetActualClickBinding(button) + local name = GetButtonName(button) + return BindingCompat.GetClickBindingForButtonName(name) +end + +function BindingCompat.GetBlizzardAliasClickBinding(buttonID) + return BindingCompat.GetClickBindingForButtonName(BindingCompat.GetBlizzardActionButtonAliasName(buttonID)) +end + +function BindingCompat.GetFallbackClickBinding(button, buttonID) + local legacyName = BindingCompat.GetLegacyActionButtonName(buttonID) + if legacyName then + return CLICK_BINDING_TEMPLATE:format(legacyName) + end + + return BindingCompat.GetActualClickBinding(button) +end + +function BindingCompat.GetNativeActionButtonCommand(buttonID) + local range = GetRangeInfo(buttonID) + if not range then + return nil + end + + local command = range.prefix .. (buttonID - range.offset) + if not range.retailOnly then + return command + end + + -- Retail-only bars must be capability checked because this file also loads + -- on TBC. Prefer the capability probe, with Addon:IsBuild as a fallback in + -- case a client delays binding-name globals. + if IsNativeBindingCommandAvailable(command) then + return command + end + + if Addon.IsBuild and Addon:IsBuild("retail") then + return command + end +end + +function BindingCompat.GetActionButtonCommand(buttonID, button) + return BindingCompat.GetNativeActionButtonCommand(buttonID) + or BindingCompat.GetFallbackClickBinding(button, buttonID) +end + + +function BindingCompat.GetActionButtonCommands(buttonID, button) + local commands = {} + local seen = {} + + AddUniqueValue(commands, seen, BindingCompat.GetNativeActionButtonCommand(buttonID)) + AddUniqueValue(commands, seen, BindingCompat.GetFallbackClickBinding(button, buttonID)) + AddUniqueValue(commands, seen, BindingCompat.GetActualClickBinding(button)) + + return commands +end + +function BindingCompat.GetActionButtonBindingKeys(buttonID, button) + local keys = {} + local seen = {} + local commands = BindingCompat.GetActionButtonCommands(buttonID, button) + + for _, command in ipairs(commands) do + AddBindingKeysForCommand(keys, seen, command) + end + + return keys +end + +function BindingCompat.GetFallbackActionButtonBindingKeys(buttonID, button) + local keys = {} + local seen = {} + + -- Fallback-only binding collection. The full binding collection above is used + -- for Dominos-owned override bindings so native keys can be captured without + -- executing Blizzard's restricted ACTIONBUTTON snippets against addon frames. + AddBindingKeysForCommand(keys, seen, BindingCompat.GetFallbackClickBinding(button, buttonID)) + AddBindingKeysForCommand(keys, seen, BindingCompat.GetActualClickBinding(button)) + + return keys +end + +function BindingCompat.UsesNativeBindingRouting(buttonID) + return BindingCompat.GetNativeActionButtonCommand(buttonID) ~= nil +end + +function BindingCompat.GetOverrideActionButtonCommand(index) + if type(index) == "number" and index > 0 then + return "ACTIONBUTTON" .. index + end +end + +function BindingCompat.GetActionButtonIndex(buttonID) + local range = GetRangeInfo(buttonID) + if range then + return buttonID - range.offset + end + + if type(buttonID) == "number" and buttonID > 0 then + return ((buttonID - 1) % NUM_ACTIONBAR_BUTTONS) + 1 + end +end + +function BindingCompat.GetActionButtonType(buttonID) + local command = BindingCompat.GetNativeActionButtonCommand(buttonID) + if not command then + return nil + end + + return command:match("^(.-)%d+$") +end + +function BindingCompat.ApplyActionButtonContract(button, buttonID) + if not button then + return + end + + local command = BindingCompat.GetActionButtonCommand(buttonID, button) + local nativeCommand = BindingCompat.GetNativeActionButtonCommand(buttonID) + local fallbackCommand = BindingCompat.GetFallbackClickBinding(button, buttonID) + local actualClickCommand = BindingCompat.GetActualClickBinding(button) + local blizzardAliasName = BindingCompat.GetBlizzardActionButtonAliasName(buttonID) + local blizzardAliasClickCommand = BindingCompat.GetBlizzardAliasClickBinding(buttonID) + local buttonType = BindingCompat.GetActionButtonType(buttonID) + local buttonIndex = BindingCompat.GetActionButtonIndex(buttonID) + + -- Mirror Blizzard's public action-button fields where practical. These are + -- intentionally stable button identity values, not the current paged action + -- slot held in the secure "action" attribute. + button.commandName = command + button.bindingAction = command + button.bindingID = buttonID + button.dominosButtonID = buttonID + button.dominosNativeCommandName = nativeCommand + button.dominosFallbackCommandName = fallbackCommand + button.dominosActualClickCommandName = actualClickCommand + button.dominosBlizzardAliasName = blizzardAliasName + button.dominosBlizzardAliasClickCommandName = blizzardAliasClickCommand + + if buttonType then + button.buttonType = buttonType + end + + if buttonIndex then + button.buttonIndex = buttonIndex + end + + button:SetAttributeNoHandler("commandName", command) + button:SetAttributeNoHandler("bindingID", buttonID) + button:SetAttributeNoHandler("nativeCommandName", nativeCommand) + button:SetAttributeNoHandler("fallbackCommandName", fallbackCommand) + button:SetAttributeNoHandler("actualClickCommandName", actualClickCommand) + button:SetAttributeNoHandler("blizzardAliasName", blizzardAliasName) + button:SetAttributeNoHandler("blizzardAliasClickCommandName", blizzardAliasClickCommand) + button:SetAttributeNoHandler("dominosButtonID", buttonID) + + BindingCompat.CreateLegacyActionButtonAlias(button, buttonID) +end + +Addon.BindingCompat = BindingCompat diff --git a/Dominos/libs/AceAddon-3.0/AceAddon-3.0.lua b/Dominos/libs/AceAddon-3.0/AceAddon-3.0.lua new file mode 100644 index 00000000..f392a216 --- /dev/null +++ b/Dominos/libs/AceAddon-3.0/AceAddon-3.0.lua @@ -0,0 +1,649 @@ +--- **AceAddon-3.0** provides a template for creating addon objects. +-- It'll provide you with a set of callback functions that allow you to simplify the loading +-- process of your addon.\\ +-- Callbacks provided are:\\ +-- * **OnInitialize**, which is called directly after the addon is fully loaded. +-- * **OnEnable** which gets called during the PLAYER_LOGIN event, when most of the data provided by the game is already present. +-- * **OnDisable**, which is only called when your addon is manually being disabled. +-- @usage +-- -- A small (but complete) addon, that doesn't do anything, +-- -- but shows usage of the callbacks. +-- local MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon") +-- +-- function MyAddon:OnInitialize() +-- -- do init tasks here, like loading the Saved Variables, +-- -- or setting up slash commands. +-- end +-- +-- function MyAddon:OnEnable() +-- -- Do more initialization here, that really enables the use of your addon. +-- -- Register Events, Hook functions, Create Frames, Get information from +-- -- the game that wasn't available in OnInitialize +-- end +-- +-- function MyAddon:OnDisable() +-- -- Unhook, Unregister Events, Hide frames that you created. +-- -- You would probably only use an OnDisable if you want to +-- -- build a "standby" mode, or be able to toggle modules on/off. +-- end +-- @class file +-- @name AceAddon-3.0.lua +-- @release $Id: AceAddon-3.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $ + +local MAJOR, MINOR = "AceAddon-3.0", 13 +local AceAddon, oldminor = LibStub:NewLibrary(MAJOR, MINOR) + +if not AceAddon then return end -- No Upgrade needed. + +AceAddon.frame = AceAddon.frame or CreateFrame("Frame", "AceAddon30Frame") -- Our very own frame +AceAddon.addons = AceAddon.addons or {} -- addons in general +AceAddon.statuses = AceAddon.statuses or {} -- statuses of addon. +AceAddon.initializequeue = AceAddon.initializequeue or {} -- addons that are new and not initialized +AceAddon.enablequeue = AceAddon.enablequeue or {} -- addons that are initialized and waiting to be enabled +AceAddon.embeds = AceAddon.embeds or setmetatable({}, {__index = function(tbl, key) tbl[key] = {} return tbl[key] end }) -- contains a list of libraries embedded in an addon + +-- Lua APIs +local tinsert, tconcat, tremove = table.insert, table.concat, table.remove +local fmt, tostring = string.format, tostring +local select, pairs, next, type, unpack = select, pairs, next, type, unpack +local loadstring, assert, error = loadstring, assert, error +local setmetatable, getmetatable, rawset, rawget = setmetatable, getmetatable, rawset, rawget + +--[[ + xpcall safecall implementation +]] +local xpcall = xpcall + +local function errorhandler(err) + return geterrorhandler()(err) +end + +local function safecall(func, ...) + -- we check to see if the func is passed is actually a function here and don't error when it isn't + -- this safecall is used for optional functions like OnInitialize OnEnable etc. When they are not + -- present execution should continue without hinderance + if type(func) == "function" then + return xpcall(func, errorhandler, ...) + end +end + +-- local functions that will be implemented further down +local Enable, Disable, EnableModule, DisableModule, Embed, NewModule, GetModule, GetName, SetDefaultModuleState, SetDefaultModuleLibraries, SetEnabledState, SetDefaultModulePrototype + +-- used in the addon metatable +local function addontostring( self ) return self.name end + +-- Check if the addon is queued for initialization +local function queuedForInitialization(addon) + for i = 1, #AceAddon.initializequeue do + if AceAddon.initializequeue[i] == addon then + return true + end + end + return false +end + +--- Create a new AceAddon-3.0 addon. +-- Any libraries you specified will be embeded, and the addon will be scheduled for +-- its OnInitialize and OnEnable callbacks. +-- The final addon object, with all libraries embeded, will be returned. +-- @paramsig [object ,]name[, lib, ...] +-- @param object Table to use as a base for the addon (optional) +-- @param name Name of the addon object to create +-- @param lib List of libraries to embed into the addon +-- @usage +-- -- Create a simple addon object +-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "AceEvent-3.0") +-- +-- -- Create a Addon object based on the table of a frame +-- local MyFrame = CreateFrame("Frame") +-- MyAddon = LibStub("AceAddon-3.0"):NewAddon(MyFrame, "MyAddon", "AceEvent-3.0") +function AceAddon:NewAddon(objectorname, ...) + local object,name + local i=1 + if type(objectorname)=="table" then + object=objectorname + name=... + i=2 + else + name=objectorname + end + if type(name)~="string" then + error(("Usage: NewAddon([object,] name, [lib, lib, lib, ...]): 'name' - string expected got '%s'."):format(type(name)), 2) + end + if self.addons[name] then + error(("Usage: NewAddon([object,] name, [lib, lib, lib, ...]): 'name' - Addon '%s' already exists."):format(name), 2) + end + + object = object or {} + object.name = name + + local addonmeta = {} + local oldmeta = getmetatable(object) + if oldmeta then + for k, v in pairs(oldmeta) do addonmeta[k] = v end + end + addonmeta.__tostring = addontostring + + setmetatable( object, addonmeta ) + self.addons[name] = object + object.modules = {} + object.orderedModules = {} + object.defaultModuleLibraries = {} + Embed( object ) -- embed NewModule, GetModule methods + self:EmbedLibraries(object, select(i,...)) + + -- add to queue of addons to be initialized upon ADDON_LOADED + tinsert(self.initializequeue, object) + return object +end + + +--- Get the addon object by its name from the internal AceAddon registry. +-- Throws an error if the addon object cannot be found (except if silent is set). +-- @param name unique name of the addon object +-- @param silent if true, the addon is optional, silently return nil if its not found +-- @usage +-- -- Get the Addon +-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") +function AceAddon:GetAddon(name, silent) + if not silent and not self.addons[name] then + error(("Usage: GetAddon(name): 'name' - Cannot find an AceAddon '%s'."):format(tostring(name)), 2) + end + return self.addons[name] +end + +-- - Embed a list of libraries into the specified addon. +-- This function will try to embed all of the listed libraries into the addon +-- and error if a single one fails. +-- +-- **Note:** This function is for internal use by :NewAddon/:NewModule +-- @paramsig addon, [lib, ...] +-- @param addon addon object to embed the libs in +-- @param lib List of libraries to embed into the addon +function AceAddon:EmbedLibraries(addon, ...) + for i=1,select("#", ... ) do + local libname = select(i, ...) + self:EmbedLibrary(addon, libname, false, 4) + end +end + +-- - Embed a library into the addon object. +-- This function will check if the specified library is registered with LibStub +-- and if it has a :Embed function to call. It'll error if any of those conditions +-- fails. +-- +-- **Note:** This function is for internal use by :EmbedLibraries +-- @paramsig addon, libname[, silent[, offset]] +-- @param addon addon object to embed the library in +-- @param libname name of the library to embed +-- @param silent marks an embed to fail silently if the library doesn't exist (optional) +-- @param offset will push the error messages back to said offset, defaults to 2 (optional) +function AceAddon:EmbedLibrary(addon, libname, silent, offset) + local lib = LibStub:GetLibrary(libname, true) + if not lib and not silent then + error(("Usage: EmbedLibrary(addon, libname, silent, offset): 'libname' - Cannot find a library instance of %q."):format(tostring(libname)), offset or 2) + elseif lib and type(lib.Embed) == "function" then + lib:Embed(addon) + tinsert(self.embeds[addon], libname) + return true + elseif lib then + error(("Usage: EmbedLibrary(addon, libname, silent, offset): 'libname' - Library '%s' is not Embed capable"):format(libname), offset or 2) + end +end + +--- Return the specified module from an addon object. +-- Throws an error if the addon object cannot be found (except if silent is set) +-- @name //addon//:GetModule +-- @paramsig name[, silent] +-- @param name unique name of the module +-- @param silent if true, the module is optional, silently return nil if its not found (optional) +-- @usage +-- -- Get the Addon +-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") +-- -- Get the Module +-- MyModule = MyAddon:GetModule("MyModule") +function GetModule(self, name, silent) + if not self.modules[name] and not silent then + error(("Usage: GetModule(name, silent): 'name' - Cannot find module '%s'."):format(tostring(name)), 2) + end + return self.modules[name] +end + +local function IsModuleTrue(self) return true end + +--- Create a new module for the addon. +-- The new module can have its own embeded libraries and/or use a module prototype to be mixed into the module.\\ +-- A module has the same functionality as a real addon, it can have modules of its own, and has the same API as +-- an addon object. +-- @name //addon//:NewModule +-- @paramsig name[, prototype|lib[, lib, ...]] +-- @param name unique name of the module +-- @param prototype object to derive this module from, methods and values from this table will be mixed into the module (optional) +-- @param lib List of libraries to embed into the addon +-- @usage +-- -- Create a module with some embeded libraries +-- MyModule = MyAddon:NewModule("MyModule", "AceEvent-3.0", "AceHook-3.0") +-- +-- -- Create a module with a prototype +-- local prototype = { OnEnable = function(self) print("OnEnable called!") end } +-- MyModule = MyAddon:NewModule("MyModule", prototype, "AceEvent-3.0", "AceHook-3.0") +function NewModule(self, name, prototype, ...) + if type(name) ~= "string" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'name' - string expected got '%s'."):format(type(name)), 2) end + if type(prototype) ~= "string" and type(prototype) ~= "table" and type(prototype) ~= "nil" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'prototype' - table (prototype), string (lib) or nil expected got '%s'."):format(type(prototype)), 2) end + + if self.modules[name] then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'name' - Module '%s' already exists."):format(name), 2) end + + -- modules are basically addons. We treat them as such. They will be added to the initializequeue properly as well. + -- NewModule can only be called after the parent addon is present thus the modules will be initialized after their parent is. + local module = AceAddon:NewAddon(fmt("%s_%s", self.name or tostring(self), name)) + + module.IsModule = IsModuleTrue + module:SetEnabledState(self.defaultModuleState) + module.moduleName = name + + if type(prototype) == "string" then + AceAddon:EmbedLibraries(module, prototype, ...) + else + AceAddon:EmbedLibraries(module, ...) + end + AceAddon:EmbedLibraries(module, unpack(self.defaultModuleLibraries)) + + if not prototype or type(prototype) == "string" then + prototype = self.defaultModulePrototype or nil + end + + if type(prototype) == "table" then + local mt = getmetatable(module) + mt.__index = prototype + setmetatable(module, mt) -- More of a Base class type feel. + end + + safecall(self.OnModuleCreated, self, module) -- Was in Ace2 and I think it could be a cool thing to have handy. + self.modules[name] = module + tinsert(self.orderedModules, module) + + return module +end + +--- Returns the real name of the addon or module, without any prefix. +-- @name //addon//:GetName +-- @paramsig +-- @usage +-- print(MyAddon:GetName()) +-- -- prints "MyAddon" +function GetName(self) + return self.moduleName or self.name +end + +--- Enables the Addon, if possible, return true or false depending on success. +-- This internally calls AceAddon:EnableAddon(), thus dispatching a OnEnable callback +-- and enabling all modules of the addon (unless explicitly disabled).\\ +-- :Enable() also sets the internal `enableState` variable to true +-- @name //addon//:Enable +-- @paramsig +-- @usage +-- -- Enable MyModule +-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") +-- MyModule = MyAddon:GetModule("MyModule") +-- MyModule:Enable() +function Enable(self) + self:SetEnabledState(true) + + -- nevcairiel 2013-04-27: don't enable an addon/module if its queued for init still + -- it'll be enabled after the init process + if not queuedForInitialization(self) then + return AceAddon:EnableAddon(self) + end +end + +--- Disables the Addon, if possible, return true or false depending on success. +-- This internally calls AceAddon:DisableAddon(), thus dispatching a OnDisable callback +-- and disabling all modules of the addon.\\ +-- :Disable() also sets the internal `enableState` variable to false +-- @name //addon//:Disable +-- @paramsig +-- @usage +-- -- Disable MyAddon +-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") +-- MyAddon:Disable() +function Disable(self) + self:SetEnabledState(false) + return AceAddon:DisableAddon(self) +end + +--- Enables the Module, if possible, return true or false depending on success. +-- Short-hand function that retrieves the module via `:GetModule` and calls `:Enable` on the module object. +-- @name //addon//:EnableModule +-- @paramsig name +-- @usage +-- -- Enable MyModule using :GetModule +-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") +-- MyModule = MyAddon:GetModule("MyModule") +-- MyModule:Enable() +-- +-- -- Enable MyModule using the short-hand +-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") +-- MyAddon:EnableModule("MyModule") +function EnableModule(self, name) + local module = self:GetModule( name ) + return module:Enable() +end + +--- Disables the Module, if possible, return true or false depending on success. +-- Short-hand function that retrieves the module via `:GetModule` and calls `:Disable` on the module object. +-- @name //addon//:DisableModule +-- @paramsig name +-- @usage +-- -- Disable MyModule using :GetModule +-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") +-- MyModule = MyAddon:GetModule("MyModule") +-- MyModule:Disable() +-- +-- -- Disable MyModule using the short-hand +-- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") +-- MyAddon:DisableModule("MyModule") +function DisableModule(self, name) + local module = self:GetModule( name ) + return module:Disable() +end + +--- Set the default libraries to be mixed into all modules created by this object. +-- Note that you can only change the default module libraries before any module is created. +-- @name //addon//:SetDefaultModuleLibraries +-- @paramsig lib[, lib, ...] +-- @param lib List of libraries to embed into the addon +-- @usage +-- -- Create the addon object +-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon") +-- -- Configure default libraries for modules (all modules need AceEvent-3.0) +-- MyAddon:SetDefaultModuleLibraries("AceEvent-3.0") +-- -- Create a module +-- MyModule = MyAddon:NewModule("MyModule") +function SetDefaultModuleLibraries(self, ...) + if next(self.modules) then + error("Usage: SetDefaultModuleLibraries(...): cannot change the module defaults after a module has been registered.", 2) + end + self.defaultModuleLibraries = {...} +end + +--- Set the default state in which new modules are being created. +-- Note that you can only change the default state before any module is created. +-- @name //addon//:SetDefaultModuleState +-- @paramsig state +-- @param state Default state for new modules, true for enabled, false for disabled +-- @usage +-- -- Create the addon object +-- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon") +-- -- Set the default state to "disabled" +-- MyAddon:SetDefaultModuleState(false) +-- -- Create a module and explicilty enable it +-- MyModule = MyAddon:NewModule("MyModule") +-- MyModule:Enable() +function SetDefaultModuleState(self, state) + if next(self.modules) then + error("Usage: SetDefaultModuleState(state): cannot change the module defaults after a module has been registered.", 2) + end + self.defaultModuleState = state +end + +--- Set the default prototype to use for new modules on creation. +-- Note that you can only change the default prototype before any module is created. +-- @name //addon//:SetDefaultModulePrototype +-- @paramsig prototype +-- @param prototype Default prototype for the new modules (table) +-- @usage +-- -- Define a prototype +-- local prototype = { OnEnable = function(self) print("OnEnable called!") end } +-- -- Set the default prototype +-- MyAddon:SetDefaultModulePrototype(prototype) +-- -- Create a module and explicitly Enable it +-- MyModule = MyAddon:NewModule("MyModule") +-- MyModule:Enable() +-- -- should print "OnEnable called!" now +-- @see NewModule +function SetDefaultModulePrototype(self, prototype) + if next(self.modules) then + error("Usage: SetDefaultModulePrototype(prototype): cannot change the module defaults after a module has been registered.", 2) + end + if type(prototype) ~= "table" then + error(("Usage: SetDefaultModulePrototype(prototype): 'prototype' - table expected got '%s'."):format(type(prototype)), 2) + end + self.defaultModulePrototype = prototype +end + +--- Set the state of an addon or module +-- This should only be called before any enabling actually happend, e.g. in/before OnInitialize. +-- @name //addon//:SetEnabledState +-- @paramsig state +-- @param state the state of an addon or module (enabled=true, disabled=false) +function SetEnabledState(self, state) + self.enabledState = state +end + + +--- Return an iterator of all modules associated to the addon. +-- @name //addon//:IterateModules +-- @paramsig +-- @usage +-- -- Enable all modules +-- for name, module in MyAddon:IterateModules() do +-- module:Enable() +-- end +local function IterateModules(self) return pairs(self.modules) end + +-- Returns an iterator of all embeds in the addon +-- @name //addon//:IterateEmbeds +-- @paramsig +local function IterateEmbeds(self) return pairs(AceAddon.embeds[self]) end + +--- Query the enabledState of an addon. +-- @name //addon//:IsEnabled +-- @paramsig +-- @usage +-- if MyAddon:IsEnabled() then +-- MyAddon:Disable() +-- end +local function IsEnabled(self) return self.enabledState end +local mixins = { + NewModule = NewModule, + GetModule = GetModule, + Enable = Enable, + Disable = Disable, + EnableModule = EnableModule, + DisableModule = DisableModule, + IsEnabled = IsEnabled, + SetDefaultModuleLibraries = SetDefaultModuleLibraries, + SetDefaultModuleState = SetDefaultModuleState, + SetDefaultModulePrototype = SetDefaultModulePrototype, + SetEnabledState = SetEnabledState, + IterateModules = IterateModules, + IterateEmbeds = IterateEmbeds, + GetName = GetName, +} +local function IsModule(self) return false end +local pmixins = { + defaultModuleState = true, + enabledState = true, + IsModule = IsModule, +} +-- Embed( target ) +-- target (object) - target object to embed aceaddon in +-- +-- this is a local function specifically since it's meant to be only called internally +function Embed(target, skipPMixins) + for k, v in pairs(mixins) do + target[k] = v + end + if not skipPMixins then + for k, v in pairs(pmixins) do + target[k] = target[k] or v + end + end +end + + +-- - Initialize the addon after creation. +-- This function is only used internally during the ADDON_LOADED event +-- It will call the **OnInitialize** function on the addon object (if present), +-- and the **OnEmbedInitialize** function on all embeded libraries. +-- +-- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing. +-- @param addon addon object to intialize +function AceAddon:InitializeAddon(addon) + safecall(addon.OnInitialize, addon) + + local embeds = self.embeds[addon] + for i = 1, #embeds do + local lib = LibStub:GetLibrary(embeds[i], true) + if lib then safecall(lib.OnEmbedInitialize, lib, addon) end + end + + -- we don't call InitializeAddon on modules specifically, this is handled + -- from the event handler and only done _once_ +end + +-- - Enable the addon after creation. +-- Note: This function is only used internally during the PLAYER_LOGIN event, or during ADDON_LOADED, +-- if IsLoggedIn() already returns true at that point, e.g. for LoD Addons. +-- It will call the **OnEnable** function on the addon object (if present), +-- and the **OnEmbedEnable** function on all embeded libraries.\\ +-- This function does not toggle the enable state of the addon itself, and will return early if the addon is disabled. +-- +-- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing. +-- Use :Enable on the addon itself instead. +-- @param addon addon object to enable +function AceAddon:EnableAddon(addon) + if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end + if self.statuses[addon.name] or not addon.enabledState then return false end + + -- set the statuses first, before calling the OnEnable. this allows for Disabling of the addon in OnEnable. + self.statuses[addon.name] = true + + safecall(addon.OnEnable, addon) + + -- make sure we're still enabled before continueing + if self.statuses[addon.name] then + local embeds = self.embeds[addon] + for i = 1, #embeds do + local lib = LibStub:GetLibrary(embeds[i], true) + if lib then safecall(lib.OnEmbedEnable, lib, addon) end + end + + -- enable possible modules. + local modules = addon.orderedModules + for i = 1, #modules do + self:EnableAddon(modules[i]) + end + end + return self.statuses[addon.name] -- return true if we're disabled +end + +-- - Disable the addon +-- Note: This function is only used internally. +-- It will call the **OnDisable** function on the addon object (if present), +-- and the **OnEmbedDisable** function on all embeded libraries.\\ +-- This function does not toggle the enable state of the addon itself, and will return early if the addon is still enabled. +-- +-- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing. +-- Use :Disable on the addon itself instead. +-- @param addon addon object to enable +function AceAddon:DisableAddon(addon) + if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end + if not self.statuses[addon.name] then return false end + + -- set statuses first before calling OnDisable, this allows for aborting the disable in OnDisable. + self.statuses[addon.name] = false + + safecall( addon.OnDisable, addon ) + + -- make sure we're still disabling... + if not self.statuses[addon.name] then + local embeds = self.embeds[addon] + for i = 1, #embeds do + local lib = LibStub:GetLibrary(embeds[i], true) + if lib then safecall(lib.OnEmbedDisable, lib, addon) end + end + -- disable possible modules. + local modules = addon.orderedModules + for i = 1, #modules do + self:DisableAddon(modules[i]) + end + end + + return not self.statuses[addon.name] -- return true if we're disabled +end + +--- Get an iterator over all registered addons. +-- @usage +-- -- Print a list of all installed AceAddon's +-- for name, addon in AceAddon:IterateAddons() do +-- print("Addon: " .. name) +-- end +function AceAddon:IterateAddons() return pairs(self.addons) end + +--- Get an iterator over the internal status registry. +-- @usage +-- -- Print a list of all enabled addons +-- for name, status in AceAddon:IterateAddonStatus() do +-- if status then +-- print("EnabledAddon: " .. name) +-- end +-- end +function AceAddon:IterateAddonStatus() return pairs(self.statuses) end + +-- Following Iterators are deprecated, and their addon specific versions should be used +-- e.g. addon:IterateEmbeds() instead of :IterateEmbedsOnAddon(addon) +function AceAddon:IterateEmbedsOnAddon(addon) return pairs(self.embeds[addon]) end +function AceAddon:IterateModulesOfAddon(addon) return pairs(addon.modules) end + +-- Blizzard AddOns which can load very early in the loading process and mess with Ace3 addon loading +local BlizzardEarlyLoadAddons = { + Blizzard_DebugTools = true, + Blizzard_TimeManager = true, + Blizzard_BattlefieldMap = true, + Blizzard_MapCanvas = true, + Blizzard_SharedMapDataProviders = true, + Blizzard_CombatLog = true, +} + +-- Event Handling +local function onEvent(this, event, arg1) + -- 2020-08-28 nevcairiel - ignore the load event of Blizzard addons which occur early in the loading process + if (event == "ADDON_LOADED" and (arg1 == nil or not BlizzardEarlyLoadAddons[arg1])) or event == "PLAYER_LOGIN" then + -- if a addon loads another addon, recursion could happen here, so we need to validate the table on every iteration + while(#AceAddon.initializequeue > 0) do + local addon = tremove(AceAddon.initializequeue, 1) + -- this might be an issue with recursion - TODO: validate + if event == "ADDON_LOADED" then addon.baseName = arg1 end + AceAddon:InitializeAddon(addon) + tinsert(AceAddon.enablequeue, addon) + end + + if IsLoggedIn() then + while(#AceAddon.enablequeue > 0) do + local addon = tremove(AceAddon.enablequeue, 1) + AceAddon:EnableAddon(addon) + end + end + end +end + +AceAddon.frame:RegisterEvent("ADDON_LOADED") +AceAddon.frame:RegisterEvent("PLAYER_LOGIN") +AceAddon.frame:SetScript("OnEvent", onEvent) + +-- upgrade embeded +for name, addon in pairs(AceAddon.addons) do + Embed(addon, true) +end + +-- 2010-10-27 nevcairiel - add new "orderedModules" table +if oldminor and oldminor < 10 then + for name, addon in pairs(AceAddon.addons) do + addon.orderedModules = {} + for module_name, module in pairs(addon.modules) do + tinsert(addon.orderedModules, module) + end + end +end diff --git a/Dominos/libs/AceAddon-3.0/AceAddon-3.0.xml b/Dominos/libs/AceAddon-3.0/AceAddon-3.0.xml new file mode 100644 index 00000000..e6ad639f --- /dev/null +++ b/Dominos/libs/AceAddon-3.0/AceAddon-3.0.xml @@ -0,0 +1,4 @@ + +