lotrointerface.com
Search Downloads


Go Back   LoTROInterface > LotRO > Developer Discussions > Lua Programming Help (L)

Reply
Thread Tools Display Modes
  #11  
Unread 06-30-2011, 02:04 PM
Fortunis's Avatar
Fortunis Fortunis is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Mar 2011
Location: Leeds, UK
Posts: 72
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
__________________
Author of Mouse Cursor Highlighter Advanced

Last edited by Fortunis : 06-30-2011 at 02:29 PM.
Reply With Quote
  #12  
Unread 06-30-2011, 03:46 PM
Equendil Equendil is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Apr 2011
Posts: 52
Quote:
Originally Posted by Digital_Utopia
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, 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'.
Reply With Quote
  #13  
Unread 07-22-2011, 10:49 AM
Equendil Equendil is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Apr 2011
Posts: 52
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. 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 :

Code:
Plugins/
	Author/
		PluginName.plugin (with <Package>Author.PluginName.Main</Package>
		PluginName/
			Resources/
				icon.tga (32x32 icon)
			Main.lua
			Favicon.lua
Favicon.lua would contain:
Code:
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.

Code:
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
__________________
Author of LIP, Bootstrap and Baruk

Last edited by Equendil : 07-22-2011 at 10:52 AM.
Reply With Quote
Reply



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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visible Buttons dinatius DDO Wish List (D) 1 08-23-2009 11:26 PM
Buttons wont show wackafoo Interface Help (L) 2 08-11-2009 03:06 PM
Missing two buttons at housing Wicked Mouse XML modification help (L) 0 04-03-2008 11:22 AM
Toggle Quickbars Skill description Deewe LotRO Wish List (L) 0 10-10-2007 08:40 AM
Mouselook Toggle feature Siknu Interface Requests (L) 1 04-04-2007 05:21 PM


All times are GMT -5. The time now is 03:43 AM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | ESOUI | LoTROInterface | MMOUI | Swtorui