In memory of Ben “bushing” Byer, who passed away on Monday, February 8th, 2016.

Changes

Jump to navigation Jump to search
770 bytes added ,  00:44, 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, in the main window, you will want to declare it this way:
+
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:
 
<source lang="cpp">
 
<source lang="cpp">
 
GuiImage image(&ImageData);
 
GuiImage image(&ImageData);
Line 448: Line 448:  
Then your image will be put into the image_name_png buffer when it is compiled. Just place your image in the images folder, and the compiler will take care of the rest for you.  
 
Then your image will be put into the image_name_png buffer when it is compiled. Just place your image in the images folder, and the compiler will take care of the rest for you.  
   −
Last, you must append your new image to the GuiWindow you are dealing with. Before doing do, you need to suspend the gui thread, so that you are not making changes to variables while the thread is reading them, and resume the thread after appending:
+
Then, you must append your new image to the GuiWindow you are dealing with. Before doing do, you need to suspend the gui thread, so that you are not making changes to variables while the thread is reading them, and resume the thread after appending:
 
<source lang = "cpp">
 
<source lang = "cpp">
 
HaltGui();
 
HaltGui();
Line 455: Line 455:  
</source>
 
</source>
 
Unless the image is created as a pointer, you must have the & before it to pass the address of your GuiImage to the Append function.
 
Unless the image is created as a pointer, you must have the & before it to pass the address of your GuiImage to the Append function.
 +
 +
Now, unless you want your menu to display for only a frame or two, you are going to want to keep the menu going somehow. Do this by adding a loop in it, usually a while loop that checks to see if your menu variable has changed:
 +
 +
<source lang = "cpp">
 +
while(menu == MENU_NONE){
 +
    VIDEO_WaitVSync();
 +
    //Other code (you will use this mostly with GuiButtons)
 +
}
 +
</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 Delete() function, which takes in a GuiElement:
 +
 +
<source lang = "cpp">
 +
mainWindow->Delete(&image);
 +
</source>
    
So that's all it takes to load an image. Easy, right? Here's an example of the complete proccess:
 
So that's all it takes to load an image. Easy, right? Here's an example of the complete proccess:
309

edits

Navigation menu