What is the activity menu?
The activity menu is the menu you see when SP is started and it let you choose and start an activity.
The menu is constructed by parsing a XML file. This XML file is located inside the 'icons' directory and is called 'menu.xml'.
The path to this directory is: schoolsplay/data/menu/<theme name>.
The path can differ on your platform so if you can't locate the path consult the schoolsplay website for additional help.
The menus come in two flavors, single layer(SL) and multi layer(ML).
Single layer means that there's one menu window with the activity icons arranged in rows.
Multi layer means that the menu consist of multiple sub menus.
The way to change the menu is to change the XML file 'menu.xml'.
Before you make any changes make sure you've copied the original 'menu.xml' file to a save location as SP won't start if your menu.xml file is corrupted.
In case SP doesn't start after you edited the xml file, copy the 'menu.xml' back and restart SP.
There are two ways to use a custom menu in SP.
- Edit and use the default 'menu.xml' file.
- Create a custom menu xml file.
Edit and use the default menu file.
After you made a backup of the original 'menu.xml' file start a text editor or use a special xml editor
and open 'menu.xml'.
A typical SL menu file would look like this:
(It's a small menu file, just for clarity, your file would be larger)
<?xml version="1.0" encoding="UTF-8"?> <rootmenu file="menu_back.png" ocw="200,205,110"> <menuitem file="memory.icon.png"> <activity>memory</activity> <position>10,10</position> </menuitem> <menuitem file="soundmemory.icon.png"> <activity>soundmemory</activity> <position>100,10</position> </menuitem> </rootmenu>
As you can see the format is very simple and strait forward, XML is plain text so you can edit it with any editor. There's a important thing to remember, you must save it as 'plain text' don't save
it in another format.
The first line is a XML declaration and we don't care about that and move on to the next line.
This line starts with a so called 'node' with the name 'rootmenu'. This node has two attributes called 'file' which holds the menus background picture and 'ocw' which holds a RGB (Red,Green,Blue) value or the path to an image for the bottom menu bar.
The 'file' attribute should contain the path to the background image for the menu. You can change the path to include a custom image.
The 'ocw' attribute is optional and when it's not available a default color will be used. It can have a RGB value or a file path to a image. When a image path is given the image will be used as background.
All the paths given in the XML file are related to the directory in which this XML file is placed.
This means that all images you want to use must be in the same directory as the XML file or that you must use a path relative to this directory or use absolute paths.
In short: don't make your live difficult, put the images inside the same directory as the XML file
and give the image name as the path.
Next are the menu items. Every activity menu item has an entry like:
<menuitem file="memory.icon.png"> <activity>memory</activity> <position>10,10</position> </menuitem>
The first 'menuitem' node has an attribute called 'file' which holds the path to the image file used for the icon on the menu button. You can change the the 'file' attribute to use an other image. The image must not be larger then 72x72 and in the 'portable network graphics' format, 'png'.
You can use other formats but it's not guarantee to work.
The next node is called 'activity' and holds the name of the activity. The name of the activity is the name of the module without it's '.py' extension.
For example the module 'memory.py' provides the activity 'memory', the module 'soundmemory.py' provides the activity 'soundmemory' etc.
The installed modules can be found in /schoolsplay/lib/.
The next node is called 'position' and holds the position of the menu button on the screen.
The position is in the form x,y where 0,0 is the top left hand corner of the activity screen and 800,500 the bottom right hand corner.
Keep in mind that when editing a XML file that a node consist of a open 'tag' and a close 'tag' with in between an optional value. Also you must take care that there are no empty nodes as SP will not run
when the XML is not properly formatted.
So this is correct:
But this is not:
Nor is this:
Multi layer menus.
Multi layer menus are the same as single layer menus with the exception that the menus are wrapped inside a 'submenu' node with an extra 'position' node.
A typical ML menu would look like this:
<?xml version="1.0" encoding="UTF-8"?> <rootmenu file="background.png" ocw="bgstrip.png"> <submenu file="memory.icon.png"> <position>10,10</position> <menuitem file="memory.icon.png"> <activity>memory</activity> <position>10,100</position> </menuitem> <menuitem file="soundmemory.icon.png"> <activity>memorynumbers</activity> <position>100,100</position> </menuitem> </submenu> <submenu file="memorylower.icon.png"> <position>140,10</position> <menuitem file="memorylower.icon.png"> .....
As you can see the format is very similar to the single layer menu. The editing of a ML menu is the same as a SL menu.
Keep in mind that you can't use the same icons for the submenu and menu items, if you do only one will be used and your menu will not display all items.