-
Notifications
You must be signed in to change notification settings - Fork 1
/
GhostRecorder.java
89 lines (72 loc) · 2.29 KB
/
GhostRecorder.java
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
public class GhostRecorder {
private String instructions="";
private int updatesSinceValueChanged=0;
private StickValues stickValues=new StickValues();
private ButtonValues buttonValues=new ButtonValues();
public GhostRecorder() {
}
public void recordLeftStickY(double lsticky) {
stickValues.setValue(StickValues.leftStickY,lsticky);
}
public void recordRightStickY(double rsticky) {
stickValues.setValue(StickValues.rightStickY,rsticky);
}
public void recordLeftStickX(double lstickx) {
stickValues.setValue(StickValues.leftStickX,lstickx);
}
public void recordRightStickX(double rstickx) {
stickValues.setValue(StickValues.rightStickX,rstickx);
}
public void recordButtonX(boolean val) {
buttonValues.setValue(ButtonValues.buttonX,val);
}
public void recordButtonY(boolean val) {
buttonValues.setValue(ButtonValues.buttonY,val);
}
public void recordButtonA(boolean val) {
buttonValues.setValue(ButtonValues.buttonA,val);
}
public void recordButtonB(boolean val) {
buttonValues.setValue(ButtonValues.buttonB,val);
}
public void recordDpadUp(boolean val) {
buttonValues.setValue(ButtonValues.dpadUp,val);
}
public void recordDpadDown(boolean val) {
buttonValues.setValue(ButtonValues.dpadDown,val);
}
public void recordDpadLeft(boolean val) {
buttonValues.setValue(ButtonValues.dpadLeft,val);
}
public void recordDpadRight(boolean val) {
buttonValues.setValue(ButtonValues.dpadRight,val);
}
public String getStringOfChangedVals(ControllerValues vals)
{
String line="";
@SuppressWarnings("unchecked")
ArrayList<String> syms=vals.getSymbolsOfChanged();
for(int i=0;i<syms.size();i++)
{
line+=syms.get(i)+":"+vals.getValue(syms.get(i));
line+=" ";
}
return line;
}
public void update() {
String line=getStringOfChangedVals(stickValues)+getStringOfChangedVals(buttonValues);
if(!line.equals(""))
{
if(updatesSinceValueChanged>0)
{
instructions+=String.valueOf(updatesSinceValueChanged)+" ";
}
instructions+=line;
updatesSinceValueChanged=0;
}
updatesSinceValueChanged+=1;
}
public String getString() {
return instructions+String.valueOf(updatesSinceValueChanged);
}
}