35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
import pygame
|
|
|
|
|
|
class FunctionSelector:
|
|
|
|
def __init__(self, resources_dir, game_res, functions):
|
|
self.font = pygame.font.Font(resources_dir + '/fonts/5Pts5.ttf', 10)
|
|
self.functions = functions
|
|
self.max_lines = 6 # Max number of lines to be shown on screen at a time.
|
|
self.offset = 0
|
|
self.game_res = game_res
|
|
|
|
self.selected = 0
|
|
self.max_index = len(self.functions) - 1
|
|
self.selector = pygame.image.load(resources_dir + '/images/dev_menu/selector.png').convert_alpha()
|
|
|
|
def draw(self, surface):
|
|
for i in range(self.max_index + 1):
|
|
text = self.font.render(self.functions[i], False, (0, 0, 0))
|
|
surface.blit(text, (8, (-3 + (i * 6))))
|
|
surface.blit(self.selector, (0, (self.selected * 6)))
|
|
|
|
def scroll_down(self):
|
|
self.selected += 1
|
|
if self.selected > self.max_index:
|
|
self.selected = self.max_index
|
|
|
|
def scroll_up(self):
|
|
self.selected -= 1
|
|
if self.selected < 0:
|
|
self.selected = 0
|
|
|
|
def get_function(self):
|
|
return self.functions[self.selected]
|