Implementation

This is how Learning Aid works under the hood. It’s kinda messy.

Learning Aid

a UI AddOn for

by Clement Cherlin

Nitty-Gritty Details

Learning Aid uses two top-level frames, or windows. The main frame contains the AddOn’s main user interface. It has a title area with the name of the AddOn, a lock button to hold the AddOn in place, preventing the player from moving it by accident, and one or more columns of spell and/or ability buttons. The other is managed by the AceGUI library and handles the options panel.

Whenever the player character learns a new spell, or any of the spells in the spellbook change in any way, the game fires the event SPELLS_CHANGED. When this happens, the game notifies Learning Aid’s event handler, which calls the function LearningAid:DiffSpellBook(). DiffSpellBook compares the current contents of the player character’s spellbook to a saved copy from after the last time Learning Aid detected a change. If the change is not the addition, removal or significant alteration of a spell, which is often the case, Learning Aid does nothing and waits for another event.

If there are one or more new spells, Learning Aid inserts a button into its window for each new spell, sets each button’s icon and label to the image and name of one of the new spells, makes a note of the spell’s internal numerical ID, resizes its frame to fit the number of buttons inside it and displays the frame. At this point, the user will generally drag the new spells to their action bar, and once finished, close the AddOn window.

Each time the player moves the mouse cursor on top of a spell or ability button, Learning Aid receives an OnEnter widget event for that button, and responds by displaying a pop-up tooltip for the spell. When the player clicks and drags one of the spells/abilities, Learning Aid receives an OnDragStart widget event and places the spell/ability on the mouse cursor so the player can drop it onto an action bar. The player can also link the spell into a chat window by shift-clicking on the spell with a chat window open, which triggers the OnModifiedClick widget event, with a parameter signifying that the shift key is held down.