-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKeyLayout.java
executable file
·167 lines (156 loc) · 4.94 KB
/
KeyLayout.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/**
* This class loads, saves, jhold keylayout info
*
* @author (Pavithran Pathmarajah)
* @version (27 May 2014)
*/
import java.io.*;
import java.util.*;
public class KeyLayout
{
// the keys in the program
int leftKey;
int rightKey;
int downKey;
int spaceKey;
int xKey;
int zKey;
int escKey;
int cKey;
int aKey;
int sKey;
String layoutName;
public KeyLayout()
{
//standard keys
leftKey=37;
rightKey=39;
downKey=40;
spaceKey=32;
xKey=88;
zKey=90;
escKey=27;
cKey=67;
aKey=65;
sKey=83;
layoutName="Standard";
}
//Reference GameType
public static void readLayouts(ArrayList<KeyLayout> layouts)
{
try
{
KeyLayout fileRead;
File fileModes=new File("RunFiles/KeyLayouts.txt");
Scanner in=new Scanner(fileModes);
while(in.hasNext())
{
System.out.println("yo");
fileRead=new KeyLayout();
String tmp;
tmp= in.next();
tmp= in.next();
fileRead.layoutName=in.next();
tmp= in.next();
tmp= in.next();
System.out.println(tmp);
fileRead.leftKey=Integer.parseInt(tmp);
tmp= in.next();
tmp= in.next();
fileRead.rightKey=Integer.parseInt(tmp);
tmp= in.next();
tmp= in.next();
fileRead.downKey=Integer.parseInt(tmp);
tmp= in.next();
tmp= in.next();
fileRead.spaceKey=Integer.parseInt(tmp);
tmp= in.next();
tmp= in.next();
fileRead.xKey=Integer.parseInt(tmp);
tmp= in.next();
tmp= in.next();
fileRead.zKey=Integer.parseInt(tmp);
tmp= in.next();
tmp= in.next();
fileRead.escKey=Integer.parseInt(tmp);
tmp= in.next();
tmp= in.next();
fileRead.cKey=Integer.parseInt(tmp);
tmp= in.next();
tmp= in.next();
fileRead.aKey=Integer.parseInt(tmp);
tmp= in.next();
tmp= in.next();
fileRead.sKey=Integer.parseInt(tmp);
tmp= in.next();
layouts.add(fileRead);
}
}
catch(IOException e)
{
}
}
public static void saveLayouts(ArrayList<KeyLayout> layouts)
{
try
{
File fileOut=new File("RunFiles/KeyLayouts.txt");
PrintWriter toFile=new PrintWriter(new FileWriter(fileOut,false));
KeyLayout tmp;
for (int i=0;i<layouts.size();i++)
{
tmp=layouts.get(i);
toFile.println("------------------");
toFile.println("KeyLayoutName: "+ tmp.layoutName);
toFile.println("leftKey: "+ tmp.leftKey);
toFile.println("rightKey: "+ tmp.rightKey);
toFile.println("downKey: "+ tmp.downKey);
toFile.println("spaceKey: "+ tmp.spaceKey);
toFile.println("xKey: "+ tmp.xKey);
toFile.println("zKey: "+ tmp.zKey);
toFile.println("escKey: "+ tmp.escKey);
toFile.println("cKey: "+ tmp.cKey);
toFile.println("aKey: "+ tmp.aKey);
toFile.println("sKey: "+ tmp.sKey);
toFile.println("------------------");
}
toFile.close();
fileOut=null;
}
catch(FileNotFoundException e)
{
}
catch(IOException e)
{
}
}
public void save()
{
try
{
File fileOut=new File("RunFiles/KeyLayouts.txt");
PrintWriter toFile=new PrintWriter(new FileWriter(fileOut,true));
toFile.println("------------------");
toFile.println("KeyLayoutName: "+ layoutName);
toFile.println("leftKey: "+ leftKey);
toFile.println("rightKey: "+ rightKey);
toFile.println("downKey: "+ downKey);
toFile.println("spaceKey: "+ spaceKey);
toFile.println("xKey: "+ xKey);
toFile.println("zKey: "+ zKey);
toFile.println("escKey: "+ escKey);
toFile.println("cKey: "+ cKey);
toFile.println("aKey: "+ aKey);
toFile.println("sKey: "+ sKey);
toFile.println("------------------");
toFile.close();
fileOut=null;
}
catch(FileNotFoundException e)
{
}
catch(IOException e)
{
}
}
}