+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 26

Thread: Minimap Buttons dock

  1. #1
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default Minimap Buttons dock

    Minimap buttons are a great way to access configuration options for addons, but after a while they seem to take over.

    I've had a first stab at writing a docking system:

    Docker_Main.lua - http://pastebin.com/awJ6q2jZ
    RiftAddon.toc - http://pastebin.com/yScWAfvc

    The way it works currently, is that you add Docker as an optional dependency to your addon:

    Code:
    Dependencies = {
    	Docker = {"optional", "before"},
    }
    Then create your minimap button as normal, but do not add any movement code to it, instead if Docker is present, pass your frame over along with a label :

    Code:
    	RX.UIElements.minimap = UI.CreateFrame("Texture", "RX.UIElements.minimap", RX.context)
    	RX.UIElements.minimap:SetHeight(36)
    	RX.UIElements.minimap:SetWidth(36)
    	RX.UIElements.minimap:SetTexture(addon.identifier, "textures/mm_button.png")
    
    	if __DOCKER then
    		__DOCKER.Register(addon.identifier, RX.UIElements.minimap)
    	else
    		function RX.UIElements.minimap.Event:LeftDown()
    		end
    		
    		function RX.UIElements.minimap.Event:MouseMove()
    		end
    		
    		function RX.UIElements.minimap.Event:LeftUp()
    		end	
    	end
    Then finally check to see if the button needs positioning (ie undocked) :

    Code:
    	if not __DOCKER then
    		RX.UIElements.minimap:SetPoint("TOPLEFT", UIParent, "TOPLEFT", Rattus_Settings.mmx, Rattus_Settings.mmy)
    	end
    Is there a better way of doing it than using globals ?

    Minimap Buttons dock-docker.png
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  2. #2
    Sword of Telara DoomSprout's Avatar
    Join Date
    Apr 2011
    Posts
    876

    Default

    I really like this idea a lot. I'll look at linking Gadgets up to it when you've got it finished. Are you giving users the option to drag buttons to wherever they want them as well as being docked? (I think that would be fairly important).

    As far as global variables go, I personally don't have an issue with an API being exposed as a global variable at all. I know people get upset about global namespace pollution, but at the end of the day you need a way to access the API, and as long as it's just a single global table that is named in a way that won't clash with anything else, it seems like the best way to go.

    The only alternative I've tried is to use Inspect.Addon.Detail(), getting a reference to the addon's data table, and then pulling an API namespace out of this. It works, but it's a lot of extra work with no real benefit that I could see.

    Gadgets: Unit Frames and Other Stuff for RIFT

  3. #3
    Sword of Telara DoomSprout's Avatar
    Join Date
    Apr 2011
    Posts
    876

    Default

    Are you giving users the option to drag buttons to wherever they want them as well as being docked?
    Just occurred to me that you wouldn't be able to grab mouse events from the buttons as this could break other functionality (like Gadgets Lock/Unlock), so I guess it would be down to individual addons to handle using or not using the Dock as appropriate.

    Gadgets: Unit Frames and Other Stuff for RIFT

  4. #4
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    The container of icons can be dragged, and repositioned.

    The ideal would be to present a window that icons can be dragged onto (or off of), and if dragged onto the dock window they would be left there, but that seems like a bit of a nightmare to coordinate between multiple addons.

    I dont want to take over handling movement code of individual icons, since they all do it differently.

    I cant think of a clean way for the dock to be selective, I would think any supporting addon would need to have an option to opt-out.

    If the user installs an addon to hold minimap icons, then presumably they want something to hold minimap icons =) So I cant see the harm in putting them there...

    I've put the current version up on riftui.
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  5. #5
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    Quote Originally Posted by DoomSprout View Post
    Just occurred to me that you wouldn't be able to grab mouse events from the buttons as this could break other functionality (like Gadgets Lock/Unlock), so I guess it would be down to individual addons to handle using or not using the Dock as appropriate.
    Exactly.

    Currently it just grabs them, reparents them and stacks them up in a window that can be moved/hidden - anything else that happens to them is processed normally.

    This is why I suggest to check for __DOCKER, and attach the movement events only if not present. That way any other mouse events on the icon are handled as they currently would be.
    Last edited by Adelea; 09-21-2012 at 08:50 AM.
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  6. #6
    Ascendant
    Join Date
    Dec 2010
    Posts
    1,868

    Default

    Now if only we could get a minimap addon so I can get rid of those stupid default ui minimap buttons it has. Like I really need zoom in and out buttons right?

  7. #7
    Sword of Telara DoomSprout's Avatar
    Join Date
    Apr 2011
    Posts
    876

    Default

    I've integrated Gadgets with Docker, works a treat and was very easy to do.

    I do have one problem though, and I'm not sure how to best get around it.

    When I right click the Gadget button and the menu pops up, I move down to a menu option, which takes my mouse cursor outside of Docker, which makes the Gadget button and therefore also the menu disappear.

    What could help here for me, and therefore possibly others, is an option on the Docker API to lock the docking tray open, and then release the lock when I no longer need it to be locked open. Does that make sense?

    The alternative is for me to re-parent my menu control, but it might look a bit odd if the menu is left floating while the Gadget button disappears.

    What do you think?

    Gadgets: Unit Frames and Other Stuff for RIFT

  8. #8
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default

    Exposing a single table containing the API isn't bad at all if it's named properly. Maybe change the name to something more specific like "MinimapDocker" or whatever as I think "Docker" is a bit too general, but I wouldn't prefix it with underscores. Names like these are usually reserved for special purpose by the vendor (for example _G).
    Author of the Imhothar's Bags addon.

  9. #9
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    Quote Originally Posted by DoomSprout View Post
    I've integrated Gadgets with Docker, works a treat and was very easy to do.

    I do have one problem though, and I'm not sure how to best get around it.

    When I right click the Gadget button and the menu pops up, I move down to a menu option, which takes my mouse cursor outside of Docker, which makes the Gadget button and therefore also the menu disappear.

    What could help here for me, and therefore possibly others, is an option on the Docker API to lock the docking tray open, and then release the lock when I no longer need it to be locked open. Does that make sense?

    The alternative is for me to re-parent my menu control, but it might look a bit odd if the menu is left floating while the Gadget button disappears.

    What do you think?
    Ideally the amount of work to integrate would be minimal, and I dont like having to make other authors do lots of work to support using it.

    I think the 'easiest' way out of this, is to expose another internal variable (currently local) and if you need to keep things open whilst docked, then flag it via this variable?

    For example:

    Code:
    	function UIFrames.mm_button.Event.MouseIn()
    		if Inspect.System.Secure() == true then
    			return
    		end
    		
    		if __DOCKER then
    			__DOCKER.AUTOHIDE_DOCKED = false
    		end
    
    		--rest of function
    And when you are ready to close your popup

    Code:
    		UIFrames.frame:SetVisible(false)
    		if __DOCKER then
    			__DOCKER.AUTOHIDE_DOCKED = true
    		end
    This is only in my testing version right now, but would/could this work ?
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  10. #10
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    Quote Originally Posted by Imhothar View Post
    Exposing a single table containing the API isn't bad at all if it's named properly. Maybe change the name to something more specific like "MinimapDocker" or whatever as I think "Docker" is a bit too general, but I wouldn't prefix it with underscores. Names like these are usually reserved for special purpose by the vendor (for example _G).
    You are probably right - and changing it would be better done sooner rather than later!
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  11. #11
    Shield of Telara Nerva3x0's Avatar
    Join Date
    Jul 2012
    Posts
    732

    Default

    I have been wanting something like this for a while. I have 6 buttons atm. Anyway I set up a few addons to use this, and noticed that the growth direction is always up. Would be nice to have some sort of option to change the growth direction. Other then that works perfectly.

  12. #12
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    I've pushed a new version to riftui -

    * changed the name to MINIMAPDOCKER to avoid using _'s
    * Exposed the MINIMAPDOCKER.AUTOHIDE_DOCKED property - set to false and the dock wont autoclose - so dont forget to reset it when youre done keeping it open!
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  13. #13
    Sword of Telara DoomSprout's Avatar
    Join Date
    Apr 2011
    Posts
    876

    Default

    Fantastic, I've updated Gadgets and it's working really nicely

    Just a note - not sure what changed, but the button doesn't seem to light up any more?

    Gadgets: Unit Frames and Other Stuff for RIFT

  14. #14
    Sword of Telara DoomSprout's Avatar
    Join Date
    Apr 2011
    Posts
    876

    Default

    Thought I'd throw some (hopefully) constructive feedback/feature requests in...

    If you're planning on adding end-user configuration options to the addon, here's what I would love to see:

    An option to flip the mouse buttons round. I would much prefer left-click dragging and right-click locking. Using the right button to drag always feels wrong to me; there is an expectation from years of using Windows/Linux UIs that you move things around by left-clicking and dragging.

    An option to hide the addon names, and show the addon buttons as a set of icons extending either up, down, left or right from the button. Or with the names left in place, options to have the list pop up to the left or right, and above or below the button.

    An option to permanently lock the docker open, so that it can be used as a standard tray area for addon buttons without hiding them.


    With regard to the API...

    Thanks for dropping the underscores, that looks a lot neater. The only other thing there is that block capitals are usually used to represent constants, so the naming still feels a little bit wrong (and yes, I know I use 'WT' for my API, but that's an acronym, so that's my excuse! ).


    I really hope all of the addon authors that use mini-map buttons embrace this addon. It's a really neat solution with a very easy to integrate API. Nice job!
    Last edited by DoomSprout; 09-21-2012 at 03:04 PM.

    Gadgets: Unit Frames and Other Stuff for RIFT

  15. #15
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    Quote Originally Posted by DoomSprout View Post
    Fantastic, I've updated Gadgets and it's working really nicely

    Just a note - not sure what changed, but the button doesn't seem to light up any more?
    Which button doesnt light up, and under what circumstances ?
    Last edited by Adelea; 09-21-2012 at 10:36 PM.
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts