Board index FlightGear Development Canvas

Use Nasal to Randomize Splash Screens

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

Use Nasal to Randomize Splash Screens

Postby jonbourg » Thu Jul 10, 2014 3:27 pm

Ok, here is my idea. I have a plane and when you start it up I would like it to pick a custom splash screen, but instead of having the same splash screen every time it would pick one at random and display it. So someone could make multiple splash screens for a plane and the nasal script would randomly pick one of them. I was thinking it could be a custom nasal script right in the -set file or it would call up a .nas file. I don't see why this couldn't be done using nasal, but I don't know how to write the code. Anybody want to give it a shot?
jonbourg
 
Posts: 328
Joined: Tue Mar 11, 2008 1:43 am
Location: Omaha, NE
Callsign: BU2B
OS: Windows8

Re: Use Nasal to Randomize Splash Screens

Postby Philosopher » Thu Jul 10, 2014 3:42 pm

I don't think it's possible without core changes – the splash screen initialized way too early, and the image used is set at that time (nowhere else AFAICT). O.o

See though the Initializing Nasal Early WIP.
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm

Re: Use Nasal to Randomize Splash Screens

Postby Hooray » Thu Jul 10, 2014 4:23 pm

right, this keeps coming up - we've had some aircraft developers who wanted to show random splash screens, multiple images (rotating) or who'd like to see some kind of "hall of arame" shown while booting.

The existing scheme is hard-coded and cannot be scripted. The only kind of flexibility it provides is that it can randomly select splash screens for aircraft that don't have a corresponding entry set. Otherwise, even splash screen updates are hard-coded, despite being property-based.

Personally, I don't think it matters very much to be honest - but for several technical reasons, all active developers agree that the scripting interpreter, and canvas, should be initialized earlier. Primarily, the idea is to provide an integrated GUI launcher that uses Nasal + Canvas:
http://wiki.flightgear.org/Aircraft_Center
Image

Inspired by the recent performance/resource utilization debate, I started looking at our "FGCanvas" idea again, which is basically just FlightGear, as is - but with a better configurable initialization process, so that certain subsystems can be made optional, and others better customized - this will also help us better understand performance issues that are specific to certain subsystems.

As you can see below, FlightGear will basically start up using just a subset of its subsystems, mainly the essential ones - while others will be dynamically allocated, on demand:
http://wiki.flightgear.org/FGCanvas
viewtopic.php?f=71&t=23499
Image

Overall, this also touches the area of initializing certain subsystems earlier, or even first - especially Nasal. So that certain things can be scripted (including splash screens): viewtopic.php?f=71&t=22021

However, the way our existing code is structured there are a handful of implicit design assumptions that are now conflicting, such as subsystem-specific extension functions being added and accessed unconditionally. In the last two days, we've made some progress in this area, and things are looking pretty encouraging (with only minor regressions):

http://wiki.flightgear.org/Initializing_Nasal_early
Image

As can be seen, this works already fairly well - removing the hard-coded splash screen feature and re-implementing it using ~50 lines of Nasal should be fairly straightforward now.

Next, there are some Nasal level issues, i.e. bootstrapping should be handled there - but otherwise, it would seem straightforward now to initialize Nasal fairly easily, and use Nasal/Canvas to do GUI stuff, while the rest of the sim is still loading. Most of the really hard work has already been handled by James & Tom fortunately. So depending on feedback, support and manpower, this could make it into one of the next two releases (after 3.2).
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Use Nasal to Randomize Splash Screens

Postby hvengel » Thu Jul 10, 2014 4:32 pm

One possibility would be to have a group of splash images in a directory and then have a nasal script that would copy images from that directory in some kind of random or rotating order over the file that is used for the splash screen after each start up of the sim. This would change the splash screen every time the software was restarted. So in sudo code it might look something like this:

Have the potential splash screens images in a special directory like Aircraft/<my aircraft>/SplashImages
This would need to be image files of the same type ONLY to keep things simple.

Listen for initialization to finish.
Get all of the file names from the SplashImages directory and put them into an array or hash
Use a random number generator or some other technique to select one of the file names from the array or hash
Copy that file over the splash screen image that is used by the simulator at start up.

Fairly simple and fairly flexible since images could be added or removed from the splash screen image directory without having to change the code. This could also be made to work for any aircraft with minimal (perhaps none at all) modifications to the code if all the aircraft used the same name for the splash screen image name and type or if the file name used by the script for the splash image was configured through a property.

So I think it is possible but the Nasal code would be changing the splash screen image for the next time FG is run rather than for the current session.

I was wondering about this same thing (rotating splash screens) earlier this week and dismissed it being something that could happen right at start up for the very reasons Philosopher mentioned. But this thread caused me to think about it a little and I realized that from a user point of view changing the splash screen for the next session would be indistinguishable from changing the image at start up and that this might be fairly simple to do. In fact I think this would be trivial to implement and I might spend a few minutes this week end putting something like this together. If I get it working I will post the code here.
hvengel
Retired
 
Posts: 1127
Joined: Sun Dec 24, 2006 5:35 am
Location: Minden Nevada

Re: Use Nasal to Randomize Splash Screens

Postby Hooray » Thu Jul 10, 2014 4:36 pm

there are still some limits here, but some workarounds should be possible - even though I'm not sure it's worth the hassle: this is the kind of thing that is trivial to do in Canvas using 5 lines of code, and changing an image is just the equivalent of a .set/setprop() call basically. So I wouldn't spend too much time working around this limitation - as can be seen, making the splash screen 100% dynamic at run-time isn't exactly rocket science using Canvas. The really hard work has already been done by TheTom. Thus, disabling the hard-coded splash screen and showing a GUI dialog without window decoration, would give aircraft developers all the flexibility they need - they could even fetch stuff via http easily :mrgreen:
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Use Nasal to Randomize Splash Screens

Postby hvengel » Thu Jul 10, 2014 5:36 pm

What I want as an aircraft dev and perhaps this is true of others as well is a standardized way to do this in the *-set.xml like: 1. Set either a splash screen image (just like the current set up for backwards compatibility but perhaps discourage this so that it goes away at some point) or a splash screen image directory in the *-set.xml file. If this is set this to use a single image then it works just like it does now. If this is set to a splash screen image directory then it rotates through the images in that directory. So it is one line of XML like the current setup that allows for rotating splash screen images. The aircraft devs shouldn't have to do more than that even if the alternative is only 5 lines of nasal code. IMO those 5 lines of canvas/Nasal code should be a standard part of the FG start up and the functionality should just be there and be a one liner to use. From my point of view fetching stuff via http would be of limited usefulness and I wouldn't use this but others may disagree
hvengel
Retired
 
Posts: 1127
Joined: Sun Dec 24, 2006 5:35 am
Location: Minden Nevada

Re: Use Nasal to Randomize Splash Screens

Postby Philosopher » Thu Jul 10, 2014 5:48 pm

I, like Hooray, think HTTP could be really cool, but whatever, you don't have to use it ;).

I think the best way to go WRT configurability is to use the same node (/sim/startup/splash-texture) for either a single file, a single directory, or a single URL (HTTP), and then allow several of these nodes, from which a list of images would be drawn up and a random one chosen. That way it's simple and backwards-compatible yet still supporting the features you want. This would require less than 60 LOC to support from Nasal (including some other features) and could be loaded ASAP with early Nasal.
Last edited by Philosopher on Thu Jul 10, 2014 5:51 pm, edited 2 times in total.
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm

Re: Use Nasal to Randomize Splash Screens

Postby Hooray » Thu Jul 10, 2014 5:50 pm

What I want as an aircraft dev and perhaps this is true of others as well is a standardized way to do this in the *-set.xml


it should be possible to support 2-3 tags and process those while booting, either setting a fixed image, picking one randomly from a configurable directory, or even running a Nasal script to do pretty much anything, including animated splash screens (gauges, progress bars) - for example:

  • <splash-texture></splash-texture>
  • <random-splash-directory></random-splash-directory>
  • <splash-nasa-filel></splash-nasal-file>

Implementing support for this should be under 50 lines of Nasal/Canvas code, and anybody wanting more elaborate schemes, should obviously use the 3rd option (even though that doesn't mean, that certain schemes couldn't be also registered. The flexibility provided by Nasal/Canvas is hard to beat here ... and it means to get rid of very old and ugly C++ code, too :D

I still find it amazing how often aircraft devs keep coming up with this - but technically, I agree that it would make sense to get rid of certain C++ code and make it more flexible via Nasal/Canvas, i.e. stuff like:
  • GUI
  • HUD
  • 2D panels
  • Splash screens
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Use Nasal to Randomize Splash Screens

Postby jonbourg » Thu Jul 10, 2014 5:56 pm

I don't do programming so I didn't understand the complexity of this. I just always thought it would be neat if you could make a set of splash screens for a particular aircraft and it would simply pick one of them at startup. It's just one of those neat to have, but not necassary things.
jonbourg
 
Posts: 328
Joined: Tue Mar 11, 2008 1:43 am
Location: Omaha, NE
Callsign: BU2B
OS: Windows8

Re: Use Nasal to Randomize Splash Screens

Postby Hooray » Thu Jul 10, 2014 5:59 pm

changing the C++ code accordingly would not be difficult at all.

But this (and much more!) will be trivial to do in a few months time using Nasal once the "reinit Nasal early" work has materialize/stabilized a little more - and it will not involve any C++ at all, like Philosopher said: it will probably be just ~30 lines of Nasal code looking for certain XML tags in your aircraft-set.xml file, and maybe an option to run your own Nasal code in case you want to do anything fancy.

The http example was just mentioned to demonstrate just how flexible a pure Nasal/Canvas-based solution would be. I don't have any need for this - but aircraft devs could for example simply load the "picture of the week" from the wiki ;-)
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Use Nasal to Randomize Splash Screens

Postby Philosopher » Thu Jul 10, 2014 6:14 pm

Or entice users with screenies of the latest versions! ;)
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm

Re: Use Nasal to Randomize Splash Screens

Postby Hooray » Thu Jul 10, 2014 6:18 pm

that's actually a pretty cool idea - sort of like an "upcoming features" gallery that promotes our nightly builds to get hopefully wider exposure & testing.
Most of Thorsten's screen shots should easily have the potential to make people check out the latest snapshot ...
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Use Nasal to Randomize Splash Screens

Postby hvengel » Thu Jul 10, 2014 10:36 pm

<splash-texture></splash-texture>
<random-splash-directory></random-splash-directory>
<splash-nasa-filel></splash-nasal-file>


Is exactly what I had in mind. I could easily do some custom Nasal and be OK with it if that was the only way to get it done but there are probably many aircraft devs that would prefer something really simple. In the end having something simple that would rotate splash screen images would be all I want and not having to write any code is a bonus.
hvengel
Retired
 
Posts: 1127
Joined: Sun Dec 24, 2006 5:35 am
Location: Minden Nevada

Re: Use Nasal to Randomize Splash Screens

Postby Johan G » Thu Jul 10, 2014 11:28 pm

hvengel wrote in Thu Jul 10, 2014 10:36 pm:
Hooray wrote in Thu Jul 10, 2014 5:50 pm: <splash-texture></splash-texture>
<random-splash-directory></random-splash-directory>
<splash-nasa-filel></splash-nasal-file>


Is exactly what I had in mind... In the end having something simple that would rotate splash screen images would be all I want and not having to write any code is a bonus.

True for me as well (though I have only done a little tinkering so far). :) I would guess that something like this is what most aircraft developers would expect.
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: Use Nasal to Randomize Splash Screens

Postby hvengel » Fri Jul 11, 2014 12:26 am

For me at least it is a matter of priorities. What things in my aircraft are more important - splash screens or other stuff like the external model, the cockpit, the FDM, liveries...? Splash screens are way down the list and to even think about messing with them it needs to be very quick and easy. This is probably the case for many aircraft devs if they already have a single splash screen image set up. On the other hand if I could setup a splash screen directory with one line of XML I would do that even if at this point there was only one splash screen image in that directory. Then it would be easy over time to put more images into that directory and users could even add their own.
hvengel
Retired
 
Posts: 1127
Joined: Sun Dec 24, 2006 5:35 am
Location: Minden Nevada

Next

Return to Canvas

Who is online

Users browsing this forum: No registered users and 3 guests