Quantcast
Download
(132Kb)
Download
Updated: 06-20-21 04:07 PM
Pictures
File Info
Compatibility:
The Burning Crusade Classic (2.5.1)
Updated:06-20-21 04:07 PM
Created:06-24-19 05:05 PM
Downloads:13,141
Favorites:38
MD5:
Categories:Classic - General, Mage

MageButtons (Classic)  Updated this week!  Popular! (More than 5000 hits)

Version: 1.04
by: Moxey [More]

MageButtons
- Purpose: Adds "menu" buttons for mage spell categories: water, food, teleports, portals, mana gems, polymorph

Features
- Consolidates spells into collapsible buttons to save bar space (like modern teleports/portals buttons)
- Horizontal or Vertical layouts
- Menu direction left/right/up/down
- Customizable button size, padding, background color, border
- Can specify button order
- Buttons can be keybound via standard bindings page (under Addons)

Other
- First time loading it will default to a set button order, need to go into Options and actually set them for them to save (will say "not set")

Known issues / TODO:
- Keybindings are wonky, probably because I'm doing something wrong, but they mostly work?
- Need to reload UI when new spells are learned from trainer so the addon will pick them up
- Not sure if the Polymorph button is worth it, was thinking it would be nice to easily switch from Sheep to Turtle to Pig
- Could add AI for easy access to lower ranks for lower level players
- Lock/unlock from options panel is out of sync with minimap click
- New spells learned from trainers are not automatically added, need to /reload

1.04 - Hopefully fixed startup error
1.03 - Increased startup delay
1.02 - Updated with TBC spells
1.01 - Set menu button strata to HIGH, updated usage
1.00 - Added mouseover option, minimap icon will now default to on
0.99 - Fix to minimap button, slash commands
0.99 - Largely rewritten, most settings changes should now occur without needing to reload
0.90 - Added check to config file to not load if character isn't a mage
Archived Files (8)
File Name
Version
Size
Author
Date
1.03
132kB
Moxey
05-18-21 05:25 PM
1.02
132kB
Moxey
05-13-21 03:00 PM
1.01
131kB
Moxey
09-04-19 04:03 PM
1.00
131kB
Moxey
08-15-19 08:13 PM
0.99
131kB
Moxey
08-11-19 02:59 PM
0.99
131kB
Moxey
08-09-19 06:17 PM
0.99
159kB
Moxey
08-08-19 09:29 PM
0.90
130kB
Moxey
06-24-19 07:59 PM


Post A Reply Comment Options
Unread 06-22-21, 08:34 AM  
lfxgroove
A Kobold Labourer

Forum posts: 0
File comments: 2
Uploads: 0
Originally Posted by endymon
Hopefully we can get a repo. IMO, every project should have a repo, even if it isn't used much.
I've went ahead and created a repo containing your published version of the code along with some fixes discussed in the comments below here: https://github.com/lfxgroove/MageButtons. Let me know if you want ownership/want me to take it down, don't mean to step on your toes or anything, just thought it'd be nice to have someplace where it's versioned
Report comment to moderator  
Reply With Quote
Unread 06-22-21, 08:16 AM  
endymon
A Kobold Labourer

Forum posts: 0
File comments: 6
Uploads: 0
Originally Posted by lfxgroove
If it's fine with you I could create a github repo? I've got a more proper fix for the spells not loading, you should wait for the spells to load by watching the SPELL_DATA_LOAD_RESULT event, and once all spells have been loaded continue with the UI setup, that seems to work well for me at least. And it allows us to remove the C_Timer calls. The event will start plopping up after calling C_Spell.RequestLoadSpellData as was suggested by endymon.
Oooo thats even better. I'm just dipping my toes into modding, so I was looking for an event like that... but nothing jumped out at me.
Preferably we should only make ONE call to fetch spell data, but I was too lazy to figure out how to properly merge all the tables of spell IDs into one for purposes of making that call.

Hopefully we can get a repo. IMO, every project should have a repo, even if it isn't used much.

Originally Posted by lclancey
This small letter case error caused the problem that everytime you re-login game, the frame would restore to its default posion.
I don't think that line fixes the load reset problem. (What did fix it was my change on line 35
Code:
 MageButtonsDB = MageButtonsDB or {}
)
But it does look like it would fix the /command for locking not working. Good catch there.
Report comment to moderator  
Reply With Quote
Unread 06-22-21, 03:20 AM  
lfxgroove
A Kobold Labourer

Forum posts: 0
File comments: 2
Uploads: 0
Originally Posted by Moxey
Think I may have finally fixed the startup error. Since it occurs inconsistently (for me, anyway), I'm going to give it a few days of testing.

No source control, this was just a pet project of mine that I thought other people might get some use out of.
If it's fine with you I could create a github repo? I've got a more proper fix for the spells not loading, you should wait for the spells to load by watching the SPELL_DATA_LOAD_RESULT event, and once all spells have been loaded continue with the UI setup, that seems to work well for me at least. And it allows us to remove the C_Timer calls. The event will start plopping up after calling C_Spell.RequestLoadSpellData as was suggested by endymon.
Report comment to moderator  
Reply With Quote
Unread 06-21-21, 09:09 PM  
lclancey
A Kobold Labourer

Forum posts: 0
File comments: 1
Uploads: 0
Bug Fix for not saving frame position.

Line 63 to line 65 in file ./MageButtons.lua
magebuttons:lockAnchor()
should be
MageButtons:lockAnchor()
This small letter case error caused the problem that everytime you re-login game, the frame would restore to its default posion.

And yes, I think a source control repo, like github, would help a lot, too, makes people easily to make contributions, instead I have to register an account in this forum to leave this comment.
Report comment to moderator  
Reply With Quote
Unread 06-20-21, 02:34 AM  
Dissosiative
A Defias Bandit

Forum posts: 2
File comments: 3
Uploads: 0
Any Easy way to make it for portals when you click on it from the flipout options instead of it swapping the spell it just casts it?
Report comment to moderator  
Reply With Quote
Unread 06-16-21, 06:15 PM  
endymon
A Kobold Labourer

Forum posts: 0
File comments: 6
Uploads: 0
I believe I fixed the initial loading problem.
It was caused by spell information not yet having been downloaded from the server. So now that is forced.
Additionally cleaned up an "evil" eval. (so I could actually debug the problem)


Add these helper function somewhere (up top makes sense)
Code:
local function make_spell_table(spell_id_list)
  local tbl = {}
  --print(spell_id_list)

  for i = 1, #spell_id_list, 1 do
    if IsSpellKnown(spell_id_list[i]) then
      local name = GetSpellInfo(spell_id_list[i])
      local subtext = GetSpellSubtext(spell_id_list[i]) or ''  -- NOTE will return nil at first unless its locally cached
      name = name .. "(" .. subtext .. ")"  -- For some reason the "()" are required for tooltips
      table.insert(tbl, name)
    end
  end

  return tbl
end

local function preload_spell_data(spell_id_list)
    for k = 1, #spell_id_list, 1 do
        C_Spell.RequestLoadSpellData(spell_id_list[k])
    end
end
Replace the entire onEvent function (tabbing may not be aligned right, but can be ignored)
Code:
local function onevent(self, event, addonName, ...)
    if (addonName ~= "MageButtons" or  event ~= "ADDON_LOADED") then
        return
    end
	--print(event)
		
	-- Set up lists of spells
    -- Bottom <--> Top
	WaterSpells = {5504, 5505, 5506, 6127, 10138, 10139, 10140, 37420, 43987, 27090}
	FoodSpells  = {587, 597, 990, 6129, 10144, 10145, 28612, 33717}
	TeleportSpells = {}
	PortalSpells  = {}

	if UnitFactionGroup("player") == "Alliance" then
              -- Darnassus (3565), Exodar (32271), Theramore (49359), Ironforge (3562), Stormwind (3561), Shattrath (33690)
		TeleportSpells = {3565, 32271, 49359, 3562, 3561, 33690} -- {3565, 3561, 3562, 32271, 49359, 33690}
              -- Darnassus (11419), Exodar (32266) Theramore (49360) Ironforge (11416) Stormwind (10059), Shattrath (33691)
		PortalSpells   = {11419, 32266, 49360, 11416, 10059, 33691} -- {11419, 10059, 11416, 32266, 49360, 33691}
	else
              -- Silvermoon (32272), Undercity (3563), Thunder Bluff (3566), Stonard (49358), Orgrimmar (3567), Shattrath (35715)
		TeleportSpells = {32272, 3563, 3566, 49358, 3567, 35715} -- {3566, 3563, 3567, 32272, 49358, 35715}
              -- Silvermoon (32267), Undercity (11418), Thunder Bluff (11420), Stonard (49361), Orgrimmar (11417), Shattrath (35717)
		PortalSpells   = {32267, 11418, 11420, 49361, 11417, 35717} -- {11420, 11418, 11417, 32267, 49361, 35717}
	end
	GemSpells = {759, 3552, 10053, 10054, 27101}
    -- pig, turtle, ???
    PolymorphSpells = {28272, 28271, 28270}  -- REM: insert basic sheep a little later
			
    -- Immediately load spell data (for rank info) so it'll be available a little later to create the addon buttons
    preload_spell_data(WaterSpells)
    preload_spell_data(FoodSpells)
    preload_spell_data(TeleportSpells)
    preload_spell_data(PortalSpells)
    preload_spell_data(GemSpells)
    preload_spell_data(PolymorphSpells)
    preload_spell_data({12826, 12825, 12824, 118}) -- Basic sheep spell ranks

	-- Needs a slight delay on initial startup to allow for spell data to load
	C_Timer.After(6, function()

		-- Choose the highest rank of sheep polymorph
        local sheep = 9999 -- A spell you will never know

		if     IsSpellKnown(12826) then sheep = 12826   -- rank 4
		elseif IsSpellKnown(12825) then sheep = 12825   -- rank 3
		elseif IsSpellKnown(12824) then sheep = 12824   -- rank 2
		elseif IsSpellKnown(118)   then sheep = 118     -- rank 1
           end
		table.insert(PolymorphSpells, 1, sheep)

        -- Create the various spell tables using helper function
        WaterTable     = make_spell_table(WaterSpells)
        FoodTable      = make_spell_table(FoodSpells)
        TeleportsTable = make_spell_table(TeleportSpells)
        PortalsTable   = make_spell_table(PortalSpells)
        GemsTable      = make_spell_table(GemSpells)
        PolymorphTable = make_spell_table(PolymorphSpells)
			
		-- Get saved frame location
		local relPoint, anchorX, anchorY = addon:getAnchorPosition()
		MageButtonsConfig:ClearAllPoints()
		MageButtonsConfig:SetPoint(relPoint, UIParent, relPoint, anchorX, anchorY)
		
		
		addon:makeBaseButtons()

		-----------------
		-- Data Broker --
		-----------------
		lockStatus = addon:getSV("framelock", "lock")
		
		db = LibStub("AceDB-3.0"):New("MageButtonsDB", SettingsDefaults)
		MageButtonsDB.db = db;
		MageButtonsMinimapData = ldb:NewDataObject("MageButtons",{
			type = "data source",
			text = "MageButtons",
			icon = "Interface/Icons/Spell_Holy_MagicalSentry.blp",
			OnClick = function(self, button)
				if button == "RightButton" then
					if IsShiftKeyDown() then
						MageButtons:maptoggle("0")
						print("MageButtons: Hiding icon, re-enable with: /MageButtons minimap 1")
					else
						InterfaceOptionsFrame_OpenToCategory(mbPanel)
						InterfaceOptionsFrame_OpenToCategory(mbPanel)
						InterfaceOptionsFrame_OpenToCategory(mbPanel)
					end
				
				elseif button == "LeftButton" then
					if lockStatus == 0 then
						-- Not locked, lock it and save the anchor position
						addon:lockAnchor()
					else
						-- locked, unlock
						addon:unlockAnchor()
					end
				end
			end,
			
			-- Minimap Icon tooltip
			OnTooltipShow = function(tooltip)
				tooltip:AddLine("|cffffffffMageButtons|r\nLeft-click to lock/unlock.\nRight-click to configure.\nShift+Right-click to hide minimap button.")
			end,
		})
		
		-- display the minimap icon?
		local mmap = addon:getSV("minimap", "icon") or 1
		if mmap == 1 then
			MageButtonsMinimapIcon:Register("mageButtonsIcon", MageButtonsMinimapData, MageButtonsDB)
			addon:maptoggle(1)
		else
			addon:maptoggle(0)
		end
	end); --end of slight delay
end
Report comment to moderator  
Reply With Quote
Unread 06-16-21, 03:29 PM  
Moxey
A Kobold Labourer
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 11
Uploads: 3
Think I may have finally fixed the startup error. Since it occurs inconsistently (for me, anyway), I'm going to give it a few days of testing.

No source control, this was just a pet project of mine that I thought other people might get some use out of.
Report comment to moderator  
Reply With Quote
Unread 06-16-21, 03:01 PM  
endymon
A Kobold Labourer

Forum posts: 0
File comments: 6
Uploads: 0
Is there a source control repo for this addon? github hopefully?
Report comment to moderator  
Reply With Quote
Unread 06-16-21, 11:29 AM  
Grokthag
A Kobold Labourer

Forum posts: 0
File comments: 3
Uploads: 0
I'm having this error when login in:
Message: [string "WaterTable = {}..."]:4: attempt to concatenate a nil value
Time: Wed Jun 16 07:26:58 2021
Count: 1
Stack: [string "WaterTable = {}..."]:4: attempt to concatenate a nil value
[string "=[C]"]: ?
[string "WaterTable = {}
for i = 1, #WaterSpells, 1 do
if IsSpellKnown(WaterSpells[i]) then
local WaterName = GetSpellInfo(WaterSpells[i]) .. "(" .. GetSpellSubtext(WaterSpells[i]) .. ")"
--WaterTable[i] = WaterName
table.insert(WaterTable, WaterName)
end
end "]:4: in function `cmdRun2'
[string "@Interface\AddOns\MageButtons\MageButtons.lua"]:179: in function <Interface\AddOns\MageButtons\MageButtons.lua:119>

Locals:
Report comment to moderator  
Reply With Quote
Unread 05-23-21, 07:27 PM  
hobox10
A Kobold Labourer

Forum posts: 0
File comments: 8
Uploads: 0
Originally Posted by Moxey
The fail to load on startup is an odd one, I think it has something to do with querying the spellbook. Try increasing the time on line 119 in the main file (currently at 6, which was an increase of what it was for Classic). I have had it fail a few times myself so far in prepatch.
I tested minor increases and drastic increases and both failed to load the addon without needing a /reload
Report comment to moderator  
Reply With Quote
Unread 05-23-21, 04:54 PM  
Moxey
A Kobold Labourer
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 11
Uploads: 3
The fail to load on startup is an odd one, I think it has something to do with querying the spellbook. Try increasing the time on line 119 in the main file (currently at 6, which was an increase of what it was for Classic). I have had it fail a few times myself so far in prepatch.
Report comment to moderator  
Reply With Quote
Unread 05-21-21, 08:49 PM  
endymon
A Kobold Labourer

Forum posts: 0
File comments: 6
Uploads: 0
@hobox10
Sorry my fix doesn't work for you. I can confirm that is all I changed, though its possible that something might break with a fresh install (or with your configuration).

I have also seen it fail to load sometimes. But as mentioned /reload fixes it.

Another bug I noticed:
/magebuttons lock <<< won't accept the command (enter key is ignored)
/magebuttons unlock <<< acts as a toggle (both unlocks and locks), same as "move"

A would be nice feature would be the ability to remember which spell currently selected between sessions.
For instance, I rarely want exodar portals (usually stormwind), but unfortunately it always defaults back to exodar.
Obviously I can modify the order of the buttons (and I have)
Code:
ALLY
-- Darnassus (3565), Exodar (32271), Theramore (49359), Ironforge (3562), Stormwind (3561), Shattrath (33690)
TeleportsSpells = {3565, 32271, 49359, 3562, 3561, 33690}
-- Darnassus (11419), Exodar (32266) Theramore (49360) Ironforge (11416) Stormwind (10059), Shattrath (33691)
PortalsSpells   = {11419, 32266, 49360, 11416, 10059, 33691}

HORDE
-- Silvermoon (32272), Undercity (3563), Thunder Bluff (3566), Stonard (49358), Orgrimmar (3567), Shattrath (35715)
TeleportsSpells = {32272, 3563, 3566, 49358, 3567, 35715}
-- Silvermoon (32267), Undercity (11418), Thunder Bluff (11420), Stonard (49361), Orgrimmar (11417), Shattrath (35717)
PortalsSpells   = {32267, 11418, 11420, 49361, 11417, 35717}
Last edited by endymon : 05-21-21 at 09:23 PM.
Report comment to moderator  
Reply With Quote
Unread 05-21-21, 04:02 AM  
hobox10
A Kobold Labourer

Forum posts: 0
File comments: 8
Uploads: 0
Thanks for updating this to TBC! I find this addon essential and irreplaceable for the convenience it provides.

There's a few bugs remaining though, hopefully you are still working on things:
  • The frame backdrop strata still isn't set to high. Under line 676 should be buttonBackdrop:SetFrameStrata("HIGH")
  • As mentioned by endymon below, the placement of the bar is not being remembered. His fix did not work for me either.
  • As mentioned by Himitsu1990 below as well, the bar will not load when the game first launches. It requires a /reload to draw the bar after loading the game the first time.

I really hope you keep improving this addon.
Report comment to moderator  
Reply With Quote
Unread 05-20-21, 10:26 PM  
Himitsu1990
A Kobold Labourer

Forum posts: 0
File comments: 1
Uploads: 0
Sometimes, I don't know why, it just wont load. When I start the game and load to my mage main character - no addon in the list. But after I type /reload - it apper in same place as was and work perfect. My again, sometimes after reloging or coming back from another an alt, it not load until i type /reload
It just a random thing. For today was 3 times in like 30 characters swaping. Can it be fix for somehow?
Report comment to moderator  
Reply With Quote
Unread 05-20-21, 12:06 AM  
endymon
A Kobold Labourer

Forum posts: 0
File comments: 6
Uploads: 0
Found a solution for resetting position

The solution that found for the constantly resetting position was:
On line 35 change it to:
Code:
MageButtonsDB = MageButtonsDB or {}
Starting on line 36, Comment out all of this
Code:
if MageButtonsDB == nil then
	MageButtonsDB["position"] = {}
	MageButtonsDB["water"] = {}
	MageButtonsDB["food"] = {}
	MageButtonsDB["teleport"] = {}
	MageButtonsDB["portal"] = {}
	MageButtonsDB["managem"] = {}
	MageButtonsDB["ai"] = {}
end
I haven't tested this in the TBC version, but things look more or less the same, so it'll probably work the same.

Other issues that I noticed but haven't attempted to fix (because they are less important)
- Lock/unlock functionality is inconsistent at best
- Position only saved when re-locked
- Cmd "lock" doesn't work although it should.
- Help command doesn't list all the commands consistently
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: