PDA

View Full Version : Adding Charsheet Tab - Injection?



bmathis
July 10th, 2019, 21:06
Is there a way to 'inject' a new tab into the record_char class without re-writing the class in an extension?

Or if I have an extension with a new tab do I have to override the entire charsheet windowclass?

(Basically is there a way to add a tab without stepping on other extensions that might also want to alter the charsheet?)

Thanks,
Brandon

Bidmaron
July 10th, 2019, 22:15
If you are lucky and the other extension used merge features of templates you might be okay. However, I have not attempted this.

bmathis
July 10th, 2019, 23:55
Thanks - that pointed me in a direction to find the reference pages to look at. It's almost working but I'm having one issue -
When I use the template merge commands, the new tab is replacing the Main tab, and the new sub window is sitting on top of every window. I'm sure I have not understood how the merge functionality works.

I've tried various combinations of merge="merge" and merge="join" at different tabs/sub sheets as well as removing them all.



<windowclass name="charsheet" merge="merge">
<sheetdata merge="join">
<sub_charsheet name="journal">
<class>charsheet_journal</class>
</sub_charsheet>
<tabs_charsheet merge="join">
<tab>
<icon>tab_journal</icon>
<subwindow>journal</subwindow>
</tab>
</tabs_charsheet>
</sheetdata>
</windowclass>


Here is the result I'm looking for:


<windowclass name="charsheet">
<frame>charsheet</frame>
<placement>
<size width="525" height="600" />
</placement>
<sizelimits>
<minimum width="525" height="570" />
<dynamic />
</sizelimits>
<softclose />
<nodelete />
<playercontrol />
<minimize>minimized_char</minimize>
<tooltip field="name" />
<script file="campaign/scripts/char.lua" />
<sheetdata>
<anchor_title_charsheet name="contentanchor" />

<button_charactivate>
<anchored to="contentanchor" position="belowright" offset="0,5" width="23" height="22" />
</button_charactivate>

<token_char name="token">
<anchored to="contentanchor" position="belowright" offset="25,6" width="45" height="45" />
</token_char>
<genericcontrol>
<anchored to="contentanchor" position="belowleft" offset="5,5" width="45" height="45" />
<icon>charlist_base</icon>
<disabled />
</genericcontrol>
<portrait_charlocal name="localportrait">
<anchored to="contentanchor" position="belowleft" offset="5,5" width="45" height="45" />
<invisible />
</portrait_charlocal>
<portrait_char name="portrait">
<anchored to="contentanchor" position="belowleft" offset="5,5" width="45" height="45" />
</portrait_char>

<label_charframetop name="nametitle">
<anchored to="contentanchor" height="20">
<top anchor="bottom" offset="7" />
<left offset="65" />
<right offset="-135" />
</anchored>
<static textres="char_label_name" />
</label_charframetop>
<stringu name="name">
<anchored to="nametitle" position="insidetop" offset="0,25" height="20" />
</stringu>
<label_charframetop name="inspirationtitle">
<anchored to="nametitle" position="righthigh" offset="20,0" width="30" height="20" />
<static textres="char_label_inspiration" />
<tooltip textres="char_tooltip_inspiration" />
</label_charframetop>
<buttongroup_counter name="inspiration">
<anchored to="inspirationtitle">
<top anchor="bottom" offset="5" />
<left anchor="center" offset="-5" />
</anchored>
<tooltip textres="char_tooltip_inspiration" />
<sourcefields><current>inspiration</current></sourcefields>
<values><maximum>3</maximum></values>
</buttongroup_counter>

<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>
<sub_charsheet name="journal">
<class>charsheet_journal</class>
</sub_charsheet>

<tabs_charsheet>
<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>
<tab>
<icon>tab_journal</icon>
<subwindow>journal</subwindow>
</tab>
<activate>1</activate>
</tabs_charsheet>

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

bmathis
July 11th, 2019, 02:26
So this 'works' but it's not exactly what I was hoping for. I end up having to replace the whole tab section, but that's better than replacing the whole sheet I suppose.


<windowclass name="charsheet" merge="join">
<sizelimits merge="replace">
<minimum width="525" height="570" />
<dynamic />
</sizelimits>
<sheetdata>
<sub_charsheet name="journal" insertafter="actions">
<class>charsheet_journal</class>
</sub_charsheet>
<tabs_charsheet merge="replace">
<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>
<tab>
<icon>tab_journal</icon>
<subwindow>journal</subwindow>
</tab>
<activate>1</activate>
</tabs_charsheet>
</sheetdata>
</windowclass>

damned
July 11th, 2019, 03:33
You do have to replace the whole tab section and it will conflict with another extension if it is also overwriting the same section.
Savage Worlds did or does have a different tab method that supported multiple Tab adds from different sources but it was specific to that ruleset.

Moon Wizard
July 11th, 2019, 05:14
You can only override/replace/merge a control in a window if it is named. I'm going to go through the rulesets I maintain (CoreRPG, 3.5E, 4E, 5E, C&C, CoC, Cypher, d20Mod) and add name="tabs" to all the tab control templates. This should allow you to more quickly add tabs without having to redefine window class. This will be included in the v3.3.8 update which is currently in beta testing in the next day or two.



<windowclass name="charsheet" merge="join">
<sheetdata>
<tabs_charsheet name="tabs">
<tab merge="add">
<icon>tab_journal</icon>
<subwindow>journal</subwindow>
</tab>
</tabs_charsheet>
</sheetdata>
</windowclass>


Regards,
JPG

Trenloe
July 11th, 2019, 05:27
I'm going to go through the rulesets I maintain (CoreRPG, 3.5E, 4E, 5E, C&C, CoC, Cypher, d20Mod) and add name="tabs" to all the tab control templates.
Added to something that might be appearing around about the start of August... ;)

Moon Wizard
July 11th, 2019, 07:19
Great, you were on my list to contact (plus a couple other things I'm working on).

Cheers,
JPG

bmathis
July 11th, 2019, 14:17
Awesome, thanks!

bmathis
July 11th, 2019, 14:26
So this is a minor issue but it's bugging me - the new tab doesn't get the 'toptab' addition like the other tabs do.

It looks like this gets added in the buttongroup_tabs:OnInit function.
Since I'm merging/replacing in basically a new buttongroup in my extension - do I need to call that function again? Or does that run after the xml merge is complete?

I've uploaded an image to show what I'm talking about, look at the top of the 'Journal' tab and how it's not divided from the Actions tab. When I click on it it gets updated correctly to show it's the active tab, but when it de-activates it goes back to that.

Moon Wizard
July 11th, 2019, 22:30
I think the issue is that the character sheet is too short for the number of tabs that you have. You'll need to increase the size of the charsheet window class and the tabs_charsheet template dimensions to fit all the tabs.

Regards,
JPG