SCI Programming.com
Welcome, Guest. Please login or register.
October 18, 2017, 01:53:12 AM
Home  >  Tutorials  >  Chapter 25: Customizing The Menubar
Chapter 25: Customizing The Menubar
About the Menu Bar

Customizing the menubar is very easy. To do so, you simply just need to modify menubar.sc and game.sh. The menubar.sc script contains all the code for setting up the menubar, and handling the items clicked. The game.sh header is where you put the defines for it's item IDs.

Getting Started
First we need to open the the menubar script. Open the game and the Game Explorer will load.

Click on the script folder and the list of scripts in your game will appear on the right, along with a preview of the first script.

Scroll down the list until you see the "MenuBar" script. Double click on it, and the script editor will open up with it.
Creating The Menu
Scroll down the script until you see the TheMenuBar instance. In it's init() method are a bunch of AddMenu() kernel calls. These add the menus to the menubar. The AddMenu calls take two parameters. The first is the menu caption string, the second is the items string. It is quite straight forward. For more detailed information on it, you can see the section in the SCI Studio Help File.

Each menu you add has it's own ID. The first menu item of the first menu has the ID of $0101. The second menu item of the first menu has the ID of $0102". The first menu item of the second menu has the ID of $0201, and so on. It is good practice to create defines for these in game.sh so they can be accessed by name.

Handling The Menu

Scroll down TheMenuBar instance until you find the handleEvent() method. This is where you can check which item had been clicked and perform the appropriate task.

In game.sh, item $0101 is defined as MENU_ABOUT, item $0102 is defined as MENU_HELP, and so on. It's simply a big switch statement. Create cases for all the items you add, and you're done!

It's as simple as that! You now know how to make a complete SCI game. It is recommended that you read over this tutorial once more. Much of the stuff which may have confused you before will be much clearer. Continue on for information on additional resources for further SCI learning.

Congratulations!
<< Prev Back to Tutorials Next >>

The SCI Programming Community
Copyright © 2007 - 2017, All Rights Reserved.