Changes

567 bytes added ,  00:58, 7 July 2009
Line 427: Line 427:  
but it can be whatever you named your menu function.
 
but it can be whatever you named your menu function.
   −
Now, open menu.cpp. Find the MainMenu function. To load an image, you declare an instance of the GuiImage class. Unless you are in the MainMenu function, you will want to declare it this way:
+
Now, open menu.cpp. Find the MainMenu function. For anything you do in libwiigui, you will want to use "menus" to display anything, except for adding things to the background of your entire GUI, which you will do in the MainMenu function. A menu is simply a function, which should return an int. At the top, declare int menu = MENU_NONE, so if this changes, it will stop your loop later on. At the end of your function, return menu, which will let MainMenu() know which menu to load next.
 +
 
 +
<source lang = "cpp">
 +
int menu_function(){
 +
    int menu = MENU_NONE;
 +
    //everything else
 +
    return menu;
 +
}
 +
</source>
 +
 
 +
To load an image, you declare an instance of the GuiImage class. Unless you are in the MainMenu function, you will want to declare it this way:
 
<source lang="cpp">
 
<source lang="cpp">
 
GuiImage image(&ImageData);
 
GuiImage image(&ImageData);
Line 465: Line 475:  
</source>
 
</source>
   −
Last, you ''must'' remove any GuiElements you have Append()ed in your menu (unless it was declared globally, but you should still remove it) before returning to the MainMenu function, or else the GUI will keep trying to display an image that doesn't exist any more. Use the Remove() function, which takes in a GuiElement:
+
Last, you ''must'' remove any GuiElements you have Append()ed in your menu (unless it was declared globally, but you should still remove it) before returning to the MainMenu function, or else the GUI will keep trying to display an image that doesn't exist any more. Use the Delete() function, which takes in a GuiElement:
    
<source lang = "cpp">
 
<source lang = "cpp">
mainWindow->Remove(&image);
+
mainWindow->Delete(&image);
 
</source>
 
</source>
   Line 630: Line 640:  
     }
 
     }
   −
     mainWindow->Remove(&image);
+
     mainWindow->Delete(&image);
 
     return menu;
 
     return menu;
 
}
 
}
309

edits