def add_button(self, button_text, x, y, w, h, ic, ac, action=None): button_rect = pygame.Rect(x,y,w,h) button_surface = pygame.Surface((w,h)) self.ui_list.append({'title':button_text, 'type':'button', 'ac':ac, 'ic':ic, 'action':action, 'rectangle':button_rect}) textSurf, textRect = Text.text_objects(button_text, constants.smallText, constants.BLACK) textRect.center = ( (x+(w/2)), (y+(h/2)) ) self.ui_list.append({'title':button_text,'type':'button_text','surface':textSurf, 'rectangle':textRect})
def draw_menu(self): menu = [] #add the menu options for x in range(len(self.level_list)): text = self.level_list[x] TextSurf, TextRect = Text.text_objects(text, constants.menuText, constants.WHITE) TextRect.center = ((constants.DWIDTH / 4), (100+(x*50))) menu.append({'title': text, 'type':'menu', 'surface':TextSurf, 'rectangle': TextRect}) #add the menu icon #IconRect = Rect((constants.DWIDTH*.75), (constants.DHEIGHT/4), 100, 100) #menu.append({'type':'icon', 'title':'Level_Icon', 'rectangle':IconRect}) return menu
def add_title(self, title): TextSurf, TextRect = Text.text_objects(title, constants.largeText, constants.WHITE) TextRect.center = ((constants.DWIDTH / 2), ((constants.DHEIGHT / 2) - 100)) self.ui_list.append({'title':title, 'type': 'text','surface':TextSurf,'rectangle':TextRect})