-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.py
76 lines (68 loc) · 2.19 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/python
# -*- coding: utf-8 -*-
from saveload import *
class Settings(object):
'''Settings Container
experimental setting control
font = font
content = setting component
'''
def __init__(self, ft):
self.font = ft
self.content = []
self.show = False
self.content.append(Saveload(ft))
def blit(self, screen, imglib, mpos):
mx = mpos[0]
my = mpos[1]
x = 0
y = 0
if mx >= x and mx <= x+50 and my >= y and my <= y+50:
screen.blit(imglib['sey'], (0, 0))
else:
screen.blit(imglib['sen'], (0, 0))
screen.blit(imglib['gear'], (0, 0))
if self.show:
cnt = 1
for se in self.content:
y += 50
ig = []
if mx >= x and mx <= x+50 and my >= y and my <= y+50:
ig.append(imglib['sey'])
else:
ig.append(imglib['sen'])
y += 50
if mx >= x and mx <= x+50 and my >= y and my <= y+50:
ig.append(imglib['sey'])
else:
ig.append(imglib['sen'])
se.blit(screen, ig, ((x, y-50), (x, y)))
cnt += 2
#suppose that each setting has two attribute
#can some one handle this
def click(self, mpos, dpo, cpo, sn):
mx = mpos[0]
my = mpos[1]
x = 0
y = 0
if mx >= x and mx <= x+50 and my >= y and my <= y+50:
self.show = not self.show
return (0, ())
#0 as reverse show
#i could not find a better way to handle settings now
#SL
if self.show:
y += 50
if mx >= x and mx <= x+50 and my >= y and my <= y+50:
self.content[0].save(dpo, cpo, sn)
self.show = False
return (1, ())
#1 as save
y += 50
if mx >= x and mx <= x+50 and my >= y and my <= y+50:
loaded = self.content[0].load()
self.show = False
return (2, loaded)
#2 as load
return (-1, ())
#-1 as NULL