Ejemplo n.º 1
1
 @Override
 public void initGui() {
   obsidiFile = new File(System.getProperty("user.dir") + "/ObsidiCode/Test/SimpleMiner.oc");
   this.buttonList.add(
       new GuiButton(
           saveButton, this.width / 2 + 5, this.height / 2 + 125, 100, 20, "Save and Exit"));
   this.buttonList.add(
       new GuiButton(resetButton, this.width / 2 - 105, this.height / 2 + 125, 100, 20, "Reset"));
   loadFile();
   if (!text.toString().contains("_") && text.toString().equals("")) text.append(cursor);
   cursorLocation = text.length() - 1;
   super.initGui();
 }
Ejemplo n.º 2
1
  // Loads any preexisting file. Also sets the RobotName.
  void loadFile() {
    System.out.println();
    if (text.toString().equals("")) {
      try {
        obsidiFileReader = new FileReader(obsidiFile);
        BufferedReader br = new BufferedReader(obsidiFileReader);
        boolean firstLine = true;
        for (String line = br.readLine(); line != null; line = br.readLine()) {
          text.append(line + '\n');
          if (firstLine) {
            robotName = line.replace(":", "");
            firstLine = false;
          }
        }

        obsidiFileReader.close();
      } catch (FileNotFoundException e) {
        ErrorHandling.Error("Could not load file: " + obsidiFile);
      } catch (IOException e) {
        ErrorHandling.Error("Could not open the file; " + e.getMessage());
      }
    }
  }