38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
|
|
import pygame
|
||
|
|
import math
|
||
|
|
from colors import *
|
||
|
|
from fonts import *
|
||
|
|
|
||
|
|
class LozengeButton:
|
||
|
|
|
||
|
|
def __init__(self, gui, name, position, radius_x, radius_y):
|
||
|
|
self.gui = gui
|
||
|
|
self.screen = gui.screen
|
||
|
|
self.name = name
|
||
|
|
self.x = position[0]
|
||
|
|
self.y = position[1]
|
||
|
|
self.radius_x = radius_x
|
||
|
|
self.radius_y = radius_y
|
||
|
|
self.focused = False
|
||
|
|
|
||
|
|
def display(self):
|
||
|
|
m1, m2, m3 = pygame.mouse.get_pressed(3)
|
||
|
|
if m1:
|
||
|
|
pos = pygame.mouse.get_pos()
|
||
|
|
if math.sqrt(math.pow(pos[0] - self.x, 2) + math.pow(pos[1] - self.y, 2)) < self.radius_y:
|
||
|
|
self.focused = True
|
||
|
|
self.gui.set_fx_mode(self.name)
|
||
|
|
|
||
|
|
if self.focused:
|
||
|
|
w = 0
|
||
|
|
fx_mode_label = font_helvetica16.render(self.name, False, color_primary)
|
||
|
|
self.screen.blit(fx_mode_label, (self.x + 20, self.y - 8))
|
||
|
|
else:
|
||
|
|
w = 2
|
||
|
|
fx_mode_label = font_helvetica16.render(str(self.name)[0:1], False, color_primary)
|
||
|
|
self.screen.blit(fx_mode_label, (self.x - 4, self.y - 7))
|
||
|
|
pygame.draw.polygon(self.screen, color_primary,
|
||
|
|
[(self.x - self.radius_x, self.y),
|
||
|
|
(self.x, self.y - self.radius_y),
|
||
|
|
(self.x + self.radius_x, self.y),
|
||
|
|
(self.x, self.y + self.radius_y)], w)
|