PDA

View Full Version : Navigationial aid



DNH
February 5th, 2008, 09:13
Is it possible to implement some sort of FG2 navigational aid, being a window containing a list of current windows? That is, I envisage a small window (perhaps tied to a simple keyboard shortcut) which lists all the current open windows by name. Clicking on one of those window names takes the user to that window, giving it focus and bringing it to the front.

I mention this because some of my players tell me that it would be useful; they find that the FG2 desktop can quickly become cluttered (hey, they should see my DM one!). We know about the numpad shortcuts but that doesn't seem to cut it (and it needs to be re-programmed each session).

Any thoughts?

joshuha
February 5th, 2008, 15:52
The windowmanager.lua file already stores windows position I beleive for windowclasses with sources. It wouldn't be too hard to write a top level window that scans through the same registry list (or create your own in the onWindowOpened event) and does an Interface.openWindow when clicking on one in the list.

DNH
February 6th, 2008, 12:25
I have been playing around with this for a while now and have had some success insofar as I can write and delete window entries to the CampaignRegistry file, videlicet:

windowmanager.lua

onInit now includes:

if CampaignRegistry.WindowsStore then
CampaignRegistry.WindowsStore = {};
end


onWindowOpened now includes:

-- Adds newly-opened window to a table in the CampaignRegistry
if not CampaignRegistry.WindowsStore then
CampaignRegistry.WindowsStore = {};
end

table.insert(CampaignRegistry.WindowsStore, sourcename);


and onWindowClosed now includes:

-- Deletes the closed window from the list in CampaignRegistry
if CampaignRegistry and CampaignRegistry.WindowsStore then
windowlist = CampaignRegistry.WindowsStore;
end

if windowlist then
for k, v in pairs(windowlist) do
if v == sourcename then
table.remove(windowlist,k);
end
end
end


... all of which now gives me a CampaignRegistry table of the id refs of open windows. But now what?!

I messed about a bit with creating a windowclass and associated windowlist but without much success. I would need clickable links which bring the window to the fore; I believe a simple openWindow call would do it. Admittedly, I didn't bash away on this for very long, but if anyone is able to offer any advice and/or code, I would be very grateful.

Thanks.

joshuha
February 6th, 2008, 14:24
Well first, shouldn't you be storing the windowclass along with the sourcename to make the openWindow() really easy?

This is all psuedo code in my head right now but I imagine in a seperate windowclass which would be your master "list" of windows you would have a windowlist with no datasource. The windowclass for these list items would have a place to store a button to open the window, the class name, and the sourcename.

Then in the script for the windowlist:



function onInit()
if CampaignRegistry.WindowsStore then
for k, v in pairs(CampaignRegistry.WindowsStore) do
newwin = createWindow();
newwin.classname = v.classname;
if v.sourcename then
newwin.sourcename = v.sourcename;
end
end
end
end


Then in list_item windowclass the button would just do an Interface.openWindow(classname, sourcename) in an onClick event.