PDA

View Full Version : Specify subwindow datasource



Grimmbart
April 29th, 2019, 17:49
Hi all

For a subwindow, the FG Manual indicates:
The created window will always have the same data source as the parent window.

Is it possible to specify a specific datanode ?

Thank's.

Moon Wizard
April 29th, 2019, 19:09
The subwindow control now supports a setValue(class, recordpath) API that you can use to load alternate data paths in Lua script.

Regards,
JPG

Grimmbart
April 29th, 2019, 19:35
Thank's for your response.
Whats is thé exact syntax ?
Is there an entry in the wiki ?

Grimmbart
April 29th, 2019, 20:31
Sorry but have you an example ?

Thank's

Moon Wizard
April 30th, 2019, 17:10
From the CoreRPG ruleset, it's used to set values into the background image panel.

wPanel.sub.setValue("imagepanelwindow", sRecord);


The values accepted are just like any link within FG. It requires a valid window class name, and a data path.

Regards,
JPG

Grimmbart
May 1st, 2019, 08:16
Thank's, I will try this today.

Nicolas

drvolk
July 7th, 2022, 06:14
From the CoreRPG ruleset, it's used to set values into the background image panel.

wPanel.sub.setValue("imagepanelwindow", sRecord);


The values accepted are just like any link within FG. It requires a valid window class name, and a data path.

Regards,
JPG

I tried to set a subwindow source path with the "Ruleset Wizard" tool (see post in the Armor/Paid Creation/Ruleset Wizard thread) . The wizard create a subwindow tag with as "source" attribute where it stores the path i set in the tool. But this seams to be not working.
Is the definition of a source as attribute in the subwindow tag currently not supported ?

So i tried the set source path of the subwindow as you described (in "onInit" of the subwindow control). This work , but has the effect that for the numberfields i have defined in my window class, which i use for the subwindow, nodes were created on root level of the main window and on the source i have defined with setValue.
I think the reason for that is, that the field control in the sub window class were inititialized before the "onInit" of the subwindow control. The "onInit" of the subwindow control then seams to trigger again a "onInit" of the numberfield control of its window class, is that right ?

If yes, how i could prevent that?

Moon Wizard
July 7th, 2022, 22:12
You can not set a "source" attribute on a subwindow. It doesn't do anything. That's only valid for value type fields (string, number, link, formattedtext, etc.)

Subwindows use the same data source path as the containing record; unless specifically set otherwise using the setValue API.

Regards,
JPG

drvolk
July 9th, 2022, 06:17
Thanks for clarify that.

Have you an idea how i could change the data source path of a subwindow with setValue before the value type fields which are contained in that subwindow will be initialized ? Otherwise the value nodes of that fields will be created in the containing record of the subwindow and not at then "new" path of the subwindow.

I have set fastinit for my subwindow, is this maybe my fault ? Or do i have to change somehow the onInit of the value field control or the window class containing to the subwindow ?

damned
July 9th, 2022, 14:18
Arent you just trying to store attribute info in the character sheet?
This will be done without you adding a source on the subwindow as someone pointed out in the other thread.

drvolk
July 9th, 2022, 21:57
Arent you just trying to store attribute info in the character sheet?
This will be done without you adding a source on the subwindow as someone pointed out in the other thread.

I want to create 7 subwindow on the main charactersheet subwindow. All 7 subwindows should use the same window class, which contains 4 field values (numberfields: current, max, used. bought).
Because the values of a subwindow will stored on the containing record, which is the same for all 7 subwindow my approach does not work. so i need a way to set an individuell data source path for each subwindow, A working solution would be a windowlist. but there i have to create the childs dynamicly , what i dont want.
the subwindow solution would be perfect if i could set data source path for its containing value fields.

Moon Wizard
July 9th, 2022, 22:50
You can't do that through XML.

For the XML, you can specify multiple subwindows that derive their data source from their parent windowclass (ala tabs on character sheet). For this approach, you can define individual window classes that provide the correct source location within the parent window class for each subwindow class. This is essentially what the default character sheet tabs do.

If you really need to force subwindows to use different source locations than parent window; then you'll need to use the subwindow.setValue API.

Regards,
JPG

damned
July 10th, 2022, 03:00
Can you post some pictures of what you are trying to build?
What is the game system?

Its most likely that what you want to achieve is already implemented (in a different way) in other rulesets.

drvolk
July 10th, 2022, 08:12
If you really need to force subwindows to use different source locations than parent window; then you'll need to use the subwindow.setValue API.

Thanks, this brings me back to my last question/issue. If i do so, i got the issue that the value field control also creates a node for the subwindow contained record, because they were initialized before the "onInit" of the subwindow, where i used the "setValue" API to change the source path for it.
I used the "fastinit" flag for the subwindow, maybe this caused that problem, i will check ...

@damned
I found ways to implement what i need, but i was looking for a more "smart" solution (especialy to realize it with the great ruleset wizard tool). The subwindow seams to be for me the solution which fits to my use case (you see all stats in the layout preview of the wizard, you only neet to implement all that logic for the numberfield only once in the window class of the subwindow, the label for the subwindows could be definded outside the subwindow and got automaticly a translateable string resource generated for it by the wizard), if it would work as i thought it would be.

I am trying to create a simple "The dark Eye" ruleset (i know the is a good working MoreCore Solution for it also available).

Moon Wizard
July 10th, 2022, 17:45
If you are trying to mirror the same controls for a bunch of stats, then you are talking about some sort of grouped templating system that can somehow be applied to multiple fields using some sort of prefix/suffix scheme, which FG doesn't do.

If you look at any of the existing ruleset, attributes like you are talking about are all built using multiple controls (not subwindows); but use templates heavily to make the set of controls simpler. (Look at 3.5E campaign/record_char_main.xml in the charsheet_main window class.)

Regards,
JPG

damned
July 10th, 2022, 23:57
yes templates are the smart way to apply commonly reused layouts/functions.

drvolk
July 11th, 2022, 05:48
Yes, then that was probably just the wrong approach again (I learned programming many decades ago and probably don't get the "old" thinking out ;)
I will try it with templates, which is now also supported by the Ruleset Wizard.

Thanks a lot for your help!

UPDATE:

Just for information, i got it work how i wanted to:

I had to remove the "activate" and "fastinit" flag of the subwindow (set to FALSE in Ruselset Wizard) and add this onInit code for the subwindow:


function onInit()
local sClass, sDataSource = self.getValue();
local sNodeName = sDataSource .. ".stats." .. self.getName();

if not DB.findNode(sNodeName) then
DB.createNode(sNodeName);
end

self.setValue(sClass, sNodeName);
window[self.getName()].setEnabled(true);
window[self.getName()].setVisible(true);
end

This results into the db structure i did like to have:


<charsheet>
<id-00001>
----
<stats>
<arcane_energie>
<boni_mali type="number">0</boni_mali>
<bought type="number">0</bought>
<max type="number">0</max>
<score type="number">0</score>
<used type="number">0</used>
</arcane_energie>
<dodge>
<boni_mali type="number">0</boni_mali>
<bought type="number">0</bought>
<max type="number">5</max>
<score type="number">5</score>
<used type="number">0</used>
</dodge>
<karma_points>
<boni_mali type="number">0</boni_mali>
<bought type="number">0</bought>
<max type="number">0</max>
<score type="number">0</score>
<used type="number">0</used>
</karma_points>
<life_points>
<boni_mali type="number">0</boni_mali>
<bought type="number">0</bought>
<max type="number">20</max>
<score type="number">20</score>
<used type="number">0</used>
</life_points>
<spirit>
<boni_mali type="number">0</boni_mali>
<bought type="number">0</bought>
<max type="number">5</max>
<score type="number">5</score>
<used type="number">0</used>
</spirit>
<toughness>
<boni_mali type="number">0</boni_mali>
<bought type="number">0</bought>
<max type="number">5</max>
<score type="number">5</score>
<used type="number">0</used>
</toughness>
</stats>
....
</id-00001>
</charsheet>