Howto:Canvas Splash Screens

From FlightGear wiki
Jump to navigation Jump to search
This article is a stub. You can help the wiki by expanding it.


Note  This feature depends on a merge request that is currently being reviewed (#1586). This is a relatively popular idea among aircraft developers, but is obviously only relevant during startup, so should probably not be prioritized compared to other Canvas related features that would be beneficial to have at runtime.

Idea / Motivation

Cquote1.png I do think that even just changing the background color (currently black) and the font could improve the screen very much.
— mftetsudou38125 (Jan 6th, 2016). Re: Alternative Loading Screens?.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png art of the splash is actually generated by FG itself. By and large only the square pic in the middle is configurable.That's a low-level measure to prevent practices like re-branding FG to sell it - unless you go to some trouble exceeding changing a few images, the splash will always read Flightgear and show the project URL. A serious fork can eliminate that, but a quick copy does not.
— Thorsten (Jan 6th, 2016). Re: Alternative Loading Screens?.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png that's not possible, because the startup screens have a fixed resolution and if I recall correctly they should (or must) be power of two ( 128x128, 256x256, 512x512, 1024x1024, etc.), while the FlightGear window can have different resolutions, so there can be parts which are not covered by the startup screen and are hence black.
— dg-505 (Jan 6th, 2016). Re: Alternative Loading Screens?.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png I can imagine so many possibilities of what can be done if that is implemented.
— mftetsudou38125 (Jan 6th, 2016). Re: Alternative Loading Screens?.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png I got some messages from aircraft developers asking if they could use the Canvas system and Nasal to create more dynamic splash screens.

I said this wouldn't be possible currently. But theoretically, most of the required hooks should be in place for this, right ? I mean, we already have support for raster images, text and vector graphics (SVG) already. Now obviously, this is not such an important thing - but it would seem doable, and we could implement much more interactive splash screens that way, showing much more useful information.


— Hooray (Fri Feb 07). Splash Screens + Canvas.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png we could consider using Canvas here if people really think they need more dynamic -and more responsive- splash screens. Compared to other simulators, FG is already pretty fast when it comes to booting. So I do not have any use for sophisticated elaborate splash screens - then again, most of the work related to this, is likely to be done either way - i.e. making Nasal & Canvas available earlier. Keep in mind that the long-term ideas post 3.2 is to move many frontend/launcher features back into FG. So this would not be about coming up with a huge new feature - it be primarily about using existing code to get rid of old C++ code - i.e .unifying the rendering 2D back-end.
— Hooray (Fri Feb 07). Re: Splash Screens + Canvas.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png once we can initialize Nasal earlier (which will probably Philosopher's boootstrap.nas script, but which also depends on Zakalawe's reset/re-init work) we should be able to pull this off with less than 50 lines of Nasal/Canvas code.

— Hooray (Sun Apr 27). Re: Splash Screens + Canvas.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png 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 (Thu Jul 10). Use Nasal to Randomize Splash Screens.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png 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.


— hvengel (Thu Jul 10). Re: Use Nasal to Randomize Splash Screens.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png 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 (Thu Jul 10). Re: Use Nasal to Randomize Splash Screens.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png 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
— Hooray (Thu Jul 10). Re: Use Nasal to Randomize Splash Screens.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png 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 (Thu Jul 10). Re: Use Nasal to Randomize Splash Screens.
(powered by Instant-Cquotes)
Cquote2.png

Status

WIP.png Work in progress
This article or section will be worked on in the upcoming hours or days.
See history for the latest developments.
Cquote1.png 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


— Hooray (Thu Jul 10). Re: Use Nasal to Randomize Splash Screens.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png 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)
— Hooray (Thu Jul 10). Re: Use Nasal to Randomize Splash Screens.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png 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).


— Hooray (Thu Jul 10). Re: Use Nasal to Randomize Splash Screens.
(powered by Instant-Cquotes)
Cquote2.png

Implementation

Cquote1.png In addition, it's worth keeping in mind that our existing splash screen handling code is rather inflexible and could be greatly simplified by allowing Canvas+Nasal to handle the animation side of things.

In fact, we could even show instruments or MFDs on the splash screen by supporting Canvases there, but also a loglist widget or other useful information that we cannot currently show easily when just starting.

So maybe it's not such a bad idea after all ?


— Hooray (Fri Feb 07). Splash Screens + Canvas.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png Regarding the limitations of the current splash screen code, we once contemplated disabling the hard-coded version (there is a property switch for that) and using a Canvas instead: Howto:Canvas Splash Screens The main/only thing missing to do that is moving the Nasal interpreter out of the SGSubsystemMgr instance and adding it separately, so that it becomes available much earlier, at which point you could even render fully animated Canvas textures (i.e. not just static images)
— Hooray (Jan 6th, 2016). Re: Alternative Loading Screens?.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png 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.
— Philosopher (Thu Jul 10). Re: Use Nasal to Randomize Splash Screens.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png 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


— Hooray (Thu Jul 10). Re: Use Nasal to Randomize Splash Screens.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png 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.
— Hooray (Thu Jul 10). Re: Use Nasal to Randomize Splash Screens.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png Agreed, I just had a look at the code ($FG_SRC/Viewer/splash.cxx) - it seems fairly straightforward to re-implement the existing functionality using ~50-80 lines of Nasal/Canvas code.


Currently, that's simply not a priority though - so you may still want to file a feature request (issue tracker) so that we don't forget about this.
Obviously, the existing feature works "well enough", and touching working code isn't exactly popular :D

Technically, it would even be a good thing to pursue - the splash screen code is not exactly compact and it handles several corner cases already.


— Hooray (Sat Jul 12). Re: Use Nasal to Randomize Splash Screens.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png Agreed, I just had a look at the code ($FG_SRC/Viewer/splash.cxx) - it seems fairly straightforward to re-implement the existing functionality using ~50-80 lines of Nasal/Canvas code.


Currently, that's simply not a priority though - so you may still want to file a feature request (issue tracker) so that we don't forget about this.
Obviously, the existing feature works "well enough", and touching working code isn't exactly popular :D

Technically, it would even be a good thing to pursue - the splash screen code is not exactly compact and it handles several corner cases already.


— Hooray (Sat Jul 12). Re: Use Nasal to Randomize Splash Screens.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png it's actually trivial, we don't even have to touch the viewer/splash screen code at all: there's an existing option to disable the whole thing via --disable-splash-screen, which is currently defaulted to false - but we only need to edit options.cxx to default it to true, which will keep all the splash code disabled - so that we can directly use Nasal/Canvas to show a GUI dialog without decoration to render things, including randomly-selected splash screens. Amount of C++ changes: ~1 line - and then it's roughly 30 lines of Nasal code to come up with a scripted splash screen that will be loaded from $FG_ROOT/Boot/default.boot - and which could support the existing scheme, as well as a "random" selection scheme, but also a totally scripted Nasal/Canvas splash mode
— Hooray (Sat Jul 12). Re: Use Nasal to Randomize Splash Screens.
(powered by Instant-Cquotes)
Cquote2.png