PinmikPanik/gamedata/objects/menu/optionmenu.py

39 lines
1.7 KiB
Python
Raw Normal View History

2021-09-10 19:22:30 +02:00
import gamedata.objects.menu.menu as menu
import math
2021-09-10 19:22:30 +02:00
class OptionMenu(menu.Menu):
def __init__(self,x,y,game,w=100,h=100):
super().__init__(x,y,game,w,h) # initialise l'objet de base avec les bons arguments
# Les dicos des boutons
def fnRetour(self,game):
2021-09-17 11:03:32 +02:00
game.lib.savesettings(game.datadir,bgm=game.globals["bgmvolume"],sfx=game.globals["sfxvolume"],filename=game.settingsname)
2021-09-10 19:22:30 +02:00
game.scene = game.scenes.main
2021-09-19 22:12:52 +02:00
btnRetour= {"name":"Back","function": fnRetour}
2021-09-10 19:22:30 +02:00
# Initialisation de la grille du menu
self.grid = [
[btnRetour]
]
self.create(self.grid,self.rect)
2021-09-16 08:34:40 +02:00
self.depth = -1
# Getting the number of unlocks ( minus 1 because the base skin isn't really an "unlock" )
unlocks = game.lib.getunlocks(game.globals["highscore"])
currentunlocks = len(unlocks["normal"]+unlocks["specials"])-1
unlocks = game.lib.getunlocks(math.inf)
totalunlocks= len(unlocks["normal"]+unlocks["specials"])-1
text = f"Highscore : {self.game.globals['highscore']} Unlocks : {currentunlocks}/{totalunlocks}"
self.highscore = self.game.fontfile.render(text,False,[255,230,50])
self.highscoreblack= self.game.fontfile.render(text,False,[0,0,0])
2021-09-17 11:19:47 +02:00
2021-09-16 08:34:40 +02:00
def draw(self):
2021-09-17 11:19:47 +02:00
margin = 2
for x in range(-margin,margin+1):
for y in range(-margin,margin+1):
self.game.lib.drawcenter(self.game,self.highscoreblack,self.game.DISPLAY_WIDTH/2+x,self.game.DISPLAY_HEIGHT*0.85+y)
self.game.lib.drawcenter(self.game,self.highscore,self.game.DISPLAY_WIDTH/2,self.game.DISPLAY_HEIGHT*0.85)
2021-09-16 08:34:40 +02:00
self.game.window.blit(self.game.sprite_lib["gui/optionsbg.png"],[0,0])