-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFunctions.pde
91 lines (83 loc) · 1.88 KB
/
Functions.pde
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
80
81
82
83
84
85
86
87
88
89
90
91
void drawText() {
p1.fill(1);
p1.textSize(50);
p1.textFont(font);
p2.textFont(font);
p2.fill(1);
p2.textSize(50);
p2.imageMode (CENTER);
for (int i = 0; i < lines; i++)
{
if (i < linesSplit) p1.text(lineStrings[i], 60, ((i+1)*60)+100);
else p2.text(lineStrings[i], 60, ((i+1-linesSplit)*60)+100);
}
}
}
void SaveText()
{
for (int i = 0; i < lines; i++)
{
lineStringsToSave[0] = lineStringsToSave[0] + lineStrings[i];
}
println(lineStringsToSave[0]);
saveStrings("Texts/UserText"+(nameID++)+".txt", lineStringsToSave);
lineStringsToSave[0] = "";
firstPressedKey = false;
}
void Write()
{
if (keyCode == BACKSPACE)
{
if (lineStrings[currentLine].length() > 0)
{
lineStrings[currentLine] = lineStrings[currentLine].substring( 0, lineStrings[currentLine].length()-1 );
currentCharactersToWin++;
} else if (lineStrings[currentLine].length() <= 0 && !safety)
{
if (currentLine > 0)
{
currentLine--;
lineStrings[currentLine] = lineStrings[currentLine].substring( 0, lineStrings[currentLine].length()-1);
currentCharactersToWin++;
}
}
} else if (keyCode == ENTER)
{
if (!safetyKey)
{
currentLine+=1;
safetyKey = true;
safety = true;
}
} else if (keyCode == SHIFT)
{
}
else if (currentLine != lines && !(lineStrings[currentLine].length() > charactersPerLine))
{
lineStrings[currentLine] = lineStrings[currentLine] + str(key);
currentCharactersToWin--;
}
if (lineStrings[currentLine].length() > charactersPerLine)
{
if (currentLine != lines-1) currentLine ++;
safety = true;
}
if (lineStrings[currentLine].length() == 1)
{
safety = false;
}
}
void CalibrateKS() {
switch(key)
{
case '*':
ks.toggleCalibration();
break;
case '-':
ks.load();
break;
case '+':
ks.save();
break;
}
}