Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Apr 7th, 2020 154 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. class GameListUI(object):
  3.  
  4.     @staticmethod
  5.     def from_database(**kwargs):
  6.         all_games = []
  7.         for library_id, library_name in database.queryLibrary():
  8.             games = database.queryOrganicGames(library_id, 'libraryname.name', True)
  9.             all_games.extend(games)
  10.         return GameListUI(game_list=all_games, **kwargs)
  11.  
  12.     def __init__(self, **kwargs):
  13.         self.game_list = kwargs['game_list']
  14.         self.bound_rect = kwargs['bound_rect']
  15.         self.start_x, self.start_y, self.end_x, self.end_y = self.bound_rect
  16.         self.width = self.end_x - self.start_x
  17.         self.height = self.end_y - self.start_y
  18.         self.max_visible_games = 4
  19.         self.horizontal_gap = 10
  20.         self.vertical_gap = 10
  21.         self.selected_index = 0
  22.         self.line_height = (self.height - ((self.max_visible_games-1) * self.vertical_gap)) / self.max_visible_games
  23.  
  24.     def scroll(self, offset):
  25.         self.selected_index += offset
  26.         if self.selected_index < 0:
  27.             self.selected_index = 0
  28.         elif self.selected_index >= len(self.game_list):
  29.             self.selected_index = len(self.game_list) - 1
  30.         print(self.selected_index)
  31.  
  32.     def render(self):
  33.         for curr_index, game in enumerate(self.game_list[self.selected_index:self.selected_index+self.max_visible_games]):
  34.             curr_pos_y = self.start_y + (self.line_height + self.vertical_gap) * curr_index
  35.             picture = pygame.image.load('mame/snap/{}'.format(game['picture']))
  36.             big_pic = pygame.transform.scale(picture, (self.line_height, self.line_height))
  37.             rect_pic = big_pic.get_rect(topleft=(self.start_x, curr_pos_y))
  38.             screen.blit(big_pic, rect_pic)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top