data/menugui.py (view raw)
1"""
2This class controls all the GUI for the player
3menu screen.
4"""
5import pygame as pg
6from . import setup
7from . import constants as c
8
9
10
11class MenuGui(object):
12 def __init__(self, inventory):
13 self.font = pg.font.Font(setup.FONTS['Fixedsys500c'], 22)
14 self.inventory = inventory
15 self.gold_box = self.make_gold_box()
16 self.stat_box = self.make_stat_box()
17 self.selection_box = self.make_selection_box()
18 self.box_group = self.make_box_group()
19
20
21 def make_gold_box(self):
22 """Makes the box that displays gold"""
23 image = setup.GFX['goldbox']
24 rect = image.get_rect(left=10, top=234)
25
26 surface = pg.Surface(rect.size)
27 surface.set_colorkey(c.BLACK)
28 surface.blit(image, (0, 0))
29
30 text = "Gold: " + str(self.inventory['gold'])
31 text_render = self.font.render(text, True, c.NEAR_BLACK)
32 text_rect = text_render.get_rect(x=80, y=60)
33 surface.blit(text_render, text_rect)
34
35 sprite = pg.sprite.Sprite()
36 sprite.image = surface
37 sprite.rect = rect
38
39 return sprite
40
41
42 def make_stat_box(self):
43 """Make the box for displaying stats and items"""
44 image = setup.GFX['playerstatsbox']
45 rect = image.get_rect(left=285, top=35)
46
47 surface = pg.Surface(rect.size)
48 surface.set_colorkey(c.BLACK)
49 surface.blit(image, (0,0))
50
51 sprite = pg.sprite.Sprite()
52 sprite.image = surface
53 sprite.rect = rect
54
55 return sprite
56
57
58 def make_selection_box(self):
59 """Make the menu with selection options"""
60 image = setup.GFX['goldbox']
61 rect = image.get_rect(left=10, top=410)
62
63 surface = pg.Surface(rect.size)
64 surface.set_colorkey(c.BLACK)
65 surface.blit(image, (0, 0))
66
67 sprite = pg.sprite.Sprite()
68 sprite.image = surface
69 sprite.rect = rect
70
71 return sprite
72
73
74 def make_box_group(self):
75 """Make the sprite group for each GUI box"""
76 return pg.sprite.Group(self.gold_box,
77 self.stat_box,
78 self.selection_box)
79
80 def update(self, keys):
81 pass
82
83 def draw(self, surface):
84 self.box_group.draw(surface)