PDA

View Full Version : Drag from character sheet



Tokuriku
September 17th, 2007, 05:36
I would like to open a project for anyone who would like to take it.

My problem is that of many people; if a player is not present at a game session, it is difficult to put his/her character on the combat tracker.

We can access the character sheet trough the characters button on the top of the UI wich takes more time then to access the characters of the players that are present but still it is not that difficult.

Putting the missing players on the combat tracker is another thing altogether.
The only way is to open a client instance and load them from the portraits.


Here is the leading idea where I'd like help on.
Once on the combat tracker, any entry, be it a PC or NPC has a round link icon on it's right. Once pressed, it opens either the charsheet of the character or the personality sheet of the NPC. Can someone come up with a way to put that or more exactly the square equivalent of personality sheets on the Main character tab.

This could be dragged as the Character Portrait on the top left of the UI to give a token or to give a link if dragged in the combat tracker directly...

Ablefish
September 17th, 2007, 05:45
In my game I've just had other players open up missing characters so the portraits are all available above the chatlog. Then I just drag 'em into the combat tracker as normal. Are you concerned about players being able to manipulate one another's sheets? Granted, all the games I play are with friends I've known for years, so this may not work for some people.

Tokuriku
September 17th, 2007, 05:57
Nah, I just need something I can work with while preparing the games.
That way I can prepare maps and combat tracker instances :)

Toadwart
September 17th, 2007, 07:55
Hmm... adding the link is simply a matter of adding a referencecontrol
e.g.


<windowreferencecontrol name="open">
<bounds>-30,15,20,20</bounds>
<icon>
<normal>button_openwindow</normal>
<pressed>button_emptytarget</pressed>
</icon>
<class>charsheet</class>
<description>
<field>name</field>
</description>
</windowreferencecontrol>


However, dragging that to the combat tracker doesn't work. Need to make some changes to the combattracker.lua script (or possibly the onDrag function of the windowreferencecontrol).
I'll see if I can figure it out tomorrow. Have a game to get to right now...

Tokuriku
September 17th, 2007, 09:32
Oh and btw, I think it would be nicer if there was a portrait instead of the little circle (or box).
That way, there'd be a portrait on the character sheet as well :)

Toadwart
September 17th, 2007, 21:30
Add this to charsheet_toplevel.xml (just before the closing </sheetdata> tag so the portrait is drawn last and therefore is on top of all other controls)


<genericcontrolname="PortraitFrame">
<bounds>-37,18,25,25</bounds>
<icon>invisible_icon</icon>
<scriptfile="scripts\charsheet_portrait.lua" />
</genericcontrol>

and create a charsheet_portrait.lua file in the scripts folder with this code in it:


local portraitwidget;
function onInit()
if window.getDatabaseNode() then
if window.getDatabaseNode().getName() then
-- small portrait
portraitwidget = window.PortraitFrame.addBitmapWidget("portrait_" .. window.getDatabaseNode().getName().. "_token");

-- full-sized portrait
-- portraitwidget = window.PortraitFrame.addBitmapWidget("portrait_" .. window.getDatabaseNode().getName().. "_charlist");
end
end
end
function onDrag(button, x, y, dragdata)
dragdata.setType("playercharacter");
dragdata.setDatabaseNode(window.getDatabaseNode()) ;
dragdata.setTokenData("portrait_" .. window.getDatabaseNode().getName().. "_token");
return dragdata;
end


Think it's missing something as the portrait can't be dragged directly onto a map, or to the desktop, like it can from the main PC portrait. However, it can be dragged to the combat tracker and seems to 'link' to the character correctly when dragged from there to a map.

Oberoten
September 18th, 2007, 07:18
A very nice little script. :)

Two nits to pick to make it use though.



<genericcontrolname="PortraitFrame">
<bounds>-37,18,25,25</bounds>
<icon>invisible_icon</icon>
<scriptfile="scripts\charsheet_portrait.lua" />
</genericcontrol>


Wlll need two added spaces:



<genericcontrol name="PortraitFrame">
<bounds>-37,18,25,25</bounds>
<icon>invisible_icon</icon>
<script file="scripts\charsheet_portrait.lua" />
</genericcontrol>


And then it works like a charm.

Tokuriku
September 18th, 2007, 11:12
Thanks a bunch!
This is more then welcomed :D

I modified your code to:

Be able to drag a token out of it.
You can put the token on the table or on a map.
Have also an "Add Identity" bubble like for personalities.
I think it could help when you have to speak for that character when he/she is not present at the session.


Without your help, I wouldn't have figured the way to link the database with the portrait, thanks again :)

p.s. Feel free to rectify my code if you see unneeded/unwanted stuff.


character_portrait.lua

local portraitwidget;
function onInit()
if window.getDatabaseNode() then
if window.getDatabaseNode().getName() then
-- small portrait
portraitwidget = window.PortraitFrame.addBitmapWidget("portrait_" .. window.getDatabaseNode().getName().. "_token");

-- full-sized portrait
-- portraitwidget = window.PortraitFrame.addBitmapWidget("portrait_" .. window.getDatabaseNode().getName().. "_charlist");
end
end
end
function onDrag(button, x, y, dragdata)
dragdata.setType("playercharacter");
dragdata.setTokenData("portrait_" .. window.getDatabaseNode().getName().. "_token");
dragdata.setDatabaseNode(window.getDatabaseNode()) ;
dragdata.setStringData(window.getDatabaseNode().ge tName());

local base = dragdata.createBaseData();
base.setType("token");
base.setTokenData("portrait_" .. window.getDatabaseNode().getName() .. "_token");

return dragdata;
end


charsheet_toplevel.xml just before </sheetdata>

<genericcontrol name="PortraitFrame">
<bounds>-37,18,25,25</bounds>
<icon>invisible_icon</icon>
<script file="scripts\charsheet_portrait.lua" />
</genericcontrol>
<stringfield name="name" source="name">
<anchored>
<to>PortraitFrame</to>
<position>over</position>
<offset>-14,-10</offset>
<top>
<offset>22</offset>
</top>
</anchored>
<frame>
<name>textline</name>
<offset>2,0,2,0</offset>
</frame>
</stringfield>
<buttoncontrol>
<bounds>-30,50,23,22</bounds>
<icon>
<normal>button_identityactivate</normal>
<pressed>button_identityactivate_down</pressed>
</icon>
<script>
function onButtonPress()
GmIdentityManager.addIdentity(window.name.getValue ());
end
</script>
</buttoncontrol>


-EDIT-
One small problem; when I create a new character, the client side can see the portrait (wich is empty) right of the bat. The Host cannot see anything until the client chooses a portrait...

Toadwart
September 19th, 2007, 01:55
Wlll need two added spaces:

That was weird. Cut-n pasted from my file so am not sure why the spaces got removed :confused:


Forgot to mention that the "invisible_icon" I used will need to be defined too (I used a 15x15 fully transparent png) - OR use a different image, maybe a 'blank token image' might help with your client/host issue for new players Kenshin?
I think what happens behind the scenes is that a 'prototype' (blank portrait) token is generated for a new player. Not sure exactly why the host doesn't see that but I assume that because it's just a 'prototype' FG doesn't send it to the host/other players.

EDIT - thanks for the token code too. Was a bit confused about the createBaseData till I saw how you had used it :)

Tokuriku
September 19th, 2007, 09:04
Thanks for everything :)
I replaced the invisible icon by the Token Icon so now at least there is something there.
You can drag it into the combat tracker but no token will come out of it of course.
Also made the "Name" stringfield invisible ;)