-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefScreen.py
79 lines (70 loc) · 3.39 KB
/
prefScreen.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
77
78
79
try: from cmu_cs3_graphics import *
except: from cmu_graphics import *
from runAppWithScreens import *
from homeScreen import *
from playScreen import *
##################################
# prefScreen
##################################
def prefScreen_onScreenStart(app):
app.largeButtonWidth = 600
app.largeButtonHeight = 75
def prefScreen_redrawAll(app):
drawRect(app.boardLeft, app.boardTop, app.boardWidth, app.boardHeight,
fill=None, border='gainsboro', borderWidth = app.boardBorderWidth)
instructions = [f'contest mode: {app.contestMode}',
f'show legals: {app.showLegals}',
f'edit legals: {app.legalsEditMode}',
f'font color: {app.fontColor}',
f'selection color: {app.selectionColor}',
f'hover color: {app.hoverColor}',
f'number selection color: {app.selectionColorNum}',
f'number hover color: {app.hoverColorNum}',
f'hint color: {app.hintColor}',
f'incorrect color: {app.incorrectColor}',]
toggles = ['c',
'l',
'n',
'f',
's',
'o',
't',
'v',
'h',
'i',]
drawLabel('Press the key on the left to change the setting', app.boardLeft + 40, app.boardTop + 40, size=16, align='left-top', font = 'monospace')
for i in range(len(instructions)):
drawLabel(instructions[i], app.boardLeft + 80, app.boardTop + 60 + i*20, size=16, align='left-top', font = 'monospace')
drawLabel(toggles[i], app.boardLeft + 40, app.boardTop + 60 + i*20, size=16, align='left-top', font = 'monospace')
# drawRightSide(app)
drawLeftSide(app)
def drawRightSide(app): # delete this later
drawRect(app.boardRightSide, app.boardTop, app.buttonWidth, 2*app.buttonHeight, fill = 'lightGrey')
drawLabel(f'{app.mistakes}', app.boardRightSide + app.buttonWidth/2, app.boardTop + app.buttonHeight, fill='black', size = 20, font = 'monospace')
def drawLeftSide(app):
drawRect(app.boardLeftSide, app.boardTop + 200, app.buttonWidth, app.buttonHeight, fill = 'lightGrey')
drawLabel('home(esc)', app.boardLeftSide + app.buttonWidth/2, app.boardTop + 200 + app.buttonHeight/2, fill='black', size = 20, font = 'monospace')
def prefScreen_onMousePress(app, mouseX, mouseY):
# left side
if ((app.boardLeftSide <= mouseX <= app.boardLeftSide + app.buttonWidth) and
(app.boardTop + 200 <= mouseY <= app.boardTop + 200 + app.buttonHeight)):
setActiveScreen('homeScreen')
def prefScreen_onKeyPress(app, key):
if key == 'escape': setActiveScreen('homeScreen')
elif key == 'c':
app.contestMode = not app.contestMode
elif key == 'l':
app.showLegals = not app.showLegals
elif key == 'n':
app.legalsEditMode = not app.legalsEditMode
elif key == 'f':
# app.getTextInput from Term Project Guide
app.fontColor = app.getTextInput('new font color')
elif key == 's':
app.selectionColor = app.getTextInput('new selection color')
elif key == 'o':
app.hoverColor = app.getTextInput('new hover color')
elif key == 'h':
app.hintColor = app.getTextInput('new hint color')
elif key == 'i':
app.fontColor = app.getTextInput('new incorrect color')