PDA

View Full Version : Simple 4 Column Window Code -errors



Tempered7
July 5th, 2025, 08:46
Heya coding-wizards,

I want to make a window with 4 editable columns.

Below code is what I managed to edit from ChatGPT's code. The problems are;


Where to access it in Tabletop? '/openwindow mysimplewindow' doesn't work, even with singleton="true" in windowclass tag under windowsheet xml.
How to resolve the error below? //EDIT: I solved it by removing <extension> tag.
And how do you suggest I tie it to somewhere for quick access? To a button? In a module? Or else?

Attachment:
64733
ChatGPT only adding to the pile of errors with its "suggestions."
Thanks in advance.

Unable to open window (mysimplewindow:).
Usage: /openwindow [windowclass] <datapath>

I thought singleton is for removing the need for setting a datapath?


extension.xml

<?xml version="1.0" encoding="iso-8859-1"?>


<root version="3.0">
<extension>
<properties>
<name>Solo Card Game Rules</name>
<version>1.0</version>
<author>Tempered7</author>
<description> This extension adds a custom window with 4 editable columns. </description>


<ruleset>
<name>5E</name>
</ruleset>
</properties>


<announcement text="Use '/openwindow mysimplewindow' in the FG chat console to open your new window."/>


<frames>
<frame name="mywindowframe" bitmap="graphics/frames/chatbox.png" />
<!-- Replace bitmap with your frame graphic, or use built-in ones -->
</frames>


<windowclasses>
<include source="window_mysheet.xml" />
</windowclasses>


</extension>


</root>



window_mysheet.xml

<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<windowclass name="mysimplewindow">
<sheetdata>
<genericcontrol name="backgroundframe">
<anchored>
<to>client</to>
<position>insidetopleft</position>
<offset>0,0</offset>
</anchored>
<frame>mywindowframe</frame>
</genericcontrol>


<!-- Four columns with editable textboxes -->
<stringfield name="col1_text">
<anchored>
<to>client</to>
<position>topleft</position>
<offset>10,10</offset>
<size>100,200</size>
</anchored>
</stringfield>


<stringfield name="col2_text">
<anchored>
<to>col1_text</to>
<position>topright</position>
<offset>10,0</offset>
<size>100,200</size>
</anchored>
</stringfield>


<stringfield name="col3_text">
<anchored>
<to>col2_text</to>
<position>topright</position>
<offset>10,0</offset>
<size>100,200</size>
</anchored>
</stringfield>


<stringfield name="col4_text">
<anchored>
<to>col3_text</to>
<position>topright</position>
<offset>10,0</offset>
<size>100,200</size>
</anchored>
</stringfield>
</sheetdata>
</windowclass>
</root>

Trenloe
July 5th, 2025, 16:08
Recommendation: I'd strongly recommend you look at the ruleset wizard for doing things like this: https://www.fantasygrounds.com/forums/showthread.php?61387-Ruleset-Wizard-The-new-Ruleset-development-environment

But, to look at this example in detail:

In my experience ChatGPT is average at best, but frequently inaccurate, for generating FG code. Always compare the code generated with FG references. For example: see here for details of the extension.xml file: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996645668/Extension+-+Data+Files

1) Add a <base> section, change <include> to <includefile>, change <frame> to <framedef> and remove <windowclasses> and <frames> from extension.xml

Note on framedef - the bitmap used has to be within the extension itself. Use the builtin "chatbox" frame using the <frame> asset.

3) To add a button to the desktop toolbar in the top right, try adding a LUA script file with:


function onInit()
DesktopManager.registerSidebarToolButton({ class = "mysimplewindow" });
end

Activate this script file from your extension.xml file using the <script> tag.


Additionally:
4) You'll need <placement> and probably <sizelimit> information in your windowclass, otherwise your window won't have a size and won't display correctly.

Also, review the positioning -> anchoring section here: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644483/Ruleset+-+Interfaces+Windows+Panels+Widgets#Positioning The position names aren't valid - topleft and topright don't exist - refer to the valid names in the shorthand graphic in that page.

I've fixed most of the issues and added a default value with underlining to each stringfield so they're easier to see in the window. I've also used the "chatbox" frame asset. See the attached Solo Card Game Rules.ext

Here's a screenshot:

https://www.fantasygrounds.com/forums/attachment.php?attachmentid=64735

But, I'll re-iterate - I strongly recommend using the Ruleset Wizard: https://www.fantasygrounds.com/forums/showthread.php?61387-Ruleset-Wizard-The-new-Ruleset-development-environment

Tempered7
July 5th, 2025, 18:13
Thank you, Trenloe!

I was trying to refer to the wiki but I got lost in it.
Also, I checked the Ruleset Wizard before. Transaction method is Paypal which is banned in my country.

/Info for consolidation;

So, to consolidate, based on the extension.xml code in OP;


<windowclasses> and <frames> must be replaced with <includefile source="any_other_file.xml" /> and be wrapped in with <base> tag.
Most importantly, <frame>chatbox</frame> in windowsheet.xml removes the need to add a background.png.
But <framedef name=... instead of <frame name=... is the right way to add a BG image.

Based on window_mysheet.xml;

<placement> and probably <sizelimit> in between <windowclass name="mysimplewindow"> will give the window its size, and limit it.
Tested with and without the <sizelimit>: Without) Its size is fixed and CTRL + LMB resizing doesn't work. With) Resizing with both CTRL + LMB & clickling from bottom right works but when I shrink it too small, top frame disappears. //Note to self: search for a fix in Trenloe's link (https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644483/Ruleset+-+Interfaces+Windows+Panels+Widgets#Positioning).


Note on framedef - the bitmap used has to be within the extension itself. Use the builtin "chatbox" frame using the <frame> asset.
For clueless newbies like me;

Bitmap in Fantasy Grounds XML


A bitmap in the context of Fantasy Grounds XML refers to a specialized type of widget that contains a single bitmap image. This image can be modulated with a color value, which affects its hue and transparency. The bitmap can be scaled to fit the size of the control, or it can be shown at its original size and clipped if a clip region is specified

Things I did:


Changed some Width x Height numbers,
Tried to add description text under One - Two... but failed. I think based on what LordEntrails said before, I should've done it with <string> type.

Trenloe
July 5th, 2025, 18:17
Also, I checked the Ruleset Wizard before. Transaction method is Paypal which is banned in my country.
Reach out to @psicodelix directly. He can probably organize some alternative method for you.

Tempered7
July 5th, 2025, 18:52
Reach out to @psicodelix directly. He can probably organize some alternative method for you.

Will do, thanks.