PDA

View Full Version : Additional charsheets



Insanity
February 18th, 2013, 19:00
I've been working from a basic ruleset that was stripped down. The charsheet has only one sheet and no functional tabs, though the tab for the main sheet is visible.

I've been looking on how to add additional sheets and tabs to switch between them, and is seems there is no code for it in this ruleset, and looking at the current 4E or other rulesets hasn't been helping me. Might be due to looking at too many xml files.

Just looking for a little guidance on adding these in.

Zeus
February 18th, 2013, 23:50
I've been working from a basic ruleset that was stripped down. The charsheet has only one sheet and no functional tabs, though the tab for the main sheet is visible.

I've been looking on how to add additional sheets and tabs to switch between them, and is seems there is no code for it in this ruleset, and looking at the current 4E or other rulesets hasn't been helping me. Might be due to looking at too many xml files.

Just looking for a little guidance on adding these in.

Take a look at charsheet_toplevel.xml in the 4E ruleset (4E/charsheet/charsheet_toplevel.xml).

The file defines the top two main window classes, charsheet (normal charsheet) and charsheetmini_top (mini char sheet).

Inside both, under the <sheet> tag towards the end you will see something like:



<subwindow name="main">
<subwindow name="combat">
<bounds>0,65,-1,-22</bounds>
<class>charsheet_combat</class>
</subwindow>
...

<buttongroup_tabs name="tabs">
<tab>
<tab>
<icon>tab_combat</icon>
<subwindow>combat</subwindow>
</tab>
....

The sub window entries reference the window class for each sheet. The buttongroup_tabs control, defines the tab for the charsheet and where each one points to. In the example above you can see the second tab references the subwindow combat.

The buttongrou_tabs control is actually a custom template defined in 4E/common/template_buttons.xml.

Therefore to add another sheet, here are the steps:

First, if your ruleset does not already have a template for buttongroup_tabs, copy the one from 4E into your ruleset so thats its available for use.

1. Define a new windowclass for the new sheet you want to add. To do this, it maybe easier to copy one of the other existing sheets (char sheet_combat, charhseet_skills, charsheet_notes etc. etc.) and edit it accordingly.

2. Add a new subwindow definition to the top charsheet window class. Again simply copy one of the others and rename and set the class field to the name of the windowclass you defined in step 1.

3. Add a new tab entry in the buttongroup_tabs control to point to the subwindow you defined in step 2. You may need to also define a new icon for the text you want to appear on the tab. Create one in any standard graphics program that can output a .png file. Use one of the existing icons as a template (see 4E/graphics/tabs/tab_combat.png as an example.

Note: The tabs <frame> graphic in 4E has 7 tabs meaning you can only have upto 7 tabs on a sheet. If your ruleset already has 7 tabs you will have to create a new tab <frame> with the additional tab graphics you require.

Hope this helps.

Insanity
February 19th, 2013, 18:13
I found the template buttongroup_tabs from the 4E. I created a new file templates_button.xml and made sure it is loaded via the base.xml.

My new templates_buttons.xml has only this;



<root>
<template name="buttongroup_tabs">
<genericcontrol>
<anchored>
<top><offset>50</offset></top>
<right mergerule="replace"><offset>-4</offset></right>
<size>
<width>18</width>
<height>92</height>
</size>
</anchored>
<frame>
<name>tabs</name>
</frame>
<tab mergerule="resetandadd" />
<script file="common/scripts/buttongroup_tabs.lua" />
</genericcontrol>
</template>
</root>

I then added the following to my charsheet_toplevel.xml



<subwindow name="main">
<bounds>0,65,-1,-22</bounds>
<class>charsheet_main</class>
</subwindow>
<subwindow name="skills">
<bounds>0,65,-1,-22</bounds>
<class>charsheet_skills</class>
</subwindow>

<buttongroup_tabs name="tabs">
<tab>
<icon>tab_main</icon>
<subwindow>main</subwindow>
</tab>
<tab>
<icon>tab_skills</icon>
<subwindow>skills</subwindow>
</tab>
</buttongroup_tabs>


I have a file charsheet_skills.xml which only has;



<root version="2.6">
<windowclass name="charsheet_skills">
<placement>
<size>
<width>252</width>
<height>611</height>
</size>
</placement>
<nodelete />
<sheetdata>

<!-- SKILLS OVERVIEW -->
<genericcontrol name="skills_overviewframe">
<bounds>10,10,100,100</bounds>
<frame>
<name>sheetgroup</name>
</frame>
</genericcontrol>
</sheetdata>
</windowclass>
</root>


And is listed in the charsheet.xml to be loaded. The ruleset loads without error, but when I go to open a character sheet, I get the following error and the main sheet does not load.


Script Error: [string "scripts/charsheet_toplevel.lua"]:25: attempt to call field 'registerTab' (a nil value)


The charsheet_toplevel.lua has the following functions, line 25 is bolded.
My knowledge of lua is very limited, and I really have no idea what is the error.


function onInit()
User.onIdentityActivation = onIdentityActivation;
CharacterSheetManager.populate("main", self)
end

-- Close this sheet if the user releases its identity
function onIdentityActivation(identity, username, activated)
if not activated and User.getUsername() == username and identity == getDatabaseNode().getName() then
close()
end
end

function onMenuSelection(selection, subselection)

end

-- callback method for CharacterSheetManager to add sheets to this window
function addSheet(name, windowclass, tabicon)
createControl(windowclass, name)
tabs.registerTab(name, tabicon)
end

Zeus
February 20th, 2013, 09:50
Hmm, looks like you have a ruleset that enables users to add new sheets to a charsheet by right clicking the char sheet and selecting add sheet.

My method, it would seem is clashing with what the ruleset is already providing.

The error your seeing relates to the function registerTab not existing as a method in the LUA script thats attached to the tabs control (common/scripts/buttongroup_tabs.lua). It would seem the ruleset your using was coded some time ago.

Undo the changes you made as per my steps and see if you can add a sheet by right clicking on the char sheet. If this does not work then we would have to examine the ruleset code more thoroughly to determine whats happening.

Insanity
February 20th, 2013, 12:16
Undoing your steps is not a problem, I actually just used the
<!-- --> to effectively splice them out, but keep the coding. The main sheet is loading again, and there does not seem to be a right option to add another sheet.

Let me know if you want to see anything or send anything.

Thanks for your help.

Insanity
March 3rd, 2013, 17:05
Got this working, still some minor positioning of the tab icons to do, but can switch between the additional sheets.