As some of you might know I've been working on integrating the chromium browser engine (or a
framework specifically for embedding it) into FSO in an effort to be able to replace the current interface code.
It's far from being complete but I think that it is in a state which can be released for public testing, but first some screenshots:
Browsing HLP while shooting Cylons
Yes, WebGL works
Here are the links to the test builds, as the required libraries and files are quite big I have uploaded them separately so I don't need to update them with the builds.
Installing:Test Builds:
Download (
dontcrashdontcrashdontcrashdontcrashdontcrash)
Required additional files:
DownloadYou need both packages but once you have downloaded and unpacked the second package you will not need to download it again, even if the builds are updates. Place all files into the root of FSO while keeping the directory structure.
For those interested:
Source codeBuilding:Special thanks to ngld for getting these changes to build on linux and also for improving the building process on Windows.
- To build, first clone the repository above and checkout the branch feature/chromiumInput. Make sure that you also clone the submodules, either by using --recursive while cloning or running git submodule update --init --recursive.
- Then you need the CEF builds for your platform: http://cefbuilds.com/
If you are on windows then use the 32-bit versions, FSO doesn't support 64-bit yet
Any branch after and including 1750 should work, if you want the newest features then you can use the trunk builds but those may not work correctly. - Unpack the downloaded zip into a directory of your choice
- Generate your project files using CMake (documentation)
- You have to set the CEF_PATH variable to the directory where you just unpacked the zip
- Windows only: If you are not using Visual Studio 2010 open the 3rdparty solution folder and in the properties of the libcef_dll_wrapper change the platform toolset to the one corresponding to the other projects
- Build the project, you can use the install mechanics of CMake to install the binaries to a directory of your choice
Using the builds:As chromium uses some resources even if it isn't being used I decided to have it disabled by default so mod that don't use it don't use more resources than necessary. For this I added an option to the
game_settings.tbl.
After
$FS2NetD port: you have the
#CHROMIUM SETTINGS section which currently only has the
$Enable Chromium: option which takes a boolean value to enable chromium. You will need this or else the browser won't work.
There are two ways of using the new capabilities:
- Via lua, I have added the ba.createBrowser() function which will create a browser which can be used to draw the contents anywhere to the screen which includes other textures and probably also texture replacement on ships. Everything should be documented in the scripting documentation.
- By replacing the state logic: I have added a system which allows to completely overwrite what FSO does in any state it may be in. Currently this only allows to create a fullscreen browser. Fullscreen browsers are different from browsers created by lua, they don't draw the contents to a texture but directly to the screen. This allows for drastic performance improvements for some pages, especially those using WebGL.
This means that the system can't use the cursor set by FSO as that is overwritten by chromium but this is no problem as you can change the cursor image with CSS (see example package below).
Now let's see what you can do with all that, there is now a new table called
states.tbl and the respective modular table
*-sta.tbm. Here is an example of what you can do:
#States
$State: GS_STATE_INITIAL_PLAYER_SELECT
+Type: HTML
+URL: http://fso/data/html/playerSelect.html
#End
$State takes a state name (documented on the wiki) and initializes custom logic for that state, currently there is only the type HTML. To configure which URL is used use the
+URL option.
As you notice from the example above you can reference files of FSO by using the
fso domain. The following path is the full path to the file you want to load relative to your mod directory.
Here is an example of what you can do with the player select screen:
http://www.mediafire.com/download/8vcx13q70x1c9hd/browserTest.7zYou can also completely replace the default mainhall, here is an example:
http://www.mediafire.com/download/xh2tm35aijm136c/mainhallTest.7zTo communicate with FSO from your JavaScript code there is the
fsoApi object within the global scope which has three functions:
- query: Starts a query for data, the player select example above used the only functions currently available
- registerCallback: Can be used to call JavaScript code from FSO. Register a function that should be called and then execute that callback from Lua with browser.executeCallback. The function return a value which can be used to unregister the callback again.
- unregisterCallback: Takes a return value from a previous call to registerCallback to remove that callback again.
I know that this information is a bit sparse but it's a WIP project so all this is subject to change.
Please test the builds, especially without any changes to your mod as I want to make sure that it works the same with unaltered data.
Thank you very much,
Regards,
m!m