In addition, RF2 utilizes some important features of Python. One of which is the List.
Here is how the buttons are loaded onto the main page:
Code: Select all
self.buttonnames = ['newgame', 'loadgame', 'savegame', 'multiplayer', 'options', 'credits', 'quitmain']
self.buttons = []
for button in self.buttonnames:
try:
self.buttons.append(menuelementbutton.loadbutton(self.menuini, self.bitmapdirectory, self.designoffset, button))
except:
pass
Code: Select all
self.buttonnames = ['newgame', 'loadgame', 'savegame', 'multiplayer', 'options', 'credits', 'quitmain'] # Make a list of all the fields containing buttons for the main page - can be used later to get named buttons - search the list for neagame, and you know it's index is the index of the button itself in the buttons list, etc.
self.buttons = [] # Make an empty list to hold all buttons on this page
for button in self.buttonnames: # Go through all the names of the buttons
try: #Try to:
self.buttons.append(menuelementbutton.loadbutton(self.menuini, self.bitmapdirectory, self.designoffset, button)) # Load the button in question from menu.ini, and add it to the list
except: # If the button could not be found
pass # Do nothing - no error if a button is missing