From bb6df3556c3e0297c9f85218278fac0f7acab98d Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Sun, 15 Nov 2026 00:49:58 -0600 Subject: [PATCH] feat(settings): retail Settings window, with Interface Options on top Ports retail's Blizzard_Settings_Shared (Settings, categories, canvas and vertical layouts, the setting controls, key binding rows, SettingsPanel, SettingsInbound) as the one options window. Addons of both eras land in it: newer addons register through the Settings API, and the 3.3.5 InterfaceOptions_AddCategory API (Ace3's AddToBlizOptions) now registers a canvas category. Its panel protocol maps onto the window's: okay on commit (Close, Apply, Escape), default and refresh where the window calls OnDefault / OnRefresh, cancel only when the window closes without a commit. A panel's name is its category ID, as Ace3 and newer addons set it. The old InterfaceOptionsFrame* names alias the window's frames so addons that restyle or overlay them keep working. ClassicAPI's own pages are vertical layouts of Settings controls (cvar and proxy settings, key binding rows, a ClassicAPI number box for settings that take any number), so the window's search finds them. They are the window's game categories, at the root of its first tab, which reads ClassicAPI; addons go on the AddOns tab. C_SettingsUtil.OpenSettingsPanel and NotifySettingsLoaded fire SETTINGS_PANEL_OPEN and SETTINGS_LOADED through the engine's event dispatcher (Event::Custom::FireValues), passing the category ID as given. Also: slider:SetEnabled, Enum.BindingSet, C_CVar.GetCVar / GetCVarDefault / RegisterCVar, C_KeyBindings.GetBindingIndex and its two context answers, and retail's CvarUtil, BindingUtil, MinimalSlider, DropdownWithSteppers and ColorPickerFrame:SetupColorPickerAndShow. Engine changes the window needs: - CVAR_UPDATE(cvarName, value) for every change of a cvar Lua can see, from a hook on CVar::Set (0x0063DF50). 1.12 fires CVAR_UPDATE only from Script_SetCVar with a caller's token. The change is queued and fired at the head of the next UI frame, never inside the setter: the engine sets cvars mid-way through its own work while a script runs further up the stack. - Script SetParent (0x007A1550) shows a frame that is shown under a visible parent, as 3.3.5's CSimpleFrame::SetParent does; 1.12's (0x0076AB10) re-shows only a frame that was visible before. The key binding rows move their buttons onto an input blocker and back after the blocker is hidden. - The child walks of the frame show (0x0076AE10) and hide (0x0076AD50) run on a copy of the child list and skip a child that has left. Each child runs its OnShow / OnHide inside the walk, and 1.12 (and 3.3.5, and 4.3.4) read the next node only afterwards, from a node a reparenting script may have freed. Auctionator's options page opens another page from its OnShow, and the window takes the first out of its canvas with SetParent(nil) while the canvas is being shown. 1.12 specifics in the port: - ToggleGameMenu() without an argument is the Escape handler and can SpellStopCasting or ClearTarget, so closing returns to the game menu through ShowUIPanel(GameMenuFrame). - StaticPopup_EscapePressed runs OnCancel(data, "clicked"), so button2 is always the dialogs' no-op choice. Only Turtle's StaticPopup has button3 / OnAlt; stock 1.12 shows two buttons. - The layout-cache reader (0x4905e0) replaces a movable or resizable frame's anchors and size from a saved record, so the window is neither: it has no drag or size handle. - A $parent name under an unnamed frame takes the nearest named ancestor's name, so pooled rows avoid templates that anchor slices by name (UIPanelButtonTemplate2, InputBoxTemplate). - GetChecked returns 1 or nil, GetBinding has no category, and GetBindingText is FrameXML Lua that needs the "KEY_" prefix. - The slider rounds every value to its step in single-precision floats, and the rounding does not settle, so a value set from a setting does not report back as a change. - Retail's Options and control atlases do not exist; the controls use 1.12's checkbox, slider, dropdown and spellbook page arrows, the frames the tooltip backdrop. Retail's strings are added in all eight locales. Not ported yet: the Keybindings category. --- README.md | 24 +- docs/API.md | 214 ++- docs/LuaCAPI.md | 12 +- src/Offsets.h | 19 + src/bindings/Api.cpp | 9 + src/cvar/Update.cpp | 134 ++ .../AddOns/!!!ClassicAPI/!!!ClassicAPI.toc | 38 +- src/embed/AddOns/!!!ClassicAPI/Compat.lua | 36 + .../!!!ClassicAPI/FrameXML/ButtonGroup.lua | 239 +++ .../FrameXML/ColorPickerFrame.lua | 42 + .../!!!ClassicAPI/FrameXML/FontStyles.xml | 22 + .../FrameXML/InterfaceOptions.lua | 486 ++---- .../FrameXML/InterfaceOptions.xml | 63 - .../!!!ClassicAPI/FrameXML/MinimalSlider.lua | 249 +++ .../!!!ClassicAPI/FrameXML/MinimalSlider.xml | 90 + .../!!!ClassicAPI/FrameXML/MinimalTab.lua | 75 + .../!!!ClassicAPI/FrameXML/MinimalTab.xml | 29 + .../FrameXML/SelectableButton.lua | 52 + .../FrameXML/SelectableButton.xml | 9 + .../FrameXML/SharedUIPanelTemplates.lua | 89 + .../FrameXML/SharedUIPanelTemplates.xml | 66 + .../!!!ClassicAPI/Menu/DropdownButton.lua | 20 +- src/embed/AddOns/!!!ClassicAPI/Menu/Menu.lua | 14 +- .../!!!ClassicAPI/Menu/MenuTemplates.lua | 94 +- .../!!!ClassicAPI/Menu/MenuTemplates.xml | 8 +- .../AddOns/!!!ClassicAPI/Menu/MenuUtil.lua | 8 + .../AddOns/!!!ClassicAPI/Options/Controls.lua | 69 + .../AddOns/!!!ClassicAPI/Options/Controls.xml | 50 + .../AddOns/!!!ClassicAPI/Options/Panel.lua | 794 +++------ .../Settings/Blizzard_Category.lua | 138 ++ .../Settings/Blizzard_CategoryList.lua | 483 ++++++ .../Settings/Blizzard_CategoryList.xml | 89 + .../Settings/Blizzard_Dialogs.lua | 57 + .../Settings/Blizzard_Keybindings.lua | 463 ++++++ .../Settings/Blizzard_Keybindings.xml | 88 + .../Settings/Blizzard_Registration.lua | 61 + .../Settings/Blizzard_Setting.lua | 447 +++++ .../Settings/Blizzard_SettingControls.lua | 1452 +++++++++++++++++ .../Settings/Blizzard_SettingControls.xml | 221 +++ .../Settings/Blizzard_Settings.lua | 728 +++++++++ .../Settings/Blizzard_SettingsInbound.lua | 284 ++++ .../Settings/Blizzard_SettingsLayouts.lua | 85 + .../Settings/Blizzard_SettingsList.lua | 160 ++ .../Settings/Blizzard_SettingsList.xml | 81 + .../Settings/Blizzard_SettingsPanel.lua | 922 +++++++++++ .../Settings/Blizzard_SettingsPanel.xml | 127 ++ .../Blizzard_SettingsPanelTemplates.xml | 55 + .../Settings/Blizzard_SettingsRegistrar.lua | 35 + .../!!!ClassicAPI/Util/ActionButton.lua | 8 + .../AddOns/!!!ClassicAPI/Util/BindingUtil.lua | 206 +++ .../AddOns/!!!ClassicAPI/Util/CvarUtil.lua | 259 +++ src/embed/AddOns/!!!ClassicAPI/Util/Mixin.lua | 8 + .../AddOns/!!!ClassicAPI/locales/deDE.lua | 25 + .../AddOns/!!!ClassicAPI/locales/enUS.lua | 26 +- .../AddOns/!!!ClassicAPI/locales/esES.lua | 25 + .../AddOns/!!!ClassicAPI/locales/frFR.lua | 25 + .../AddOns/!!!ClassicAPI/locales/koKR.lua | 25 + .../AddOns/!!!ClassicAPI/locales/ruRU.lua | 26 +- .../AddOns/!!!ClassicAPI/locales/zhCN.lua | 26 +- .../AddOns/!!!ClassicAPI/locales/zhTW.lua | 25 + src/frame/ChildWalk.cpp | 128 ++ src/frame/ParentVisibility.cpp | 69 + src/settings/Panel.cpp | 88 + src/slider/Enable.cpp | 17 +- 64 files changed, 8985 insertions(+), 1031 deletions(-) create mode 100644 src/cvar/Update.cpp create mode 100644 src/embed/AddOns/!!!ClassicAPI/FrameXML/ButtonGroup.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/FrameXML/ColorPickerFrame.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/FrameXML/FontStyles.xml delete mode 100644 src/embed/AddOns/!!!ClassicAPI/FrameXML/InterfaceOptions.xml create mode 100644 src/embed/AddOns/!!!ClassicAPI/FrameXML/MinimalSlider.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/FrameXML/MinimalSlider.xml create mode 100644 src/embed/AddOns/!!!ClassicAPI/FrameXML/MinimalTab.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/FrameXML/MinimalTab.xml create mode 100644 src/embed/AddOns/!!!ClassicAPI/FrameXML/SelectableButton.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/FrameXML/SelectableButton.xml create mode 100644 src/embed/AddOns/!!!ClassicAPI/Options/Controls.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/Options/Controls.xml create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_Category.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_CategoryList.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_CategoryList.xml create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_Dialogs.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_Keybindings.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_Keybindings.xml create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_Registration.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_Setting.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_SettingControls.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_SettingControls.xml create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_Settings.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_SettingsInbound.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_SettingsLayouts.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_SettingsList.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_SettingsList.xml create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_SettingsPanel.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_SettingsPanel.xml create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_SettingsPanelTemplates.xml create mode 100644 src/embed/AddOns/!!!ClassicAPI/Settings/Blizzard_SettingsRegistrar.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/Util/BindingUtil.lua create mode 100644 src/embed/AddOns/!!!ClassicAPI/Util/CvarUtil.lua create mode 100644 src/frame/ChildWalk.cpp create mode 100644 src/frame/ParentVisibility.cpp create mode 100644 src/settings/Panel.cpp diff --git a/README.md b/README.md index 2ce7ff1c..3d183428 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ In the Frame rows, a name that starts with `:` is a method of the widget that th | [Animation](docs/API.md#animation) | `region:CreateAnimationGroup`, `region:GetAnimationGroups`, `region:StopAnimating`, `SetMaxAnimFramerate`, `GetMaxAnimFramerate`, `AnimationGroup` and `Animation` / `Alpha` / `Translation` / `Scale` / `Rotation` / `Path` / `ControlPoint` methods | | [AuctionHouse](docs/API.md#auctionhouse) | `C_AuctionHouse.PostItem`, `CanCancelAuction` | | [AutoComplete](docs/API.md#autocomplete) | `C_AutoComplete.GetAutoCompleteResults`, `C_AutoComplete.IsRecognizedName`, `C_AutoComplete.GetAutoCompletePresenceID`, `C_AutoComplete.GetAutoCompleteRealms` | -| [Bindings](docs/API.md#bindings) | `SetBindingSpell`, `SetBindingItem`, `SetBindingMacro`, `SetBindingClick`, `SetOverrideBinding`, `SetOverrideBindingSpell`, `SetOverrideBindingItem`, `SetOverrideBindingMacro`, `SetOverrideBindingClick`, `ClearOverrideBindings`, `GetBindingAction` (`checkOverride`), `GetBindingByKey`, `IsModifiedClick`, `GetModifiedClick`, `SetModifiedClick`, `GetNumModifiedClickActions`, `GetModifiedClickAction` | +| [Bindings](docs/API.md#bindings) | `SetBindingSpell`, `SetBindingItem`, `SetBindingMacro`, `SetBindingClick`, `SetOverrideBinding`, `SetOverrideBindingSpell`, `SetOverrideBindingItem`, `SetOverrideBindingMacro`, `SetOverrideBindingClick`, `ClearOverrideBindings`, `GetBindingAction` (`checkOverride`), `GetBindingByKey`, `IsModifiedClick`, `GetModifiedClick`, `SetModifiedClick`, `GetNumModifiedClickActions`, `GetModifiedClickAction`, `C_KeyBindings.GetBindingIndex`, `C_KeyBindings.GetBindingContextForAction`, `C_KeyBindings.GetCustomBindingType` | | [Chat](docs/API.md#chat) | `GetCurrentChatEvent`, `GetCurrentChatGUID`, `IsChatAFK`, `IsChatDND`, `SendSystemMessage` | | [ChatBubbles](docs/API.md#chatbubbles) | `C_ChatBubbles.GetAllChatBubbles` | | [Class](docs/API.md#class) | `FillLocalizedClassList` | @@ -68,7 +68,7 @@ In the Frame rows, a name that starts with `:` is a method of the widget that th | [Combat](docs/API.md#combat) | `InCombatLockdown`, `StartAttack`, `StopAttack` | | [CombatLog](docs/API.md#combatlog) | `CombatLogGetCurrentEventInfo`, `COMBATLOG_OBJECT_*` (constants) | | [Console](docs/API.md#console) | `CalculateStringEditDistance`, `ConsoleAddMessage`, `ConsoleEcho`, `ConsoleExec`, `ConsoleGetAllCommands`, `ConsoleGetColorFromType`, `ConsoleGetFontHeight`, `ConsoleIsActive`, `ConsolePrintAllMatchingCommands`, `SetConsoleKey` | -| [CVar](docs/API.md#cvar) | `C_CVar.AreCVarsLoaded`, `C_CVar.DoesCVarExist`, `C_CVar.GetCVarBitfield`, `C_CVar.GetCVarBool`, `C_CVar.GetCVarInfo`, `C_CVar.RemoveTempCVar`, `C_CVar.SetCVar`, `C_CVar.SetCVarBitfield`, `C_CVar.SetTempCVar`, `GetCVar`, `GetCVarDefault` | +| [CVar](docs/API.md#cvar) | `C_CVar.AreCVarsLoaded`, `C_CVar.DoesCVarExist`, `C_CVar.GetCVar`, `C_CVar.GetCVarBitfield`, `C_CVar.GetCVarBool`, `C_CVar.GetCVarDefault`, `C_CVar.GetCVarInfo`, `C_CVar.RegisterCVar`, `C_CVar.RemoveTempCVar`, `C_CVar.SetCVar`, `C_CVar.SetCVarBitfield`, `C_CVar.SetTempCVar`, `GetCVar`, `GetCVarDefault` | | [Cursor](docs/API.md#cursor) | `CursorHasMacro`, `GetCursorInfo` | | [Container](docs/API.md#container) | `C_Container.AutoStoreItem`, `C_Container.CalculateTotalNumberOfFreeBagSlots`, `C_Container.GetContainerItemCharges`, `C_Container.GetContainerItemDurability`, `C_Container.GetContainerItemID`, `C_Container.GetContainerItemInfo`, `C_Container.GetContainerItemEquipmentSetInfo`, `C_Container.GetContainerItemQuestInfo`, `C_Container.GetContainerItemRepairCost`, `C_Container.GetContainerFreeSlots`, `C_Container.GetContainerNumFreeSlots`, `C_Container.GetBackpackAutosortDisabled`, `C_Container.GetBankAutosortDisabled`, `C_Container.GetItemCooldown`, `C_Container.GetSortBagsRightToLeft`, `C_Container.HasContainerItem`, `C_Container.IsContainerFiltered`, `C_Container.IsContainerItemOpenable`, `C_Container.MoveItem`, `C_Container.PlayerHasHearthstone`, `C_Container.SetBackpackAutosortDisabled`, `C_Container.SetBagPortraitTexture`, `C_Container.SetBankAutosortDisabled`, `C_Container.SetItemSearch`, `C_Container.SetSortBagsRightToLeft`, `C_Container.SortBags`, `C_Container.SortBankBags`, `C_Container.SwapItems`, `C_Container.UseHearthstone`, `GetItemCooldown`, `SetBagPortraitTexture` | | [Creature](docs/API.md#creature) | `C_CreatureInfo.GetCreatureID`, `C_CreatureInfo.GetCreatureInfoByID`, `C_CreatureInfo.RequestLoadCreatureByID`, `C_CreatureInfo.GetRaceInfo`, `C_CreatureInfo.GetClassInfo`, `C_CreatureInfo.GetCreatureFamilyInfo`, `C_CreatureInfo.GetCreatureFamilyIDs`, `C_CreatureInfo.GetFactionInfo`, `C_CreatureInfo.GetCreatureTypeInfo`, `C_CreatureInfo.GetCreatureTypeIDs` | @@ -88,7 +88,7 @@ In the Frame rows, a name that starts with `:` is a method of the widget that th | [Frame: Texture](docs/API.md#texturesetrotationangle--cx-cy) | `:SetRotation` / `:GetRotation`, `:SetVertexOffset` / `:GetVertexOffset`, `:SetColorTexture`, `:SetAtlas` / `:GetAtlas`, `:ResetTexCoord`, `:SetSpriteSheetCell`, `:SetTexture` wrap modes, `:SetHorizTile` / `:GetHorizTile`, `:SetVertTile` / `:GetVertTile`, `:SetDesaturation` / `:GetDesaturation`, `IsDesaturateSupported`, `:SetMask`, `frame:CreateMaskTexture`, `:AddMaskTexture` / `:RemoveMaskTexture`, `:GetNumMaskTextures`, `:GetMaskTexture` | | [Frame: EditBox](docs/API.md#editboxsetcursorpositionposition) | `:SetCursorPosition` / `:GetCursorPosition`, `:GetUTF8CursorPosition`, `:ClearHighlightText`, `:SetHighlightColor` / `:GetHighlightColor`, `:HasFocus`, `GetCurrentKeyBoardFocus`, `:HasText`, `:ClearHistory`, `:Enable` / `:Disable` / `:IsEnabled`, `:SetCountInvisibleLetters` / `:IsCountInvisibleLetters`, `:IsInIMECompositionMode` | | [Frame: StatusBar](docs/API.md#statusbarsetreversefillisreversefill--statusbargetreversefill) | `:SetReverseFill` / `:GetReverseFill`, `:SetRotatesTexture` / `:GetRotatesTexture`, `:SetFillStyle` / `:GetFillStyle`, `:SetColorFill`, `:SetStatusBarDesaturated` / `:IsStatusBarDesaturated`, `:SetStatusBarDesaturation` / `:GetStatusBarDesaturation`, `:SetTimerDuration` / `:GetTimerDuration`, `:SetValue` / `:SetMinMaxValues` with `interpolation`, `:GetInterpolatedValue`, `:IsInterpolating`, `:SetToTargetValue` | -| [Frame: Slider](docs/API.md#sliderenable--sliderdisable--sliderisenabled) | `:Enable` / `:Disable` / `:IsEnabled` | +| [Frame: Slider](docs/API.md#sliderenable--sliderdisable--slidersetenabledenabled--sliderisenabled) | `:Enable` / `:Disable` / `:SetEnabled` / `:IsEnabled` | | [Frame: Cooldown](docs/API.md#createframecooldown--name-parent-template) | `CreateFrame("Cooldown")`, `:SetCooldown`, `:SetCooldownDuration`, `:SetCooldownFromExpirationTime`, `:Clear`, `:GetCooldownTimes`, `:GetCooldownDuration`, `:GetCooldownDisplayDuration`, `:Pause` / `:Resume`, `:SetPaused` / `:IsPaused`, `:SetReverse` / `:GetReverse`, `:SetDrawEdge` / `:GetDrawEdge`, `:SetDrawSwipe` / `:GetDrawSwipe`, `:SetDrawBling` / `:GetDrawBling`, `:SetSwipeColor`, `:SetEdgeColor`, `:SetSwipeTexture`, `:SetEdgeTexture`, `:SetBlingTexture`, `:SetRotation` / `:GetRotation`, `:SetHideCountdownNumbers` / `:GetHideCountdownNumbers`, `:GetCountdownFontString`, `:SetCountdownAbbrevThreshold` / `:GetCountdownAbbrevThreshold`, `:SetCountdownMillisecondsThreshold` / `:GetCountdownMillisecondsThreshold`, `:SetMinimumCountdownDuration` / `:GetMinimumCountdownDuration`, `OnCooldownDone`, `CooldownFrame_Set`, `CooldownFrame_Clear`, `CooldownFrame_SetDisplayAsPercentage` | | [Frame: ModelScene](docs/API.md#modelscene) | `CreateFrame("ModelScene")`, `` (`drawLayer`, `fogNear`, `fogFar`, ``, ``), `:CreateActor`, `:GetNumActors`, `:GetActorAtIndex`, `:SetCameraPosition` / `:GetCameraPosition`, `:SetCameraOrientationByYawPitchRoll`, `:SetCameraOrientationByAxisVectors`, `:GetCameraForward`, `:GetCameraRight`, `:GetCameraUp`, `:SetCameraFieldOfView` / `:GetCameraFieldOfView`, `:SetCameraNearClip` / `:GetCameraNearClip`, `:SetCameraFarClip` / `:GetCameraFarClip`, `:SetViewInsets` / `:GetViewInsets`, `:SetViewTranslation` / `:GetViewTranslation`, `:Project3DPointTo2D`, `"FollowCamera"` (`:SetFollowActor` / `:GetFollowActor`), `:SetLightType` / `:GetLightType`, `:SetLightVisible` / `:IsLightVisible`, `:SetLightDirection` / `:GetLightDirection`, `:SetLightPosition` / `:GetLightPosition`, `:SetLightAmbientColor` / `:GetLightAmbientColor`, `:SetLightDiffuseColor` / `:GetLightDiffuseColor`, `:SetFogColor` / `:GetFogColor`, `:SetFogNear` / `:GetFogNear`, `:SetFogFar` / `:GetFogFar`, `:ClearFog`, `:SetDrawLayer` / `:GetDrawLayer`, `:SetPaused`, `:GetSceneTime`, `:After`, `:NewTimer`, `:NewTicker`, `:SetAllowOverlappedModels` / `:GetAllowOverlappedModels`, `:SetGroundTerrain` / `:GetGroundTerrain`, `:SetWorldModel`, `:SetWorldModelByMapID`, `:ClearWorldModel`, `:SetWorldTerrain`, `:ClearWorldTerrain`, `:SetPlayWorldModelSounds` / `:GetPlayWorldModelSounds`, `:TraceSegment`, `:GetLiquidAtPoint`, `:SweepCollider`, `:SetSoundListenerActor` / `:GetSoundListenerActor`, `:GetActorAtCursor`, `:GetCursorRay`, `:GetActorsInRadius`, `:SetMoveMarker` / `:ClearMoveMarker` / `:GetMoveMarker`, `OnActorEnter` / `OnActorLeave` | | [Frame: ModelSceneActor](docs/API.md#actorsetmodelbycreaturedisplayiddisplayid--useactiveplayercustomizations) | `:SetModelByCreatureDisplayID`, `:SetModelByPath`, `:SetModelByUnit`, `:SetModelByUnitCreatureDisplayID`, `:GetModelUnitGUID`, `:Dress`, `:Undress`, `:UndressSlot`, `:TryOn`, `:DressPlayerSlot`, `:IsSlotAllowed` / `:IsSlotVisible`, `:GetItemTransmogInfo`, `:GetItemTransmogInfoList`, `:SetItemTransmogInfo`, `:SetSheathed` / `:GetSheathed`, `:SetSheathedCategory`, `:UseUnitSheatheCategory`, `:SetAutoDress` / `:GetAutoDress`, `:IsGeoReady`, `:ClearModel`, `:IsLoaded`, `:GetModelPath`, `:SetPosition` / `:GetPosition`, `:SetYaw` / `:GetYaw`, `:SetPitch` / `:GetPitch`, `:SetRoll` / `:GetRoll`, `:SetScale` / `:GetScale`, `:SetUseCenterForOrigin` / `:IsUsingCenterForOrigin`, `:GetActiveBoundingBox`, `:GetMaxBoundingBox`, `:Show` / `:Hide` / `:SetShown` / `:IsShown` / `:IsVisible`, `:SetAlpha` / `:GetAlpha`, `:SetAnimation` / `:GetAnimation`, `:GetAnimationVariation`, `:SetAnimationBlendOperation` / `:GetAnimationBlendOperation`, `:SetPaused` / `:GetPaused`, `:SetSpellVisualKit` / `:GetSpellVisualKit`, `:ApplySpellVisualKit`, `:PlayAnimationKit` / `:StopAnimationKit`, `:AttachToMount`, `:DetachFromMount`, `:CalculateMountScale`, `:GetAttachmentPosition`, `:AttachToActor`, `:DetachFromActor`, `:PlaySpellVisual`, `:StopSpellVisual`, `:PlaySound`, `:SetPlayAnimationSounds` / `:GetPlayAnimationSounds`, `:SetShadowShown` / `:IsShadowShown`, `:SetHighlight` / `:IsHighlighted`, `:SetSelectionCircle` / `:ClearSelectionCircle` / `:GetSelectionCircle`, `:SetNameText` / `:ClearNameText` / `:GetNameText`, `:GetNamePosition`, `:SetMovementEnabled` / `:IsMovementEnabled`, `:StartMovingForward`, `:StartMovingBackward`, `:StopMoving`, `:StartStrafingLeft`, `:StartStrafingRight`, `:StopStrafing`, `:StartTurningLeft`, `:StartTurningRight`, `:StopTurning`, `:Jump`, `:StartPitchingUp`, `:StartPitchingDown`, `:StopPitching`, `:IsFalling`, `:IsSwimming`, `:MoveTo`, `:SetWalking` / `:IsWalking`, `:GetCameraPivotHeight`, `OnLoad`, `OnUpdate`, `OnModelLoading`, `OnModelLoaded`, `OnModelCleared`, `OnAnimFinished`, `OnSpellVisualImpact`, `OnMoveFinished`, `` templates | @@ -127,6 +127,7 @@ In the Frame rows, a name that starts with `:` is a method of the widget that th | [PlayerInfo](docs/API.md#playerinfo) | `C_PlayerInfo.CanUseItem`, `C_PlayerInfo.GetClass`, `C_PlayerInfo.GetName`, `C_PlayerInfo.GetRace`, `C_PlayerInfo.GetSex`, `C_PlayerInfo.GUIDIsCreature`, `C_PlayerInfo.GUIDIsGameObject`, `C_PlayerInfo.GUIDIsPet`, `C_PlayerInfo.GUIDIsPlayer`, `C_PlayerInfo.IsConnected` | | [Profiling](docs/API.md#profiling) | `GetAddOnCPUUsage`, `GetAddOnMemoryUsage`, `GetEventCPUUsage`, `GetFrameCPUUsage`, `GetFunctionCPUUsage`, `GetScriptCPUUsage`, `ResetCPUUsage`, `UpdateAddOnCPUUsage`, `UpdateAddOnMemoryUsage` | | [Quest](docs/API.md#quest) | `C_QuestLog.GetInfo`, `C_QuestLog.GetNumQuestObjectives`, `C_QuestLog.GetQuestDetails`, `C_QuestLog.GetQuestLogTitle`, `C_QuestLog.GetHeaderIndexForQuest`, `C_QuestLog.GetLogIndexForQuestID`, `C_QuestLog.GetQuestIDForLogIndex`, `C_QuestLog.GetTitleForQuestID`, `C_QuestLog.IsOnQuest`, `C_QuestLog.IsQuestDataCachedByID`, `C_QuestLog.IsUnitOnQuest`, `C_QuestLog.RequestLoadQuestByID`, `GetQuestLogCompletionText`, `GetQuestLogLeaderBoardID` (Turtle WoW only: `C_QuestLog.GetAllCompletedQuestIDs`, `C_QuestLog.IsQuestFlaggedCompleted`, `GetQuestsCompleted`, `QueryQuestsCompleted`) | +| [SettingsUtil](docs/API.md#settingsutil) | `C_SettingsUtil.NotifySettingsLoaded`, `C_SettingsUtil.OpenSettingsPanel` | | [Sound](docs/API.md#sound) | `C_Sound.GetRecentSoundFiles`, `C_Sound.GetSoundScaledVolume`, `C_Sound.IsPlaying`, `C_Sound.PlayItemSound`, `C_Sound.PlaySound`, `C_Sound.PlaySoundWithOptions`, `C_Sound.PlayVocalErrorSound`, `MuteSoundFile`, `PlaySound`, `PlaySoundFile`, `StopSound`, `UnmuteSoundFile` | | [Spell](docs/API.md#spell) | `C_Spell.CancelSpellByID`, `C_Spell.CastAtCursor`, `C_Spell.CastAtUnit`, `C_Spell.CastingInfo`, `C_Spell.ChannelInfo`, `C_Spell.DoesSpellExist`, `C_Spell.GetSchoolString`, `C_Spell.GetSpellCastCount`, `C_Spell.GetSpellCooldown`, `C_Spell.GetSpellDescription`, `C_Spell.GetSpellDispelType`, `C_Spell.GetSpellEffectInfo`, `C_Spell.GetSpellEffectMechanics`, `C_Spell.GetSpellInfo`, `C_Spell.GetSpellLevelInfo`, `C_Spell.GetSpellLink`, `C_Spell.GetSpellLossOfControlCooldown`, `C_Spell.GetSpellMechanicByID`, `C_Spell.GetSpellName`, `C_Spell.GetSpellPowerCost`, `C_Spell.GetSpellRadius`, `C_Spell.GetSpellReagents`, `C_Spell.GetSpellRequiredTargetLevel`, `C_Spell.GetSpellSubtext`, `C_Spell.GetSpellTexture`, `C_Spell.IsAutoAttackSpell`, `C_Spell.IsCurrentSpell`, `C_Spell.IsNextMeleeSpell`, `C_Spell.IsRangedAutoAttackSpell`, `C_Spell.IsSelfBuff`, `C_Spell.IsSpellHarmful`, `C_Spell.IsSpellHelpful`, `C_Spell.IsSpellInRange`, `C_Spell.IsSpellPassive`, `C_Spell.IsSpellUsable`, `C_Spell.ResetsMeleeSwing`, `C_Spell.SpellHasRange`, `C_Spell.UnitCastingInfo`, `C_Spell.UnitChannelInfo`, `CanDualWield`, `CancelSpellByName`, `CancelUnitBuff`, `CastSpellByID`, `CastSpellNoToggle`, `GetCraftSpellID`, `GetCritChance`, `GetRangedCritChance`, `GetSpellBaseCooldown`, `GetSpellBonusDamage`, `GetSpellBonusHealing`, `GetSpellInfo`, `GetSpellLink`, `GetSpellRadius`, `GetSpellRequiredTargetLevel`, `GetSpellSchool`, `IsAttackSpell`, `IsAutoRepeatSpell`, `IsConsumableSpell`, `IsHarmfulSpell`, `IsHelpfulSpell`, `IsPassiveSpell`, `IsPlayerSpell`, `IsSpellKnown`, `IsUsableSpell`, `SpellHasRange`, `UnitCastingDuration`, `UnitChannelDuration` | | [SpellActivationOverlay](docs/API.md#spellactivationoverlay) | `C_SpellActivationOverlay.IsSpellOverlayed`, `IsSpellOverlayed` | @@ -219,7 +220,8 @@ for what each command does, and Each setting is saved in `WTF\Config.wtf`. Read and write them with `GetCVar` / `SetCVar` or `/console`. Click a group name for the full rules. To change these settings, the player cache and the ClassicAPI key bindings in the game, -open the game menu and click AddOn Options, then ClassicAPI. +open the game menu and click AddOn Options. The Settings window opens on +its ClassicAPI tab. | Group | CVar | Default | What it does | |-------|------|---------|--------------| @@ -296,6 +298,7 @@ when launching with `-console`), not as Lua functions. See the | `COMBAT_LOG_EVENT` | `timestamp, subevent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...` ([details](docs/API.md#combat_log_event_unfiltered--combat_log_event-events)) | | `COMBAT_LOG_EVENT_UNFILTERED` | same as `COMBAT_LOG_EVENT` | | `CURSOR_CHANGED` | `isDefault, newCursorType, oldCursorType, oldCursorVirtualID` | +| `CVAR_UPDATE` | `cvarName, value` — fires for every cvar change ([details](docs/API.md#cvar_update-event-fires-for-every-change)) | | `DYNAMIC_GOSSIP_POI_UPDATED` | *(none)* | | `EQUIPMENT_SETS_CHANGED` | *(none)* | | `EQUIPMENT_SWAP_PENDING` | `setID` | @@ -340,6 +343,8 @@ when launching with `-console`), not as Lua functions. See the | `QUEST_REMOVED` | `questID` | | `QUEST_TURNED_IN` | `questID, xpReward, moneyReward` | | `SELF_RES_SPELL_CHANGED` | *(none)* | +| `SETTINGS_LOADED` | *(none)* | +| `SETTINGS_PANEL_OPEN` | `openToCategoryID, scrollToElementName` | | `SOUNDKIT_FINISHED` | `soundHandle` (only for sounds played with `runFinishCallback`) | | `SPELL_ACTIVATION_OVERLAY_SHOW` | `spellID, texture, locationType, scale, r, g, b` ([details](docs/API.md#spell_activation_overlay_show--spell_activation_overlay_hide-events)) | | `SPELL_ACTIVATION_OVERLAY_HIDE` | `spellID` (`nil` hides every alert) | @@ -395,6 +400,7 @@ when launching with `-console`), not as Lua functions. See the | Item quality | `LE_ITEM_QUALITY_POOR` … `LE_ITEM_QUALITY_WOWTOKEN` | | Unit stat | `LE_UNIT_STAT_STRENGTH` … `LE_UNIT_STAT_SPIRIT` | | Addon security | `Enum.AddOnSecurityStatus.{Secure,Insecure,Banned,NotAvailable}` | +| Binding set | `Enum.BindingSet.{Default,Account,Character,Current}` (0–3) | | Power type | `Enum.PowerType.{HealthCost,None,Mana,Rage,Focus,Energy,Happiness}` | | Inventory type | `Enum.InventoryType.Index*Type` (0–34, e.g. `IndexHeadType`=1 … `IndexRelicType`=28) | | Item class | `Enum.ItemClass.{Consumable,Container,Weapon,Gem,Armor,Reagent,Projectile,Tradegoods,ItemEnhancement,Recipe,Quiver,Questitem,Key,Miscellaneous,…}` (0–19) | @@ -480,11 +486,13 @@ functions but that consumer code still expects to find as globals — (`ContinueOnAddOnLoaded` and more), `FormattingUtil` (`GetMoneyString`, `FormatLargeNumber` and more), `FrameUtil`, `DataProvider`, `CircularBuffer`, `EasingUtil`, `ScriptAnimationUtil`, `Interpolator`, `EnumUtil`, `StringUtil`, `AnchorUtil`, -`GridLayoutUtil`, and the layout frame templates (`VerticalLayoutFrame`, +`GridLayoutUtil`, the layout frame templates (`VerticalLayoutFrame`, `HorizontalLayoutFrame`, `ResizeLayoutFrame`, `GridLayoutFrame`, -`StaticGridLayoutFrame`). It also holds the conditional slash -commands and `SecureCmdOptionParse`, the parser that reads `[conditions]` -and `@unit` for them. +`StaticGridLayoutFrame`), and the retail Settings window (`Settings`, +`SettingsPanel`) with the `InterfaceOptions_AddCategory` functions on +top. It also holds the conditional slash commands and +`SecureCmdOptionParse`, the parser that reads `[conditions]` and `@unit` +for them. **You don't have to install the addon manually** — the DLL embeds the contents of [`src/embed/AddOns/!!!ClassicAPI/`](src/embed/AddOns/!!!ClassicAPI/) and diff --git a/docs/API.md b/docs/API.md index 3e97d14b..19a7e5a0 100644 --- a/docs/API.md +++ b/docs/API.md @@ -83,6 +83,9 @@ build instructions. - [Function keys F13 to F24](#function-keys-f13-to-f24) - [Modified clicks](#modified-clicks) - [`ActionButtonUseKeyDown`](#actionbuttonusekeydown) + - [`Enum.BindingSet`](#enumbindingset) + - [`C_KeyBindings.GetBindingIndex(action)`](#c_keybindingsgetbindingindexaction) + - [`C_KeyBindings.GetBindingContextForAction(action)` / `C_KeyBindings.GetCustomBindingType(bindingIndex)`](#c_keybindingsgetbindingcontextforactionaction--c_keybindingsgetcustombindingtypebindingindex) - [CharacterList](#characterlist) - [`GetSavedCharacterOrder(realm)` / `SetSavedCharacterOrder(realm, order)` — GlueXML only](#getsavedcharacterorderrealm--setsavedcharacterorderrealm-order--gluexml-only) @@ -200,6 +203,7 @@ build instructions. - [CVar](#cvar) - [`GetCVar(name)`](#getcvarname) - [`GetCVarDefault(name)`](#getcvardefaultname) + - [`C_CVar.GetCVar(name)` / `C_CVar.GetCVarDefault(name)` / `C_CVar.RegisterCVar(name [, value])`](#c_cvargetcvarname--c_cvargetcvardefaultname--c_cvarregistercvarname--value) - [`C_CVar.SetCVar(name [, value])`](#c_cvarsetcvarname--value) - [`C_CVar.GetCVarInfo(name)`](#c_cvargetcvarinfoname) - [`C_CVar.DoesCVarExist(name)`](#c_cvardoescvarexistname) @@ -255,6 +259,7 @@ build instructions. - [`ACTION_USABLE_CHANGED` event](#action_usable_changed-event) - [`COMBAT_LOG_EVENT_UNFILTERED` / `COMBAT_LOG_EVENT` events](#combat_log_event_unfiltered--combat_log_event-events) - [`CURSOR_CHANGED` event](#cursor_changed-event) + - [`CVAR_UPDATE` event (fires for every change)](#cvar_update-event-fires-for-every-change) - [`EQUIPMENT_SETS_CHANGED` event](#equipment_sets_changed-event) - [`EQUIPMENT_SWAP_PENDING` event](#equipment_swap_pending-event) - [`EQUIPMENT_SWAP_FINISHED` event](#equipment_swap_finished-event) @@ -281,6 +286,8 @@ build instructions. - [`QUEST_REMOVED` event](#quest_removed-event) - [`QUEST_TURNED_IN` event](#quest_turned_in-event) - [`SELF_RES_SPELL_CHANGED` event](#self_res_spell_changed-event) + - [`SETTINGS_LOADED` event](#settings_loaded-event) + - [`SETTINGS_PANEL_OPEN` event](#settings_panel_open-event) - [`SOUNDKIT_FINISHED` event](#soundkit_finished-event) - [`SPELL_ACTIVATION_OVERLAY_SHOW` / `SPELL_ACTIVATION_OVERLAY_HIDE` events](#spell_activation_overlay_show--spell_activation_overlay_hide-events) - [`SPELL_ACTIVATION_OVERLAY_GLOW_SHOW` / `SPELL_ACTIVATION_OVERLAY_GLOW_HIDE` events](#spell_activation_overlay_glow_show--spell_activation_overlay_glow_hide-events) @@ -355,6 +362,8 @@ build instructions. - [`CreateFrame("Cooldown" [, name, parent, template])`](#createframecooldown--name-parent-template) - [`frame:SetShown(shown)`](#framesetshownshown) - [A frame moved to a new parent takes its children along](#a-frame-moved-to-a-new-parent-takes-its-children-along) + - [A shown frame moved under a visible parent becomes visible](#a-shown-frame-moved-under-a-visible-parent-becomes-visible) + - [`OnShow` and `OnHide` can move frames](#onshow-and-onhide-can-move-frames) - [A ScrollFrame keeps clipping its content when it moves](#a-scrollframe-keeps-clipping-its-content-when-it-moves) - [`fontstring:GetStringHeight()`](#fontstringgetstringheight) - [`fontstring:GetUnboundedStringWidth()`](#fontstringgetunboundedstringwidth) @@ -402,7 +411,7 @@ build instructions. - [`editBox:SetCountInvisibleLetters(count)` / `editBox:IsCountInvisibleLetters()`](#editboxsetcountinvisibleletterscount--editboxiscountinvisibleletters) - [`editBox:ClearHistory()`](#editboxclearhistory) - [`editBox:Enable()` / `editBox:Disable()` / `editBox:IsEnabled()`](#editboxenable--editboxdisable--editboxisenabled) - - [`slider:Enable()` / `slider:Disable()` / `slider:IsEnabled()`](#sliderenable--sliderdisable--sliderisenabled) + - [`slider:Enable()` / `slider:Disable()` / `slider:SetEnabled(enabled)` / `slider:IsEnabled()`](#sliderenable--sliderdisable--slidersetenabledenabled--sliderisenabled) - [`OnEnable` and `OnDisable` (scripts)](#onenable-and-ondisable-scripts) - [`OnMinMaxChanged(self, min, max)` (script)](#onminmaxchangedself-min-max-script) - [`statusBar:SetReverseFill(isReverseFill)` / `statusBar:GetReverseFill()`](#statusbarsetreversefillisreversefill--statusbargetreversefill) @@ -1016,6 +1025,10 @@ build instructions. - [`C_QuestLog.GetAllCompletedQuestIDs()`](#c_questloggetallcompletedquestids) - [A turn-in always prints "*quest* completed."](#a-turn-in-always-prints-quest-completed) +- [SettingsUtil](#settingsutil) + - [`C_SettingsUtil.OpenSettingsPanel([openToCategoryID [, scrollToElementName]])`](#c_settingsutilopensettingspanelopentocategoryid--scrolltoelementname) + - [`C_SettingsUtil.NotifySettingsLoaded()`](#c_settingsutilnotifysettingsloaded) + - [Sound](#sound) - [`PlaySound(soundKitID)` / `PlaySound(soundName)`](#playsoundsoundkitid--playsoundsoundname) - [`C_Sound.PlaySound(soundKitID [, channel, forceNoDuplicates, runFinishCallback])`](#c_soundplaysoundsoundkitid--channel-forcenoduplicates-runfinishcallback) @@ -2846,6 +2859,36 @@ common in PvP / heal-tank-while-killing-add scenarios. The two bindings show in the TARGETING block of the keybind list, not at the bottom. + +### `Enum.BindingSet` + +The sets of key bindings, for `LoadBindings`, `SaveBindings` and +`GetCurrentBindingSet`. + +| Field | Value | +|---|---| +| `Default` | 0 | +| `Account` | 1 | +| `Character` | 2 | +| `Current` | 3 | + +`GetCurrentBindingSet()` returns `Account` or `Character`. + +### `C_KeyBindings.GetBindingIndex(action)` + +Returns the index of the binding for `action`, the index that +`GetBinding(index)` takes. Returns `nil` when no binding has that action. + +```lua +local index = C_KeyBindings.GetBindingIndex("INTERACTTARGET") +local action, key1, key2 = GetBinding(index) +``` + +### `C_KeyBindings.GetBindingContextForAction(action)` / `C_KeyBindings.GetCustomBindingType(bindingIndex)` + +Both functions return `nil`. The client has one set of key bindings for all +actions, so no action has a binding context of its own. The client has no +custom binding types. ## CharacterList ### `GetSavedCharacterOrder(realm)` / `SetSavedCharacterOrder(realm, order)` — GlueXML only @@ -4996,6 +5039,12 @@ it returns no values. If `name` is not a string or a number, `GetCVarDefault` raises an error. `GetCVarDefault` works the same way on the glue screens. +### `C_CVar.GetCVar(name)` / `C_CVar.GetCVarDefault(name)` / `C_CVar.RegisterCVar(name [, value])` + +The same functions as [`GetCVar`](#getcvarname), +[`GetCVarDefault`](#getcvardefaultname) and `RegisterCVar`, under their +`C_CVar` names. + ### `C_CVar.SetCVar(name [, value])` Sets a cvar and saves it to Config.wtf, as `SetCVar` does. Returns `true` @@ -6265,6 +6314,26 @@ Two holdings that look alike still count as a change: picking up one of two identical stacks, dropping it, and picking up the other reports each pickup separately. +### `CVAR_UPDATE` event (fires for every change) + +``` +CVAR_UPDATE: cvarName, value +``` + +Fires when the value of a cvar changes. `cvarName` is the name of the cvar, +and `value` is its new value as a string. The Settings window and +`CVarCallbackRegistry` use this event to keep their controls up to date. + +- The event fires only when the value changes, and only for a cvar that + `GetCVar` can read. +- The event fires at the start of the next frame, not during the call that + changes the cvar. A script that sets a cvar sees the event after the + script ends. +- A cvar that changes more than one time in a frame fires one event. + `value` is the value that the cvar has when the event fires. +- `SetCVar(name, value, eventName)` fires a second `CVAR_UPDATE`, with + `eventName` in place of the cvar name. + ### `EQUIPMENT_SETS_CHANGED` event Fires (with no payload) after any mutation: `Create`, `Save`, @@ -6825,6 +6894,22 @@ again when the player comes back to life. When it fires, read [`C_DeathInfo.GetSelfResurrectOptions`](#c_deathinfogetselfresurrectoptions) again. A change to an item option does not fire this event. +### `SETTINGS_LOADED` event + +Fires one time, when the Settings window has registered all of its +settings. It has no payload. + +### `SETTINGS_PANEL_OPEN` event + +Fires when an addon asks the Settings window to open. + +``` +SETTINGS_PANEL_OPEN: openToCategoryID, scrollToElementName +``` + +- **`openToCategoryID`** (number or string, or nil) — the category to show. +- **`scrollToElementName`** (string or nil) — the setting to scroll to. + ### `SOUNDKIT_FINISHED` event Fires when a sound finishes playing. @@ -8556,6 +8641,30 @@ child:GetFrameLevel() -- 22 `frame:SetFrameLevel(level)` moves only `frame`. The frames under it keep the levels they have. +### A shown frame moved under a visible parent becomes visible + +`frame:SetParent(parent)` makes `frame` visible when `frame` is shown and +`parent` is visible, or when `parent` is `nil`. A frame is shown when its +own `Show()` is in effect, even while a hidden parent keeps it from being +visible. + +```lua +local holder = CreateFrame("Frame", nil, UIParent) +holder:Hide() +local button = CreateFrame("Button", nil, holder) -- shown, not visible +button:SetParent(UIParent) +button:IsVisible() -- true +``` + +`OnShow` runs when the frame becomes visible. + +### `OnShow` and `OnHide` can move frames + +When a frame is shown or hidden, its children are shown or hidden one at a +time, and each child runs its `OnShow` or `OnHide` before the next child. +These scripts can call `SetParent` on any frame, also on the child itself. +A child that is no longer under the frame when its turn comes is skipped. + ### A ScrollFrame keeps clipping its content when it moves A ScrollFrame's scroll child, and all the frames in it, stay clipped to the @@ -9315,11 +9424,13 @@ Does nothing when the box has no history. call `editBox:SetFocus()`. - Each call runs the script, also when the box is already in that state. -### `slider:Enable()` / `slider:Disable()` / `slider:IsEnabled()` +### `slider:Enable()` / `slider:Disable()` / `slider:SetEnabled(enabled)` / `slider:IsEnabled()` `slider:Disable()` stops the mouse from moving the slider and runs its `OnDisable` script. `slider:Enable()` lets the mouse move it again and runs -its `OnEnable` script. `slider:IsEnabled()` returns `true` or `false`. +its `OnEnable` script. `slider:SetEnabled(enabled)` calls `Enable()` when +`enabled` is true, and `Disable()` when it is false or nil. +`slider:IsEnabled()` returns `true` or `false`. - A disabled slider still runs its `OnMouseDown` and `OnMouseUp` scripts, and `slider:SetValue()` still changes its value. @@ -12754,20 +12865,19 @@ end ### `InterfaceOptionsFrame` and addon option panels -Later clients list addon option panels in the Interface Options window, -`InterfaceOptionsFrame`. An addon adds its panel with -`InterfaceOptions_AddCategory(panel)` (Ace3's `AddToBlizOptions` does this -for every Ace3 addon) and opens it with -`InterfaceOptionsFrame_OpenToCategory(panel)`. Without these two -functions, Ace3 addons stop while they initialize. +Addons add option panels to the Settings window in two ways. Older addons +call `InterfaceOptions_AddCategory(panel)`. Ace3's `AddToBlizOptions` does +this for every Ace3 addon. Newer addons call +`Settings.RegisterCanvasLayoutCategory` and `Settings.RegisterAddOnCategory`. +Both kinds of panel show in the same window, in its AddOns list. ```lua local panel = CreateFrame("Frame") panel.name = "MyAddon" -- required: the list entry -panel.okay = function(self) end -- optional: Okay pressed -panel.cancel = function(self) end -- optional: Cancel pressed -panel.default = function(self) end -- optional: Defaults pressed -panel.refresh = function(self) end -- optional: panel shown +panel.okay = function(self) end -- optional: the window commits +panel.cancel = function(self) end -- optional: the window closes without a commit +panel.default = function(self) end -- optional: defaults are set +panel.refresh = function(self) end -- optional: the window opens, or the panel shows InterfaceOptions_AddCategory(panel) local sub = CreateFrame("Frame") @@ -12777,21 +12887,51 @@ InterfaceOptions_AddCategory(sub) InterfaceOptionsFrame_OpenToCategory(panel) -- or the category's name ``` -The window lists addon panels under AddOns; a category with children starts -collapsed. To open the window, click AddOn Options in the game menu (above -Key Bindings). When you close a window that you opened from the game menu, the -game menu opens again. Okay and Cancel call `okay` / `cancel` on every panel. -Escape does the same as Cancel. Defaults calls `default` on the panel shown. -`InterfaceOptionsFrame_Show()` toggles the window. The names match later -clients (`InterfaceOptionsFrameAddOns` with its `buttons`, `buttonHeight` and -`update` fields, the `InterfaceOptionsFrameAddOnsList` scroll frame, -`InterfaceOptionsFramePanelContainer.displayedPanel`, -`InterfaceOptionsListButtonTemplate`, `INTERFACEOPTIONS_ADDONCATEGORIES`), -because addons and libraries use them directly. +The name of a panel is also the ID of its category. Thus +`Settings.GetCategory("MyAddon")` and `Settings.OpenToCategory("MyAddon")` +find the panel. The `parent` field can name a category that an addon added +through either API. If the parent is not in the list yet, the panel shows at +the top level. The list sorts addon categories by name, so the `position` +argument has no effect. -This is the addon side only. The client's own settings stay in their own -windows, and the Categories list, which later clients fill with the game's -settings, exists but stays empty. +The window calls the panel functions at these times: + +- **Close**, **Apply** and Escape commit. Then `okay` runs on every panel. +- `cancel` runs only when the window closes without a commit. That occurs + when you click Exit in the dialog about settings that are not applied, or + when an addon clicks `InterfaceOptionsFrameCancel`. +- **Defaults** opens a dialog. **All Settings** runs `default` on every + panel. **These Settings** runs `default` on the panel that shows. On a + client whose dialogs have only two buttons, the dialog has no These + Settings choice. +- `refresh` runs when the window opens and each time the panel shows. + +The Defaults button shows above a list of settings, not above a panel. After +the window closes, the game menu opens. A panel can have its own `OnCommit`, +`OnDefault` or `OnRefresh` method. Then that method runs in place of `okay`, +`default` or `refresh`. + +To open the window, click AddOn Options in the game menu (above Key +Bindings). `InterfaceOptionsFrame_Show()` opens or closes the window. +`InterfaceAddOnsList_Update()` builds the list again. The window shows its +Game and AddOns tabs only when both lists have categories. + +The names of the earlier Interface Options window are parts of the Settings +window, because addons use these names directly: + +| Name | Part of the Settings window | +|------|-----------------------------| +| `InterfaceOptionsFrame` | `SettingsPanel`, the window | +| `InterfaceOptionsFrameAddOns`, `InterfaceOptionsFrameCategories` | The category list. Its `buttons` table is empty. Its `update` field builds the list again. | +| `InterfaceOptionsFrameAddOnsList` | The scroll box of the category list | +| `InterfaceOptionsFrameAddOnsListScrollBar` | The scroll bar of the category list | +| `InterfaceOptionsFramePanelContainer` | The frame that holds the panel. Its `displayedPanel` field is the panel that shows. | +| `InterfaceOptionsFrameOkay` | The Close button | +| `InterfaceOptionsFrameCancel` | A hidden button. A click closes the window without a commit. | +| `InterfaceOptionsFrameDefaults` | A hidden button. A click sets the defaults of the category that shows. | + +`INTERFACEOPTIONS_ADDONCATEGORIES` lists the panels that +`InterfaceOptions_AddCategory` added. ## Item @@ -22331,6 +22471,26 @@ f:SetScript("OnEvent", function() end) ``` +## SettingsUtil + +### `C_SettingsUtil.OpenSettingsPanel([openToCategoryID [, scrollToElementName]])` + +Opens the Settings window. With a category ID, the window shows that +category. With `scrollToElementName` too, the list of settings scrolls to +the setting of that name. `Settings.OpenToCategory` calls this function. + +The function fires `SETTINGS_PANEL_OPEN` with its two arguments, and the +window opens on that event. A category ID is the number that the category +gets, or the value that an addon puts in the `ID` field of the category. +Many addons set `ID` to the name of the category. Then the name opens the +category. + +### `C_SettingsUtil.NotifySettingsLoaded()` + +Fires `SETTINGS_LOADED`. The Settings window calls this function one time, +after `VARIABLES_LOADED` and `PLAYER_ENTERING_WORLD`. At that time, every +function that addons gave to `SettingsRegistrar:AddRegistrant` has run. + ## Sound Every sound the client plays comes from one table of sound entries. Each diff --git a/docs/LuaCAPI.md b/docs/LuaCAPI.md index db550928..ae6400be 100644 --- a/docs/LuaCAPI.md +++ b/docs/LuaCAPI.md @@ -31,8 +31,16 @@ build uses the MSVC fastcall convention. Each `TValue` is **16 bytes** here |--------|-----------------|---------------------------------------------| | `+0x08`| `top` | `TValue *` — top of stack (next free slot) | | `+0x0C`| `base` | `TValue *` — base of the current frame | -| `+0x10`| `ci` | `CallInfo *` — current call info | -| `+0x18`| `stack` | bottom of stack array | +| `+0x10`| `l_G` | `global_State *` | +| `+0x14`| `ci` | `CallInfo *` — current call info (`lua_getstack` `0x006FBAA0` reads it) | +| `+0x1C`| `stack` | bottom of stack array | +| `+0x20`| `stacksize` | | +| `+0x28`| `base_ci` | `CallInfo *` — first call info; `ci == base_ci` when no function runs | + +The GC counters are `global_State` fields, at `l_G` (`L+0x10`): + +| Offset | Field | Notes | +|--------|-----------------|---------------------------------------------| | `+0x24`| `gcthreshold` | bytes; `lua_setgcthreshold` writes here | | `+0x28`| `nblocks` | live byte count (read by `lua_getgccount`) | diff --git a/src/Offsets.h b/src/Offsets.h index 72bbc1c1..4a18e5a3 100644 --- a/src/Offsets.h +++ b/src/Offsets.h @@ -1775,6 +1775,9 @@ enum Offsets { CVAR_FLAG_ARCHIVE = 0x1, CVAR_FLAG_STAGED = 0x2, CVAR_FLAG_READ_ONLY = 0x4, + CVAR_FLAG_SCRIPT_VISIBLE = 0x80000000, + // The cvar's name string (docs/notes/cvar.md; `cvarlist` prints it). + OFF_CVAR_NAME = 0x14, OFF_CVAR_CALLBACK = 0xBC, OFF_CVAR_USERDATA = 0xC0, // Console categories — the registrar's category argument, an index into @@ -4385,6 +4388,16 @@ enum Offsets { FUN_PLAYERMODEL_SHOW = 0x00505D00, FUN_SIMPLEFRAME_HIDE = 0x0076AD50, FUN_SIMPLEFRAME_SHOW = 0x0076AE10, + // The child loops of FUN_SIMPLEFRAME_HIDE and FUN_SIMPLEFRAME_SHOW. Each + // starts with `mov ebx, [esi+0x300]` (8B 9E 00 03 00 00, the head of + // OFF_FRAME_CHILD_LIST), calls each child's VTBL_FRAME_HIDE / + // VTBL_FRAME_SHOW, reads the next node only after the call + // (`mov ebx, [ebx+4]`), and leaves at the RESUME address, where nothing + // reads EBX before the function's `pop ebx`. + SITE_SIMPLEFRAME_HIDE_CHILD_WALK = 0x0076ADC9, + SITE_SIMPLEFRAME_HIDE_CHILD_WALK_RESUME = 0x0076ADF9, + SITE_SIMPLEFRAME_SHOW_CHILD_WALK = 0x0076AEB6, + SITE_SIMPLEFRAME_SHOW_CHILD_WALK_RESUME = 0x0076AEE0, // The turn latch (SetRotation sets it, the next paint clears it) and the // turn deadline in OS ms (now + 100 on a turn, 0 once Stand is armed). OFF_PLAYERMODEL_TURNING = 0x3E8, @@ -5005,6 +5018,12 @@ enum Offsets { // caller), after storing the alpha byte (0x007690D2), both list heads and // the base vtable (0x007692E5). FUN_FRAME_SET_PARENT = 0x0076AB10, + // Script SetParent — `int __fastcall(lua_State *)`, the method table + // 0x0087C9B8's entry 4 (docs/raw_methods.txt). Reads the parent argument + // (nil, a name, or a frame table) and calls the object's vtable+0x14, which + // for a frame is FUN_FRAME_SET_PARENT (benilla-re ui/visibility + // "Reparenting by script"). + FUN_SCRIPT_REGION_SET_PARENT = 0x007A1550, // CSimpleFrame destructor body — `void __thiscall(frame)`, plain `ret`. // Called or tail-called by the base vtable's slot-0 deleting destructor // (0x00769380) and every derived frame class's destructor (16 call sites, diff --git a/src/bindings/Api.cpp b/src/bindings/Api.cpp index b8b636ed..0eb2af38 100644 --- a/src/bindings/Api.cpp +++ b/src/bindings/Api.cpp @@ -514,7 +514,16 @@ const Game::Doc::Function kGetBindingAction{"Returns the command bound to a key. kGetBindingActionArgs, kGetBindingActionRets, "BindingsGlobals"}; +// The engine's binding sets (Offsets::BINDING_SET_*), as retail names them. +const Game::Lua::EnumIntegerEntry kBindingSet[] = { + {"Default", Offsets::BINDING_SET_DEFAULT}, + {"Account", Offsets::BINDING_SET_ACCOUNT}, + {"Character", Offsets::BINDING_SET_CHARACTER}, + {"Current", Offsets::BINDING_SET_CURRENT}, +}; + void RegisterLuaFunctions() { + Game::Lua::RegisterIntegerEnum("Enum", "BindingSet", kBindingSet, "KeyBindings"); Game::Lua::RegisterGlobalFunction("GetBindingByKey", &Script_GetBindingByKey, &kGetBindingByKey); Game::Lua::RegisterGlobalFunction("SetBindingSpell", &Script_SetBindingSpell, diff --git a/src/cvar/Update.cpp b/src/cvar/Update.cpp new file mode 100644 index 00000000..c7ebb597 --- /dev/null +++ b/src/cvar/Update.cpp @@ -0,0 +1,134 @@ +// This file is part of ClassicAPI. +// +// ClassicAPI is free software: you can redistribute it and/or modify it under the terms +// of the GNU General Public License as published by the Free Software Foundation, either +// version 3 of the License, or (at your option) any later version. +// +// ClassicAPI is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along with +// ClassicAPI. If not, see . + +// `CVAR_UPDATE(cvarName, value)` whenever a cvar that Lua can see changes, as +// retail fires it. Retail's Settings window and CVarCallbackRegistry listen +// for it by the cvar's name. +// +// 1.12 fires CVAR_UPDATE (event 0x138) only from Script_SetCVar +// (FUN_00488C10), and only with the event token a caller passes as the third +// argument: `SetCVar(name, value, "TOKEN")` -> CVAR_UPDATE("TOKEN", value). +// That path stays as it is. The stock frames that listen (OptionsFrame, +// UIOptionsFrame, SoundOptionsFrame, TextStatusBar) key on upper-case tokens +// such as "SHOW_BUFF_DURATIONS", which no cvar name matches, so a fire by name +// is new to them; SoundOptionsFrame reloads its check boxes on any fire, which +// changes nothing. ReputationWatchBar (ReputationFrame.xml) is the one that +// keys on a cvar name: a fire for statusBarText now locks or unlocks the +// watched reputation's text, as that handler means to, and any other fire runs +// ReputationWatchBar_Update, as every UPDATE_FACTION already does. +// +// The hook is on CVar::Set (FUN_SET_CVAR_VALUE), which every write goes +// through: Script_SetCVar, C_CVar.SetCVar, the console `set` command and the +// engine's own writes. A change is fired at the head of the next UI frame, +// where no frame is mid-draw and no engine code is mid-way through its work. +// It is never fired inside the setter: the engine sets cvars from inside its +// own code while a script runs further up the stack, and a listener run +// there would run in the middle of engine code that does not expect a +// script. That a script is running somewhere does not make the setter's +// caller a script. +// +// Only a cvar that Lua can see (CVAR_FLAG_SCRIPT_VISIBLE) fires, only when its +// value text changed, and only while a frame listens, so the Config.wtf load +// and the cvar registrations at startup fire nothing. +// +// A cvar that changed fires once per frame, with the value it has when the +// event fires, not the value of each change. Retail fires inside the setter, +// so the value it gives is always the current one, and its listeners rely on +// that: the Settings window writes the value it is given back into its +// setting. A value from an earlier change of the same frame would be written +// back over the later one, change the cvar again and fire again, so two +// changes in one frame would swap the cvar between them every frame. The value +// is copied before the fire: a listener that sets the cvar frees the engine's +// string while the dispatcher still hands it to the listeners after it. + +#include "event/Custom.h" +#include "tick/FrameTick.h" + +#include "Game.h" +#include "Offsets.h" + +#include +#include +#include +#include + +namespace CVar::Update { + +namespace { + +// CVar::Set — __thiscall(cvar, value, apply, setReset, setDefault, force), +// RET 0x14; declared __fastcall with the unused EDX so the hook matches it. +using Set_t = int(__fastcall *)(void *cvar, void *edx, const char *value, int apply, int setReset, + int setDefault, int force); + +Set_t g_origSet = nullptr; + +// Each cvar that changed since the last drain, once, in the order of its first +// change. A cvar record lives as long as the client: the engine never frees +// one. +std::vector g_pending; + +int ListeningSlot() { + const int slot = Event::Custom::LookupByName("CVAR_UPDATE"); + return Event::Custom::HasListeners(slot) ? slot : -1; +} + +const char *ValueOf(void *cvar) { + const char *value = Game::Read(cvar, Offsets::OFF_CVAR_VALUE_STR); + return value != nullptr ? value : ""; +} + +int __fastcall Set_h(void *cvar, void *edx, const char *value, int apply, int setReset, + int setDefault, int force) { + const bool visible = + (Game::Read(cvar, Offsets::OFF_CVAR_FLAGS) & Offsets::CVAR_FLAG_SCRIPT_VISIBLE) != 0; + const int slot = visible ? ListeningSlot() : -1; + if (slot < 0) + return g_origSet(cvar, edx, value, apply, setReset, setDefault, force); + + const std::string before = ValueOf(cvar); + const int result = g_origSet(cvar, edx, value, apply, setReset, setDefault, force); + if (before == ValueOf(cvar)) + return result; + + if (std::find(g_pending.begin(), g_pending.end(), cvar) == g_pending.end()) + g_pending.push_back(cvar); + return result; +} + +void Drain() { + if (g_pending.empty()) + return; + std::vector changed; + changed.swap(g_pending); + const int slot = ListeningSlot(); + if (slot < 0) + return; + for (void *cvar : changed) { + const std::string value = ValueOf(cvar); + Event::Custom::Fire(slot, "%s%s", Game::Read(cvar, Offsets::OFF_CVAR_NAME), + value.c_str()); + } +} + +// A change queued under the old interface is not fired into the new one. +void PrepareForReload() { g_pending.clear(); } + +const Game::HookAutoRegister _setHook{Offsets::FUN_SET_CVAR_VALUE, reinterpret_cast(&Set_h), + reinterpret_cast(&g_origSet)}; +const Tick::FrameTick::AutoSubscribeBefore _tick{&Drain}; +const Game::ReloadAutoRegister _reload{&PrepareForReload}; + +} // namespace + +} // namespace CVar::Update diff --git a/src/embed/AddOns/!!!ClassicAPI/!!!ClassicAPI.toc b/src/embed/AddOns/!!!ClassicAPI/!!!ClassicAPI.toc index 52981c45..00712949 100644 --- a/src/embed/AddOns/!!!ClassicAPI/!!!ClassicAPI.toc +++ b/src/embed/AddOns/!!!ClassicAPI/!!!ClassicAPI.toc @@ -8,9 +8,6 @@ locales\locales.xml -FrameXML\InterfaceOptions.xml -FrameXML\InterfaceOptions.lua - SecureTemplates.xml Compat.lua Util\EnvironmentUtil.lua @@ -38,6 +35,8 @@ Util\ExportUtil.lua Util\ButtonStateBehavior.lua Util\CallbackRegistry.lua Util\GlobalCallbackRegistry.lua +Util\CvarUtil.lua +Util\BindingUtil.lua Util\TemplateInfoCache.lua Util\FrameFactory.lua Util\DataProvider.lua @@ -144,6 +143,15 @@ FrameXML\InputBoxTemplates.xml FrameXML\SearchBoxTemplate.xml [ExcludeLoadGameType turtle] FrameXML\ColorSwatch.lua FrameXML\ColorSwatch.xml +FrameXML\ColorPickerFrame.lua +FrameXML\MinimalSlider.lua +FrameXML\MinimalSlider.xml +FrameXML\FontStyles.xml +FrameXML\SelectableButton.lua +FrameXML\SelectableButton.xml +FrameXML\ButtonGroup.lua +FrameXML\MinimalTab.lua +FrameXML\MinimalTab.xml FrameXML\ScriptErrorsFrame.lua FrameXML\ScriptErrorsFrame.xml FrameXML\ModelScene\CameraRegistry.lua @@ -174,6 +182,30 @@ Menu\Classic\MenuTemplates.lua Menu\Classic\MenuTemplates.xml Menu\MenuUtil.lua +Settings\Blizzard_SettingsRegistrar.lua +Settings\Blizzard_Settings.lua +Settings\Blizzard_Category.lua +Settings\Blizzard_CategoryList.lua +Settings\Blizzard_CategoryList.xml +Settings\Blizzard_SettingsList.lua +Settings\Blizzard_SettingsList.xml +Settings\Blizzard_Setting.lua +Settings\Blizzard_SettingControls.lua +Settings\Blizzard_SettingControls.xml +Settings\Blizzard_Keybindings.lua +Settings\Blizzard_Keybindings.xml +Settings\Blizzard_SettingsPanelTemplates.xml +Settings\Blizzard_SettingsPanel.lua +Settings\Blizzard_SettingsPanel.xml +Settings\Blizzard_Dialogs.lua +Settings\Blizzard_SettingsLayouts.lua +Settings\Blizzard_Registration.lua +Settings\Blizzard_SettingsInbound.lua + +FrameXML\InterfaceOptions.lua + +Options\Controls.lua +Options\Controls.xml Options\Panel.lua APIDocumentation\BaseAPIMixin.lua diff --git a/src/embed/AddOns/!!!ClassicAPI/Compat.lua b/src/embed/AddOns/!!!ClassicAPI/Compat.lua index 38ddc0c6..bfd5c51c 100644 --- a/src/embed/AddOns/!!!ClassicAPI/Compat.lua +++ b/src/embed/AddOns/!!!ClassicAPI/Compat.lua @@ -8,6 +8,33 @@ end C_Container.GetContainerNumSlots = GetContainerNumSlots C_Container.PickupContainerItem = PickupContainerItem +C_CVar.GetCVar = GetCVar +C_CVar.GetCVarDefault = GetCVarDefault +C_CVar.RegisterCVar = RegisterCVar + +C_KeyBindings = C_KeyBindings or {} + +-- This client's binding list holds each action once. +function C_KeyBindings.GetBindingIndex(action) + for index = 1, GetNumBindings() do + if GetBinding(index) == action then + return index + end + end + return nil +end + +-- This client has one binding context, so no action has a context of its +-- own. +function C_KeyBindings.GetBindingContextForAction(action) + return nil +end + +-- This client has no custom binding types (retail's push-to-talk key). +function C_KeyBindings.GetCustomBindingType(bindingIndex) + return nil +end + C_ActionBar = C_ActionBar or {} -- Retail answers per game type. This client always has a keyring. @@ -43,3 +70,12 @@ end function C_PlayerInfo.GetAlternateFormInfo() return false, false end + +-- Retail marks the settings added in the current version as new. Nothing in +-- this client is new. +function IsNewSettingInCurrentVersion(variable) + return false +end + +function MarkNewSettingAsSeen(variable) +end diff --git a/src/embed/AddOns/!!!ClassicAPI/FrameXML/ButtonGroup.lua b/src/embed/AddOns/!!!ClassicAPI/FrameXML/ButtonGroup.lua new file mode 100644 index 00000000..5b69714e --- /dev/null +++ b/src/embed/AddOns/!!!ClassicAPI/FrameXML/ButtonGroup.lua @@ -0,0 +1,239 @@ +-- Verbatim backport of retail's Blizzard_SharedXML/ButtonGroup.lua. + +--[[ + Required Elements - all buttons in the group need to inherit from SelectableButtonMixin + and have the OnClick handler defined in XML +]] + +ButtonGroupBaseMixin = CreateFromMixins(CallbackRegistryMixin); + +ButtonGroupBaseMixin:GenerateCallbackEvents( + { + "Selected", + "Unselected", + } +); + +function ButtonGroupBaseMixin:Init() + CallbackRegistryMixin.OnLoad(self); + self.buttons = {}; +end + +function ButtonGroupBaseMixin:SetShown(shown) + for index, button in ipairs(self.buttons) do + button:SetShown(shown); + end +end + +function ButtonGroupBaseMixin:AddButton(button) + self:AddInternal(button); +end + +function ButtonGroupBaseMixin:AddButtons(buttons) + for buttonIndex, button in ipairs(buttons) do + self:AddInternal(button); + end +end + +function ButtonGroupBaseMixin:AddInternal(button, func, group) + table.insert(self.buttons, button); + + -- NOTE: The SelectableButton that this is intended to be used with doesn't actually care about the mouseButton argument. + local previousOnClickScript = button:GetScript("OnClick"); + assert(not button.previousOnClickScript); + button.previousOnClickScript = previousOnClickScript; + + button:SetScript("OnClick", function(o, mouseButton) + -- Only run our group's selection changed callback if the button object didn't have a mixin-OnClick method, + -- or if the OnClick method indicated that selection state actually changed. + local wasSelected = button:IsSelected(); + + if previousOnClickScript then + previousOnClickScript(button, mouseButton); + end + + local isSelected = button:IsSelected(); + local selectionChanged = wasSelected ~= isSelected; + + if not previousOnClickScript or selectionChanged then + func(group, button, button:IsSelected()); + end + end); +end + +function ButtonGroupBaseMixin:RemoveButton(button) + self:RemoveInternal(button); +end + +function ButtonGroupBaseMixin:RemoveButtons(buttons) + if buttons == self.buttons then + self:RemoveAllButtons(); + else + for buttonIndex, button in ipairs(buttons) do + self:RemoveInternal(button); + end + end +end + +function ButtonGroupBaseMixin:RemoveInternal(button) + tDeleteItem(self.buttons, button); + + -- Restore the button's OnClick to whatever it used to be. + button:SetScript("OnClick", button.previousOnClickScript); + button.previousOnClickScript = nil; +end + +function ButtonGroupBaseMixin:SetButtons(buttons) + self:RemoveAllButtons(); + self:AddButtons(buttons); +end + +function ButtonGroupBaseMixin:RemoveAllButtons() + for index, button in ipairs_reverse(self.buttons) do + self:RemoveInternal(button); + end +end + +function ButtonGroupBaseMixin:GetButtons() + return self.buttons; +end + +function ButtonGroupBaseMixin:Reset() + self:RemoveAllButtons(); + self:UnregisterEvents(); + self.callbacks = {}; +end + +function ButtonGroupBaseMixin:FindButtonByPredicate(pred) + for buttonIndex, button in ipairs(self.buttons) do + if pred(button) then + return button; + end + end + return nil; +end + +function ButtonGroupBaseMixin:GetButtonsByPredicate(pred) + local buttons = {}; + for buttonIndex, button in ipairs(self.buttons) do + if pred(button) then + table.insert(buttons, button); + end + end + return buttons; +end + +function ButtonGroupBaseMixin:Unselect(button) + self:UnselectAtIndex(self:GetButtonIndex(button)); +end + +function ButtonGroupBaseMixin:Select(button) + self:SelectAtIndex(self:GetButtonIndex(button)); +end + +function ButtonGroupBaseMixin:SelectAtIndex(index) + self:SetSelectedAtIndex(index, true); +end + +function ButtonGroupBaseMixin:UnselectAtIndex(index) + self:SetSelectedAtIndex(index, false); +end + +local function SetButtonSelectedAndGetWasChanged(button, selected) + local wasSelected = button:IsSelected(); + button:SetSelected(selected); + return wasSelected ~= button:IsSelected(); +end + +function ButtonGroupBaseMixin:SetSelectedAtIndex(index, selected) + local button = self:GetAtIndex(index); + if button then + + if SetButtonSelectedAndGetWasChanged(button, selected) then + self:OnSelectionChange(button, selected); + end + end +end + +function ButtonGroupBaseMixin:GetSelectedButtons() + return self:GetButtonsByPredicate( + function(button) + return button:IsSelected(); + end + ); +end + +function ButtonGroupBaseMixin:GetButtonIndex(button) + return tIndexOf(self.buttons, button); +end + +function ButtonGroupBaseMixin:GetAtIndex(index) + return self.buttons[index]; +end + +ButtonGroupMixin = CreateFromMixins(ButtonGroupBaseMixin); + +function ButtonGroupMixin:OnSelectionChange(button, newSelected) + local event = newSelected and ButtonGroupBaseMixin.Event.Selected or ButtonGroupBaseMixin.Event.Unselected; + self:TriggerEvent(event, button, self:GetButtonIndex(button)); +end + +function ButtonGroupMixin:AddInternal(button) + ButtonGroupBaseMixin.AddInternal(self, button, self.OnSelectionChange, self); +end + +function CreateButtonGroup() + return CreateAndInitFromMixin(ButtonGroupMixin); +end + +RadioButtonGroupMixin = CreateFromMixins(ButtonGroupBaseMixin); + +function RadioButtonGroupMixin:CanChangeSelection(button, newSelected) + return not (not newSelected and #self:GetSelectedButtons() == 1); +end + +function RadioButtonGroupMixin:OnSelectionChange(button, newSelected) + -- Deselect everything that was selected + for selectedButtonIndex, selectedButton in ipairs(self:GetSelectedButtons()) do + if selectedButton ~= button then + selectedButton:SetSelected(false); + self:TriggerEvent(ButtonGroupBaseMixin.Event.Unselected, selectedButton, self:GetButtonIndex(selectedButton)); + end + end + + -- Select the new thing if appropriate + if newSelected then + self:TriggerEvent(ButtonGroupBaseMixin.Event.Selected, button, self:GetButtonIndex(button)); + else + self:TriggerEvent(ButtonGroupBaseMixin.Event.Unselected, button, self:GetButtonIndex(button)); + end +end + +function RadioButtonGroupMixin:AddInternal(button) + button:SetSelectionChangeInterrupt(GenerateClosure(self.CanChangeSelection, self)); + ButtonGroupBaseMixin.AddInternal(self, button, self.OnSelectionChange, self); +end + +function RadioButtonGroupMixin:RemoveInternal(button) + button:SetSelectionChangeInterrupt(nil); + ButtonGroupBaseMixin.RemoveInternal(self, button); +end + +DeselectableRadioButtonGroupMixin = CreateFromMixins(RadioButtonGroupMixin); + +function DeselectableRadioButtonGroupMixin:CanChangeSelection(button, newSelected) + return true; +end + +--[[ + Required Elements - all buttons in the group need to inherit from SelectableButtonTemplate + and you CAN override the OnLoad, and OnClick handler if needed +]]-- +function CreateRadioButtonGroup() + return CreateAndInitFromMixin(RadioButtonGroupMixin); +end + +function CreateDeselectableRadioButtonGroup() + return CreateAndInitFromMixin(DeselectableRadioButtonGroupMixin); +end + diff --git a/src/embed/AddOns/!!!ClassicAPI/FrameXML/ColorPickerFrame.lua b/src/embed/AddOns/!!!ClassicAPI/FrameXML/ColorPickerFrame.lua new file mode 100644 index 00000000..c49ea256 --- /dev/null +++ b/src/embed/AddOns/!!!ClassicAPI/FrameXML/ColorPickerFrame.lua @@ -0,0 +1,42 @@ +-- Backport of the ColorPickerFrameMixin methods from Classic Era's +-- Blizzard_ColorPickerFrame/Classic/ColorPickerFrame.lua, added to this +-- client's own ColorPickerFrame. +-- +-- Differences from the Classic Era source: +-- - This client's frame calls ColorPickerFrame.func when the color changes +-- and when OK is clicked, where Classic Era's calls swatchFunc. So +-- SetupColorPickerAndShow sets both. +-- - The previous values are also the argument the frame gives cancelFunc, +-- as this client's own callers expect. +-- - This client's frame has no stratum of its own, so it takes UIParent's +-- MEDIUM and opens behind the HIGH Settings window. It is put in the +-- DIALOG stratum that Classic Era's frame declares. + +ColorPickerFrame:SetFrameStrata("DIALOG"); + +function ColorPickerFrame:GetColorAlpha() + return OpacitySliderFrame:GetValue(); +end + +function ColorPickerFrame:SetupColorPickerAndShow(info) + self.swatchFunc = info.swatchFunc; + self.func = info.swatchFunc; + self.hasOpacity = info.hasOpacity; + self.opacityFunc = info.opacityFunc; + self.opacity = info.opacity; + self.previousValues = { r = info.r, g = info.g, b = info.b, a = info.opacity }; + self.cancelFunc = info.cancelFunc; + self.extraInfo = info.extraInfo; + + ColorSwatch:SetColorTexture(info.r, info.g, info.b); + self:SetColorRGB(info.r, info.g, info.b); + self:Show(); +end + +function ColorPickerFrame:GetExtraInfo() + return self.extraInfo; +end + +function ColorPickerFrame:GetPreviousValues() + return self.previousValues.r, self.previousValues.g, self.previousValues.b, self.previousValues.a; +end diff --git a/src/embed/AddOns/!!!ClassicAPI/FrameXML/FontStyles.xml b/src/embed/AddOns/!!!ClassicAPI/FrameXML/FontStyles.xml new file mode 100644 index 00000000..84eaf4bd --- /dev/null +++ b/src/embed/AddOns/!!!ClassicAPI/FrameXML/FontStyles.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + diff --git a/src/embed/AddOns/!!!ClassicAPI/FrameXML/InterfaceOptions.lua b/src/embed/AddOns/!!!ClassicAPI/FrameXML/InterfaceOptions.lua index df976408..2c2c5da7 100644 --- a/src/embed/AddOns/!!!ClassicAPI/FrameXML/InterfaceOptions.lua +++ b/src/embed/AddOns/!!!ClassicAPI/FrameXML/InterfaceOptions.lua @@ -1,373 +1,201 @@ --- Backport of the Interface Options panel's addon side (InterfaceOptionsFrame, --- InterfaceOptions_AddCategory, InterfaceOptionsFrame_OpenToCategory) to --- vanilla 1.12 / Lua 5.0. +-- The Interface Options API of 3.3.5-era clients (InterfaceOptions_AddCategory, +-- InterfaceOptionsFrame_OpenToCategory and the InterfaceOptionsFrame names), +-- on top of the Settings window (Settings\Blizzard_SettingsPanel.lua). -- --- Later clients list addon option panels in InterfaceOptionsFrame. Addons add --- theirs with InterfaceOptions_AddCategory(panel) - Ace3's --- AceConfigDialog:AddToBlizOptions does it for every Ace3 addon - and open them --- with InterfaceOptionsFrame_OpenToCategory. Frame and list names match later --- clients because addons reach for them directly (Zygor Guides Viewer 2.0 --- re-tints the frame's first region; LibBetterBlizzOptions-1.0 resizes the --- lists through their `buttons` / `buttonHeight` / `update` fields). +-- Addons from both eras run here. Ace3's AceConfigDialog:AddToBlizOptions +-- calls InterfaceOptions_AddCategory whenever it exists; newer addons call +-- Settings.RegisterCanvasLayoutCategory when Settings and SettingsPanel +-- exist. Both land in the one Settings window: a panel added here is a +-- canvas category in the AddOns set. -- --- Implementation differences from the modern source: --- - Addon panels only. Vanilla's own options stay in UIOptionsFrame and --- friends; the Categories list exists (empty, hidden) for code that --- expects it. --- - Panel protocol as on later clients: panel.name (required), panel.parent --- (name of the category to nest under), and optional okay / cancel / --- default / refresh, each called with the panel. Categories with children --- start collapsed. Okay and Cancel call okay / cancel on every panel; --- Defaults calls default on the one shown; Escape is Cancel. --- - The game-menu entry is an extra AddOn Options button: the client's own --- options keep their buttons, so the addon list gets one of its own. --- Not "AddOns" - on later clients that button opens the addon list. --- - Lua 5.0: no `...` expression or select(). +-- The panel protocol of 3.3.5 maps onto the Settings window's own: +-- - panel.name (required) is the category's name and its ID, as Ace3 and +-- newer addons set it, so Settings.GetCategory(name) finds it. +-- - panel.parent names the category to nest under: a category added here +-- or through Settings, found by ID or by name. A panel whose parent is +-- not registered yet is listed at the top level. +-- - panel.okay runs when the window commits (Close and Apply), panel.default +-- when its defaults are set, panel.refresh when the window opens and when +-- the panel is shown. The panel keeps its own OnCommit, OnDefault or +-- OnRefresh if it has one. +-- - panel.cancel runs when the window closes without committing: the +-- discard dialog's Exit, or InterfaceOptionsFrameCancel. Close and Escape +-- commit, as on retail. +-- - The list sorts addon categories by name, so `position` has no effect. +-- +-- The old window's names are the Settings window's frames, because addons +-- reach for them directly (Auctionator sets backdrops on InterfaceOptionsFrame, +-- InterfaceOptionsFrameAddOns and InterfaceOptionsFrameCategories and lays a +-- frame over InterfaceOptionsFrame; skins restyle all of them): +-- InterfaceOptionsFrame SettingsPanel +-- InterfaceOptionsFrameAddOns, ...Categories the category list +-- InterfaceOptionsFrameAddOnsList the list's ScrollBox +-- InterfaceOptionsFrameAddOnsListScrollBar the list's scroll bar +-- InterfaceOptionsFramePanelContainer the canvas a panel is shown in; +-- displayedPanel is that panel +-- InterfaceOptionsFrameOkay the Close button +-- InterfaceOptionsFrameCancel / ...Defaults hidden buttons: closing without +-- commit / defaults for the shown +-- category +-- The list has no fixed rows: its `buttons` table is empty, and its `update` +-- (also InterfaceAddOnsList_Update) rebuilds it. INTERFACEOPTIONS_ADDONCATEGORIES +-- lists the panels added here. -if InterfaceOptionsFrame then return end -- a real implementation wins +local categoryList = SettingsPanel:GetCategoryList(); +local canvas = SettingsPanel:GetSettingsCanvas(); -INTERFACEOPTIONS_ADDONCATEGORIES = INTERFACEOPTIONS_ADDONCATEGORIES or {} -local categories = INTERFACEOPTIONS_ADDONCATEGORIES - -local BUTTON_HEIGHT = 18 -local NUM_BUTTONS = 24 - -local function report(err) - local handler = geterrorhandler and geterrorhandler() - if handler then handler(err) end -end - -local LIST_BACKDROP = { - bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", - edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, tileSize = 16, edgeSize = 16, - insets = { left = 5, right = 5, top = 5, bottom = 5 }, -} - --- --------------------------------------------------------------------------- --- Frame --- --------------------------------------------------------------------------- - -local frame = CreateFrame("Frame", "InterfaceOptionsFrame", UIParent) -frame:Hide() -frame:SetWidth(648) -frame:SetHeight(568) -frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0) -frame:SetFrameStrata("DIALOG") -frame:SetToplevel(true) -frame:EnableMouse(true) -frame:SetMovable(true) -frame:SetClampedToScreen(true) - --- The background is the frame's first region: addons re-tint it through --- InterfaceOptionsFrame:GetRegions(). -local background = frame:CreateTexture(nil, "BACKGROUND") -background:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Background") -background:SetPoint("TOPLEFT", frame, "TOPLEFT", 11, -12) -background:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -12, 11) -frame:SetBackdrop({ - edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", - edgeSize = 32, - insets = { left = 11, right = 12, top = 12, bottom = 11 }, -}) - -local header = frame:CreateTexture(nil, "ARTWORK") -header:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header") -header:SetWidth(360) -header:SetHeight(64) -header:SetPoint("TOP", frame, "TOP", 0, 12) -local title = frame:CreateFontString(nil, "ARTWORK", "GameFontNormal") -title:SetPoint("TOP", header, "TOP", 0, -14) -title:SetText(ADDON_OPTIONS) - -frame:SetScript("OnMouseDown", function() - if arg1 == "LeftButton" then this:StartMoving() end -end) -frame:SetScript("OnMouseUp", function() this:StopMovingOrSizing() end) - --- A native center panel, as on later clients: ShowUIPanel swaps it with the --- game menu, CloseAllWindows closes it, and closing returns to lastFrame. -UIPanelWindows["InterfaceOptionsFrame"] = { area = "center", pushable = 0, whileDead = 1 } - --- --------------------------------------------------------------------------- --- Category lists and the panel container --- --------------------------------------------------------------------------- - -local function CreateList(name) - local list = CreateFrame("Frame", name, frame) - list:SetWidth(185) - list:SetPoint("TOPLEFT", frame, "TOPLEFT", 22, -40) - list:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 22, 50) - list:SetBackdrop(LIST_BACKDROP) - list:SetBackdropColor(0, 0, 0, 0.5) - list:SetBackdropBorderColor(0.6, 0.6, 0.6) - list.buttonHeight = BUTTON_HEIGHT - list.buttons = {} - for i = 1, NUM_BUTTONS do - local button = CreateFrame("Button", name .. "Button" .. i, list, "InterfaceOptionsListButtonTemplate") - if i == 1 then - button:SetPoint("TOPLEFT", list, "TOPLEFT", 5, -8) - else - button:SetPoint("TOPLEFT", list.buttons[i - 1], "BOTTOMLEFT", 0, 0) - end - button:Hide() - list.buttons[i] = button - end - return list -end - --- Vanilla keeps its own options elsewhere; this list stays empty. -local gameList = CreateList("InterfaceOptionsFrameCategories") -gameList.update = function() end -gameList:Hide() - -local addOnList = CreateList("InterfaceOptionsFrameAddOns") - -local scroll = CreateFrame("ScrollFrame", "InterfaceOptionsFrameAddOnsList", addOnList, "FauxScrollFrameTemplate") -scroll:SetPoint("TOPLEFT", addOnList, "TOPLEFT", 0, -8) -scroll:SetPoint("BOTTOMRIGHT", addOnList, "BOTTOMRIGHT", -30, 8) - -local container = CreateFrame("Frame", "InterfaceOptionsFramePanelContainer", frame) -container:SetPoint("TOPLEFT", addOnList, "TOPRIGHT", 16, 0) -container:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -22, 50) -container:SetBackdrop(LIST_BACKDROP) -container:SetBackdropColor(0, 0, 0, 0.5) -container:SetBackdropBorderColor(0.6, 0.6, 0.6) +INTERFACEOPTIONS_ADDONCATEGORIES = {}; +local panels = INTERFACEOPTIONS_ADDONCATEGORIES; -- --------------------------------------------------------------------------- -- Categories -- --------------------------------------------------------------------------- +local function FindCategoryByName(categories, name) + for _, category in ipairs(categories) do + if category:GetName() == name then + return category; + end + local found = FindCategoryByName(category:GetSubcategories(), name); + if found then + return found; + end + end +end + +-- By ID first, as Settings.GetCategory does, then by name: a category +-- registered through Settings keeps its counter ID unless the addon set it. local function FindCategory(name) - for _, panel in ipairs(categories) do - if panel.name == name then return panel end - end + return Settings.GetCategory(name) or FindCategoryByName(SettingsPanel:GetAllCategories(), name); end -local function HasChildren(panel) - for _, p in ipairs(categories) do - if p.parent == panel.name then return true end - end -end - --- Top-level categories in order, each followed by its children when expanded. --- A child whose parent is not registered is listed at the top level. -local function VisibleCategories() - local out = {} - for _, panel in ipairs(categories) do - if not panel.parent or not FindCategory(panel.parent) then - table.insert(out, panel) - if not panel.collapsed then - for _, child in ipairs(categories) do - if child.parent == panel.name then table.insert(out, child) end - end - end +local function FindCategoryForFrame(categories, frame) + for _, category in ipairs(categories) do + local layout = SettingsPanel:GetLayout(category); + if layout and layout:GetLayoutType() == SettingsLayoutMixin.LayoutType.Canvas and layout:GetFrame() == frame then + return category; + end + local found = FindCategoryForFrame(category:GetSubcategories(), frame); + if found then + return found; end end - return out end -function InterfaceAddOnsList_Update() - local entries = VisibleCategories() - local offset = FauxScrollFrame_GetOffset(scroll) or 0 - local numButtons = table.getn(addOnList.buttons) - for i = 1, numButtons do - local button = addOnList.buttons[i] - local panel = entries[i + offset] - local text = getglobal(button:GetName() .. "Text") - local toggle = getglobal(button:GetName() .. "Toggle") - if panel then - button.element = panel - text:SetText(panel.name) - local isChild = panel.parent and FindCategory(panel.parent) - text:SetFontObject(isChild and GameFontHighlightSmall or GameFontNormal) - text:ClearAllPoints() - text:SetPoint("LEFT", button, "LEFT", isChild and 20 or 8, 0) - if toggle then - if HasChildren(panel) then - local tex = panel.collapsed and "Plus" or "Minus" - toggle:SetNormalTexture("Interface\\Buttons\\UI-" .. tex .. "Button-UP") - toggle:SetPushedTexture("Interface\\Buttons\\UI-" .. tex .. "Button-DOWN") - toggle:Show() - else - toggle:Hide() - end - end - if panel == container.displayedPanel then button:LockHighlight() else button:UnlockHighlight() end - button:Show() - else - button.element = nil - button:UnlockHighlight() - button:Hide() +-- A canvas callback that runs the panel's 3.3.5 one, looked up when it runs: +-- addons set okay / cancel / default / refresh before or after adding the +-- panel. +local function Forward(method) + return function(panel) + local fn = panel[method]; + if type(fn) == "function" then + fn(panel); end end - FauxScrollFrame_Update(scroll, table.getn(entries), numButtons, BUTTON_HEIGHT) -end -addOnList.update = InterfaceAddOnsList_Update - -scroll:SetScript("OnVerticalScroll", function() - FauxScrollFrame_OnVerticalScroll(BUTTON_HEIGHT, InterfaceAddOnsList_Update) -end) - --- The shown panel lives in container.displayedPanel, as on later clients: --- addons read it there. -local function DisplayPanel(panel) - local shown = container.displayedPanel - if shown and shown ~= panel then shown:Hide() end - container.displayedPanel = panel - panel:SetParent(container) - panel:ClearAllPoints() - panel:SetPoint("TOPLEFT", container, "TOPLEFT", 4, -4) - panel:SetPoint("BOTTOMRIGHT", container, "BOTTOMRIGHT", -4, 4) - panel:Show() - if type(panel.refresh) == "function" then - local ok, err = pcall(panel.refresh, panel) - if not ok then report(err) end - end - InterfaceAddOnsList_Update() end -function InterfaceOptionsListButton_OnClick(button) - if button and button.element then DisplayPanel(button.element) end -end - -function InterfaceOptionsListButton_ToggleSubCategories(button) - local panel = button and button.element - if not panel then return end - panel.collapsed = not panel.collapsed - InterfaceAddOnsList_Update() -end +local OnCommit = Forward("okay"); +local OnDefault = Forward("default"); +local OnRefresh = Forward("refresh"); function InterfaceOptions_AddCategory(panel, addOn, position) if type(panel) ~= "table" or type(panel.name) ~= "string" then - error("Usage: InterfaceOptions_AddCategory(panel [, addOn, position])", 2) + error("Usage: InterfaceOptions_AddCategory(panel [, addOn, position])", 2); end - panel:Hide() - if panel.parent then - local parent = FindCategory(panel.parent) - if parent and parent.collapsed == nil then parent.collapsed = true end - end - if position and position >= 1 and position <= table.getn(categories) + 1 then - table.insert(categories, position, panel) + panel:Hide(); + + if panel.OnCommit == nil then panel.OnCommit = OnCommit; end + if panel.OnDefault == nil then panel.OnDefault = OnDefault; end + if panel.OnRefresh == nil then panel.OnRefresh = OnRefresh; end + + local parent = panel.parent and FindCategory(panel.parent); + local category; + if parent then + category = Settings.RegisterCanvasLayoutSubcategory(parent, panel, panel.name); else - table.insert(categories, panel) + category = Settings.RegisterCanvasLayoutCategory(panel, panel.name); end - if panel.collapsed == nil and HasChildren(panel) then panel.collapsed = true end - if frame:IsShown() then InterfaceAddOnsList_Update() end + category.ID = panel.name; + Settings.RegisterAddOnCategory(category); + + table.insert(panels, panel); end function InterfaceOptionsFrame_OpenToCategory(panel) - if type(panel) == "string" then panel = FindCategory(panel) end - if type(panel) ~= "table" then return end - local p = panel - while p and p.parent do - local parent = FindCategory(p.parent) - if parent then parent.collapsed = false end - p = parent + local category; + if type(panel) == "string" then + category = FindCategory(panel); + elseif type(panel) == "table" then + category = FindCategoryForFrame(SettingsPanel:GetAllCategories(), panel); + if not category and type(panel.name) == "string" then + category = FindCategory(panel.name); + end + end + if category then + Settings.OpenToCategory(category:GetID()); end - ShowUIPanel(frame) - DisplayPanel(panel) end function InterfaceOptionsFrame_Show() - if frame:IsShown() then HideUIPanel(frame) else ShowUIPanel(frame) end + if SettingsPanel:IsShown() then + SettingsPanel:Close(); + else + SettingsPanel:Open(); + end end -frame:SetScript("OnShow", function() - if not container.displayedPanel and categories[1] then - DisplayPanel(categories[1]) - else - InterfaceAddOnsList_Update() - end -end) +function InterfaceAddOnsList_Update() + categoryList:CreateCategories(); +end -frame:SetScript("OnHide", function() - if this.lastFrame then - ShowUIPanel(this.lastFrame) - this.lastFrame = nil - end -end) - --- --------------------------------------------------------------------------- --- Okay / Cancel / Defaults --- --------------------------------------------------------------------------- - -local function CallAll(method) - for _, panel in ipairs(categories) do - local fn = panel[method] +-- Closing without a commit gives each panel added here its cancel, before +-- the window hides, as the old window's Cancel did. +local ExitWithoutCommit = SettingsPanel.ExitWithoutCommit; +function SettingsPanel:ExitWithoutCommit() + for _, panel in ipairs(panels) do + local fn = panel.cancel; if type(fn) == "function" then - local ok, err = pcall(fn, panel) - if not ok then report(err) end + local ok, err = pcall(fn, panel); + if not ok then CallErrorHandler(err); end end end -end - -local function PanelButton(name, label, point, x) - local b = CreateFrame("Button", name, frame, "UIPanelButtonTemplate") - b:SetWidth(96) - b:SetHeight(22) - b:SetPoint(point, frame, point, x, 16) - b:SetText(label) - return b -end - -PanelButton("InterfaceOptionsFrameCancel", CANCEL, "BOTTOMRIGHT", -16):SetScript("OnClick", function() - CallAll("cancel") - HideUIPanel(frame) -end) -PanelButton("InterfaceOptionsFrameOkay", OKAY, "BOTTOMRIGHT", -114):SetScript("OnClick", function() - CallAll("okay") - HideUIPanel(frame) -end) -PanelButton("InterfaceOptionsFrameDefaults", DEFAULTS, "BOTTOMLEFT", 22):SetScript("OnClick", function() - local panel = container.displayedPanel - if panel and type(panel.default) == "function" then - local ok, err = pcall(panel.default, panel) - if not ok then report(err) end - end -end) - --- Escape is Cancel, as on later clients: their ToggleGameMenu clicks --- InterfaceOptionsFrameCancel right after dismissing a static popup. --- Without this, Escape reaches CloseAllWindows, which closes the window --- without calling any panel's cancel. -local ToggleGameMenu_Orig = ToggleGameMenu -function ToggleGameMenu(clicked) - if not clicked and frame:IsVisible() then - if not StaticPopup_EscapePressed() then InterfaceOptionsFrameCancel:Click() end - return - end - ToggleGameMenu_Orig(clicked) + ExitWithoutCommit(self); end -- --------------------------------------------------------------------------- --- Game menu entry +-- The old window's names -- --------------------------------------------------------------------------- --- Goes right above Key Bindings. Stock anchors Key Bindings under Interface --- Options and Turtle under its single Options button, so the new button takes --- over whatever anchor Key Bindings has and Key Bindings moves under it. --- --- The splice waits for the menu's first show. Other addons insert their own --- buttons the same way -- ShaguTweaks anchors "Advanced Options" under --- Interface Options and moves Key Bindings under it -- and they load after --- us. Splicing at load time would claim the slot first, and the later addon --- would anchor its button on the same spot as ours. By the first show every --- addon has placed its buttons, so ours goes into the chain as it stands. -local menuButton = CreateFrame("Button", "GameMenuButtonAddOnOptions", GameMenuFrame, "GameMenuButtonTemplate") -menuButton:SetText(ADDON_OPTIONS) -local spliced -GameMenuFrame:HookScript("OnShow", function() - if spliced then return end - spliced = true - local point, relativeTo, relativePoint, x, y = GameMenuButtonKeybindings:GetPoint() - menuButton:SetPoint(point, relativeTo, relativePoint, x, y) - GameMenuButtonKeybindings:ClearAllPoints() - GameMenuButtonKeybindings:SetPoint(point, menuButton, relativePoint, x, y) - GameMenuFrame:SetHeight(GameMenuFrame:GetUnscaledHeight() + menuButton:GetUnscaledHeight() - y) -end) -menuButton:SetScript("OnClick", function() - PlaySound("igMainMenuOption") - ShowUIPanel(frame) - frame.lastFrame = GameMenuFrame -end) +InterfaceOptionsFrame = SettingsPanel; +InterfaceOptionsFrameAddOns = categoryList; +InterfaceOptionsFrameCategories = categoryList; +InterfaceOptionsFrameAddOnsList = categoryList.ScrollBox; +InterfaceOptionsFrameAddOnsListScrollBar = categoryList.ScrollBar; +InterfaceOptionsFramePanelContainer = canvas; +InterfaceOptionsFrameOkay = SettingsPanel.CloseButton; + +categoryList.buttons = {}; +categoryList.buttonHeight = 20; +categoryList.update = InterfaceAddOnsList_Update; + +hooksecurefunc(SettingsPanel, "DisplayLayout", function(self, layout) + if layout and layout:GetLayoutType() == SettingsLayoutMixin.LayoutType.Canvas then + canvas.displayedPanel = layout:GetFrame(); + else + canvas.displayedPanel = nil; + end +end); + +local cancel = CreateFrame("Button", "InterfaceOptionsFrameCancel", SettingsPanel, "UIPanelButtonTemplate"); +cancel:SetText(CANCEL); +cancel:Hide(); +cancel:SetScript("OnClick", function() + SettingsPanel:ExitWithoutCommit(); +end); + +local defaults = CreateFrame("Button", "InterfaceOptionsFrameDefaults", SettingsPanel, "UIPanelButtonTemplate"); +defaults:SetText(SETTINGS_DEFAULTS); +defaults:Hide(); +defaults:SetScript("OnClick", function() + SettingsPanel:SetCurrentCategorySettingsToDefaults(); +end); diff --git a/src/embed/AddOns/!!!ClassicAPI/FrameXML/InterfaceOptions.xml b/src/embed/AddOns/!!!ClassicAPI/FrameXML/InterfaceOptions.xml deleted file mode 100644 index 250f345a..00000000 --- a/src/embed/AddOns/!!!ClassicAPI/FrameXML/InterfaceOptions.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - InterfaceOptionsListButton_OnClick(this) - - - - - - - - - - - - - - - - - diff --git a/src/embed/AddOns/!!!ClassicAPI/FrameXML/MinimalSlider.lua b/src/embed/AddOns/!!!ClassicAPI/FrameXML/MinimalSlider.lua new file mode 100644 index 00000000..7511569d --- /dev/null +++ b/src/embed/AddOns/!!!ClassicAPI/FrameXML/MinimalSlider.lua @@ -0,0 +1,249 @@ +-- Backport of retail's Blizzard_SharedXML/Shared/Slider/MinimalSlider.lua. +-- +-- Differences from the retail source: +-- - The bar is 1.12's OptionsSliderTemplate backdrop (see MinimalSlider.xml), +-- set here because the template has no atlas pieces. +-- - No SetObeyStepOnDrag: this client's slider always rounds its value to +-- the step. +-- - Thumb is the slider's thumb texture, read here: retail's template names +-- it with a parentKey. +-- - No narration: this client has none. +-- - SetValue does not report the value it sets. 1.12's slider rounds every +-- value to the step in single-precision floats, and the rounding does +-- not settle: a value that comes back through a setting rounds a hair +-- away again and fires OnValueChanged again, so the Settings slider and +-- its setting called each other until the stack ran out. When the value +-- the slider lands on is within rounding of the one asked for, +-- OnValueChanged updates the labels and steppers but does not trigger +-- the OnValueChanged event; the caller already has the value. + +local STEPPER_DISABLED_ALPHA = 0.5; + +local SLIDER_BACKDROP = { + bgFile = "Interface\\Buttons\\UI-SliderBar-Background", + edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", + tile = true, + tileSize = 8, + edgeSize = 8, + insets = { left = 3, right = 3, top = 6, bottom = 6 }, +}; + +MinimalSliderMixin = {}; + +function MinimalSliderMixin:OnLoad() + self:SetBackdrop(SLIDER_BACKDROP); + self.Thumb = self:GetThumbTexture(); +end + +function MinimalSliderMixin:Release() + self:SetScript("OnValueChanged", nil); +end + +local function NoModification(value) + return value; +end + +function CreateMinimalSliderFormatter(labelType, value) + local formatter = nil; + if value == nil then + formatter = NoModification; + elseif type(value) == "function" then + formatter = value; + else + -- Ignores the control value and returns the function argument instead. + formatter = function(v) + return value; + end; + end + return formatter; +end + +MinimalSliderWithSteppersMixin = CreateFromMixins(CallbackRegistryMixin); + +MinimalSliderWithSteppersMixin:GenerateCallbackEvents( + { + "OnValueChanged", + "OnInteractStart", + "OnInteractEnd", + } +); + +MinimalSliderWithSteppersMixin.Label = EnumUtil.MakeEnum("Left", "Right", "Top", "Min", "Max"); + +local interactionFlags = { + Hover = 1, + Click = 2, +}; + +function MinimalSliderWithSteppersMixin:OnLoad() + CallbackRegistryMixin.OnLoad(self); + + self.InteractionFlags = CreateFromMixins(FlagsMixin); + self.InteractionFlags:OnLoad(); + + local forward = false; + self.Back:SetScript("OnClick", GenerateClosure(self.OnStepperClicked, self, forward)); + + local backward = true; + self.Forward:SetScript("OnClick", GenerateClosure(self.OnStepperClicked, self, backward)); + + local function OnMouseDown(slider) + if slider:IsEnabled() then + self:SetInteractionFlag(interactionFlags.Click); + PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON); + end + end + self.Slider:SetScript("OnMouseDown", OnMouseDown); + + local function OnMouseUp(slider) + if slider:IsEnabled() then + self:ClearInteractionFlag(interactionFlags.Click); + end + end + self.Slider:SetScript("OnMouseUp", OnMouseUp); + + local function OnEnter(slider) + if slider:IsEnabled() then + self:SetInteractionFlag(interactionFlags.Hover); + end + end + self.Slider:SetScript("OnEnter", OnEnter); + + local function OnLeave(slider) + if slider:IsEnabled() then + self:ClearInteractionFlag(interactionFlags.Hover); + end + end + self.Slider:SetScript("OnLeave", OnLeave); +end + +function MinimalSliderWithSteppersMixin:OnStepperClicked(forward) + local value = self.Slider:GetValue(); + local step = self.Slider:GetValueStep(); + if forward then + self.Slider:SetValue(value + step); + else + self.Slider:SetValue(value - step); + end + + PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON); +end + +local function SetStepperButtonEnabled(button, enabled) + button:SetEnabled(enabled); + button:SetAlpha(enabled and 1.0 or STEPPER_DISABLED_ALPHA); + button:DesaturateHierarchy(enabled and 0 or 1); +end + +function MinimalSliderWithSteppersMixin:UpdateStepperStates() + if not self:IsSliderEnabled() then + return; + end + + local value = self.Slider:GetValue(); + local minValue, maxValue = self.Slider:GetMinMaxValues(); + local step = self.Slider:GetValueStep(); + local atMin = value <= minValue + (step * 0.5); + local atMax = value >= maxValue - (step * 0.5); + SetStepperButtonEnabled(self.Back, not atMin); + SetStepperButtonEnabled(self.Forward, not atMax); +end + +function MinimalSliderWithSteppersMixin:Init(value, minValue, maxValue, steps, formatters) + self.Slider:SetMinMaxValues(minValue, maxValue); + self.Slider:SetValueStep((maxValue - minValue) / steps); + self.Slider:SetValue(value); + + self.formatters = formatters; + self:FormatValue(value); + self:UpdateStepperStates(); + + local function OnValueChanged(slider, value) + self:FormatValue(value); + self:UpdateStepperStates(); + + local requested = self.requestedValue; + if requested and math.abs(value - requested) <= slider:GetValueStep() * 0.001 then + return; + end + + self:TriggerEvent(MinimalSliderWithSteppersMixin.Event.OnValueChanged, value); + end + self.Slider:SetScript("OnValueChanged", OnValueChanged); +end + +function MinimalSliderWithSteppersMixin:SetInteractionFlag(flag) + local wasAnySet = self.InteractionFlags:IsAnySet(); + self.InteractionFlags:Set(flag); + if not wasAnySet then + self:TriggerEvent(MinimalSliderWithSteppersMixin.Event.OnInteractStart); + end +end + +function MinimalSliderWithSteppersMixin:ClearInteractionFlag(flag) + local wasAnySet = self.InteractionFlags:IsAnySet(); + self.InteractionFlags:Clear(flag); + if wasAnySet and not self.InteractionFlags:IsAnySet() then + self:TriggerEvent(MinimalSliderWithSteppersMixin.Event.OnInteractEnd); + end +end + +function MinimalSliderWithSteppersMixin:FormatValue(value) + if not self.formatters then + return; + end + + for labelID, formatter in pairs(self.formatters) do + local label = self.Labels[labelID]; + if label then + label:SetText(formatter(value)); + label:Show(); + end + end +end + +local function ConfigureSlider(self, color, alpha) + self.Slider.Thumb:SetAlpha(alpha); + + local r, g, b = color:GetRGB(); + self.LeftText:SetVertexColor(r, g, b); + self.RightText:SetVertexColor(r, g, b); + self.TopText:SetVertexColor(r, g, b); + self.MinText:SetVertexColor(r, g, b); + self.MaxText:SetVertexColor(r, g, b); +end + +function MinimalSliderWithSteppersMixin:SetEnabled(enabled) + self.sliderEnabled = enabled; + if enabled then + ConfigureSlider(self, NORMAL_FONT_COLOR, 1.0); + else + ConfigureSlider(self, GRAY_FONT_COLOR, .7); + end + self.Slider:SetEnabled(enabled); + + if enabled then + self:UpdateStepperStates(); + else + SetStepperButtonEnabled(self.Back, false); + SetStepperButtonEnabled(self.Forward, false); + end +end + +function MinimalSliderWithSteppersMixin:SetValue(value) + self.requestedValue = value; + self.Slider:SetValue(value); + self.requestedValue = nil; +end + +function MinimalSliderWithSteppersMixin:IsSliderEnabled() + return self.sliderEnabled ~= false; +end + +function MinimalSliderWithSteppersMixin:Release() + self.Slider:Release(); + + for index, label in ipairs(self.Labels) do + label:Hide(); + end +end diff --git a/src/embed/AddOns/!!!ClassicAPI/FrameXML/MinimalSlider.xml b/src/embed/AddOns/!!!ClassicAPI/FrameXML/MinimalSlider.xml new file mode 100644 index 00000000..c91604cd --- /dev/null +++ b/src/embed/AddOns/!!!ClassicAPI/FrameXML/MinimalSlider.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/embed/AddOns/!!!ClassicAPI/FrameXML/MinimalTab.lua b/src/embed/AddOns/!!!ClassicAPI/FrameXML/MinimalTab.lua new file mode 100644 index 00000000..fcdedf36 --- /dev/null +++ b/src/embed/AddOns/!!!ClassicAPI/FrameXML/MinimalTab.lua @@ -0,0 +1,75 @@ +-- Backport of retail's Blizzard_SharedXML/Shared/Tabs/MinimalTab.lua. +-- +-- The one difference: retail sets the three pieces from Options_Tab +-- atlases, which this client does not have. The tab is the tooltip backdrop +-- the Settings window frames its lists with, and UpdateAtlas colors it by +-- state: the selected tab is lighter with a gold edge, a hovered tab a little +-- lighter than the others. + +local TAB_BACKDROP = +{ + bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", + edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", + tile = true, tileSize = 16, edgeSize = 16, + insets = { left = 5, right = 5, top = 5, bottom = 5 }, +}; + +MinimalTabMixin = {}; + +function MinimalTabMixin:OnLoad() + SelectableButtonMixin.OnLoad(self); + self:SetBackdrop(TAB_BACKDROP); + + self.Text:SetText(self.tabText); + self:SetWidth(self.Text:GetStringWidth() + 40); + + self:OnSelected(false); +end + +function MinimalTabMixin:UpdateAtlas() + if self:IsSelected() then + self:SetBackdropColor(0.25, 0.25, 0.25, 0.9); + self:SetBackdropBorderColor(1, 0.82, 0); + elseif self.over then + self:SetBackdropColor(0.15, 0.15, 0.15, 0.8); + self:SetBackdropBorderColor(0.8, 0.8, 0.8); + else + self:SetBackdropColor(0, 0, 0, 0.5); + self:SetBackdropBorderColor(0.6, 0.6, 0.6); + end +end + +function MinimalTabMixin:OnSelected(newSelected) + self:UpdateAtlas(); + + self.Text:SetPoint("CENTER", 0, 0); + if newSelected then + self.Text:SetFontObject("GameFontHighlightSmall"); + else + self.Text:SetFontObject(self.over and "GameFontHighlightSmall" or "GameFontNormalSmall"); + end +end + +function MinimalTabMixin:OnEnter() + self.over = true; + self:UpdateAtlas(); + if not self:IsSelected() then + self.Text:SetFontObject("GameFontHighlightSmall"); + end +end + +function MinimalTabMixin:OnLeave() + self.over = nil; + self:UpdateAtlas(); + if not self:IsSelected() then + self.Text:SetFontObject("GameFontNormalSmall"); + end +end + +function MinimalTabMixin:OnEnable() + self:UpdateAtlas(); +end + +function MinimalTabMixin:OnDisable() + self:UpdateAtlas(); +end diff --git a/src/embed/AddOns/!!!ClassicAPI/FrameXML/MinimalTab.xml b/src/embed/AddOns/!!!ClassicAPI/FrameXML/MinimalTab.xml new file mode 100644 index 00000000..c6070fe9 --- /dev/null +++ b/src/embed/AddOns/!!!ClassicAPI/FrameXML/MinimalTab.xml @@ -0,0 +1,29 @@ + + + + diff --git a/src/embed/AddOns/!!!ClassicAPI/FrameXML/SelectableButton.lua b/src/embed/AddOns/!!!ClassicAPI/FrameXML/SelectableButton.lua new file mode 100644 index 00000000..43f88fca --- /dev/null +++ b/src/embed/AddOns/!!!ClassicAPI/FrameXML/SelectableButton.lua @@ -0,0 +1,52 @@ +-- Verbatim backport of retail's Blizzard_SharedXML/SelectableButton.lua. + +SelectableButtonMixin = {}; + +function SelectableButtonMixin:OnLoad() + self.selected = false; +end + +function SelectableButtonMixin:Reset() + self.CanChangeSelectionOverride = nil; + self.selected = false; +end + +function SelectableButtonMixin:OnClick() + return self:SetSelected(not self:IsSelected()); +end + +function SelectableButtonMixin:CanChangeSelection(newSelected) + if self:IsSelected() == newSelected then + return false; + end + + if self.SelectionChangeInterrupt then + return self.SelectionChangeInterrupt(self, newSelected); + end + + return true; +end + +function SelectableButtonMixin:SetSelectionChangeInterrupt(callback) + self.SelectionChangeInterrupt = callback; +end + +function SelectableButtonMixin:IsSelected() + return not not self.selected; +end + +function SelectableButtonMixin:SetSelected(newSelected) + if self:CanChangeSelection(newSelected) then + self:SetSelectedState(newSelected); + self:OnSelected(newSelected); + end +end + +function SelectableButtonMixin:OnSelected(newSelected) +-- Derive +end + +function SelectableButtonMixin:SetSelectedState(newSelected) + -- Derive + self.selected = newSelected; +end \ No newline at end of file diff --git a/src/embed/AddOns/!!!ClassicAPI/FrameXML/SelectableButton.xml b/src/embed/AddOns/!!!ClassicAPI/FrameXML/SelectableButton.xml new file mode 100644 index 00000000..139fb2b9 --- /dev/null +++ b/src/embed/AddOns/!!!ClassicAPI/FrameXML/SelectableButton.xml @@ -0,0 +1,9 @@ + + + + diff --git a/src/embed/AddOns/!!!ClassicAPI/FrameXML/SharedUIPanelTemplates.lua b/src/embed/AddOns/!!!ClassicAPI/FrameXML/SharedUIPanelTemplates.lua index ee6c386a..daa3b811 100644 --- a/src/embed/AddOns/!!!ClassicAPI/FrameXML/SharedUIPanelTemplates.lua +++ b/src/embed/AddOns/!!!ClassicAPI/FrameXML/SharedUIPanelTemplates.lua @@ -11,6 +11,10 @@ -- - 1.12 FrameXML owns UIPanelCloseButton (its own OnClick), so -- UIPanelCloseButtonDefaultAnchors inherits UIPanelCloseButtonNoScripts -- and runs UIPanelCloseButton_OnClick itself. +-- - DropdownWithSteppersMixin has no gamepad cursor anchors: this client +-- has no gamepad navigation. +-- - 1.12's Button:IsEnabled returns 1 or 0, and 0 is true in Lua, so +-- DropdownWithSteppersMixin compares the dropdown's with 1. function TruncatedTooltipScript_OnEnter(self) local text = self.truncatedTooltipScriptText or self.Text; @@ -305,3 +309,88 @@ end function PanelResizeButtonMixin:SetOnResizeCallback(resizeCallback) self.resizeCallback = resizeCallback; end + +DropdownWithSteppersMixin = {}; + +function DropdownWithSteppersMixin:OnLoad() + self.IncrementButton:SetPoint("LEFT", self.Dropdown, "RIGHT", (self.incrementOffsetX or 4), 0); + self.IncrementButton:SetScript("OnClick", GenerateClosure(self.OnIncrementClicked, self)); + + self.DecrementButton:SetPoint("RIGHT", self.Dropdown, "LEFT", (self.decrementOffsetX or -5), 0); + self.DecrementButton:SetScript("OnClick", GenerateClosure(self.OnDecrementClicked, self)); + + local function OnUpdate(o, previousRadio, nextRadio, selections) + local canDecrement = previousRadio ~= nil; + local canIncrement = nextRadio ~= nil; + self:SetSteppersEnabled(canDecrement, canIncrement); + end + + self.Dropdown:RegisterCallback(DropdownButtonMixin.Event.OnUpdate, OnUpdate); +end + +function DropdownWithSteppersMixin:SetEnabled(enabled) + self.Dropdown:SetEnabled(enabled); + self:UpdateSteppers(); +end + +function DropdownWithSteppersMixin:OnIncrementClicked(button, buttonName, down) + self:Increment(); + + PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON); +end + +function DropdownWithSteppersMixin:OnDecrementClicked(button, buttonName, down) + self:Decrement(); + + PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON); +end + +function DropdownWithSteppersMixin:Increment() + self.Dropdown:Increment(); +end + +function DropdownWithSteppersMixin:Decrement() + self.Dropdown:Decrement(); +end + +function DropdownWithSteppersMixin:HideSteppers() + self.DecrementButton:Hide(); + self.IncrementButton:Hide(); +end + +function DropdownWithSteppersMixin:ShowSteppers() + self.DecrementButton:Show(); + self.IncrementButton:Show(); +end + +function DropdownWithSteppersMixin:SetSteppersShown(shown) + self.DecrementButton:SetShown(shown); + self.IncrementButton:SetShown(shown); +end + +function DropdownWithSteppersMixin:SetSteppersEnabled(canDecrement, canIncrement) + if self.Dropdown:IsEnabled() == 1 then + self.DecrementButton:SetEnabled(canDecrement); + self.IncrementButton:SetEnabled(canIncrement); + else + self.DecrementButton:SetEnabled(false); + self.IncrementButton:SetEnabled(false); + end +end + +function DropdownWithSteppersMixin:UpdateSteppers() + if self.Dropdown:IsEnabled() == 1 then + local previousRadio, nextRadio, selections = self.Dropdown:CollectSelectionData(); + local canDecrement = previousRadio ~= nil; + local canIncrement = nextRadio ~= nil; + self:SetSteppersEnabled(canDecrement, canIncrement); + else + self:SetSteppersEnabled(false, false); + end +end + +DropdownWithSteppersAndLabelMixin = CreateFromMixins(DropdownWithSteppersMixin); + +function DropdownWithSteppersAndLabelMixin:SetText(text) + self.Label:SetText(text); +end diff --git a/src/embed/AddOns/!!!ClassicAPI/FrameXML/SharedUIPanelTemplates.xml b/src/embed/AddOns/!!!ClassicAPI/FrameXML/SharedUIPanelTemplates.xml index 6ba13ce7..d16d9d5b 100644 --- a/src/embed/AddOns/!!!ClassicAPI/FrameXML/SharedUIPanelTemplates.xml +++ b/src/embed/AddOns/!!!ClassicAPI/FrameXML/SharedUIPanelTemplates.xml @@ -13,6 +13,13 @@ - The resize grip is the chat frame's expand arrow, turned to point at the corner. - No FrameGlow, gamepad jump hints, TopTileStreaks or button bar. + - DarkMenuElementTemplate's hover is 1.12's dropdown highlight + (UI-QuestTitleHighlight), stretched over the row: the + common-dropdown-customize-mouseover atlas is art this client does not + have. + - The dropdown steppers are the spellbook's page arrows. Retail's + SteppersIncrementButtonTemplate and SteppersDecrementButtonTemplate + are atlases. -->