3
# This code is part of the 'enjuewemela' game
5
# Main author: Facundo Batista
6
# Code, bug tracker, etc:
7
# https://launchpad.net/enjuewemela/
9
"""High scores window."""
14
from xdg.BaseDirectory import xdg_data_home
16
from cocos import layer
17
from cocos.director import director
21
WHITE = (255, 255, 255, 255)
23
class HighScores(layer.Layer):
24
"""Show the high scores."""
27
('classic', 'Classic', (255, 0, 0, 255)),
28
('rush', 'Rush', (0, 0, 255, 255)),
32
super(HighScores, self).__init__()
34
f_varbl = utils.FontWriter(self, "Sansation")
35
f_fixed = utils.FontWriter(self, "SV Basic Manual")
37
fname = os.path.join(xdg_data_home, 'enjuewemela.hs')
38
if not os.path.exists(fname):
42
with open(fname, 'rb') as fh:
43
all_hs = pickle.load(fh)
45
print "WARNING: problems with the high score filename:", e
48
# some info for the initial drawing
49
win_w, win_h = director.get_window_size()
54
cant_paneles = len(self._styles)
55
cant_separ = cant_paneles - 1
56
panel_width = (win_w - border * 2 - separ * cant_separ) // cant_paneles
57
alto_panel = win_h - border * 2
60
for i in range(cant_paneles):
62
b = utils.Base(100, x, border, panel_width, alto_panel)
64
x += panel_width + separ
66
for i, (style, title, color) in enumerate(self._styles):
67
# location of panel border
68
panel_left = border + (panel_width + separ) * i
69
panel_center = panel_left + panel_width // 2
70
panel_right = panel_left + panel_width
73
y = win_h - border - 40
74
f_varbl(title, (panel_center, y), 40, "center", color=color)
77
for name, score in all_hs[style][:10]:
78
f_varbl(name, (panel_left+10, y), 20, "left", color=WHITE)
80
f_fixed(s, (panel_right-10, y), 20, "right", color=WHITE)