GUI, Inventory & Menu: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
*>SSH
m (→‎Getting that classical Sierra look for GUIs: tagged as needing update for 2.7)
mNo edit summary
 
(25 intermediate revisions by 10 users not shown)
Line 1: Line 1:
{{deprecated}}
==Getting rid of that big gray status bar at the top==
==Getting rid of that big gray status bar at the top==
''When I test my game, there is this gray box at the very top of the screen that I can't get rid of. I don't want it there. What is it, and how do I get rid of it?''
''When I test my game, there is this gray box at the very top of the screen that I can't get rid of. I don't want it there. What is it, and how do I get rid of it?''
Line 19: Line 21:
''How can I add money into my game? You know, like the character carries around an inventory item that is a coin, and it keeps count of how much money he has...and...er...you know what I mean...! And what about having multiple inventory items! HUH!?''
''How can I add money into my game? You know, like the character carries around an inventory item that is a coin, and it keeps count of how much money he has...and...er...you know what I mean...! And what about having multiple inventory items! HUH!?''


Easy. The character's global inventory variables (such as '''player.inv[34]''', or '''cPlayer.InventoryQuantity[iMoney.ID]''' for V2.7 and newer) are integers and can be used to keep track of how many items (or, in this case, money) the character has.
Easy. The character's global inventory variables (such as '''player.inv[34]''', or '''player.InventoryQuantity[iMoney.ID]''' for V2.7 and newer) are integers and can be used to keep track of how many items (or, in this case, money) the character has.


==Adding score/hotspot info to the big grey status bar==
==Adding score/hotspot info to the big grey status bar==
Line 25: Line 27:


The answer to this question is indeed in the AGS manual ('''help file — "ags.chm"'''), under "'''Editing the GUIs'''". Here is an excerpt from the manual:
The answer to this question is indeed in the AGS manual ('''help file — "ags.chm"'''), under "'''Editing the GUIs'''". Here is an excerpt from the manual:
<blockquote>
'''Interface text'''<br><br>
You can easily display static text on interfaces. For example, the Sierra-style interface displays the score in the status bar.<br>
To add text to a GUI, you add a label. Click the "Add label" button, then drag out a rectangle like you did when adding a button. You can change the text displayed in the label by editing the "Text" property. Notice that the text automatically wraps around to fit inside the rectangle you drew.<br>
As well as typing normal text into the label, you can add some special markers which allow the text to change during the game. The following tokens will be replaced with the relevant values in the game:<br>
*'''@GAMENAME@'''    The game's name, specified on the Game Settings pane
*'''@OVERHOTSPOT@'''  Name of the hotspot which the cursor is over
*'''@SCORE@'''        The player's current score (number only)
*'''@SCORETEXT@'''    The text "Score: X of Y" with the relevant numbers filled in.<br>
*'''@TOTALSCORE@'''  The maximum possible score, specified on the Game Settings pane
'''Example:''' You have @SCORE@ out of @TOTALSCORE@ possible points.<br><br>
The Properties window also allows you to align the text to the left, right, or centre, as well as change its font and colour.</blockquote>
It may also be helpful to use the [[Description Module]].


  '''Interface text'''
==Using a specific inventory item to trigger an action==
  You can easily display static text on interfaces. For example, the Sierra-style
''I need a specific inventory item to trigger an action when interacting it with a hotspot/object/character/other item. So far, I can only see how to set it so that any item can be used.''
  interface displays the score in the status bar.
  To add text to a GUI, you add a label. Click the "Add label" button, then drag out
  a rectangle like you did when adding a button. You can change the text displayed
  in the label by editing the "Text" property. Notice that the text automatically
  wraps around to fit inside the rectangle you drew.
  As well as typing normal text into the label, you can add some special markers which
  allow the text to change during the game. The following tokens will be replaced with
  the relevant values in the game:
  @GAMENAME@    The game's name, specified on the Game Settings pane
  @OVERHOTSPOT@  Name of the hotspot which the cursor is over
  @SCORE@        The player's current score (number only)
  @SCORETEXT@    The text "Score: X of Y" with the relevant numbers filled in.
  @TOTALSCORE@  The maximum possible score, specified on the Game Settings pane
  '''Example:''' You have @SCORE@ out of @TOTALSCORE@ possible points.
  The Properties window also allows you to align the text to the left, right, or
  centre, as well as change its font and colour.


And there you have it.
If you're using the Interaction Editor, choose "'''Conditional - if inventory item is used'''" action under the "'''Use inventory item on (whatever)'''" interaction.


==Using a specific inventory item on a hotspot to trigger an action==
Otherwise, if you're using scripting only, use the following code (in AGS V2.62):
''I need a specific inventory item to trigger an action when interacting it with a hotspot. So far, I can only see is to set it so that any item can be used with the hotspot.''
 
  if (player.activeinv == 31) {
    // Place code here
  }


If you're using the Interaction Editor, choose "'''Conditional - if inventory item is used'''" action under the "'''Use inventory item on hotspot'''" interaction.
This will detect whether the player's current inventory item selected is #31, and if so, the code between the braces is run. Take out the // comments if you want.


Otherwise, if you're using scripting only, use the following code:
In AGS V2.7 and higher, use the following code:


   if (player.activeinv == 31) {
   if (player.ActiveInventory==iItem){
     // Place code here
     // Place code here
   }
   }


This will detect whether the player's current inventory item selected is #31, and if so, the code between the braces is run. Take out the // comments if you want.
This will detect whether the player's current inventory item selected is iItem.
Rather than using the item numbers, AGS now uses '''script O-Names''': usually ''i'' followed by the item name for inventory items(so, if the item is called ''Key'' the script O-Name will be ''iKey''), which are  shown on the 'Inventory Items' window of the editor).


==Customizing graphics of AGS default GUIs; Creating your own GUIs==
==Customizing graphics of AGS default GUIs; Creating your own GUIs==
Line 89: Line 92:


==Creating your own custom inventory==
==Creating your own custom inventory==
''How would I go about creating my own custom inventory GUI? I don't much like the default AGS one. OR, I have a problem creating my own inventory GUI. HELP!''
''How would I go about creating my own custom inventory GUI? I don't much like the default AGS one. OR, I have a problem creating my own inventory GUI. HELP!''


Everything you need to know about custom inventory GUIs can be found in [http://www.bigbluecup.com/yabb/index.php?topic=10946.0 this thread].
Everything you need to know about custom inventory GUIs can be found in [http://www.adventuregamestudio.co.uk/forums/index.php?topic=10946.0 this thread].
 
==Inventory items don't show up==
 
The inventory items won't display if the InvWindow GUI control is smaller than an inventory item slot (40x22 pixels by default).
Enlarge the InvWindow control or decrease its ItemWidth and ItemHeight properties in the GUI editor.


==Getting that classical Sierra look for GUIs==
==Getting that classical Sierra look for GUIs==
Line 132: Line 141:


First off, that setting is deceptively named "'''Foreground colour'''" in the AGS Editor, under GUI Properties. Also remember that AGS treats Color #0 (zero) as transparent, so set the GUI's Foreground Color to "0" to get rid of it, or a different pallette color number to change it.
First off, that setting is deceptively named "'''Foreground colour'''" in the AGS Editor, under GUI Properties. Also remember that AGS treats Color #0 (zero) as transparent, so set the GUI's Foreground Color to "0" to get rid of it, or a different pallette color number to change it.
NOTE: As of AGS V2.7, this setting has been renamed "'''Border Color'''".


==Making your GUI modal==
==Making your GUI modal==
Line 149: Line 160:


==Changing AGS's default speech/narrator dialog boxes to your own==
==Changing AGS's default speech/narrator dialog boxes to your own==
''How would I change AGS's default black-and-white dialog boxes into something more colourful? I want to cusomtize the narrator/speech GUIs!''
''How would I change AGS's default black-and-white dialog boxes into something more colourful? I want to customize the narrator/speech GUIs!''


This is found in the AGS manual, albeit a bit hidden:
This is found in the AGS manual, albeit a bit hidden:
<blockquote>
'''Customized Text Windows'''<br><br>
If you want to add a personal touch to the standard white text-boxes which display all the messages during the game, you can create a border using the GUI Editor.<br>
Create a new GUI, and check the "'''text window'''" box for it. The element will be resized to about 1/4 of the screen, and you will see 8 pictures - one in each corner and one on each side. These are the border graphics. You change the graphic for a corner in the normal way.<br>
In the game, the corner graphics will be placed in the respective corners of the text window, and the side graphics will be repeated along the edge of the window. To tell the game to use your custom text window style, go to the '''General Settings''' pane, and check the "'''Text windows use GUI'''" box. Then, enter the number of the GUI which you used.<br>
You can also set a background picture for the text window. In the GUI editor, simply set a background picture for the GUI element. The graphic you specify will not be tiled or stretched in the game; however, it will be clipped to fit the window. You should use a graphic of at least about 250x80 pixels to make sure that it fills up the whole window.<br>
To set the text colour in the window, simply set the '''Foreground Colour''' of the GUI and that will be used to print the message text in.
</blockquote>
=="Error: InventoryScreen: one or more of the inventory screen graphics have been deleted"==
''Every time I try to open my Inventory GUI I get this error. What's going on here?''
This is most likely to happen if you've started a game using the 'Empty' template. This starts a game with NO existing sprites - which includes the ones needed by the default Inventory GUI. You'll need to import three sprites to be used for the 'Look at', 'Use' and 'OK' buttons. Then, right-click them, select 'Change sprite number ...' and renumber them to 2041, 2042 and 2043 respectively.
==Checking if the player has a certain Inventory Item==
''I want an interaction to happen only when the player has an Inventory Item (like a key to open a door) OR something not to happen when the player has an Item. How do I do that?''
Simply use the [http://www.adventuregamestudio.co.uk/manual/ags49.htm#character.inventoryquantity InventoryQuantity] property, e.g.:
  if (player.InventoryQuantity[iKey.ID] == 0)
    Display("You don't have the key.");
Or:
  if (player.InventoryQuantity[iStolen.ID] != 0)
    Display("You can't go in there carrying Stolen goods.");
If you want to stop the player from taking an Item multiple times (like taking someting out of a drawer), you're better using a variable. If you use InventoryQuantity and the player can lose the Item later in the game, they'll be able to go back and pick it up again.


  '''Customized Text Windows'''
'''Note:'''
  If you want to add a personal touch to the standard white text-boxes which display
* The InventoryQuantity property was introduced in V2.7. Before that, use the ''character[].inv'' array.
  all the messages during the game, you can create a border using the GUI Editor.
  Create a new GUI, and check the "text window" box for it.
  The element will be resized to about 1/4 of the screen, and you will see 8 pictures
  - one in each corner and one on each side. These are the border graphics. You
  change the graphic for a corner in the normal way.
  In the game, the corner graphics will be placed in the respective corners of
  the text window, and the side graphics will be repeated along the edge of the
  window. To tell the game to use your custom text window style, go to the General
  Settings pane, and check the "Text windows use GUI" box. Then, enter the number
  of the GUI which you used.
  You can also set a background picture for the text window. In the GUI editor, simply
  set a background picture for the GUI element. The graphic you specify will not be
  tiled or stretched in the game; however, it will be clipped to fit the window. You
  should use a graphic of at least about 250x80 pixels to make sure that it fills up
  the whole window.
  To set the text colour in the window, simply set the Foreground Colour of the GUI
  and that will be used to print the message text in.


[[Category:The AGS Beginners' FAQ]]
[[Category:Beginner Tutorials]]

Navigation menu