MCPcopy Index your code
hub / github.com/ForOhForError/Yet-Another-Magic-Card-Recognizer / init

Method init

src/SavedConfig.java:16–80  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14
15
16 public static void init()
17 {
18 File f = new File("config.txt");
19 if(f.exists())
20 {
21 try {
22 Scanner s = new Scanner(f);
23 while(s.hasNextLine())
24 {
25 String l = s.nextLine();
26 if(l.startsWith("path:"))
27 {
28 PATH = l.substring(5);
29 }
30 if(l.startsWith("debug:"))
31 {
32 String st = l.substring(6).trim().toLowerCase();
33 if(st.equals("true")){
34 DEBUG = true;
35 }
36 else
37 {
38 DEBUG = false;
39 }
40 }
41 }
42 s.close();
43 }
44 catch (FileNotFoundException e)
45 {
46 }
47 }
48 else
49 {
50 JOptionPane.showMessageDialog(null, "Config file not found; doing initial setup.");
51 JOptionPane.showMessageDialog(null, "You will be prompted for a directory to save set data to.");
52 JFileChooser chooser = new JFileChooser();
53 chooser.setCurrentDirectory(new File(System.getProperty("user.dir")));
54 chooser.setDialogTitle("Select a directory to save set data to");
55 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
56 chooser.setAcceptAllFileFilterUsed(false);
57 if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
58 String s = chooser.getSelectedFile().getAbsolutePath();
59 if(!s.endsWith(File.separator))
60 {
61 s = s+File.separator;
62 }
63 PATH = s;
64 DEBUG=false;
65 writeOut();
66 }
67 else {
68 System.exit(0);
69 }
70 }
71
72 if(!DEBUG)
73 {

Callers 1

mainMethod · 0.95

Calls 3

writeOutMethod · 0.95
equalsMethod · 0.80
closeMethod · 0.80

Tested by

no test coverage detected