def update(self): self.apply_button = Button((100, 100, 100), settings.WIDTH / 2 - 240, settings.HEIGHT / 2 + self.height / 2 - 60, 220, 50, 'Применить') self.cancel_button = Button((100, 100, 100), settings.WIDTH / 2, settings.HEIGHT / 2 + self.height / 2 - 60, 220, 50, 'Отменить')
class Info: def __init__(self, color, width, height, text=''): pygame.init() self.clock = pygame.time.Clock() self.width = width self.height = height self.text = text self.color = color self.apply_button = None @staticmethod def info_exit(): settings.INFO_LOOP = False def update(self): self.apply_button = Button((100, 100, 100), settings.WIDTH / 2 - 110, settings.HEIGHT / 2 + self.height / 2 - 60, 220, 50, 'Продолжить') def draw(self, win): pygame.draw.rect(win, self.color, (settings.WIDTH / 2 - self.width / 2, settings.HEIGHT / 2 - self.height / 2, self.width, self.height)) if self.text != '': font = pygame.font.SysFont('comicsans', 50) text = font.render(self.text, 1, (0, 0, 0)) win.blit(text, (settings.WIDTH / 2 - text.get_width() / 2, settings.HEIGHT / 2 - self.height / 2 + 20)) def info_loop(self): self.update() check_debug('Info loop', 'EVENT') while settings.INFO_LOOP: for ev in pygame.event.get(): mouse = pygame.mouse.get_pos() if ev.type == pygame.QUIT: self.info_exit() if ev.type == pygame.KEYDOWN: if ev.key == pygame.K_ESCAPE: self.info_exit() if ev.type == pygame.MOUSEBUTTONDOWN: if self.apply_button.check(mouse): self.info_exit() if ev.type == pygame.MOUSEMOTION: if self.apply_button.check(mouse):self.apply_button.color = (120,120,120) else: self.update() self.apply_button.draw(settings.SCREEN) pygame.display.update() self.clock.tick(settings.FPS)
def update(self): self.new_game_button = Button( (100, 100, 100), settings.WIDTH / 2 - 100, settings.HEIGHT / 2 - 110, 240, 50, 'Новая игра') self.setting_button = Button((100, 100, 100), settings.WIDTH / 2 - 100, settings.HEIGHT / 2 - 50, 240, 50, 'Настройки') self.exit_button = Button((100, 100, 100), settings.WIDTH / 2 - 100, settings.HEIGHT / 2 + 30, 240, 50, 'Выйти') self.info_game_button = Button((100, 100, 100), settings.WIDTH - 60, settings.HEIGHT - 60, 50, 50, '!')
def load_preset(self): if not settings.PRESET_LOAD: settings.PRESET_DATA = self.config.setting_load( json_path.PRESET_LIST) self.config.set_preset_params(settings.PRESET_DATA) width = 0 for key in settings.PRESET_LIST: height = 50 for el in settings.PRESET_LIST[key]: self.preset_buttons[key.lower()].append( Button((100, 100, 100), 20 + width, 10 + height, 240, 50, el.split(':')[0])) height += 60 width += 260
def update(self): self.apply_button = Button((100, 100, 100), settings.WIDTH / 2 - 110, settings.HEIGHT / 2 + self.height / 2 - 60, 220, 50, 'Продолжить')
def update(self): self.back_button = Button((100, 100, 100), settings.WIDTH / 2 - 100, settings.HEIGHT - 100, 200, 50, 'Назад') self.fullscreen_button = Button((100, 100, 100), 50, 50, 300, 50, 'Полный экран')
def update(self): self.exit_button = Button((100, 100, 100), settings.WIDTH / 2 - 100, settings.HEIGHT - 70, 240, 50, 'Выйти')
def update(self): self.exit_button = Button((100, 100, 100), 20, settings.HEIGHT - 60, 240, 50, 'Выйти') self.start_button = Button((100, 100, 100), settings.WIDTH - 250, settings.HEIGHT - 60, 240, 50, 'Начать')