Browser Plugin
From C4 Engine Wiki
Beginning with version 2.6, the C4 Engine includes a plugin that provides a web browser widget that can be added to user interface panels and in-game panel effects with the panel editor. An example use of the browser widget is available in the sample world Data/Tutorial/world/Browser.wld, shown in Figure 1 to the right.
Installing Awesomium
The browser widget uses Awesomium to render web pages to a texture map and handle user interaction. Awesomium is not distributed with the C4 Engine and must be installed separately before the browser widget can function. To install Awesomium, first download the SDK for either Windows or Mac, and then follow the instructions below for each platform.
Windows
- Run the Awesomium installer and let it install the SDK somewhere on your hard disk. The folder that is installed will only need to exist temporarily.
- Navigate to the
build/bin/release/directory inside the Awesomium SDK folder. - Copy all of the contents of the
build/bin/release/directory to your C4 folder. - The following files and folders should now exist in the same folder that contains
C4.exe:-
Awesomium.dll -
AwesomiumProcess.exe -
icudt42.dll -
locales
-
- You can now delete the Awesomium SDK folder that was previously installed.
Mac OS X
- Navigate to the
build/bin/release/directory inside the Awesomium SDK folder. - Copy the file
Awesomium.frameworkto your C4 folder. - The file
Awesomium.frameworkshould now exist in the same folder that containsC4.appand theXcodefolder. - You can now delete the Awesomium SDK disk image that was originally downloaded.
Using the Browser Widget
The binaries that ship with C4 do not include a pre-built browser plugin, so it needs to be compiled before it can be used. The project files are set up to compile the browser plugin by default, so simply rebuilding the entire engine in Visual Studio or Xcode will create it.
Once the browser plugin has been built, the browser widget appears in the list of widgets in the panel editor. The browser widget has the following settings in addition to the standard widget settings:
|
Setting |
Description |
|
Internal width (pixels) |
The width of the internal texture map into which web pages are rendered. Together with the internal height, this defines the virtual window size for the web browser, and it is independent of the size of the browser widget within the panel. |
|
Internal height (pixels) |
The height of the internal texture map into which web pages are rendered. |
|
Enable alpha blending |
If checked, then the browser texture is rendered with alpha blending enabled. This allows web pages with transparent backgrounds to render as transparent widgets in the panel. |
|
Home page address |
The URL of the home page for the browser widget. If this is not blank, then the browser widget will initially navigate to this address when it is first created in a dialog or in-game panel effect. |
|
Address widget identifier |
This is an optional identifier that names the text widget that holds the address for the web browser. Whenever the browser's current location is changed, the text widget is updated with the current location. The target widget can be any widget that is based on the text widget, such as an edit text widget. |
Browser Functions
The browser widget also defines several controller functions that can be used to send commands to the browser from a script, and these are listed below. Most of these are demonstrated by the buttons at the top of the panel in the Data/Tutorial/world/Browser.wld world.
|
Setting |
Description |
|
Reload Browser Widget |
Reloads the web page at the browser's current location. |
|
Stop Browser Widget |
Stops loading a web page. |
|
Navigate Back |
Navigates back to a previously visited web page. |
|
Navigate Forward |
Navigates forward to a previously visited web page. |
|
Navigate to Address |
Navigates to an address specified in the function settings. |
|
Navigate to Text Widget |
Navigates to an address specified by a text-based widget. |

