-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBrainstormsHUD.java
More file actions
83 lines (73 loc) · 1.47 KB
/
BrainstormsHUD.java
File metadata and controls
83 lines (73 loc) · 1.47 KB
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
import processing.core.PApplet;
public class BrainstormsHUD extends HUDObject
{
private static final int NO_FOCUS = 0;
private static final int TEXT_FOCUS = 1;
private String brainstormName;
private ObjectProvider objects;
private int mode;
BrainstormsHUD(PApplet context, ObjectProvider objects)
{
this.context=context;
this.objects = objects;
this.name = "Brainstorms";
this.active = true;
this.setPosition(context.width/2, context.height/2, 0);
this.mode = NO_FOCUS;
this.brainstormName = "";
}
public void render()
{
}
public void focus()
{
mode = TEXT_FOCUS;
}
public boolean inFocus()
{
if(mode == NO_FOCUS)
{
return false;
}
else
{
return true;
}
}
public void charKeyStroke(char key)
{
if(inFocus())
{
if((key >= ' ' && key <= '~'))
{
brainstormName += key;
}
}
}
public void keyStroke(int keyCode)
{
if(inFocus() && brainstormName != "" && keyCode == 10)
{
objects.addTextObject(brainstormName);
brainstormName = "";
mode = NO_FOCUS;
}
if(inFocus() && keyCode == 8)
{
if(brainstormName.length() > 0)
brainstormName = brainstormName.substring(0, brainstormName.length() - 1);
}
}
public boolean hit(int x, int y)
{
if(inFocus())
{
mode = NO_FOCUS;
return true;
}
else
{
return false;
}
}
}