FG Spreadshirt Swag
  1. #1

    Drag from character sheet

    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...
    Always keep it in perspective!

  2. #2
    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.

  3. #3
    Nah, I just need something I can work with while preparing the games.
    That way I can prepare maps and combat tracker instances
    Always keep it in perspective!

  4. #4
    Hmm... adding the link is simply a matter of adding a referencecontrol
    e.g.
    Code:
     
       <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...
    Work Less, Game More!

  5. #5
    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
    Always keep it in perspective!

  6. #6
    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)
    Code:
     
    <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:
    Code:
     
    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.
    Work Less, Game More!

  7. #7
    Oberoten's Avatar
    Join Date
    May 2006
    Location
    Älvsbyn, Sweden
    Posts
    2,620
    A very nice little script.

    Two nits to pick to make it use though.

    Code:
    <genericcontrolname="PortraitFrame">
      <bounds>-37,18,25,25</bounds>
      <icon>invisible_icon</icon>
      <scriptfile="scripts\charsheet_portrait.lua" />
    </genericcontrol>
    Wlll need two added spaces:

    Code:
    <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.
    For your Ars Magica needs :
    https://fgrepository.com




    Atque in perpetuum frater, Ave atque vale.

  8. #8
    Thanks a bunch!
    This is more then welcomed

    I modified your code to:
    1. Be able to drag a token out of it.
      You can put the token on the table or on a map.
    2. 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
    Code:
    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().getName());
    	
    	local base = dragdata.createBaseData();
    		base.setType("token");
    		base.setTokenData("portrait_" .. window.getDatabaseNode().getName() .. "_token");
    
      return dragdata;
    end

    charsheet_toplevel.xml just before </sheetdata>
    Code:
    <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...
    Last edited by Tokuriku; September 18th, 2007 at 23:18.
    Always keep it in perspective!

  9. #9
    [QUOTE =Oberoten]
    Wlll need two added spaces:
    [/quote]
    That was weird. Cut-n pasted from my file so am not sure why the spaces got removed


    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
    Last edited by Toadwart; September 19th, 2007 at 04:43.
    Work Less, Game More!

  10. #10
    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
    Always keep it in perspective!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Starfinder Playlist

Log in

Log in