View Full Version : Identitylist menu request + sharing windows
joshuha
May 31st, 2007, 05:22
Is their a way possible to acces/add menu items to the portrait control right now? I believe this is the identitylist right?
If not, can I put a request for the abiltiy to do this?
Basically I want to call the registerMenuItem function so I can have custom functions built into the right-click when I click on a player that is logged in.
Also, I may need to put this as a seperate request but right now we can only share windows with users, can we get the ability to do this to identites as well?
I realize that probable a big change on the backend and I also realize that someone playing multiple characters will see the shared window anyways when switching back and forth but it still helps the RP immersion and also helps with me doing things like sharing windows programatically to name in the combat tracker for instance.
Goblin-King
May 31st, 2007, 07:21
Is their a way possible to acces/add menu items to the portrait control right now? I believe this is the identitylist right?
If not, can I put a request for the abiltiy to do this?
Basically I want to call the registerMenuItem function so I can have custom functions built into the right-click when I click on a player that is logged in.
The script is in scripts/characterlist_entry.lua. You can add stuff there if you need to.
Also, I may need to put this as a seperate request but right now we can only share windows with users, can we get the ability to do this to identites as well?
I'm not exactly sure what you need. Players with multiple identities are still only using one tabletop for all the identities, and all sharing operations are directed at a user's tabletop instead of a particular identity. If you simply wish to be able to share windows based on an identity name, use User.getIdentityOwner to get the user name and pass that to the share function.
joshuha
May 31st, 2007, 15:31
I'm not exactly sure what you need. Players with multiple identities are still only using one tabletop for all the identities, and all sharing operations are directed at a user's tabletop instead of a particular identity. If you simply wish to be able to share windows based on an identity name, use User.getIdentityOwner to get the user name and pass that to the share function.
Its more of an immersion thing. Say I am playing 2 characters that are on completely different maps. When I switch to Character A I only want to see the map that he is on and the same to Character B.
Also, I am working on a card dealing engine and I deal/share hands out and want to share per player in the game not per user. Obviously I can place a label on the window itself to denote which player it belongs to but was hoping for something more elegant.
TarynWinterblade
June 1st, 2007, 01:36
Its more of an immersion thing. Say I am playing 2 characters that are on completely different maps. When I switch to Character A I only want to see the map that he is on and the same to Character B.
Also, I am working on a card dealing engine and I deal/share hands out and want to share per player in the game not per user. Obviously I can place a label on the window itself to denote which player it belongs to but was hoping for something more elegant.
Technically, what you want can be accomplished by adding some window management code to the identity switching - I did something similar that re-opens the windows that were open on program exit (or the last time the registry was saved, in the event of a crash)...
The code I think you'll want to use is below (not tested... might not work entirely right...)
In scripts/windowmanager.lua:
function onInit()
if not CampaignRegistry.activeWindows then
CampaignRegistry.activeWindows = {}
end
Interface.onWindowOpened = onWindowOpened;
Interface.onWindowClosed = onWindowClosed;
end
function onWindowOpened(window)
local sourcename = "";
if window.getDatabaseNode() then
sourcename = window.getDatabaseNode().getNodeName();
end
if CampaignRegistry.windowpositions then
if CampaignRegistry.windowpositions[window.getClass()] then
if CampaignRegistry.windowpositions[window.getClass()][sourcename] then
local pos = CampaignRegistry.windowpositions[window.getClass()][sourcename];
window.setPosition(pos.x, pos.y);
window.setSize(pos.w, pos.h);
end
end
end
-- We don't want to do this for the host...
if not User.isHost() then
local iden = User.getCurrentIdentity()
if not CampaignRegistry.activeWindows[iden] then
CampaignRegistry.activeWindows[iden] = {}
end
if not CampaignRegistry.activeWindows[iden][window.getClass()] then
CampaignRegistry.activeWindows[iden][window.getClass()] = {}
end
CampaignRegistry.activeWindows[iden][window.getClass()][sourcename] = true
end
end
function onWindowClosed(window)
if not CampaignRegistry.windowpositions then
CampaignRegistry.windowpositions = {};
end
if not CampaignRegistry.windowpositions[window.getClass()] then
CampaignRegistry.windowpositions[window.getClass()] = {};
end
-- Get window data source node name
local sourcename = "";
if window.getDatabaseNode() then
sourcename = window.getDatabaseNode().getNodeName();
end
-- Get window positioning data
local x, y = window.getPosition();
local w, h = window.getSize();
-- Store positioning data
local pos = {};
pos.x = x;
pos.y = y;
pos.w = w;
pos.h = h;
CampaignRegistry.windowpositions[window.getClass()][sourcename] = pos;
if not User.isHost() then
local iden = User.getCurrentIdentity()
if CampaignRegistry.activeWindows[iden] then
if CampaignRegistry.activeWindows[iden][window.getClass()] then
CampaignRegistry.activeWindows[iden][window.getClass()][sourcename] = nil
if next(CampaignRegistry.activeWindows[iden][window.getClass()],nil) == nil then
CampaignRegistry.activeWindows[iden][window.getClass()] = nil
end
end
end
end
end
function openIdentityOwnedWindows(iden)
if not iden then
iden = User.getCurrentIdentity()
end
if CampaignRegistry.activeWindows[iden] then
for k, v in pairs(CampaignRegistry.activeWindows[iden]) do
for k2, v2 in pairs(v) do
if v2 then
Interface.openWindow(k, k2)
end
end
end
end
end
function closeIdentityOwnedWindows(identity)
if not iden then
iden = User.getCurrentIdentity()
end
if CampaignRegistry.activeWindows[iden] then
for k, v in pairs(CampaignRegistry.activeWindows[iden]) do
for k2, v2 in pairs(v) do
if v2 then
local w = Interface.findWindow(k, k2)
if w then
w.close()
end
end
end
end
end
end
In scripts/characterlist_entry.lua:
function onMenuSelection(selection)
if User.isOwnedIdentity(identityname) then
if selection == 5 then
WindowManager.closeIdentityOwnedWindows(User.getCu rrentIdentity());
User.setCurrentIdentity(identityname);
WindowManager.openIdentityOwnedWindows(identitynam e);
if CampaignRegistry and CampaignRegistry.colortables and CampaignRegistry.colortables[identityname] then
local colortable = CampaignRegistry.colortables[identityname];
User.setCurrentIdentityColors(colortable.color or "000000", colortable.blacktext or false);
end
elseif selection == 4 then
User.releaseIdentity(identityname);
end
end
if User.isHost() then
if selection == 5 then
User.ringBell(User.getIdentityOwner(identityname)) ;
end
end
end
Hope it helps... *thinks for a minute* heh, scratch that... I hope it works...
joshuha
June 1st, 2007, 01:39
Nice idea! I will try to incorporate some of the logic in my next build of my card engine. I will let you know.
TarynWinterblade
June 1st, 2007, 01:55
A random afterthought: Including a tag to indicate that a particular object is supposed to be owned by an identity and processed by the code, that way only certain windows are identity specific, and others are global for the user.
The part that lets this be easily addable is that you can access any of the tags of a window simply by stating, say, window.tag, and you'll be able to tell if a particular tag (such as "shareable") is in that window's definition. Just add a identityowned tag to all of your windows and change the if statements to make sure that it exists before adding it to the activeWindows list (maybe rename it to be "identityWindows" or something too...)
And... sadly... to indicate how scatterbrained I am right now (too tired from work)... when I posted the code up top, I managed to cut the onWindowOpened function out of my windowmanger.lua file instead of copying it... >.<
Dachannien
June 1st, 2007, 08:11
You're doing a card engine? A la playing cards? I'm very interested in how you're implementing that, since the same concepts could be used to implement just about any board game in FG2.
Now, if we only had access to the physics engine, we could do Hungry Hungry Hippos! :D
nezzir
June 1st, 2007, 21:57
Now, if we only had access to the physics engine, we could do Hungry Hungry Hippos! :D
I'll play that with you (if I can be the blue hippo)! :D
Powered by vBulletin® Version 4.2.1 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.