PDA

View Full Version : Creating a new window on desktop



Ranzarok
July 5th, 2019, 22:15
I am attempting to create a new window for the desktop when you load a campaign. So I defined a new windowclass in the desktop_classes.xml and set a new framedef in the graphics_frames.xml. From the FG docs, I couldn't find if there was something else I needed to do in order for it to show up. Right now, it just has some dummy string_label in the sheetdata tag. Just trying to get it to draw first.

EDIT: Seems I am missing quite a few things. Premature posting. My apologies.

Thanks

Ranzarok
July 5th, 2019, 22:20
I think maybe I have it figured out. Will delete post if I do.

damned
July 6th, 2019, 05:14
Better yet - please post the full files/code :)

Ranzarok
July 6th, 2019, 08:09
Sure. I am sure this is FG 101 for most of you but if you want to see it here ya go.

I created a new panel on the desktop (that's the part I was missing), created some new art for the panel, added the Doom and Momentum buttons. Right now, it is using basicnumber tags for the pool numbers. Next thing I have to do is create the functionality for both the Doom Pool and the Group Momentum Pool and a way for the player generated Momentum total to be added to the group Momentum if the player chooses to bank it. Long way to go, but learning along the way.

windowclass in my desktop_classes.xml

<windowclass name="doom_tracker">
<noclose />
<sizelimits>
<dynamic />
<minimum width="200" height="400" />
</sizelimits>
<sheetdata>

<genericcontrol name="dtbase">
<bounds>1,1,99,199</bounds>
<icon>doomtracker</icon>
</genericcontrol>

<button_dtmom name="dtmomentum">
<bounds>19,20,62,62</bounds>
</button_dtmom>

<basicnumber name="gmompool">
<bounds>25,70,20,20</bounds>
</basicnumber>

<button_dtdoom name="dtdoom">
<bounds>19,120,62,62</bounds>
</button_dtdoom>

<basicnumber name="gdoompool">
<bounds>55,110,20,20</bounds>
</basicnumber>

</sheetdata>
</windowclass>
template for the buttons in the Doom Tracker in my template_desktop.xml


<!-- Buttons for Doom Tracker -->

<template name="button_dtmom" merge="join">
<buttoncontrol>
<icon normal="button_dtmomentum" pressed="button_dtmomentum_down" />

<script>
function onButtonPress()
local msg = {font = "msgfont", icon = "momentumicon"};
msg.text = " You need to make this spend a Momentum from the Group Pool and subtract it from the total. ";
Comm.deliverChatMessage(msg);
end
</script>

</buttoncontrol>
</template>

<template name="button_dtdoom" merge="join">
<buttoncontrol>
<icon normal="button_dtdoom" pressed="button_dtdoom_down" />

<script>
function onButtonPress()
local msg = {font = "msgfont", icon = "doomicon"};
msg.text = " You need to make this spend a Doom from the Doom Pool and subtract it from the total. ";
Comm.deliverChatMessage(msg);
end
</script>

</buttoncontrol>
</template>

panel created in desktop_panels.xml

<panel name="doom_tracker" modes="host,client">
<class>doom_tracker</class>
<bounds>400,-350,100,200</bounds>
<dynamic />
<locked />
</panel>

27802

damned
July 6th, 2019, 09:20
Sure. I am sure this is FG 101 for most of you but if you want to see it here ya go.

You might be surprised.
Posts like this are very valuable!

superteddy57
July 7th, 2019, 05:38
Very much so! Love seeing new things that could be huge improvements to other systems.

Ranzarok
July 8th, 2019, 19:29
I've found out that creating the window the way I have described still doesn't get me what I need. Only having done the above, the window shows up when I launch FG campaign but it is unbound, so I can't get data from or send data to it. On start up the console reports the node as nil.

I've went through Jeffery Redding's extension tutorial, the FG documentation and tried things but to no avail. I have even looked at MoreCore's dicepool windowclass and the onInit call but still get the error. Any help would be appreciated.

I put this in to get the nil notification

<windowclass name="doomtracker">
<noclose />
<sizelimits>
<dynamic />
<minimum width="200" height="400" />
</sizelimits>

<script>
function onInit()
Debug.console("self", self);
Debug.console("getDatabaseNode", self.getDatabaseNode());
end
</script>

I've also tried this bit of onInit but I think there is more to it then just declaring the class name? (my terminology is probably all wrong)

<windowclass name="doomtracker">
<noclose />
<sizelimits>
<dynamic />
<minimum width="200" height="400" />
</sizelimits>

<script>
function onInit()
DoomTracker.registerControl(self);
end

function onClose()
DoomTracker.registerControl(nil);
end
</script>

<sheetdata>

<genericcontrol name="dtbase">
<bounds>1,1,99,199</bounds>
<icon>doomtracker</icon>
</genericcontrol>

<button_dtmom name="dtmomentum">
<bounds>19,20,62,62</bounds>
</button_dtmom>

<basicnumber name="gmompool">
<bounds>25,70,20,20</bounds>
</basicnumber>

<button_dtdoom name="dtdoom">
<bounds>19,120,62,62</bounds>
</button_dtdoom>

<basicnumber name="gdoompool">
<bounds>55,110,20,20</bounds>
</basicnumber>

</sheetdata>
</windowclass>

I have both the desktop_panels.xml and the desktop_classes.xml included in my extension.xml file

celestian
July 8th, 2019, 20:11
How are you opening the window?

Ranzarok
July 8th, 2019, 20:22
How are you opening the window?

Thanks for the reply

Through the desktop_panels.xml (I was opening with a "/" in the chat window but wanted to open when FG loaded the campaign, so I did this:)

<panel name="doomtracker" modes="host,client">
<class>doomtracker</class>
<bounds>400,-350,100,200</bounds>
<dynamic />
<locked />
</panel>

damned
July 8th, 2019, 23:29
Hi Ranzarok

In terms of creating a new window etc - if you are looking at MoreCore objects - then the locations is an example of a new window and data type.
But you are also looking at making it a new desktop object that is always there like the Chat Window?

I didnt write any of the DicePool stuff - that was ianmward but he also released it as a CoreRPG extension so you can see the code without having to search your way through everything.

Ranzarok
July 9th, 2019, 00:54
Thanks damned. I did look at the DicePool lua and tried to model it after that but failed.

Also wondering if you can call, or reference an unbound windowclass (windowinstance?) I apologize for the terminology, I realize that it's probably all wrong and I am doing more harm then good.

I think it might be more helpful to try and explain what I want to do.

https://brucepatnaude.com/images/temp/helpImage2.png

So here is the code for the "doomtracker" window
desktop_classes.xml

<windowclass name="doomtracker">
<frame>grouptracker</frame>
<noclose />
<sizelimits>
<dynamic />
<minimum width="200" height="400" />
</sizelimits>

<script>
function onInit()

Debug.console("self", self);
Debug.console("getClass", self.getClass())
Debug.console("getDatabaseNode", self.getDatabaseNode());
Debug.console("getFrame", self.getFrame());
end

</script>

<sheetdata>

<genericcontrol name="dtbase">
<bounds>1,1,99,199</bounds>
<icon>doomtracker</icon>
</genericcontrol>

<button_dtmom name="dtmomentum">
<bounds>19,20,62,62</bounds>
</button_dtmom>

<basicnumber name="gmompool">
<bounds>25,70,20,20</bounds>
</basicnumber>

<button_dtdoom name="dtdoom">
<bounds>19,120,62,62</bounds>
</button_dtdoom>

<basicnumber name="gdoompool">
<bounds>55,110,20,20</bounds>
</basicnumber>

</sheetdata>
</windowclass>

and in the desktop_panels.xml

<panel name="doomtracker" modes="host,client">
<class>doomtracker</class>
<bounds>400,-350,100,200</bounds>
<dynamic />
<locked />
</panel>

The basicnumber field I want to access is "gdoompool".

So that's where I am at. EDIT: Forgot to mention, the doomtracker window would be persistent. No need to close it.

damned
July 9th, 2019, 01:33
I had thought about creating a type of shared/group "hero points " which could be used for something like this but has never climbed high enough up my wish list :)

So we have two issues right?

1. You are wanting to adjust the values of the Shared Pool by PCs clicking on their Char Sheet?
2. You want the window that tracks the Shared Pool to open automatically and be persistent?

I would worry less about the second issue for now.

As a guess - the player doesnt own the gdoompool so they cant make changes to it
They can only make changes to records they own - their char sheet and any notes they created.

You will need to do some OOB messaging.
There is an example of building some OOB in this video - https://www.youtube.com/watch?v=zTNLJDMLpGk its CT but i reckon it might be the missing key...

Ranzarok
July 9th, 2019, 01:44
Thanks!

Yes, you are correct, that is what the issues are. I actually have the shared pool window up at the opening of the campaign, I can add numbers to the two basicnumber fields and I have both of the buttons but no real functionality.
This:
As a guess - the player doesnt own the gdoompool so they cant make changes to it
They can only make changes to records they own - their char sheet and any notes they created. helps alot.

I will take a look at the video. I appreciate the help.

Ranzarok
July 12th, 2019, 07:20
I'm still working on the Doom tracker window with the help of damned's video, not getting it done yet, so I decided to finish up some more of the little things. With the exception of having the ability to create a new item and designate it as a "weapon" with its own set of properties, and then be able to drag and drop it on the character sheet and the npc sheet, those two are nearly complete. They have abilities and skills listed with proper button rollers to factor in all of their modifiers. Talents, Spells, and Creatures on its own sub window (tab), background, languages, appearance, warstory on another.

Just the doom tracker and the weapon list issues to go and I should be ready to test it with live folks. :)

Thanks for all of the help so far. "Knowing is half the battle."

https://www.brucepatnaude.com/images/temp/status1.jpg

damned
July 12th, 2019, 10:17
Its looking good!

Ranzarok
July 26th, 2019, 22:54
Decided to make my doomtracker tied to the campaign DB (Was going to try the OBB msg that damned pointed me too, but I found out I need to store the pool values in the campaign DB). The window is created using panel on initialization. It has a windowclass = doomtracker and has two number controls and two button controls.
I've looked for something similar to emulate but the modifier stack and the dicepool are not tied to a database ( that info is stored in memory?).

Should I be using a function in DesktopManager to register the window?

Oberoten
July 27th, 2019, 01:10
Decidedly following this. Would love nothing more but to create a clockface using the same method, a Doomsday clock. Very useful for a lot of indie-games.

damned
July 27th, 2019, 01:29
Decided to make my doomtracker tied to the campaign DB (Was going to try the OBB msg that damned pointed me too, but I found out I need to store the pool values in the campaign DB). The window is created using panel on initialization. It has a windowclass = doomtracker and has two number controls and two button controls.
I've looked for something similar to emulate but the modifier stack and the dicepool are not tied to a database ( that info is stored in memory?).

Should I be using a function in DesktopManager to register the window?

You need BOTH the OOB and the DB.
The data is stored in the DB and when players make changes they are using OOB.
Have a look at dbdamage roll (in scripts).


Decidedly following this. Would love nothing more but to create a clockface using the same method, a Doomsday clock. Very useful for a lot of indie-games.

Something like these?

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

https://www.fantasygrounds.com/forums/showthread.php?40872-Blades-in-the-Dark-One-Shots&p=363593&viewfull=1#post363593

Oberoten
July 27th, 2019, 01:37
Something like these?

https://www.fantasygrounds.com/forums/showthread.php?40872-Blades-in-the-Dark-One-Shots&p=363593&viewfull=1#post363593

Yes. Exactly like that. I missed this. :)

- Obe

Ranzarok
August 1st, 2019, 00:06
I've abandoned the Doom Tracker as a desktop panel and rewritten it as a sidebar item. I was able to bind the window and manipulate the data (Doom Pool and Group Momentum) on the Host side (DM) and now I am trying to work through the OOB messaging that damned pointed me to. Still haven't cracked that nut yet even by using his video and the dbdamage roll lua as an example.

What I am trying to do sounds simple but I know it's not (at least for me)

https://i.imgur.com/X3NDQgP.png

With this, I can click on the button to "spend" either Momentum or Doom, and by double clicking on the number box, I can add to either.

Is there a way to make this window visible to clients as well (players and not only GM)? I am sure it has to be set in the onInit function but not sure of the syntax. Or at the very least, allow GM to share it with connected players once he opens it.

Adding new window via sidebar (Host side only I think)

function onInit()
if(User.isHost()) then
DesktopManager.registerDockShortcut("button_track", "button_track_down", "Doom and Momentum Tracker", "trackerwindow", "TrackBox");
end
end

To spend:

<template name="button_tmom" merge="join">
<buttoncontrol>
<icon normal="button_dtmomentum" pressed="button_dtmomentum_down" />

<script>
function onButtonPress()

local rActor = ActorManager.getActor("pc", window.getDatabaseNode());
Debug.console("rActor: ");
Debug.console(rActor);

local nodeWin = window.getDatabaseNode();
Debug.console("nodeWin: ", nodeWin);

local totalmom = nodeWin.getChild("grpmompool").getValue();
Debug.console("totalmom: ", totalmom);

if totalmom == 0 then
Debug.console(totalmom);
local msg = {font = "msgfont", icon = "maxmomicon"};
msg.text = " The group Momentum Pool is empty.";
Comm.deliverChatMessage(msg);

return totalmom;
end

nodeWin.getChild("grpmompool").setValue(totalmom-1);
Debug.console(totalmom);

local msg = {font = "msgfont", icon = "smomentumicon"};
msg.text = " One (1) group Momentum spent. ";
Comm.deliverChatMessage(msg);

end
</script>

</buttoncontrol>
</template>

To add:

<basicnumber name="grpmompool">
<bounds>25,70,20,20</bounds>
<script>
function onDoubleClick(x,y)
local rActor = ActorManager.getActor("pc", window.getDatabaseNode());
Debug.console("rActor: ");
Debug.console(rActor);

local nodeWin = window.getDatabaseNode();
Debug.console("nodeWin: ");
Debug.console(nodeWin);

local mompool = nodeWin.getChild("grpmompool").getValue();
Debug.console(mompool);

if mompool == 6 then
Debug.console(mompool);
local msg = {font = "msgfont", icon = "maxmomicon"};
msg.text = "Group Momentum at maximum.";
Comm.deliverChatMessage(msg);

return mompool;
end

nodeWin.getChild("grpmompool").setValue(mompool+1);
Debug.console(mompool);

local msg = {font = "msgfont", icon = "addmomicon"};
msg.text = rActor.sName .. " added 1 to the Group Momentum. ";
Comm.deliverChatMessage(msg);
end
</script>
</basicnumber>

<basicnumber name="grpdoompool">
<bounds>55,110,20,20</bounds>
<script>
function onDoubleClick(x,y)
local rActor = ActorManager.getActor("pc", window.getDatabaseNode());
Debug.console("rActor: ");
Debug.console(rActor);

local nodeWin = window.getDatabaseNode();
Debug.console("nodeWin: ");
Debug.console(nodeWin);

local doompool = nodeWin.getChild("grpdoompool").getValue();
Debug.console(doompool);

nodeWin.getChild("grpdoompool").setValue(doompool+1);
Debug.console(doompool);

local msg = {font = "msgfont", icon = "adddoomicon"};
msg.text = rActor.sName .. " added 1 to the DM Doom Pool. ";
Comm.deliverChatMessage(msg);
end
</script>
</basicnumber>


If I could just figure out that OOB messaging code I would be all set. I need to allow the player(s) to add to the basicnumber "grpdoompool" from their character sheet with a onButtonPress.

Thanks again for your help damned.

If anyone is interested, here is a screenshot of the work to-date on my Conan 2d20 extension. I also have a Hyborian calendar as a module (with the help of mattekure's samples and tutorial).
28178