Difference between revisions of "Text Boxes"
m (typo) |
|||
Line 7: | Line 7: | ||
All text boxes operate the same way and can contain [[alternate descriptions]], each of which can contain graphics to display with the text and sounds to play when it is shown. | All text boxes operate the same way and can contain [[alternate descriptions]], each of which can contain graphics to display with the text and sounds to play when it is shown. | ||
− | There are two slightly different types, a large re-sizable text box in which the tabs on the right-hand side are labelled Source, Preview, [[ | + | There are two slightly different types, a large re-sizable text box in which the tabs on the right-hand side are labelled Source, Preview, [[Text Boxes#Graphics|Graphics]] and [[Text Boxes#Sound|Sound]], and a smaller fixed-size text box where the tab labels are abreviated to Src, Pvw, Gfx and Aud. |
== Automatic Capitalisation == | == Automatic Capitalisation == |
Revision as of 05:24, 26 May 2014
All multi-line text boxes within ADRIFT are completely flexible as to how and what they display. They are designed to look simple at first glance, with the user typing in basic descriptions. They all support Syntax Highlighting to show functions, references, keys, comments and variables. Alternate Descriptions can be used to append extra text, or completely change the displayed message, based on Restrictions.
Contents
Text box fundamentals
A text box allows you to enter multiple lines of text that ADRIFT will print to the runner screen during the game.
All text boxes operate the same way and can contain alternate descriptions, each of which can contain graphics to display with the text and sounds to play when it is shown.
There are two slightly different types, a large re-sizable text box in which the tabs on the right-hand side are labelled Source, Preview, Graphics and Sound, and a smaller fixed-size text box where the tab labels are abreviated to Src, Pvw, Gfx and Aud.
Automatic Capitalisation
ADRIFT will automatically capitalise the first word of every sentance. Specifically, it capitalises the first letter of the first word in the text box, and the first word after each full stop.
If your text box contains:
i am a flower. my petals are yellow.
ADRIFT will print:
I am a flower. My petals are yellow.
Normally of course you would do this yourself, but ADRIFT allows sentances to be assembled from separate pieces of text using functions and variables. For example, you may want to print the sentance:
%Colour% light filters in through the window.
But the %Color% variable may contain the word "orange" which is not capitalised, and which you may be using elsewhere where it should not be capitalised. ADRIFT will automatically fix the capitalisation to give you:
Orange light filters in through the window.
If you don't want this capitalisation to occur, then insert less-than, greater-than characters in front of the letter that should remain lower-case:
i.e. <>this is not capitalised.
Which is printed as:
i.e. this is not capitalised.
Tab pages
Down the right-hand side of the text box there may be several tabs named Source, Preview, Graphics and Sound (Abreviated to Src, Pvw, Gfx and Aud in the smaller text boxes on property sheets).
Each of these switches the text box to a different page.
The "Source" page is the normal page where you type the text you want to be displayed.
The other 3 tabs are only shown if they are selected in the ADRIFT settings page:
The three selections can be seen in the "Text Boxes" section at the lower right of this page.
Preview
This section has still to be completed. I am hoping that it will provide a preview of the text as it would be displayed in Runner. It may also be possible to apply What-You-See-Is-What-You-Get formatting directly to the text.
Graphics
You can insert graphics into a piece of text by selecting the Graphics tab on the right hand side. This provides a handy preview and URL. You can enter a filename, or a URL from the Internet here. Internet images will be downloaded on the fly, which can minimize the size of your adventure. By default, this will display the graphic at the start of the section of text.
It is also possible to insert multiple images in any piece of text by using <img> tags. The format is <img src="filename or url">. Using the <img> tags also allows you to customise exactly where in the text it will appear. This is useful if, for example, you have <waitkey> or <wait X> tags in your text. Also, you may want different images to appear for different alternate descriptions
Sound
As with Graphics, you can insert an audio clip by selecting the Audio tab on the right hand side. This provides three main buttons, a channel selector, and a loop checkbox.
To play a sound, click the Play button. This will bring up the file dialog box, where you can select a WAV, MP3 or MID file. There are plans to allow OGG files in a later release. Once selected, you can preview the sound by right-clicking on the Play button. You can have the audio loop indefinitely by selecting the Loop checkbox.
ADRIFT has 8 sound channels. This means you can have background music on a particular channel, and overlay different audio clips on other channels. By default, everything will be on channel 1.
To pause a sound file (for example, you might want to pause a piece of music when a particular piece of text is displayed), select the Pause button. This will pause any piece of audio on the selected channel. When you next select to play sound on this channel, assuming it is the same audio clip then it will resume where it left off.
To stop a sound file, select the Stop button. If this piece of music is played again, it will start from the beginning.
As with the Play button, you can right-click on the pause/stop buttons to stop a piece of audio from being previewed.
As with graphics, you can control exactly when the sound will be played using tags. This is useful in case you want to play multiple sound effects in the same text box, or wish to play the sound after a wait command. The syntax is:
<audio [play src="filename or url"|pause|stop] {channel=X} {loop=[Y/N]}>
So for example: <audio play src="myfile.mp3" channel=2 loop=Y> or <audio pause channel=2>
Embedded functions
A text box can just contain simple text, but to add variety to the text being output you can insert variables, functions, references and expressions anywhere in the text.
- Variables are delimited by % symbols, so to display the contents of the "Score" variable you must insert %Score% into the text.
- Item functions are used to display the values of the properties of an item (character, object or location). If you enter the key of an item followed by a full-stop, ADRIFT will display a list of all of the properties of that item from which you can select the one that you want. NOTE: The object key must use exactly the same case as it is displayed in the folder and the top of the item, usually mostly lower-case but with each word starting with a capital letter.
- The % delimited General Functions can be used to get the keys of the current player character (%Player%), the only other character in the same room (%AloneWithChar%) and the NPC that the player is talking to (%ConvCharacter%). There are also useful functions to change the case of some text, capitalise the first character, or display a random number.
- References are only available during the execution of a task. If a task uses an object reference (%object% is used in the general tasks command template) then you can use %object% to provide the key for the functions above.
- Expressions are for more complex equations than can be done with nested functions. They can be used to calculate a mathematical equation, perform text manipulation, or choose between different text to display using an IF statement. An expression inserted into text must be between the symbols <# and #>
When the contents of the text box is displayed on the screen, ADRIFT makes several passes through the text to substitute variables and references with their contents, and the functions and expressions with the result of evaluating them.
This means that if a text variable contains an expression, ADRIFT will replace the variable with its contents in the first pass, then in the second pass it will recognise the inserted expression and execute it.
Substitution occurs in the following order:
- Functions (recursively, including variable substitution)
- Item functions (recursively)
- Expressions (also includes function evaluation)
Drag and Drop
As well as being able to drag and drop pieces of text into the text boxes, you can also drag items from the main ADRIFT window into the boxes too. This provides a quick way of creating functions. So for example, if you drag a character from a list into a text window it will pop up a menu asking which property of the character you wish to display. By selecting one of these entries, the corresponding function for your selection will be inserted into the textbox at the cursor location.
- Open the edit form you wish to place a function on.
- If the edit window does NOT have a button on the windows taskbar, then open the Settings form and tick the "Show all open windows in taskbar" option.
- Move the mouse to the folder window containing the item you wish to use in the function.
- Position the mouse over the item and hold down the left button and "Drag" the item down to the button on the windows taskbar that represents the edit window.
- Wait a moment until the edit window appears again (keeping the mouse button held down).
- Continue dragging the item to the edit window.
- Drag the item to the position in the text that you want to insert the function.
- Release the mouse button.
If we drag a character to a text box, seven choices will be shown in a menu:
If the key of this character is "Susan", then this is what will be inserted into the text:
Menu Selection | Inserted Text |
---|---|
Character Name | Susan.Name |
Character Key | Susan |
Character description | Susan.Description |
List objects held by Character | Susan.Held.List |
List objects worn by Character | Susan.Worn.List |
Location of Character | Susan.CharacterLocation |
Parent of Character | Susan.Parent |
If we drag an object to a text box, seven choices will be shown in the menu:
If the key of this object is "Vase", then this is what will be inserted into the text:
Menu Selection | Inserted Text |
---|---|
Object name | Vase.Name |
Object Key | Vase |
Object Description | Vase.Description |
List objects on | Vase.Children(On) |
List objects inside | Vase.Contents |
List objects on and inside | Vase.Children |
Parent of object | Vase.Parent |
If we drag a location to a text box, five choices will be shown in the menu:
Menu Selection | Inserted Text |
---|---|
Location name | Location1.Name |
Location Key | Location1 |
Display Location | Location1.LongLocationDescription |
Exits from Location | Location1.Exits.List |
Objects at Location | Location1.Objects.List(Indefinite) |
If we drag an event to a text box, three choices will be shown in the menu:
Menu Selection | Inserted Text |
---|---|
Event Length | Event1.Length |
Event Position | Event1.Position |
Event Key | Event1 |
If we drag a Task to a text box, two choices will be shown in the menu:
Menu Selection | Inserted Text |
---|---|
Task Key | Task1 |
Task Completed | %TaskCompleted[Task1]% |
If we drag a Property to a text box, two choices will be shown in the menu:
Menu Selection | Inserted Text |
---|---|
Property Value | <Item Key>.Property1 |
Property Key | Property1 |
If we drag a Variable to a text box, two choices will be shown in the menu:
Menu Selection | Inserted Text |
---|---|
Variable Value | %VariableName% |
Variable Key | Variable1 |
Special Characters
The following symbol characters are used for special purposes, so cant be used freely in text.
< | Less than | This is used for HTML markup tags and to insert comments in the text. The tag finishes at the next > character. To include a < character in text, use the code <!-- This is a comment -->
You have <# IF(Player.Held.Count > 1, "more than one", "zero or one") #> items. |
% | Percent | Two of these are used as delimiters around variable names, functions and references that are embedded in the text and evaluated immediately prior to the text being output. Note that nested % symbols may be placed inside the brackets of a function. The equation finishes and normal text resumes at the next % symbol that is not enclosed by brackets. |
The following special symbols are used inside embedded general functions delimited by % symbols:
( ) | Parentheses | Used to delimit the parameter lists of math and string functions that can be used to calculate parameters for the % function. |
[ ] | Square brackets | When used after a function name these are used to delimit the parameters for the function, [ ] is also used to indicate the index value when used with an array variable. |
, | comma | Separates parameters in a parameter list. |
< > | Less than, greater than | Must be used in pairs inside of other brackets as Adrift does not currently nest different types of delimiter correctly. To include a < character in text, use the code < and for > use > |
HTML markup tags
Many standard HTML markup tags, and some unique Adrift tags, can be inserted into the text to control the formatting of the output.
<br> | (break) Start a new line. |
<img src="filename or url"> | Insert an image into the text (see also the graphics section above). |
<cls> | Clear the screen. |
<b>boldface</b> | Write in boldface. |
<u>underline</u> | underline the text. |
<i>italics</i> | Write in italics. |
<centre>Centralise text</centre> |
|
<right>right justify text</right> | right justify text |
< | Displays the < character |
> | Displays the > character |
&perc; | Displays the % character |
" | Displays the " character |
<font colour="#RRGGBB">text</font> | Allows the text color, font or point size to be changed. The color is specified as three 2-digit hexadecimal numbers in the order red-green-blue. |
<wait N> | (Where N is a number) Wait for N seconds before continuing. ie. <wait 5> pauses the text output to the screen for 5 seconds. |
Press any key<waitkey> | Pauses the text output until player presses a key. Note that you need to provide your own "Press a key to continue" message BEFORE the <waitkey> tag. |
<<< The Standard Library | Main Page | Alternate Descriptions >>> |