Legacy-of-Sylvanaar / wow-instant-messenger

WIM (WoW Instant Messenger) is a World of Warcraft addon which brings an instant messenger feel to communication in game.
https://www.curseforge.com/wow/addons/wim-3
MIT License
11 stars 8 forks source link

Macro compatibility #18

Closed meyverick closed 1 year ago

meyverick commented 1 year ago

Is your feature request related to a problem? Please describe. I can't use WIM if the Minimap button isn't enabled.

Describe the solution you'd like I'd like to be able to create a macro /wim toggleAll that show all windows on click or hide all if already shown.

Describe alternatives you've considered Browsing your code thinking something like ShowUIPanel(WIMFrame) exists but I haven't found something similar.

Pazza commented 1 year ago

You can write a macro using scripts utilizing the following exposed methods.

WIM.ShowAllWindows(['whisper', 'chat']) 
WIM.ShowAllUnreadWindows(['whisper', 'chat'])
WIM.HideAllWindows(['whisper', 'chat'])

In each of these, the arguments are optional. They are available to filter specific types of windows if desired.

Example: /script WIM.ShowAllWindows() to show all windows (derr) /script WIM.HideAllWindows('whisper') to hide all whisper windows only.

I don't recall if there is anything exposed to see if a window is currently open so you can determine what to do (hide or show), but you could create your own variable and keep track yourself.

Example: /script _wimHidden = not _wimHidden; if _wimHidden then WIM.ShowAllWindows() else WIM.HideAllWindows() end

I will leave this open as a feature request, but these tools should provide you with what you are trying to do. Window behaviors such as animations can be controlled from WIM's settings.

Pazza commented 1 year ago

In addition to addingthe new slash command: /wim toggle { all | whisper | chat }, I added a new public method which would go with my previous post. It is being used internally for the toggle command.

local listOfShownWindows = WIM.GetWindowsShown(['whisper', 'chat']);

stiffsen commented 1 year ago

I wanted to use this neat functionality in order to get rid of that minimap button. However, while I can execute /wim toggle all from the chat command line, it doesn't work when executed from a macro. Any idea what might be going wrong here? /wim also cannot be executed from a macro.

I am on wotlk classic.

Pazza commented 1 year ago

There was a work around made for slash commands since Wow's API was tainting everything that registered a slash command. It must not work within macros...

I might have to expose the function so it can be called as a script.

Pazza commented 1 year ago

I exposed the function so you can call a script in your macro.

WIM.ToggleWindows(type) where type takes the same arguments as /wim toggle.

stiffsen commented 1 year ago

That works! Thanks! :-)

By the way, toggling window visibility was just a workaround to get rid of that minimap button. The best solution would of course be if the WIM minimap button would only show on mouseover, a feature the addon "SexyMap" adds for many other addon-buttons.