assigned all of them a easier and more understandable key phrase or key word added the key word dictionary in classes.py Signed-off-by: SpagettiFisch <63868515+SpagettiFisch@users.noreply.github.com>
73 lines
No EOL
2.5 KiB
Python
73 lines
No EOL
2.5 KiB
Python
import pygame
|
|
|
|
pygame.font.init()
|
|
fonts = {
|
|
'medieval': 'medieval.ttf',
|
|
'minecraft': 'Minecraft Evenings.otf',
|
|
'3dpixel': '3D-Pixel.ttf',
|
|
'8bit': '8bitlim.ttf',
|
|
'8bito': '8blimro.ttf',
|
|
'arcade': 'ARCADECLASSIC.ttf',
|
|
'modern_game': 'astron boy video.otf',
|
|
'modern': 'astron boy.otf',
|
|
'wonder': 'Beyond Wonderland.ttf',
|
|
'curved': 'Digitag.ttf',
|
|
'simple': 'DisposableDroidBB.ttf',
|
|
'rounded': 'dpcomic.ttf',
|
|
'playfull': 'Endalian Script.ttf',
|
|
'blocky': 'FREAKSOFNATURE.ttf',
|
|
'catchy': 'Future TimeSplitters.otf',
|
|
'simple_wide': 'Halo3.ttf',
|
|
'simple_fat': 'INVASION2000.ttf',
|
|
'very_gamy': 'ka1.ttf',
|
|
'simple_round': 'Karma Suture.otf',
|
|
'mono': 'manaspc.ttf',
|
|
'damaged': 'Merchant Copy.ttf',
|
|
'big_natural': 'MorialCitadel.TTF',
|
|
'spacy': 'nasalization-rg.otf',
|
|
'sci-fi': 'neuropol.otf',
|
|
'hollow_big_edge': 'papercut.ttf',
|
|
'space_shuttle': 'pdark.ttf',
|
|
'thin': 'PixelFJVerdana12pt.ttf',
|
|
'random': 'Seattle Avenue.ttf',
|
|
'pixel': 'yoster.ttf'
|
|
}
|
|
|
|
class Button():
|
|
def __init__(self, x, y, width, height, font, buttonText='Button', onclickFunction=None, onePress=False):
|
|
font = pygame.font.Font(f'fonts/{fonts[font]}', 48)
|
|
self.x = x
|
|
self.y = y
|
|
self.width = width
|
|
self.height = height
|
|
self.onclickFunction = onclickFunction
|
|
self.onePress = onePress
|
|
self.alreadyPressed = False
|
|
|
|
with open('art/textbox.png', 'r') as tb:
|
|
self.box = pygame.image.load(tb)
|
|
self.box = pygame.transform.scale(self.box, (width, height))
|
|
|
|
|
|
self.buttonRect = pygame.Rect(self.x, self.y, self.width, self.height)
|
|
|
|
self.buttonSurf = font.render(buttonText, True, '#baab80')
|
|
|
|
def process(self, screen):
|
|
mousePos = pygame.mouse.get_pos()
|
|
if self.buttonRect.collidepoint(mousePos):
|
|
#self.buttonSurface.fill(self.fillColors['hover'])
|
|
if pygame.mouse.get_pressed(num_buttons=3)[0]:
|
|
#self.buttonSurface.fill(self.fillColors['pressed'])
|
|
if self.onePress:
|
|
self.onclickFunction()
|
|
elif not self.alreadyPressed:
|
|
self.onclickFunction()
|
|
self.alreadyPressed = True
|
|
else:
|
|
self.alreadyPressed = False
|
|
self.box.blit(self.buttonSurf, [
|
|
self.buttonRect.width/2 - self.buttonSurf.get_rect().width/2,
|
|
self.buttonRect.height/2 - self.buttonSurf.get_rect().height/2
|
|
])
|
|
screen.blit(self.box, self.buttonRect) |