PDA

View Full Version : Adding tab to 5e character sheet



KlatuB
June 16th, 2019, 17:50
I want to add a new tab to the 5e character sheet, I have got the tab to display on the sheet but currently the tab name is blank. I have looked at the MoreCore extension as suggested in another thread, but that is using graphics for the tabs, from what I can tell the 5e ruleset doesn't do that, and I would like to keep the look consistent. Where do I look to find the tab names.

Zacchaeus
June 16th, 2019, 17:52
I don't know specifically but if you search for the name of an existing one in the files you should find it.

damned
June 16th, 2019, 23:20
All rulesets use graphics for the tab names.

Slagmoth
August 9th, 2020, 20:19
I would love to do the same thing, but can't find where the xml looks for the tabs. If I were to do this in C# I would likely use reflection to just look for a type of file or property in the class. But I can't seem to find out how to create a new tab, it keeps crashing the load on me.

SilentRuin
August 9th, 2020, 22:02
I have never added one, but I've certainly had to write my own version of the \common\template_windows.xml templates for tabs_charsheet and tabs_recordsheet. That's the raw code that I overwrote because I needed to be notified when tabs changed and had to add that code in myself. The only reason I needed to do the xml's was because they are what point to the script file and I needed it to point to my version of it. I tell you this because all things with tabs start with these templates and the



<script file="common/scripts/buttongroup_tabs.lua" />


When dealing with the charsheet you need to understand that you'll need to create a merge version of 5E\campaign\record_char.xml in your extension. Looking at this file you can see where the tabs are defined - there are 7 of them. Be aware other people write extensions and if you go off and break the world to fit your stuff in you'll probably break them to if they touch that. I'm purposely ignoring any extensions outside of these 7 in my current extension so it should not impact me.

Here is the relevant chunk of that xml that deals with tabs..



<sub_charsheet name="main">
<class>charsheet_main</class>
</sub_charsheet>
<sub_charsheet name="skills">
<class>charsheet_skills</class>
</sub_charsheet>
<sub_charsheet name="abilities">
<class>charsheet_abilities</class>
</sub_charsheet>
<sub_charsheet name="inventory">
<class>charsheet_inventory</class>
</sub_charsheet>
<sub_charsheet name="notes">
<class>charsheet_notes</class>
</sub_charsheet>
<sub_charsheet name="logs">
<class>charsheet_logs</class>
</sub_charsheet>
<sub_charsheet name="actions">
<class>charsheet_actions</class>
</sub_charsheet>

<tabs_charsheet name="tabs">
<tab>
<icon>tab_main</icon>
<subwindow>main</subwindow>
</tab>
<tab>
<icon>tab_skills</icon>
<subwindow>skills</subwindow>
</tab>
<tab>
<icon>tab_abilities</icon>
<subwindow>abilities</subwindow>
</tab>
<tab>
<icon>tab_inventory</icon>
<subwindow>inventory</subwindow>
</tab>
<tab>
<icon>tab_notes</icon>
<subwindow>notes</subwindow>
</tab>
<tab>
<icon>tab_log</icon>
<subwindow>logs</subwindow>
</tab>
<tab>
<icon>tab_actions</icon>
<subwindow>actions</subwindow>
</tab>
<activate>1</activate>
</tabs_charsheet>


That's it. Each of those tabs hold a subwindow which holds a class which you can look up elsewhere - but you'd obviously have your own new subwindow and class of your own.

All the tab logic is buried in the tabs_charsheet template (remember I mentioned it earlier and the code tied into it).

I suspect to add a new tab you'd do something like this (not sure - don't blame if it doesn't work I've never done it - this is theory)...
In your extensions version of record_char.xml...


<root>
<!-- Add your stuff to the character sheet -->
<windowclass name="charsheet" merge="join">
<sheetdata>
<sub_charsheet name="YOUR_STUFF">
<class>charsheet_YOUR_STUFF</class>
</sub_charsheet>
<tabs_charsheet name="tabs" merge="join">
<tab>
<icon>tab_YOUR_STUFF</icon>
<subwindow>YOUR_STUFF</subwindow>
</tab>
</tabs_charsheet>
</sheetdata>
</windowclass>
</root>


where that charsheet_YOURS_STUFF is something you make yourself based on the 7 other examples you have to work with.

Now - none of this may work.

But that is my guess based on having had to rewrite parts of the core of it.

Then in your code you can mess around with the nitty gritty if you need to with stuff like this.



local nActiveTab = window.parentcontrol.window.tabs.getIndex();


Good luck - if it doesn't work - that's all I got :)

Slagmoth
August 10th, 2020, 23:47
Much appreciated. I should have dug a bit more before asking to be honest but this points me in the right direction.

When/If I get this working I will post how I did it.

superteddy57
August 11th, 2020, 18:14
Edit - Sorry might be double information since I didn't refresh the page and see SilentRuin's response.

Creating a new tab onto the character sheet is done by adding a reference to the new tab in the campaign/record_char.xml file
38485
As you can see in the image, it lists the subwindows that are going to be created and their associated windowclasses. Add your tab's own reference there and also add the graphic for the tab in the tabs_charsheet section of code. The icon is the graphic being used for the tab and subwindow points to the subwindow name.

This can work in reverse if you wish to remove a tab as well. Just delete the references in both sections and the tab will not appear on the character sheet.

SilentRuin
August 11th, 2020, 18:45
Edit - Sorry might be double information since I didn't refresh the page and see SilentRuin's response.

Creating a new tab onto the character sheet is done by adding a reference to the new tab in the campaign/record_char.xml file
38485
As you can see in the image, it lists the subwindows that are going to be created and their associated windowclasses. Add your tab's own reference there and also add the graphic for the tab in the tabs_charsheet section of code. The icon is the graphic being used for the tab and subwindow points to the subwindow name.

This can work in reverse if you wish to remove a tab as well. Just delete the references in both sections and the tab will not appear on the character sheet.

Don't know if my response is correct - it was a theory - I've never done it myself.

superteddy57
August 11th, 2020, 21:46
Ah, well then what I described would be the fastest and easiest approach to adding tabs to the character sheet in my opinion.

Slagmoth
August 13th, 2020, 01:30
Don't know if my response is correct - it was a theory - I've never done it myself.

Your suggestions worked for the most part. So I have created the new tab (which is blank atm because I have not created a graphic) but it is not styling to the bottom of the tabs. It appears where the "Main" tab would be and the data is overlaying the tabs as I to through them. Right now I am just using a mock up of the Inventory tab as that will be the base.

The idea is to have a tab with the assets and property that a character has but is not currently carrying. In the current campaign the party has procured an old Manor House and they have rooms there that contain their valuables that are not convenient to carry. Some of them also have items in another player's bag of holding. The Inventory is getting cluttered and I was looking to reorganize it a bit.

I have been digging through all of the XML and see the styling for the pieces inside a given window but do not see a styling for the main framing of the character sheet.

So my extended record_char looks like this:

<windowclass name="charsheet" merge="join">
<sheetdata>
<sub_charsheet name="assets" merge="add">
<class>charsheet_assets</class>
</sub_charsheet>

<tabs_charsheet name="tabs" merge="add">
<tab>
<icon>tab_assets</icon>
<subwindow>assets</subwindow>
</tab>
</tabs_charsheet>

<close_charsheet />
<resize_charsheet />
</sheetdata>
</windowclass>

I assume that the merge="join" would only be required on the parent node but was being safe.

damned
August 13th, 2020, 01:36
Ive never merged the actual <tabs_charsheet name="tabs"> Ive only ever replaced it.

superteddy57
August 13th, 2020, 01:53
I would honestly forgo the merge and add options till you see how the moving parts work. I would clone and then change. So you see how the code works and how to change it.

SilentRuin
August 13th, 2020, 14:05
Does not look like my example of the current 7 things for sure. You're on your own with that - never having done it I can only tell you how I think it should be done based on the code I've worked with. Your going down even a more different path than that. Good luck.

Slagmoth
August 14th, 2020, 04:16
Does not look like my example of the current 7 things for sure. You're on your own with that - never having done it I can only tell you how I think it should be done based on the code I've worked with. Your going down even a more different path than that. Good luck.

Thanks for the help anyway. It at least got me in the right direction.

At this point I have part of a tab working with something that looks similar to the Inventory tab but need to track down how to do the strings and something about the LUA scripts that run the drops need to be changed around. I will look more into that tomorrow.