Elements Bits of an HTML page are called elements, and "gameBorder" is just one of them. All HTML documents have an "html" element that contains everything else, and inside that it has a "head" and a "body" elements. Quest then has a few dozen elements that make up the interface inside the "body" element.
You can look at those elements as you play a game. In the off-line editor, click on HTML Tools (on-line, your browser will probably have the facility to do this too). On the left you will see a hierarchy of elements (you will need to expand them to see them all), and on the right a list of properties. Click on an element, and it will be highlighted in your game so you can see what it refers to.
Most of the interesting elements are of the type "div", and each is identified by an "id". The gameBorder one looks like this:
CSS Properties and ValuesThere are a large number of CSS properties, to get a full list, use the internet. I will mention of of the interesting ones. You do need to be careful that you supply the right type of value, but we will look at that too. Also, be aware that CSS uses America spelling for "center" and "color".
colorThe colour of text is determined by the "color" property. You can set colours in a number of ways, the easiest is to use a name. This Wiki page has a full list of available names (note that there are no spaces in the name; for once, capitalisation does not matter):
http://en.wikipedia.org/wiki/Web_colors JS.eval("$('#gameBorder').css('color', 'blueviolet');")
You can also set colours by using the RGB code. These both set the colour to red.
JS.eval("$('#gameBorder').css('color', 'rgb(255, 0, 0)');")
JS.eval("$('#gameBorder').css('color', '#ff0000');")
Each splits colours in to three components: red, green, blue. In the first, each component is a number from 0 to 255. In the second, if is a hexadecimal number from 00 to ff. If you do not know what hexadecimal is, use the other format.
background-colorThis works just the same as color, but changes the background for this element.
JS.eval("$('#gameBorder').css('background-color', 'blueviolet');")
background-imageIn theory, you should be able to set the background image for each element, but I have not got that to work. You can set it for the entire page using the SetBackgroundImage function. If anyone can do it with CSS/JQuery, let me know how!
The status bar at the top uses an image. If you want to stop that image displaying, do this:
JS.eval("$('#status').css('background-image', 'none');")
widthThis will change the width of the element. You have the potential to mess up big time here, so change one element at a time and see what happens. Elements do impact on each other, so you may not see any difference. When experimenting, change the width of Quest itself to see what effect that has too.
Note that the value must include "px", which says the units are pixels.
JS.eval("$('#gameBorder').css('width', '950px');")
opacityThe opacity property defines how much this element covers the one below (the reverse of transparency). It can range from 0.0 (this element is not visible) to 1.0 (this element is completely opaque).
JS.eval("$('#gameBorder').css('opacity', '0.5');")
borderThe border property lets you set borders. You can set various aspects in one go, so in this example a dashed line, 5 px wide and blue, will be added.
JS.eval("$('#gameBorder').css('border', 'dashed 5px blue');")
The status bar at the top has a blue border. If you want to remove it, do this (also set the width to 950px to keep it aligned):
JS.eval("$('#status').css('border', 'none');")
FontsThere are about a dozen "base fonts" available in Quest. These are fonts that are pretty much guaranteed to be available on any computer (or at least equivalents, so we have Arial on PC, or Helvetica on Mac or failing that sans-serif).
If you want to change the font during a game, use the SetFontName function. This allows you to list the equivalent fonts, so will ensure users on other operating systems see more-or-less the same thing.
SetFontName("Arial, Heletica, sans-serif")
msg("This is in Heletica")
SetFontName("'Courier New', Courier, monospace")
msg("This is in Courier")
SetFontName("Impact, Charcoal, sans-serif")
msg("This is in Charcoal")
The sans-serif and monospace as generic fonts; there are also serif, cursive and fantasy. They will all map to
something on every computer, though the cursive and fantasy tend to fall well short of the names.
You also have access to web fonts. These are provided on-line by Google, and by default you can access just one in your game. To use any more, you need to call the SetWebFontName to pull the font off the internet, and then SetFontName as normal to actually use it.
// Pull the fonts off the internet
SetWebFontName("Wallpoet")
SetWebFontName("Admina")
// Now we can swap between them as much as we like
SetFontName("Wallpoet")
msg("This is in Wallpoet")
SetFontName("Admina")
msg("This is in Admina")
SetFontName("Wallpoet")
msg("This is in Wallpoet")
The "Continue" linkYou can change in the colour of hyperlinks on the Display tab of the game object, but it does not affect the "Continue" message when the game waits for the player to press a button, because that is actually part of the command line, not the output text. However, you can change it with JQuery, like this:
JS.eval ("$('#txtCommandDiv a').css('color', 'orange');")
Where and When To Do StuffWhen changing the styles of existing elements, put the code the InitUserInterface function. However, if you are adding new elements that may not work.
To add a new element, you need to output the HTML code, and Quest only offers one way to do that - using the
msg command (okay, there are also some
OutputXxx functions, but they are also essentially the same). We have no control when the text will appear in the HTML source, it will go at the end of the output section.
Note that the HTML code will get saved when the player clicks the save button, because it is part of the output text. For this reason it may be better in game.start, rather than
InitUserInterface (if it is in
InitUserInterface, when the player resumes play from a save, the HTML code will be added a second time.
However, it is important to remember that if you try to change the CSS values of your new HTML code before it has been added, it will not work. If you have JavaScript telling it to be in blue in
InitUserInterface, but your
msg command in in game.start, the text will not be blue because the JavaScript will try to change it before it exists. You should, therefore, try to have all the styling included in the HTML.
If you find you need to change CSS styles before adding the elements, the way to do that is to add a new style element to the HTML source, and in there define the styles for a class. When you later add your new HTML code, use that class. A fair knowledge of HTML and CSS is useful here!
Another approach is to move the HTML after it has been added, using the JQuery functions
insertAfter or
insertBefore for example. If the code gets moved out of the divOutput part then it will not be saved. In this case it should be safe to put it into
InitUserInterface.
That said, using
insertAfter or
insertBefore in
InitUserInterface can have problems of its own, and you can find that after the player reloads a saved game, new output text appears above the old text instead of below it. I have yet to establish under what conditions this happens, so it is vital that after you upload your game you play it, then save it, then reload a save game and play that too and see if it still works as it should.