Board index FlightGear Development Documentation

Documentation of fgcommand missing

Discussion of the FlightGear documentation, how it can be improved and coordination of people working on it.

Documentation of fgcommand missing

Postby Necolatis » Mon Dec 15, 2014 8:01 pm

The fgcommand show-message is not documented anywhere I could find.

How do I set transparency and position?
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1833
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2018.1.1
OS: Windows 10 Pro

Re: Documentation of fgcommand missing

Postby Hooray » Mon Dec 15, 2014 8:09 pm

show-message is not a hard-coded fgcommand implemented in C++, it's dynamically-added via the Nasal extension function addcommand() and implemented in tooltip.nas as a Nasal function: https://gitorious.org/fg/fgdata/source/ ... p.nas#L381

It's using a conventional Canvas: https://gitorious.org/fg/fgdata/source/ ... p.nas#L361
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11100
Joined: Tue Mar 25, 2008 8:40 am

Re: Documentation of fgcommand missing

Postby Necolatis » Mon Dec 15, 2014 10:40 pm

Thanks, I had to make calls to private methods sadly, but now the tips is placed where I want them. :)
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1833
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2018.1.1
OS: Windows 10 Pro

Re: Documentation of fgcommand missing

Postby Necolatis » Mon Dec 15, 2014 10:55 pm

I could change the tooltip code to allow for setting an Y position, if I am allowed to touch that code? Will be backwards compatible ofc.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1833
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2018.1.1
OS: Windows 10 Pro

Re: Documentation of fgcommand missing

Postby Hooray » Tue Dec 16, 2014 3:04 am

sounds like a good idea to me to expose more settings - I think someone else recently wanted to make similar adjustments (Jabberwocky ??) - so maybe just file a merge request for exposing such things via the existing props.Node API ?
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11100
Joined: Tue Mar 25, 2008 8:40 am

Re: Documentation of fgcommand missing

Postby Necolatis » Tue Dec 16, 2014 3:14 am

Yes, will do. Thanks.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1833
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2018.1.1
OS: Windows 10 Pro

Re: Documentation of fgcommand missing

Postby Hooray » Tue Dec 16, 2014 4:14 am

Here's two related efforts/threads:

Improving screen text visibility

Subject: gui.popupTip sizing and or positioning
Philosopher wrote:Hmm, I don't think it's possible to show two popupTips simultaneously (AFAIK, I could be wrong). However, you could (try and) look at Nasal/canvas/tooltip.nas and create your own Tooltips (basically you can look at that and Nasal/gui.nas for examples based on gui.popupTip and go from there; warning, it might be hard :D). Those will allow custom repositioning, and might fit your needs better anyways.


So you might want to get in touch if you think your work is overlapping
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11100
Joined: Tue Mar 25, 2008 8:40 am

Re: Documentation of fgcommand missing

Postby Necolatis » Tue Dec 16, 2014 6:22 am

From what I can see the work is not overlapping. But just to be safe I sent a pm to Talkless, although he has not been on the forums for a while, and the thread is over a month old.

If he gets in trouble with merging code I can help him out. But from the looks of it he gave up early on using tooltip.nas so should be safe.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1833
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2018.1.1
OS: Windows 10 Pro

Re: Documentation of fgcommand missing

Postby Hooray » Tue Dec 16, 2014 6:29 pm

Regarding your merge request (gitorious comments don't seem to work ATM for me...):

normally there should be no need for the quotes around the hash keys in the props.Node.new() call - e.g. something like this should suffice (untested):

Code: Select all
fgcommand("show-message", props.Node.new({ label: label, delay:delay, x: position.x, y: position.y }));


You can also simplify your conditional by factoring out the logic into a helper function, e.g. instead of using this twice:

Code: Select all
if(node != nil and node.getNode('y') != nil and num(node.getNode('y').getValue()) != nil)


you could have something like this:

Code: Select all
var haveNode = func(node, key) {
if(node == nil ) return nil;
var n = node.getNode(key);
(if n == nil) return nil;
var value = num(n.getValue() );
return value;
}


and then simplify your whole expression:

Code: Select all
if(var y = haveNode(node, 'y') != nil ) {
      me.setInt("y", y);
    } else {
      me.setInt("y", getprop('/sim/startup/ysize') * 0.2);
    }
    if(var x = haveNode(node, 'x')  != nil) {
      me.setInt("x", x);
    } else {
      var screenW = getprop('/sim/startup/xsize');
      me.setInt("x", (screenW - me._width) * 0.5);
    }


(again: this is untested)
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11100
Joined: Tue Mar 25, 2008 8:40 am

Re: Documentation of fgcommand missing

Postby Necolatis » Tue Dec 16, 2014 7:35 pm

Hooray wrote in Tue Dec 16, 2014 6:29 pm:
Code: Select all
fgcommand("show-message", props.Node.new({ label: label, delay:delay, x: position.x, y: position.y }));


That won't work when x or y is not defined, is why I used the quotes.

Hooray wrote in Tue Dec 16, 2014 6:29 pm:You can also simplify your conditional by factoring out the logic into a helper function, e.g. instead of using this twice:


Did that now, works. Thanks. :)
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1833
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2018.1.1
OS: Windows 10 Pro

Re: Documentation of fgcommand missing

Postby Hooray » Tue Dec 16, 2014 7:42 pm

That's true (I completely missed that) , but you can still use single quotes
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11100
Joined: Tue Mar 25, 2008 8:40 am

Re: Documentation of fgcommand missing

Postby Necolatis » Tue Dec 16, 2014 7:44 pm

Whats the advantage of single quotes over double quotes?
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1833
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2018.1.1
OS: Windows 10 Pro

Re: Documentation of fgcommand missing

Postby Hooray » Tue Dec 16, 2014 7:47 pm

depends on the context (shouldn't matter here at all, aside from readability) - but e.g. in print() statements there's no escaping done (need to check that though, might be confusing this with php/perl - but I'm sure that Philsosopher knows all the nitty gritty details ...)
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11100
Joined: Tue Mar 25, 2008 8:40 am

Re: Documentation of fgcommand missing

Postby Necolatis » Tue Dec 16, 2014 8:02 pm

Roger that. Tested it and it made no difference as you said. Merge updated.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1833
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2018.1.1
OS: Windows 10 Pro

Re: Documentation of fgcommand missing

Postby Philosopher » Tue Dec 16, 2014 10:00 pm

Yeah, Nasal != Python – using indentifiers instead of strings for hash keys doesn't mean evaluate an expression ;). (It actually means, using an identifier, that the involved strings are interned... which is good in some cases.) Single quotes, yes, only have \' as an escape – aka 99% raw.

Anyways (sorry just going off of Hooray's comments): instead of node.getNode(something).getValue(), use node.getValue(something) – it's quicker and cleaner and there's no need to check if the node exists ;).
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Next

Return to Documentation

Who is online

Users browsing this forum: No registered users and 1 guest