PDA

View Full Version : Plugin toggle buttons


Marll
06-29-2011, 04:21 PM
So while I'm usually comfortable using chat box command line switches, my wife is less inclined to remember the commands to bring up options for a plugin. I like the fact that a button can be displayed so that you can toggle the window, but wondering if they can be made to be different sizes?

What would be cool to see is the option to allow for a smaller one, something small and round like the other icons that appear on the radar currently, that could be dragged and placed so that they look like part of the radar ring. Is this possible? If so, would it be easy to change the lua to accomodate this (as in myself) or is this something that authors might be able to build in, if they feel so inclined?

D.H1cks
06-29-2011, 04:53 PM
Lua authors can set the size of buttons.

It would be up to the author to provide methods for the user to change the size of these buttons.

Marll
06-29-2011, 05:55 PM
What about in the Lua, does this information have to live in a certain place across all plugins? Is there a specific thing that I could look for to see if I can modify it?

Fortunis
06-29-2011, 06:01 PM
Probably look for-

objectName = Turbine.UI.Lotro.Button

objectName being the name the author has given the button, but the author may have used many buttons so you may have a hard time.

besides that, if there is an image for the button in the plugin files, look for its name in the code and see what button is associated with it.
Then check objectName:SetSize and objectName:SetPosition

MrJackdaw
06-30-2011, 01:32 AM
What about in the Lua, does this information have to live in a certain place across all plugins? Is there a specific thing that I could look for to see if I can modify it?

The problem being - this could be different for every plugin in existence! Whilst you could do the search suggested above, buttons can be used for a variety of things as well.

Best to contact the plugin author and make a feature request.

Digital_Utopia
06-30-2011, 05:35 AM
The easiest way to do it would be to simply add a alias to the command, and put it on your quickslots. As far as actually coding it yourself - this is what you'd need to do.

1) Find the name of the function that is called when you type in the slash command
2) Create a Turbine.UI.Lotro.Button, and place it at the coords you want it at
3) call the above mentioned function on that button's onclick handler


Being able to move it around is an entirely different ballgame that would entail

detecting whether alt, shift or ctrl is being pressed - depending on what modifier you want to "unlock" the button's position

setting whether your modifier is being pressed as a variable

having your button's "MouseDown" event handler check that variable, and then setting another variable as a flag to allow movement

if that flag is set to true (modifier pressed, and mouse button is down over the button, then change the button's position, relative to the mouse - on that button's MouseMove handler.

Obviously MouseUp and KeyUp handlers would be used to set the above mentioned flags to false.

Then of course, you have to keep in mind that if the author's plugin hides itself when you press f12, that you would have to put that button as a child of whatever window is hidden on that event. Otherwise, you'll still see that button after hiding the UI

Also, for best results, you'd probably want to use a Turbine.UI.Button instead, providing your own images for the three states (up, down and over) - as that way you'd be able to do a circular button, instead of the standard LotRO button.

Elentir
06-30-2011, 09:29 AM
Is it possible to create buttons that we can put into our quickslots like skills? I guess not for the moment cause otherwise you guys would have already implemented it by now. :D

MrJackdaw
06-30-2011, 10:09 AM
Should be able to do this using alias'

Marll
06-30-2011, 10:23 AM
The alias isn't a bad idea, though I wish that Turbine allowed us to assign icons to them, but whatever I suppose.


Still think that it would be nice to have smaller ones that can be placed, or moved around (many of them do this already, just drag and drop) to be placed out of the way on the radar ring, just seems like a perfect place for them so they don't take up screen real estate, and like addons were in WoW when I used to play, the icons look like they belong on the radar ring.

Digital_Utopia
06-30-2011, 01:58 PM
I've noticed that WoW addon authors have started using a slide out type of icon menu for their addons - presumably due to an alternative to mini-map icons, as you can only fit so many on there.

But anyway, that might be something worth looking into. It would require cooperation from individual authors, but it would certainly make things easier.

I'm not sure if global variables are confined to apartments, but that might be one way of doing it, without having to do any manual editing or whatnot.

Fortunis
06-30-2011, 02:04 PM
Im actually planning to do (or at least look into doing) something that involves most of the above (with a twist). Ive just been contemplating wether to package it all together with mouse cursor highlight advanced or not :s

Edit: It probably makes more sense to package it as a different plugin :)

Equendil
06-30-2011, 03:46 PM
I've noticed that WoW addon authors have started using a slide out type of icon menu for their addons - presumably due to an alternative to mini-map icons, as you can only fit so many on there.

But anyway, that might be something worth looking into. It would require cooperation from individual authors, but it would certainly make things easier.

I'm not sure if global variables are confined to apartments, but that might be one way of doing it, without having to do any manual editing or whatnot.
When I started working on Bootstrap (http://www.lotrointerface.com/downloads/info570-Bootstrap-PluginManager.html), my main objective was to provide a way to interact with (not just load) other plugins through a graphical user interface rather than just shell commands. This has taken the form of a menu similar to the native 'system' menu, without icons, and can (obviously) take another form. For that matter I originally meant to make a tool bar, which I'll probably do eventually as an alternative to the 'menu'. The main difficulty of course is that icons don't just get created out of nothing.

While developing the plugin, I also toyed with the idea of exposing an API for plugin authors to register functions and icons directly, although I dismissed it so far because 1) registering functions is pretty much what's being done with shell commands, 2) I'm not going to convince everyone to do so, 3) 'Apartments'.

I might resuscitate that idea, should I manage to get around 'Apartments'.

Equendil
07-22-2011, 10:49 AM
It appears to me that it's not currently possible to achieve communication between plugins if they are in different 'apartments', in any other way than using shell commands, which I'd rather not do as a generic solution to that particular problem.

Still, I wanted to move forward with Bootstrap (http://www.lotrointerface.com/downloads/info570-Bootstrap-PluginManager.html). As mentioned above, my primary objective with that plugin other than functionalities already existing in other plugin managers, was to offer the user a graphical user interface to interact with plugins. I've now added icons to Bootstrap's menu, which makes it fairly similar to Turbine's own panel menu, and gives me the option of turning it into an icon-only bar or something in the future.

Currently, I've assigned every existing plugin (that might have any business being in the menu) an icon, either from the plugin's resources (preferably), or in game resources that I thought appropriate. I hope the authors of those plugins will find them suitable (feel free to criticize !).

Ideally though, plugin authors themselves should be picking the icons they want used. To that end, I devised a relatively simple way for a plugin to expose a 'favourite icon', in a way that is not intrinsically bound to my own plugin (and hence can be used by others).

It's rather lightweight for plugin authors to do so, and I hope it catches (if not, oh well, I'll keep assigning icons by hand). Anyway, here goes:

Declaring a favourite icon - Favicon.lua

By adding a "Favicon.lua" file to their plugins, authors can declare an icon to be used by other plugins. Favicon.lua should be in the same folder as the 'package' (entry point of the plugin) defined in .plugin definition files.

Favicon.lua should contain a table named "Favicon". Favicon should itself have a subtable named 'Regular" (to allow for other icon states), with the following fields:
Resource: either an ID of an in game image resource, or the path of a JPEG or targa image relative to plugins/
Width: the width of the image
Height: the height of the image


Eg: if a plugin hiearchy looks like this :

Plugins/
Author/
PluginName.plugin (with <Package>Author.PluginName.Main</Package>
PluginName/
Resources/
icon.tga (32x32 icon)
Main.lua
Favicon.lua

Favicon.lua would contain:
Favicon = {
Regular = { Resource = "Author/PluginName/Resources/icon.tga", Width = 32, Height = 32 }
}


Retrieving a plugin's favourite icon

Because it might not be immediately obvious, below is a code snippet to extract the icon data from a plugin's Favicon.lua.

GetPluginFavicon( pluginData )

parameters
pluginData: definition table of a plugin as returned by Turbine.PluginManager.GetAvailablePlugins()

Returns
- nil if it fails
- resource, width, height if success (where resource is a resource that can be sent to Turbine.UI.Control:SetBackground() )

Note: for the sake of code safety, it is preferable to call subsequent SetBackground() on those resources in a protected call. Never vouch for external data.

function GetPluginFavicon( pluginData )
-- extract the 'path' of the 'package' of the plugin (which is set up in the .plugin definition file)
i, j = string.find( pluginData.Package, "[%w_%.]+%." ); -- extract "a.b.c." from "a.b.c.d"
if i == nil then return nil; end
local path = string.sub( package, i, j );

-- import a "Favicon.lua" in the same place as the 'package' if it exists
local success = pcall( import, path .. "Favicon" ); -- protected call to catch errors ...
if not success then
return nil; -- import will fail if the file does not exist or is malformed, time to return ...
end

-- Favicon.lua should now be imported, go down the namespaces where it should have been loaded
local env = _G -- begin from the global environment
for name in string.gfind( path, "[%w_]+" ) do -- for each 'name' in the path
env = env[name]; -- go down one level
if env == nil then -- this shouldn't occur, but just in case something went terribly wrong ...
return nil;
end
end

-- and extracts the information we need
local icon = env.Favicon;
if icon == nil or icon.Regular == nil then
return nil;
end

return icon.Regular.Resource, icon.Regular.Width, icon.Regular.Height;
end