Quantcast Secure action buttons OnReceiveDrag and mounts - Page 2 - WoWInterface
 
Thread Tools Display Modes
09-29-14, 03:06 PM   #21
Alternator
A Fallenroot Satyr
 
Alternator's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 20
You know,
Here I was inventing more complicated solutions!
I might give that idea a try and see how it behaves for me. Cheers.
 
09-29-14, 08:02 PM   #22
Alternator
A Fallenroot Satyr
 
Alternator's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 20
Heh - Fun Fact :S

Call PickupCompanion("mount", 2) ... You will put the Albino Drake on the cursor. (Edit: It seems this only holds up to a point - it's mainly academic anyway since thats not how the UI works)

Then call GetCursorInfo()... And now suddenly we get the correct Index.

Even more amusing... Place the Action onto a Standard Action Button and you can now query back the correct SpellID, and the button works as expected
And if you pick it back up from the Action Button and query the cursor, again it is reporting the correct ID.


It looks like there are some how two competing systems under the hood for Mounts, but the broken one is currently in use in the system (Broken for Addon Author Purposes at least).

Last edited by Alternator : 10-01-14 at 06:35 PM.
 
09-30-14, 10:21 PM   #23
Alternator
A Fallenroot Satyr
 
Alternator's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 20
Sorry for spamming this thread, but just in case it is helpful

I opted to not use the cursor scanning approach, and found something which I haven't tested a lot yet but I think will work ok. (though hooksecurefunc is needed).

I determined that GetActionInfo is returning that same useless Index...
But that GameTooltip:GetSpell() will return the correct SpellID for the Mount...
In theory (and someone may rain on this?!) when picking up an action from an Action Button the tooltip for the mount will be shown.
So by hooking on GameTooltip:SetAction we can capture UselessIndex to SpellID mappings by looking at GetActionInfo and GameTooltip:GetSpell (and from there we can determine the MountIndex)

and of course
C_MountJournal.Pickup to capture UselessIndex to MountIndex mappings (from the Index passed to Pickup, and then from GetCursorInfo())

Naturally if this info is then wanted in a secure env it could be a pain given the sporadic nature, so really I'm just listing it as another work around for tackling this mess.
 
10-01-14, 04:12 AM   #24
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Lets say a user drags a mount from the mount journal to your action button in combat. How would you get the spellid from the tooltip to your buttons secure environment in this scenario without tainting it?
 
10-01-14, 06:06 PM   #25
Alternator
A Fallenroot Satyr
 
Alternator's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 20
In my case I don't allow button changes during combat so all changes to the button happen outside of the secure environment, which is why so far that method seems to work for my purposes (I don't think there would be an avenue to determine the info within the secure environment itself).

In the past I looked at in combat changes and found that the secure handlers were missing some key bits of info needed to properly change actions during combat, though if it's viable I might give it another look as it's something I would like to support!
 
10-16-14, 02:21 PM   #26
another
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 11
Slightly changed solution without ActionButton hacks. Used HookScript "OnEnter" for MountJournal list buttons.

Set hooks "OnEnter"
Code:
local function HookOnEnter(self)
	local spellID = self:GetParent().spellID
	local index = self:GetParent().index
	--print("HookOnEnter index ", index, " spellID", spellID)
	FlyoutButton_MountJournalIndexToSpellID[index] = spellID
end

local MountButtonsHookIsSet

local function SettingsHookFunc()
	hooksecurefunc("TogglePetJournal", function()
		if PetJournalParent:IsShown() then
			--print("PetJournalParent:IsShown")
			if not MountButtonsHookIsSet then
				--print("Looking for mount buttons")
				for i = 1, 20 do -- I see 12
					local bName = "MountJournalListScrollFrameButton"..i
					--print(bName)
					local f = _G[bName]
					if f then
						--print("Button "..bName.." found")
						if f.DragButton then
							--print("f.DragButton found")
							f.DragButton:HookScript("OnEnter", HookOnEnter)
						end
					end
				end
				MountButtonsHookIsSet = true
			end
		end
	end)
end
call SettingsHookFunc on init somewhere.

Code:
FlyoutButton_MountJournalIndexToSpellID = {}
local FlyoutButton_MountJournalUselessIndexToIndex = {}

local function HookSecureFunc_C_MountJournal_Pickup(Index)
	local _, UselessIndex = GetCursorInfo()
	if (Index and UselessIndex) then
		FlyoutButton_MountJournalUselessIndexToIndex[UselessIndex] = FlyoutButton_MountJournalIndexToSpellID[Index]
		--print("Index", "UselessIndex", Index, UselessIndex)
	end
end
hooksecurefunc(C_MountJournal, "Pickup", HookSecureFunc_C_MountJournal_Pickup)

function FlyoutButton_GetCursorValues()
	local command, value, subValue, id = GetCursorInfo()
	--print("GetCursorValues ", command, value, subValue, id)
	if (command == "spell") then
		-- do whatever with other types
	elseif (command == "mount") then
		command = "spell"
		id = FlyoutButton_MountJournalUselessIndexToIndex[value] -- here is spellID
		value = FlyoutButton_GetGenericSpellNameById(id)
		subValue = "MOUNT"
		--print(command, value, subValue, id)		
	end
	return command, value, subValue, id
end
Here is the way to get spellID. I'm still using it through attributes "spell" etc. And rename "FlyoutButton" stuff since it's directly from my addon. Works in current "FlyoutButton Custom" v2.63
So if something not works for you - see my sources.
 
10-16-14, 02:48 PM   #27
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Thanks a lot for sharing sir. What if the player drags the mount from an action button?

Unfortunatly I need a complete list before combat starts as I can't access unsecure stuff in combat. :/
 
10-16-14, 04:01 PM   #28
another
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 11
Well, I found in recent UI sources (Blizzard_PetJournal.xml) that this buttons have both index and spellID. Probably you/someone should dig deeper to find how exactly Blizzard assigned spellID to those buttons for mounts etc (maybe in Blizzard_PetJournal.lua).
 
10-16-14, 06:56 PM   #29
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
I'm already using the spellID.

On OnReceiveDrag a secure button gets the args "mount" and the the stupid Mount Journal index number (index of the mount in the complete list of all mounts - available or not).
But you can't set a secure button to type "mount" (or "summonmount"). So I have to set the button to type/spell with the name of the mount (I don't want to use type/action as there no available action IDs). Which works (I'm writing the MJ-indexnumbers with the spellIDs for all mounts pre-combat to my button header).

The trouble starts if the player drags the mount FROM the secure button. You can't pickup a "mount" or "summonmount" button type. I have to pickup the mount as a spell (does not take the mounts name ... only the mounts spellID, hahaha ... but whatever ... guess what ... I'm writing the MJ-indexnumbers with the mount names to my button header too *g*).
So, OnDragStart I pickup "spell"/<SpellIdOfTheMount>. Now the mount is on the cursor.

And now it's getting weird. On placing the cursor content ("spell"/<SpellIdOfTheMount>) from the cursor to another secure button the secure button receives the args "companion", <SomeNewIndex>, and "MOUNT". (should be at least "mount" and <SomeNewIndex> as above ... but nevermind ... it's Blizzard and I don't want to overburden then)
The funny part is, <SomeNewIndex> is not the MJ index number I've got above. And it is not the summonpet index number. And it is not just the running index number from the list of all mounts ...
... no, no...
... it is ... surprise ... the mounts index number in a list of all usable mounts. Ahahaha.

The MJ is such a joke.
Whatever, it's working now (in combat too), and I do not touch it ever again. If they ever change something that breaks my triple-hack-memory-wasting-workaround with their %)&$/% mount journal I'll rather abandon my addon then spending even another single minute of my life working with it.
 
10-17-14, 12:22 PM   #30
another
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 11
I'm using "spell" and spell name too As attributes.
Yes, I checked, when dragged from secure buttons its old "mount" and old style spellbook index (slot) ... But

Code:
	for slot = 1, GetNumCompanions(compType) do
		--creatureID, creatureName, creatureSpellID, icon, issummoned
		local creatureID, name, id = GetCompanionInfo(compType, slot)
		print(creatureID, name, id)
		local spellName = GetSpellInfo(id)
		if spellName then
			cache2slot[spellName] = {slot, compType}
			print("CacheCompanionSpells", spellName, slot, compType)
		end
	end
not works anymore for "MOUNT" (returns nils). What a mess ...

Found short way of getting mount journal index to spell id without hooks to MountJournal buttons "OnEnter". It's
Code:
	for i=1, C_MountJournal.GetNumMounts() do
		local creatureName, spellID, icon, active, isUsable, sourceType, isFavorite, _, _, hideOnChar, isCollected = C_MountJournal.GetMountInfo(i)

		MountJournalIndexToSpellID[i] = spellID
	end
I think it will be broken until some 6.2 patch (as always). Maybe we should stop making hacks to make our addons almost working. Let players whining and complaining on Blizzard forums about broken addons. To force Blizzard make proper API.

P.S. I disabled battlepet's support completely in my addons. Except I like to have several my favorite mounts in short dropdown list ..

Last edited by another : 10-17-14 at 12:26 PM. Reason: P.S.
 
10-17-14, 11:54 PM   #31
Alternator
A Fallenroot Satyr
 
Alternator's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 20
off topic

Duugu, Reading your post was cathartic!

I've just spent the last 4 days battling to sort out a slew of errors since this pre-exp patch to 6.0.2, I should have anticipated it (from memory they usually do release the engine update to Live before the Exp comes out).

And yeah - Mount Index's which are useless, I don't even want to think about what's going to happen to the actual Journal Index's and the transformations they will sooner or later under go.
And then with 6.0.2 they decided that their GUID Battlepet id's weren't good enough, so they chucked them and created a whole new set - and made the old ones throw lua errors if you try to use them

And just today I find out that the cooldown swipe/bling animation breaks EffectiveAlpha inheritance, it wont even take the alpha of the Cooldown frame... it can be worked around - but what a pain!
 
10-23-14, 10:56 AM   #32
sconley
An Aku'mai Servant
Join Date: Dec 2006
Posts: 31
Originally Posted by Duugu View Post
I've queried all mounts from the Mount Journal to get the related summonmount value (missing values indicate mounts I do not own).

The second list shows the same data sorted by the summonmount index column. It exposes that the summonmount index is ascending analogous to the spellID.

Does not help though. Just a funny insight.


Code:
C_MountJournal	spellID		summonmount	creatureName
index			 	index
1		48778				Acherus Deathcharger
2		60025		268		Albino Drake
Where did you get the summonmount data? I'd like to make a function that accepts the id returned by GetActionInfo() using that index.
thanks.
 
10-23-14, 11:02 AM   #33
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
That number is from GetCursorInfo if the mount is on the cursor. So, you actually have to pick up the mount to get it.
It's the same number that is passed to a secure button on OnReceiveDrag.
 
10-23-14, 11:09 AM   #34
sconley
An Aku'mai Servant
Join Date: Dec 2006
Posts: 31
Originally Posted by Duugu View Post
That number is from GetCursorInfo if the mount is on the cursor. So, you actually have to pick up the mount to get it.
It's the same number that is passed to a secure button on OnReceiveDrag.
Thanks for the quick answer. I guess I'll have to hard code the table. I have an addon that I wrote/use myself to load the action bar buttons. I need a way to tell which item/mount/spell/etc is in an action slot without picking up anything and putting on the cursor.
 
10-23-14, 11:21 AM   #35
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
If you're using type/action (like with the standard bars) this problem should not apply to you.
With type/action you can get/set the attribute action/summonmount and use GetActionInfo to query the number.
 
10-23-14, 11:37 AM   #36
sconley
An Aku'mai Servant
Join Date: Dec 2006
Posts: 31
Originally Posted by Duugu View Post
If you're using type/action (like with the standard bars) this problem should not apply to you.
With type/action you can get/set the attribute action/summonmount and use GetActionInfo to query the number.
Here is what I'm doing (short description):
For each class I play, I have a list of the names of spells, mounts, items, etc that go into each action slot.
Example: actions = {'Kill Command', 'Arcane Shot', 'Swift Zhevra'}
In my addon, I look at what is already in blizzard action bar slot to determine if I need to replace it. If I have to pickup the object from the action slot it makes a lot of noise and is slow.
When I use GetActionInfo(3) .... This is the blizzard slot 3 not the one from my actions table,
I need to get from the number it returns 224 to the name of the mount.
Hope that makes sense.
This was working until the last patch. It still works for spells, items, macros.

I wanted an addon that just had names not spell id's, etc.
 
10-27-14, 12:39 PM   #37
Banknorris
A Flamescale Wyrmkin
 
Banknorris's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 143
Originally Posted by semlar View Post
Here's probably as close to a complete list as you can get right now, extracted from the db2 cache.
Lua Code:
  1. Mounts = { -- [mount index] = spellID
  2. }
Would you mind to share how do you extract data from db2 cache? I don't even know where db2 cache is. I am happy with this solution but I would like to be able to repeat it myself in the future if more mounts are added. Thanks.
 
10-30-14, 12:26 PM   #38
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,014
Originally Posted by Banknorris View Post
Would you mind to share how do you extract data from db2 cache?
I used CASCExplorer to extract mount.db2 from the dbfilesclient directory, then I used a python script I wrote to extract and format the data as a lua table.
 
10-30-14, 12:50 PM   #39
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
To open the db2 file, you can also use TOM_RUS' DBC Viewer (source - binary). It allows you to export the data to an SQL table script.

There's also foxlit's DBC/DB2 Lua module (part of LuaCASC).

For Mounts.db2, these are the column definitions I can figure out:
Code:
Column 1-4 = ???
Column 5 = Name - string
Column 6 = Description - string
Column 7 = Source - string
Column 8 = ???
Column 9 = SpellID - int
Column 10 = ???

Last edited by Choonstertwo : 10-30-14 at 12:53 PM.
 
10-30-14, 01:18 PM   #40
Banknorris
A Flamescale Wyrmkin
 
Banknorris's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 143
Working on it now, thank you both.
 
 

WoWInterface » Site Forums » Archived Beta Forums » WoD Beta archived threads » Secure action buttons OnReceiveDrag and mounts

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off