PDA

View Full Version : Coding Help: Make new tab in inventory area



Leperchan5
January 18th, 2018, 16:11
Hello everyone,

I was wondering if anyone knew how (or the code) to add a new tab in the inventory section (much like the Sci-Fi companion & Rippers do). I know you can make a tab for the whole character but I'm trying to add it to inventory because it is well inventory based. All else fail I could use "Cyber ware" but it's really not that. All else fail I can dive into the Sci fi companion and try to figure it out
but any help would be appreciated.

dberkompas
January 18th, 2018, 17:49
You'll need to write an extension.

Just to satisfy my curiosity, do you mean another tab after Mundane, Weapons, Armor, Vehicles and Notes?


Dave

Leperchan5
January 18th, 2018, 19:18
I am well aware that I would have to make an extension, but a little confused on where to start. To answer your second question, yes. I want to add another tab after weapons, armor, ect. When you add the Sci-fi companion or the Ripper's setting they add Cyber-ware or Ripper Tech in a tab. This akin to what I want to do.

dberkompas
January 18th, 2018, 19:40
Well, how about we start you off on the right path then? Are you game?


Dave

Leperchan5
January 18th, 2018, 19:50
I am 100% down for that. I am so ready to game, I rolled Initiative (or in this case, drew a card) :D

dberkompas
January 18th, 2018, 19:55
A good place to start:
https://www.fantasygrounds.com/wiki/index.php/Developer_Guide

1. Create a directory in your extensions directory, we're going to call it leperchan5.
2. Create a directory inside leperchan5 called charsheet.
3. Inside leperchan5, create a file called extension.xml
4. Copy/paste the following into extension.xml

<?xml version="1.0" encoding="iso-8859-1"?>
<root version="3.3" release="1">
<announcement text="Add a tab to Inventory" font="emotefont" icon="rulesetlogo_CoreRPG" />
<properties>
<name>Adding tab to Inventory</name>
<version>1</version>
<author>Your Name</author>
<description>Add tab to Inventory for Savage Worlds</description>
<ruleset><name>SavageWorlds</name></ruleset>
</properties>
<base>
</base>
</root>

5. Start up Fantasy Grounds
6. Create a new campaign, select Savage Worlds.
7. Hopefully you'll now see an Extension called 'Adding tab to Inventory'

Of course, it won't do anything at the moment, as we haven't made any modifications.

(to be continued, I'm doing this as I type this)


Dave

dberkompas
January 18th, 2018, 20:00
Next, we're going to have to take a look at how all this crazy stuff is put together.

Inside the ruleset directory, you'll see a file called SavageWorlds.pak. Copy (DO NOT MOVE) to your desktop, and change the filename to SavageWorlds.zip

Create a folder on your desktop, name it something you're remember, and move the file you just copied to the desktop into this folder.

Next, unzip that file into this new folder, so you don't clutter up your precious desktop.


Dave

Leperchan5
January 18th, 2018, 20:22
All this looks good so far. I have a few things I need to do, but I'll be diving into the Savage World Pak code once i'm done :)

Thank you for getting me started on the right track.

dberkompas
January 18th, 2018, 20:54
Now we're rolling...

Open up extension.xml, and put the following between <base> and </base>.


<includefile source="charsheet/charsheet_inventory.xml" />
<includefile source="charsheet/charsheet_inventory_leperchan5.xml" />
<includefile source="strings/strings_common.xml" />

Next, find those files and replicate the path just like the unzipped SavageWorlds.pak.

You won't have a charsheet_inventory_leperchan5.xml, just copy charsheet_inventory_notes.xml and replace _notes with _leperchan5.

Next time, we're going to modify those three files so that a tab appears in the inventory.
(Yup, that's all there is to adding a tab, quite simple)


Dave

dberkompas
January 18th, 2018, 20:56
Your directory structure should look like this:

leperchan5
├── charsheet
│** ├── charsheet_inventory.xml
│** └── charsheet_inventory_leperchan5.xml
├── extension.xml
└── strings
** └── strings_common.xml


Dave

dberkompas
January 18th, 2018, 21:04
Open up leperchan5/strings/strings_common.xml and add the following line right before common_mundane

<string name="common_leperchan5">Leperchan5</string>


In charsheet/charsheet_inventory.xml, add the following before notes_button section:

<button_inventorytab name="leperchan5_button">
<labelres>common_leperchan5</labelres>
</button_inventorytab>


Further down, after notes_sub, add the following:

<subwindow_inventory name="leperchan5_sub">
<class>inventoryleperchan5_subwindow</class>
</subwindow_inventory>


We'll be finishing up here very shortly.


Dave

dberkompas
January 18th, 2018, 21:10
Finally, in charsheet/charsheet_inventory_leperchan5.xml:

Replace inventorynotes_subwindow with inventoryleperchan5_subwindow

The whole file should look like this:
<?xml version="1.0" encoding="iso-8859-1"?>

<!--
Please see the license.html file included with this distribution for
attribution and copyright information.
-->

<root>
<windowclass name="inventoryleperchan5_subwindow">
<sheetdata>
<label_char_center>
<static>Leperchan5 Tab</static>
</label_char_center>
<stringfield name="shortnotes">
<anchored position="over" offset="-20,-9">
<top offset="42" />
</anchored>
<multilinespacing>20</multilinespacing>
<font>sheettextsw</font>
<lineoffset default="on">-2</lineoffset>
</stringfield>
<scrollbar>
<anchored to="shortnotes"/>
<target>shortnotes</target>
</scrollbar>
</sheetdata>
</windowclass>
</root>


Save everything. If you're already in Savage Worlds, and have the extension enabled, just type /reload, and you should see the new tab.

Nothing fancy, just a place for text.


Dave

Ikael
January 18th, 2018, 22:10
Alternatively you could check attached sampler extension. It's highly recommended to utilize merge-rules instead of including codes from SavageWorlds ruleset, this would allow you to evade extensions getting broken when the ruleset is updated, and if something is broken, it's less maintenance work to keep it up.

dberkompas
January 18th, 2018, 22:20
Sweeeet, thanks Ikael.


Dave

Leperchan5
January 18th, 2018, 22:21
Wow, this will save a lot of time. Thanks everyone!