Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

XNA Profiles

kevingadd edited this page Aug 18, 2012 · 12 revisions

JSILc includes a set of profiles for XNA 3.1 and XNA 4.0. If it detects that the project you're building is an XNA game (you'll need to feed it your .sln file, not your executable), it will automatically load the appropriate profile and use it to process your game content.

How it works

JSILc looks for a project containing the targets from XNA Game Studio 3.1 or 4.0. This means that the Windows Game Project template should be detected.

The XNA profile scans your project for one or more content projects (.contentproj files) and processes the ones that your game project referenced. Each content project processed produces one or more browser-ready output files, along with a manifest (Foo.contentproj.manifest.js) that you can include into a page in order to give the JSIL preloader (JSIL.Browser.js) the information it needs to load that content.

When combined with the appropriate application manifests (Foo.exe.manifest.js, etc) and the right stub libraries (JSIL.XNACore.js followed by JSIL.XNA3.js or JSIL.XNA4.js, as appropriate) your application should work with no additional changes.

##Configuration In addition to the standard configuration options for JSILc, the XNA profiles have additional options that you can set by adding a 'ProfileSettings' key to your configuration file, like so:

{
  "OutputDirectory": "%configdirectory%",
  "ProfileSettings": {
    ...
  }
}

The ProfileSettings dictionary can contain the following setting keys:

Key Type Default Value Description
ContentOutputDirectory String null If specified, sets the location for converted XNA content. If this is not set, no content will be converted! A good choice is "%configdirectory%/Content". Supports Variable Expansion.
JPEGQuality Integer 90 The quality level to use when converting textures to JPEG. 1 - 100.
MP3Quality String -V 3 The quality parameter(s) to pass to LAME when generating MP3s.
OGGQuality String -q 6 The quality parameter(s) to pass to OggEnc when generating Ogg Vorbis files.
UsePNGQuant Boolean false If true, JSILc will attempt to use PNGQuant to optimize the PNGs it generates from your textures by converting them to 8-bit RGBA. This will dramatically reduce their size at the expense of adding dithering artifacts.
PNGQuantColorCount Integer 256 Configures the number of colors PNGQuant will attempt to produce when compressing images. If you lower this, the images will probably get a bit smaller.
PNGQuantOptions String You can use this to pass extra options to PNGQuant.
FileSettings Dictionary {} A dictionary containing a list of settings for each individual content file in your project. See the 'File Settings' section below.
ForceCopyXNBImporters Array of Strings [] Allows you to specify one or more XNB file importers that, if seen in a project, should trigger JSILc to convert the raw output .XNB file to your content directory. See 'Raw XNB Files' below.
ForceCopyXNBProcessors Array of Strings [] Allows you to specify one or more XNB file processors that, if seen in a project, should trigger JSILc to convert the raw output .XNB file to your content directory. See 'Raw XNB Files' below.

##File Settings

The FileSettings option allows you to specify settings for individual files in your content project, like so:

"FileSettings": {
  "Textures\\Panels\\intro1.png": "ForceJPEG",

You do it by specifying the full path to the file (rooted in the content directory - so Content\Textures\Panels\intro1.png becomes Textures\Panels\intro1.png.).

The file setting is a string containing one or more Keyword Settings. The available options are listed below.

Keyword Description
UseXNB Forces copying of this file to the output directory as a Raw XNB, much like ForceCopyXNBImporters & ForceCopyXNBProcessors. See 'Raw XNB Files' below.
ForceJPEG Forces this texture to be converted to a JPEG instead of a PNG. This is useful if you know the PNG does not contain an alpha channel.
NoPNGQuant Disables PNGQuant for this file. This is useful if the dithering artifacts produced by PNGQuant are too severe on particular images.

You can also use Variable Expansion to assign a friendly name to a group of settings that you wish to apply to multiple files - i.e. define a variable named ImageSettings and then put %ImageSettings% in the settings string for each of your images.

##Raw XNB Files For some file formats, it is difficult or impossible to serve them to a web browser in a format that has all of the features that the XNA Framework equivalent have - for example, SpriteFonts have numerous features that are difficult (if not impossible) to reproduce by serving up a regular TTF file, and Effects have no browser equivalent.

For other file formats, it makes more sense to load them at run-time using the XNA Framework Content Readers than to let the browser do it - for example, DXT-compressed textures are sometimes smaller than the equivalent PNG or JPEG.

You can configure JSILc to copy the raw XNB file (produced by the XNA Content Pipeline when you built your project) directly to the output folder, and add it to the asset manifest so it will be loaded by your game in the browser, either by using the ForceCopyXNBImporters/ForceCopyXNBProcessors Profile Settings, or the UseXNB File Setting.

In cases where there is no suitable alternative, JSILc should use the raw XNB file automatically (SpriteFonts and Effects, for example.)

##Dependencies

  • MP3 conversion requires the console version of LAME to be located where JSILc can find it. Currently, it looks in ..\Upstream\LAME\lame.exe.
  • OGG conversion requires the console version of OggEnc to be located where JSILc can find it. Currently, it looks in ..\Upstream\OggEnc\oggenc2.exe.
  • If your sound files are not stored in .WAV (for example, if you added an .MP3 to your content project), JSILc will attempt to use FFMPEG to decode them before converting them to OGG and MP3. It currently looks in ..\Upstream\FFMPEG\ffmpeg.exe.
  • If PNGQuant is enabled, JSILc looks for it at .\PNGQuant.exe.