Skip to content

Commit 8f0d169

Browse files
committed
Added initial message
1 parent e2dfc6c commit 8f0d169

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/main/Settings.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import java.util.ArrayList;
1212
import java.util.HashMap;
1313

14+
import javax.swing.JOptionPane;
15+
1416
public class Settings {
1517

1618
public static Color bg = new Color(238,238,238);
@@ -33,6 +35,7 @@ public static void init() {
3335

3436
} catch (FileNotFoundException fnfe) {
3537
createNewInitFile();
38+
System.exit(0);
3639
} catch (IOException e) {
3740
e.printStackTrace();
3841
}
@@ -43,11 +46,17 @@ public static void init() {
4346
HashMap<String, String> settingMap = new HashMap<>();
4447

4548
for (String s : lines) {
49+
s = s.replace("+ ", "+").replace(" +", "+");
50+
System.out.println(s);
4651
String[] pair = s.split(":");
4752

4853
// s = keystr: value
4954
// ___ |_[0]|__|[1]|
50-
settingMap.put(pair[0].trim(), pair[1].trim());
55+
try {
56+
settingMap.put(pair[0].trim(), pair[1].trim());
57+
} catch (ArrayIndexOutOfBoundsException e) {
58+
System.err.println("Invalid line: \"" + s + "\"");
59+
}
5160
}
5261

5362
lines.clear();
@@ -122,8 +131,8 @@ private static void createNewInitFile() {
122131
pw.println("// Gestures: (swipe 1 -> 2)");
123132
pw.println("UP -> LEFT: press B");
124133
pw.println("UP -> RIGHT: press E");
125-
pw.println("DOWN -> LEFT: press ALT+TAB");
126-
pw.println("DOWN -> RIGHT: press CTRL+D");
134+
pw.println("DOWN -> LEFT: press ALT + TAB");
135+
pw.println("DOWN -> RIGHT: press CTRL + D");
127136
pw.println("LEFT -> UP: press V");
128137
pw.println("LEFT -> DOWN: press L");
129138
pw.println("RIGHT -> UP: press G");
@@ -153,7 +162,7 @@ private static void createNewInitFile() {
153162
e.printStackTrace();
154163
return;
155164
}
156-
init();
165+
JOptionPane.showMessageDialog(null, "No settings.ini found, creating new one.\nPlease adjust the settings and restart the program.", "Info", JOptionPane.INFORMATION_MESSAGE);
157166

158167
}
159168

0 commit comments

Comments
 (0)