PDA

View Full Version : Deriving windowclasses



Xarxus
October 17th, 2022, 11:51
I noticed that I have 2 very similar windowclasses. The second has all the fields of the first with 2 differences: one of the fields (same type: formattedtextcontrol, same name) has a different width, a new field.
I wonder if there is a way to derive the second windowclass from the first.

Trenloe
October 17th, 2022, 15:57
You could use windowclass merging - see this information in the ruleset developer portion of the FG Wiki: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644522/Ruleset+-+Layering#Window-Class-Merging

Xarxus
October 17th, 2022, 20:12
Uhm, if I understand correctly the Window Class Merging allows you to merge your class with one of a previous layer. The new class will have the same name as the previous one.
In my case both classes are on the same layer and must have different names, otherwise it would be difficult to use the right one in the right place.

Is it not possible to put windowclasses in a template?

Trenloe
October 17th, 2022, 21:43
Sorry, I didn't fully understand what you were asking before. Templates are only available for window controls: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644511/Ruleset+-+Templates+for+code+re-use

But, you can put the windowclass with the common controls in a subwindow and then use that as essentially a template within a windowclass. This is something the main FG rulesets have been moving to in some recent updates - using subwindow data to define frequently used controls within a windowclass.

A simple example is the CoreRPG ruleset campaign\record_item.xml file - where the base definition for the item window is configured. This uses the following code within the main "item" windowclass:


<subwindow_record name="main">
<class>item_main</class>
<activate />
</subwindow_record>

With other controls defined outside of this subwindow.

Then the "item_main" windowclass defines the controls that appear within that subwindow.

Xarxus
October 18th, 2022, 18:37
It is not clear to me; I can use subwindows as controls, so I can "break" my windowclasses into multiple parts to be chained, right?

Trenloe
October 18th, 2022, 18:40
It is not clear to me; I can use subwindows as controls, so I can "break" my windowclasses into multiple parts to be chained, right?
Yes. For an example, please have a look at the CoreRPG files I referenced in post #4.

Xarxus
October 18th, 2022, 20:25
Yes, I'm studing it. I've a lot to study... and to test

Ty guy!

Xarxus
April 15th, 2023, 12:51
I don't know if it's a new feature or something I previously missed, but I think the solution to my problem is copy.
The following code comes from the CoreRPG's record_npc.xml file. It's exactly what I needed. If I'm not
mistaken it's not documented on the wiki.

<windowclass name="npc_header" copy="record_header_id_token" />

Moon Wizard
April 15th, 2023, 17:44
It's an undocumented feature right now; because we're still figuring out what the ramifications of the feature will be, the usefulness of the feature, and what problems might occur. We generally try to use features in our own code for several months or more to make sure that they work the way we would like them to work and that they are useful, before announcing and locking in APIs.

Regards,
JPG

Xarxus
April 15th, 2023, 20:47
It's an undocumented feature right now; because we're still figuring out what the ramifications of the feature will be, the usefulness of the feature, and what problems might occur. We generally try to use features in our own code for several months or more to make sure that they work the way we would like them to work and that they are useful, before announcing and locking in APIs.

Regards,
JPG

For what my opinion is worth, I think it's a very useful feature.
I strongly support it.

Moon Wizard
April 15th, 2023, 22:37
We definitely understand the strength of the feature, which is why I introduced it for testing. But, it does have some caveats and limitations that I wanted to test out in a live environment before making it official. It's actually been a good test feature so far; but I want to let it settle a bit and think about how it should work long term before finalizing.

Regards,
JPG

Xarxus
April 16th, 2023, 11:00
I get that, but I still root for him to stay. :)

Indeed, I think it would be comfortable on other controls as well. For example, it is convenient for the Font to
have different fonts of the same type with different colors or sizes. Changing the first one would also benefit
the others.

I think it would also be convenient for the development of Themes.