2025-02-23 15:26:53 +01:00
|
|
|
import pygame
|
2025-02-24 22:05:24 +01:00
|
|
|
from colors import *
|
2025-02-24 23:23:05 +01:00
|
|
|
from fonts import *
|
2025-02-28 13:16:39 +01:00
|
|
|
from knobs import Knobs
|
2025-02-25 19:59:56 +01:00
|
|
|
from lozenge_button import LozengeButton
|
2025-02-24 23:23:05 +01:00
|
|
|
|
|
|
|
|
class GuiMain:
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
# pygame setup
|
|
|
|
|
pygame.init()
|
2025-02-28 13:16:39 +01:00
|
|
|
self.screen = pygame.display.set_mode((800, 480))
|
|
|
|
|
#self.screen = pygame.display.set_mode((0,0), pygame.FULLSCREEN)
|
2025-02-25 21:26:16 +01:00
|
|
|
self.screenH = self.screen.get_height()
|
|
|
|
|
self.screenW = self.screen.get_width()
|
2025-02-24 23:23:05 +01:00
|
|
|
|
2025-02-25 19:59:56 +01:00
|
|
|
fx_mode_labels = [
|
2025-02-24 23:23:05 +01:00
|
|
|
'Strings',
|
|
|
|
|
'Beat',
|
|
|
|
|
'L-Loop',
|
|
|
|
|
'R-Loop',
|
|
|
|
|
'Jack',
|
|
|
|
|
'Athmo'
|
|
|
|
|
]
|
|
|
|
|
|
2025-02-25 19:59:56 +01:00
|
|
|
# Create and position the fx_mode buttons
|
|
|
|
|
self.fx_mode_buttons = []
|
|
|
|
|
|
|
|
|
|
for i in range(len(fx_mode_labels)):
|
|
|
|
|
x = self.screenW * 2.5 / 19
|
2025-02-25 22:10:16 +01:00
|
|
|
y = i * self.screenH / 7.5 + 45
|
2025-02-25 19:59:56 +01:00
|
|
|
r_x = self.screenW * 0.35 / 19
|
|
|
|
|
r_y = (self.screenH-20) / 16
|
|
|
|
|
self.fx_mode_buttons.append(LozengeButton(self, fx_mode_labels[i], (x,y), r_x, r_y))
|
|
|
|
|
|
|
|
|
|
self.fx_mode_buttons[0].focused = True
|
|
|
|
|
|
2025-02-28 13:33:11 +01:00
|
|
|
self.knobs = Knobs(self, [0, 0.1, 0.4, 0.9, 0.2, 0.5, 0.8, 0.3])
|
2025-02-24 23:23:05 +01:00
|
|
|
|
|
|
|
|
self.clock = pygame.time.Clock()
|
|
|
|
|
self.running = True
|
|
|
|
|
self.run()
|
|
|
|
|
|
2025-02-25 19:59:56 +01:00
|
|
|
def set_fx_mode(self, mode):
|
|
|
|
|
for b in self.fx_mode_buttons:
|
|
|
|
|
if b.name != mode: b.focused = False
|
|
|
|
|
|
2025-02-24 23:23:05 +01:00
|
|
|
def run(self):
|
|
|
|
|
while self.running:
|
|
|
|
|
# poll for events
|
|
|
|
|
# pygame.QUIT event means the user clicked X to close your window
|
|
|
|
|
for event in pygame.event.get():
|
|
|
|
|
if event.type == pygame.QUIT:
|
|
|
|
|
self.running = False
|
|
|
|
|
|
|
|
|
|
# fill the screen with a color to wipe away anything from last frame
|
|
|
|
|
self.screen.fill("black")
|
|
|
|
|
|
|
|
|
|
# RENDER YOUR GAME HERE
|
|
|
|
|
|
2025-02-28 13:16:39 +01:00
|
|
|
self.knobs.display()
|
2025-02-24 23:23:05 +01:00
|
|
|
|
2025-02-25 19:59:56 +01:00
|
|
|
for button in self.fx_mode_buttons:
|
|
|
|
|
button.display()
|
2025-02-25 22:10:16 +01:00
|
|
|
|
|
|
|
|
for i in range(1,4):
|
|
|
|
|
pygame.draw.line(self.screen, color_primary_dark,
|
|
|
|
|
(self.fx_mode_buttons[i].radius_x*0.5 + 60, self.fx_mode_buttons[i].y),
|
|
|
|
|
(self.fx_mode_buttons[i].x - self.fx_mode_buttons[i].radius_x * 1.5,
|
|
|
|
|
self.fx_mode_buttons[i].y))
|
|
|
|
|
pygame.draw.circle(self.screen, color_primary,
|
|
|
|
|
(40, self.fx_mode_buttons[i].y), 20)
|
|
|
|
|
pygame.draw.rect(self.screen, color_primary,
|
|
|
|
|
((20, self.fx_mode_buttons[0].y-20),(40, 40)))
|
|
|
|
|
|
|
|
|
|
pygame.draw.polygon(self.screen, "white", [(0, self.screenH/2), (self.screenW*3 / 19, self.screenH), (0, self.screenH)])
|
2025-02-24 23:23:05 +01:00
|
|
|
# flip() the display to put your work on screen
|
|
|
|
|
pygame.display.flip()
|
|
|
|
|
|
|
|
|
|
self.clock.tick(60) # limits FPS to 60
|
2025-02-25 20:36:47 +01:00
|
|
|
|
|
|
|
|
# exit when esc is pressed
|
|
|
|
|
for event in pygame.event.get():
|
|
|
|
|
if event.type == pygame.KEYDOWN:
|
|
|
|
|
if event.key == pygame.K_ESCAPE:
|
|
|
|
|
pygame.quit()
|
|
|
|
|
return
|
2025-02-24 23:23:05 +01:00
|
|
|
|
|
|
|
|
pygame.quit()
|
|
|
|
|
|
|
|
|
|
GuiMain()
|